]> The Tcpdump Group git mirrors - tcpdump/commitdiff
fix RIP Request/full table decoding issues
authorDenis Ovsienko <[email protected]>
Mon, 11 Jun 2012 17:01:34 +0000 (21:01 +0400)
committerDenis Ovsienko <[email protected]>
Tue, 12 Jun 2012 09:59:06 +0000 (13:59 +0400)
RIP Request and Response messages have the same structure. Update a
switch block in rip_print() to proceed with decoding of both.

A Request message may contain an AFI 0 RTE standing for a full table
request, normally sent on a router start. Update rip_entry_print_v1()
and rip_entry_print_v2() to treat IPv4 and AFI 0 as two valid,
distinguishable cases.

print-rip.c
tests/TESTLIST
tests/ripv1v2.out [new file with mode: 0644]
tests/ripv1v2.pcap [new file with mode: 0644]

index 27446a6823638075afc5213af43a3801afb03759..84f8951ca1e373632012a6ec07a49d564332c02e 100644 (file)
@@ -102,7 +102,7 @@ rip_entry_print_v1(register const struct rip_netinfo *ni)
 
        /* RFC 1058 */
        family = EXTRACT_16BITS(&ni->rip_family);
-       if (family != BSD_AFNUM_INET) {
+       if (family != BSD_AFNUM_INET && family != 0) {
                printf("\n\t AFI %s, ", tok2str(bsd_af_values, "Unknown (%u)", family));
                 print_unknown_data((u_int8_t *)&ni->rip_family,"\n\t  ",RIP_ROUTELEN);
                return;
@@ -113,6 +113,12 @@ rip_entry_print_v1(register const struct rip_netinfo *ni)
                /* MBZ fields not zero */
                 print_unknown_data((u_int8_t *)&ni->rip_family,"\n\t  ",RIP_ROUTELEN);
                return;
+       }
+       if (family == 0) {
+               printf("\n\t  AFI 0, %s, metric: %u",
+                       ipaddr_string(&ni->rip_dest),
+                       EXTRACT_32BITS(&ni->rip_metric));
+               return;
        } /* BSD_AFNUM_INET */
        printf("\n\t  %s, metric: %u",
                ipaddr_string(&ni->rip_dest),
@@ -141,13 +147,13 @@ rip_entry_print_v2(register const struct rip_netinfo *ni)
                               EXTRACT_16BITS(&ni->rip_tag));
                         print_unknown_data((u_int8_t *)&ni->rip_dest,"\n\t  ",RIP_AUTHLEN);
                }
-       } else if (family != BSD_AFNUM_INET) {
+       } else if (family != BSD_AFNUM_INET && family != 0) {
                printf("\n\t  AFI %s", tok2str(bsd_af_values, "Unknown (%u)", family));
                 print_unknown_data((u_int8_t *)&ni->rip_tag,"\n\t  ",RIP_ROUTELEN-2);
                return;
-       } else { /* BSD_AFNUM_INET */
+       } else { /* BSD_AFNUM_INET or AFI 0 */
                printf("\n\t  AFI %s, %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ",
-                       tok2str(bsd_af_values, "Unknown (%u)", family),
+                       tok2str(bsd_af_values, "%u", family),
                        ipaddr_string(&ni->rip_dest),
                       mask2plen(EXTRACT_32BITS(&ni->rip_dest_mask)),
                        EXTRACT_16BITS(&ni->rip_tag),
@@ -213,6 +219,7 @@ rip_print(const u_char *dat, u_int length)
                     return;
 
                switch (rp->rip_cmd) {
+               case RIPCMD_REQUEST:
                case RIPCMD_RESPONSE:
                        j = length / sizeof(*ni);
                         printf(", routes: %u",j);
@@ -231,7 +238,6 @@ rip_print(const u_char *dat, u_int length)
                                printf("[|rip]");
                        break;
 
-               case RIPCMD_REQUEST:
                case RIPCMD_TRACEOFF:
                case RIPCMD_POLL:
                case RIPCMD_POLLENTRY:
index e96137023a2ba0e530cc812c9dd35899d85be57b..7dbb2b14f63f3cfbbc1e56ed3da306057202b834 100644 (file)
@@ -70,3 +70,6 @@ icmpv6          icmpv6.pcap             icmpv6.out      -t -vv -c1
 
 # SPB tests
 spb                spb.pcap                spb.out -t
+
+# RIP tests
+ripv1v2         ripv1v2.pcap            ripv1v2.out     -t -v
diff --git a/tests/ripv1v2.out b/tests/ripv1v2.out
new file mode 100644 (file)
index 0000000..26e6097
--- /dev/null
@@ -0,0 +1,16 @@
+IP (tos 0xc0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 52)
+    10.0.0.20.520 > 10.0.0.255.520: 
+       RIPv1, Request, length: 24, routes: 1
+         AFI 0, 0.0.0.0, metric: 16
+IP (tos 0xc0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 52)
+    10.0.0.20.520 > 10.0.0.255.520: 
+       RIPv1, Response, length: 24, routes: 1
+         10.70.178.0, metric: 1
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [DF], proto UDP (17), length 52)
+    10.0.0.20.520 > 224.0.0.9.520: 
+       RIPv2, Request, length: 24, routes: 1
+         AFI 0,         0.0.0.0/0 , tag 0x0000, metric: 16, next-hop: self
+IP (tos 0xc0, ttl 1, id 0, offset 0, flags [DF], proto UDP (17), length 52)
+    10.0.0.20.520 > 224.0.0.9.520: 
+       RIPv2, Response, length: 24, routes: 1
+         AFI IPv4,     10.70.178.0/24, tag 0x0000, metric: 1, next-hop: self
diff --git a/tests/ripv1v2.pcap b/tests/ripv1v2.pcap
new file mode 100644 (file)
index 0000000..b98056f
Binary files /dev/null and b/tests/ripv1v2.pcap differ