]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ipx.c
Default to first interface from pcap_findalldevs()
[tcpdump] / print-ipx.c
index 7404dd79c86f6bad5f370b32afac226e86d231c9..22e613e77e1253104a591072ba2e25a5a1900d75 100644 (file)
  * Contributed by Brad Parker ([email protected]).
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
 
 #include <stdio.h>
 
-#include "interface.h"
+#include "netdissect.h"
 #include "addrtoname.h"
 #include "extract.h"
 
 
 /* IPX transport header */
 struct ipxHdr {
-    u_int16_t  cksum;          /* Checksum */
-    u_int16_t  length;         /* Length, in bytes, including header */
-    u_int8_t   tCtl;           /* Transport Control (i.e. hop count) */
-    u_int8_t   pType;          /* Packet Type (i.e. level 2 protocol) */
-    u_int16_t  dstNet[2];      /* destination net */
-    u_int8_t   dstNode[6];     /* destination node */
-    u_int16_t  dstSkt;         /* destination socket */
-    u_int16_t  srcNet[2];      /* source net */
-    u_int8_t   srcNode[6];     /* source node */
-    u_int16_t  srcSkt;         /* source socket */
+    uint16_t   cksum;          /* Checksum */
+    uint16_t   length;         /* Length, in bytes, including header */
+    uint8_t    tCtl;           /* Transport Control (i.e. hop count) */
+    uint8_t    pType;          /* Packet Type (i.e. level 2 protocol) */
+    uint16_t   dstNet[2];      /* destination net */
+    uint8_t    dstNode[6];     /* destination node */
+    uint16_t   dstSkt;         /* destination socket */
+    uint16_t   srcNet[2];      /* source net */
+    uint8_t    srcNode[6];     /* source node */
+    uint16_t   srcSkt;         /* source socket */
 };
 
 #define ipxSize        30
 
-static const char *ipxaddr_string(u_int32_t, const u_char *);
+static const char *ipxaddr_string(uint32_t, const u_char *);
 static void ipx_decode(netdissect_options *, const struct ipxHdr *, const u_char *, u_int);
 static void ipx_sap_print(netdissect_options *, const u_short *, u_int);
 static void ipx_rip_print(netdissect_options *, const u_short *, u_int);
@@ -89,14 +88,14 @@ ipx_print(netdissect_options *ndo, const u_char *p, u_int length)
        ND_TCHECK(ipx->length);
        length = EXTRACT_16BITS(&ipx->length);
 
-       ipx_decode(ndo, ipx, (u_char *)ipx + ipxSize, length - ipxSize);
+       ipx_decode(ndo, ipx, p + ipxSize, length - ipxSize);
        return;
 trunc:
        ND_PRINT((ndo, "[|ipx %d]", length));
 }
 
 static const char *
-ipxaddr_string(u_int32_t net, const u_char *node)
+ipxaddr_string(uint32_t net, const u_char *node)
 {
     static char line[256];
 
@@ -117,15 +116,15 @@ ipx_decode(netdissect_options *ndo, const struct ipxHdr *ipx, const u_char *data
        ND_PRINT((ndo, "ipx-ncp %d", length));
        break;
       case IPX_SKT_SAP:
-       ipx_sap_print(ndo, (u_short *)datap, length);
+       ipx_sap_print(ndo, (const u_short *)datap, length);
        break;
       case IPX_SKT_RIP:
-       ipx_rip_print(ndo, (u_short *)datap, length);
+       ipx_rip_print(ndo, (const u_short *)datap, length);
        break;
       case IPX_SKT_NETBIOS:
        ND_PRINT((ndo, "ipx-netbios %d", length));
 #ifdef TCPDUMP_DO_SMB
-       ipx_netbios_print(datap, length);
+       ipx_netbios_print(ndo, datap, length);
 #endif
        break;
       case IPX_SKT_DIAGNOSTICS:
@@ -134,11 +133,11 @@ ipx_decode(netdissect_options *ndo, const struct ipxHdr *ipx, const u_char *data
       case IPX_SKT_NWLINK_DGM:
        ND_PRINT((ndo, "ipx-nwlink-dgm %d", length));
 #ifdef TCPDUMP_DO_SMB
-       ipx_netbios_print(datap, length);
+       ipx_netbios_print(ndo, datap, length);
 #endif
        break;
       case IPX_SKT_EIGRP:
-       eigrp_print(datap, length);
+       eigrp_print(ndo, datap, length);
        break;
       default:
        ND_PRINT((ndo, "ipx-#%x %d", dstSkt, length));
@@ -165,7 +164,7 @@ ipx_sap_print(netdissect_options *ndo, const u_short *ipx, u_int length)
            ND_PRINT((ndo, "ipx-sap-nearest-req"));
 
        ND_TCHECK(ipx[0]);
-       ND_PRINT((ndo, " %s", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0])))));
+       ND_PRINT((ndo, " %s", ipxsap_string(ndo, htons(EXTRACT_16BITS(&ipx[0])))));
        break;
 
       case 2:
@@ -177,14 +176,14 @@ ipx_sap_print(netdissect_options *ndo, const u_short *ipx, u_int length)
 
        for (i = 0; i < 8 && length > 0; i++) {
            ND_TCHECK(ipx[0]);
-           ND_PRINT((ndo, " %s '", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0])))));
-           if (fn_printzp((u_char *)&ipx[1], 48, ndo->ndo_snapend)) {
+           ND_PRINT((ndo, " %s '", ipxsap_string(ndo, htons(EXTRACT_16BITS(&ipx[0])))));
+           if (fn_printzp(ndo, (const u_char *)&ipx[1], 48, ndo->ndo_snapend)) {
                ND_PRINT((ndo, "'"));
                goto trunc;
            }
            ND_TCHECK2(ipx[25], 10);
            ND_PRINT((ndo, "' addr %s",
-               ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (u_char *)&ipx[27])));
+               ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (const u_char *)&ipx[27])));
            ipx += 32;
            length -= 64;
        }