]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-lldp.c
Use more the EXTRACT_U_1() macro (40/n)
[tcpdump] / print-lldp.c
index 6b34005f71b854c8590e28f628fb50b465b752c8..c3bd4bc4b501a1c6a17097cbe54dcae97b43b59a 100644 (file)
@@ -617,8 +617,10 @@ print_ets_priority_assignment_table(netdissect_options *ndo,
     ND_PRINT((ndo, "\n\t    Priority Assignment Table"));
     ND_PRINT((ndo, "\n\t     Priority : 0   1   2   3   4   5   6   7"));
     ND_PRINT((ndo, "\n\t     Value    : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d",
-            ptr[0]>>4,ptr[0]&0x0f,ptr[1]>>4,ptr[1]&0x0f,ptr[2]>>4,
-            ptr[2] & 0x0f, ptr[3] >> 4, ptr[3] & 0x0f));
+              EXTRACT_U_1(ptr) >> 4, EXTRACT_U_1(ptr) & 0x0f,
+              EXTRACT_U_1(ptr + 1) >> 4, EXTRACT_U_1(ptr + 1) & 0x0f,
+              EXTRACT_U_1(ptr + 2) >> 4, EXTRACT_U_1(ptr + 2) & 0x0f,
+              EXTRACT_U_1(ptr + 3) >> 4, EXTRACT_U_1(ptr + 3) & 0x0f));
 }
 
 static void
@@ -628,7 +630,9 @@ print_tc_bandwidth_table(netdissect_options *ndo,
     ND_PRINT((ndo, "\n\t    TC Bandwidth Table"));
     ND_PRINT((ndo, "\n\t     TC%%   : 0   1   2   3   4   5   6   7"));
     ND_PRINT((ndo, "\n\t     Value : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d",
-             ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7]));
+              EXTRACT_U_1(ptr), EXTRACT_U_1(ptr + 1), EXTRACT_U_1(ptr + 2),
+              EXTRACT_U_1(ptr + 3), EXTRACT_U_1(ptr + 4), EXTRACT_U_1(ptr + 5),
+              EXTRACT_U_1(ptr + 6), EXTRACT_U_1(ptr + 7)));
 }
 
 static void
@@ -638,7 +642,9 @@ print_tsa_assignment_table(netdissect_options *ndo,
     ND_PRINT((ndo, "\n\t    TSA Assignment Table"));
     ND_PRINT((ndo, "\n\t     Traffic Class: 0   1   2   3   4   5   6   7"));
     ND_PRINT((ndo, "\n\t     Value        : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d",
-             ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7]));
+              EXTRACT_U_1(ptr), EXTRACT_U_1(ptr + 1), EXTRACT_U_1(ptr + 2),
+              EXTRACT_U_1(ptr + 3), EXTRACT_U_1(ptr + 4), EXTRACT_U_1(ptr + 5),
+              EXTRACT_U_1(ptr + 6), EXTRACT_U_1(ptr + 7)));
 }
 
 /*
@@ -677,7 +683,7 @@ lldp_private_8021_print(netdissect_options *ndo,
         ND_PRINT((ndo, "\n\t    port and protocol vlan id (PPVID): %u, flags [%s] (0x%02x)",
                EXTRACT_BE_U_2(tptr + 5),
                bittok2str(lldp_8021_port_protocol_id_values, "none", EXTRACT_U_1((tptr + 4))),
-               *(tptr + 4)));
+               EXTRACT_U_1(tptr + 4)));
         break;
     case LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME:
         if (tlv_len < 6) {
@@ -746,7 +752,7 @@ lldp_private_8021_print(netdissect_options *ndo,
         if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION_LENGTH) {
                return hexdump;
         }
-        ND_PRINT((ndo, "\n\t    RES: %d", *(tptr + 4)));
+        ND_PRINT((ndo, "\n\t    RES: %d", EXTRACT_U_1(tptr + 4)));
         /*Print Priority Assignment Table */
         print_ets_priority_assignment_table(ndo, tptr + 5);
         /*Print TC Bandwidth Table */
@@ -774,7 +780,7 @@ lldp_private_8021_print(netdissect_options *ndo,
         if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY_MIN_LENGTH) {
             return hexdump;
         }
