]> The Tcpdump Group git mirrors - tcpdump/commitdiff
More EXTRACT_8BITS() changes. Use ND_CHECK_nBITS() more as well.
authorGuy Harris <[email protected]>
Mon, 20 Nov 2017 01:59:51 +0000 (17:59 -0800)
committerGuy Harris <[email protected]>
Mon, 20 Nov 2017 01:59:51 +0000 (17:59 -0800)
print-bgp.c
print-bootp.c
print-cfm.c
print-dhcp6.c
print-domain.c
print-dvmrp.c
print-fr.c
print-geneve.c
print-isoclns.c

index 3e59df88f0d5537f0945cad7b6a70ec407d3d54b..26404015b3c45fefeac632df655fc45f9a3359db 100644 (file)
@@ -680,8 +680,9 @@ bgp_vpn_sg_print(netdissect_options *ndo,
     total_length = 0;
 
     /* Source address length, encoded in bits */
-    ND_TCHECK2(pptr[0], 1);
-    addr_length =  *pptr++;
+    ND_TCHECK_8BITS(pptr);
+    addr_length = EXTRACT_8BITS(pptr);
+    pptr++;
 
     /* Source address */
     ND_TCHECK2(pptr[0], (addr_length >> 3));
@@ -694,8 +695,9 @@ bgp_vpn_sg_print(netdissect_options *ndo,
     }
 
     /* Group address length, encoded in bits */
-    ND_TCHECK2(pptr[0], 1);
-    addr_length =  *pptr++;
+    ND_TCHECK_8BITS(pptr);
+    addr_length = EXTRACT_8BITS(pptr);
+    pptr++;
 
     /* Group address */
     ND_TCHECK2(pptr[0], (addr_length >> 3));
@@ -874,7 +876,7 @@ decode_mdt_vpn_nlri(netdissect_options *ndo,
     ND_TCHECK(pptr[0]);
 
     /* if the NLRI is not predefined length, quit.*/
-    if (*pptr != MDT_VPN_NLRI_LEN * 8)
+    if (EXTRACT_8BITS(pptr) != MDT_VPN_NLRI_LEN * 8)
        return -1;
     pptr++;
 
@@ -928,8 +930,10 @@ decode_multicast_vpn(netdissect_options *ndo,
         u_int offset;
 
        ND_TCHECK2(pptr[0], 2);
-        route_type = *pptr++;
-        route_length = *pptr++;
+        route_type = EXTRACT_8BITS(pptr);
+        pptr++;
+        route_length = EXTRACT_8BITS(pptr);
+        pptr++;
 
         snprintf(buf, buflen, "Route-Type: %s (%u), length: %u",
                  tok2str(bgp_multicast_vpn_route_type_values,
@@ -1033,7 +1037,7 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
 {
         int plen,tlen,stringlen,tlv_type,tlv_len,ttlv_len;
 
-       ND_TCHECK2(pptr[0], 2);
+       ND_TCHECK_16BITS(pptr);
         plen=EXTRACT_BE_16BITS(pptr);
         tlen=plen;
         pptr+=2;
@@ -1073,7 +1077,8 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
                if (tlen < 3)
                    return -1;
                ND_TCHECK2(pptr[0], 3);
-               tlv_type=*pptr++;
+               tlv_type=EXTRACT_8BITS(pptr);
+               pptr++;
                tlv_len=EXTRACT_BE_16BITS(pptr);
                ttlv_len=tlv_len;
                pptr+=2;
@@ -1090,7 +1095,8 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
                    while (ttlv_len>0) {
                        ND_TCHECK(pptr[0]);
                        if (buflen!=0) {
-                           stringlen=snprintf(buf,buflen, "%02x",*pptr++);
+                           stringlen=snprintf(buf,buflen, "%02x",EXTRACT_8BITS(pptr));
+                           pptr++;
                            UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
                        }
                        ttlv_len--;
@@ -1452,7 +1458,7 @@ bgp_attr_print(netdissect_options *ndo,
                if (len != 4)
                        ND_PRINT((ndo, "invalid len"));
                else {
-                       ND_TCHECK2(tptr[0], 4);
+                       ND_TCHECK_32BITS(tptr);
                        ND_PRINT((ndo, "%u", EXTRACT_BE_32BITS(tptr)));
                }
                break;
@@ -1498,7 +1504,7 @@ bgp_attr_print(netdissect_options *ndo,
                }
                while (tlen>0) {
                        uint32_t comm;
-                       ND_TCHECK2(tptr[0], 4);
+                       ND_TCHECK_32BITS(tptr);
                        comm = EXTRACT_BE_32BITS(tptr);
                        switch (comm) {
                        case BGP_COMMUNITY_NO_EXPORT:
@@ -1546,7 +1552,7 @@ bgp_attr_print(netdissect_options *ndo,
        case BGPTYPE_MP_REACH_NLRI:
                ND_TCHECK2(tptr[0], 3);
                af = EXTRACT_BE_16BITS(tptr);
-               safi = tptr[2];
+               safi = EXTRACT_8BITS(tptr + 2);
 
                 ND_PRINT((ndo, "\n\t    AFI: %s (%u), %sSAFI: %s (%u)",
                        tok2str(af_values, "Unknown AFI", af),
@@ -2058,7 +2064,7 @@ bgp_attr_print(netdissect_options *ndo,
                 while (tlen>0) {
                     uint16_t extd_comm;
 
-                    ND_TCHECK2(tptr[0], 2);
+                    ND_TCHECK_16BITS(tptr);
                     extd_comm=EXTRACT_BE_16BITS(tptr);
 
                    ND_PRINT((ndo, "\n\t    %s (0x%04x), Flags [%s]",
@@ -2141,8 +2147,8 @@ bgp_attr_print(netdissect_options *ndo,
                 uint8_t tunnel_type, flags;
 
                 ND_TCHECK2(tptr[0], 5);
-                tunnel_type = *(tptr+1);
-                flags = *tptr;
+                flags = EXTRACT_8BITS(tptr);
+                tunnel_type = EXTRACT_8BITS(tptr+1);
                 tlen = len;
 
                 ND_PRINT((ndo, "\n\t    Tunnel-type %s (%u), Flags [%s], MPLS Label %u",
@@ -2205,7 +2211,7 @@ bgp_attr_print(netdissect_options *ndo,
 
                    ND_TCHECK2(tptr[0], 3);
 
-                   type = *tptr;
+                   type = EXTRACT_8BITS(tptr);
                    length = EXTRACT_BE_16BITS(tptr + 1);
                    tptr += 3;
                    tlen -= 3;
@@ -2244,7 +2250,7 @@ bgp_attr_print(netdissect_options *ndo,
                break;
        }
         case BGPTYPE_ATTR_SET:
-                ND_TCHECK2(tptr[0], 4);
+                ND_TCHECK_32BITS(tptr);
                 if (len < 4)
                        goto trunc;
                ND_PRINT((ndo, "\n\t    Origin AS: %s",
@@ -2258,8 +2264,8 @@ bgp_attr_print(netdissect_options *ndo,
                     ND_TCHECK2(tptr[0], 2);
                     if (len < 2)
                         goto trunc;
-                    aflags = *tptr;
-                    atype = *(tptr + 1);
+                    aflags = EXTRACT_8BITS(tptr);
+                    atype = EXTRACT_8BITS(tptr + 1);
                     tptr += 2;
                     len -= 2;
                     alenlen = bgp_attr_lenlen(aflags, tptr);
@@ -2510,7 +2516,7 @@ bgp_update_print(netdissect_options *ndo,
        length -= BGP_SIZE;
 
        /* Unfeasible routes */
-       ND_TCHECK2(p[0], 2);
+       ND_TCHECK_16BITS(p);
        if (length < 2)
                goto trunc;
        withdrawn_routes_len = EXTRACT_BE_16BITS(p);
@@ -2530,7 +2536,7 @@ bgp_update_print(netdissect_options *ndo,
                length -= withdrawn_routes_len;
        }
 
-       ND_TCHECK2(p[0], 2);
+       ND_TCHECK_16BITS(p);
        if (length < 2)
                goto trunc;
        len = EXTRACT_BE_16BITS(p);
@@ -2553,8 +2559,8 @@ bgp_update_print(netdissect_options *ndo,
                            goto trunc;
                        if (length < 2)
                            goto trunc;
-                       aflags = *p;
-                       atype = *(p + 1);
+                       aflags = EXTRACT_8BITS(p);
+                       atype = EXTRACT_8BITS(p + 1);
                        p += 2;
                        len -= 2;
                        length -= 2;
@@ -2710,8 +2716,8 @@ bgp_notification_print(netdissect_options *ndo,
                bgpn.bgpn_minor == BGP_NOTIFY_MINOR_CEASE_RESET) &&
                length >= BGP_NOTIFICATION_SIZE + 1) {
                    tptr = dat + BGP_NOTIFICATION_SIZE;
-                   ND_TCHECK2(*tptr, 1);
-                   shutdown_comm_length = *(tptr);
+                   ND_TCHECK_8BITS(tptr);
+                   shutdown_comm_length = EXTRACT_8BITS(tptr);
                    remainder_offset = 0;
                    /* garbage, hexdump it all */
                    if (shutdown_comm_length > BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN ||
index 2f97352129aa5abd02d36e574e81ca7ba7175c89..5a368cf282e01f99a88f0e330913ecceaa9ebdae 100644 (file)
@@ -354,8 +354,8 @@ bootp_print(netdissect_options *ndo,
                ND_PRINT((ndo, "\n\t  Client-Ethernet-Address %s", etheraddr_string(ndo, bp->bp_chaddr)));
        }
 
-       ND_TCHECK2(bp->bp_sname[0], 1);         /* check first char only */
-       if (*bp->bp_sname) {
+       ND_TCHECK_8BITS(bp->bp_sname);          /* check first char only */
+       if (EXTRACT_8BITS(bp->bp_sname)) {
                ND_PRINT((ndo, "\n\t  sname \""));
                if (fn_printztn(ndo, bp->bp_sname, (u_int)sizeof bp->bp_sname,
                    ndo->ndo_snapend)) {
@@ -365,8 +365,8 @@ bootp_print(netdissect_options *ndo,
                }
                ND_PRINT((ndo, "\""));
        }
-       ND_TCHECK2(bp->bp_file[0], 1);          /* check first char only */
-       if (*bp->bp_file) {
+       ND_TCHECK_8BITS(bp->bp_file);           /* check first char only */
+       if (EXTRACT_8BITS(bp->bp_file)) {
                ND_PRINT((ndo, "\n\t  file \""));
                if (fn_printztn(ndo, bp->bp_file, (u_int)sizeof bp->bp_file,
                    ndo->ndo_snapend)) {
@@ -611,14 +611,15 @@ rfc1048_print(netdissect_options *ndo,
        bp += sizeof(int32_t);
 
        /* Loop while we there is a tag left in the buffer */
-       while (ND_TTEST2(*bp, 1)) {
-               tag = *bp++;
+       while (ND_TTEST_8BITS(bp)) {
+               tag = EXTRACT_8BITS(bp);
+               bp++;
                if (tag == TAG_PAD && ndo->ndo_vflag < 3)
                        continue;
                if (tag == TAG_END && ndo->ndo_vflag < 3)
                        return;
                if (tag == TAG_EXTENDED_OPTION) {
-                       ND_TCHECK2(*(bp + 1), 2);
+                       ND_TCHECK_16BITS(bp + 1);
                        tag = EXTRACT_BE_16BITS(bp + 1);
                        /* XXX we don't know yet if the IANA will
                         * preclude overlap of 1-byte and 2-byte spaces.
@@ -633,8 +634,9 @@ rfc1048_print(netdissect_options *ndo,
                        len = 0;
                else {
                        /* Get the length; check for truncation */
-                       ND_TCHECK2(*bp, 1);
-                       len = *bp++;
+                       ND_TCHECK_8BITS(bp);
+                       len = EXTRACT_8BITS(bp);
+                       bp++;
                }
 
                ND_PRINT((ndo, "\n\t    %s Option %u, length %u%s", cp, tag, len,
@@ -642,7 +644,8 @@ rfc1048_print(netdissect_options *ndo,
 
                if (tag == TAG_PAD && ndo->ndo_vflag > 2) {
                        u_int ntag = 1;
-                       while (ND_TTEST2(*bp, 1) && *bp == TAG_PAD) {
+                       while (ND_TTEST_8BITS(bp) &&
+                           EXTRACT_8BITS(bp) == TAG_PAD) {
                                bp++;
                                ntag++;
                        }
@@ -656,7 +659,8 @@ rfc1048_print(netdissect_options *ndo,
                }
 
                if (tag == TAG_DHCP_MESSAGE && len == 1) {
-                       uc = *bp++;
+                       uc = EXTRACT_8BITS(bp);
+                       bp++;
                        ND_PRINT((ndo, "%s", tok2str(dhcp_msg_values, "Unknown (%u)", uc)));
                        continue;
                }
@@ -664,7 +668,8 @@ rfc1048_print(netdissect_options *ndo,
                if (tag == TAG_PARM_REQUEST) {
                        idx = 0;
                        while (len-- > 0) {
-                               uc = *bp++;
+                               uc = EXTRACT_8BITS(bp);
+                               bp++;
                                cp = tok2str(tag2str, "?Option %u", uc);
                                if (idx % 4 == 0)
                                        ND_PRINT((ndo, "\n\t      "));
@@ -769,9 +774,11 @@ rfc1048_print(netdissect_options *ndo,
                case 'B':
                        /* boolean */
                        while (len > 0) {
+                               uint8_t bool_value;
                                if (!first)
                                        ND_PRINT((ndo, ","));
-                               switch (*bp) {
+                               bool_value = EXTRACT_8BITS(bp);
+                               switch (bool_value) {
                                case 0:
                                        ND_PRINT((ndo, "N"));
                                        break;
@@ -779,7 +786,7 @@ rfc1048_print(netdissect_options *ndo,
                                        ND_PRINT((ndo, "Y"));
                                        break;
                                default:
-                                       ND_PRINT((ndo, "%u?", *bp));
+                                       ND_PRINT((ndo, "%u?", bool_value));
                                        break;
                                }
                                ++bp;
@@ -793,12 +800,14 @@ rfc1048_print(netdissect_options *ndo,
                default:
                        /* Bytes */
                        while (len > 0) {
+                               uint8_t byte_value;
                                if (!first)
                                        ND_PRINT((ndo, c == 'x' ? ":" : "."));
+                               byte_value = EXTRACT_8BITS(bp);
                                if (c == 'x')
-                                       ND_PRINT((ndo, "%02x", *bp));
+                                       ND_PRINT((ndo, "%02x", byte_value));
                                else
-                                       ND_PRINT((ndo, "%u", *bp));
+                                       ND_PRINT((ndo, "%u", byte_value));
                                ++bp;
                                --len;
                                first = 0;
@@ -815,7 +824,8 @@ rfc1048_print(netdissect_options *ndo,
                                        ND_PRINT((ndo, "ERROR: length < 1 bytes"));
                                        break;
                                }
-                               tag = *bp++;
+                               tag = EXTRACT_8BITS(bp);
+                               ++bp;
                                --len;
                                ND_PRINT((ndo, "%s", tok2str(nbo2str, NULL, tag)));
                                break;
@@ -826,7 +836,8 @@ rfc1048_print(netdissect_options *ndo,
                                        ND_PRINT((ndo, "ERROR: length < 1 bytes"));
                                        break;
                                }
-                               tag = *bp++;
+                               tag = EXTRACT_8BITS(bp);
+                               ++bp;
                                --len;
                                ND_PRINT((ndo, "%s", tok2str(oo2str, NULL, tag)));
                                break;
@@ -839,11 +850,11 @@ rfc1048_print(netdissect_options *ndo,
                                        len = 0;
                                        break;
                                }
-                               if (*bp)
+                               if (EXTRACT_8BITS(bp))
                                        ND_PRINT((ndo, "[%s] ", client_fqdn_flags(EXTRACT_8BITS(bp))));
                                bp++;
-                               if (*bp || *(bp+1))
-                                       ND_PRINT((ndo, "%u/%u ", *bp, *(bp+1)));
+                               if (EXTRACT_8BITS(bp) || EXTRACT_8BITS(bp+1))
+                                       ND_PRINT((ndo, "%u/%u ", EXTRACT_8BITS(bp), EXTRACT_8BITS(bp+1)));
                                bp += 2;
                                ND_PRINT((ndo, "\""));
                                if (fn_printn(ndo, bp, len - 3, ndo->ndo_snapend)) {
@@ -864,7 +875,8 @@ rfc1048_print(netdissect_options *ndo,
                                        ND_PRINT((ndo, "ERROR: length < 1 bytes"));
                                        break;
                                }
-                               type = *bp++;
+                               type = EXTRACT_8BITS(bp);
+                               bp++;
                                len--;
                                if (type == 0) {
                                        ND_PRINT((ndo, "\""));
@@ -881,7 +893,7 @@ rfc1048_print(netdissect_options *ndo,
                                        while (len > 0) {
                                                if (!first)
                                                        ND_PRINT((ndo, ":"));
-                                               ND_PRINT((ndo, "%02x", *bp));
+                                               ND_PRINT((ndo, "%02x", EXTRACT_8BITS(bp)));
                                                ++bp;
                                                --len;
                                                first = 0;
@@ -892,8 +904,9 @@ rfc1048_print(netdissect_options *ndo,
 
                        case TAG_AGENT_CIRCUIT:
                                while (len >= 2) {
-                                       subopt = *bp++;
-                                       suboptlen = *bp++;
+                                       subopt = EXTRACT_8BITS(bp);
+                                       suboptlen = EXTRACT_8BITS(bp+1);
+                                       bp += 2;
                                        len -= 2;
                                        if (suboptlen > len) {
                                                ND_PRINT((ndo, "\n\t      %s SubOption %u, length %u: length goes past end of option",
@@ -941,7 +954,8 @@ rfc1048_print(netdissect_options *ndo,
                                while (len > 0) {
                                        if (!first)
                                                ND_PRINT((ndo, ","));
-                                       mask_width = *bp++;
+                                       mask_width = EXTRACT_8BITS(bp);
+                                       bp++;
                                        len--;
                                        /* mask_width <= 32 */
                                        if (mask_width > 32) {
@@ -965,7 +979,8 @@ rfc1048_print(netdissect_options *ndo,
                                                for (i = 0; i < significant_octets ; i++) {
                                                        if (i > 0)
                                                                ND_PRINT((ndo, "."));
-                                                       ND_PRINT((ndo, "%d", *bp++));
+                                                       ND_PRINT((ndo, "%d", EXTRACT_8BITS(bp)));
+                                                       bp++;
                                                }
                                                for (i = significant_octets ; i < 4 ; i++)
                                                        ND_PRINT((ndo, ".0"));
@@ -992,7 +1007,8 @@ rfc1048_print(netdissect_options *ndo,
                                        break;
                                }
                                while (len > 0) {
-                                       suboptlen = *bp++;
+                                       suboptlen = EXTRACT_8BITS(bp);
+                                       bp++;
                                        len--;
                                        ND_PRINT((ndo, "\n\t      "));
                                        ND_PRINT((ndo, "instance#%u: ", suboptnumber));
index 2acd8e90273fe0876373f409398626a45c9824c4..ebd92c35cb1dd88d8284a6d95af269995011a056 100644 (file)
@@ -232,7 +232,7 @@ cfm_network_addr_print(netdissect_options *ndo,
         return hexdump;
     }
     /* The calling function must make any due ND_TCHECK calls. */
-    network_addr_type = *tptr;
+    network_addr_type = EXTRACT_8BITS(tptr);
     ND_PRINT((ndo, "\n\t  Network Address Type %s (%u)",
            tok2str(af_values, "Unknown", network_addr_type),
            network_addr_type));
@@ -567,7 +567,7 @@ cfm_print(netdissect_options *ndo,
             }
             ND_PRINT((ndo, ", Status: %s (%u)",
                    tok2str(cfm_tlv_port_status_values, "Unknown", EXTRACT_8BITS(tptr)),
-                   *tptr));
+                   EXTRACT_8BITS(tptr)));
             break;
 
         case CFM_TLV_INTERFACE_STATUS:
@@ -577,7 +577,7 @@ cfm_print(netdissect_options *ndo,
             }
             ND_PRINT((ndo, ", Status: %s (%u)",
                    tok2str(cfm_tlv_interface_status_values, "Unknown", EXTRACT_8BITS(tptr)),
-                   *tptr));
+                   EXTRACT_8BITS(tptr)));
             break;
 
         case CFM_TLV_PRIVATE:
@@ -606,7 +606,7 @@ cfm_print(netdissect_options *ndo,
              * Get the Chassis ID length and check it.
              * IEEE 802.1Q-2014 Section 21.5.3.1
              */
-            chassis_id_length = *tptr;
+            chassis_id_length = EXTRACT_8BITS(tptr);
             tptr++;
             tlen--;
             cfm_tlv_len--;
@@ -621,7 +621,7 @@ cfm_print(netdissect_options *ndo,
                     ND_PRINT((ndo, "\n\t  (TLV too short)"));
                     goto next_tlv;
                 }
-                chassis_id_type = *tptr;
+                chassis_id_type = EXTRACT_8BITS(tptr);
                 cfm_tlv_len--;
                 ND_PRINT((ndo, "\n\t  Chassis-ID Type %s (%u), Chassis-ID length %u",
                        tok2str(cfm_tlv_senderid_chassisid_values,
@@ -680,7 +680,7 @@ cfm_print(netdissect_options *ndo,
             }
 
             /* Here mgmt_addr_length stands for the management domain length. */
-            mgmt_addr_length = *tptr;
+            mgmt_addr_length = EXTRACT_8BITS(tptr);
             tptr++;
             tlen--;
             cfm_tlv_len--;
@@ -710,7 +710,7 @@ cfm_print(netdissect_options *ndo,
                 }
 
                 /* Here mgmt_addr_length stands for the management address length. */
-                mgmt_addr_length = *tptr;
+                mgmt_addr_length = EXTRACT_8BITS(tptr);
                 tptr++;
                 tlen--;
                 cfm_tlv_len--;
index cc2787a96b3ec5974e77f46411f5977addd9a159..2b16bc0037899c8454a9205a95f5f7687b45bb9c 100644 (file)
@@ -286,11 +286,15 @@ dhcp6opt_print(netdissect_options *ndo,
        uint16_t opttype;
        size_t optlen;
        uint8_t auth_proto;
+       uint8_t auth_alg;
+       uint8_t auth_rdm;
        u_int authinfolen, authrealmlen;
        int remain_len;  /* Length of remaining options */
        int label_len;   /* Label length */
        uint16_t subopt_code;
        uint16_t subopt_len;
+       uint8_t dh6_reconf_type;
+       uint8_t dh6_lq_query_type;
 
        if (cp == ep)
                return;
@@ -395,7 +399,7 @@ dhcp6opt_print(netdissect_options *ndo,
                                break;
                        }
                        tp = (const u_char *)(dh6o + 1);
-                       ND_PRINT((ndo, " %d)", *tp));
+                       ND_PRINT((ndo, " %d)", EXTRACT_8BITS(tp)));
                        break;
                case DH6OPT_ELAPSED_TIME:
                        if (optlen != 2) {
@@ -417,7 +421,7 @@ dhcp6opt_print(netdissect_options *ndo,
                                break;
                        }
                        tp = (const u_char *)(dh6o + 1);
-                       auth_proto = *tp;
+                       auth_proto = EXTRACT_8BITS(tp);
                        switch (auth_proto) {
                        case DH6OPT_AUTHPROTO_DELAYED:
                                ND_PRINT((ndo, " proto: delayed"));
@@ -430,22 +434,24 @@ dhcp6opt_print(netdissect_options *ndo,
                                break;
                        }
                        tp++;
-                       switch (*tp) {
+                       auth_alg = EXTRACT_8BITS(tp);
+                       switch (auth_alg) {
                        case DH6OPT_AUTHALG_HMACMD5:
                                /* XXX: may depend on the protocol */
                                ND_PRINT((ndo, ", alg: HMAC-MD5"));
                                break;
                        default:
-                               ND_PRINT((ndo, ", alg: %d", *tp));
+                               ND_PRINT((ndo, ", alg: %d", auth_alg));
                                break;
                        }
                        tp++;
-                       switch (*tp) {
+                       auth_rdm = EXTRACT_8BITS(tp);
+                       switch (auth_rdm) {
                        case DH6OPT_AUTHRDM_MONOCOUNTER:
                                ND_PRINT((ndo, ", RDM: mono"));
                                break;
                        default:
-                               ND_PRINT((ndo, ", RDM: %d", *tp));
+                               ND_PRINT((ndo, ", RDM: %d", auth_rdm));
                                break;
                        }
                        tp++;
@@ -468,7 +474,7 @@ dhcp6opt_print(netdissect_options *ndo,
                                        ND_PRINT((ndo, ", realm: "));
                                }
                                for (i = 0; i < authrealmlen; i++, tp++)
-                                       ND_PRINT((ndo, "%02x", *tp));
+                                       ND_PRINT((ndo, "%02x", EXTRACT_8BITS(tp)));
                                ND_PRINT((ndo, ", key ID: %08x", EXTRACT_BE_32BITS(tp)));
                                tp += 4;
                                ND_PRINT((ndo, ", HMAC-MD5:"));
@@ -480,7 +486,7 @@ dhcp6opt_print(netdissect_options *ndo,
                                        ND_PRINT((ndo, " ??"));
                                        break;
                                }
-                               switch (*tp++) {
+                               switch (EXTRACT_8BITS(tp)) {
                                case DH6OPT_AUTHRECONFIG_KEY:
                                        ND_PRINT((ndo, " reconfig-key"));
                                        break;
@@ -491,6 +497,7 @@ dhcp6opt_print(netdissect_options *ndo,
                                        ND_PRINT((ndo, " type: ??"));
                                        break;
                                }
+                               tp++;
                                ND_PRINT((ndo, " value:"));
                                for (i = 0; i < 4; i++, tp+= 4)
                                        ND_PRINT((ndo, " %08x", EXTRACT_BE_32BITS(tp)));
@@ -523,7 +530,8 @@ dhcp6opt_print(netdissect_options *ndo,
                                break;
                        }
                        tp = (const u_char *)(dh6o + 1);
-                       switch (*tp) {
+                       dh6_reconf_type = EXTRACT_8BITS(tp);
+                       switch (dh6_reconf_type) {
                        case DH6_RENEW:
                                ND_PRINT((ndo, " for renew)"));
                                break;
@@ -531,7 +539,7 @@ dhcp6opt_print(netdissect_options *ndo,
                                ND_PRINT((ndo, " for inf-req)"));
                                break;
                        default:
-                               ND_PRINT((ndo, " for ?\?\?(%02x))", *tp));
+                               ND_PRINT((ndo, " for ?\?\?(%02x))", dh6_reconf_type));
                                break;
                        }
                        break;
@@ -648,7 +656,8 @@ dhcp6opt_print(netdissect_options *ndo,
                                break;
                        }
                        tp = (const u_char *)(dh6o + 1);
-                       switch (*tp) {
+                       dh6_lq_query_type = EXTRACT_8BITS(tp);
+                       switch (dh6_lq_query_type) {
                        case 1:
                                ND_PRINT((ndo, " by-address"));
                                break;
@@ -656,7 +665,7 @@ dhcp6opt_print(netdissect_options *ndo,
                                ND_PRINT((ndo, " by-clientID"));
                                break;
                        default:
-                               ND_PRINT((ndo, " type_%d", (int)*tp));
+                               ND_PRINT((ndo, " type_%d", (int)dh6_lq_query_type));
                                break;
                        }
                        ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[1])));
@@ -733,13 +742,14 @@ dhcp6opt_print(netdissect_options *ndo,
                        remain_len = optlen;
                        ND_PRINT((ndo, " "));
                        /* Encoding is described in section 3.1 of RFC 1035 */
-                       while (remain_len && *tp) {
-                               label_len =  *tp++;
+                       while (remain_len && EXTRACT_8BITS(tp)) {
+                               label_len = EXTRACT_8BITS(tp);
+                               tp++;
                                if (label_len < remain_len - 1) {
                                        (void)fn_printn(ndo, tp, label_len, NULL);
                                        tp += label_len;
                                        remain_len -= (label_len + 1);
-                                       if(*tp) ND_PRINT((ndo, "."));
+                                       if(EXTRACT_8BITS(tp)) ND_PRINT((ndo, "."));
                                } else {
                                        ND_PRINT((ndo, " ?"));
                                        break;
index 3eea6ac7ee23898410eacb0c5c8030f104e2012a..1968608b3f27ac74917e8333b5461c5701bdcadd 100644 (file)
@@ -56,9 +56,10 @@ ns_nskip(netdissect_options *ndo,
 {
        register u_char i;
 
-       if (!ND_TTEST2(*cp, 1))
+       if (!ND_TTEST_8BITS(cp))
                return (NULL);
-       i = *cp++;
+       i = EXTRACT_8BITS(cp);
+       cp++;
        while (i) {
                if ((i & INDIR_MASK) == INDIR_MASK)
                        return (cp + 1);
@@ -67,17 +68,19 @@ ns_nskip(netdissect_options *ndo,
 
                        if ((i & ~INDIR_MASK) != EDNS0_ELT_BITLABEL)
                                return(NULL); /* unknown ELT */
-                       if (!ND_TTEST2(*cp, 1))
+                       if (!ND_TTEST_8BITS(cp))
                                return (NULL);
-                       if ((bitlen = *cp++) == 0)
+                       if ((bitlen = EXTRACT_8BITS(cp)) == 0)
                                bitlen = 256;
+                       cp++;
                        bytelen = (bitlen + 7) / 8;
                        cp += bytelen;
                } else
                        cp += i;
-               if (!ND_TTEST2(*cp, 1))
+               if (!ND_TTEST_8BITS(cp))
                        return (NULL);
-               i = *cp++;
+               i = EXTRACT_8BITS(cp);
+               cp++;
        }
        return (cp);
 }
@@ -91,9 +94,9 @@ blabel_print(netdissect_options *ndo,
        const u_char *bitp, *lim;
        char tc;
 
-       if (!ND_TTEST2(*cp, 1))
+       if (!ND_TTEST_8BITS(cp))
                return(NULL);
-       if ((bitlen = *cp) == 0)
+       if ((bitlen = EXTRACT_8BITS(cp)) == 0)
                bitlen = 256;
        slen = (bitlen + 3) / 4;
        lim = cp + 1 + slen;
@@ -106,11 +109,13 @@ blabel_print(netdissect_options *ndo,
        }
        if (b > 4) {
                ND_TCHECK(*bitp);
-               tc = *bitp++;
+               tc = EXTRACT_8BITS(bitp);
+               bitp++;
                ND_PRINT((ndo, "%02x", tc & (0xff << (8 - b))));
        } else if (b > 0) {
                ND_TCHECK(*bitp);
-               tc = *bitp++;
+               tc = EXTRACT_8BITS(bitp);
+               bitp++;
                ND_PRINT((ndo, "%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b))));
        }
        ND_PRINT((ndo, "/%d]", bitlen));
@@ -126,18 +131,18 @@ labellen(netdissect_options *ndo,
 {
        register u_int i;
 
-       if (!ND_TTEST2(*cp, 1))
+       if (!ND_TTEST_8BITS(cp))
                return(-1);
-       i = *cp;
+       i = EXTRACT_8BITS(cp);
        if ((i & INDIR_MASK) == EDNS0_MASK) {
                int bitlen, elt;
                if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL) {
                        ND_PRINT((ndo, "<ELT %d>", elt));
                        return(-1);
                }
-               if (!ND_TTEST2(*(cp + 1), 1))
+               if (!ND_TTEST_8BITS(cp + 1))
                        return(-1);
-               if ((bitlen = *(cp + 1)) == 0)
+               if ((bitlen = EXTRACT_8BITS(cp + 1)) == 0)
                        bitlen = 256;
                return(((bitlen + 7) / 8) + 1);
        } else
@@ -156,10 +161,12 @@ ns_nprint(netdissect_options *ndo,
 
        if ((l = labellen(ndo, cp)) == (u_int)-1)
                return(NULL);
-       if (!ND_TTEST2(*cp, 1))
+       if (!ND_TTEST_8BITS(cp))
                return(NULL);
        max_offset = (u_int)(cp - bp);
-       if (((i = *cp++) & INDIR_MASK) != INDIR_MASK) {
+       i = EXTRACT_8BITS(cp);
+       cp++;
+       if ((i & INDIR_MASK) != INDIR_MASK) {
                compress = 0;
                rp = cp + l;
        }
@@ -171,9 +178,9 @@ ns_nprint(netdissect_options *ndo,
                                        rp = cp + 1;
                                        compress = 1;
                                }
-                               if (!ND_TTEST2(*cp, 1))
+                               if (!ND_TTEST_8BITS(cp))
                                        return(NULL);
-                               offset = (((i << 8) | *cp) & 0x3fff);
+                               offset = (((i << 8) | EXTRACT_8BITS(cp)) & 0x3fff);
                                /*
                                 * This must move backwards in the packet.
                                 * No RFC explicitly says that, but BIND's
@@ -192,9 +199,10 @@ ns_nprint(netdissect_options *ndo,
                                cp = bp + offset;
                                if ((l = labellen(ndo, cp)) == (u_int)-1)
                                        return(NULL);
-                               if (!ND_TTEST2(*cp, 1))
+                               if (!ND_TTEST_8BITS(cp))
                                        return(NULL);
-                               i = *cp++;
+                               i = EXTRACT_8BITS(cp);
+                               cp++;
                                continue;
                        }
                        if ((i & INDIR_MASK) == EDNS0_MASK) {
@@ -218,9 +226,10 @@ ns_nprint(netdissect_options *ndo,
                        ND_PRINT((ndo, "."));
                        if ((l = labellen(ndo, cp)) == (u_int)-1)
                                return(NULL);
-                       if (!ND_TTEST2(*cp, 1))
+                       if (!ND_TTEST_8BITS(cp))
                                return(NULL);
-                       i = *cp++;
+                       i = EXTRACT_8BITS(cp);
+                       cp++;
                        if (!compress)
                                rp += l + 1;
                }
@@ -236,9 +245,10 @@ ns_cprint(netdissect_options *ndo,
 {
        register u_int i;
 
-       if (!ND_TTEST2(*cp, 1))
+       if (!ND_TTEST_8BITS(cp))
                return (NULL);
-       i = *cp++;
+       i = EXTRACT_8BITS(cp);
+       cp++;
        if (fn_printn(ndo, cp, i, ndo->ndo_snapend))
                return (NULL);
        return (cp + i);
@@ -502,9 +512,9 @@ ns_rprint(netdissect_options *ndo,
                int pbit, pbyte;
                char ntop_buf[INET6_ADDRSTRLEN];
 
-               if (!ND_TTEST2(*cp, 1))
+               if (!ND_TTEST_8BITS(cp))
                        return(NULL);
-               pbit = *cp;
+               pbit = EXTRACT_8BITS(cp);
                pbyte = (pbit & ~7) / 8;
                if (pbit > 128) {
                        ND_PRINT((ndo, " %u(bad plen)", pbit));
@@ -548,23 +558,23 @@ ns_rprint(netdissect_options *ndo,
                if ((cp = ns_nprint(ndo, cp, bp)) == NULL)
                        return(NULL);
                cp += 6;
-               if (!ND_TTEST2(*cp, 2))
+               if (!ND_TTEST_16BITS(cp))
                        return(NULL);
                ND_PRINT((ndo, " fudge=%u", EXTRACT_BE_16BITS(cp)));
                cp += 2;
-               if (!ND_TTEST2(*cp, 2))
+               if (!ND_TTEST_16BITS(cp))
                        return(NULL);
                ND_PRINT((ndo, " maclen=%u", EXTRACT_BE_16BITS(cp)));
                cp += 2 + EXTRACT_BE_16BITS(cp);
-               if (!ND_TTEST2(*cp, 2))
+               if (!ND_TTEST_16BITS(cp))
                        return(NULL);
                ND_PRINT((ndo, " origid=%u", EXTRACT_BE_16BITS(cp)));
                cp += 2;
-               if (!ND_TTEST2(*cp, 2))
+               if (!ND_TTEST_16BITS(cp))
                        return(NULL);
                ND_PRINT((ndo, " error=%u", EXTRACT_BE_16BITS(cp)));
                cp += 2;
-               if (!ND_TTEST2(*cp, 2))
+               if (!ND_TTEST_16BITS(cp))
                        return(NULL);
                ND_PRINT((ndo, " otherlen=%u", EXTRACT_BE_16BITS(cp)));
                cp += 2;
index 814b3598ddfa9fc46eda95e9fe874fc588d386ec..cab00a5537743abe9d3c4fab7de91fcddd5c7b66 100644 (file)
@@ -197,14 +197,16 @@ print_report(netdissect_options *ndo,
                        }
                        origin = 0;
                        for (i = 0; i < width; ++i) {
-                               ND_TCHECK(*bp);
-                               origin = origin << 8 | *bp++;
+                               ND_TCHECK_8BITS(bp);
+                               origin = origin << 8 | EXTRACT_8BITS(bp);
+                               bp++;
                        }
                        for ( ; i < 4; ++i)
                                origin <<= 8;
 
-                       ND_TCHECK(*bp);
-                       metric = *bp++;
+                       ND_TCHECK_8BITS(bp);
+                       metric = EXTRACT_8BITS(bp);
+                       bp++;
                        done = metric & 0x80;
                        metric &= 0x7f;
                        ND_PRINT((ndo, "\n\t  %s metric %d", intoa(htonl(origin)),
@@ -262,9 +264,12 @@ print_neighbors(netdissect_options *ndo,
                ND_TCHECK2(bp[0], 7);
                laddr = bp;
                bp += 4;
-               metric = *bp++;
-               thresh = *bp++;
-               ncount = *bp++;
+               metric = EXTRACT_8BITS(bp);
+               bp++;
+               thresh = EXTRACT_8BITS(bp);
+               bp++;
+               ncount = EXTRACT_8BITS(bp);
+               bp++;
                len -= 7;
                while (--ncount >= 0) {
                        ND_TCHECK2(bp[0], 4);
@@ -297,10 +302,14 @@ print_neighbors2(netdissect_options *ndo,
                ND_TCHECK2(bp[0], 8);
                laddr = bp;
                bp += 4;
-               metric = *bp++;
-               thresh = *bp++;
-               flags = *bp++;
-               ncount = *bp++;
+               metric = EXTRACT_8BITS(bp);
+               bp++;
+               thresh = EXTRACT_8BITS(bp);
+               bp++;
+               flags = EXTRACT_8BITS(bp);
+               bp++;
+               ncount = EXTRACT_8BITS(bp);
+               bp++;
                len -= 8;
                while (--ncount >= 0 && (len >= 4) && (bp + 4) <= ep) {
                        ND_PRINT((ndo, " [%s -> ", ipaddr_string(ndo, laddr)));
index b262ac59fdaed1986d079dd3dde4c2bbe92e4ce7..efb2d0200ac5ba1d319f7492ada0a91f7c784617 100644 (file)
@@ -102,44 +102,44 @@ static int parse_q922_addr(netdissect_options *ndo,
                            const u_char *p, u_int *dlci,
                            u_int *addr_len, uint8_t *flags, u_int length)
 {
-       if (!ND_TTEST(p[0]) || length < 1)
+       if (!ND_TTEST_8BITS(p) || length < 1)
                return -1;
-       if ((p[0] & FR_EA_BIT))
+       if ((EXTRACT_8BITS(p) & FR_EA_BIT))
                return 0;
 
-       if (!ND_TTEST(p[1]) || length < 2)
+       if (!ND_TTEST_8BITS(p+1) || length < 2)
                return -1;
        *addr_len = 2;
-       *dlci = ((p[0] & 0xFC) << 2) | ((p[1] & 0xF0) >> 4);
+       *dlci = ((EXTRACT_8BITS(p) & 0xFC) << 2) | ((EXTRACT_8BITS(p+1) & 0xF0) >> 4);
 
-        flags[0] = p[0] & 0x02; /* populate the first flag fields */
-        flags[1] = p[1] & 0x0c;
+        flags[0] = EXTRACT_8BITS(p) & 0x02; /* populate the first flag fields */
+        flags[1] = EXTRACT_8BITS(p+1) & 0x0c;
         flags[2] = 0;           /* clear the rest of the flags */
         flags[3] = 0;
 
-       if (p[1] & FR_EA_BIT)
+       if (EXTRACT_8BITS(p+1) & FR_EA_BIT)
                return 1;       /* 2-byte Q.922 address */
 
        p += 2;
        length -= 2;
-       if (!ND_TTEST(p[0]) || length < 1)
+       if (!ND_TTEST_8BITS(p) || length < 1)
                return -1;
        (*addr_len)++;          /* 3- or 4-byte Q.922 address */
-       if ((p[0] & FR_EA_BIT) == 0) {
-               *dlci = (*dlci << 7) | (p[0] >> 1);
+       if ((EXTRACT_8BITS(p) & FR_EA_BIT) == 0) {
+               *dlci = (*dlci << 7) | (EXTRACT_8BITS(p) >> 1);
                (*addr_len)++;  /* 4-byte Q.922 address */
                p++;
                length--;
        }
 
-       if (!ND_TTEST(p[0]) || length < 1)
+       if (!ND_TTEST_8BITS(p) || length < 1)
                return -1;
-       if ((p[0] & FR_EA_BIT) == 0)
+       if ((EXTRACT_8BITS(p) & FR_EA_BIT) == 0)
                return 0; /* more than 4 bytes of Q.922 address? */
 
-        flags[3] = p[0] & 0x02;
+        flags[3] = EXTRACT_8BITS(p) & 0x02;
 
-        *dlci = (*dlci << 6) | (p[0] >> 2);
+        *dlci = (*dlci << 6) | (EXTRACT_8BITS(p) >> 2);
 
        return 1;
 }
@@ -253,19 +253,19 @@ fr_print(netdissect_options *ndo,
                return 0;
        }
 
-       ND_TCHECK(p[addr_len]);
+       ND_TCHECK_8BITS(p + addr_len);
        if (length < addr_len + 1)
                goto trunc;
 
-       if (p[addr_len] != LLC_UI && dlci != 0) {
+       if (EXTRACT_8BITS(p + addr_len) != LLC_UI && dlci != 0) {
                 /*
                  * Let's figure out if we have Cisco-style encapsulation,
                  * with an Ethernet type (Cisco HDLC type?) following the
                  * address.
                  */
-               if (!ND_TTEST2(p[addr_len], 2) || length < addr_len + 2) {
+               if (!ND_TTEST_16BITS(p + addr_len) || length < addr_len + 2) {
                         /* no Ethertype */
-                        ND_PRINT((ndo, "UI %02x! ", p[addr_len]));
+                        ND_PRINT((ndo, "UI %02x! ", EXTRACT_8BITS(p + addr_len)));
                 } else {
                         extracted_ethertype = EXTRACT_BE_16BITS(p + addr_len);
 
@@ -279,17 +279,17 @@ fr_print(netdissect_options *ndo,
                                             ndo->ndo_snapend-p-addr_len-ETHERTYPE_LEN,
                                             NULL, NULL) == 0)
                                 /* ether_type not known, probably it wasn't one */
-                                ND_PRINT((ndo, "UI %02x! ", p[addr_len]));
+                                ND_PRINT((ndo, "UI %02x! ", EXTRACT_8BITS(p + addr_len)));
                         else
                                 return addr_len + 2;
                 }
         }
 
-       ND_TCHECK(p[addr_len+1]);
+       ND_TCHECK_8BITS(p + addr_len + 1);
        if (length < addr_len + 2)
                goto trunc;
 
-       if (p[addr_len + 1] == 0) {
+       if (EXTRACT_8BITS(p + addr_len + 1) == 0) {
                /*
                 * Assume a pad byte after the control (UI) byte.
                 * A pad byte should only be used with 3-byte Q.922.
@@ -307,10 +307,10 @@ fr_print(netdissect_options *ndo,
                hdr_len = addr_len + 1 /* UI */ + 1 /* NLPID */;
        }
 
-        ND_TCHECK(p[hdr_len - 1]);
+        ND_TCHECK_8BITS(p + hdr_len - 1);
        if (length < hdr_len)
                goto trunc;
-       nlpid = p[hdr_len - 1];
+       nlpid = EXTRACT_8BITS(p + hdr_len - 1);
 
        if (ndo->ndo_eflag)
                fr_hdr_print(ndo, length, addr_len, dlci, flags, nlpid);
@@ -458,10 +458,10 @@ mfr_print(netdissect_options *ndo,
 
     ND_TCHECK2(*p, 4); /* minimum frame header length */
 
-    if ((p[0] & MFR_BEC_MASK) == MFR_CTRL_FRAME && p[1] == 0) {
+    if ((EXTRACT_8BITS(p) & MFR_BEC_MASK) == MFR_CTRL_FRAME && EXTRACT_8BITS(p+1) == 0) {
         ND_PRINT((ndo, "FRF.16 Control, Flags [%s], %s, length %u",
-               bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)),
-               tok2str(mfr_ctrl_msg_values,"Unknown Message (0x%02x)",p[2]),
+               bittok2str(frf_flag_values,"none",(EXTRACT_8BITS(p) & MFR_BEC_MASK)),
+               tok2str(mfr_ctrl_msg_values,"Unknown Message (0x%02x)",EXTRACT_8BITS(p+2)),
                length));
         tptr = p + 3;
         tlen = length -3;
@@ -552,13 +552,13 @@ mfr_print(netdissect_options *ndo,
  *    +----+----+----+----+----+----+----+----+
  */
 
-    sequence_num = (p[0]&0x1e)<<7 | p[1];
+    sequence_num = (EXTRACT_8BITS(p)&0x1e)<<7 | EXTRACT_8BITS(p+1);
     /* whole packet or first fragment ? */
-    if ((p[0] & MFR_BEC_MASK) == MFR_FRAG_FRAME ||
-        (p[0] & MFR_BEC_MASK) == MFR_B_BIT) {
+    if ((EXTRACT_8BITS(p) & MFR_BEC_MASK) == MFR_FRAG_FRAME ||
+        (EXTRACT_8BITS(p) & MFR_BEC_MASK) == MFR_B_BIT) {
         ND_PRINT((ndo, "FRF.16 Frag, seq %u, Flags [%s], ",
                sequence_num,
-               bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK))));
+               bittok2str(frf_flag_values,"none",(EXTRACT_8BITS(p) & MFR_BEC_MASK))));
         hdr_len = 2;
         fr_print(ndo, p+hdr_len,length-hdr_len);
         return hdr_len;
@@ -567,7 +567,7 @@ mfr_print(netdissect_options *ndo,
     /* must be a middle or the last fragment */
     ND_PRINT((ndo, "FRF.16 Frag, seq %u, Flags [%s]",
            sequence_num,
-           bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK))));
+           bittok2str(frf_flag_values,"none",(EXTRACT_8BITS(p) & MFR_BEC_MASK))));
     print_unknown_data(ndo, p, "\n\t", length);
 
     return hdr_len;
@@ -604,13 +604,13 @@ frf15_print(netdissect_options *ndo,
         goto trunc;
     ND_TCHECK2(*p, 2);
 
-    flags = p[0]&MFR_BEC_MASK;
-    sequence_num = (p[0]&0x1e)<<7 | p[1];
+    flags = EXTRACT_8BITS(p)&MFR_BEC_MASK;
+    sequence_num = (EXTRACT_8BITS(p)&0x1e)<<7 | EXTRACT_8BITS(p+1);
 
     ND_PRINT((ndo, "FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u",
            sequence_num,
            bittok2str(frf_flag_values,"none",flags),
-           p[0]&FR_FRF15_FRAGTYPE ? "Interface" : "End-to-End",
+           EXTRACT_8BITS(p)&FR_FRF15_FRAGTYPE ? "Interface" : "End-to-End",
            length));
 
 /* TODO:
@@ -813,7 +813,7 @@ q933_print(netdissect_options *ndo,
         * Get the length of the call reference value.
         */
        olen = length; /* preserve the original length for display */
-       call_ref_length = (*p) & 0x0f;
+       call_ref_length = EXTRACT_8BITS(p) & 0x0f;
        p++;
        length--;
 
@@ -827,7 +827,7 @@ q933_print(netdissect_options *ndo,
                        ND_PRINT((ndo, "length %u", olen));
                        goto trunc;
                }
-               call_ref[i] = *p;
+               call_ref[i] = EXTRACT_8BITS(p);
                p++;
                length--;
        }
@@ -841,7 +841,7 @@ q933_print(netdissect_options *ndo,
                ND_PRINT((ndo, "length %u", olen));
                goto trunc;
        }
-       msgtype = *p;
+       msgtype = EXTRACT_8BITS(p);
        p++;
        length--;
 
@@ -857,7 +857,7 @@ q933_print(netdissect_options *ndo,
                        ND_PRINT((ndo, "length %u", olen));
                        goto trunc;
                }
-               iecode = *p;
+               iecode = EXTRACT_8BITS(p);
                if (IE_IS_SHIFT(iecode)) {
                        /*
                         * It's a shift.  Skip over it.
@@ -907,8 +907,8 @@ q933_print(netdissect_options *ndo,
        ND_PRINT((ndo, "%s, codeset %u", is_ansi ? "ANSI" : "CCITT", codeset));
 
        if (call_ref_length != 0) {
-               ND_TCHECK(p[0]);
-               if (call_ref_length > 1 || p[0] != 0) {
+               ND_TCHECK(EXTRACT_8BITS(p));
+               if (call_ref_length > 1 || EXTRACT_8BITS(p) != 0) {
                        /*
                         * Not a dummy call reference.
                         */
@@ -958,7 +958,7 @@ q933_print(netdissect_options *ndo,
                        }
                        goto trunc;
                }
-               iecode = *p;
+               iecode = EXTRACT_8BITS(p);
                p++;
                length--;
 
@@ -1001,7 +1001,7 @@ q933_print(netdissect_options *ndo,
                                }
                                goto trunc;
                        }
-                       ielength = *p;
+                       ielength = EXTRACT_8BITS(p);
                        p++;
                        length--;
 
@@ -1083,8 +1083,8 @@ fr_q933_print_ie_codeset_0_5(netdissect_options *ndo, u_int iecode,
             }
             if (ndo->ndo_vflag) {
                 ND_PRINT((ndo, "%s (%u)",
-                       tok2str(fr_lmi_report_type_ie_values,"unknown",p[0]),
-                       p[0]));
+                       tok2str(fr_lmi_report_type_ie_values,"unknown",EXTRACT_8BITS(p)),
+                       EXTRACT_8BITS(p)));
            }
             return 1;
 
@@ -1098,7 +1098,7 @@ fr_q933_print_ie_codeset_0_5(netdissect_options *ndo, u_int iecode,
                 ND_PRINT((ndo, "Invalid LINK VERIFY IE"));
                 return 1;
             }
-            ND_PRINT((ndo, "TX Seq: %3d, RX Seq: %3d", p[0], p[1]));
+            ND_PRINT((ndo, "TX Seq: %3d, RX Seq: %3d", EXTRACT_8BITS(p), EXTRACT_8BITS(p+1)));
             return 1;
 
         case FR_LMI_ANSI_PVC_STATUS_IE: /* fall through */
@@ -1108,28 +1108,30 @@ fr_q933_print_ie_codeset_0_5(netdissect_options *ndo, u_int iecode,
            }
             /* now parse the DLCI information element. */
             if ((ielength < 3) ||
-                (p[0] & 0x80) ||
-                ((ielength == 3) && !(p[1] & 0x80)) ||
-                ((ielength == 4) && ((p[1] & 0x80) || !(p[2] & 0x80))) ||
-                ((ielength == 5) && ((p[1] & 0x80) || (p[2] & 0x80) ||
-                                   !(p[3] & 0x80))) ||
+                (EXTRACT_8BITS(p) & 0x80) ||
+                ((ielength == 3) && !(EXTRACT_8BITS(p+1) & 0x80)) ||
+                ((ielength == 4) &&
+                  ((EXTRACT_8BITS(p+1) & 0x80) || !(EXTRACT_8BITS(p+2) & 0x80))) ||
+                ((ielength == 5) &&
+                  ((EXTRACT_8BITS(p+1) & 0x80) || (EXTRACT_8BITS(p+2) & 0x80) ||
+                   !(EXTRACT_8BITS(p+3) & 0x80))) ||
                 (ielength > 5) ||
-                !(p[ielength - 1] & 0x80)) {
+                !(EXTRACT_8BITS(p + ielength - 1) & 0x80)) {
                 ND_PRINT((ndo, "Invalid DLCI in PVC STATUS IE"));
                 return 1;
            }
 
-            dlci = ((p[0] & 0x3F) << 4) | ((p[1] & 0x78) >> 3);
+            dlci = ((EXTRACT_8BITS(p) & 0x3F) << 4) | ((EXTRACT_8BITS(p+1) & 0x78) >> 3);
             if (ielength == 4) {
-                dlci = (dlci << 6) | ((p[2] & 0x7E) >> 1);
+                dlci = (dlci << 6) | ((EXTRACT_8BITS(p+2) & 0x7E) >> 1);
            }
             else if (ielength == 5) {
-                dlci = (dlci << 13) | (p[2] & 0x7F) | ((p[3] & 0x7E) >> 1);
+                dlci = (dlci << 13) | (EXTRACT_8BITS(p+2) & 0x7F) | ((EXTRACT_8BITS(p+3) & 0x7E) >> 1);
            }
 
             ND_PRINT((ndo, "DLCI %u: status %s%s", dlci,
-                    p[ielength - 1] & 0x8 ? "New, " : "",
-                    p[ielength - 1] & 0x2 ? "Active" : "Inactive"));
+                    EXTRACT_8BITS(p + ielength - 1) & 0x8 ? "New, " : "",
+                    EXTRACT_8BITS(p + ielength - 1) & 0x2 ? "Active" : "Inactive"));
             return 1;
        }
 
index 7d6014a63cf5a1114dacc9f63edfcdae2645ba48..f7054fb54bf733fced240c033e9f8a3e13a02c83 100644 (file)
@@ -157,7 +157,7 @@ geneve_print(netdissect_options *ndo, const u_char *bp, u_int len)
 
     ND_TCHECK2(*bp, 8);
 
-    ver_opt = *bp;
+    ver_opt = EXTRACT_8BITS(bp);
     bp += 1;
     len -= 1;
 
@@ -167,7 +167,7 @@ geneve_print(netdissect_options *ndo, const u_char *bp, u_int len)
         return;
     }
 
-    flags = *bp;
+    flags = EXTRACT_8BITS(bp);
     bp += 1;
     len -= 1;
 
@@ -179,7 +179,7 @@ geneve_print(netdissect_options *ndo, const u_char *bp, u_int len)
     bp += 3;
     len -= 3;
 
-    reserved = *bp;
+    reserved = EXTRACT_8BITS(bp);
     bp += 1;
     len -= 1;
 
index 0eef061117338d1b4543805a319544adeef437b2..692de8ee77548dff655ba1827ff71c714a4a2d23 100644 (file)
@@ -797,8 +797,10 @@ clnp_print(netdissect_options *ndo,
 
         if (li < sizeof(struct clnp_header_t)) {
             ND_PRINT((ndo, " length indicator %u < min PDU size:", li));
-            while (pptr < ndo->ndo_snapend)
-                ND_PRINT((ndo, "%02X", *pptr++));
+            while (pptr < ndo->ndo_snapend) {
+                ND_PRINT((ndo, "%02X", EXTRACT_8BITS(pptr)));
+                pptr++;
+            }
             return (0);
         }
 
@@ -815,7 +817,7 @@ clnp_print(netdissect_options *ndo,
             return (0);
         }
        ND_TCHECK(*pptr);
-        dest_address_length = *pptr;
+        dest_address_length = EXTRACT_8BITS(pptr);
         pptr += 1;
         li -= 1;
         if (li < dest_address_length) {
@@ -832,7 +834,7 @@ clnp_print(netdissect_options *ndo,
             return (0);
         }
        ND_TCHECK(*pptr);
-        source_address_length = *pptr;
+        source_address_length = EXTRACT_8BITS(pptr);
         pptr += 1;
         li -= 1;
         if (li < source_address_length) {
@@ -901,8 +903,9 @@ clnp_print(netdissect_options *ndo,
                 return (0);
             }
             ND_TCHECK2(*pptr, 2);
-            op = *pptr++;
-            opli = *pptr++;
+            op = EXTRACT_8BITS(pptr);
+            opli = EXTRACT_8BITS(pptr + 1);
+            pptr += 2;
             li -= 2;
             if (opli > li) {
                 ND_PRINT((ndo, ", opt (%d) too long", op));
@@ -938,7 +941,7 @@ clnp_print(netdissect_options *ndo,
                     ND_PRINT((ndo, "%s %s",
                            tok2str(clnp_option_sr_rr_values,"Unknown",EXTRACT_8BITS(tptr)),
                            tok2str(clnp_option_sr_rr_string_values, "Unknown Option %u", op)));
-                    nsap_offset=*(tptr+1);
+                    nsap_offset=EXTRACT_8BITS(tptr+1);
                     if (nsap_offset == 0) {
                             ND_PRINT((ndo, " Bad NSAP offset (0)"));
                             break;
@@ -951,7 +954,7 @@ clnp_print(netdissect_options *ndo,
                     tptr+=nsap_offset;
                     tlen-=nsap_offset;
                     while (tlen > 0) {
-                            source_address_length=*tptr;
+                            source_address_length=EXTRACT_8BITS(tptr);
                             if (tlen < source_address_length+1) {
                                     ND_PRINT((ndo, "\n\t    NSAP address goes past end of option"));
                                     break;
@@ -972,7 +975,7 @@ clnp_print(netdissect_options *ndo,
                             ND_PRINT((ndo, ", bad opt len"));
                             return (0);
                     }
-                    ND_PRINT((ndo, "0x%1x", *tptr&0x0f));
+                    ND_PRINT((ndo, "0x%1x", EXTRACT_8BITS(tptr)&0x0f));
                     break;
 
             case CLNP_OPTION_QOS_MAINTENANCE:
@@ -983,11 +986,11 @@ clnp_print(netdissect_options *ndo,
                     ND_PRINT((ndo, "\n\t    Format Code: %s",
                            tok2str(clnp_option_scope_values, "Reserved", EXTRACT_8BITS(tptr) & CLNP_OPTION_SCOPE_MASK)));
 
-                    if ((*tptr&CLNP_OPTION_SCOPE_MASK) == CLNP_OPTION_SCOPE_GLOBAL)
+                    if ((EXTRACT_8BITS(tptr)&CLNP_OPTION_SCOPE_MASK) == CLNP_OPTION_SCOPE_GLOBAL)
                             ND_PRINT((ndo, "\n\t    QoS Flags [%s]",
                                    bittok2str(clnp_option_qos_global_values,
                                               "none",
-                                              *tptr&CLNP_OPTION_OPTION_QOS_MASK)));
+                                              EXTRACT_8BITS(tptr)&CLNP_OPTION_OPTION_QOS_MASK)));
                     break;
 
             case CLNP_OPTION_SECURITY:
@@ -996,8 +999,8 @@ clnp_print(netdissect_options *ndo,
                             return (0);
                     }
                     ND_PRINT((ndo, "\n\t    Format Code: %s, Security-Level %u",
-                           tok2str(clnp_option_scope_values,"Reserved",EXTRACT_8BITS(tptr) & CLNP_OPTION_SCOPE_MASK),
-                           *(tptr+1)));
+                           tok2str(clnp_option_scope_values,"Reserved",EXTRACT_8BITS(tptr)&CLNP_OPTION_SCOPE_MASK),
+                           EXTRACT_8BITS(tptr+1)));
                     break;
 
             case CLNP_OPTION_DISCARD_REASON:
@@ -1038,7 +1041,7 @@ clnp_print(netdissect_options *ndo,
         case    CLNP_PDU_ER: /* fall through */
         case   CLNP_PDU_ERP:
             ND_TCHECK(*pptr);
-            if (*(pptr) == NLPID_CLNP) {
+            if (EXTRACT_8BITS(pptr) == NLPID_CLNP) {
                 ND_PRINT((ndo, "\n\t-----original packet-----\n\t"));
                 /* FIXME recursion protection */
                 clnp_print(ndo, pptr, length - clnp_header->length_indicator);
@@ -1129,8 +1132,10 @@ esis_print(netdissect_options *ndo,
 
        if (li < sizeof(struct esis_header_t) + 2) {
             ND_PRINT((ndo, " length indicator %u < min PDU size:", li));
-            while (pptr < ndo->ndo_snapend)
-                ND_PRINT((ndo, "%02X", *pptr++));
+            while (pptr < ndo->ndo_snapend) {
+                ND_PRINT((ndo, "%02X", EXTRACT_8BITS(pptr)));
+                pptr++;
+            }
             return;
        }
 
@@ -1174,7 +1179,7 @@ esis_print(netdissect_options *ndo,
                        ND_PRINT((ndo, ", bad redirect/li"));
                        return;
                }
-               dstl = *pptr;
+               dstl = EXTRACT_8BITS(pptr);
                pptr++;
                li--;
                ND_TCHECK2(*pptr, dstl);
@@ -1192,7 +1197,7 @@ esis_print(netdissect_options *ndo,
                        ND_PRINT((ndo, ", bad redirect/li"));
                        return;
                }
-               snpal = *pptr;
+               snpal = EXTRACT_8BITS(pptr);
                pptr++;
                li--;
                ND_TCHECK2(*pptr, snpal);
@@ -1208,7 +1213,7 @@ esis_print(netdissect_options *ndo,
                        ND_PRINT((ndo, ", bad redirect/li"));
                        return;
                }
-               netal = *pptr;
+               netal = EXTRACT_8BITS(pptr);
                pptr++;
                ND_TCHECK2(*pptr, netal);
                if (li < netal) {
@@ -1240,7 +1245,7 @@ esis_print(netdissect_options *ndo,
                 ND_PRINT((ndo, ", bad esh/li"));
                 return;
             }
-            source_address_number = *pptr;
+            source_address_number = EXTRACT_8BITS(pptr);
             pptr++;
             li--;
 
@@ -1252,7 +1257,7 @@ esis_print(netdissect_options *ndo,
                     ND_PRINT((ndo, ", bad esh/li"));
                    return;
                }
-                source_address_length = *pptr;
+                source_address_length = EXTRACT_8BITS(pptr);
                 pptr++;
                li--;
 
@@ -1277,7 +1282,7 @@ esis_print(netdissect_options *ndo,
                 ND_PRINT((ndo, ", bad ish/li"));
                 return;
             }
-            source_address_length = *pptr;
+            source_address_length = EXTRACT_8BITS(pptr);
             pptr++;
             li--;
             ND_TCHECK2(*pptr, source_address_length);
@@ -1309,8 +1314,9 @@ esis_print(netdissect_options *ndo,
                 return;
             }
             ND_TCHECK2(*pptr, 2);
-            op = *pptr++;
-            opli = *pptr++;
+            op = EXTRACT_8BITS(pptr);
+            opli = EXTRACT_8BITS(pptr + 1);
+            pptr += 2;
             li -= 2;
             if (opli > li) {
                 ND_PRINT((ndo, ", opt (%d) too long", op));
@@ -1336,12 +1342,12 @@ esis_print(netdissect_options *ndo,
 
             case ESIS_OPTION_PROTOCOLS:
                 while (opli>0) {
-                    ND_TCHECK(*tptr);
+                    ND_TCHECK_8BITS(tptr);
                     ND_PRINT((ndo, "%s (0x%02x)",
                            tok2str(nlpid_values,
                                    "unknown",
                                    EXTRACT_8BITS(tptr)),
-                           *tptr));
+                           EXTRACT_8BITS(tptr)));
                     if (opli>1) /* further NPLIDs ? - put comma */
                         ND_PRINT((ndo, ", "));
                     tptr++;
@@ -1406,8 +1412,8 @@ isis_print_mt_port_cap_subtlv(netdissect_options *ndo,
   while (len > 2)
   {
     ND_TCHECK2(*tptr, 2);
-    stlv_type = *(tptr++);
-    stlv_len  = *(tptr++);
+    stlv_type = EXTRACT_8BITS(tptr);
+    stlv_len  = EXTRACT_8BITS(tptr + 1);
 
     /* first lets see if we know the subTLVs name*/
     ND_PRINT((ndo, "\n\t       %s subTLV #%u, length: %u",
@@ -1415,8 +1421,9 @@ isis_print_mt_port_cap_subtlv(netdissect_options *ndo,
                stlv_type,
                stlv_len));
 
+    tptr = tptr + 2;
     /*len -= TLV_TYPE_LEN_OFFSET;*/
-    len = len -2;
+    len = len - 2;
 
     /* Make sure the subTLV fits within the space left */
     if (len < stlv_len)
@@ -1457,8 +1464,10 @@ isis_print_mt_port_cap_subtlv(netdissect_options *ndo,
           goto trunc;
 
         ND_PRINT((ndo, "\n\t        RES: %d V: %d A: %d D: %d",
-                        (*(tptr) >> 5), (((*tptr)>> 4) & 0x01),
-                        ((*(tptr) >> 2) & 0x03), ((*tptr) & 0x03)));
+                        (EXTRACT_8BITS(tptr) >> 5),
+                        ((EXTRACT_8BITS(tptr) >> 4) & 0x01),
+                        ((EXTRACT_8BITS(tptr) >> 2) & 0x03),
+                        (EXTRACT_8BITS(tptr) & 0x03)));
 
         tptr++;
 
@@ -1524,8 +1533,10 @@ isis_print_mt_capability_subtlv(netdissect_options *ndo,
   while (len > 2)
   {
     ND_TCHECK2(*tptr, 2);
-    stlv_type = *(tptr++);
-    stlv_len  = *(tptr++);
+    stlv_type = EXTRACT_8BITS(tptr);
+    stlv_len  = EXTRACT_8BITS(tptr + 1);
+    tptr = tptr + 2;
+    len = len - 2;
 
     /* first lets see if we know the subTLVs name*/
     ND_PRINT((ndo, "\n\t      %s subTLV #%u, length: %u",
@@ -1533,8 +1544,6 @@ isis_print_mt_capability_subtlv(netdissect_options *ndo,
                stlv_type,
                stlv_len));
 
-    len = len - 2;
-
     /* Make sure the subTLV fits within the space left */
     if (len < stlv_len)
       goto trunc;
@@ -1562,9 +1571,10 @@ isis_print_mt_capability_subtlv(netdissect_options *ndo,
           ND_PRINT((ndo, ", SPSource-ID: %d",
                     (EXTRACT_BE_32BITS(tptr) & 0x000fffff)));
           tptr = tptr+4;
-          ND_PRINT((ndo, ", No of Trees: %x", *(tptr)));
+          ND_PRINT((ndo, ", No of Trees: %x", EXTRACT_8BITS(tptr)));
 
-          tmp = *(tptr++);
+          tmp = EXTRACT_8BITS(tptr);
+          tptr++;
 
           len = len - ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN;
           stlv_len = stlv_len - ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN;
@@ -1575,8 +1585,10 @@ isis_print_mt_capability_subtlv(netdissect_options *ndo,
               goto trunc;
 
             ND_PRINT((ndo, "\n\t         U:%d, M:%d, A:%d, RES:%d",
-                      *(tptr) >> 7, (*(tptr) >> 6) & 0x01,
-                      (*(tptr) >> 5) & 0x01, (*(tptr) & 0x1f)));
+                      EXTRACT_8BITS(tptr) >> 7,
+                      (EXTRACT_8BITS(tptr) >> 6) & 0x01,
+                      (EXTRACT_8BITS(tptr) >> 5) & 0x01,
+                      (EXTRACT_8BITS(tptr) & 0x1f)));
 
             tptr++;
 
@@ -1613,7 +1625,7 @@ isis_print_mt_capability_subtlv(netdissect_options *ndo,
           stlv_len = stlv_len - 8;
 
           while (stlv_len >= 4) {
-            ND_TCHECK2(*tptr, 4);
+            ND_TCHECK_32BITS(tptr);
             ND_PRINT((ndo, "\n\t        T: %d, R: %d, RES: %d, ISID: %d",
                     (EXTRACT_BE_32BITS(tptr) >> 31),
                     (EXTRACT_BE_32BITS(tptr) >> 30) & 0x01,
@@ -1868,7 +1880,7 @@ isis_print_is_reach_subtlv(netdissect_options *ndo,
             ND_PRINT((ndo, "%sBandwidth Constraints Model ID: %s (%u)",
                    ident,
                    tok2str(diffserv_te_bc_values, "unknown", EXTRACT_8BITS(tptr)),
-                   *tptr));
+                   EXTRACT_8BITS(tptr)));
             tptr++;
             /* decode BCs until the subTLV ends */
             for (te_class = 0; te_class < (subl-1)/4; te_class++) {
@@ -1897,21 +1909,21 @@ isis_print_is_reach_subtlv(netdissect_options *ndo,
             if (subl >= 2) {
               ND_PRINT((ndo, ", %s, Priority %u",
                   bittok2str(gmpls_link_prot_values, "none", EXTRACT_8BITS(tptr)),
-                  *(tptr+1)));
+                  EXTRACT_8BITS(tptr+1)));
             }
             break;
         case ISIS_SUBTLV_SPB_METRIC:
             if (subl >= 6) {
               ND_PRINT((ndo, ", LM: %u", EXTRACT_BE_24BITS(tptr)));
               tptr=tptr+3;
-              ND_PRINT((ndo, ", P: %u", *(tptr)));
+              ND_PRINT((ndo, ", P: %u", EXTRACT_8BITS(tptr)));
               tptr++;
               ND_PRINT((ndo, ", P-ID: %u", EXTRACT_BE_16BITS(tptr)));
             }
             break;
         case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR:
             if (subl >= 36) {
-              gmpls_switch_cap = *tptr;
+              gmpls_switch_cap = EXTRACT_8BITS(tptr);
               ND_PRINT((ndo, "%s  Interface Switching Capability:%s",
                    ident,
                    tok2str(gmpls_switch_cap_values, "Unknown", gmpls_switch_cap)));
@@ -1988,15 +2000,16 @@ isis_print_ext_is_reach(netdissect_options *ndo,
     tptr+=NODE_ID_LEN;
 
     if (tlv_type != ISIS_TLV_IS_ALIAS_ID) { /* the Alias TLV Metric field is implicit 0 */
-        if (!ND_TTEST2(*tptr, 3))    /* and is therefore skipped */
+        if (!ND_TTEST_24BITS(tptr))    /* and is therefore skipped */
            return(0);
        ND_PRINT((ndo, ", Metric: %d", EXTRACT_BE_24BITS(tptr)));
        tptr+=3;
     }
 
-    if (!ND_TTEST2(*tptr, 1))
+    if (!ND_TTEST_8BITS(tptr))
         return(0);
-    subtlv_sum_len=*(tptr++); /* read out subTLV length */
+    subtlv_sum_len=EXTRACT_8BITS(tptr); /* read out subTLV length */
+    tptr++;
     proc_bytes=NODE_ID_LEN+3+1;
     ND_PRINT((ndo, ", %ssub-TLVs present",subtlv_sum_len ? "" : "no "));
     if (subtlv_sum_len) {
@@ -2004,8 +2017,9 @@ isis_print_ext_is_reach(netdissect_options *ndo,
         while (subtlv_sum_len>0) {
             if (!ND_TTEST2(*tptr,2))
                 return(0);
-            subtlv_type=*(tptr++);
-            subtlv_len=*(tptr++);
+            subtlv_type=EXTRACT_8BITS(tptr);
+            subtlv_len=EXTRACT_8BITS(tptr+1);
+            tptr+=2;
             /* prepend the indent string */
             snprintf(ident_buffer, sizeof(ident_buffer), "%s  ",ident);
             if (!isis_print_is_reach_subtlv(ndo, tptr, subtlv_type, subtlv_len, ident_buffer))
@@ -2027,7 +2041,7 @@ static int
 isis_print_mtid(netdissect_options *ndo,
                 const uint8_t *tptr, const char *ident)
 {
-    if (!ND_TTEST2(*tptr, 2))
+    if (!ND_TTEST_16BITS(tptr))
         return(0);
 
     ND_PRINT((ndo, "%s%s",
@@ -2058,16 +2072,17 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
     uint8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
     u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen;
 
-    if (!ND_TTEST2(*tptr, 4))
+    if (!ND_TTEST_32BITS(tptr))
         return (0);
     metric = EXTRACT_BE_32BITS(tptr);
     processed=4;
     tptr+=4;
 
     if (afi == AF_INET) {
-        if (!ND_TTEST2(*tptr, 1)) /* fetch status byte */
+        if (!ND_TTEST_8BITS(tptr)) /* fetch status byte */
             return (0);
-        status_byte=*(tptr++);
+        status_byte=EXTRACT_8BITS(tptr);
+        tptr++;
         bit_length = status_byte&0x3f;
         if (bit_length > 32) {
             ND_PRINT((ndo, "%sIPv4 prefix: bad bit length %u",
@@ -2079,14 +2094,15 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
     } else if (afi == AF_INET6) {
         if (!ND_TTEST2(*tptr, 2)) /* fetch status & prefix_len byte */
             return (0);
-        status_byte=*(tptr++);
-        bit_length=*(tptr++);
+        status_byte=EXTRACT_8BITS(tptr);
+        bit_length=EXTRACT_8BITS(tptr+1);
         if (bit_length > 128) {
             ND_PRINT((ndo, "%sIPv6 prefix: bad bit length %u",
                    ident,
                    bit_length));
             return (0);
         }
+        tptr+=2;
         processed+=2;
     } else
         return (0); /* somebody is fooling us */
@@ -2129,17 +2145,19 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
            than one subTLV - therefore the first byte must reflect
            the aggregate bytecount of the subTLVs for this prefix
         */
-        if (!ND_TTEST2(*tptr, 1))
+        if (!ND_TTEST_8BITS(tptr))
             return (0);
-        sublen=*(tptr++);
+        sublen=EXTRACT_8BITS(tptr);
+        tptr++;
         processed+=sublen+1;
         ND_PRINT((ndo, " (%u)", sublen));   /* print out subTLV length */
 
         while (sublen>0) {
             if (!ND_TTEST2(*tptr,2))
                 return (0);
-            subtlvtype=*(tptr++);
-            subtlvlen=*(tptr++);
+            subtlvtype=EXTRACT_8BITS(tptr);
+            subtlvlen=EXTRACT_8BITS(tptr+1);
+            tptr+=2;
             /* prepend the indent string */
             snprintf(ident_buffer, sizeof(ident_buffer), "%s  ",ident);
             if (!isis_print_ip_reach_subtlv(ndo, tptr, subtlvtype, subtlvlen, ident_buffer))
@@ -2189,6 +2207,7 @@ isis_print(netdissect_options *ndo,
 
     uint8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len;
     uint8_t ext_is_len, ext_ip_len, mt_len;
+    uint8_t isis_subtlv_idrp;
     const uint8_t *optr, *pptr, *tptr;
     u_short packet_len,pdu_len, key_id;
     u_int i,vendor_id;
@@ -2545,11 +2564,12 @@ isis_print(netdissect_options *ndo,
        ND_TCHECK2(*pptr, 2);
        if (packet_len < 2)
            goto trunc;
-       tlv_type = *pptr++;
-       tlv_len = *pptr++;
+       tlv_type = EXTRACT_8BITS(pptr);
+       tlv_len = EXTRACT_8BITS(pptr + 1);
+       pptr += 2;
+       packet_len -= 2;
         tmp =tlv_len; /* copy temporary len & pointer to packet data */
         tptr = pptr;
-       packet_len -= 2;
 
         /* first lets see if we know the TLVs name*/
        ND_PRINT((ndo, "\n\t    %s TLV #%u, length: %u",
@@ -2568,8 +2588,9 @@ isis_print(netdissect_options *ndo,
         /* now check if we have a decoder otherwise do a hexdump at the end*/
        switch (tlv_type) {
        case ISIS_TLV_AREA_ADDR:
-           ND_TCHECK2(*tptr, 1);
-           alen = *tptr++;
+           ND_TCHECK_8BITS(tptr);
+           alen = EXTRACT_8BITS(tptr);
+           tptr++;
            while (tmp && alen < tmp) {
                ND_TCHECK2(*tptr, alen);
                ND_PRINT((ndo, "\n\t      Area address (length: %u): %s",
@@ -2579,8 +2600,9 @@ isis_print(netdissect_options *ndo,
                tmp -= alen + 1;
                if (tmp==0) /* if this is the last area address do not attemt a boundary check */
                     break;
-               ND_TCHECK2(*tptr, 1);
-               alen = *tptr++;
+               ND_TCHECK_8BITS(tptr);
+               alen = EXTRACT_8BITS(tptr);
+               tptr++;
            }
            break;
        case ISIS_TLV_ISNEIGH:
@@ -2593,9 +2615,10 @@ isis_print(netdissect_options *ndo,
            break;
 
         case ISIS_TLV_ISNEIGH_VARLEN:
-            if (!ND_TTEST2(*tptr, 1) || tmp < 3) /* min. TLV length */
+            if (!ND_TTEST_8BITS(tptr) || tmp < 3) /* min. TLV length */
                goto trunctlv;
-           lan_alen = *tptr++; /* LAN address length */
+           lan_alen = EXTRACT_8BITS(tptr); /* LAN address length */
+           tptr++;
            if (lan_alen == 0) {
                 ND_PRINT((ndo, "\n\t      LAN address length 0 bytes (invalid)"));
                 break;
@@ -2649,7 +2672,7 @@ isis_print(netdissect_options *ndo,
             }
             break;
         case ISIS_TLV_IS_REACH:
-           ND_TCHECK2(*tptr,1);  /* check if there is one byte left to read out the virtual flag */
+           ND_TCHECK_8BITS(tptr);  /* check if there is one byte left to read out the virtual flag */
             ND_PRINT((ndo, "\n\t      %s",
                    tok2str(isis_is_reach_virtual_values,
                            "bogus virtual flag 0x%02x",
@@ -2751,22 +2774,22 @@ isis_print(netdissect_options *ndo,
            }
            break;
        case ISIS_TLV_AUTH:
-           ND_TCHECK2(*tptr, 1);
+           ND_TCHECK_8BITS(tptr);
 
             ND_PRINT((ndo, "\n\t      %s: ",
                    tok2str(isis_subtlv_auth_values,
                            "unknown Authentication type 0x%02x",
                            EXTRACT_8BITS(tptr))));
 
-           switch (*tptr) {
+           switch (EXTRACT_8BITS(tptr)) {
            case ISIS_SUBTLV_AUTH_SIMPLE:
                if (fn_printzp(ndo, tptr + 1, tlv_len - 1, ndo->ndo_snapend))
                    goto trunctlv;
                break;
            case ISIS_SUBTLV_AUTH_MD5:
                for(i=1;i<tlv_len;i++) {
-                   ND_TCHECK2(*(tptr + i), 1);
-                   ND_PRINT((ndo, "%02x", *(tptr + i)));
+                   ND_TCHECK_8BITS(tptr + i);
+                   ND_PRINT((ndo, "%02x", EXTRACT_8BITS(tptr + i)));
                }
                if (tlv_len != ISIS_SUBTLV_AUTH_MD5_LEN+1)
                     ND_PRINT((ndo, ", (invalid subTLV) "));
@@ -2778,12 +2801,12 @@ isis_print(netdissect_options *ndo,
 
                break;
             case ISIS_SUBTLV_AUTH_GENERIC:
-               ND_TCHECK2(*(tptr + 1), 2);
-                key_id = EXTRACT_BE_16BITS((tptr + 1));
+               ND_TCHECK_16BITS(tptr + 1);
+                key_id = EXTRACT_BE_16BITS(tptr + 1);
                 ND_PRINT((ndo, "%u, password: ", key_id));
                 for(i=1 + sizeof(uint16_t);i<tlv_len;i++) {
-                    ND_TCHECK2(*(tptr + i), 1);
-                    ND_PRINT((ndo, "%02x", *(tptr + i)));
+                    ND_TCHECK_8BITS(tptr + i);
+                    ND_PRINT((ndo, "%02x", EXTRACT_8BITS(tptr + i)));
                 }
                 break;
            case ISIS_SUBTLV_AUTH_PRIVATE:
@@ -2797,10 +2820,10 @@ isis_print(netdissect_options *ndo,
        case ISIS_TLV_PTP_ADJ:
            tlv_ptp_adj = (const struct isis_tlv_ptp_adj *)tptr;
            if(tmp>=1) {
-               ND_TCHECK2(*tptr, 1);
+               ND_TCHECK_8BITS(tptr);
                ND_PRINT((ndo, "\n\t      Adjacency State: %s (%u)",
                       tok2str(isis_ptp_adjancey_values, "unknown", EXTRACT_8BITS(tptr)),
-                      *tptr));
+                      EXTRACT_8BITS(tptr)));
                tmp--;
            }
            if(tmp>sizeof(tlv_ptp_adj->extd_local_circuit_id)) {
@@ -2825,12 +2848,12 @@ isis_print(netdissect_options *ndo,
        case ISIS_TLV_PROTOCOLS:
            ND_PRINT((ndo, "\n\t      NLPID(s): "));
            while (tmp>0) {
-               ND_TCHECK2(*(tptr), 1);
+               ND_TCHECK_8BITS(tptr);
                ND_PRINT((ndo, "%s (0x%02x)",
                        tok2str(nlpid_values,
                                "unknown",
                                EXTRACT_8BITS(tptr)),
-                       *tptr));
+                       EXTRACT_8BITS(tptr)));
                if (tmp>1) /* further NPLIDs ? - put comma */
                    ND_PRINT((ndo, ", "));
                 tptr++;
@@ -2840,7 +2863,7 @@ isis_print(netdissect_options *ndo,
 
     case ISIS_TLV_MT_PORT_CAP:
     {
-      ND_TCHECK2(*(tptr), 2);
+      ND_TCHECK_16BITS(tptr);
 
       ND_PRINT((ndo, "\n\t       RES: %d, MTID(s): %d",
               (EXTRACT_BE_16BITS(tptr) >> 12),
@@ -2857,7 +2880,7 @@ isis_print(netdissect_options *ndo,
 
     case ISIS_TLV_MT_CAPABILITY:
 
-      ND_TCHECK2(*(tptr), 2);
+      ND_TCHECK_16BITS(tptr);
 
       ND_PRINT((ndo, "\n\t      O: %d, RES: %d, MTID(s): %d",
                 (EXTRACT_BE_16BITS(tptr) >> 15) & 0x01,
@@ -2902,7 +2925,7 @@ isis_print(netdissect_options *ndo,
 
            if (tmp < 1)
                break;
-           ND_TCHECK2(*tptr, 1);
+           ND_TCHECK_8BITS(tptr);
            ND_PRINT((ndo, ", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(EXTRACT_8BITS(tptr)) ? "numbered" : "unnumbered"));
            tptr++;
            tmp--;
@@ -2922,7 +2945,7 @@ isis_print(netdissect_options *ndo,
            tmp-=sizeof(struct in_addr);
 
            while (tmp>=4) {
-                ND_TCHECK2(*tptr, 4);
+                ND_TCHECK_32BITS(tptr);
                 ND_PRINT((ndo, "\n\t      Link-ID: 0x%08x", EXTRACT_BE_32BITS(tptr)));
                 tptr+=4;
                 tmp-=4;
@@ -3030,9 +3053,11 @@ isis_print(netdissect_options *ndo,
                    tok2str(isis_subtlv_idrp_values,
                            "Unknown (0x%02x)",
                            EXTRACT_8BITS(tptr))));
-            switch (*tptr++) {
+            isis_subtlv_idrp = EXTRACT_8BITS(tptr);
+            tptr++;
+            switch (isis_subtlv_idrp) {
             case ISIS_SUBTLV_IDRP_ASN:
-                ND_TCHECK2(*tptr, 2); /* fetch AS number */
+                ND_TCHECK_16BITS(tptr); /* fetch AS number */
                 ND_PRINT((ndo, "AS Number: %u", EXTRACT_BE_16BITS(tptr)));
                 break;
             case ISIS_SUBTLV_IDRP_LOCAL:
@@ -3070,8 +3095,9 @@ isis_print(netdissect_options *ndo,
             tmp-=sizeof(struct isis_metric_block);
 
             while(tmp>0) {
-                ND_TCHECK2(*tptr, 1);
-                prefix_len=*tptr++; /* read out prefix length in semioctets*/
+                ND_TCHECK_8BITS(tptr);
+                prefix_len=EXTRACT_8BITS(tptr); /* read out prefix length in semioctets*/
+                tptr++;
                 if (prefix_len < 2) {
                     ND_PRINT((ndo, "\n\t\tAddress: prefix length %u < 2", prefix_len));
                     break;