]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-decnet.c
Add program_name field in the netdissect_options structure
[tcpdump] / print-decnet.c
index f32b511e541e393605e1a3051a0ce5abd7baa46d..41d022fc42b2bc267ccc026d45b1a78cd8d246ed 100644 (file)
@@ -37,12 +37,12 @@ struct rtentry;
 #include <string.h>
 
 #include "extract.h"
-#include "interface.h"
+#include "netdissect.h"
 #include "addrtoname.h"
 
 static const char tstr[] = "[|decnet]";
 
-#ifndef WIN32
+#ifndef _WIN32
 typedef uint8_t byte[1];               /* single byte field */
 #else
 /*
@@ -50,7 +50,7 @@ typedef uint8_t byte[1];              /* single byte field */
  */
 typedef unsigned char Byte[1];         /* single byte field */
 #define byte Byte
-#endif /* WIN32 */
+#endif /* _WIN32 */
 typedef uint8_t word[2];               /* 2 byte field */
 typedef uint8_t longword[4];           /* 4 bytes field */
 
@@ -585,7 +585,7 @@ decnet_print(netdissect_options *ndo,
            break;
        default:
            ND_PRINT((ndo, "unknown message flags under mask"));
-           ND_DEFAULTPRINT((u_char *)ap, min(length, caplen));
+           ND_DEFAULTPRINT((const u_char *)ap, min(length, caplen));
            return;
        }
 
@@ -616,11 +616,11 @@ print_decnet_ctlmsg(netdissect_options *ndo,
                     u_int caplen)
 {
        int mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags);
-       register union controlmsg *cmp = (union controlmsg *)rhp;
+       register const union controlmsg *cmp = (const union controlmsg *)rhp;
        int src, dst, info, blksize, eco, ueco, hello, other, vers;
        etheraddr srcea, rtea;
        int priority;
-       char *rhpx = (char *)rhp;
+       const char *rhpx = (const char *)rhp;
        int ret;
 
        switch (mflags & RMF_CTLMASK) {
@@ -691,7 +691,7 @@ print_decnet_ctlmsg(netdissect_options *ndo,
            vers = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_vers);
            eco = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_eco);
            ueco = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_ueco);
-           memcpy((char *)&srcea, (char *)&(cmp->cm_rhello.rh_src),
+           memcpy((char *)&srcea, (const char *)&(cmp->cm_rhello.rh_src),
                sizeof(srcea));
            src = EXTRACT_LE_16BITS(srcea.dne_remote.dne_nodeaddr);
            info = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_info);
@@ -714,13 +714,13 @@ print_decnet_ctlmsg(netdissect_options *ndo,
            vers = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_vers);
            eco = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_eco);
            ueco = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_ueco);
-           memcpy((char *)&srcea, (char *)&(cmp->cm_ehello.eh_src),
+           memcpy((char *)&srcea, (const char *)&(cmp->cm_ehello.eh_src),
                sizeof(srcea));
            src = EXTRACT_LE_16BITS(srcea.dne_remote.dne_nodeaddr);
            info = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_info);
            blksize = EXTRACT_LE_16BITS(cmp->cm_ehello.eh_blksize);
            /*seed*/