-        ND_PRINT((ndo, "\n\t    RES: %d", *(tptr + 4)));
+        ND_PRINT((ndo, "\n\t    RES: %d", EXTRACT_U_1(tptr + 4)));
         if(tlv_len<=LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY_MIN_LENGTH){
                return hexdump;
         }
@@ -869,7 +875,7 @@ lldp_private_8023_print(netdissect_options *ndo,
         }
         ND_PRINT((ndo, "\n\t    autonegotiation [%s] (0x%02x)",
                bittok2str(lldp_8023_autonegotiation_values, "none", EXTRACT_U_1((tptr + 4))),
-               *(tptr + 4)));
+               EXTRACT_U_1(tptr + 4)));
         ND_PRINT((ndo, "\n\t    PMD autoneg capability [%s] (0x%04x)",
                bittok2str(lldp_pmd_capability_values,"unknown", EXTRACT_BE_U_2(tptr + 5)),
                EXTRACT_BE_U_2(tptr + 5)));
@@ -992,7 +998,7 @@ lldp_private_tia_print(netdissect_options *ndo,
                           EXTRACT_BE_U_2(tptr + 4)), EXTRACT_BE_U_2(tptr + 4)));
         ND_PRINT((ndo, "\n\t    Device type [%s] (0x%02x)",
                tok2str(lldp_tia_device_type_values, "unknown", EXTRACT_U_1((tptr + 6))),
-               *(tptr + 6)));
+               EXTRACT_U_1(tptr + 6)));
         break;
 
     case LLDP_PRIVATE_TIA_SUBTYPE_NETWORK_POLICY:
@@ -1001,7 +1007,7 @@ lldp_private_tia_print(netdissect_options *ndo,
         }
         ND_PRINT((ndo, "\n\t    Application type [%s] (0x%02x)",
                tok2str(lldp_tia_application_type_values, "none", EXTRACT_U_1((tptr + 4))),
-               *(tptr + 4)));
+               EXTRACT_U_1(tptr + 4)));
         ND_PRINT((ndo, ", Flags [%s]", bittok2str(
                    lldp_tia_network_policy_bits_values, "none", EXTRACT_U_1((tptr + 5)))));
         ND_PRINT((ndo, "\n\t    Vlan id %u",
@@ -1027,9 +1033,9 @@ lldp_private_tia_print(netdissect_options *ndo,
                 return hexdump;
             }
             ND_PRINT((ndo, "\n\t    Latitude resolution %u, latitude value %" PRIu64,
-                   (*(tptr + 5) >> 2), lldp_extract_latlon(tptr + 5)));
+                   (EXTRACT_U_1(tptr + 5) >> 2), lldp_extract_latlon(tptr + 5)));
             ND_PRINT((ndo, "\n\t    Longitude resolution %u, longitude value %" PRIu64,
-                   (*(tptr + 10) >> 2), lldp_extract_latlon(tptr + 10)));
+                   (EXTRACT_U_1(tptr + 10) >> 2), lldp_extract_latlon(tptr + 10)));
             ND_PRINT((ndo, "\n\t    Altitude type %s (%u)",
                    tok2str(lldp_tia_location_altitude_type_values, "unknown",EXTRACT_U_1((tptr + 15)) >> 4),
                    (EXTRACT_U_1(tptr + 15) >> 4)));
@@ -1038,7 +1044,7 @@ lldp_private_tia_print(netdissect_options *ndo,
                    ((EXTRACT_BE_U_4(tptr + 16) & 0x3fffffff))));
             ND_PRINT((ndo, "\n\t    Datum %s (0x%02x)",
                    tok2str(lldp_tia_location_datum_type_values, "unknown", EXTRACT_U_1((tptr + 20))),
-                   *(tptr + 20)));
+                   EXTRACT_U_1(tptr + 20)));
             break;
 
         case LLDP_TIA_LOCATION_DATA_FORMAT_CIVIC_ADDRESS:
@@ -1055,7 +1061,7 @@ lldp_private_tia_print(netdissect_options *ndo,
             ND_PRINT((ndo, "\n\t    LCI length %u, LCI what %s (0x%02x), Country-code ",
                    lci_len,
                    tok2str(lldp_tia_location_lci_what_values, "unknown", EXTRACT_U_1((tptr + 6))),
-                   *(tptr + 6)));
+                   EXTRACT_U_1(tptr + 6)));
 
             /* Country code */
             safeputs(ndo, tptr + 7, 2);
