]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-fr.c
The third argument to linkaddr_string is one of the LINKADDR_ enums.
[tcpdump] / print-fr.c
index ce3513791e4e8599029bb32de04ae07e0b270ba5..59d394171c6276b34279ca860f4d9f3305921feb 100644 (file)
 /* \summary: Frame Relay printer */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
-#include <netdissect-stdinc.h>
+#include "netdissect-stdinc.h"
 
 #include <stdio.h>
 #include <string.h>
@@ -98,62 +98,60 @@ static const struct tok frf_flag_values[] = {
  * 0 on invalid address, -1 on truncated packet
  * save the flags dep. on address length
  */
-static int parse_q922_addr(netdissect_options *ndo,
+static int parse_q922_header(netdissect_options *ndo,
                            const u_char *p, u_int *dlci,
-                           u_int *addr_len, uint8_t *flags, u_int length)
+                           u_int *addr_len, uint32_t *flags, u_int length)
 {
-       if (!ND_TTEST_8BITS(p) || length < 1)
+       if (!ND_TTEST_1(p) || length < 1)
                return -1;
-       if ((EXTRACT_8BITS(p) & FR_EA_BIT))
+       if ((GET_U_1(p) & FR_EA_BIT))
                return 0;
 
-       if (!ND_TTEST_8BITS(p+1) || length < 2)
+       if (!ND_TTEST_1(p + 1) || length < 2)
                return -1;
        *addr_len = 2;
-       *dlci = ((EXTRACT_8BITS(p) & 0xFC) << 2) | ((EXTRACT_8BITS(p+1) & 0xF0) >> 4);
+       *dlci = ((GET_U_1(p) & 0xFC) << 2) | ((GET_U_1(p + 1) & 0xF0) >> 4);
 
-        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;
+       *flags = ((GET_U_1(p) & 0x02) << 24) |  /* CR flag */
+                ((GET_U_1(p + 1) & 0x0e) << 16);       /* FECN,BECN,DE flags */
 
-       if (EXTRACT_8BITS(p+1) & FR_EA_BIT)
+       if (GET_U_1(p + 1) & FR_EA_BIT)
                return 1;       /* 2-byte Q.922 address */
 
        p += 2;
        length -= 2;
-       if (!ND_TTEST_8BITS(p) || length < 1)
+       if (!ND_TTEST_1(p) || length < 1)
                return -1;
        (*addr_len)++;          /* 3- or 4-byte Q.922 address */
-       if ((EXTRACT_8BITS(p) & FR_EA_BIT) == 0) {
-               *dlci = (*dlci << 7) | (EXTRACT_8BITS(p) >> 1);
+       if ((GET_U_1(p) & FR_EA_BIT) == 0) {
+               *dlci = (*dlci << 7) | (GET_U_1(p) >> 1);
                (*addr_len)++;  /* 4-byte Q.922 address */
                p++;
                length--;
        }
 
-       if (!ND_TTEST_8BITS(p) || length < 1)
+       if (!ND_TTEST_1(p) || length < 1)
                return -1;
-       if ((EXTRACT_8BITS(p) & FR_EA_BIT) == 0)
+       if ((GET_U_1(p) & FR_EA_BIT) == 0)
                return 0; /* more than 4 bytes of Q.922 address? */
 
-        flags[3] = EXTRACT_8BITS(p) & 0x02;
+       *flags = *flags | (GET_U_1(p) & 0x02);  /* SDLC flag */
 
-        *dlci = (*dlci << 6) | (EXTRACT_8BITS(p) >> 2);
+        *dlci = (*dlci << 6) | (GET_U_1(p) >> 2);
 
        return 1;
 }
 
-char *
+const char *
 q922_string(netdissect_options *ndo, const u_char *p, u_int length)
 {
 
     static u_int dlci, addr_len;
-    static uint8_t flags[4];
+    static uint32_t flags;
     static char buffer[sizeof("DLCI xxxxxxxxxx")];
     memset(buffer, 0, sizeof(buffer));
 
-    if (parse_q922_addr(ndo, p, &dlci, &addr_len, flags, length) == 1){
+    if (parse_q922_header(ndo, p, &dlci, &addr_len, &flags, length) == 1){
         snprintf(buffer, sizeof(buffer), "DLCI %u", dlci);
     }
 
@@ -188,54 +186,55 @@ q922_string(netdissect_options *ndo, const u_char *p, u_int length)
 */
 
 static void
-fr_hdr_print(netdissect_options *ndo,
-             int length, u_int addr_len, u_int dlci, uint8_t *flags, uint16_t nlpid)
+fr_hdr_print(netdissect_options *ndo, int length, u_int addr_len,
+            u_int dlci, uint32_t flags, uint16_t nlpid)
 {
     if (ndo->ndo_qflag) {
-        ND_PRINT((ndo, "Q.922, DLCI %u, length %u: ",
+        ND_PRINT("Q.922, DLCI %u, length %u: ",
                      dlci,
-                     length));
+                     length);
     } else {
         if (nlpid <= 0xff) /* if its smaller than 256 then its a NLPID */
-            ND_PRINT((ndo, "Q.922, hdr-len %u, DLCI %u, Flags [%s], NLPID %s (0x%02x), length %u: ",
+            ND_PRINT("Q.922, hdr-len %u, DLCI %u, Flags [%s], NLPID %s (0x%02x), length %u: ",
                          addr_len,
                          dlci,
-                         bittok2str(fr_header_flag_values, "none", EXTRACT_BE_32BITS(flags)),
+                         bittok2str(fr_header_flag_values, "none", flags),
                          tok2str(nlpid_values,"unknown", nlpid),
                          nlpid,
-                         length));
+                         length);
         else /* must be an ethertype */
-            ND_PRINT((ndo, "Q.922, hdr-len %u, DLCI %u, Flags [%s], cisco-ethertype %s (0x%04x), length %u: ",
+            ND_PRINT("Q.922, hdr-len %u, DLCI %u, Flags [%s], cisco-ethertype %s (0x%04x), length %u: ",
                          addr_len,
                          dlci,
-                         bittok2str(fr_header_flag_values, "none", EXTRACT_BE_32BITS(flags)),
+                         bittok2str(fr_header_flag_values, "none", flags),
                          tok2str(ethertype_values, "unknown", nlpid),
                          nlpid,
-                         length));
+                         length);
     }
 }
 
 u_int
 fr_if_print(netdissect_options *ndo,
-            const struct pcap_pkthdr *h, register const u_char *p)
+            const struct pcap_pkthdr *h, const u_char *p)
 {
-       register u_int length = h->len;
-       register u_int caplen = h->caplen;
+       u_int length = h->len;
+       u_int caplen = h->caplen;
 
-        ND_TCHECK2(*p, 4); /* minimum frame header length */
+       ndo->ndo_protocol = "fr_if";
+        ND_TCHECK_4(p); /* minimum frame header length */
 
         if ((length = fr_print(ndo, p, length)) == 0)
             return (0);
         else
             return length;
- trunc:
-        ND_PRINT((ndo, "[|fr]"));
+trunc:
+        nd_print_trunc(ndo);
         return caplen;
 }
 
 u_int
 fr_print(netdissect_options *ndo,
-         register const u_char *p, u_int length)
+         const u_char *p, u_int length)
 {
        int ret;
        uint16_t extracted_ethertype;
@@ -243,31 +242,32 @@ fr_print(netdissect_options *ndo,
        u_int addr_len;
        uint16_t nlpid;
        u_int hdr_len;
-       uint8_t flags[4];
+       uint32_t flags;
 
-       ret = parse_q922_addr(ndo, p, &dlci, &addr_len, flags, length);
+       ndo->ndo_protocol = "fr";
+       ret = parse_q922_header(ndo, p, &dlci, &addr_len, &flags, length);
        if (ret == -1)
                goto trunc;
        if (ret == 0) {
-               ND_PRINT((ndo, "Q.922, invalid address"));
+               ND_PRINT("Q.922, invalid address");
                return 0;
        }
 
-       ND_TCHECK_8BITS(p + addr_len);
+       ND_TCHECK_1(p + addr_len);
        if (length < addr_len + 1)
                goto trunc;
 
-       if (EXTRACT_8BITS(p + addr_len) != LLC_UI && dlci != 0) {
+       if (GET_U_1(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_TTEST_16BITS(p + addr_len) || length < addr_len + 2) {
+               if (!ND_TTEST_2(p + addr_len) || length < addr_len + 2) {
                         /* no Ethertype */
-                        ND_PRINT((ndo, "UI %02x! ", EXTRACT_8BITS(p + addr_len)));
+                        ND_PRINT("UI %02x! ", GET_U_1(p + addr_len));
                 } else {
-                        extracted_ethertype = EXTRACT_BE_16BITS(p + addr_len);
+                        extracted_ethertype = GET_BE_U_2(p + addr_len);
 
                         if (ndo->ndo_eflag)
                                 fr_hdr_print(ndo, length, addr_len, dlci,
@@ -276,26 +276,26 @@ fr_print(netdissect_options *ndo,
                         if (ethertype_print(ndo, extracted_ethertype,
                                             p+addr_len+ETHERTYPE_LEN,
                                             length-addr_len-ETHERTYPE_LEN,
-                                            ndo->ndo_snapend-p-addr_len-ETHERTYPE_LEN,
+                                            ND_BYTES_AVAILABLE_AFTER(p)-addr_len-ETHERTYPE_LEN,
                                             NULL, NULL) == 0)
                                 /* ether_type not known, probably it wasn't one */
-                                ND_PRINT((ndo, "UI %02x! ", EXTRACT_8BITS(p + addr_len)));
+                                ND_PRINT("UI %02x! ", GET_U_1(p + addr_len));
                         else
                                 return addr_len + 2;
                 }
         }
 
-       ND_TCHECK_8BITS(p + addr_len + 1);
+       ND_TCHECK_1(p + addr_len + 1);
        if (length < addr_len + 2)
                goto trunc;
 
-       if (EXTRACT_8BITS(p + addr_len + 1) == 0) {
+       if (GET_U_1(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.
                 */
                if (addr_len != 3)
-                       ND_PRINT((ndo, "Pad! "));
+                       ND_PRINT("Pad! ");
                hdr_len = addr_len + 1 /* UI */ + 1 /* pad */ + 1 /* NLPID */;
        } else {
                /*
@@ -303,14 +303,14 @@ fr_print(netdissect_options *ndo,
                 * A pad byte should be used with 3-byte Q.922.
                 */
                if (addr_len == 3)
-                       ND_PRINT((ndo, "No pad! "));
+                       ND_PRINT("No pad! ");
                hdr_len = addr_len + 1 /* UI */ + 1 /* NLPID */;
        }
 
-        ND_TCHECK_8BITS(p + hdr_len - 1);
+        ND_TCHECK_1(p + hdr_len - 1);
        if (length < hdr_len)
                goto trunc;
-       nlpid = EXTRACT_8BITS(p + hdr_len - 1);
+       nlpid = GET_U_1(p + hdr_len - 1);
 
        if (ndo->ndo_eflag)
                fr_hdr_print(ndo, length, addr_len, dlci, flags, nlpid);
@@ -333,7 +333,7 @@ fr_print(netdissect_options *ndo,
                break;
 
        case NLPID_SNAP:
-               if (snap_print(ndo, p, length, ndo->ndo_snapend - p, NULL, NULL, 0) == 0) {
+               if (snap_print(ndo, p, length, ND_BYTES_AVAILABLE_AFTER(p), NULL, NULL, 0) == 0) {
                        /* ether_type not known, print raw packet */
                         if (!ndo->ndo_eflag)
                             fr_hdr_print(ndo, length + hdr_len, hdr_len,
@@ -365,27 +365,28 @@ fr_print(netdissect_options *ndo,
 
        return hdr_len;
 
- trunc:
-        ND_PRINT((ndo, "[|fr]"));
+trunc:
+        nd_print_trunc(ndo);
         return 0;
 
 }
 
 u_int
 mfr_if_print(netdissect_options *ndo,
-             const struct pcap_pkthdr *h, register const u_char *p)
+             const struct pcap_pkthdr *h, const u_char *p)
 {
-       register u_int length = h->len;
-       register u_int caplen = h->caplen;
+       u_int length = h->len;
+       u_int caplen = h->caplen;
 
-        ND_TCHECK2(*p, 2); /* minimum frame header length */
+       ndo->ndo_protocol = "mfr_if";
+        ND_TCHECK_2(p); /* minimum frame header length */
 
         if ((length = mfr_print(ndo, p, length)) == 0)
             return (0);
         else
             return length;
- trunc:
-        ND_PRINT((ndo, "[|mfr]"));
+trunc:
+        nd_print_trunc(ndo);
         return caplen;
 }
 
@@ -435,7 +436,7 @@ struct ie_tlv_header_t {
 
 u_int
 mfr_print(netdissect_options *ndo,
-          register const u_char *p, u_int length)
+          const u_char *p, u_int length)
 {
     u_int tlen,idx,hdr_len = 0;
     uint16_t sequence_num;
@@ -456,13 +457,20 @@ mfr_print(netdissect_options *ndo,
  *    +----+----+----+----+----+----+----+----+
  */
 
-    ND_TCHECK2(*p, 4); /* minimum frame header length */
+    ndo->ndo_protocol = "mfr";
 
-    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",(EXTRACT_8BITS(p) & MFR_BEC_MASK)),
-               tok2str(mfr_ctrl_msg_values,"Unknown Message (0x%02x)",EXTRACT_8BITS(p+2)),
-               length));
+    if (length < 4) {  /* minimum frame header length */
+        ND_PRINT("[length %u < 4]", length);
+        nd_print_invalid(ndo);
+        return length;
+    }
+    ND_TCHECK_4(p);
+
+    if ((GET_U_1(p) & MFR_BEC_MASK) == MFR_CTRL_FRAME && GET_U_1(p + 1) == 0) {
+        ND_PRINT("FRF.16 Control, Flags [%s], %s, length %u",
+               bittok2str(frf_flag_values,"none",(GET_U_1(p) & MFR_BEC_MASK)),
+               tok2str(mfr_ctrl_msg_values,"Unknown Message (0x%02x)",GET_U_1(p + 2)),
+               length);
         tptr = p + 3;
         tlen = length -3;
         hdr_len = 3;
@@ -471,20 +479,20 @@ mfr_print(netdissect_options *ndo,
             return hdr_len;
 
         while (tlen>sizeof(struct ie_tlv_header_t)) {
-            ND_TCHECK2(*tptr, sizeof(struct ie_tlv_header_t));
-            ie_type=tptr[0];
-            ie_len=tptr[1];
+            ND_TCHECK_LEN(tptr, sizeof(struct ie_tlv_header_t));
+            ie_type=GET_U_1(tptr);
+            ie_len=GET_U_1(tptr + 1);
 
-            ND_PRINT((ndo, "\n\tIE %s (%u), length %u: ",
+            ND_PRINT("\n\tIE %s (%u), length %u: ",
                    tok2str(mfr_ctrl_ie_values,"Unknown",ie_type),
                    ie_type,
-                   ie_len));
+                   ie_len);
 
             /* infinite loop check */
             if (ie_type == 0 || ie_len <= sizeof(struct ie_tlv_header_t))
                 return hdr_len;
 
-            ND_TCHECK2(*tptr, ie_len);
+            ND_TCHECK_LEN(tptr, ie_len);
             tptr+=sizeof(struct ie_tlv_header_t);
             /* tlv len includes header */
             ie_len-=sizeof(struct ie_tlv_header_t);
@@ -493,14 +501,20 @@ mfr_print(netdissect_options *ndo,
             switch (ie_type) {
 
             case MFR_CTRL_IE_MAGIC_NUM:
-                ND_PRINT((ndo, "0x%08x", EXTRACT_BE_32BITS(tptr)));
+                /* FRF.16.1 Section 3.4.3 Magic Number Information Element */
+                if (ie_len != 4) {
+                    ND_PRINT("[IE data length %d != 4]", ie_len);
+                    nd_print_invalid(ndo);
+                    break;
+                }
+                ND_PRINT("0x%08x", GET_BE_U_4(tptr));
                 break;
 
             case MFR_CTRL_IE_BUNDLE_ID: /* same message format */
             case MFR_CTRL_IE_LINK_ID:
                 for (idx = 0; idx < ie_len && idx < MFR_ID_STRING_MAXLEN; idx++) {
-                    if (*(tptr+idx) != 0) /* don't print null termination */
-                        safeputchar(ndo, *(tptr + idx));
+                    if (GET_U_1(tptr + idx) != 0) /* don't print null termination */
+                        fn_print_char(ndo, GET_U_1(tptr + idx));
                     else
                         break;
                 }
@@ -542,38 +556,38 @@ mfr_print(netdissect_options *ndo,
  *
  *      7    6    5    4    3    2    1    0
  *    +----+----+----+----+----+----+----+----+
- *    | B  | E  | C=0|seq. (high 4 bits) | EA  |
+ *    | B  | E  | C=0|seq. (high 4 bits) | EA |
  *    +----+----+----+----+----+----+----+----+
  *    |        sequence  (low 8 bits)         |
  *    +----+----+----+----+----+----+----+----+
- *    |        DLCI (6 bits)        | CR | EA  |
+ *    |        DLCI (6 bits)        | CR | EA |
  *    +----+----+----+----+----+----+----+----+
  *    |   DLCI (4 bits)   |FECN|BECN| DE | EA |
  *    +----+----+----+----+----+----+----+----+
  */
 
-    sequence_num = (EXTRACT_8BITS(p)&0x1e)<<7 | EXTRACT_8BITS(p+1);
+    sequence_num = (GET_U_1(p)&0x1e)<<7 | GET_U_1(p + 1);
     /* whole packet or first fragment ? */
-    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], ",
+    if ((GET_U_1(p) & MFR_BEC_MASK) == MFR_FRAG_FRAME ||
+        (GET_U_1(p) & MFR_BEC_MASK) == MFR_B_BIT) {
+        ND_PRINT("FRF.16 Frag, seq %u, Flags [%s], ",
                sequence_num,
-               bittok2str(frf_flag_values,"none",(EXTRACT_8BITS(p) & MFR_BEC_MASK))));
+               bittok2str(frf_flag_values,"none",(GET_U_1(p) & MFR_BEC_MASK)));
         hdr_len = 2;
         fr_print(ndo, p+hdr_len,length-hdr_len);
         return hdr_len;
     }
 
     /* must be a middle or the last fragment */
-    ND_PRINT((ndo, "FRF.16 Frag, seq %u, Flags [%s]",
+    ND_PRINT("FRF.16 Frag, seq %u, Flags [%s]",
            sequence_num,
-           bittok2str(frf_flag_values,"none",(EXTRACT_8BITS(p) & MFR_BEC_MASK))));
+           bittok2str(frf_flag_values,"none",(GET_U_1(p) & MFR_BEC_MASK)));
     print_unknown_data(ndo, p, "\n\t", length);
 
     return hdr_len;
 
- trunc:
-    ND_PRINT((ndo, "[|mfr]"));
+trunc:
+    nd_print_trunc(ndo);
     return length;
 }
 
@@ -602,16 +616,16 @@ frf15_print(netdissect_options *ndo,
 
     if (length < 2)
         goto trunc;
-    ND_TCHECK2(*p, 2);
+    ND_TCHECK_2(p);
 
-    flags = EXTRACT_8BITS(p)&MFR_BEC_MASK;
-    sequence_num = (EXTRACT_8BITS(p)&0x1e)<<7 | EXTRACT_8BITS(p+1);
+    flags = GET_U_1(p)&MFR_BEC_MASK;
+    sequence_num = (GET_U_1(p)&0x1e)<<7 | GET_U_1(p + 1);
 
-    ND_PRINT((ndo, "FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u",
+    ND_PRINT("FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u",
            sequence_num,
            bittok2str(frf_flag_values,"none",flags),
-           EXTRACT_8BITS(p)&FR_FRF15_FRAGTYPE ? "Interface" : "End-to-End",
-           length));
+           GET_U_1(p)&FR_FRF15_FRAGTYPE ? "Interface" : "End-to-End",
+           length);
 
 /* TODO:
  * depending on all permutations of the B, E and C bit
@@ -624,7 +638,7 @@ frf15_print(netdissect_options *ndo,
     return;
 
 trunc:
-    ND_PRINT((ndo, "[|frf.15]"));
+    nd_print_trunc(ndo);
 }
 
 /*
@@ -800,12 +814,13 @@ q933_print(netdissect_options *ndo,
        u_int non_locking_shift;
        u_int unshift_codeset;
 
-       ND_PRINT((ndo, "%s", ndo->ndo_eflag ? "" : "Q.933"));
+       ndo->ndo_protocol = "q.933";
+       ND_PRINT("%s", ndo->ndo_eflag ? "" : "Q.933");
 
-       if (length == 0 || !ND_TTEST(*p)) {
+       if (length == 0 || !ND_TTEST_1(p)) {
                if (!ndo->ndo_eflag)
-                       ND_PRINT((ndo, ", "));
-               ND_PRINT((ndo, "length %u", length));
+                       ND_PRINT(", ");
+               ND_PRINT("length %u", length);
                goto trunc;
        }
 
@@ -813,7 +828,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 = EXTRACT_8BITS(p) & 0x0f;
+       call_ref_length = GET_U_1(p) & 0x0f;
        p++;
        length--;
 
@@ -821,13 +836,13 @@ q933_print(netdissect_options *ndo,
         * Get the call reference value.
         */
        for (i = 0; i < call_ref_length; i++) {
-               if (length == 0 || !ND_TTEST(*p)) {
+               if (length == 0 || !ND_TTEST_1(p)) {
                        if (!ndo->ndo_eflag)
-                               ND_PRINT((ndo, ", "));
-                       ND_PRINT((ndo, "length %u", olen));
+                               ND_PRINT(", ");
+                       ND_PRINT("length %u", olen);
                        goto trunc;
                }
-               call_ref[i] = EXTRACT_8BITS(p);
+               call_ref[i] = GET_U_1(p);
                p++;
                length--;
        }
@@ -835,13 +850,13 @@ q933_print(netdissect_options *ndo,
        /*
         * Get the message type.
         */
-       if (length == 0 || !ND_TTEST(*p)) {
+       if (length == 0 || !ND_TTEST_1(p)) {
                if (!ndo->ndo_eflag)
-                       ND_PRINT((ndo, ", "));
-               ND_PRINT((ndo, "length %u", olen));
+                       ND_PRINT(", ");
+               ND_PRINT("length %u", olen);
                goto trunc;
        }
-       msgtype = EXTRACT_8BITS(p);
+       msgtype = GET_U_1(p);
        p++;
        length--;
 
@@ -851,13 +866,13 @@ q933_print(netdissect_options *ndo,
        non_locking_shift = 0;
        unshift_codeset = codeset;
        if (length != 0) {
-               if (!ND_TTEST(*p)) {
+               if (!ND_TTEST_1(p)) {
                        if (!ndo->ndo_eflag)
-                               ND_PRINT((ndo, ", "));
-                       ND_PRINT((ndo, "length %u", olen));
+                               ND_PRINT(", ");
+                       ND_PRINT("length %u", olen);
                        goto trunc;
                }
-               iecode = EXTRACT_8BITS(p);
+               iecode = GET_U_1(p);
                if (IE_IS_SHIFT(iecode)) {
                        /*
                         * It's a shift.  Skip over it.
@@ -903,30 +918,30 @@ q933_print(netdissect_options *ndo,
 
        /* printing out header part */
        if (!ndo->ndo_eflag)
-               ND_PRINT((ndo, ", "));
-       ND_PRINT((ndo, "%s, codeset %u", is_ansi ? "ANSI" : "CCITT", codeset));
+               ND_PRINT(", ");
+       ND_PRINT("%s, codeset %u", is_ansi ? "ANSI" : "CCITT", codeset);
 
        if (call_ref_length != 0) {
-               ND_TCHECK_8BITS(p);
-               if (call_ref_length > 1 || EXTRACT_8BITS(p) != 0) {
+               ND_TCHECK_1(p);
+               if (call_ref_length > 1 || GET_U_1(p) != 0) {
                        /*
                         * Not a dummy call reference.
                         */
-                       ND_PRINT((ndo, ", Call Ref: 0x"));
+                       ND_PRINT(", Call Ref: 0x");
                        for (i = 0; i < call_ref_length; i++)
-                               ND_PRINT((ndo, "%02x", call_ref[i]));
+                               ND_PRINT("%02x", call_ref[i]);
                }
        }
        if (ndo->ndo_vflag) {
-               ND_PRINT((ndo, ", %s (0x%02x), length %u",
+               ND_PRINT(", %s (0x%02x), length %u",
                   tok2str(fr_q933_msg_values,
                        "unknown message", msgtype),
                   msgtype,
-                  olen));
+                  olen);
        } else {
-               ND_PRINT((ndo, ", %s",
+               ND_PRINT(", %s",
                       tok2str(fr_q933_msg_values,
-                              "unknown message 0x%02x", msgtype)));
+                              "unknown message 0x%02x", msgtype));
        }
 
        /* Loop through the rest of the IEs */
@@ -952,13 +967,13 @@ q933_print(netdissect_options *ndo,
                /*
                 * Get the first octet of the IE.
                 */
-               if (!ND_TTEST(*p)) {
+               if (!ND_TTEST_1(p)) {
                        if (!ndo->ndo_vflag) {
-                               ND_PRINT((ndo, ", length %u", olen));
+                               ND_PRINT(", length %u", olen);
                        }
                        goto trunc;
                }
-               iecode = EXTRACT_8BITS(p);
+               iecode = GET_U_1(p);
                p++;
                length--;
 
@@ -995,13 +1010,13 @@ q933_print(netdissect_options *ndo,
                        /*
                         * No.  Get the IE length.
                         */
-                       if (length == 0 || !ND_TTEST(*p)) {
+                       if (length == 0 || !ND_TTEST_1(p)) {
                                if (!ndo->ndo_vflag) {
-                                       ND_PRINT((ndo, ", length %u", olen));
+                                       ND_PRINT(", length %u", olen);
                                }
                                goto trunc;
                        }
-                       ielength = EXTRACT_8BITS(p);
+                       ielength = GET_U_1(p);
                        p++;
                        length--;
 
@@ -1009,20 +1024,20 @@ q933_print(netdissect_options *ndo,
                         * however some IEs (DLCI Status, Link Verify)
                         * are also interesting in non-verbose mode */
                        if (ndo->ndo_vflag) {
-                               ND_PRINT((ndo, "\n\t%s IE (0x%02x), length %u: ",
+                               ND_PRINT("\n\t%s IE (0x%02x), length %u: ",
                                    tok2str(fr_q933_ie_codesets[codeset],
                                        "unknown", iecode),
                                    iecode,
-                                   ielength));
+                                   ielength);
                        }
 
                        /* sanity checks */
                        if (iecode == 0 || ielength == 0) {
                                return;
                        }
-                       if (length < ielength || !ND_TTEST2(*p, ielength)) {
+                       if (length < ielength || !ND_TTEST_LEN(p, ielength)) {
                                if (!ndo->ndo_vflag) {
-                                       ND_PRINT((ndo, ", length %u", olen));
+                                       ND_PRINT(", length %u", olen);
                                }
                                goto trunc;
                        }
@@ -1056,12 +1071,12 @@ q933_print(netdissect_options *ndo,
                }
        }
        if (!ndo->ndo_vflag) {
-           ND_PRINT((ndo, ", length %u", olen));
+           ND_PRINT(", length %u", olen);
        }
        return;
 
 trunc:
-       ND_PRINT((ndo, "[|q.933]"));
+       nd_print_trunc(ndo);
 }
 
 static int
@@ -1076,15 +1091,15 @@ fr_q933_print_ie_codeset_0_5(netdissect_options *ndo, u_int iecode,
         case FR_LMI_CCITT_REPORT_TYPE_IE:
             if (ielength < 1) {
                 if (!ndo->ndo_vflag) {
-                    ND_PRINT((ndo, ", "));
+                    ND_PRINT(", ");
                }
-                ND_PRINT((ndo, "Invalid REPORT TYPE IE"));
+                ND_PRINT("Invalid REPORT TYPE IE");
                 return 1;
             }
             if (ndo->ndo_vflag) {
-                ND_PRINT((ndo, "%s (%u)",
-                       tok2str(fr_lmi_report_type_ie_values,"unknown",EXTRACT_8BITS(p)),
-                       EXTRACT_8BITS(p)));
+                ND_PRINT("%s (%u)",
+                       tok2str(fr_lmi_report_type_ie_values,"unknown",GET_U_1(p)),
+                       GET_U_1(p));
            }
             return 1;
 
@@ -1092,54 +1107,48 @@ fr_q933_print_ie_codeset_0_5(netdissect_options *ndo, u_int iecode,
         case FR_LMI_CCITT_LINK_VERIFY_IE:
         case FR_LMI_ANSI_LINK_VERIFY_IE_91:
             if (!ndo->ndo_vflag) {
-                ND_PRINT((ndo, ", "));
+                ND_PRINT(", ");
            }
             if (ielength < 2) {
-                ND_PRINT((ndo, "Invalid LINK VERIFY IE"));
+                ND_PRINT("Invalid LINK VERIFY IE");
                 return 1;
             }
-            ND_PRINT((ndo, "TX Seq: %3d, RX Seq: %3d", EXTRACT_8BITS(p), EXTRACT_8BITS(p+1)));
+            ND_PRINT("TX Seq: %3d, RX Seq: %3d", GET_U_1(p), GET_U_1(p + 1));
             return 1;
 
         case FR_LMI_ANSI_PVC_STATUS_IE: /* fall through */
         case FR_LMI_CCITT_PVC_STATUS_IE:
             if (!ndo->ndo_vflag) {
-                ND_PRINT((ndo, ", "));
+                ND_PRINT(", ");
            }
             /* now parse the DLCI information element. */
             if ((ielength < 3) ||
-                (EXTRACT_8BITS(p) & 0x80) ||
-                ((ielength == 3) && !(EXTRACT_8BITS(p+1) & 0x80)) ||
+                (GET_U_1(p) & 0x80) ||
+                ((ielength == 3) && !(GET_U_1(p + 1) & 0x80)) ||
                 ((ielength == 4) &&
-                  ((EXTRACT_8BITS(p+1) & 0x80) || !(EXTRACT_8BITS(p+2) & 0x80))) ||
+                  ((GET_U_1(p + 1) & 0x80) || !(GET_U_1(p + 2) & 0x80))) ||
                 ((ielength == 5) &&
-                  ((EXTRACT_8BITS(p+1) & 0x80) || (EXTRACT_8BITS(p+2) & 0x80) ||
-                   !(EXTRACT_8BITS(p+3) & 0x80))) ||
+                  ((GET_U_1(p + 1) & 0x80) || (GET_U_1(p + 2) & 0x80) ||
+                   !(GET_U_1(p + 3) & 0x80))) ||
                 (ielength > 5) ||
-                !(EXTRACT_8BITS(p + ielength - 1) & 0x80)) {
-                ND_PRINT((ndo, "Invalid DLCI in PVC STATUS IE"));
+                !(GET_U_1(p + ielength - 1) & 0x80)) {
+                ND_PRINT("Invalid DLCI in PVC STATUS IE");
                 return 1;
            }
 
-            dlci = ((EXTRACT_8BITS(p) & 0x3F) << 4) | ((EXTRACT_8BITS(p+1) & 0x78) >> 3);
+            dlci = ((GET_U_1(p) & 0x3F) << 4) | ((GET_U_1(p + 1) & 0x78) >> 3);
             if (ielength == 4) {
-                dlci = (dlci << 6) | ((EXTRACT_8BITS(p+2) & 0x7E) >> 1);
+                dlci = (dlci << 6) | ((GET_U_1(p + 2) & 0x7E) >> 1);
            }
             else if (ielength == 5) {
-                dlci = (dlci << 13) | (EXTRACT_8BITS(p+2) & 0x7F) | ((EXTRACT_8BITS(p+3) & 0x7E) >> 1);
+                dlci = (dlci << 13) | (GET_U_1(p + 2) & 0x7F) | ((GET_U_1(p + 3) & 0x7E) >> 1);
            }
 
-            ND_PRINT((ndo, "DLCI %u: status %s%s", dlci,
-                    EXTRACT_8BITS(p + ielength - 1) & 0x8 ? "New, " : "",
-                    EXTRACT_8BITS(p + ielength - 1) & 0x2 ? "Active" : "Inactive"));
+            ND_PRINT("DLCI %u: status %s%s", dlci,
+                    GET_U_1(p + ielength - 1) & 0x8 ? "New, " : "",
+                    GET_U_1(p + ielength - 1) & 0x2 ? "Active" : "Inactive");
             return 1;
        }
 
         return 0;
 }
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */