X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/a719238471802a311ebe2537c9554d45a3bca718..d2777156522f139a858bd6b5b51e364826bc95a7:/print-bgp.c diff --git a/print-bgp.c b/print-bgp.c index bcf7a3c4..e13fdd91 100644 --- a/print-bgp.c +++ b/print-bgp.c @@ -263,12 +263,10 @@ static const struct tok bgp_notify_major_values[] = { { 0, NULL} }; -/* draft-ietf-idr-cease-subcode-02 */ +/* RFC 4486 */ #define BGP_NOTIFY_MINOR_CEASE_MAXPRFX 1 -/* draft-ietf-idr-shutdown-07 */ #define BGP_NOTIFY_MINOR_CEASE_SHUT 2 #define BGP_NOTIFY_MINOR_CEASE_RESET 4 -#define BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN 128 static const struct tok bgp_notify_minor_cease_values[] = { { BGP_NOTIFY_MINOR_CEASE_MAXPRFX, "Maximum Number of Prefixes Reached"}, { BGP_NOTIFY_MINOR_CEASE_SHUT, "Administrative Shutdown"}, @@ -915,7 +913,7 @@ bgp_rt_prefix_print(netdissect_options *ndo, u_int plen) { /* allocate space for the largest possible string */ - char rtc_prefix_in_hex[20] = ""; + char rtc_prefix_in_hex[sizeof("0000 0000 0000 0000")] = ""; u_int rtc_prefix_in_hex_len = 0; static char output[61]; /* max response string */ /* allocate space for the largest possible string */ @@ -951,7 +949,7 @@ bgp_rt_prefix_print(netdissect_options *ndo, /* * get the ext-comm type * Note: pptr references a static 8 octet buffer with unused bits set to 0, - * hense EXTRACT_*() macros are safe. + * hence EXTRACT_*() macros are safe. */ ec_type = EXTRACT_BE_U_2(pptr); switch (ec_type) { @@ -2911,8 +2909,6 @@ bgp_notification_print(netdissect_options *ndo, const struct bgp_notification *bgp_notification_header; const u_char *tptr; uint8_t bgpn_major, bgpn_minor; - uint8_t shutdown_comm_length; - uint8_t remainder_offset; ND_TCHECK_LEN(dat, BGP_NOTIFICATION_SIZE); if (length= BGP_NOTIFICATION_SIZE + 7) { @@ -2978,18 +2974,17 @@ bgp_notification_print(netdissect_options *ndo, GET_BE_U_4(tptr + 3)); } /* - * draft-ietf-idr-shutdown describes a method to send a communication + * RFC 9003 describes a method to send a communication * intended for human consumption regarding the Administrative Shutdown */ if ((bgpn_minor == BGP_NOTIFY_MINOR_CEASE_SHUT || bgpn_minor == BGP_NOTIFY_MINOR_CEASE_RESET) && length >= BGP_NOTIFICATION_SIZE + 1) { tptr = dat + BGP_NOTIFICATION_SIZE; - shutdown_comm_length = GET_U_1(tptr); - remainder_offset = 0; + uint8_t shutdown_comm_length = GET_U_1(tptr); + uint8_t remainder_offset = 0; /* garbage, hexdump it all */ - if (shutdown_comm_length > BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN || - shutdown_comm_length > length - (BGP_NOTIFICATION_SIZE + 1)) { + if (shutdown_comm_length > length - (BGP_NOTIFICATION_SIZE + 1)) { ND_PRINT(", invalid Shutdown Communication length"); } else if (shutdown_comm_length == 0) { @@ -2998,7 +2993,6 @@ bgp_notification_print(netdissect_options *ndo, } /* a proper shutdown communication */ else { - ND_TCHECK_LEN(tptr + 1, shutdown_comm_length); ND_PRINT(", Shutdown Communication (length: %u): \"", shutdown_comm_length); (void)nd_printn(ndo, tptr+1, shutdown_comm_length, NULL); ND_PRINT("\"");