]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Use more the EXTRACT_U_1() macro (51/n)
authorFrancois-Xavier Le Bail <[email protected]>
Sat, 9 Dec 2017 10:40:36 +0000 (11:40 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Sat, 9 Dec 2017 10:46:15 +0000 (11:46 +0100)
Moreover: Use more the ND_ISPRINT() macro.

12 files changed:
print-cdp.c
print-chdlc.c
print-dccp.c
print-fr.c
print-icmp6.c
print-msdp.c
print-pim.c
print-pppoe.c
print-radius.c
print-slow.c
print-snmp.c
print-syslog.c

index 908f55f406daa84ee711615e4fb141106064b3fb..0c594843b061c97e2309318401ad61f201116757 100644 (file)
@@ -304,7 +304,8 @@ cdp_print_addr(netdissect_options *ndo,
                        goto trunc;
                al = EXTRACT_BE_U_2(p + pl);    /* address length */
 
-               if (pt == PT_NLPID && pl == 1 && *p == NLPID_IP && al == 4) {
+               if (pt == PT_NLPID && pl == 1 && EXTRACT_U_1(p) == NLPID_IP &&
+                   al == 4) {
                        /*
                         * IPv4: protocol type = NLPID, protocol length = 1
                         * (1-byte NLPID), protocol = 0xcc (NLPID for IPv4),
index 47a7b1654885fa67fc011039b9477710eceddbb2..d65e74375bb14e3ec5917b234fb6897064226238 100644 (file)
@@ -95,9 +95,9 @@ chdlc_print(netdissect_options *ndo, register const u_char *p, u_int length)
                 if (length < 2)
                     goto trunc;
                 ND_TCHECK_2(p);
-                if (*(p+1) == NLPID_CLNP ||
-                    *(p+1) == NLPID_ESIS ||
-                    *(p+1) == NLPID_ISIS)
+                if (EXTRACT_U_1(p + 1) == NLPID_CLNP ||
+                    EXTRACT_U_1(p + 1) == NLPID_ESIS ||
+                    EXTRACT_U_1(p + 1) == NLPID_ISIS)
                     isoclns_print(ndo, p + 1, length - 1);
                 else
                     isoclns_print(ndo, p, length);
index 59edea5a2bd6f243bc017cc3e5f47b164a1122a3..b4d1e8e53f00971d01cad30412fb961e4829085d 100644 (file)
@@ -537,11 +537,11 @@ static int dccp_print_option(netdissect_options *ndo, const u_char *option, u_in
 
        ND_TCHECK_1(option);
 
-       if (*option >= 32) {
+       if (EXTRACT_U_1(option) >= 32) {
                ND_TCHECK_1(option + 1);
                optlen = EXTRACT_U_1(option + 1);
                if (optlen < 2) {
-                       if (*option >= 128)
+                       if (EXTRACT_U_1(option) >= 128)
                                ND_PRINT((ndo, "CCID option %u optlen too short", EXTRACT_U_1(option)));
                        else
                                ND_PRINT((ndo, "%s optlen too short",
@@ -552,7 +552,7 @@ static int dccp_print_option(netdissect_options *ndo, const u_char *option, u_in
                optlen = 1;
 
        if (hlen < optlen) {
-               if (*option >= 128)
+               if (EXTRACT_U_1(option) >= 128)
                        ND_PRINT((ndo, "CCID option %u optlen goes past header length",
                                  EXTRACT_U_1(option)));
                else
@@ -562,7 +562,7 @@ static int dccp_print_option(netdissect_options *ndo, const u_char *option, u_in
        }
        ND_TCHECK2(*option, optlen);
 
-       if (*option >= 128) {
+       if (EXTRACT_U_1(option) >= 128) {
                ND_PRINT((ndo, "CCID option %d", EXTRACT_U_1(option)));
                switch (optlen) {
                        case 4:
@@ -585,7 +585,7 @@ static int dccp_print_option(netdissect_options *ndo, const u_char *option, u_in
                                ND_PRINT((ndo, " optlen too short"));
                                return optlen;
                        }
-                       if (*(option + 2) < 10){
+                       if (EXTRACT_U_1(option + 2) < 10){
                                ND_PRINT((ndo, " %s", dccp_feature_nums[EXTRACT_U_1(option + 2)]));
                                for (i = 0; i < optlen - 3; i++)
                                        ND_PRINT((ndo, " %d", EXTRACT_U_1(option + 3 + i)));
index c8415e12c8b6f27dcf734d651fb8384e3d9783ad..8c8bf781787870f022ef563b350c3c0a4f4ede65 100644 (file)
@@ -499,7 +499,7 @@ mfr_print(netdissect_options *ndo,
             case MFR_CTRL_IE_BUNDLE_ID: /* same message format */
             case MFR_CTRL_IE_LINK_ID:
                 for (idx = 0; idx < ie_len && idx < MFR_ID_STRING_MAXLEN; idx++) {
-                    if (*(tptr+idx) != 0) /* don't print null termination */
+                    if (EXTRACT_U_1(tptr + idx) != 0) /* don't print null termination */
                         safeputchar(ndo, EXTRACT_U_1(tptr + idx));
                     else
                         break;
index dabec424693d007a07f1abf5404fefe09a32d429..2b03d6dbc32a7888f4af63cfb724e156edef2ddd 100644 (file)
@@ -1553,7 +1553,7 @@ dnsname_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
                        if (cp == ep) {
                                /* FQDN */
                                ND_PRINT((ndo,"."));
-                       } else if (cp + 1 == ep && *cp == '\0') {
+                       } else if (cp + 1 == ep && EXTRACT_U_1(cp) == '\0') {
                                /* truncated */
                        } else {
                                /* invalid */
index 7eb6b1050be10b3d8dbed2564025b11f704c48e5..f1769de04a9807f9a7fcf39e1f6f178612efcd24 100644 (file)
@@ -65,8 +65,9 @@ msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
                                ND_PRINT((ndo, " [w/data]"));
                                if (ndo->ndo_vflag > 1) {
                                        ND_PRINT((ndo, " "));
-                                       ip_print(ndo, sp + *sp * 12 + 8 - 3,
-                                                len - (*sp * 12 + 8));
+                                       ip_print(ndo, sp +
+                                                EXTRACT_U_1(sp) * 12 + 8 - 3,
+                                                len - (EXTRACT_U_1(sp) * 12 + 8));
                                }
                        }
                        break;
index ee04fbd333aaab2751ed1a228fca36295ba15ff7..b6048c776a09516678605712518c6599c4637cbe 100644 (file)
@@ -825,7 +825,7 @@ pimv2_print(netdissect_options *ndo,
                                        ND_PRINT((ndo, "ERROR: Option Length != 4 Bytes (%u)", olen));
                                } else {
                                        ND_PRINT((ndo, "v%d", EXTRACT_U_1(bp)));
-                                       if (*(bp+1) != 0) {
+                                       if (EXTRACT_U_1(bp + 1) != 0) {
                                                ND_PRINT((ndo, ", interval "));
                                                unsigned_relts_print(ndo,
                                                                     EXTRACT_U_1(bp + 1));
index f1fedc75292298e70afea4fc5d4ddc62bc7e24b2..652f82ef1b52a592be0fb35c1e6e9d510f13d379 100644 (file)
@@ -156,7 +156,7 @@ pppoe_print(netdissect_options *ndo, register const u_char *bp, u_int length)
                                /* TODO print UTF-8 decoded text */
                                ND_TCHECK2(*p, tag_len);
                                for (v = p; v < p + tag_len && tag_str_len < MAXTAGPRINT-1; v++)
-                                       if (*v >= 32 && *v < 127) {
+                                       if (ND_ISPRINT(EXTRACT_U_1(v))) {
                                                tag_str[tag_str_len++] = EXTRACT_U_1(v);
                                                ascii_count++;
                                        } else {
index 1862b0a9f3bd46f9eb26646cf84b69f90bcfe175..fda7710ca191119c7cd9b8effac35af9c536b8d9 100644 (file)
@@ -593,7 +593,7 @@ print_attr_string(netdissect_options *ndo,
       case TUNNEL_PASS:
            if (length < 3)
               goto trunc;
-           if (*data && (*data <=0x1F) )
+           if (EXTRACT_U_1(data) && (EXTRACT_U_1(data) <= 0x1F))
               ND_PRINT((ndo, "Tag[%u] ", EXTRACT_U_1(data)));
            else
               ND_PRINT((ndo, "Tag[Unused] "));
@@ -613,7 +613,7 @@ print_attr_string(netdissect_options *ndo,
            {
               if (length < 1)
                  goto trunc;
-              if (*data)
+              if (EXTRACT_U_1(data))
                 ND_PRINT((ndo, "Tag[%u] ", EXTRACT_U_1(data)));
               else
                 ND_PRINT((ndo, "Tag[Unused] "));
@@ -731,7 +731,7 @@ print_attr_num(netdissect_options *ndo,
 
       if ( (attr_code == TUNNEL_TYPE) || (attr_code == TUNNEL_MEDIUM) )
       {
-         if (!*data)
+         if (!EXTRACT_U_1(data))
             ND_PRINT((ndo, "Tag[Unused] "));
          else
             ND_PRINT((ndo, "Tag[%d] ", EXTRACT_U_1(data)));
@@ -795,7 +795,7 @@ print_attr_num(netdissect_options *ndo,
           break;
 
         case TUNNEL_PREFERENCE:
-            if (*data)
+            if (EXTRACT_U_1(data))
                ND_PRINT((ndo, "Tag[%d] ", EXTRACT_U_1(data)));
             else
                ND_PRINT((ndo, "Tag[Unused] "));
@@ -1002,7 +1002,7 @@ print_attr_strange(netdissect_options *ndo,
                return;
            }
            ND_TCHECK_1(data);
-           if (*data)
+           if (EXTRACT_U_1(data))
               ND_PRINT((ndo, "User can change password"));
            else
               ND_PRINT((ndo, "User cannot change password"));
index f3dc330dd50e75ac5ac7316aea81d1c217a2ca8b..972af657a20b468749116dc05dd3ed1413d8e981 100644 (file)
@@ -261,7 +261,7 @@ slow_print(netdissect_options *ndo,
         if (len < 2)
             goto tooshort;
         ND_TCHECK_1(pptr + 1);
-        if (*(pptr+1) != LACP_VERSION) {
+        if (EXTRACT_U_1(pptr + 1) != LACP_VERSION) {
             ND_PRINT((ndo, "LACP version %u packet not supported", EXTRACT_U_1(pptr + 1)));
             return;
         }
@@ -272,7 +272,7 @@ slow_print(netdissect_options *ndo,
         if (len < 2)
             goto tooshort;
         ND_TCHECK_1(pptr + 1);
-        if (*(pptr+1) != MARKER_VERSION) {
+        if (EXTRACT_U_1(pptr + 1) != MARKER_VERSION) {
             ND_PRINT((ndo, "MARKER version %u packet not supported", EXTRACT_U_1(pptr + 1)));
             return;
         }
index ec43a4ddf30bf70cf2362222a9c5e8e3eaeadce7..ee6589606c7b6f86393cef0110d2ab63847372e1 100644 (file)
@@ -444,8 +444,8 @@ asn1_parse(netdissect_options *ndo,
        class = form >> 1;              /* bits 7&6 -> bits 1&0, range 0-3 */
        form &= 0x1;                    /* bit 5 -> bit 0, range 0-1 */
 #else
-       form = (u_char)(*p & ASN_FORM_BITS) >> ASN_FORM_SHIFT;
-       class = (u_char)(*p & ASN_CLASS_BITS) >> ASN_CLASS_SHIFT;
+       form = (u_char)(EXTRACT_U_1(p) & ASN_FORM_BITS) >> ASN_FORM_SHIFT;
+       class = (u_char)(EXTRACT_U_1(p) & ASN_CLASS_BITS) >> ASN_CLASS_SHIFT;
 #endif
        elem->form = form;
        elem->class = class;
@@ -470,7 +470,7 @@ asn1_parse(netdissect_options *ndo,
                                ND_PRINT((ndo, "[Xtagfield?]"));
                                return -1;
                        }
-                       id = (id << 7) | (*p & ~ASN_BIT8);
+                       id = (id << 7) | (EXTRACT_U_1(p) & ~ASN_BIT8);
                        len--;
                        hdr++;
                        p++;
@@ -771,7 +771,7 @@ asn1_print(netdissect_options *ndo,
 
                for (; i-- > 0; p++) {
                        ND_TCHECK_1(p);
-                       o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8);
+                       o = (o << ASN_SHIFT7) + (EXTRACT_U_1(p) & ~ASN_BIT8);
                        if (EXTRACT_U_1(p) & ASN_LONGLEN)
                                continue;
 
@@ -923,7 +923,7 @@ smi_decode_oid(netdissect_options *ndo,
 
        for (*oidlen = 0; i-- > 0; p++) {
                ND_TCHECK_1(p);
-               o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8);
+               o = (o << ASN_SHIFT7) + (EXTRACT_U_1(p) & ~ASN_BIT8);
                if (EXTRACT_U_1(p) & ASN_LONGLEN)
                    continue;
 
index 15720fa2b6cda5099fbc4af276a38c73cc0c4f86..1610bd6d594e03c6b0738a04e258d7f672d4bb3c 100644 (file)
@@ -91,17 +91,17 @@ syslog_print(netdissect_options *ndo,
      */
 
     ND_TCHECK_1(pptr);
-    if (*(pptr+msg_off) == '<') {
+    if (EXTRACT_U_1(pptr + msg_off) == '<') {
         msg_off++;
         ND_TCHECK_1(pptr + msg_off);
         while (msg_off <= SYSLOG_MAX_DIGITS &&
                EXTRACT_U_1(pptr + msg_off) >= '0' &&
                EXTRACT_U_1(pptr + msg_off) <= '9') {
-            pri = pri * 10 + (*(pptr+msg_off) - '0');
+            pri = pri * 10 + (EXTRACT_U_1(pptr + msg_off) - '0');
             msg_off++;
             ND_TCHECK_1(pptr + msg_off);
         }
-        if (*(pptr+msg_off) != '>') {
+        if (EXTRACT_U_1(pptr + msg_off) != '>') {
             ND_PRINT((ndo, "%s", tstr));
             return;
         }