]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-bgp.c
Rename EXTRACT_ macros
[tcpdump] / print-bgp.c
index eed258b450687b11d7a194b47a172c1d0a4ba0c9..0f56b003b3ead565650a6669ebb1ae94de40a0f5 100644 (file)
@@ -106,13 +106,13 @@ struct bgp_route_refresh {
     uint8_t  afi[2]; /* the compiler messes this structure up               */
     uint8_t  res;    /* when doing misaligned sequences of int8 and int16   */
     uint8_t  safi;   /* afi should be int16 - so we have to access it using */
-};                    /* EXTRACT_16BITS(&bgp_route_refresh->afi) (sigh)      */
+};                    /* EXTRACT_BE_U_2(&bgp_route_refresh->afi) (sigh)      */
 #define BGP_ROUTE_REFRESH_SIZE          23
 
 #define bgp_attr_lenlen(flags, p) \
        (((flags) & 0x10) ? 2 : 1)
 #define bgp_attr_len(flags, p) \
-       (((flags) & 0x10) ? EXTRACT_BE_16BITS(p) : *(p))
+       (((flags) & 0x10) ? EXTRACT_BE_U_2(p) : *(p))
 
 #define BGPTYPE_ORIGIN                 1
 #define BGPTYPE_AS_PATH                        2