@@ -1108,7 +1114,7 @@ lldp_private_tia_print(netdissect_options *ndo,
             return hexdump;
         }
         ND_PRINT((ndo, "\n\t    Power type [%s]",
-               (*(tptr + 4) & 0xC0 >> 6) ? "PD device" : "PSE device"));
+               (EXTRACT_U_1(tptr + 4) & 0xC0 >> 6) ? "PD device" : "PSE device"));
         ND_PRINT((ndo, ", Power source [%s]",
                tok2str(lldp_tia_power_source_values, "none", (EXTRACT_U_1((tptr + 4)) & 0x30) >> 4)));
         ND_PRINT((ndo, "\n\t    Power priority [%s] (0x%02x)",
@@ -1203,8 +1209,8 @@ lldp_private_dcbx_print(netdissect_options *ndo,
             }
            ND_PRINT((ndo, "\n\t    Control - Protocol Control (type 0x%x, length %d)",
                LLDP_DCBX_CONTROL_TLV, tlv_len));
-           ND_PRINT((ndo, "\n\t      Oper_Version: %d", *tptr));
-           ND_PRINT((ndo, "\n\t      Max_Version: %d", *(tptr + 1)));
+           ND_PRINT((ndo, "\n\t      Oper_Version: %d", EXTRACT_U_1(tptr)));
+           ND_PRINT((ndo, "\n\t      Max_Version: %d", EXTRACT_U_1(tptr + 1)));
            ND_PRINT((ndo, "\n\t      Sequence Number: %d", EXTRACT_BE_U_4(tptr + 2)));
            ND_PRINT((ndo, "\n\t      Acknowledgement Number: %d",
                                        EXTRACT_BE_U_4(tptr + 6)));
@@ -1215,14 +1221,14 @@ lldp_private_dcbx_print(netdissect_options *ndo,
             }
            ND_PRINT((ndo, "\n\t    Feature - Priority Group (type 0x%x, length %d)",
                LLDP_DCBX_PRIORITY_GROUPS_TLV, tlv_len));
-           ND_PRINT((ndo, "\n\t      Oper_Version: %d", *tptr));
-           ND_PRINT((ndo, "\n\t      Max_Version: %d", *(tptr + 1)));
-           ND_PRINT((ndo, "\n\t      Info block(0x%02X): ", *(tptr + 2)));
+           ND_PRINT((ndo, "\n\t      Oper_Version: %d", EXTRACT_U_1(tptr)));
+           ND_PRINT((ndo, "\n\t      Max_Version: %d", EXTRACT_U_1(tptr + 1)));
+           ND_PRINT((ndo, "\n\t      Info block(0x%02X): ", EXTRACT_U_1(tptr + 2)));
            tval = EXTRACT_U_1(tptr + 2);
            ND_PRINT((ndo, "Enable bit: %d, Willing bit: %d, Error Bit: %d",
                (tval &  0x80) ? 1 : 0, (tval &  0x40) ? 1 : 0,
                (tval &  0x20) ? 1 : 0));
-           ND_PRINT((ndo, "\n\t      SubType: %d", *(tptr + 3)));
+           ND_PRINT((ndo, "\n\t      SubType: %d", EXTRACT_U_1(tptr + 3)));
            ND_PRINT((ndo, "\n\t      Priority Allocation"));
 
            /*
@@ -1236,8 +1242,8 @@ lldp_private_dcbx_print(netdissect_options *ndo,
            }
            ND_PRINT((ndo, "\n\t      Priority Group Allocation"));
            for (i = 0; i <= 7; i++)
-               ND_PRINT((ndo, "\n\t          Pg percentage[%d]: %d", i, *(tptr + 8 + i)));
-           ND_PRINT((ndo, "\n\t      NumTCsSupported: %d", *(tptr + 8 + 8)));
+               ND_PRINT((ndo, "\n\t          Pg percentage[%d]: %d", i, EXTRACT_U_1(tptr + 8 + i)));
+           ND_PRINT((ndo, "\n\t      NumTCsSupported: %d", EXTRACT_U_1(tptr + 8 + 8)));
            break;
         case LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV:
             if (tlv_len < 6) {
@@ -1246,20 +1252,20 @@ lldp_private_dcbx_print(netdissect_options *ndo,
            ND_PRINT((ndo, "\n\t    Feature - Priority Flow Control"));
            ND_PRINT((ndo, " (type 0x%x, length %d)",
                LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV, tlv_len));
-           ND_PRINT((ndo, "\n\t      Oper_Version: %d", *tptr));
-           ND_PRINT((ndo, "\n\t      Max_Version: %d", *(tptr + 1)));
-           ND_PRINT((ndo, "\n\t      Info block(0x%02X): ", *(tptr + 2)));
+           ND_PRINT((ndo, "\n\t      Oper_Version: %d", EXTRACT_U_1(tptr)));
+           ND_PRINT((ndo, "\n\t      Max_Version: %d", EXTRACT_U_1(tptr + 1)));
+           ND_PRINT((ndo, "\n\t      Info block(0x%02X): ", EXTRACT_U_1(tptr + 2)));
            tval = EXTRACT_U_1(tptr + 2);
            ND_PRINT((ndo, "Enable bit: %d, Willing bit: %d, Error Bit: %d",
                (tval &  0x80) ? 1 : 0, (tval &  0x40) ? 1 : 0,
                (tval &  0x20) ? 1 : 0));
-           ND_PRINT((ndo, "\n\t      SubType: %d", *(tptr + 3)));
+           ND_PRINT((ndo, "\n\t      SubType: %d", EXTRACT_U_1(tptr + 3)));
            tval = EXTRACT_U_1(tptr + 4);
-           ND_PRINT((ndo, "\n\t      PFC Config (0x%02X)", *(tptr + 4)));
+           ND_PRINT((ndo, "\n\t      PFC Config (0x%02X)", EXTRACT_U_1(tptr + 4)));
            for (i = 0; i <= 7; i++)
                ND_PRINT((ndo, "\n\t          Priority Bit %d: %s",
                    i, (tval & (1 << i)) ? "Enabled" : "Disabled"));
-           ND_PRINT((ndo, "\n\t      NumTCPFCSupported: %d", *(tptr + 5)));
+           ND_PRINT((ndo, "\n\t      NumTCPFCSupported: %d", EXTRACT_U_1(tptr + 5)));
            break;
         case LLDP_DCBX_APPLICATION_TLV:
             if (tlv_len < 4) {
@@ -1267,14 +1273,14 @@ lldp_private_dcbx_print(netdissect_options *ndo,
             }
            ND_PRINT((ndo, "\n\t    Feature - Application (type 0x%x, length %d)",
                LLDP_DCBX_APPLICATION_TLV, tlv_len));
-           ND_PRINT((ndo, "\n\t      Oper_Version: %d", *tptr));
-           ND_PRINT((ndo, "\n\t      Max_Version: %d", *(tptr + 1)));
-           ND_PRINT((ndo, "\n\t      Info block(0x%02X): ", *(tptr + 2)));
+           ND_PRINT((ndo, "\n\t      Oper_Version: %d", EXTRACT_U_1(tptr)));
+           ND_PRINT((ndo, "\n\t      Max_Version: %d", EXTRACT_U_1(tptr + 1)));
+           ND_PRINT((ndo, "\n\t      Info block(0x%02X): ", EXTRACT_U_1(tptr + 2)));
            tval = EXTRACT_U_1(tptr + 2);
            ND_PRINT((ndo, "Enable bit: %d, Willing bit: %d, Error Bit: %d",
                (tval &  0x80) ? 1 : 0, (tval &  0x40) ? 1 : 0,
                (tval &  0x20) ? 1 : 0));
-           ND_PRINT((ndo, "\n\t      SubType: %d", *(tptr + 3)));
+           ND_PRINT((ndo, "\n\t      SubType: %d", EXTRACT_U_1(tptr + 3)));
            tval = tlv_len - 4;
            mptr = tptr + 4;
            while (tval >= 6) {
@@ -1286,7 +1292,7 @@ lldp_private_dcbx_print(netdissect_options *ndo,
                        (uval >> 22),
                        (uval >> 22) ? "Socket Number" : "L2 EtherType"));
                ND_PRINT((ndo, "\n\t          OUI: 0x%06x", uval & 0x3fffff));
-               ND_PRINT((ndo, "\n\t          User Priority Map: 0x%02x", *(mptr + 5)));
+               ND_PRINT((ndo, "\n\t          User Priority Map: 0x%02x", EXTRACT_U_1(mptr + 5)));
                tval = tval - 6;
                mptr = mptr + 6;
            }