]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-lldp.c
OSPF: Use %zu to print sizeof values
[tcpdump] / print-lldp.c
index e728bae682a93e19aa421e805db8b36ae7aaeb80..812d72e58f18b7a3b9c2efdd417eb821e028eb1f 100644 (file)
@@ -136,6 +136,7 @@ static const struct tok lldp_cap_values[] = {
 #define LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID     2
 #define LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME            3
 #define LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY    4
+#define LLDP_PRIVATE_8021_SUBTYPE_LINKAGGR             7
 #define LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION 8
 #define LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION       9
 #define LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION     10
@@ -149,6 +150,7 @@ static const struct tok lldp_8021_subtype_values[] = {
     { LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID, "Port and Protocol VLAN ID"},
     { LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME, "VLAN name"},
     { LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY, "Protocol Identity"},
+    { LLDP_PRIVATE_8021_SUBTYPE_LINKAGGR, "Link aggregation"},
     { LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION, "Congestion Notification"},
     { LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION, "ETS Configuration"},
     { LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION, "ETS Recommendation"},
@@ -712,6 +714,16 @@ lldp_private_8021_print(netdissect_options *ndo,
         ND_PRINT("\n\t    protocol identity: ");
         (void)nd_printzp(ndo, tptr + 5, sublen, NULL);
         break;
+
+    case LLDP_PRIVATE_8021_SUBTYPE_LINKAGGR:
+        if (tlv_len < 9) {
+            return hexdump;
+        }
+        ND_PRINT("\n\t    aggregation status [%s], aggregation port ID %u",
+               bittok2str(lldp_aggregation_values, "none", GET_U_1((tptr + 4))),
+               GET_BE_U_4(tptr + 5));
+        break;
+
     case LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION:
         if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION_LENGTH){
                return hexdump;
@@ -796,7 +808,7 @@ lldp_private_8021_print(netdissect_options *ndo,
                tval=GET_U_1(tptr + i + 5);
                ND_PRINT("\n\t      Priority: %u, RES: %u, Sel: %u, Protocol ID: %u",
                         tval >> 5, (tval >> 3) & 0x03, (tval & 0x07),
-                        GET_BE_U_2(tptr + i + 5));
+                        GET_BE_U_2(tptr + i + 6));
                i=i+3;
         }
         break;
@@ -1163,10 +1175,11 @@ lldp_private_dcbx_print(netdissect_options *ndo,
 {
     int hexdump = FALSE;
     u_int subtype;
-    uint8_t tval;
+    uint16_t tval;
     uint16_t tlv;
     uint32_t i, pgval, uval;
-    u_int tlen, tlv_type, tlv_len;
+    u_int tlen, tlv_type;
+    uint16_t tlv_len;
     const u_char *tptr, *mptr;
 
     if (len < 4) {
@@ -1337,19 +1350,17 @@ lldp_network_addr_print(netdissect_options *ndo, const u_char *tptr, u_int len)
     af = GET_U_1(tptr);
     switch (af) {
     case AFNUM_INET:
-        if (len < 4)
+        if (len < sizeof(nd_ipv4))
           return NULL;
-        /* This cannot be assigned to ipaddr_string(), which is a macro. */
         pfunc = ipaddr_string;
         break;
     case AFNUM_INET6:
-        if (len < 16)
+        if (len < sizeof(nd_ipv6))
           return NULL;
-        /* This cannot be assigned to ip6addr_string(), which is a macro. */
         pfunc = ip6addr_string;
         break;
     case AFNUM_802:
-        if (len < 6)
+        if (len < MAC_ADDR_LEN)
           return NULL;
         pfunc = etheraddr_string;
         break;
@@ -1359,10 +1370,10 @@ lldp_network_addr_print(netdissect_options *ndo, const u_char *tptr, u_int len)
     }
 
     if (!pfunc) {
-        nd_snprintf(buf, sizeof(buf), "AFI %s (%u), no AF printer !",
+        snprintf(buf, sizeof(buf), "AFI %s (%u), no AF printer !",
                  tok2str(af_values, "Unknown", af), af);
     } else {
-        nd_snprintf(buf, sizeof(buf), "AFI %s (%u): %s",
+        snprintf(buf, sizeof(buf), "AFI %s (%u): %s",
                  tok2str(af_values, "Unknown", af), af, (*pfunc)(ndo, tptr+1));
     }
 
@@ -1494,7 +1505,7 @@ lldp_print(netdissect_options *ndo,
                     if (tlv_len < 1+6) {
                         goto trunc;
                     }
-                    ND_PRINT("%s", etheraddr_string(ndo, tptr + 1));
+                    ND_PRINT("%s", GET_ETHERADDR_STRING(tptr + 1));
                     break;
 
                 case LLDP_CHASSIS_INTF_NAME_SUBTYPE: /* fall through */
@@ -1535,7 +1546,7 @@ lldp_print(netdissect_options *ndo,
                     if (tlv_len < 1+6) {
                         goto trunc;
                     }
-                    ND_PRINT("%s", etheraddr_string(ndo, tptr + 1));
+                    ND_PRINT("%s", GET_ETHERADDR_STRING(tptr + 1));
                     break;
 
                 case LLDP_PORT_INTF_NAME_SUBTYPE: /* fall through */