]> The Tcpdump Group git mirrors - tcpdump/commitdiff
- bugfix: rework the AS_PATH decoder per draft-ietf-idr-rfc3065bis:
authorhannes <hannes>
Fri, 16 Jan 2004 10:07:20 +0000 (10:07 +0000)
committerhannes <hannes>
Fri, 16 Jan 2004 10:07:20 +0000 (10:07 +0000)
    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

print-bgp.c

index 722e3008c2ba8c2b90fe5877f0fe8bd145cc2521..aad4b6d56ffe3459da6c0418540ea627de6527f2 100644 (file)
@@ -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 <tcpdump-stdinc.h>
@@ -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: