Changeset View
Changeset View
Standalone View
Standalone View
head/contrib/tcpdump/print-babel.c
Show All 40 Lines | |||||
#include "extract.h" | #include "extract.h" | ||||
static const char tstr[] = "[|babel]"; | static const char tstr[] = "[|babel]"; | ||||
static void babel_print_v2(netdissect_options *, const u_char *cp, u_int length); | static void babel_print_v2(netdissect_options *, const u_char *cp, u_int length); | ||||
void | void | ||||
babel_print(netdissect_options *ndo, | babel_print(netdissect_options *ndo, | ||||
const u_char *cp, u_int length) { | const u_char *cp, u_int length) | ||||
{ | |||||
ND_PRINT((ndo, "babel")); | ND_PRINT((ndo, "babel")); | ||||
ND_TCHECK2(*cp, 4); | ND_TCHECK2(*cp, 4); | ||||
if(cp[0] != 42) { | if(cp[0] != 42) { | ||||
ND_PRINT((ndo, " malformed header")); | ND_PRINT((ndo, " malformed header")); | ||||
return; | return; | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 207 Lines • ▼ Show 20 Lines | |||||
* Diversity sub-TLV is not the same as a Diversity sub-TLV with an empty body. | * Diversity sub-TLV is not the same as a Diversity sub-TLV with an empty body. | ||||
* The former would mean a lack of any claims about the interference, and the | * The former would mean a lack of any claims about the interference, and the | ||||
* latter would state that interference is definitely absent. | * latter would state that interference is definitely absent. | ||||
* A type 3 sub-TLV is valid both for Hello and IHU TLVs, though the exact | * A type 3 sub-TLV is valid both for Hello and IHU TLVs, though the exact | ||||
* semantic of the sub-TLV is different in each case. | * semantic of the sub-TLV is different in each case. | ||||
*/ | */ | ||||
static void | static void | ||||
subtlvs_print(netdissect_options *ndo, | subtlvs_print(netdissect_options *ndo, | ||||
const u_char *cp, const u_char *ep, const uint8_t tlv_type) { | const u_char *cp, const u_char *ep, const uint8_t tlv_type) | ||||
{ | |||||
uint8_t subtype, sublen; | uint8_t subtype, sublen; | ||||
const char *sep; | const char *sep; | ||||
uint32_t t1, t2; | uint32_t t1, t2; | ||||
while (cp < ep) { | while (cp < ep) { | ||||
subtype = *cp++; | subtype = *cp++; | ||||
if(subtype == MESSAGE_SUB_PAD1) { | if(subtype == MESSAGE_SUB_PAD1) { | ||||
ND_PRINT((ndo, " sub-pad1")); | ND_PRINT((ndo, " sub-pad1")); | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | corrupt: | ||||
ND_PRINT((ndo, " (corrupt)")); | ND_PRINT((ndo, " (corrupt)")); | ||||
} | } | ||||
#define ICHECK(i, l) \ | #define ICHECK(i, l) \ | ||||
if ((i) + (l) > bodylen || (i) + (l) > length) goto corrupt; | if ((i) + (l) > bodylen || (i) + (l) > length) goto corrupt; | ||||
static void | static void | ||||
babel_print_v2(netdissect_options *ndo, | babel_print_v2(netdissect_options *ndo, | ||||
const u_char *cp, u_int length) { | const u_char *cp, u_int length) | ||||
{ | |||||
u_int i; | u_int i; | ||||
u_short bodylen; | u_short bodylen; | ||||
u_char v4_prefix[16] = | u_char v4_prefix[16] = | ||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 }; | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 }; | ||||
u_char v6_prefix[16] = {0}; | u_char v6_prefix[16] = {0}; | ||||
ND_TCHECK2(*cp, 4); | ND_TCHECK2(*cp, 4); | ||||
if (length < 4) | if (length < 4) | ||||
▲ Show 20 Lines • Show All 252 Lines • Show Last 20 Lines |