]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-decnet.c
Revert partially the commit 21b1273
[tcpdump] / print-decnet.c
index f90ca6a05ba1e502a257f27b47f9a821459f10ce..e1c0c486e3f5f32cfb521901dda4bfb4101dabe4 100644 (file)
@@ -22,7 +22,7 @@
 /* \summary: DECnet printer */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
 #include "netdissect-stdinc.h"
 #include <stdlib.h>
 #include <string.h>
 
-struct mbuf;
-struct rtentry;
-
-#ifdef HAVE_DNET_HTOA
-  #ifdef HAVE_NETDNET_DN_H
-    #include <netdnet/dn.h>
-  #endif
-  #ifndef HAVE_STRUCT_DN_NADDR
-#define DN_MAXADDL     20              /* max size of DECnet address */
-struct dn_naddr {
-       unsigned short  a_len;          /* length of address */
-       unsigned char   a_addr[DN_MAXADDL]; /* address as bytes */
-};
-  #endif /* HAVE_STRUCT_DN_NADDR */
-  #ifdef HAVE_NETDNET_DNETDB_H
-    #include <netdnet/dnetdb.h>
-  #endif
-  #ifndef NETDNET_DNETDB_H_DECLARES_DNET_HTOA
-    extern char *dnet_htoa(struct dn_naddr *);
-  #endif
-#endif
-
 #include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
 
-static const char tstr[] = "[|decnet]";
 
 #ifndef _WIN32
 typedef nd_uint8_t byte;               /* single byte field */
@@ -492,10 +469,10 @@ struct dcmsg                              /* disconnect confirm message */
 /* Forwards */
 static int print_decnet_ctlmsg(netdissect_options *, const union routehdr *, u_int, u_int);
 static void print_t_info(netdissect_options *, u_int);
-static int print_l1_routes(netdissect_options *, const char *, u_int);
-static int print_l2_routes(netdissect_options *, const char *, u_int);
+static int print_l1_routes(netdissect_options *, const u_char *, u_int);
+static int print_l2_routes(netdissect_options *, const u_char *, u_int);
 static void print_i_info(netdissect_options *, u_int);
-static int print_elist(const char *, u_int);
+static int print_elist(const u_char *, u_int);
 static int print_nsp(netdissect_options *, const u_char *, u_int);
 static void print_reason(netdissect_options *, u_int);
 