-           memcpy((char *)&rtea, (char *)&(cmp->cm_ehello.eh_router),
+           memcpy((char *)&rtea, (const char *)&(cmp->cm_ehello.eh_router),
                sizeof(rtea));
            dst = EXTRACT_LE_16BITS(rtea.dne_remote.dne_nodeaddr);
            hello = EXTRACT_LE_16BITS(cmp->cm_ehello.eh_hello);
@@ -735,7 +735,7 @@ print_decnet_ctlmsg(netdissect_options *ndo,
 
        default:
            ND_PRINT((ndo, "unknown control message"));
-           ND_DEFAULTPRINT((u_char *)rhp, min(length, caplen));
+           ND_DEFAULTPRINT((const u_char *)rhp, min(length, caplen));
            ret = 1;
            break;
        }
@@ -854,7 +854,7 @@ static int
 print_nsp(netdissect_options *ndo,
           const u_char *nspp, u_int nsplen)
 {
-       const struct nsphdr *nsphp = (struct nsphdr *)nspp;
+       const struct nsphdr *nsphp = (const struct nsphdr *)nspp;
        int dst, src, flags;
 
        if (nsplen < sizeof(struct nsphdr))
@@ -873,10 +873,10 @@ print_nsp(netdissect_options *ndo,
            case MFS_BOM+MFS_EOM:
                ND_PRINT((ndo, "data %d>%d ", src, dst));
                {
-                   struct seghdr *shp = (struct seghdr *)nspp;
+                   const struct seghdr *shp = (const struct seghdr *)nspp;
                    int ack;
 #ifdef PRINT_NSPDATA
-                   u_char *dp;
+                   const u_char *dp;
 #endif
                    u_int data_off = sizeof(struct minseghdr);
 
@@ -919,10 +919,10 @@ print_nsp(netdissect_options *ndo,
            case MFS_ILS+MFS_INT:
                ND_PRINT((ndo, "intr "));
                {
-                   struct seghdr *shp = (struct seghdr *)nspp;
+                   const struct seghdr *shp = (const struct seghdr *)nspp;
                    int ack;
 #ifdef PRINT_NSPDATA
-                   u_char *dp;
+                   const u_char *dp;
 #endif
                    u_int data_off = sizeof(struct minseghdr);
 
@@ -965,9 +965,9 @@ print_nsp(netdissect_options *ndo,
            case MFS_ILS:
                ND_PRINT((ndo, "link-service %d>%d ", src, dst));
                {
-                   struct seghdr *shp = (struct seghdr *)nspp;
-                   struct lsmsg *lsmp =
-                       (struct lsmsg *)&(nspp[sizeof(struct seghdr)]);
+                   const struct seghdr *shp = (const struct seghdr *)nspp;
+                   const struct lsmsg *lsmp =
+                       (const struct lsmsg *)&(nspp[sizeof(struct seghdr)]);
                    int ack;
                    int lsflags, fcval;
 
@@ -1031,7 +1031,7 @@ print_nsp(netdissect_options *ndo,
            case MFS_DACK:
                ND_PRINT((ndo, "data-ack %d>%d ", src, dst));
                {
-                   struct ackmsg *amp = (struct ackmsg *)nspp;
+                   const struct ackmsg *amp = (const struct ackmsg *)nspp;
                    int ack;
 
                    if (nsplen < sizeof(struct ackmsg))
@@ -1056,7 +1056,7 @@ print_nsp(netdissect_options *ndo,
            case MFS_IACK:
                ND_PRINT((ndo, "ils-ack %d>%d ", src, dst));
                {
-                   struct ackmsg *amp = (struct ackmsg *)nspp;
+                   const struct ackmsg *amp = (const struct ackmsg *)nspp;
                    int ack;
 
                    if (nsplen < sizeof(struct ackmsg))
@@ -1097,10 +1097,10 @@ print_nsp(netdissect_options *ndo,
                    ND_PRINT((ndo, "retrans-conn-initiate "));
                ND_PRINT((ndo, "%d>%d ", src, dst));
                {
-                   struct cimsg *cimp = (struct cimsg *)nspp;
+                   const struct cimsg *cimp = (const struct cimsg *)nspp;
                    int services, info, segsize;
 #ifdef PRINT_NSPDATA
-                   u_char *dp;
+                   const u_char *dp;
 #endif
 
                    if (nsplen < sizeof(struct cimsg))
@@ -1150,11 +1150,11 @@ print_nsp(netdissect_options *ndo,
            case MFS_CC:
                ND_PRINT((ndo, "conn-confirm %d>%d ", src, dst));
                {
-                   struct ccmsg *ccmp = (struct ccmsg *)nspp;
+                   const struct ccmsg *ccmp = (const struct ccmsg *)nspp;
                    int services, info;
                    u_int segsize, optlen;
 #ifdef PRINT_NSPDATA
-                   u_char *dp;
+                   const u_char *dp;
 #endif
 
                    if (nsplen < sizeof(struct ccmsg))
@@ -1208,11 +1208,11 @@ print_nsp(netdissect_options *ndo,
            case MFS_DI:
                ND_PRINT((ndo, "disconn-initiate %d>%d ", src, dst));
                {
-                   struct dimsg *dimp = (struct dimsg *)nspp;
+                   const struct dimsg *dimp = (const struct dimsg *)nspp;
                    int reason;
                    u_int optlen;
 #ifdef PRINT_NSPDATA
-                   u_char *dp;
+                   const u_char *dp;
 #endif
 
                    if (nsplen < sizeof(struct dimsg))
@@ -1237,7 +1237,7 @@ print_nsp(netdissect_options *ndo,
            case MFS_DC:
                ND_PRINT((ndo, "disconn-confirm %d>%d ", src, dst));
                {
-                   struct dcmsg *dcmp = (struct dcmsg *)nspp;
+                   const struct dcmsg *dcmp = (const struct dcmsg *)nspp;
                    int reason;
 
                    ND_TCHECK(*dcmp);
@@ -1295,7 +1295,7 @@ print_reason(netdissect_options *ndo,
 }
 
 const char *
-dnnum_string(u_short dnaddr)
+dnnum_string(netdissect_options *ndo, u_short dnaddr)
 {
        char *str;
        size_t siz;
@@ -1304,13 +1304,13 @@ dnnum_string(u_short dnaddr)
 
        str = (char *)malloc(siz = sizeof("00.0000"));
        if (str == NULL)
-               error("dnnum_string: malloc");
+               (*ndo->ndo_error)(ndo, "dnnum_string: malloc");
        snprintf(str, siz, "%d.%d", area, node);
        return(str);
 }
 
 const char *
-dnname_string(u_short dnaddr)
+dnname_string(netdissect_options *ndo, u_short dnaddr)
 {
 #ifdef HAVE_DNET_HTOA
        struct dn_naddr dna;
@@ -1322,9 +1322,9 @@ dnname_string(u_short dnaddr)
        if(dnname != NULL)
                return (strdup(dnname));
        else
-               return(dnnum_string(dnaddr));
+               return(dnnum_string(ndo, dnaddr));
 #else
-       return(dnnum_string(dnaddr));   /* punt */
+       return(dnnum_string(ndo, dnaddr));      /* punt */
 #endif
 }