1 /* 2 * Redistribution and use in source and binary forms, with or without 3 * modification, are permitted provided that: (1) source code 4 * distributions retain the above copyright notice and this paragraph 5 * in its entirety, and (2) distributions including binary code include 6 * the above copyright notice and this paragraph in its entirety in 7 * the documentation or other materials provided with the distribution. 8 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND 9 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT 10 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 11 * FOR A PARTICULAR PURPOSE. 12 * 13 * Original code by Francesco Fondelli (francesco dot fondelli, gmail dot com) 14 */ 15 16 #include <sys/cdefs.h> 17 #ifndef lint 18 __RCSID("$NetBSD: print-otv.c,v 1.3 2017/02/05 04:05:05 spz Exp $"); 19 #endif 20 21 /* \summary: Overlay Transport Virtualization (OTV) printer */ 22 23 /* specification: draft-hasmit-otv-04 */ 24 25 #ifdef HAVE_CONFIG_H 26 #include "config.h" 27 #endif 28 29 #include <netdissect-stdinc.h> 30 31 #include "netdissect.h" 32 #include "extract.h" 33 34 /* 35 * OTV header, draft-hasmit-otv-04 36 * 37 * 0 1 2 3 38 * 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 39 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 * |R|R|R|R|I|R|R|R| Overlay ID | 41 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 * | Instance ID | Reserved | 43 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 44 */ 45 46 void 47 otv_print(netdissect_options *ndo, const u_char *bp, u_int len) 48 { 49 uint8_t flags; 50 51 ND_PRINT((ndo, "OTV, ")); 52 if (len < 8) 53 goto trunc; 54 55 ND_TCHECK(*bp); 56 flags = *bp; 57 ND_PRINT((ndo, "flags [%s] (0x%02x), ", flags & 0x08 ? "I" : ".", flags)); 58 bp += 1; 59 60 ND_TCHECK2(*bp, 3); 61 ND_PRINT((ndo, "overlay %u, ", EXTRACT_24BITS(bp))); 62 bp += 3; 63 64 ND_TCHECK2(*bp, 3); 65 ND_PRINT((ndo, "instance %u\n", EXTRACT_24BITS(bp))); 66 bp += 3; 67 68 /* Reserved */ 69 ND_TCHECK(*bp); 70 bp += 1; 71 72 ether_print(ndo, bp, len - 8, ndo->ndo_snapend - bp, NULL, NULL); 73 return; 74 75 trunc: 76 ND_PRINT((ndo, " [|OTV]")); 77 } 78