1026d7285Schristos /* 2026d7285Schristos * Redistribution and use in source and binary forms, with or without 3026d7285Schristos * modification, are permitted provided that: (1) source code 4026d7285Schristos * distributions retain the above copyright notice and this paragraph 5026d7285Schristos * in its entirety, and (2) distributions including binary code include 6026d7285Schristos * the above copyright notice and this paragraph in its entirety in 7026d7285Schristos * the documentation or other materials provided with the distribution. 8026d7285Schristos * THIS SOFTWARE IS PROVIDED ``AS IS'' AND 9026d7285Schristos * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT 10026d7285Schristos * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 11026d7285Schristos * FOR A PARTICULAR PURPOSE. 12026d7285Schristos * 13026d7285Schristos * Original code by Francesco Fondelli (francesco dot fondelli, gmail dot com) 14026d7285Schristos */ 15026d7285Schristos 16fdccd7e4Schristos #include <sys/cdefs.h> 17fdccd7e4Schristos #ifndef lint 18*26ba0b50Schristos __RCSID("$NetBSD: print-otv.c,v 1.5 2024/09/02 16:15:32 christos Exp $"); 19fdccd7e4Schristos #endif 20fdccd7e4Schristos 21dc860a36Sspz /* \summary: Overlay Transport Virtualization (OTV) printer */ 22dc860a36Sspz 23dc860a36Sspz /* specification: draft-hasmit-otv-04 */ 24dc860a36Sspz 25c74ad251Schristos #include <config.h> 26026d7285Schristos 27c74ad251Schristos #include "netdissect-stdinc.h" 28026d7285Schristos 29c74ad251Schristos #define ND_LONGJMP_FROM_TCHECK 30784088dfSchristos #include "netdissect.h" 31026d7285Schristos #include "extract.h" 32026d7285Schristos 33c74ad251Schristos #define OTV_HDR_LEN 8 34c74ad251Schristos 35026d7285Schristos /* 36026d7285Schristos * OTV header, draft-hasmit-otv-04 37026d7285Schristos * 38026d7285Schristos * 0 1 2 3 39026d7285Schristos * 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 40026d7285Schristos * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41026d7285Schristos * |R|R|R|R|I|R|R|R| Overlay ID | 42026d7285Schristos * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 43026d7285Schristos * | Instance ID | Reserved | 44026d7285Schristos * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 45026d7285Schristos */ 46026d7285Schristos 47026d7285Schristos void 48c47fd378Schristos otv_print(netdissect_options *ndo, const u_char *bp, u_int len) 49026d7285Schristos { 50c47fd378Schristos uint8_t flags; 51026d7285Schristos 52c74ad251Schristos ndo->ndo_protocol = "otv"; 53c74ad251Schristos ND_PRINT("OTV, "); 54c74ad251Schristos if (len < OTV_HDR_LEN) { 55c74ad251Schristos ND_PRINT("[length %u < %u]", len, OTV_HDR_LEN); 56c74ad251Schristos goto invalid; 57c74ad251Schristos } 58026d7285Schristos 59c74ad251Schristos flags = GET_U_1(bp); 60c74ad251Schristos ND_PRINT("flags [%s] (0x%02x), ", flags & 0x08 ? "I" : ".", flags); 61dc860a36Sspz bp += 1; 62dc860a36Sspz 63c74ad251Schristos ND_PRINT("overlay %u, ", GET_BE_U_3(bp)); 64dc860a36Sspz bp += 3; 65dc860a36Sspz 66c74ad251Schristos ND_PRINT("instance %u\n", GET_BE_U_3(bp)); 67dc860a36Sspz bp += 3; 68dc860a36Sspz 69dc860a36Sspz /* Reserved */ 70c74ad251Schristos ND_TCHECK_1(bp); 71dc860a36Sspz bp += 1; 72dc860a36Sspz 73c74ad251Schristos ether_print(ndo, bp, len - OTV_HDR_LEN, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL); 74dc860a36Sspz return; 75dc860a36Sspz 76c74ad251Schristos invalid: 77c74ad251Schristos nd_print_invalid(ndo); 78c74ad251Schristos ND_TCHECK_LEN(bp, len); 79026d7285Schristos } 80