]> The Tcpdump Group git mirrors - tcpdump/commitdiff
VTP: Filter out non-printable characters
authorFrancois-Xavier Le Bail <[email protected]>
Tue, 10 Nov 2015 12:28:17 +0000 (13:28 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Tue, 10 Nov 2015 12:28:17 +0000 (13:28 +0100)
Use fn_printzp().

Moreover:
Improve some comments.
Use 'type' instead of '*(tptr+1)' when possible.

print-vtp.c

index cba34a6c6081c9ec30e01f8d8a8496e67c431df7..ce8cdac71b34fb0595d0dc3222fc1b4bbe9b64e6 100644 (file)
@@ -135,7 +135,7 @@ vtp_print (netdissect_options *ndo,
     ND_PRINT((ndo, "VTPv%u, Message %s (0x%02x), length %u",
           *tptr,
           tok2str(vtp_message_type_values,"Unknown message type", type),
-          *(tptr+1),
+          type,
           length));
 
     /* In non-verbose mode, just print version and message type */
@@ -144,9 +144,10 @@ vtp_print (netdissect_options *ndo,
     }
 
     /* verbose mode print all fields */
-    ND_PRINT((ndo, "\n\tDomain name: %s, %s: %u",
-          (tptr+4),
-          tok2str(vtp_header_values,"Unknown",*(tptr+1)),
+    ND_PRINT((ndo, "\n\tDomain name: "));
+    fn_printzp(ndo, tptr + 4, *(tptr + 3), NULL);
+    ND_PRINT((ndo, ", %s: %u",
+          tok2str(vtp_header_values, "Unknown", type),
           *(tptr+2)));
 
     tptr += VTP_HEADER_LEN;
@@ -162,7 +163,7 @@ vtp_print (netdissect_options *ndo,
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         *  |     Version   |     Code      |    Followers  |    MmgtD Len  |
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-        *  |                    Management Domain Name                     |
+        *  |       Management Domain Name  (zero-padded to 32 bytes)       |
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         *  |                    Configuration revision number              |
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -201,7 +202,7 @@ vtp_print (netdissect_options *ndo,
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         *  |     Version   |     Code      |   Seq number  |    MmgtD Len  |
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-        *  |                    Management Domain Name                     |
+        *  |       Management Domain Name  (zero-padded to 32 bytes)       |
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         *  |                    Configuration revision number              |
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -241,13 +242,13 @@ vtp_print (netdissect_options *ndo,
            ND_TCHECK2(*tptr, len);
 
            vtp_vlan = (const struct vtp_vlan_*)tptr;
-           ND_PRINT((ndo, "\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name %s",
+           ND_PRINT((ndo, "\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name ",
                   tok2str(vtp_vlan_status,"Unknown",vtp_vlan->status),
                   tok2str(vtp_vlan_type_values,"Unknown",vtp_vlan->type),
                   EXTRACT_16BITS(&vtp_vlan->vlanid),
                   EXTRACT_16BITS(&vtp_vlan->mtu),
-                  EXTRACT_32BITS(&vtp_vlan->index),
-                  (tptr + VTP_VLAN_INFO_OFFSET)));
+                  EXTRACT_32BITS(&vtp_vlan->index)));
+           fn_printzp(ndo, tptr + VTP_VLAN_INFO_OFFSET, vtp_vlan->name_len, NULL);
 
             /*
              * Vlan names are aligned to 32-bit boundaries.
@@ -339,7 +340,7 @@ vtp_print (netdissect_options *ndo,
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         *  |     Version   |     Code      |   Reserved    |    MmgtD Len  |
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-        *  |                    Management Domain Name                     |
+        *  |       Management Domain Name  (zero-padded to 32 bytes)       |
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         *  |                          Start value                          |
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+