@@ -506,30 +483,31 @@ decnet_print(netdissect_options *ndo,
 {
        const union routehdr *rhp;
        u_int mflags;
-       u_int dst, src, hops;
+       uint16_t dst, src;
+       u_int hops;
        u_int nsplen, pktlen;
        const u_char *nspp;
 
+       ndo->ndo_protocol = "decnet";
        if (length < sizeof(struct shorthdr)) {
-               ND_PRINT("%s", tstr);
+               nd_print_trunc(ndo);
                return;
        }
 
        ND_TCHECK_LEN(ap, sizeof(short));
-       pktlen = EXTRACT_LE_U_2(ap);
+       pktlen = GET_LE_U_2(ap);
        if (pktlen < sizeof(struct shorthdr)) {
-               ND_PRINT("%s", tstr);
+               nd_print_trunc(ndo);
                return;
        }
        if (pktlen > length) {
-               ND_PRINT("%s", tstr);
+               nd_print_trunc(ndo);
                return;
        }
        length = pktlen;
 
        rhp = (const union routehdr *)(ap + sizeof(short));
-       ND_TCHECK(rhp->rh_short.sh_flags);
-       mflags = EXTRACT_U_1(rhp->rh_short.sh_flags);
+       mflags = GET_U_1(rhp->rh_short.sh_flags);
 
        if (mflags & RMF_PAD) {
            /* pad bytes of some sort in front of message */
@@ -537,7 +515,7 @@ decnet_print(netdissect_options *ndo,
            if (ndo->ndo_vflag)
                ND_PRINT("[pad:%u] ", padlen);
            if (length < padlen + 2) {
-               ND_PRINT("%s", tstr);
+               nd_print_trunc(ndo);
                return;
            }
            ND_TCHECK_LEN(ap + sizeof(short), padlen);
@@ -545,13 +523,12 @@ decnet_print(netdissect_options *ndo,
            length -= padlen;
            caplen -= padlen;
            rhp = (const union routehdr *)(ap + sizeof(short));
-           ND_TCHECK(rhp->rh_short.sh_flags);
-           mflags = EXTRACT_U_1(rhp->rh_short.sh_flags);
+           mflags = GET_U_1(rhp->rh_short.sh_flags);
        }
 
        if (mflags & RMF_FVER) {
                ND_PRINT("future-version-decnet");
-               ND_DEFAULTPRINT(ap, min(length, caplen));
+               ND_DEFAULTPRINT(ap, ND_MIN(length, caplen));
                return;
        }
 
@@ -565,29 +542,29 @@ decnet_print(netdissect_options *ndo,
        switch (mflags & RMF_MASK) {
        case RMF_LONG:
            if (length < sizeof(struct longhdr)) {
-               ND_PRINT("%s", tstr);
+               nd_print_trunc(ndo);
                return;
            }
-           ND_TCHECK(rhp->rh_long);
+           ND_TCHECK_SIZE(&rhp->rh_long);
            dst =
-               EXTRACT_LE_U_2(rhp->rh_long.lg_dst.dne_remote.dne_nodeaddr);
+               GET_LE_U_2(rhp->rh_long.lg_dst.dne_remote.dne_nodeaddr);
            src =
-               EXTRACT_LE_U_2(rhp->rh_long.lg_src.dne_remote.dne_nodeaddr);
-           hops = EXTRACT_U_1(rhp->rh_long.lg_visits);
+               GET_LE_U_2(rhp->rh_long.lg_src.dne_remote.dne_nodeaddr);
+           hops = GET_U_1(rhp->rh_long.lg_visits);
            nspp = ap + sizeof(short) + sizeof(struct longhdr);
            nsplen = length - sizeof(struct longhdr);
            break;
        case RMF_SHORT:
-           ND_TCHECK(rhp->rh_short);
-           dst = EXTRACT_LE_U_2(rhp->rh_short.sh_dst);
-           src = EXTRACT_LE_U_2(rhp->rh_short.sh_src);
-           hops = (EXTRACT_U_1(rhp->rh_short.sh_visits) & VIS_MASK)+1;
+           ND_TCHECK_SIZE(&rhp->rh_short);
+           dst = GET_LE_U_2(rhp->rh_short.sh_dst);
+           src = GET_LE_U_2(rhp->rh_short.sh_src);
+           hops = (GET_U_1(rhp->rh_short.sh_visits) & VIS_MASK)+1;
            nspp = ap + sizeof(short) + sizeof(struct shorthdr);
            nsplen = length - sizeof(struct shorthdr);
            break;
        default:
            ND_PRINT("unknown message flags under mask");
-           ND_DEFAULTPRINT((const u_char *)ap, min(length, caplen));
+           ND_DEFAULTPRINT((const u_char *)ap, ND_MIN(length, caplen));
            return;
        }
 
@@ -608,7 +585,7 @@ decnet_print(netdissect_options *ndo,
        return;
 
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return;
 }
 
@@ -618,12 +595,12 @@ print_decnet_ctlmsg(netdissect_options *ndo,
                     u_int caplen)
 {
        /* Our caller has already checked for mflags */
-       u_int mflags = EXTRACT_U_1(rhp->rh_short.sh_flags);
+       u_int mflags = GET_U_1(rhp->rh_short.sh_flags);
        const union controlmsg *cmp = (const union controlmsg *)rhp;
-       u_int src, dst, info, blksize, eco, ueco, hello, other, vers;
-       etheraddr srcea, rtea;
+       uint16_t src, dst;
+       u_int info, blksize, eco, ueco, hello, other, vers;
        u_int priority;
-       const char *rhpx = (const char *)rhp;
+       const u_char *rhpx = (const u_char *)rhp;
        int ret;
 
        switch (mflags & RMF_CTLMASK) {
@@ -631,14 +608,14 @@ print_decnet_ctlmsg(netdissect_options *ndo,
            ND_PRINT("init ");
            if (length < sizeof(struct initmsg))
                goto trunc;
-           ND_TCHECK(cmp->cm_init);
-           src = EXTRACT_LE_U_2(cmp->cm_init.in_src);
-           info = EXTRACT_U_1(cmp->cm_init.in_info);
-           blksize = EXTRACT_LE_U_2(cmp->cm_init.in_blksize);
-           vers = EXTRACT_U_1(cmp->cm_init.in_vers);
-           eco = EXTRACT_U_1(cmp->cm_init.in_eco);
-           ueco = EXTRACT_U_1(cmp->cm_init.in_ueco);
-           hello = EXTRACT_LE_U_2(cmp->cm_init.in_hello);
+           ND_TCHECK_SIZE(&cmp->cm_init);
+           src = GET_LE_U_2(cmp->cm_init.in_src);
+           info = GET_U_1(cmp->cm_init.in_info);
+           blksize = GET_LE_U_2(cmp->cm_init.in_blksize);
+           vers = GET_U_1(cmp->cm_init.in_vers);
+           eco = GET_U_1(cmp->cm_init.in_eco);
+           ueco = GET_U_1(cmp->cm_init.in_ueco);
+           hello = GET_LE_U_2(cmp->cm_init.in_hello);
            print_t_info(ndo, info);
            ND_PRINT("src %sblksize %u vers %u eco %u ueco %u hello %u",
                        dnaddr_string(ndo, src), blksize, vers, eco, ueco,
@@ -649,9 +626,9 @@ print_decnet_ctlmsg(netdissect_options *ndo,
            ND_PRINT("verification ");
            if (length < sizeof(struct verifmsg))
                goto trunc;
-           ND_TCHECK(cmp->cm_ver);
-           src = EXTRACT_LE_U_2(cmp->cm_ver.ve_src);
-           other = EXTRACT_U_1(cmp->cm_ver.ve_fcnval);
+           ND_TCHECK_SIZE(&cmp->cm_ver);
+           src = GET_LE_U_2(cmp->cm_ver.ve_src);
+           other = GET_U_1(cmp->cm_ver.ve_fcnval);
            ND_PRINT("src %s fcnval %o", dnaddr_string(ndo, src), other);
            ret = 1;
            break;
@@ -659,9 +636,9 @@ print_decnet_ctlmsg(netdissect_options *ndo,
            ND_PRINT("test ");
            if (length < sizeof(struct testmsg))
                goto trunc;
-           ND_TCHECK(cmp->cm_test);
-           src = EXTRACT_LE_U_2(cmp->cm_test.te_src);
-           other = EXTRACT_U_1(cmp->cm_test.te_data);
+           ND_TCHECK_SIZE(&cmp->cm_test);
+           src = GET_LE_U_2(cmp->cm_test.te_src);
+           other = GET_U_1(cmp->cm_test.te_data);
            ND_PRINT("src %s data %o", dnaddr_string(ndo, src), other);
            ret = 1;
            break;
@@ -669,8 +646,8 @@ print_decnet_ctlmsg(netdissect_options *ndo,
            ND_PRINT("lev-1-routing ");
            if (length < sizeof(struct l1rout))
                goto trunc;
-           ND_TCHECK(cmp->cm_l1rou);
-           src = EXTRACT_LE_U_2(cmp->cm_l1rou.r1_src);
+           ND_TCHECK_SIZE(&cmp->cm_l1rou);
+           src = GET_LE_U_2(cmp->cm_l1rou.r1_src);
            ND_PRINT("src %s ", dnaddr_string(ndo, src));
            ret = print_l1_routes(ndo, &(rhpx[sizeof(struct l1rout)]),
                                length - sizeof(struct l1rout));
@@ -679,8 +656,8 @@ print_decnet_ctlmsg(netdissect_options *ndo,
            ND_PRINT("lev-2-routing ");
            if (length < sizeof(struct l2rout))
                goto trunc;
-           ND_TCHECK(cmp->cm_l2rout);
-           src = EXTRACT_LE_U_2(cmp->cm_l2rout.r2_src);
+           ND_TCHECK_SIZE(&cmp->cm_l2rout);
+           src = GET_LE_U_2(cmp->cm_l2rout.r2_src);
            ND_PRINT("src %s ", dnaddr_string(ndo, src));
            ret = print_l2_routes(ndo, &(rhpx[sizeof(struct l2rout)]),
                                length - sizeof(struct l2rout));
@@ -689,17 +666,16 @@ print_decnet_ctlmsg(netdissect_options *ndo,
            ND_PRINT("router-hello ");
            if (length < sizeof(struct rhellomsg))
                goto trunc;
-           ND_TCHECK(cmp->cm_rhello);
-           vers = EXTRACT_U_1(cmp->cm_rhello.rh_vers);
-           eco = EXTRACT_U_1(cmp->cm_rhello.rh_eco);
-           ueco = EXTRACT_U_1(cmp->cm_rhello.rh_ueco);
-           memcpy((char *)&srcea, (const char *)&(cmp->cm_rhello.rh_src),
-               sizeof(srcea));
-           src = EXTRACT_LE_U_2(srcea.dne_remote.dne_nodeaddr);
-           info = EXTRACT_U_1(cmp->cm_rhello.rh_info);
-           blksize = EXTRACT_LE_U_2(cmp->cm_rhello.rh_blksize);
-           priority = EXTRACT_U_1(cmp->cm_rhello.rh_priority);
-           hello = EXTRACT_LE_U_2(cmp->cm_rhello.rh_hello);
+           ND_TCHECK_SIZE(&cmp->cm_rhello);
+           vers = GET_U_1(cmp->cm_rhello.rh_vers);
+           eco = GET_U_1(cmp->cm_rhello.rh_eco);
+           ueco = GET_U_1(cmp->cm_rhello.rh_ueco);
+           src =
+               GET_LE_U_2(cmp->cm_rhello.rh_src.dne_remote.dne_nodeaddr);
+           info = GET_U_1(cmp->cm_rhello.rh_info);
+           blksize = GET_LE_U_2(cmp->cm_rhello.rh_blksize);
+           priority = GET_U_1(cmp->cm_rhello.rh_priority);
+           hello = GET_LE_U_2(cmp->cm_rhello.rh_hello);
            print_i_info(ndo, info);
            ND_PRINT("vers %u eco %u ueco %u src %s blksize %u pri %u hello %u",
                        vers, eco, ueco, dnaddr_string(ndo, src),
@@ -711,21 +687,19 @@ print_decnet_ctlmsg(netdissect_options *ndo,
            ND_PRINT("endnode-hello ");
            if (length < sizeof(struct ehellomsg))
                goto trunc;
-           ND_TCHECK(cmp->cm_ehello);
-           vers = EXTRACT_U_1(cmp->cm_ehello.eh_vers);
-           eco = EXTRACT_U_1(cmp->cm_ehello.eh_eco);
-           ueco = EXTRACT_U_1(cmp->cm_ehello.eh_ueco);
-           memcpy((char *)&srcea, (const char *)&(cmp->cm_ehello.eh_src),
-               sizeof(srcea));
-           src = EXTRACT_LE_U_2(srcea.dne_remote.dne_nodeaddr);
-           info = EXTRACT_U_1(cmp->cm_ehello.eh_info);
-           blksize = EXTRACT_LE_U_2(cmp->cm_ehello.eh_blksize);
+           ND_TCHECK_SIZE(&cmp->cm_ehello);
+           vers = GET_U_1(cmp->cm_ehello.eh_vers);
+           eco = GET_U_1(cmp->cm_ehello.eh_eco);
+           ueco = GET_U_1(cmp->cm_ehello.eh_ueco);
+           src =
+               GET_LE_U_2(cmp->cm_ehello.eh_src.dne_remote.dne_nodeaddr);
+           info = GET_U_1(cmp->cm_ehello.eh_info);
+           blksize = GET_LE_U_2(cmp->cm_ehello.eh_blksize);
            /*seed*/
-           memcpy((char *)&rtea, (const char *)&(cmp->cm_ehello.eh_router),
-               sizeof(rtea));
-           dst = EXTRACT_LE_U_2(rtea.dne_remote.dne_nodeaddr);
-           hello = EXTRACT_LE_U_2(cmp->cm_ehello.eh_hello);
-           other = EXTRACT_U_1(cmp->cm_ehello.eh_data);
+           dst =
+               GET_LE_U_2(cmp->cm_ehello.eh_router.dne_remote.dne_nodeaddr);
+           hello = GET_LE_U_2(cmp->cm_ehello.eh_hello);
+           other = GET_U_1(cmp->cm_ehello.eh_data);
            print_i_info(ndo, info);
            ND_PRINT("vers %u eco %u ueco %u src %s blksize %u rtr %s hello %u data %o",
                        vers, eco, ueco, dnaddr_string(ndo, src),
@@ -735,7 +709,7 @@ print_decnet_ctlmsg(netdissect_options *ndo,
 
        default:
            ND_PRINT("unknown control message");
-           ND_DEFAULTPRINT((const u_char *)rhp, min(length, caplen));
+           ND_DEFAULTPRINT((const u_char *)rhp, ND_MIN(length, caplen));
            ret = 1;
            break;
        }
@@ -764,7 +738,7 @@ print_t_info(netdissect_options *ndo,
 
 static int
 print_l1_routes(netdissect_options *ndo,
-                const char *rp, u_int len)
+                const u_char *rp, u_int len)
 {
        u_int count;
        u_int id;
@@ -773,15 +747,15 @@ print_l1_routes(netdissect_options *ndo,
        /* The last short is a checksum */
        while (len > (3 * sizeof(short))) {
            ND_TCHECK_LEN(rp, 3 * sizeof(short));
-           count = EXTRACT_LE_U_2(rp);
+           count = GET_LE_U_2(rp);
            if (count > 1024)
                return (1);     /* seems to be bogus from here on */
            rp += sizeof(short);
            len -= sizeof(short);
-           id = EXTRACT_LE_U_2(rp);
+           id = GET_LE_U_2(rp);
            rp += sizeof(short);
            len -= sizeof(short);
-           info = EXTRACT_LE_U_2(rp);
+           info = GET_LE_U_2(rp);
            rp += sizeof(short);
            len -= sizeof(short);
            ND_PRINT("{ids %u-%u cost %u hops %u} ", id, id + count,
@@ -795,7 +769,7 @@ trunc:
 
 static int
 print_l2_routes(netdissect_options *ndo,
-                const char *rp, u_int len)
+                const u_char *rp, u_int len)
 {
        u_int count;
        u_int area;
@@ -804,15 +778,15 @@ print_l2_routes(netdissect_options *ndo,
        /* The last short is a checksum */
        while (len > (3 * sizeof(short))) {
            ND_TCHECK_LEN(rp, 3 * sizeof(short));
-           count = EXTRACT_LE_U_2(rp);
+           count = GET_LE_U_2(rp);
            if (count > 1024)
                return (1);     /* seems to be bogus from here on */
            rp += sizeof(short);
            len -= sizeof(short);
-           area = EXTRACT_LE_U_2(rp);
+           area = GET_LE_U_2(rp);
            rp += sizeof(short);
            len -= sizeof(short);
-           info = EXTRACT_LE_U_2(rp);
+           info = GET_LE_U_2(rp);
            rp += sizeof(short);
            len -= sizeof(short);
            ND_PRINT("{areas %u-%u cost %u hops %u} ", area, area + count,
@@ -844,7 +818,7 @@ print_i_info(netdissect_options *ndo,
 }
 
 static int
-print_elist(const char *elp _U_, u_int len _U_)
+print_elist(const u_char *elp _U_, u_int len _U_)
 {
        /* Not enough examples available for me to debug this */
        return (1);
@@ -860,9 +834,9 @@ print_nsp(netdissect_options *ndo,
        if (nsplen < sizeof(struct nsphdr))
                goto trunc;
        ND_TCHECK_SIZE(nsphp);
-       flags = EXTRACT_U_1(nsphp->nh_flags);
-       dst = EXTRACT_LE_U_2(nsphp->nh_dst);
-       src = EXTRACT_LE_U_2(nsphp->nh_src);
+       flags = GET_U_1(nsphp->nh_flags);
+       dst = GET_LE_U_2(nsphp->nh_dst);
+       src = GET_LE_U_2(nsphp->nh_src);
 
        switch (flags & NSP_TYPEMASK) {
        case MFT_DATA:
@@ -879,8 +853,7 @@ print_nsp(netdissect_options *ndo,
 
                    if (nsplen < data_off)
                        goto trunc;
-                   ND_TCHECK(shp->sh_seq[0]);
-                   ack = EXTRACT_LE_U_2(shp->sh_seq[0]);
+                   ack = GET_LE_U_2(shp->sh_seq[0]);
                    if (ack & SGQ_ACK) {        /* acknum field */
                        if ((ack & SGQ_NAK) == SGQ_NAK)
                            ND_PRINT("nak %u ", ack & SGQ_MASK);
@@ -889,8 +862,7 @@ print_nsp(netdissect_options *ndo,
                        data_off += sizeof(short);
                        if (nsplen < data_off)
                            goto trunc;
-                       ND_TCHECK(shp->sh_seq[1]);
-                       ack = EXTRACT_LE_U_2(shp->sh_seq[1]);
+                       ack = GET_LE_U_2(shp->sh_seq[1]);
                        if (ack & SGQ_OACK) {   /* ackoth field */
                            if ((ack & SGQ_ONAK) == SGQ_ONAK)
                                ND_PRINT("onak %u ", ack & SGQ_MASK);
@@ -899,8 +871,7 @@ print_nsp(netdissect_options *ndo,
                            data_off += sizeof(short);
                            if (nsplen < data_off)
                                goto trunc;
-                           ND_TCHECK(shp->sh_seq[2]);
-                           ack = EXTRACT_LE_U_2(shp->sh_seq[2]);
+                           ack = GET_LE_U_2(shp->sh_seq[2]);
                        }
                    }
                    ND_PRINT("seg %u ", ack & SGQ_MASK);
@@ -915,8 +886,7 @@ print_nsp(netdissect_options *ndo,
 
                    if (nsplen < data_off)
                        goto trunc;
-                   ND_TCHECK(shp->sh_seq[0]);
-                   ack = EXTRACT_LE_U_2(shp->sh_seq[0]);
+                   ack = GET_LE_U_2(shp->sh_seq[0]);
                    if (ack & SGQ_ACK) {        /* acknum field */
                        if ((ack & SGQ_NAK) == SGQ_NAK)
                            ND_PRINT("nak %u ", ack & SGQ_MASK);
@@ -925,8 +895,7 @@ print_nsp(netdissect_options *ndo,
                        data_off += sizeof(short);
                        if (nsplen < data_off)
                            goto trunc;
-                       ND_TCHECK(shp->sh_seq[1]);
-                       ack = EXTRACT_LE_U_2(shp->sh_seq[1]);
+                       ack = GET_LE_U_2(shp->sh_seq[1]);
                        if (ack & SGQ_OACK) {   /* ackdat field */
                            if ((ack & SGQ_ONAK) == SGQ_ONAK)
                                ND_PRINT("nakdat %u ", ack & SGQ_MASK);
@@ -935,8 +904,7 @@ print_nsp(netdissect_options *ndo,
                            data_off += sizeof(short);
                            if (nsplen < data_off)
                                goto trunc;
-                           ND_TCHECK(shp->sh_seq[2]);
-                           ack = EXTRACT_LE_U_2(shp->sh_seq[2]);
+                           ack = GET_LE_U_2(shp->sh_seq[2]);
                        }
                    }
                    ND_PRINT("seg %u ", ack & SGQ_MASK);
@@ -953,28 +921,25 @@ print_nsp(netdissect_options *ndo,
 
                    if (nsplen < sizeof(struct seghdr) + sizeof(struct lsmsg))
                        goto trunc;
-                   ND_TCHECK(shp->sh_seq[0]);
-                   ack = EXTRACT_LE_U_2(shp->sh_seq[0]);
+                   ack = GET_LE_U_2(shp->sh_seq[0]);
                    if (ack & SGQ_ACK) {        /* acknum field */
                        if ((ack & SGQ_NAK) == SGQ_NAK)
                            ND_PRINT("nak %u ", ack & SGQ_MASK);
                        else
                            ND_PRINT("ack %u ", ack & SGQ_MASK);
-                       ND_TCHECK(shp->sh_seq[1]);
-                       ack = EXTRACT_LE_U_2(shp->sh_seq[1]);
+                       ack = GET_LE_U_2(shp->sh_seq[1]);
                        if (ack & SGQ_OACK) {   /* ackdat field */
                            if ((ack & SGQ_ONAK) == SGQ_ONAK)
                                ND_PRINT("nakdat %u ", ack & SGQ_MASK);
                            else
                                ND_PRINT("ackdat %u ", ack & SGQ_MASK);
-                           ND_TCHECK(shp->sh_seq[2]);
-                           ack = EXTRACT_LE_U_2(shp->sh_seq[2]);
+                           ack = GET_LE_U_2(shp->sh_seq[2]);
                        }
                    }
                    ND_PRINT("seg %u ", ack & SGQ_MASK);
                    ND_TCHECK_SIZE(lsmp);
-                   lsflags = EXTRACT_U_1(lsmp->ls_lsflags);
-                   fcval = EXTRACT_U_1(lsmp->ls_fcval);
+                   lsflags = GET_U_1(lsmp->ls_lsflags);
+                   fcval = GET_U_1(lsmp->ls_fcval);
                    switch (lsflags & LSI_MASK) {
                    case LSI_DATA:
                        ND_PRINT("dat seg count %u ", fcval);
@@ -1017,13 +982,13 @@ print_nsp(netdissect_options *ndo,
                    if (nsplen < sizeof(struct ackmsg))
                        goto trunc;
                    ND_TCHECK_SIZE(amp);
-                   ack = EXTRACT_LE_U_2(amp->ak_acknum[0]);
+                   ack = GET_LE_U_2(amp->ak_acknum[0]);
                    if (ack & SGQ_ACK) {        /* acknum field */
                        if ((ack & SGQ_NAK) == SGQ_NAK)
                            ND_PRINT("nak %u ", ack & SGQ_MASK);
                        else
                            ND_PRINT("ack %u ", ack & SGQ_MASK);
-                       ack = EXTRACT_LE_U_2(amp->ak_acknum[1]);
+                       ack = GET_LE_U_2(amp->ak_acknum[1]);
                        if (ack & SGQ_OACK) {   /* ackoth field */
                            if ((ack & SGQ_ONAK) == SGQ_ONAK)
                                ND_PRINT("onak %u ", ack & SGQ_MASK);
@@ -1042,14 +1007,13 @@ print_nsp(netdissect_options *ndo,
                    if (nsplen < sizeof(struct ackmsg))
                        goto trunc;
                    ND_TCHECK_SIZE(amp);
-                   ack = EXTRACT_LE_U_2(amp->ak_acknum[0]);
+                   ack = GET_LE_U_2(amp->ak_acknum[0]);
                    if (ack & SGQ_ACK) {        /* acknum field */
                        if ((ack & SGQ_NAK) == SGQ_NAK)
                            ND_PRINT("nak %u ", ack & SGQ_MASK);
                        else
                            ND_PRINT("ack %u ", ack & SGQ_MASK);
-                       ND_TCHECK(amp->ak_acknum[1]);
-                       ack = EXTRACT_LE_U_2(amp->ak_acknum[1]);
+                       ack = GET_LE_U_2(amp->ak_acknum[1]);
                        if (ack & SGQ_OACK) {   /* ackdat field */
                            if ((ack & SGQ_ONAK) == SGQ_ONAK)
                                ND_PRINT("nakdat %u ", ack & SGQ_MASK);
@@ -1083,9 +1047,9 @@ print_nsp(netdissect_options *ndo,
                    if (nsplen < sizeof(struct cimsg))
                        goto trunc;
                    ND_TCHECK_SIZE(cimp);
-                   services = EXTRACT_U_1(cimp->ci_services);
-                   info = EXTRACT_U_1(cimp->ci_info);
-                   segsize = EXTRACT_LE_U_2(cimp->ci_segsize);
+                   services = GET_U_1(cimp->ci_services);
+                   info = GET_U_1(cimp->ci_info);
+                   segsize = GET_LE_U_2(cimp->ci_segsize);
 
                    switch (services & COS_MASK) {
                    case COS_NONE:
@@ -1124,10 +1088,10 @@ print_nsp(netdissect_options *ndo,
                    if (nsplen < sizeof(struct ccmsg))
                        goto trunc;
                    ND_TCHECK_SIZE(ccmp);
-                   services = EXTRACT_U_1(ccmp->cc_services);
-                   info = EXTRACT_U_1(ccmp->cc_info);
-                   segsize = EXTRACT_LE_U_2(ccmp->cc_segsize);
-                   optlen = EXTRACT_U_1(ccmp->cc_optlen);
+                   services = GET_U_1(ccmp->cc_services);
+                   info = GET_U_1(ccmp->cc_info);
+                   segsize = GET_LE_U_2(ccmp->cc_segsize);
+                   optlen = GET_U_1(ccmp->cc_optlen);
 
                    switch (services & COS_MASK) {
                    case COS_NONE:
@@ -1169,8 +1133,8 @@ print_nsp(netdissect_options *ndo,
                    if (nsplen < sizeof(struct dimsg))
                        goto trunc;
                    ND_TCHECK_SIZE(dimp);
-                   reason = EXTRACT_LE_U_2(dimp->di_reason);
-                   optlen = EXTRACT_U_1(dimp->di_optlen);
+                   reason = GET_LE_U_2(dimp->di_reason);
+                   optlen = GET_U_1(dimp->di_optlen);
 
                    print_reason(ndo, reason);
                    if (optlen) {
@@ -1185,7 +1149,7 @@ print_nsp(netdissect_options *ndo,
                    u_int reason;
 
                    ND_TCHECK_SIZE(dcmp);
-                   reason = EXTRACT_LE_U_2(dcmp->dc_reason);
+                   reason = GET_LE_U_2(dcmp->dc_reason);
 
                    print_reason(ndo, reason);
                }
@@ -1246,28 +1210,10 @@ dnnum_string(netdissect_options *ndo, u_short dnaddr)
        u_int area = (u_short)(dnaddr & AREAMASK) >> AREASHIFT;
        u_int node = dnaddr & NODEMASK;
 
+       /* malloc() return used by the 'dnaddrtable' hash table: do not free() */
        str = (char *)malloc(siz = sizeof("00.0000"));
        if (str == NULL)
-               (*ndo->ndo_error)(ndo, "dnnum_string: malloc");
+               (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC, "dnnum_string: malloc");
        snprintf(str, siz, "%u.%u", area, node);
        return(str);
 }
-
-const char *
-dnname_string(netdissect_options *ndo, u_short dnaddr)
-{
-#ifdef HAVE_DNET_HTOA
-       struct dn_naddr dna;
-       char *dnname;
-
-       dna.a_len = sizeof(short);
-       memcpy((char *)dna.a_addr, (char *)&dnaddr, sizeof(short));
-       dnname = dnet_htoa(&dna);
-       if(dnname != NULL)
-               return (strdup(dnname));
-       else
-               return(dnnum_string(ndo, dnaddr));
-#else
-       return(dnnum_string(ndo, dnaddr));      /* punt */
-#endif
-}