From: hannes Date: Fri, 16 Jan 2004 10:07:20 +0000 (+0000) Subject: - bugfix: rework the AS_PATH decoder per draft-ietf-idr-rfc3065bis: X-Git-Tag: tcpdump-3.8.2~42 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/ebe7dfee41ae838dd53a1bd9df5a62b3d7277b16 - bugfix: rework the AS_PATH decoder per draft-ietf-idr-rfc3065bis: CONFED_AS_SET and CONFED_AS_SEQUENCE codepoints have changed; - rework the SEQ and SET display output in accordance with contemporary routing software ( AS ) indicates an CONFED AS SEQUENCE segment { AS } indicates an AS SET segment ({ AS }) indicates an CONFED AS SET segment --- diff --git a/print-bgp.c b/print-bgp.c index 722e3008..aad4b6d5 100644 --- a/print-bgp.c +++ b/print-bgp.c @@ -36,7 +36,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.72.2.2 2003-11-16 08:51:13 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.72.2.3 2004-01-16 10:07:20 hannes Exp $"; #endif #include @@ -161,6 +161,27 @@ static struct tok bgp_attr_values[] = { { 0, NULL} }; +#define BGP_AS_SET 1 +#define BGP_AS_SEQUENCE 2 +#define BGP_CONFED_AS_SEQUENCE 3 /* draft-ietf-idr-rfc3065bis-01 */ +#define BGP_CONFED_AS_SET 4 /* draft-ietf-idr-rfc3065bis-01 */ + +static struct tok bgp_as_path_segment_open_values[] = { + { BGP_AS_SEQUENCE, ""}, + { BGP_AS_SET, "{ "}, + { BGP_CONFED_AS_SEQUENCE, "( "}, + { BGP_CONFED_AS_SET, "({ "}, + { 0, NULL} +}; + +static struct tok bgp_as_path_segment_close_values[] = { + { BGP_AS_SEQUENCE, ""}, + { BGP_AS_SET, "}"}, + { BGP_CONFED_AS_SEQUENCE, ")"}, + { BGP_CONFED_AS_SET, "})"}, + { 0, NULL} +}; + #define BGP_OPT_AUTH 1 #define BGP_OPT_CAP 2 @@ -735,21 +756,14 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) printf("empty"); break; } + while (tptr < pptr + len) { - /* - * under RFC1965, p[0] means: - * 1: AS_SET 2: AS_SEQUENCE - * 3: AS_CONFED_SET 4: AS_CONFED_SEQUENCE - */ - if (tptr[0] == 3 || tptr[0] == 4) - printf("confed"); - printf("%s", (tptr[0] & 1) ? "{" : ""); - for (i = 0; i < tptr[1] * 2; i += 2) { - printf("%s%u", i == 0 ? "" : " ", - EXTRACT_16BITS(&tptr[2 + i])); - } - printf("%s", (tptr[0] & 1) ? "}" : ""); - tptr += 2 + tptr[1] * 2; + printf("%s", tok2str(bgp_as_path_segment_open_values, "?", tptr[0])); + for (i = 0; i < tptr[1] * 2; i += 2) { + printf("%u ", EXTRACT_16BITS(&tptr[2 + i])); + } + printf("%s", tok2str(bgp_as_path_segment_close_values, "?", tptr[0])); + tptr += 2 + tptr[1] * 2; } break; case BGPTYPE_NEXT_HOP: