]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Use more the EXTRACT_U_1() macro (44/n)
authorFrancois-Xavier Le Bail <[email protected]>
Sun, 3 Dec 2017 12:53:38 +0000 (13:53 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Sun, 3 Dec 2017 13:00:15 +0000 (14:00 +0100)
In: switch (... p[n] ...) ...

print-ip.c
print-pim.c
print-sl.c
print-smb.c
print-sunatm.c
print-vjc.c

index a49a957ca8eea9e44f66013c230661c5e62b8201..b7359d087bccee6e3dec6f8cac85baa00be9d877 100644 (file)
@@ -191,7 +191,7 @@ ip_printts(netdissect_options *ndo,
        if (ptr < 4 || ((ptr - 4) & (hoplen-1)) || ptr > length + 1)
                ND_PRINT((ndo, "[bad ptr %u]", EXTRACT_U_1(cp + 2)));
        ND_TCHECK(cp[3]);
-       switch (cp[3]&0xF) {
+       switch (EXTRACT_U_1(cp + 3)&0xF) {
        case IPOPT_TS_TSONLY:
                ND_PRINT((ndo, "TSONLY"));
                break;
index 3c41d9f94497d642885f9b808490f43ac1711385..8c3028291c3177cea9c46850b840f6373083f831 100644 (file)
@@ -260,7 +260,7 @@ pimv1_print(netdissect_options *ndo,
        switch (type) {
        case PIMV1_TYPE_QUERY:
                if (ND_TTEST(bp[8])) {
-                       switch (bp[8] >> 4) {
+                       switch (EXTRACT_U_1(bp + 8) >> 4) {
                        case 0:
                                ND_PRINT((ndo, " Dense-mode"));
                                break;
@@ -407,7 +407,7 @@ cisco_autorp_print(netdissect_options *ndo,
                if (len < 1)
                        goto trunc;
                ND_TCHECK(bp[0]);
-               switch (bp[0] & 0x3) {
+               switch (EXTRACT_U_1(bp) & 0x3) {
                case 0: ND_PRINT((ndo, " PIMv?"));
                        break;
                case 1: ND_PRINT((ndo, " PIMv1"));
index ed29874ec31bcd6570e2cd6aa050b5c2c711e2bc..a0be325064f55ef19d9630476a056ef1d5c28f54 100644 (file)
@@ -155,7 +155,7 @@ sliplink_print(netdissect_options *ndo,
                ND_PRINT((ndo, "%02x: ", EXTRACT_U_1(p + SLX_CHDR + CHDR_LEN - 1)));
                return;
        }
-       switch (p[SLX_CHDR] & 0xf0) {
+       switch (EXTRACT_U_1(p + SLX_CHDR) & 0xf0) {
 
        case TYPE_IP:
                ND_PRINT((ndo, "ip %d: ", length + SLIP_HDRLEN));
index 0f0d9cebde3cd3559ddc4b74092c1a6a1a7f896c..2db946067be3600538da0c9a98e581bd877548a8 100644 (file)
@@ -1200,7 +1200,7 @@ nbt_udp137_print(netdissect_options *ndo,
                        ND_TCHECK(*p);
                        if (EXTRACT_U_1(p) & 0x80)
                            ND_PRINT((ndo, "<GROUP> "));
-                       switch (p[0] & 0x60) {
+                       switch (EXTRACT_U_1(p) & 0x60) {
                        case 0x00: ND_PRINT((ndo, "B ")); break;
                        case 0x20: ND_PRINT((ndo, "P ")); break;
                        case 0x40: ND_PRINT((ndo, "M ")); break;
index eaa7125d82ee1271b7342436042e4b883813a46d..c46598d47c81f21eb78161e316980640a6576177 100644 (file)
@@ -81,7 +81,7 @@ sunatm_if_print(netdissect_options *ndo,
                ND_PRINT((ndo, EXTRACT_U_1(p + DIR_POS) & 0x80 ? "Tx: " : "Rx: "));
        }
 
-       switch (p[DIR_POS] & 0x0f) {
+       switch (EXTRACT_U_1(p + DIR_POS) & 0x0f) {
 
        case PT_LANE:
                traftype = ATM_LANE;
index b5f88ab6d2cecc43d546656cccbf94e6ee8d85e2..01e6c9766aa5535423a0006fc11f892bf8f6f9f0 100644 (file)
@@ -88,7 +88,7 @@ vjc_print(netdissect_options *ndo, register const u_char *bp, u_short proto _U_)
 {
        int i;
 
-       switch (bp[0] & 0xf0) {
+       switch (EXTRACT_U_1(bp) & 0xf0) {
        case TYPE_IP:
                if (ndo->ndo_eflag)
                        ND_PRINT((ndo, "(vjc type=IP) "));