1d03c0883SXin LI /* 2d03c0883SXin LI * Redistribution and use in source and binary forms, with or without 3d03c0883SXin LI * modification, are permitted provided that: (1) source code 4d03c0883SXin LI * distributions retain the above copyright notice and this paragraph 5d03c0883SXin LI * in its entirety, and (2) distributions including binary code include 6d03c0883SXin LI * the above copyright notice and this paragraph in its entirety in 7d03c0883SXin LI * the documentation or other materials provided with the distribution. 8d03c0883SXin LI * THIS SOFTWARE IS PROVIDED ``AS IS'' AND 9d03c0883SXin LI * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT 10d03c0883SXin LI * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 11d03c0883SXin LI * FOR A PARTICULAR PURPOSE. 12d03c0883SXin LI * 13d03c0883SXin LI * Original code by Francesco Fondelli (francesco dot fondelli, gmail dot com) 14d03c0883SXin LI */ 15d03c0883SXin LI 163340d773SGleb Smirnoff /* \summary: Overlay Transport Virtualization (OTV) printer */ 173340d773SGleb Smirnoff 183340d773SGleb Smirnoff /* specification: draft-hasmit-otv-04 */ 193340d773SGleb Smirnoff 20*ee67461eSJoseph Mingrone #include <config.h> 21d03c0883SXin LI 22*ee67461eSJoseph Mingrone #include "netdissect-stdinc.h" 23d03c0883SXin LI 24*ee67461eSJoseph Mingrone #define ND_LONGJMP_FROM_TCHECK 253340d773SGleb Smirnoff #include "netdissect.h" 26d03c0883SXin LI #include "extract.h" 27d03c0883SXin LI 28*ee67461eSJoseph Mingrone #define OTV_HDR_LEN 8 29*ee67461eSJoseph Mingrone 30d03c0883SXin LI /* 31d03c0883SXin LI * OTV header, draft-hasmit-otv-04 32d03c0883SXin LI * 33d03c0883SXin LI * 0 1 2 3 34d03c0883SXin LI * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 35d03c0883SXin LI * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36d03c0883SXin LI * |R|R|R|R|I|R|R|R| Overlay ID | 37d03c0883SXin LI * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 38d03c0883SXin LI * | Instance ID | Reserved | 39d03c0883SXin LI * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40d03c0883SXin LI */ 41d03c0883SXin LI 42d03c0883SXin LI void 433c602fabSXin LI otv_print(netdissect_options *ndo, const u_char *bp, u_int len) 44d03c0883SXin LI { 453c602fabSXin LI uint8_t flags; 46d03c0883SXin LI 47*ee67461eSJoseph Mingrone ndo->ndo_protocol = "otv"; 48*ee67461eSJoseph Mingrone ND_PRINT("OTV, "); 49*ee67461eSJoseph Mingrone if (len < OTV_HDR_LEN) { 50*ee67461eSJoseph Mingrone ND_PRINT("[length %u < %u]", len, OTV_HDR_LEN); 51*ee67461eSJoseph Mingrone goto invalid; 52*ee67461eSJoseph Mingrone } 53d03c0883SXin LI 54*ee67461eSJoseph Mingrone flags = GET_U_1(bp); 55*ee67461eSJoseph Mingrone ND_PRINT("flags [%s] (0x%02x), ", flags & 0x08 ? "I" : ".", flags); 563340d773SGleb Smirnoff bp += 1; 573340d773SGleb Smirnoff 58*ee67461eSJoseph Mingrone ND_PRINT("overlay %u, ", GET_BE_U_3(bp)); 593340d773SGleb Smirnoff bp += 3; 603340d773SGleb Smirnoff 61*ee67461eSJoseph Mingrone ND_PRINT("instance %u\n", GET_BE_U_3(bp)); 623340d773SGleb Smirnoff bp += 3; 633340d773SGleb Smirnoff 643340d773SGleb Smirnoff /* Reserved */ 65*ee67461eSJoseph Mingrone ND_TCHECK_1(bp); 663340d773SGleb Smirnoff bp += 1; 673340d773SGleb Smirnoff 68*ee67461eSJoseph Mingrone ether_print(ndo, bp, len - OTV_HDR_LEN, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL); 693340d773SGleb Smirnoff return; 703340d773SGleb Smirnoff 71*ee67461eSJoseph Mingrone invalid: 72*ee67461eSJoseph Mingrone nd_print_invalid(ndo); 73*ee67461eSJoseph Mingrone ND_TCHECK_LEN(bp, len); 74d03c0883SXin LI } 75