]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-decnet.c
Clean up whitespaces
[tcpdump] / print-decnet.c
index ba409c7c813bb8595140b2f2a7494f94b18e6764..06985d0d5147d0a98623da9472bb855e5ea0de66 100644 (file)
@@ -31,9 +31,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-struct mbuf;
-struct rtentry;
-
 #ifdef HAVE_DNET_HTOA
   #ifdef HAVE_NETDNET_DN_H
     #include <netdnet/dn.h>
@@ -57,7 +54,6 @@ struct dn_naddr {
 #include "extract.h"
 #include "addrtoname.h"
 
-static const char tstr[] = "[|decnet]";
 
 #ifndef _WIN32
 typedef nd_uint8_t byte;               /* single byte field */
@@ -492,10 +488,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);
 
@@ -510,19 +506,20 @@ decnet_print(netdissect_options *ndo,
        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);
        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;
@@ -537,7 +534,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);
@@ -565,7 +562,7 @@ 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_SIZE(&rhp->rh_long);
@@ -608,7 +605,7 @@ decnet_print(netdissect_options *ndo,
        return;
 
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
        return;
 }
 
@@ -621,9 +618,8 @@ print_decnet_ctlmsg(netdissect_options *ndo,
        u_int mflags = EXTRACT_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;
        u_int priority;
-       const char *rhpx = (const char *)rhp;
+       const u_char *rhpx = (const u_char *)rhp;
        int ret;
 
        switch (mflags & RMF_CTLMASK) {
@@ -693,9 +689,8 @@ print_decnet_ctlmsg(netdissect_options *ndo,
            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);
+           src =
+               EXTRACT_LE_U_2(cmp->cm_rhello.rh_src.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);
@@ -715,15 +710,13 @@ print_decnet_ctlmsg(netdissect_options *ndo,
            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);
+           src =
+               EXTRACT_LE_U_2(cmp->cm_ehello.eh_src.dne_remote.dne_nodeaddr);
            info = EXTRACT_U_1(cmp->cm_ehello.eh_info);
            blksize = EXTRACT_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);
+           dst =
+               EXTRACT_LE_U_2(cmp->cm_ehello.eh_router.dne_remote.dne_nodeaddr);
            hello = EXTRACT_LE_U_2(cmp->cm_ehello.eh_hello);
            other = EXTRACT_U_1(cmp->cm_ehello.eh_data);
            print_i_info(ndo, info);
@@ -764,7 +757,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;
@@ -795,7 +788,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;
@@ -844,7 +837,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);
@@ -1246,10 +1239,11 @@ 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");
-       snprintf(str, siz, "%u.%u", area, node);
+               (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC, "dnnum_string: malloc");
+       nd_snprintf(str, siz, "%u.%u", area, node);
        return(str);
 }