#include "netdissect-stdinc.h"
+#define ND_LONGJMP_FROM_TCHECK
#include "netdissect.h"
#include "extract.h"
{ 0, NULL }
};
+static const struct tok bfd_port_values[] = {
+ { BFD_CONTROL_PORT, "Control" },
+ { BFD_MULTIHOP_PORT, "Multihop" },
+ { BFD_LAG_PORT, "LAG" },
+ { SBFD_PORT, "S-BFD" },
+ { 0, NULL }
+};
+
#define BFD_FLAG_AUTH 0x04
static const struct tok bfd_v0_flag_values[] = {
{ 0, NULL }
};
-static int
+static void
auth_print(netdissect_options *ndo, const u_char *pptr)
{
const struct bfd_auth_header_t *bfd_auth_header;
pptr++;
ND_PRINT(", Password: ");
/* the length is equal to the password length plus three */
- if (nd_printn(ndo, pptr, auth_len - 3,
- ndo->ndo_snapend))
- goto trunc;
+ nd_printjn(ndo, pptr, auth_len - 3);
break;
case AUTH_MD5:
case AUTH_MET_MD5:
break;
}
pptr += 2;
- ND_TCHECK_4(pptr);
ND_PRINT(", Sequence Number: 0x%08x", GET_BE_U_4(pptr));
pptr += 4;
ND_TCHECK_LEN(pptr, AUTH_MD5_HASH_LEN);
break;
}
pptr += 2;
- ND_TCHECK_4(pptr);
ND_PRINT(", Sequence Number: 0x%08x", GET_BE_U_4(pptr));
pptr += 4;
ND_TCHECK_LEN(pptr, AUTH_SHA1_HASH_LEN);
ND_PRINT("%02x", GET_U_1(pptr + i));
break;
}
- return 0;
-
-trunc:
- return 1;
}
void
u_int len, u_int port)
{
ndo->ndo_protocol = "bfd";
- if (port == BFD_CONTROL_PORT) {
+ if (port == BFD_CONTROL_PORT ||
+ port == BFD_MULTIHOP_PORT ||
+ port == BFD_LAG_PORT ||
+ port == SBFD_PORT) {
/*
* Control packet.
*/
/* BFDv0 */
case 0:
- if (ndo->ndo_vflag < 1)
- {
+ if (ndo->ndo_vflag < 1) {
ND_PRINT("BFDv0, Control, Flags: [%s], length: %u",
bittok2str(bfd_v0_flag_values, "none", flags),
len);
GET_BE_U_4(bfd_header->required_min_echo_interval)/1000);
if (flags & BFD_FLAG_AUTH) {
- if (auth_print(ndo, pptr))
- goto trunc;
+ auth_print(ndo, pptr);
}
break;
/* BFDv1 */
case 1:
- if (ndo->ndo_vflag < 1)
- {
- ND_PRINT("BFDv1, Control, State %s, Flags: [%s], length: %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT("BFDv1, %s, State %s, Flags: [%s], length: %u",
+ tok2str(bfd_port_values, "unknown (%u)", port),
tok2str(bfd_v1_state_values, "unknown (%u)", (flags & 0xc0) >> 6),
bittok2str(bfd_v1_flag_values, "none", flags & 0x3f),
len);
return;
}
- ND_PRINT("BFDv1, length: %u\n\tControl, State %s, Flags: [%s], Diagnostic: %s (0x%02x)",
+ ND_PRINT("BFDv1, length: %u\n\t%s, State %s, Flags: [%s], Diagnostic: %s (0x%02x)",
len,
+ tok2str(bfd_port_values, "unknown (%u)", port),
tok2str(bfd_v1_state_values, "unknown (%u)", (flags & 0xc0) >> 6),
bittok2str(bfd_v1_flag_values, "none", flags & 0x3f),
tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(version_diag)),
GET_BE_U_4(bfd_header->required_min_echo_interval)/1000);
if (flags & BFD_FLAG_AUTH) {
- if (auth_print(ndo, pptr))
- goto trunc;
+ auth_print(ndo, pptr);
}
break;
return;
}
}
- return;
-
-trunc:
- nd_print_trunc(ndo);
}