]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-lldp.c
Makefile.in: don't remove configure and config.h.in in make distclean.
[tcpdump] / print-lldp.c
index 054a961782ddf8d35a3a41c1d77b17d581fd4d71..a04f054ed48372655a849df00b09e61eb3ab762b 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"},
@@ -699,7 +701,7 @@ lldp_private_8021_print(netdissect_options *ndo,
             return hexdump;
         }
         ND_PRINT("\n\t    vlan name: ");
-        (void)nd_printzp(ndo, tptr + 7, sublen, NULL);
+        nd_printjnp(ndo, tptr + 7, sublen);
         break;
     case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY:
         if (tlv_len < 5) {
@@ -710,8 +712,18 @@ lldp_private_8021_print(netdissect_options *ndo,
             return hexdump;
         }
         ND_PRINT("\n\t    protocol identity: ");
-        (void)nd_printzp(ndo, tptr + 5, sublen, NULL);
+        nd_printjnp(ndo, tptr + 5, sublen);
         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;
@@ -958,7 +970,7 @@ lldp_private_iana_print(netdissect_options *ndo,
     switch (subtype) {
     case LLDP_IANA_SUBTYPE_MUDURL:
         ND_PRINT("\n\t  MUD-URL=");
-        (void)nd_printn(ndo, tptr+4, tlv_len-4, NULL);
+        nd_printjn(ndo, tptr+4, tlv_len-4);
         break;
     default:
         hexdump=TRUE;
@@ -1070,7 +1082,7 @@ lldp_private_tia_print(netdissect_options *ndo,
                    GET_U_1(tptr + 6));
 
             /* Country code */
-            (void)nd_printzp(ndo, tptr + 7, 2, NULL);
+            nd_printjnp(ndo, tptr + 7, 2);
 
             lci_len = lci_len-3;
             tptr = tptr + 9;
@@ -1098,7 +1110,7 @@ lldp_private_tia_print(netdissect_options *ndo,
                    return hexdump;
                }
 
-                (void)nd_printzp(ndo, tptr, ca_len, NULL);
+                nd_printjnp(ndo, tptr, ca_len);
                 tptr += ca_len;
                 lci_len -= ca_len;
             }
@@ -1106,7 +1118,7 @@ lldp_private_tia_print(netdissect_options *ndo,
 
         case LLDP_TIA_LOCATION_DATA_FORMAT_ECS_ELIN:
             ND_PRINT("\n\t    ECS ELIN id ");
-            (void)nd_printzp(ndo, tptr + 5, tlv_len - 5, NULL);
+            nd_printjnp(ndo, tptr + 5, tlv_len - 5);
             break;
 
         default:
@@ -1143,7 +1155,7 @@ lldp_private_tia_print(netdissect_options *ndo,
     case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_ASSET_ID:
         ND_PRINT("\n\t  %s ",
                tok2str(lldp_tia_inventory_values, "unknown", subtype));
-        (void)nd_printzp(ndo, tptr + 4, tlv_len - 4, NULL);
+        nd_printjnp(ndo, tptr + 4, tlv_len - 4);
         break;
 
     default:
@@ -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));
     }
 
@@ -1425,7 +1436,7 @@ lldp_mgmt_addr_tlv_print(netdissect_options *ndo,
         }
         if (oid_len) {
             ND_PRINT("\n\t  OID length %u", oid_len);
-            (void)nd_printzp(ndo, tptr + 1, oid_len, NULL);
+            nd_printjnp(ndo, tptr + 1, oid_len);
         }
     }
 
@@ -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 */
@@ -1502,7 +1513,7 @@ lldp_print(netdissect_options *ndo,
                 case LLDP_CHASSIS_CHASSIS_COMP_SUBTYPE:
                 case LLDP_CHASSIS_INTF_ALIAS_SUBTYPE:
                 case LLDP_CHASSIS_PORT_COMP_SUBTYPE:
-                    (void)nd_printzp(ndo, tptr + 1, tlv_len - 1, NULL);
+                    nd_printjnp(ndo, tptr + 1, tlv_len - 1);
                     break;
 
                 case LLDP_CHASSIS_NETWORK_ADDR_SUBTYPE:
@@ -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 */
@@ -1543,7 +1554,7 @@ lldp_print(netdissect_options *ndo,
                 case LLDP_PORT_AGENT_CIRC_ID_SUBTYPE:
                 case LLDP_PORT_INTF_ALIAS_SUBTYPE:
                 case LLDP_PORT_PORT_COMP_SUBTYPE:
-                    (void)nd_printzp(ndo, tptr + 1, tlv_len - 1, NULL);
+                    nd_printjnp(ndo, tptr + 1, tlv_len - 1);
                     break;
 
                 case LLDP_PORT_NETWORK_ADDR_SUBTYPE:
@@ -1573,7 +1584,7 @@ lldp_print(netdissect_options *ndo,
         case LLDP_PORT_DESCR_TLV:
             if (ndo->ndo_vflag) {
                 ND_PRINT(": ");
-                (void)nd_printzp(ndo, tptr, tlv_len, NULL);
+                nd_printjnp(ndo, tptr, tlv_len);
             }
             break;
 
@@ -1583,13 +1594,13 @@ lldp_print(netdissect_options *ndo,
              * similar to the CDP printer.
              */
             ND_PRINT(": ");
-            (void)nd_printzp(ndo, tptr, tlv_len, NULL);
+            nd_printjnp(ndo, tptr, tlv_len);
             break;
 
         case LLDP_SYSTEM_DESCR_TLV:
             if (ndo->ndo_vflag) {
                 ND_PRINT("\n\t  ");
-                (void)nd_printzp(ndo, tptr, tlv_len, NULL);
+                nd_printjnp(ndo, tptr, tlv_len);
             }
             break;