@@ -606,7 +606,7 @@ decode_labeled_prefix4(netdissect_options *ndo,
        snprintf(buf, buflen, "%s/%d, label:%u %s",
                  ipaddr_string(ndo, &addr),
                  plen,
-                 EXTRACT_BE_24BITS(pptr + 1)>>4,
+                 EXTRACT_BE_U_3(pptr + 1)>>4,
                  ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
 
        return 4 + plenbytes;
@@ -681,7 +681,7 @@ bgp_vpn_sg_print(netdissect_options *ndo,
 
     /* Source address length, encoded in bits */
     ND_TCHECK_1(pptr);
-    addr_length = EXTRACT_8BITS(pptr);
+    addr_length = EXTRACT_U_1(pptr);
     pptr++;
 
     /* Source address */
@@ -696,7 +696,7 @@ bgp_vpn_sg_print(netdissect_options *ndo,
 
     /* Group address length, encoded in bits */
     ND_TCHECK_1(pptr);
-    addr_length = EXTRACT_8BITS(pptr);
+    addr_length = EXTRACT_U_1(pptr);
     pptr++;
 
     /* Group address */
@@ -725,13 +725,13 @@ bgp_vpn_rd_print(netdissect_options *ndo,
     char *pos = rd;
 
     /* ok lets load the RD format */
-    switch (EXTRACT_BE_16BITS(pptr)) {
+    switch (EXTRACT_BE_U_2(pptr)) {
 
         /* 2-byte-AS:number fmt*/
     case 0:
         snprintf(pos, sizeof(rd) - (pos - rd), "%u:%u (= %u.%u.%u.%u)",
-                 EXTRACT_BE_16BITS(pptr + 2),
-                 EXTRACT_BE_32BITS(pptr + 4),
+                 EXTRACT_BE_U_2(pptr + 2),
+                 EXTRACT_BE_U_4(pptr + 4),
                  *(pptr+4), *(pptr+5), *(pptr+6), *(pptr+7));
         break;
         /* IP-address:AS fmt*/
@@ -739,15 +739,15 @@ bgp_vpn_rd_print(netdissect_options *ndo,
     case 1:
         snprintf(pos, sizeof(rd) - (pos - rd), "%u.%u.%u.%u:%u",
             *(pptr+2), *(pptr+3), *(pptr+4), *(pptr+5),
-            EXTRACT_BE_16BITS(pptr + 6));
+            EXTRACT_BE_U_2(pptr + 6));
         break;
 
         /* 4-byte-AS:number fmt*/
     case 2:
        snprintf(pos, sizeof(rd) - (pos - rd), "%s:%u (%u.%u.%u.%u:%u)",
-           as_printf(ndo, astostr, sizeof(astostr), EXTRACT_BE_32BITS(pptr + 2)),
-           EXTRACT_BE_16BITS(pptr + 6), *(pptr+2), *(pptr+3), *(pptr+4),
-           *(pptr+5), EXTRACT_BE_16BITS(pptr + 6));
+           as_printf(ndo, astostr, sizeof(astostr), EXTRACT_BE_U_4(pptr + 2)),
+           EXTRACT_BE_U_2(pptr + 6), *(pptr+2), *(pptr+3), *(pptr+4),
+           *(pptr+5), EXTRACT_BE_U_2(pptr + 6));
         break;
     default:
         snprintf(pos, sizeof(rd) - (pos - rd), "unknown RD format");
@@ -785,7 +785,7 @@ decode_rt_routing_info(netdissect_options *ndo,
 
        /* With at least "origin AS", possibly with "route target". */
        ND_TCHECK_4(pptr + 1);
-       as_printf(ndo, asbuf, sizeof(asbuf), EXTRACT_BE_32BITS(pptr + 1));
+       as_printf(ndo, asbuf, sizeof(asbuf), EXTRACT_BE_U_4(pptr + 1));
 
         plen-=32; /* adjust prefix length */
 
@@ -844,7 +844,7 @@ decode_labeled_vpn_prefix4(netdissect_options *ndo,
                  bgp_vpn_rd_print(ndo, pptr+4),
                  ipaddr_string(ndo, &addr),
                  plen,
-                 EXTRACT_BE_24BITS(pptr + 1)>>4,
+                 EXTRACT_BE_U_3(pptr + 1)>>4,
                  ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
 
        return 12 + (plen + 7) / 8;
@@ -876,7 +876,7 @@ decode_mdt_vpn_nlri(netdissect_options *ndo,
     ND_TCHECK(pptr[0]);
 
     /* if the NLRI is not predefined length, quit.*/
-    if (EXTRACT_8BITS(pptr) != MDT_VPN_NLRI_LEN * 8)
+    if (EXTRACT_U_1(pptr) != MDT_VPN_NLRI_LEN * 8)
        return -1;
     pptr++;
 
@@ -930,9 +930,9 @@ decode_multicast_vpn(netdissect_options *ndo,
         u_int offset;
 
        ND_TCHECK2(pptr[0], 2);
-        route_type = EXTRACT_8BITS(pptr);
+        route_type = EXTRACT_U_1(pptr);
         pptr++;
-        route_length = EXTRACT_8BITS(pptr);
+        route_length = EXTRACT_U_1(pptr);
         pptr++;
 
         snprintf(buf, buflen, "Route-Type: %s (%u), length: %u",
@@ -955,7 +955,7 @@ decode_multicast_vpn(netdissect_options *ndo,
            snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
                bgp_vpn_rd_print(ndo, pptr),
                as_printf(ndo, astostr, sizeof(astostr),
-               EXTRACT_BE_32BITS(pptr + BGP_VPN_RD_LEN)));
+               EXTRACT_BE_U_4(pptr + BGP_VPN_RD_LEN)));
             break;
 
         case BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI:
@@ -991,7 +991,7 @@ decode_multicast_vpn(netdissect_options *ndo,
            snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
                bgp_vpn_rd_print(ndo, pptr),
                as_printf(ndo, astostr, sizeof(astostr),
-               EXTRACT_BE_32BITS(pptr + BGP_VPN_RD_LEN)));
+               EXTRACT_BE_U_4(pptr + BGP_VPN_RD_LEN)));
             pptr += BGP_VPN_RD_LEN + 4;
 
             bgp_vpn_sg_print(ndo, pptr, buf, buflen);
@@ -1038,7 +1038,7 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
         int plen,tlen,stringlen,tlv_type,tlv_len,ttlv_len;
 
        ND_TCHECK_2(pptr);
-        plen=EXTRACT_BE_16BITS(pptr);
+        plen=EXTRACT_BE_U_2(pptr);
         tlen=plen;
         pptr+=2;
        /* Old and new L2VPN NLRI share AFI/SAFI
@@ -1065,9 +1065,9 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
            buf[0]='\0';
            stringlen=snprintf(buf, buflen, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u",
                               bgp_vpn_rd_print(ndo, pptr),
-                              EXTRACT_BE_16BITS(pptr + 8),
-                              EXTRACT_BE_16BITS(pptr + 10),
-                              EXTRACT_BE_24BITS(pptr + 12)>>4); /* the label is offsetted by 4 bits so lets shift it right */
+                              EXTRACT_BE_U_2(pptr + 8),
+                              EXTRACT_BE_U_2(pptr + 10),
+                              EXTRACT_BE_U_3(pptr + 12)>>4); /* the label is offsetted by 4 bits so lets shift it right */
            UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
            pptr+=15;
            tlen-=15;
@@ -1077,9 +1077,9 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
                if (tlen < 3)
                    return -1;
                ND_TCHECK2(pptr[0], 3);
-               tlv_type=EXTRACT_8BITS(pptr);
+               tlv_type=EXTRACT_U_1(pptr);
                pptr++;
-               tlv_len=EXTRACT_BE_16BITS(pptr);
+               tlv_len=EXTRACT_BE_U_2(pptr);
                ttlv_len=tlv_len;
                pptr+=2;
 
@@ -1095,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",EXTRACT_8BITS(pptr));
+                           stringlen=snprintf(buf,buflen, "%02x",
+                                               EXTRACT_U_1(pptr));
                            pptr++;
                            UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
                        }
@@ -1191,7 +1192,7 @@ decode_labeled_prefix6(netdissect_options *ndo,
        snprintf(buf, buflen, "%s/%d, label:%u %s",
                  ip6addr_string(ndo, &addr),
                  plen,
-                 EXTRACT_BE_24BITS(pptr + 1)>>4,
+                 EXTRACT_BE_U_3(pptr + 1)>>4,
                  ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
 
        return 4 + plenbytes;
@@ -1233,7 +1234,7 @@ decode_labeled_vpn_prefix6(netdissect_options *ndo,
                  bgp_vpn_rd_print(ndo, pptr+4),
                  ip6addr_string(ndo, &addr),
                  plen,
-                 EXTRACT_BE_24BITS(pptr + 1)>>4,
+                 EXTRACT_BE_U_3(pptr + 1)>>4,
                  ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
 
        return 12 + (plen + 7) / 8;
@@ -1302,7 +1303,7 @@ decode_labeled_vpn_clnp_prefix(netdissect_options *ndo,
                  bgp_vpn_rd_print(ndo, pptr+4),
                  isonsap_string(ndo, addr,(plen + 7) / 8),
                  plen,
-                 EXTRACT_BE_24BITS(pptr + 1)>>4,
+                 EXTRACT_BE_U_3(pptr + 1)>>4,
                  ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
 
        return 12 + (plen + 7) / 8;
@@ -1435,8 +1436,8 @@ bgp_attr_print(netdissect_options *ndo,
                            ND_PRINT((ndo, "%s ",
                                as_printf(ndo, astostr, sizeof(astostr),
                                as_size == 2 ?
-                               EXTRACT_BE_16BITS(tptr + i + 2) :
-                               EXTRACT_BE_32BITS(tptr + i + 2))));
+                               EXTRACT_BE_U_2(tptr + i + 2) :
+                               EXTRACT_BE_U_4(tptr + i + 2))));
                         }
                        ND_TCHECK(tptr[0]);
                         ND_PRINT((ndo, "%s", tok2str(bgp_as_path_segment_close_values,
@@ -1459,7 +1460,7 @@ bgp_attr_print(netdissect_options *ndo,
                        ND_PRINT((ndo, "invalid len"));
                else {
                        ND_TCHECK_4(tptr);
-                       ND_PRINT((ndo, "%u", EXTRACT_BE_32BITS(tptr)));
+                       ND_PRINT((ndo, "%u", EXTRACT_BE_U_4(tptr)));
                }
                break;
        case BGPTYPE_ATOMIC_AGGREGATE:
@@ -1479,12 +1480,12 @@ bgp_attr_print(netdissect_options *ndo,
                 ND_TCHECK2(tptr[0], len);
                 if (len == 6) {
                    ND_PRINT((ndo, " AS #%s, origin %s",
-                       as_printf(ndo, astostr, sizeof(astostr), EXTRACT_BE_16BITS(tptr)),
+                       as_printf(ndo, astostr, sizeof(astostr), EXTRACT_BE_U_2(tptr)),
                        ipaddr_string(ndo, tptr + 2)));
                 } else {
                    ND_PRINT((ndo, " AS #%s, origin %s",
                        as_printf(ndo, astostr, sizeof(astostr),
-                       EXTRACT_BE_32BITS(tptr)), ipaddr_string(ndo, tptr + 4)));
+                       EXTRACT_BE_U_4(tptr)), ipaddr_string(ndo, tptr + 4)));
                 }
                 break;
        case BGPTYPE_AGGREGATOR4:
@@ -1494,7 +1495,7 @@ bgp_attr_print(netdissect_options *ndo,
                }
                ND_TCHECK2(tptr[0], 8);
                ND_PRINT((ndo, " AS #%s, origin %s",
-                   as_printf(ndo, astostr, sizeof(astostr), EXTRACT_BE_32BITS(tptr)),
+                   as_printf(ndo, astostr, sizeof(astostr), EXTRACT_BE_U_4(tptr)),
                    ipaddr_string(ndo, tptr + 4)));
                break;
        case BGPTYPE_COMMUNITIES:
@@ -1505,7 +1506,7 @@ bgp_attr_print(netdissect_options *ndo,
                while (tlen>0) {
                        uint32_t comm;
                        ND_TCHECK_4(tptr);
-                       comm = EXTRACT_BE_32BITS(tptr);
+                       comm = EXTRACT_BE_U_4(tptr);
                        switch (comm) {
                        case BGP_COMMUNITY_NO_EXPORT:
                                ND_PRINT((ndo, " NO_EXPORT"));
@@ -1551,8 +1552,8 @@ bgp_attr_print(netdissect_options *ndo,
                 break;
        case BGPTYPE_MP_REACH_NLRI:
                ND_TCHECK2(tptr[0], 3);
-               af = EXTRACT_BE_16BITS(tptr);
-               safi = EXTRACT_8BITS(tptr + 2);
+               af = EXTRACT_BE_U_2(tptr);
+               safi = EXTRACT_U_1(tptr + 2);
 
                 ND_PRINT((ndo, "\n\t    AFI: %s (%u), %sSAFI: %s (%u)",
                        tok2str(af_values, "Unknown AFI", af),
@@ -1710,10 +1711,10 @@ bgp_attr_print(netdissect_options *ndo,
                                        bgp_vpn_rd_print(ndo, tptr),
                                        isonsap_string(ndo, tptr+BGP_VPN_RD_LEN,tlen-BGP_VPN_RD_LEN)));
                                 /* rfc986 mapped IPv4 address ? */
-                                if (EXTRACT_BE_32BITS(tptr + BGP_VPN_RD_LEN) ==  0x47000601)
+                                if (EXTRACT_BE_U_4(tptr + BGP_VPN_RD_LEN) ==  0x47000601)
                                     ND_PRINT((ndo, " = %s", ipaddr_string(ndo, tptr+BGP_VPN_RD_LEN+4)));
                                 /* rfc1888 mapped IPv6 address ? */
-                                else if (EXTRACT_BE_24BITS(tptr + BGP_VPN_RD_LEN) ==  0x350000)
+                                else if (EXTRACT_BE_U_3(tptr + BGP_VPN_RD_LEN) ==  0x350000)
                                     ND_PRINT((ndo, " = %s", ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN+3)));
                                 tptr += tlen;
                                 tlen = 0;
@@ -1902,7 +1903,7 @@ bgp_attr_print(netdissect_options *ndo,
 
        case BGPTYPE_MP_UNREACH_NLRI:
                ND_TCHECK2(tptr[0], BGP_MP_NLRI_MINSIZE);
-               af = EXTRACT_BE_16BITS(tptr);
+               af = EXTRACT_BE_U_2(tptr);
                safi = tptr[2];
 
                 ND_PRINT((ndo, "\n\t    AFI: %s (%u), %sSAFI: %s (%u)",
@@ -2065,7 +2066,7 @@ bgp_attr_print(netdissect_options *ndo,
                     uint16_t extd_comm;
 
                     ND_TCHECK_2(tptr);
-                    extd_comm=EXTRACT_BE_16BITS(tptr);
+                    extd_comm=EXTRACT_BE_U_2(tptr);
 
                    ND_PRINT((ndo, "\n\t    %s (0x%04x), Flags [%s]",
                           tok2str(bgp_extd_comm_subtype_values,
@@ -2080,8 +2081,8 @@ bgp_attr_print(netdissect_options *ndo,
                     case BGP_EXT_COM_RO_0:
                     case BGP_EXT_COM_L2VPN_RT_0:
                         ND_PRINT((ndo, ": %u:%u (= %s)",
-                               EXTRACT_BE_16BITS(tptr + 2),
-                               EXTRACT_BE_32BITS(tptr + 4),
+                               EXTRACT_BE_U_2(tptr + 2),
+                               EXTRACT_BE_U_4(tptr + 4),
                                ipaddr_string(ndo, tptr+4)));
                         break;
                     case BGP_EXT_COM_RT_1:
@@ -2090,16 +2091,16 @@ bgp_attr_print(netdissect_options *ndo,
                     case BGP_EXT_COM_VRF_RT_IMP:
                         ND_PRINT((ndo, ": %s:%u",
                                ipaddr_string(ndo, tptr+2),
-                               EXTRACT_BE_16BITS(tptr + 6)));
+                               EXTRACT_BE_U_2(tptr + 6)));
                         break;
                     case BGP_EXT_COM_RT_2:
                     case BGP_EXT_COM_RO_2:
                        ND_PRINT((ndo, ": %s:%u",
                            as_printf(ndo, astostr, sizeof(astostr),
-                           EXTRACT_BE_32BITS(tptr + 2)), EXTRACT_BE_16BITS(tptr + 6)));
+                           EXTRACT_BE_U_4(tptr + 2)), EXTRACT_BE_U_2(tptr + 6)));
                        break;
                     case BGP_EXT_COM_LINKBAND:
-                       bw.i = EXTRACT_BE_32BITS(tptr + 2);
+                       bw.i = EXTRACT_BE_U_4(tptr + 2);
                         ND_PRINT((ndo, ": bandwidth: %.3f Mbps",
                                bw.f*8/1000000));
                         break;
@@ -2117,7 +2118,7 @@ bgp_attr_print(netdissect_options *ndo,
                                ipaddr_string(ndo, tptr+2),
                                tok2str(bgp_extd_comm_ospf_rtype_values,
                                          "unknown (0x%02x)",
-                                         EXTRACT_8BITS((tptr + 6))),
+                                         EXTRACT_U_1((tptr + 6))),
                                (*(tptr+7) &  BGP_OSPF_RTYPE_METRIC_TYPE) ? "E2" : "",
                                ((*(tptr+6) == BGP_OSPF_RTYPE_EXT) || (*(tptr+6) == BGP_OSPF_RTYPE_NSSA)) ? "E1" : ""));
                         break;
@@ -2125,12 +2126,12 @@ bgp_attr_print(netdissect_options *ndo,
                         ND_PRINT((ndo, ": %s Control Flags [0x%02x]:MTU %u",
                                tok2str(l2vpn_encaps_values,
                                          "unknown encaps",
-                                         EXTRACT_8BITS((tptr + 2))),
-                               EXTRACT_8BITS((tptr + 3)),
-                               EXTRACT_BE_16BITS(tptr + 4)));
+                                         EXTRACT_U_1((tptr + 2))),
+                               EXTRACT_U_1((tptr + 3)),
+                               EXTRACT_BE_U_2(tptr + 4)));
                         break;
                     case BGP_EXT_COM_SOURCE_AS:
-                        ND_PRINT((ndo, ": AS %u", EXTRACT_BE_16BITS(tptr + 2)));
+                        ND_PRINT((ndo, ": AS %u", EXTRACT_BE_U_2(tptr + 2)));
                         break;
                     default:
                         ND_TCHECK2(*tptr,8);
@@ -2147,15 +2148,15 @@ bgp_attr_print(netdissect_options *ndo,
                 uint8_t tunnel_type, flags;
 
                 ND_TCHECK2(tptr[0], 5);
-                flags = EXTRACT_8BITS(tptr);
-                tunnel_type = EXTRACT_8BITS(tptr+1);
+                flags = EXTRACT_U_1(tptr);
+                tunnel_type = EXTRACT_U_1(tptr + 1);
                 tlen = len;
 
                 ND_PRINT((ndo, "\n\t    Tunnel-type %s (%u), Flags [%s], MPLS Label %u",
                        tok2str(bgp_pmsi_tunnel_values, "Unknown", tunnel_type),
                        tunnel_type,
                        bittok2str(bgp_pmsi_flag_values, "none", flags),
-                       EXTRACT_BE_24BITS(tptr + 2)>>4));
+                       EXTRACT_BE_U_3(tptr + 2)>>4));
 
                 tptr +=5;
                 tlen -= 5;
@@ -2185,13 +2186,13 @@ bgp_attr_print(netdissect_options *ndo,
                     ND_TCHECK2(tptr[0], 8);
                     ND_PRINT((ndo, "\n\t      Root-Node %s, LSP-ID 0x%08x",
                            ipaddr_string(ndo, tptr),
-                           EXTRACT_BE_32BITS(tptr + 4)));
+                           EXTRACT_BE_U_4(tptr + 4)));
                     break;
                 case BGP_PMSI_TUNNEL_RSVP_P2MP:
                     ND_TCHECK2(tptr[0], 8);
                     ND_PRINT((ndo, "\n\t      Extended-Tunnel-ID %s, P2MP-ID 0x%08x",
                            ipaddr_string(ndo, tptr),
-                           EXTRACT_BE_32BITS(tptr + 4)));
+                           EXTRACT_BE_U_4(tptr + 4)));
                     break;
                 default:
                     if (ndo->ndo_vflag <= 1) {
@@ -2211,8 +2212,8 @@ bgp_attr_print(netdissect_options *ndo,
 
                    ND_TCHECK2(tptr[0], 3);
 
-                   type = EXTRACT_8BITS(tptr);
-                   length = EXTRACT_BE_16BITS(tptr + 1);
+                   type = EXTRACT_U_1(tptr);
+                   length = EXTRACT_BE_U_2(tptr + 1);
                    tptr += 3;
                    tlen -= 3;
 
@@ -2235,7 +2236,7 @@ bgp_attr_print(netdissect_options *ndo,
                        if (length < 8)
                            goto trunc;
                        ND_PRINT((ndo, ", metric %" PRIu64,
-                                 EXTRACT_BE_64BITS(tptr)));
+                                 EXTRACT_BE_U_8(tptr)));
                        break;
 
                    default:
@@ -2254,7 +2255,7 @@ bgp_attr_print(netdissect_options *ndo,
                 if (len < 4)
                        goto trunc;
                ND_PRINT((ndo, "\n\t    Origin AS: %s",
-                   as_printf(ndo, astostr, sizeof(astostr), EXTRACT_BE_32BITS(tptr))));
+                   as_printf(ndo, astostr, sizeof(astostr), EXTRACT_BE_U_4(tptr))));
                tptr+=4;
                 len -=4;
 
@@ -2264,8 +2265,8 @@ bgp_attr_print(netdissect_options *ndo,
                     ND_TCHECK2(tptr[0], 2);
                     if (len < 2)
                         goto trunc;
-                    aflags = EXTRACT_8BITS(tptr);
-                    atype = EXTRACT_8BITS(tptr + 1);
+                    aflags = EXTRACT_U_1(tptr);
+                    atype = EXTRACT_U_1(tptr + 1);
                     tptr += 2;
                     len -= 2;
                     alenlen = bgp_attr_lenlen(aflags, tptr);
@@ -2309,9 +2310,9 @@ bgp_attr_print(netdissect_options *ndo,
                while (len > 0) {
                        ND_TCHECK2(*tptr, 12);
                        ND_PRINT((ndo, "%u:%u:%u%s",
-                                EXTRACT_BE_32BITS(tptr),
-                                EXTRACT_BE_32BITS(tptr + 4),
-                                EXTRACT_BE_32BITS(tptr + 8),
+                                EXTRACT_BE_U_4(tptr),
+                                EXTRACT_BE_U_4(tptr + 4),
+                                EXTRACT_BE_U_4(tptr + 8),
                                 (len > 12) ? ", " : ""));
                         tptr += 12;
                         len -= 12;
@@ -2356,8 +2357,8 @@ bgp_capabilities_print(netdissect_options *ndo,
                 case BGP_CAPCODE_MP:
                     ND_PRINT((ndo, "\n\t\tAFI %s (%u), SAFI %s (%u)",
                            tok2str(af_values, "Unknown",
-                                      EXTRACT_BE_16BITS(opt + i + 2)),
-                           EXTRACT_BE_16BITS(opt + i + 2),
+                                      EXTRACT_BE_U_2(opt + i + 2)),
+                           EXTRACT_BE_U_2(opt + i + 2),
                            tok2str(bgp_safi_values, "Unknown",
                                       opt[i+5]),
                            opt[i+5]));
@@ -2365,14 +2366,14 @@ bgp_capabilities_print(netdissect_options *ndo,
                 case BGP_CAPCODE_RESTART:
                     ND_PRINT((ndo, "\n\t\tRestart Flags: [%s], Restart Time %us",
                            ((opt[i+2])&0x80) ? "R" : "none",
-                           EXTRACT_BE_16BITS(opt + i + 2)&0xfff));
+                           EXTRACT_BE_U_2(opt + i + 2)&0xfff));
                     tcap_len-=2;
                     cap_offset=4;
                     while(tcap_len>=4) {
                         ND_PRINT((ndo, "\n\t\t  AFI %s (%u), SAFI %s (%u), Forwarding state preserved: %s",
                                tok2str(af_values,"Unknown",
-                                          EXTRACT_BE_16BITS(opt + i + cap_offset)),
-                               EXTRACT_BE_16BITS(opt + i + cap_offset),
+                                          EXTRACT_BE_U_2(opt + i + cap_offset)),
+                               EXTRACT_BE_U_2(opt + i + cap_offset),
                                tok2str(bgp_safi_values,"Unknown",
                                           opt[i+cap_offset+2]),
                                opt[i+cap_offset+2],
@@ -2392,7 +2393,7 @@ bgp_capabilities_print(netdissect_options *ndo,
                     if (cap_len == 4) {
                         ND_PRINT((ndo, "\n\t\t 4 Byte AS %s",
                             as_printf(ndo, astostr, sizeof(astostr),
-                            EXTRACT_BE_32BITS(opt + i + 2))));
+                            EXTRACT_BE_U_4(opt + i + 2))));
                     }
                     break;
                 case BGP_CAPCODE_ADD_PATH:
@@ -2407,8 +2408,8 @@ bgp_capabilities_print(netdissect_options *ndo,
                             break;
                         }
                         ND_PRINT((ndo, "\n\t\tAFI %s (%u), SAFI %s (%u), Send/Receive: %s",
-                                  tok2str(af_values,"Unknown",EXTRACT_BE_16BITS(opt + i + cap_offset)),
-                                  EXTRACT_BE_16BITS(opt + i + cap_offset),
+                                  tok2str(af_values,"Unknown",EXTRACT_BE_U_2(opt + i + cap_offset)),
+                                  EXTRACT_BE_U_2(opt + i + cap_offset),
                                   tok2str(bgp_safi_values,"Unknown",opt[i+cap_offset+2]),
                                   opt[i+cap_offset+2],
                                   tok2str(bgp_add_path_recvsend,"Bogus (0x%02x)",opt[i+cap_offset+3])
@@ -2519,7 +2520,7 @@ bgp_update_print(netdissect_options *ndo,
        ND_TCHECK_2(p);
        if (length < 2)
                goto trunc;
-       withdrawn_routes_len = EXTRACT_BE_16BITS(p);
+       withdrawn_routes_len = EXTRACT_BE_U_2(p);
        p += 2;
        length -= 2;
        if (withdrawn_routes_len) {
@@ -2539,7 +2540,7 @@ bgp_update_print(netdissect_options *ndo,
        ND_TCHECK_2(p);
        if (length < 2)
                goto trunc;
-       len = EXTRACT_BE_16BITS(p);
+       len = EXTRACT_BE_U_2(p);
        p += 2;
        length -= 2;
 
@@ -2559,8 +2560,8 @@ bgp_update_print(netdissect_options *ndo,
                            goto trunc;
                        if (length < 2)
                            goto trunc;
-                       aflags = EXTRACT_8BITS(p);
-                       atype = EXTRACT_8BITS(p + 1);
+                       aflags = EXTRACT_U_1(p);
+                       atype = EXTRACT_U_1(p + 1);
                        p += 2;
                        len -= 2;
                        length -= 2;
@@ -2702,11 +2703,11 @@ bgp_notification_print(netdissect_options *ndo,
                ND_TCHECK2(*tptr, 7);
                ND_PRINT((ndo, ", AFI %s (%u), SAFI %s (%u), Max Prefixes: %u",
                       tok2str(af_values, "Unknown",
-                                 EXTRACT_BE_16BITS(tptr)),
-                      EXTRACT_BE_16BITS(tptr),
-                      tok2str(bgp_safi_values, "Unknown", EXTRACT_8BITS((tptr + 2))),
-                      EXTRACT_8BITS((tptr + 2)),
-                      EXTRACT_BE_32BITS(tptr + 3)));
+                                 EXTRACT_BE_U_2(tptr)),
+                      EXTRACT_BE_U_2(tptr),
+                      tok2str(bgp_safi_values, "Unknown", EXTRACT_U_1((tptr + 2))),
+                      EXTRACT_U_1((tptr + 2)),
+                      EXTRACT_BE_U_4(tptr + 3)));
            }
            /*
             * draft-ietf-idr-shutdown describes a method to send a communication
@@ -2717,7 +2718,7 @@ bgp_notification_print(netdissect_options *ndo,
                length >= BGP_NOTIFICATION_SIZE + 1) {
                    tptr = dat + BGP_NOTIFICATION_SIZE;
                    ND_TCHECK_1(tptr);
-                   shutdown_comm_length = EXTRACT_8BITS(tptr);
+                   shutdown_comm_length = EXTRACT_U_1(tptr);
                    remainder_offset = 0;
                    /* garbage, hexdump it all */
                    if (shutdown_comm_length > BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN ||
@@ -2770,8 +2771,8 @@ bgp_route_refresh_print(netdissect_options *ndo,
                tok2str(af_values,"Unknown",
                          /* this stinks but the compiler pads the structure
                           * weird */
-                         EXTRACT_BE_16BITS(&bgp_route_refresh_header->afi)),
-               EXTRACT_BE_16BITS(&bgp_route_refresh_header->afi),
+                         EXTRACT_BE_U_2(&bgp_route_refresh_header->afi)),
+               EXTRACT_BE_U_2(&bgp_route_refresh_header->afi),
                tok2str(bgp_safi_values,"Unknown",
                          bgp_route_refresh_header->safi),
                bgp_route_refresh_header->safi));