]> The Tcpdump Group git mirrors - tcpdump/commitdiff
fix iteration over Babel Pad1 TLVs
authorDenis Ovsienko <[email protected]>
Fri, 10 May 2013 12:03:08 +0000 (16:03 +0400)
committerDenis Ovsienko <[email protected]>
Wed, 29 May 2013 09:03:23 +0000 (13:03 +0400)
The Pad1 TLV consists only of the Type field (RFC6126 Section 4.4.1),
thus the check for Pad1 type must be done before the Length field is
consumed, if ever. This change brings tcpdump decoder into line with the
spec and Babel implementation's own TLV iterator.

print-babel.c
tests/babel_pad1.out

index c15f958670fd341e70ebf4d8aafe5f995f391807..8b422b3f1fea05620838c07c7e60455bc8c786a1 100644 (file)
@@ -212,23 +212,22 @@ babel_print_v2(const u_char *cp, u_int length) {
         u_int type, len;
 
         message = cp + 4 + i;
         u_int type, len;
 
         message = cp + 4 + i;
+
+        TCHECK2(*message, 1);
+        if((type = message[0]) == MESSAGE_PAD1) {
+            printf(vflag ? "\n\tPad 1" : " pad1");
+            i += 1;
+            continue;
+        }
+
         TCHECK2(*message, 2);
         ICHECK(i, 2);
         TCHECK2(*message, 2);
         ICHECK(i, 2);
-        type = message[0];
         len = message[1];
 
         TCHECK2(*message, 2 + len);
         ICHECK(i, 2 + len);
 
         switch(type) {
         len = message[1];
 
         TCHECK2(*message, 2 + len);
         ICHECK(i, 2 + len);
 
         switch(type) {
-        case MESSAGE_PAD1: {
-            if(!vflag)
-                printf(" pad1");
-            else
-                printf("\n\tPad 1");
-        }
-            break;
-
         case MESSAGE_PADN: {
             if(!vflag)
                 printf(" padN");
         case MESSAGE_PADN: {
             if(!vflag)
                 printf(" padN");
index 563ebcb42783025e4ea03ad857e3dcd4b1001d11..c42f2ebf0b400be06908b913a273fa962ed3b435 100644 (file)
@@ -1,2 +1,2 @@
-IP6 fe80::b299:28ff:fec8:d646.6696 > ff02::1:6.6696: babel 2 (9) hello [|babel]
-IP6 fe80::b299:28ff:fec8:d646.6696 > ff02::1:6.6696: babel 2 (60) hello pad1 pad1 [|babel]
+IP6 fe80::b299:28ff:fec8:d646.6696 > ff02::1:6.6696: babel 2 (9) hello pad1
+IP6 fe80::b299:28ff:fec8:d646.6696 > ff02::1:6.6696: babel 2 (60) hello pad1 nh pad1 router-id pad1 update pad1 update pad1