]> The Tcpdump Group git mirrors - tcpdump/commitdiff
NDOize 8 more small decoders
authorDenis Ovsienko <[email protected]>
Thu, 13 Mar 2014 13:21:55 +0000 (17:21 +0400)
committerDenis Ovsienko <[email protected]>
Thu, 13 Mar 2014 13:21:55 +0000 (17:21 +0400)
This change converts ZeroMQ, IPX, MPLS, IPv6 options, PPPoE, RIPng,
PFLOG and Sun RPC decoders.

24 files changed:
interface.h
netdissect.h
print-arcnet.c
print-chdlc.c
print-ether.c
print-gre.c
print-ip6.c
print-ip6opts.c
print-ipx.c
print-juniper.c
print-llc.c
print-mpls.c
print-null.c
print-pflog.c
print-pgm.c
print-ppp.c
print-pppoe.c
print-ripng.c
print-sll.c
print-sunrpc.c
print-tcp.c
print-udp.c
print-zeromq.c
tcpdump.c

index 242fb3973cbac9fb1e4abe33806ac5f4181e9c9e..2103bc02853baa8ab1a7e010ac9d54cc2f525e2f 100644 (file)
@@ -193,7 +193,6 @@ extern void default_print(const u_char *, u_int);
 extern void dvmrp_print(const u_char *, u_int);
 extern void egp_print(const u_char *, u_int);
 extern u_int enc_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int pflog_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int token_print(const u_char *, u_int, u_int);
 extern u_int token_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void fddi_print(const u_char *, u_int, u_int);
@@ -210,7 +209,6 @@ extern u_int ieee802_11_radio_avs_if_print(const struct pcap_pkthdr *,
        const u_char *);
 extern void icmp_print(const u_char *, u_int, const u_char *, int);
 extern void igmp_print(const u_char *, u_int);
-extern void ipx_print(const u_char *, u_int);
 extern void isoclns_print(const u_char *, u_int, u_int);
 extern void krb_print(const u_char *);
 extern u_int llap_print(const u_char *, u_int);
@@ -237,12 +235,10 @@ extern void lwapp_control_print(const u_char *, u_int, int);
 extern void lwapp_data_print(const u_char *, u_int);
 extern void eigrp_print(const u_char *, u_int);
 extern void pim_print(const u_char *, u_int, u_int);
-extern u_int pppoe_print(const u_char *, u_int);
 extern u_int ppp_print(register const u_char *, u_int);
 extern u_int ppp_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int ppp_hdlc_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int ppp_bsdos_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int pppoe_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int prism_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void q933_print(const u_char *, u_int);
 extern void vqp_print(register const u_char *, register u_int);
@@ -266,7 +262,6 @@ extern u_int juniper_frelay_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int juniper_chdlc_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int sll_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void snmp_print(const u_char *, u_int);
-extern void sunrpcrequest_print(const u_char *, u_int, const u_char *);
 extern void tcp_print(const u_char *, u_int, const u_char *, int);
 extern void tftp_print(const u_char *, u_int);
 extern void timed_print(const u_char *);
@@ -298,22 +293,15 @@ extern void pptp_print(const u_char *);
 extern void dccp_print(const u_char *, const u_char *, u_int);
 extern void sctp_print(const u_char *, const u_char *, u_int);
 extern void forces_print(const u_char *, u_int);
-extern void mpls_print(const u_char *, u_int);
 extern void mpls_lsp_ping_print(const u_char *, u_int);
 extern void zephyr_print(const u_char *, int);
-extern void zmtp1_print(const u_char *, u_int);
-extern void zmtp1_print_datagram(const u_char *, const u_int);
 extern void sip_print(const u_char *, u_int);
 extern void syslog_print(const u_char *, u_int);
 extern int mptcp_print(const u_char *, u_int, u_char);
 
 
 #ifdef INET6
-extern void ip6_opt_print(const u_char *, int);
-extern int hbhopt_print(const u_char *);
-extern int dstopt_print(const u_char *);
 extern int mobility_print(const u_char *, const u_char *);
-extern void ripng_print(const u_char *, unsigned int);
 extern void ospf6_print(const u_char *, u_int);
 extern void dhcp6_print(const u_char *, u_int);
 extern void babel_print(const u_char *, u_int);
index d1c994daa23885c2841ccbc2137270dd4fb156ff..cd6c36180f486497135c233a061aa5f4c809aceb 100644 (file)
@@ -402,6 +402,14 @@ extern u_int usb_linux_64_byte_print(netdissect_options *, const struct pcap_pkt
 extern u_int symantec_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
 extern u_int chdlc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
 extern u_int chdlc_print(netdissect_options *, register const u_char *, u_int);
+extern void zmtp1_print(netdissect_options *, const u_char *, u_int);
+extern void zmtp1_print_datagram(netdissect_options *, const u_char *, const u_int);
+extern void ipx_print(netdissect_options *, const u_char *, u_int);
+extern void mpls_print(netdissect_options *, const u_char *, u_int);
+extern u_int pppoe_print(netdissect_options *, const u_char *, u_int);
+extern u_int pppoe_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void sunrpcrequest_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern u_int pflog_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
 
 /* stuff that has not yet been rototiled */
 extern const u_char * ns_nprint (register const u_char *, register const u_char *);
@@ -442,7 +450,6 @@ extern void igmp_print(netdissect_options *,
                       register const u_char *, u_int);
 extern void igrp_print(netdissect_options *,const u_char *, u_int,
                       const u_char *);
-extern void ipx_print(netdissect_options *,const u_char *, u_int);
 extern void isoclns_print(netdissect_options *,const u_char *,
                          u_int, u_int, const u_char *, const u_char *);
 extern void krb_print(netdissect_options *,const u_char *, u_int);
@@ -452,8 +459,6 @@ extern const char *linkaddr_string(netdissect_options *ndo,
 extern void ltalk_if_print(netdissect_options *ndo,
                           u_char *user, const struct pcap_pkthdr *h,
                           const u_char *p);
-extern void mpls_print(netdissect_options *ndo,
-                      const u_char *bp, u_int length);
 extern void msdp_print(netdissect_options *ndo,
                       const unsigned char *sp, u_int length);
 extern void nfsreply_print(netdissect_options *,const u_char *,
@@ -468,8 +473,6 @@ extern void ospf_print(netdissect_options *,const u_char *,
 extern void pimv1_print(netdissect_options *,const u_char *, u_int);
 extern void mobile_print(netdissect_options *,const u_char *, u_int);
 extern void pim_print(netdissect_options *,const u_char *, u_int, u_int);
-extern void pppoe_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-extern void pppoe_print(netdissect_options *,const u_char *, u_int);
 extern void ppp_print(netdissect_options *,
                      register const u_char *, u_int);
 
@@ -495,8 +498,6 @@ extern void sll_if_print(u_char *,
                         const struct pcap_pkthdr *, const u_char *);
 
 extern void snmp_print(netdissect_options *,const u_char *, u_int);
-extern void sunrpcrequest_print(netdissect_options *,const u_char *,
-                               u_int, const u_char *);
 extern void tcp_print(netdissect_options *,const u_char *, u_int,
                      const u_char *, int);
 extern void tftp_print(netdissect_options *,const u_char *, u_int);
@@ -541,13 +542,12 @@ extern u_int ieee802_15_4_if_print(netdissect_options *,const struct pcap_pkthdr
 extern void ip6_print(netdissect_options *,const u_char *, u_int);
 extern int frag6_print(netdissect_options *, const u_char *, const u_char *);
 extern int rt6_print(netdissect_options *, const u_char *, const u_char *);
+extern int hbhopt_print(netdissect_options *, const u_char *);
+extern int dstopt_print(netdissect_options *, const u_char *);
+extern void ripng_print(netdissect_options *, const u_char *, unsigned int);
 #if 0
-extern void ip6_opt_print(netdissect_options *,const u_char *, int);
-extern int hbhopt_print(netdissect_options *,const u_char *);
-extern int dstopt_print(netdissect_options *,const u_char *);
 extern void icmp6_print(netdissect_options *,const u_char *,
                        const u_char *);
-extern void ripng_print(netdissect_options *,const u_char *, int);
 extern void ospf6_print(netdissect_options *,const u_char *, u_int);
 extern void dhcp6_print(netdissect_options *,const u_char *,
                        u_int, u_int16_t, u_int16_t);
index 4f32dce465ba546dbbd465a245707e0ac11e2ede..846cf780008c2e5b4d16ea4c3afe2e8a34921dd0 100644 (file)
@@ -344,7 +344,7 @@ arcnet_encap_print(netdissect_options *ndo, u_char arctype, const u_char *p,
                return (1);
 
        case ARCTYPE_IPX:
-               ipx_print(p, length);
+               ipx_print(ndo, p, length);
                return (1);
 
        default:
index f84007478312b68ea0065c248b64ebaec6496484..aab55a5e4de6be41bf4491845b151ff9a8558232 100644 (file)
@@ -89,7 +89,7 @@ chdlc_print(netdissect_options *ndo, register const u_char *p, u_int length) {
 #endif
         case ETHERTYPE_MPLS:
         case ETHERTYPE_MPLS_MULTI:
-                mpls_print(p, length);
+                mpls_print(ndo, p, length);
                break;
         case ETHERTYPE_ISO:
                 /* is the fudge byte set ? lets verify by spotting ISO headers */
index 84ad77d85ac57d60b4525a9000ed3d8a7c75195c..b2ca0d13ae4d99b980aa4f87887e29da537ae9ef 100644 (file)
@@ -353,7 +353,7 @@ ethertype_print(netdissect_options *ndo,
 
        case ETHERTYPE_IPX:
                ND_PRINT((ndo, "(NOV-ETHII) "));
-               ipx_print(/*ndo,*/p, length);
+               ipx_print(ndo, p, length);
                return (1);
 
         case ETHERTYPE_ISO:
@@ -364,7 +364,7 @@ ethertype_print(netdissect_options *ndo,
        case ETHERTYPE_PPPOES:
        case ETHERTYPE_PPPOED2:
        case ETHERTYPE_PPPOES2:
-               pppoe_print(/*ndo,*/p, length);
+               pppoe_print(ndo, p, length);
                return (1);
 
        case ETHERTYPE_EAPOL:
@@ -405,7 +405,7 @@ ethertype_print(netdissect_options *ndo,
 
        case ETHERTYPE_MPLS:
        case ETHERTYPE_MPLS_MULTI:
-               mpls_print(/*ndo,*/p, length);
+               mpls_print(ndo, p, length);
                return (1);
 
        case ETHERTYPE_TIPC:
index b0eeb56e18506b1b77990b4a39d183878419698e..72edc2466b6ef52a93d03ae5642b712d4aaeb72c 100644 (file)
@@ -205,10 +205,10 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
                break;
 #endif
        case ETHERTYPE_MPLS:
-               mpls_print(bp, len);
+               mpls_print(ndo, bp, len);
                break;
        case ETHERTYPE_IPX:
-               ipx_print(bp, len);
+               ipx_print(ndo, bp, len);
                break;
        case ETHERTYPE_ATALK:
                atalk_print(bp, len);
index d3fe53a6d8fb291b5f2a24686a824ed982a8ecf1..946971a3ba0dea3805e733d78da517360e93dc1a 100644 (file)
@@ -153,11 +153,11 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
 
                switch (nh) {
                case IPPROTO_HOPOPTS:
-                       advance = hbhopt_print(cp);
+                       advance = hbhopt_print(ndo, cp);
                        nh = *cp;
                        break;
                case IPPROTO_DSTOPTS:
-                       advance = dstopt_print(cp);
+                       advance = dstopt_print(ndo, cp);
                        nh = *cp;
                        break;
                case IPPROTO_FRAGMENT:
index 784edcee4862f1db139af965acb6d10464b31b03..f0dd45036d44671ee3f48d516c8ada8c533f3630 100644 (file)
 #ifdef INET6
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
 #include "ip6.h"
 
-#include "interface.h"
+#include "netdissect.h"
 #include "addrtoname.h"
 #include "extract.h"
 
 static void
-ip6_sopt_print(const u_char *bp, int len)
+ip6_sopt_print(netdissect_options *ndo, const u_char *bp, int len)
 {
     int i;
     int optlen;
@@ -62,32 +60,32 @@ ip6_sopt_print(const u_char *bp, int len)
 
        switch (bp[i]) {
        case IP6OPT_PAD1:
-            printf(", pad1");
+            ND_PRINT((ndo, ", pad1"));
            break;
        case IP6OPT_PADN:
            if (len - i < IP6OPT_MINLEN) {
-               printf(", padn: trunc");
+               ND_PRINT((ndo, ", padn: trunc"));
                goto trunc;
            }
-            printf(", padn");
+            ND_PRINT((ndo, ", padn"));
            break;
        default:
            if (len - i < IP6OPT_MINLEN) {
-               printf(", sopt_type %d: trunc)", bp[i]);
+               ND_PRINT((ndo, ", sopt_type %d: trunc)", bp[i]));
                goto trunc;
            }
-           printf(", sopt_type 0x%02x: len=%d", bp[i], bp[i + 1]);
+           ND_PRINT((ndo, ", sopt_type 0x%02x: len=%d", bp[i], bp[i + 1]));
            break;
        }
     }
     return;
 
 trunc:
-    printf("[trunc] ");
+    ND_PRINT((ndo, "[trunc] "));
 }
 
-void
-ip6_opt_print(const u_char *bp, int len)
+static void
+ip6_opt_print(netdissect_options *ndo, const u_char *bp, int len)
 {
     int i;
     int optlen = 0;
@@ -108,81 +106,81 @@ ip6_opt_print(const u_char *bp, int len)
 
        switch (bp[i]) {
        case IP6OPT_PAD1:
-            printf("(pad1)");
+            ND_PRINT((ndo, "(pad1)"));
            break;
        case IP6OPT_PADN:
            if (len - i < IP6OPT_MINLEN) {
-               printf("(padn: trunc)");
+               ND_PRINT((ndo, "(padn: trunc)"));
                goto trunc;
            }
-            printf("(padn)");
+            ND_PRINT((ndo, "(padn)"));
            break;
        case IP6OPT_ROUTER_ALERT:
            if (len - i < IP6OPT_RTALERT_LEN) {
-               printf("(rtalert: trunc)");
+               ND_PRINT((ndo, "(rtalert: trunc)"));
                goto trunc;
            }
            if (bp[i + 1] != IP6OPT_RTALERT_LEN - 2) {
-               printf("(rtalert: invalid len %d)", bp[i + 1]);
+               ND_PRINT((ndo, "(rtalert: invalid len %d)", bp[i + 1]));
                goto trunc;
            }
-           printf("(rtalert: 0x%04x) ", EXTRACT_16BITS(&bp[i + 2]));
+           ND_PRINT((ndo, "(rtalert: 0x%04x) ", EXTRACT_16BITS(&bp[i + 2])));
            break;
        case IP6OPT_JUMBO:
            if (len - i < IP6OPT_JUMBO_LEN) {
-               printf("(jumbo: trunc)");
+               ND_PRINT((ndo, "(jumbo: trunc)"));
                goto trunc;
            }
            if (bp[i + 1] != IP6OPT_JUMBO_LEN - 2) {
-               printf("(jumbo: invalid len %d)", bp[i + 1]);
+               ND_PRINT((ndo, "(jumbo: invalid len %d)", bp[i + 1]));
                goto trunc;
            }
-           printf("(jumbo: %u) ", EXTRACT_32BITS(&bp[i + 2]));
+           ND_PRINT((ndo, "(jumbo: %u) ", EXTRACT_32BITS(&bp[i + 2])));
            break;
         case IP6OPT_HOME_ADDRESS:
            if (len - i < IP6OPT_HOMEADDR_MINLEN) {
-               printf("(homeaddr: trunc)");
+               ND_PRINT((ndo, "(homeaddr: trunc)"));
                goto trunc;
            }
            if (bp[i + 1] < IP6OPT_HOMEADDR_MINLEN - 2) {
-               printf("(homeaddr: invalid len %d)", bp[i + 1]);
+               ND_PRINT((ndo, "(homeaddr: invalid len %d)", bp[i + 1]));
                goto trunc;
            }
-           printf("(homeaddr: %s", ip6addr_string(&bp[i + 2]));
+           ND_PRINT((ndo, "(homeaddr: %s", ip6addr_string(&bp[i + 2])));
             if (bp[i + 1] > IP6OPT_HOMEADDR_MINLEN - 2) {
-               ip6_sopt_print(&bp[i + IP6OPT_HOMEADDR_MINLEN],
+               ip6_sopt_print(ndo, &bp[i + IP6OPT_HOMEADDR_MINLEN],
                    (optlen - IP6OPT_HOMEADDR_MINLEN));
            }
-            printf(")");
+            ND_PRINT((ndo, ")"));
            break;
        default:
            if (len - i < IP6OPT_MINLEN) {
-               printf("(type %d: trunc)", bp[i]);
+               ND_PRINT((ndo, "(type %d: trunc)", bp[i]));
                goto trunc;
            }
-           printf("(opt_type 0x%02x: len=%d)", bp[i], bp[i + 1]);
+           ND_PRINT((ndo, "(opt_type 0x%02x: len=%d)", bp[i], bp[i + 1]));
            break;
        }
     }
-    printf(" ");
+    ND_PRINT((ndo, " "));
     return;
 
 trunc:
-    printf("[trunc] ");
+    ND_PRINT((ndo, "[trunc] "));
 }
 
 int
-hbhopt_print(register const u_char *bp)
+hbhopt_print(netdissect_options *ndo, register const u_char *bp)
 {
     const struct ip6_hbh *dp = (struct ip6_hbh *)bp;
     int hbhlen = 0;
 
-    TCHECK(dp->ip6h_len);
+    ND_TCHECK(dp->ip6h_len);
     hbhlen = (int)((dp->ip6h_len + 1) << 3);
-    TCHECK2(*dp, hbhlen);
-    printf("HBH ");
-    if (vflag)
-       ip6_opt_print((const u_char *)dp + sizeof(*dp), hbhlen - sizeof(*dp));
+    ND_TCHECK2(*dp, hbhlen);
+    ND_PRINT((ndo, "HBH "));
+    if (ndo->ndo_vflag)
+       ip6_opt_print(ndo, (const u_char *)dp + sizeof(*dp), hbhlen - sizeof(*dp));
 
     return(hbhlen);
 
@@ -192,17 +190,17 @@ hbhopt_print(register const u_char *bp)
 }
 
 int
-dstopt_print(register const u_char *bp)
+dstopt_print(netdissect_options *ndo, register const u_char *bp)
 {
     const struct ip6_dest *dp = (struct ip6_dest *)bp;
     int dstoptlen = 0;
 
-    TCHECK(dp->ip6d_len);
+    ND_TCHECK(dp->ip6d_len);
     dstoptlen = (int)((dp->ip6d_len + 1) << 3);
-    TCHECK2(*dp, dstoptlen);
-    printf("DSTOPT ");
-    if (vflag) {
-       ip6_opt_print((const u_char *)dp + sizeof(*dp),
+    ND_TCHECK2(*dp, dstoptlen);
+    ND_PRINT((ndo, "DSTOPT "));
+    if (ndo->ndo_vflag) {
+       ip6_opt_print(ndo, (const u_char *)dp + sizeof(*dp),
            dstoptlen - sizeof(*dp));
     }
 
index e7102a5e5a7c5657c21310362a943db014c6a2ae..215ef20109f2168fc17db3f2465e2611ce307945 100644 (file)
@@ -28,9 +28,7 @@
 
 #include <tcpdump-stdinc.h>
 
-#include <stdlib.h>
 #include <stdio.h>
-#include <string.h>
 
 #include "interface.h"
 #include "addrtoname.h"
@@ -62,38 +60,38 @@ struct ipxHdr {
 #define ipxSize        30
 
 static const char *ipxaddr_string(u_int32_t, const u_char *);
-void ipx_decode(const struct ipxHdr *, const u_char *, u_int);
-void ipx_sap_print(const u_short *, u_int);
-void ipx_rip_print(const u_short *, u_int);
+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);
 
 /*
  * Print IPX datagram packets.
  */
 void
-ipx_print(const u_char *p, u_int length)
+ipx_print(netdissect_options *ndo, const u_char *p, u_int length)
 {
        const struct ipxHdr *ipx = (const struct ipxHdr *)p;
 
-       if (!eflag)
-               printf("IPX ");
+       if (!ndo->ndo_eflag)
+               ND_PRINT((ndo, "IPX "));
 
-       TCHECK(ipx->srcSkt);
-       (void)printf("%s.%04x > ",
+       ND_TCHECK(ipx->srcSkt);
+       ND_PRINT((ndo, "%s.%04x > ",
                     ipxaddr_string(EXTRACT_32BITS(ipx->srcNet), ipx->srcNode),
-                    EXTRACT_16BITS(&ipx->srcSkt));
+                    EXTRACT_16BITS(&ipx->srcSkt)));
 
-       (void)printf("%s.%04x: ",
+       ND_PRINT((ndo, "%s.%04x: ",
                     ipxaddr_string(EXTRACT_32BITS(ipx->dstNet), ipx->dstNode),
-                    EXTRACT_16BITS(&ipx->dstSkt));
+                    EXTRACT_16BITS(&ipx->dstSkt)));
 
        /* take length from ipx header */
-       TCHECK(ipx->length);
+       ND_TCHECK(ipx->length);
        length = EXTRACT_16BITS(&ipx->length);
 
-       ipx_decode(ipx, (u_char *)ipx + ipxSize, length - ipxSize);
+       ipx_decode(ndo, ipx, (u_char *)ipx + ipxSize, length - ipxSize);
        return;
 trunc:
-       printf("[|ipx %d]", length);
+       ND_PRINT((ndo, "[|ipx %d]", length));
 }
 
 static const char *
@@ -107,33 +105,33 @@ ipxaddr_string(u_int32_t net, const u_char *node)
     return line;
 }
 
-void
-ipx_decode(const struct ipxHdr *ipx, const u_char *datap, u_int length)
+static void
+ipx_decode(netdissect_options *ndo, const struct ipxHdr *ipx, const u_char *datap, u_int length)
 {
     register u_short dstSkt;
 
     dstSkt = EXTRACT_16BITS(&ipx->dstSkt);
     switch (dstSkt) {
       case IPX_SKT_NCP:
-       (void)printf("ipx-ncp %d", length);
+       ND_PRINT((ndo, "ipx-ncp %d", length));
        break;
       case IPX_SKT_SAP:
-       ipx_sap_print((u_short *)datap, length);
+       ipx_sap_print(ndo, (u_short *)datap, length);
        break;
       case IPX_SKT_RIP:
-       ipx_rip_print((u_short *)datap, length);
+       ipx_rip_print(ndo, (u_short *)datap, length);
        break;
       case IPX_SKT_NETBIOS:
-       (void)printf("ipx-netbios %d", length);
+       ND_PRINT((ndo, "ipx-netbios %d", length));
 #ifdef TCPDUMP_DO_SMB
        ipx_netbios_print(datap, length);
 #endif
        break;
       case IPX_SKT_DIAGNOSTICS:
-       (void)printf("ipx-diags %d", length);
+       ND_PRINT((ndo, "ipx-diags %d", length));
        break;
       case IPX_SKT_NWLINK_DGM:
-       (void)printf("ipx-nwlink-dgm %d", length);
+       ND_PRINT((ndo, "ipx-nwlink-dgm %d", length));
 #ifdef TCPDUMP_DO_SMB
        ipx_netbios_print(datap, length);
 #endif
@@ -142,17 +140,17 @@ ipx_decode(const struct ipxHdr *ipx, const u_char *datap, u_int length)
        eigrp_print(datap, length);
        break;
       default:
-       (void)printf("ipx-#%x %d", dstSkt, length);
+       ND_PRINT((ndo, "ipx-#%x %d", dstSkt, length));
        break;
     }
 }
 
-void
-ipx_sap_print(const u_short *ipx, u_int length)
+static void
+ipx_sap_print(netdissect_options *ndo, const u_short *ipx, u_int length)
 {
     int command, i;
 
-    TCHECK(ipx[0]);
+    ND_TCHECK(ipx[0]);
     command = EXTRACT_16BITS(ipx);
     ipx++;
     length -= 2;
@@ -161,79 +159,79 @@ ipx_sap_print(const u_short *ipx, u_int length)
       case 1:
       case 3:
        if (command == 1)
-           (void)printf("ipx-sap-req");
+           ND_PRINT((ndo, "ipx-sap-req"));
        else
-           (void)printf("ipx-sap-nearest-req");
+           ND_PRINT((ndo, "ipx-sap-nearest-req"));
 
-       TCHECK(ipx[0]);
-       (void)printf(" %s", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0]))));
+       ND_TCHECK(ipx[0]);
+       ND_PRINT((ndo, " %s", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0])))));
        break;
 
       case 2:
       case 4:
        if (command == 2)
-           (void)printf("ipx-sap-resp");
+           ND_PRINT((ndo, "ipx-sap-resp"));
        else
-           (void)printf("ipx-sap-nearest-resp");
+           ND_PRINT((ndo, "ipx-sap-nearest-resp"));
 
        for (i = 0; i < 8 && length > 0; i++) {
-           TCHECK(ipx[0]);
-           (void)printf(" %s '", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0]))));
-           if (fn_printzp((u_char *)&ipx[1], 48, snapend)) {
-               printf("'");
+           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, "'"));
                goto trunc;
            }
-           TCHECK2(ipx[25], 10);
-           printf("' addr %s",
-               ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (u_char *)&ipx[27]));
+           ND_TCHECK2(ipx[25], 10);
+           ND_PRINT((ndo, "' addr %s",
+               ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (u_char *)&ipx[27])));
            ipx += 32;
            length -= 64;
        }
        break;
       default:
-       (void)printf("ipx-sap-?%x", command);
+       ND_PRINT((ndo, "ipx-sap-?%x", command));
        break;
     }
     return;
 trunc:
-    printf("[|ipx %d]", length);
+    ND_PRINT((ndo, "[|ipx %d]", length));
 }
 
-void
-ipx_rip_print(const u_short *ipx, u_int length)
+static void
+ipx_rip_print(netdissect_options *ndo, const u_short *ipx, u_int length)
 {
     int command, i;
 
-    TCHECK(ipx[0]);
+    ND_TCHECK(ipx[0]);
     command = EXTRACT_16BITS(ipx);
     ipx++;
     length -= 2;
 
     switch (command) {
       case 1:
-       (void)printf("ipx-rip-req");
+       ND_PRINT((ndo, "ipx-rip-req"));
        if (length > 0) {
-           TCHECK(ipx[3]);
-           (void)printf(" %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
-                        EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3]));
+           ND_TCHECK(ipx[3]);
+           ND_PRINT((ndo, " %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
+                        EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3])));
        }
        break;
       case 2:
-       (void)printf("ipx-rip-resp");
+       ND_PRINT((ndo, "ipx-rip-resp"));
        for (i = 0; i < 50 && length > 0; i++) {
-           TCHECK(ipx[3]);
-           (void)printf(" %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
-                        EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3]));
+           ND_TCHECK(ipx[3]);
+           ND_PRINT((ndo, " %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
+                        EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3])));
 
            ipx += 4;
            length -= 8;
        }
        break;
       default:
-       (void)printf("ipx-rip-?%x", command);
+       ND_PRINT((ndo, "ipx-rip-?%x", command));
        break;
     }
     return;
 trunc:
-    printf("[|ipx %d]", length);
+    ND_PRINT((ndo, "[|ipx %d]", length));
 }
index c375e7f715fd4032df1e6572d847414f980df35f..ce515d7d8e9dda5a128ad102fabf64d5e4bf8cdb 100644 (file)
@@ -780,7 +780,7 @@ juniper_mlppp_print(const struct pcap_pkthdr *h, register const u_char *p)
             return l2info.header_len;
 #endif
         case JUNIPER_LSQ_L3_PROTO_MPLS:
-            mpls_print(p,l2info.length);
+            mpls_print(gndo, p, l2info.length);
             return l2info.header_len;
         case JUNIPER_LSQ_L3_PROTO_ISO:
             isoclns_print(p,l2info.length,l2info.caplen);
@@ -835,7 +835,7 @@ juniper_mfr_print(const struct pcap_pkthdr *h, register const u_char *p)
                 return l2info.header_len;
 #endif
             case JUNIPER_LSQ_L3_PROTO_MPLS:
-                mpls_print(p,l2info.length);
+                mpls_print(gndo, p, l2info.length);
                 return l2info.header_len;
             case JUNIPER_LSQ_L3_PROTO_ISO:
                 isoclns_print(p,l2info.length,l2info.caplen);
index b9c99632658e39c2f6b42f5a70facb1caa8faefc..c5bda71e87058b83f33c691807703b0837ce42f9 100644 (file)
@@ -211,7 +211,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
             if (eflag)
                printf("IPX 802.3: ");
 
-            ipx_print(p, length);
+            ipx_print(gndo, p, length);
             return (1);
        }
 
@@ -258,7 +258,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
                 if (eflag)
                         printf("IPX 802.2: ");
 
-               ipx_print(p+3, length-3);
+               ipx_print(gndo, p+3, length-3);
                return (1);
        }
 
index 8862e4b0e97ec7a540ef517d76f292643ce24403..cd323ce26c44667170ad02fcdaaf8a60bd0d78fc 100644 (file)
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
 #include "interface.h"
 #include "extract.h"                   /* must come after interface.h */
 #include "mpls.h"
@@ -59,7 +55,7 @@ enum mpls_packet_type {
  * RFC3032: MPLS label stack encoding
  */
 void
-mpls_print(const u_char *bp, u_int length)
+mpls_print(netdissect_options *ndo, const u_char *bp, u_int length)
 {
        const u_char *p;
        u_int32_t label_entry;
@@ -67,21 +63,21 @@ mpls_print(const u_char *bp, u_int length)
        enum mpls_packet_type pt = PT_UNKNOWN;
 
        p = bp;
-       printf("MPLS");
+       ND_PRINT((ndo, "MPLS"));
        do {
-               TCHECK2(*p, sizeof(label_entry));
+               ND_TCHECK2(*p, sizeof(label_entry));
                label_entry = EXTRACT_32BITS(p);
-               printf("%s(label %u",
-                      (label_stack_depth && vflag) ? "\n\t" : " ",
-                              MPLS_LABEL(label_entry));
+               ND_PRINT((ndo, "%s(label %u",
+                      (label_stack_depth && ndo->ndo_vflag) ? "\n\t" : " ",
+                              MPLS_LABEL(label_entry)));
                label_stack_depth++;
-               if (vflag &&
+               if (ndo->ndo_vflag &&
                    MPLS_LABEL(label_entry) < sizeof(mpls_labelname) / sizeof(mpls_labelname[0]))
-                       printf(" (%s)", mpls_labelname[MPLS_LABEL(label_entry)]);
-               printf(", exp %u", MPLS_EXP(label_entry));
+                       ND_PRINT((ndo, " (%s)", mpls_labelname[MPLS_LABEL(label_entry)]));
+               ND_PRINT((ndo, ", exp %u", MPLS_EXP(label_entry)));
                if (MPLS_STACK(label_entry))
-                       printf(", [S]");
-               printf(", ttl %u)", MPLS_TTL(label_entry));
+                       ND_PRINT((ndo, ", [S]"));
+               ND_PRINT((ndo, ", ttl %u)", MPLS_TTL(label_entry)));
 
                p += sizeof(label_entry);
        } while (!MPLS_STACK(label_entry));
@@ -177,25 +173,22 @@ mpls_print(const u_char *bp, u_int length)
         * Print the payload.
         */
        if (pt == PT_UNKNOWN) {
-               if (!suppress_default_print)
-                       default_print(p, length - (p - bp));
+               if (!ndo->ndo_suppress_default_print)
+                       ndo->ndo_default_print(ndo, p, length - (p - bp));
                return;
        }
-       if (vflag)
-               printf("\n\t");
-       else
-               printf(" ");
+       ND_PRINT((ndo, ndo->ndo_vflag ? "\n\t" : " "));
        switch (pt) {
 
        case PT_IPV4:
-               ip_print(gndo, p, length - (p - bp));
+               ip_print(ndo, p, length - (p - bp));
                break;
 
        case PT_IPV6:
 #ifdef INET6
-               ip6_print(gndo, p, length - (p - bp));
+               ip6_print(ndo, p, length - (p - bp));
 #else
-               printf("IPv6, length: %u", length);
+               ND_PRINT((ndo, "IPv6, length: %u", length));
 #endif
                break;
 
@@ -209,7 +202,7 @@ mpls_print(const u_char *bp, u_int length)
        return;
 
 trunc:
-       printf("[|MPLS]");
+       ND_PRINT((ndo, "[|MPLS]"));
 }
 
 
index be9d65f9e737559c1bb3a1e9203f1c49d0c52a35..16330b9431dd82e0f7b173b4cffbc2da3770b69c 100644 (file)
@@ -125,7 +125,7 @@ null_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
                break;
 
        case BSD_AFNUM_IPX:
-               ipx_print(p, length);
+               ipx_print(ndo, p, length);
                break;
 
        default:
index 547f0738f8ae4f737eac4a4812277cd5c37e8de8..eb88784c9359d7c895aba3e78cd12c7209440b6f 100644 (file)
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
+#include "netdissect.h"
 #include "extract.h"
-#include "interface.h"
 
 static const char tstr[] = "[|pflog]";
 
@@ -86,26 +84,27 @@ static const struct tok pf_directions[] = {
 #define        OPENBSD_AF_INET6        24
 
 static void
-pflog_print(const struct pfloghdr *hdr)
+pflog_print(netdissect_options *ndo, const struct pfloghdr *hdr)
 {
        u_int32_t rulenr, subrulenr;
 
        rulenr = EXTRACT_32BITS(&hdr->rulenr);
        subrulenr = EXTRACT_32BITS(&hdr->subrulenr);
        if (subrulenr == (u_int32_t)-1)
-               printf("rule %u/", rulenr);
+               ND_PRINT((ndo, "rule %u/", rulenr));
        else
-               printf("rule %u.%s.%u/", rulenr, hdr->ruleset, subrulenr);
+               ND_PRINT((ndo, "rule %u.%s.%u/", rulenr, hdr->ruleset, subrulenr));
 
-       printf("%s: %s %s on %s: ",
+       ND_PRINT((ndo, "%s: %s %s on %s: ",
            tok2str(pf_reasons, "unkn(%u)", hdr->reason),
            tok2str(pf_actions, "unkn(%u)", hdr->action),
            tok2str(pf_directions, "unkn(%u)", hdr->dir),
-           hdr->ifname);
+           hdr->ifname));
 }
 
 u_int
-pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+pflog_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
+               register const u_char *p)
 {
        u_int length = h->len;
        u_int hdrlen;
@@ -115,28 +114,28 @@ pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
 
        /* check length */
        if (caplen < sizeof(u_int8_t)) {
-               printf("%s", tstr);
+               ND_PRINT((ndo, "%s", tstr));
                return (caplen);
        }
 
 #define MIN_PFLOG_HDRLEN       45
        hdr = (struct pfloghdr *)p;
        if (hdr->length < MIN_PFLOG_HDRLEN) {
-               printf("[pflog: invalid header length!]");
+               ND_PRINT((ndo, "[pflog: invalid header length!]"));
                return (hdr->length);   /* XXX: not really */
        }
        hdrlen = BPF_WORDALIGN(hdr->length);
 
        if (caplen < hdrlen) {
-               printf("%s", tstr);
+               ND_PRINT((ndo, "%s", tstr));
                return (hdrlen);        /* XXX: true? */
        }
 
        /* print what we know */
        hdr = (struct pfloghdr *)p;
-       TCHECK(*hdr);
-       if (eflag)
-               pflog_print(hdr);
+       ND_TCHECK(*hdr);
+       if (ndo->ndo_eflag)
+               pflog_print(ndo, hdr);
 
        /* skip to the real packet */
        af = hdr->af;
@@ -149,7 +148,7 @@ pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
 #if OPENBSD_AF_INET != AF_INET
                case OPENBSD_AF_INET:           /* XXX: read pcap files */
 #endif
-                       ip_print(gndo, p, length);
+                       ip_print(ndo, p, length);
                        break;
 
 #ifdef INET6
@@ -157,21 +156,21 @@ pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
 #if OPENBSD_AF_INET6 != AF_INET6
                case OPENBSD_AF_INET6:          /* XXX: read pcap files */
 #endif
-                       ip6_print(gndo, p, length);
+                       ip6_print(ndo, p, length);
                        break;
 #endif
 
        default:
                /* address family not handled, print raw packet */
-               if (!eflag)
-                       pflog_print(hdr);
-               if (!suppress_default_print)
-                       default_print(p, caplen);
+               if (!ndo->ndo_eflag)
+                       pflog_print(ndo, hdr);
+               if (!ndo->ndo_suppress_default_print)
+                       ndo->ndo_default_print(ndo, p, caplen);
        }
 
        return (hdrlen);
 trunc:
-       printf("%s", tstr);
+       ND_PRINT((ndo, "%s", tstr));
        return (hdrlen);
 }
 
index b1bc77ff8004164713552a17c7d60b9f69e291e4..20de180f9e600eaef9280f6b50fd14e3c6c15dfa 100644 (file)
@@ -815,7 +815,7 @@ pgm_print(register const u_char *bp, register u_int length,
        (void)printf(" [%u]", length);
        if (packettype == PT_PGM_ZMTP1 &&
            (pgm->pgm_type == PGM_ODATA || pgm->pgm_type == PGM_RDATA))
-               zmtp1_print_datagram(bp, EXTRACT_16BITS(&pgm->pgm_length));
+               zmtp1_print_datagram(gndo, bp, EXTRACT_16BITS(&pgm->pgm_length));
 
        return;
 
index 47cb959d0b423a21954bce9b9a47fd9face26cb7..55ca4df357e1c23626fea235af627aba91130f37 100644 (file)
@@ -1471,14 +1471,14 @@ handle_ppp(u_int proto, const u_char *p, int length)
 #endif
        case ETHERTYPE_IPX:     /*XXX*/
        case PPP_IPX:
-               ipx_print(p, length);
+               ipx_print(gndo, p, length);
                break;
        case PPP_OSI:
                isoclns_print(p, length, length);
                break;
        case PPP_MPLS_UCAST:
        case PPP_MPLS_MCAST:
-               mpls_print(p, length);
+               mpls_print(gndo, p, length);
                break;
        case PPP_COMP:
                printf("compressed PPP data");
@@ -1781,7 +1781,7 @@ ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_
 #endif
                        case PPP_MPLS_UCAST:
                        case PPP_MPLS_MCAST:
-                               mpls_print(p, length);
+                               mpls_print(gndo, p, length);
                                break;
                        }
                        goto printx;
@@ -1800,7 +1800,7 @@ ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_
 #endif
                        case PPP_MPLS_UCAST:
                        case PPP_MPLS_MCAST:
-                               mpls_print(p, length);
+                               mpls_print(gndo, p, length);
                                break;
                        }
                        goto printx;
index 8cb894112e219b44567c0a9b815c38baace62804..109f3f48fb44b466ac40ae0c3970e96c2363b7ef 100644 (file)
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
 #include "interface.h"
-#include "ppp.h"
-#include "ethertype.h"
-#include "ether.h"
 #include "extract.h"                   /* must come after interface.h */
 
 /* Codes */
@@ -89,13 +83,13 @@ static const struct tok pppoetag2str[] = {
 #define MAXTAGPRINT 80
 
 u_int
-pppoe_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+pppoe_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
 {
-       return (pppoe_print(p, h->len));
+       return (pppoe_print(ndo, p, h->len));
 }
 
 u_int
-pppoe_print(register const u_char *bp, u_int length)
+pppoe_print(netdissect_options *ndo, register const u_char *bp, u_int length)
 {
        u_int16_t pppoe_ver, pppoe_type, pppoe_code, pppoe_sessionid;
        u_int pppoe_length;
@@ -107,7 +101,7 @@ pppoe_print(register const u_char *bp, u_int length)
        }
        length -= PPPOE_HDRLEN;
        pppoe_packet = bp;
-       TCHECK2(*pppoe_packet, PPPOE_HDRLEN);
+       ND_TCHECK2(*pppoe_packet, PPPOE_HDRLEN);
        pppoe_ver  = (pppoe_packet[0] & 0xF0) >> 4;
        pppoe_type  = (pppoe_packet[0] & 0x0F);
        pppoe_code = pppoe_packet[1];
@@ -116,22 +110,22 @@ pppoe_print(register const u_char *bp, u_int length)
        pppoe_payload = pppoe_packet + PPPOE_HDRLEN;
 
        if (pppoe_ver != 1) {
-               printf(" [ver %d]",pppoe_ver);
+               ND_PRINT((ndo, " [ver %d]",pppoe_ver));
        }
        if (pppoe_type != 1) {
-               printf(" [type %d]",pppoe_type);
+               ND_PRINT((ndo, " [type %d]",pppoe_type));
        }
 
-       printf("PPPoE %s", tok2str(pppoecode2str, "PAD-%x", pppoe_code));
+       ND_PRINT((ndo, "PPPoE %s", tok2str(pppoecode2str, "PAD-%x", pppoe_code)));
        if (pppoe_code == PPPOE_PADI && pppoe_length > 1484 - PPPOE_HDRLEN) {
-               printf(" [len %u!]",pppoe_length);
+               ND_PRINT((ndo, " [len %u!]",pppoe_length));
        }
        if (pppoe_length > length) {
-               printf(" [len %u > %u!]", pppoe_length, length);
+               ND_PRINT((ndo, " [len %u > %u!]", pppoe_length, length));
                pppoe_length = length;
        }
        if (pppoe_sessionid) {
-               printf(" [ses 0x%x]", pppoe_sessionid);
+               ND_PRINT((ndo, " [ses 0x%x]", pppoe_sessionid));
        }
 
        if (pppoe_code) {
@@ -145,7 +139,7 @@ pppoe_print(register const u_char *bp, u_int length)
                 * tag_type is previous tag or 0xffff for first iteration
                 */
                while (tag_type && p < pppoe_payload + pppoe_length) {
-                       TCHECK2(*p, 4);
+                       ND_TCHECK2(*p, 4);
                        tag_type = EXTRACT_16BITS(p);
                        tag_len = EXTRACT_16BITS(p + 2);
                        p += 4;
@@ -158,7 +152,7 @@ pppoe_print(register const u_char *bp, u_int length)
                                unsigned tag_str_len = 0;
 
                                /* TODO print UTF-8 decoded text */
-                               TCHECK2(*p, tag_len);
+                               ND_TCHECK2(*p, tag_len);
                                for (v = p; v < p + tag_len && tag_str_len < MAXTAGPRINT-1; v++)
                                        if (*v >= 32 && *v < 127) {
                                                tag_str[tag_str_len++] = *v;
@@ -170,24 +164,24 @@ pppoe_print(register const u_char *bp, u_int length)
                                tag_str[tag_str_len] = 0;
 
                                if (isascii > isgarbage) {
-                                       printf(" [%s \"%*.*s\"]",
+                                       ND_PRINT((ndo, " [%s \"%*.*s\"]",
                                               tok2str(pppoetag2str, "TAG-0x%x", tag_type),
                                               (int)tag_str_len,
                                               (int)tag_str_len,
-                                              tag_str);
+                                              tag_str));
                                } else {
                                        /* Print hex, not fast to abuse printf but this doesn't get used much */
-                                       printf(" [%s 0x", tok2str(pppoetag2str, "TAG-0x%x", tag_type));
+                                       ND_PRINT((ndo, " [%s 0x", tok2str(pppoetag2str, "TAG-0x%x", tag_type)));
                                        for (v=p; v<p+tag_len; v++) {
-                                               printf("%02X", *v);
+                                               ND_PRINT((ndo, "%02X", *v));
                                        }
-                                       printf("]");
+                                       ND_PRINT((ndo, "]"));
                                }
 
 
                        } else
-                               printf(" [%s]", tok2str(pppoetag2str,
-                                   "TAG-0x%x", tag_type));
+                               ND_PRINT((ndo, " [%s]", tok2str(pppoetag2str,
+                                   "TAG-0x%x", tag_type)));
 
                        p += tag_len;
                        /* p points to next tag */
@@ -195,11 +189,11 @@ pppoe_print(register const u_char *bp, u_int length)
                return (0);
        } else {
                /* PPPoE data */
-               printf(" ");
+               ND_PRINT((ndo, " "));
                return (PPPOE_HDRLEN + ppp_print(pppoe_payload, pppoe_length));
        }
 
 trunc:
-       printf("[|pppoe]");
+       ND_PRINT((ndo, "[|pppoe]"));
        return (PPPOE_HDRLEN);
 }
index b50b0814be860068c4cf3102e5bef91911fc3dc6..6bd47e67a3d13559cb79e1a96d8c885c7470a45f 100644 (file)
@@ -26,9 +26,8 @@
 #ifdef INET6
 
 #include <tcpdump-stdinc.h>
-#include <stdio.h>
 
-#include "interface.h"
+#include "netdissect.h"
 #include "addrtoname.h"
 #include "extract.h"
 
@@ -86,8 +85,6 @@ struct        rip6 {
 
 #define        HOPCNT_INFINITY6        16
 
-#define        RIP6_PORT               521
-
 #if !defined(IN6_IS_ADDR_UNSPECIFIED) && !defined(_MSC_VER) /* MSVC inline */
 static int IN6_IS_ADDR_UNSPECIFIED(const struct in6_addr *addr)
 {
@@ -97,19 +94,19 @@ static int IN6_IS_ADDR_UNSPECIFIED(const struct in6_addr *addr)
 #endif
 
 static int
-rip6_entry_print(register const struct netinfo6 *ni, int metric)
+rip6_entry_print(netdissect_options *ndo, register const struct netinfo6 *ni, int metric)
 {
        int l;
-       l = printf("%s/%d", ip6addr_string(&ni->rip6_dest), ni->rip6_plen);
+       l = ND_PRINT((ndo, "%s/%d", ip6addr_string(&ni->rip6_dest), ni->rip6_plen));
        if (ni->rip6_tag)
-               l += printf(" [%d]", EXTRACT_16BITS(&ni->rip6_tag));
+               l += ND_PRINT((ndo, " [%d]", EXTRACT_16BITS(&ni->rip6_tag)));
        if (metric)
-               l += printf(" (%d)", ni->rip6_metric);
+               l += ND_PRINT((ndo, " (%d)", ni->rip6_metric));
        return l;
 }
 
 void
-ripng_print(const u_char *dat, unsigned int length)
+ripng_print(netdissect_options *ndo, const u_char *dat, unsigned int length)
 {
        register const struct rip6 *rp = (struct rip6 *)dat;
        register const struct netinfo6 *ni;
@@ -118,9 +115,9 @@ ripng_print(const u_char *dat, unsigned int length)
        int j;
        int trunc;
 
-       if (snapend < dat)
+       if (ndo->ndo_snapend < dat)
                return;
-       amt = snapend - dat;
+       amt = ndo->ndo_snapend - dat;
        i = min(length, amt);
        if (i < (sizeof(struct rip6) - sizeof(struct netinfo6)))
                return;
@@ -133,46 +130,46 @@ ripng_print(const u_char *dat, unsigned int length)
                if (j == 1
                    &&  rp->rip6_nets->rip6_metric == HOPCNT_INFINITY6
                    &&  IN6_IS_ADDR_UNSPECIFIED(&rp->rip6_nets->rip6_dest)) {
-                       printf(" ripng-req dump");
+                       ND_PRINT((ndo, " ripng-req dump"));
                        break;
                }
                if (j * sizeof(*ni) != length - 4)
-                       printf(" ripng-req %d[%u]:", j, length);
+                       ND_PRINT((ndo, " ripng-req %d[%u]:", j, length));
                else
-                       printf(" ripng-req %d:", j);
+                       ND_PRINT((ndo, " ripng-req %d:", j));
                trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
                for (ni = rp->rip6_nets; i >= sizeof(*ni);
                    i -= sizeof(*ni), ++ni) {
-                       if (vflag > 1)
-                               printf("\n\t");
+                       if (ndo->ndo_vflag > 1)
+                               ND_PRINT((ndo, "\n\t"));
                        else
-                               printf(" ");
-                       rip6_entry_print(ni, 0);
+                               ND_PRINT((ndo, " "));
+                       rip6_entry_print(ndo, ni, 0);
                }
                break;
        case RIP6_RESPONSE:
                j = length / sizeof(*ni);
                if (j * sizeof(*ni) != length - 4)
-                       printf(" ripng-resp %d[%u]:", j, length);
+                       ND_PRINT((ndo, " ripng-resp %d[%u]:", j, length));
                else
-                       printf(" ripng-resp %d:", j);
+                       ND_PRINT((ndo, " ripng-resp %d:", j));
                trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
                for (ni = rp->rip6_nets; i >= sizeof(*ni);
                    i -= sizeof(*ni), ++ni) {
-                       if (vflag > 1)
-                               printf("\n\t");
+                       if (ndo->ndo_vflag > 1)
+                               ND_PRINT((ndo, "\n\t"));
                        else
-                               printf(" ");
-                       rip6_entry_print(ni, ni->rip6_metric);
+                               ND_PRINT((ndo, " "));
+                       rip6_entry_print(ndo, ni, ni->rip6_metric);
                }
                if (trunc)
-                       printf("[|ripng]");
+                       ND_PRINT((ndo, "[|ripng]"));
                break;
        default:
-               printf(" ripng-%d ?? %u", rp->rip6_cmd, length);
+               ND_PRINT((ndo, " ripng-%d ?? %u", rp->rip6_cmd, length));
                break;
        }
        if (rp->rip6_vers != RIP6_VERSION)
-               printf(" [vers %d]", rp->rip6_vers);
+               ND_PRINT((ndo, " [vers %d]", rp->rip6_vers));
 }
 #endif /* INET6 */
index c1e42c20e65e897d04adc236259cbffe297ad5ad..9818e2eec097c184b50e5395a77791e26ce0b3d3 100644 (file)
@@ -241,7 +241,7 @@ recurse:
                        /*
                         * Ethernet_802.3 IPX frame.
                         */
-                       ipx_print(p, length);
+                       ipx_print(gndo, p, length);
                        break;
 
                case LINUX_SLL_P_802_2:
index 16a524b5308b331481779f8df4b1155cf0f6fb53..2589dfd708a0a615ce4c40be6553a033a95e871a 100644 (file)
@@ -50,7 +50,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "interface.h"
+#include "netdissect.h"
 #include "addrtoname.h"
 #include "extract.h"
 
@@ -165,8 +165,8 @@ static const struct tok proc2str[] = {
 static char *progstr(u_int32_t);
 
 void
-sunrpcrequest_print(register const u_char *bp, register u_int length,
-                   register const u_char *bp2)
+sunrpcrequest_print(netdissect_options *ndo, register const u_char *bp,
+                    register u_int length, register const u_char *bp2)
 {
        register const struct sunrpc_msg *rp;
        register const struct ip *ip;
@@ -178,7 +178,7 @@ sunrpcrequest_print(register const u_char *bp, register u_int length,
 
        rp = (struct sunrpc_msg *)bp;
 
-       if (!nflag) {
+       if (!ndo->ndo_nflag) {
                snprintf(srcid, sizeof(srcid), "0x%x",
                    EXTRACT_32BITS(&rp->rm_xid));
                strlcpy(dstid, "sunrpc", sizeof(dstid));
@@ -191,28 +191,28 @@ sunrpcrequest_print(register const u_char *bp, register u_int length,
        switch (IP_V((struct ip *)bp2)) {
        case 4:
                ip = (struct ip *)bp2;
-               printf("%s.%s > %s.%s: %d",
+               ND_PRINT((ndo, "%s.%s > %s.%s: %d",
                    ipaddr_string(&ip->ip_src), srcid,
-                   ipaddr_string(&ip->ip_dst), dstid, length);
+                   ipaddr_string(&ip->ip_dst), dstid, length));
                break;
 #ifdef INET6
        case 6:
                ip6 = (struct ip6_hdr *)bp2;
-               printf("%s.%s > %s.%s: %d",
+               ND_PRINT((ndo, "%s.%s > %s.%s: %d",
                    ip6addr_string(&ip6->ip6_src), srcid,
-                   ip6addr_string(&ip6->ip6_dst), dstid, length);
+                   ip6addr_string(&ip6->ip6_dst), dstid, length));
                break;
 #endif
        default:
-               printf("%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length);
+               ND_PRINT((ndo, "%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length));
                break;
        }
 
-       printf(" %s", tok2str(proc2str, " proc #%u",
-           EXTRACT_32BITS(&rp->rm_call.cb_proc)));
+       ND_PRINT((ndo, " %s", tok2str(proc2str, " proc #%u",
+           EXTRACT_32BITS(&rp->rm_call.cb_proc))));
        x = EXTRACT_32BITS(&rp->rm_call.cb_rpcvers);
        if (x != 2)
-               printf(" [rpcver %u]", x);
+               ND_PRINT((ndo, " [rpcver %u]", x));
 
        switch (EXTRACT_32BITS(&rp->rm_call.cb_proc)) {
 
@@ -221,11 +221,11 @@ sunrpcrequest_print(register const u_char *bp, register u_int length,
        case SUNRPC_PMAPPROC_GETPORT:
        case SUNRPC_PMAPPROC_CALLIT:
                x = EXTRACT_32BITS(&rp->rm_call.cb_prog);
-               if (!nflag)
-                       printf(" %s", progstr(x));
+               if (!ndo->ndo_nflag)
+                       ND_PRINT((ndo, " %s", progstr(x)));
                else
-                       printf(" %u", x);
-               printf(".%u", EXTRACT_32BITS(&rp->rm_call.cb_vers));
+                       ND_PRINT((ndo, " %u", x));
+               ND_PRINT((ndo, ".%u", EXTRACT_32BITS(&rp->rm_call.cb_vers)));
                break;
        }
 }
index 7eb13b376ba3c4fb8d5e57a3eca5d8a2ac54a739..27620d6604174be2577d7cbe56ecc0338c98fd39 100644 (file)
@@ -663,7 +663,7 @@ tcp_print(register const u_char *bp, register u_int length,
         if (packettype) {
                 switch (packettype) {
                 case PT_ZMTP1:
-                        zmtp1_print(bp, length);
+                        zmtp1_print(gndo, bp, length);
                         break;
                 }
                 return;
index f52de0356cd394041444f63fca449fca68a54763..0951a2becf3c29489bbad5ad3ca419862df29f04 100644 (file)
@@ -422,7 +422,7 @@ udp_print(register const u_char *bp, u_int length,
                        rp = (struct sunrpc_msg *)(up + 1);
                        direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
                        if (direction == SUNRPC_CALL)
-                               sunrpcrequest_print((u_char *)rp, length,
+                               sunrpcrequest_print(gndo, (u_char *)rp, length,
                                    (u_char *)ip);
                        else
                                nfsreply_print((u_char *)rp, length,
@@ -623,7 +623,7 @@ udp_print(register const u_char *bp, u_int length,
                                 (u_char *) ip);
 #ifdef INET6
                else if (ISPORT(RIPNG_PORT))
-                       ripng_print((const u_char *)(up + 1), length);
+                       ripng_print(gndo, (const u_char *)(up + 1), length);
                else if (ISPORT(DHCP6_SERV_PORT) || ISPORT(DHCP6_CLI_PORT))
                        dhcp6_print((const u_char *)(up + 1), length);
                else if (ISPORT(AHCP_PORT))
index 93650b31a05733550375876153e4751a9c11fdb9..b2cf6db4c3136ec2cdc9ac725e7161d2b21aaa32 100644 (file)
@@ -34,9 +34,7 @@
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-
-#include "interface.h"
+#include "netdissect.h"
 #include "extract.h"
 
 static const char tstr[] = " [|zmtp1]";
@@ -77,42 +75,42 @@ static const char tstr[] = " [|zmtp1]";
  */
 
 static const u_char *
-zmtp1_print_frame(const u_char *cp, const u_char *ep) {
+zmtp1_print_frame(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
        u_int64_t body_len_declared, body_len_captured, header_len;
        u_int8_t flags;
 
-       printf("\n\t");
-       TCHECK2(*cp, 1); /* length/0xFF */
+       ND_PRINT((ndo, "\n\t"));
+       ND_TCHECK2(*cp, 1); /* length/0xFF */
 
        if (cp[0] != 0xFF) {
                header_len = 1; /* length */
                body_len_declared = cp[0];
                if (body_len_declared == 0)
                        return cp + header_len; /* skip to next frame */
-               printf(" frame flags+body  (8-bit) length %u", cp[0]);
-               TCHECK2(*cp, header_len + 1); /* length, flags */
+               ND_PRINT((ndo, " frame flags+body  (8-bit) length %u", cp[0]));
+               ND_TCHECK2(*cp, header_len + 1); /* length, flags */
                flags = cp[1];
        } else {
                header_len = 1 + 8; /* 0xFF, length */
-               printf(" frame flags+body (64-bit) length");
-               TCHECK2(*cp, header_len); /* 0xFF, length */
+               ND_PRINT((ndo, " frame flags+body (64-bit) length"));
+               ND_TCHECK2(*cp, header_len); /* 0xFF, length */
                body_len_declared = EXTRACT_64BITS(cp + 1);
                if (body_len_declared == 0)
                        return cp + header_len; /* skip to next frame */
-               printf(" %" PRIu64, body_len_declared);
-               TCHECK2(*cp, header_len + 1); /* 0xFF, length, flags */
+               ND_PRINT((ndo, " %" PRIu64, body_len_declared));
+               ND_TCHECK2(*cp, header_len + 1); /* 0xFF, length, flags */
                flags = cp[9];
        }
 
        body_len_captured = ep - cp - header_len;
        if (body_len_declared > body_len_captured)
-               printf(" (%" PRIu64 " captured)", body_len_captured);
-       printf(", flags 0x%02x", flags);
+               ND_PRINT((ndo, " (%" PRIu64 " captured)", body_len_captured));
+       ND_PRINT((ndo, ", flags 0x%02x", flags));
 
-       if (vflag) {
+       if (ndo->ndo_vflag) {
                u_int64_t body_len_printed = MIN(body_len_captured, body_len_declared);
 
-               printf(" (%s|%s|%s|%s|%s|%s|%s|%s)",
+               ND_PRINT((ndo, " (%s|%s|%s|%s|%s|%s|%s|%s)",
                        flags & 0x80 ? "MBZ" : "-",
                        flags & 0x40 ? "MBZ" : "-",
                        flags & 0x20 ? "MBZ" : "-",
@@ -120,32 +118,32 @@ zmtp1_print_frame(const u_char *cp, const u_char *ep) {
                        flags & 0x08 ? "MBZ" : "-",
                        flags & 0x04 ? "MBZ" : "-",
                        flags & 0x02 ? "MBZ" : "-",
-                       flags & 0x01 ? "MORE" : "-");
+                       flags & 0x01 ? "MORE" : "-"));
 
-               if (vflag == 1)
+               if (ndo->ndo_vflag == 1)
                        body_len_printed = MIN(VBYTES + 1, body_len_printed);
                if (body_len_printed > 1) {
-                       printf(", first %" PRIu64 " byte(s) of body:", body_len_printed - 1);
-                       hex_and_ascii_print(gndo, "\n\t ", cp + header_len + 1, body_len_printed - 1);
-                       printf("\n");
+                       ND_PRINT((ndo, ", first %" PRIu64 " byte(s) of body:", body_len_printed - 1));
+                       hex_and_ascii_print(ndo, "\n\t ", cp + header_len + 1, body_len_printed - 1);
+                       ND_PRINT((ndo, "\n"));
                }
        }
 
-       TCHECK2(*cp, header_len + body_len_declared); /* Next frame within the buffer ? */
+       ND_TCHECK2(*cp, header_len + body_len_declared); /* Next frame within the buffer ? */
        return cp + header_len + body_len_declared;
 
 trunc:
-       printf("%s", tstr);
+       ND_PRINT((ndo, "%s", tstr));
        return ep;
 }
 
 void
-zmtp1_print(const u_char *cp, u_int len) {
-       const u_char *ep = MIN(snapend, cp + len);
+zmtp1_print(netdissect_options *ndo, const u_char *cp, u_int len) {
+       const u_char *ep = MIN(ndo->ndo_snapend, cp + len);
 
-       printf(": ZMTP/1.0");
+       ND_PRINT((ndo, ": ZMTP/1.0"));
        while (cp < ep)
-               cp = zmtp1_print_frame(cp, ep);
+               cp = zmtp1_print_frame(ndo, cp, ep);
 }
 
 /* The functions below decode a ZeroMQ datagram, supposedly stored in the "Data"
@@ -165,52 +163,52 @@ zmtp1_print(const u_char *cp, u_int len) {
  */
 
 static const u_char *
-zmtp1_print_intermediate_part(const u_char *cp, const u_int len) {
+zmtp1_print_intermediate_part(netdissect_options *ndo, const u_char *cp, const u_int len) {
        u_int frame_offset;
        u_int64_t remaining_len;
 
-       TCHECK2(*cp, 2);
+       ND_TCHECK2(*cp, 2);
        frame_offset = EXTRACT_16BITS(cp);
-       printf("\n\t frame offset 0x%04x", frame_offset);
+       ND_PRINT((ndo, "\n\t frame offset 0x%04x", frame_offset));
        cp += 2;
-       remaining_len = snapend - cp; /* without the frame length */
+       remaining_len = ndo->ndo_snapend - cp; /* without the frame length */
 
        if (frame_offset == 0xFFFF)
                frame_offset = len - 2; /* always within the declared length */
        else if (2 + frame_offset > len) {
-               printf(" (exceeds datagram declared length)");
+               ND_PRINT((ndo, " (exceeds datagram declared length)"));
                goto trunc;
        }
 
        /* offset within declared length of the datagram */
        if (frame_offset) {
-               printf("\n\t frame intermediate part, %u bytes", frame_offset);
+               ND_PRINT((ndo, "\n\t frame intermediate part, %u bytes", frame_offset));
                if (frame_offset > remaining_len)
-                       printf(" (%"PRIu64" captured)", remaining_len);
-               if (vflag) {
+                       ND_PRINT((ndo, " (%"PRIu64" captured)", remaining_len));
+               if (ndo->ndo_vflag) {
                        u_int64_t len_printed = MIN(frame_offset, remaining_len);
 
-                       if (vflag == 1)
+                       if (ndo->ndo_vflag == 1)
                                len_printed = MIN(VBYTES, len_printed);
                        if (len_printed > 1) {
-                               printf(", first %"PRIu64" byte(s):", len_printed);
-                               hex_and_ascii_print(gndo, "\n\t ", cp, len_printed);
-                               printf("\n");
+                               ND_PRINT((ndo, ", first %"PRIu64" byte(s):", len_printed));
+                               hex_and_ascii_print(ndo, "\n\t ", cp, len_printed);
+                               ND_PRINT((ndo, "\n"));
                        }
                }
        }
        return cp + frame_offset;
 
 trunc:
-       printf("%s", tstr);
+       ND_PRINT((ndo, "%s", tstr));
        return cp + len;
 }
 
 void
-zmtp1_print_datagram(const u_char *cp, const u_int len) {
-       const u_char *ep = MIN(snapend, cp + len);
+zmtp1_print_datagram(netdissect_options *ndo, const u_char *cp, const u_int len) {
+       const u_char *ep = MIN(ndo->ndo_snapend, cp + len);
 
-       cp = zmtp1_print_intermediate_part(cp, len);
+       cp = zmtp1_print_intermediate_part(ndo, cp, len);
        while (cp < ep)
-               cp = zmtp1_print_frame(cp, ep);
+               cp = zmtp1_print_frame(ndo, cp, ep);
 }
index 1acb2952e21769b1f521810b9b3f412415d3ca2e..fab11fe5ad2e23c03f3feb8dd78b340c3c494023 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -184,9 +184,6 @@ static const struct printer printers[] = {
 #ifdef DLT_PPP_SERIAL
        { ppp_hdlc_if_print,    DLT_PPP_SERIAL },
 #endif
-#ifdef DLT_PPP_ETHER
-       { pppoe_if_print,       DLT_PPP_ETHER },
-#endif
 #ifdef DLT_LINUX_SLL
        { sll_if_print,         DLT_LINUX_SLL },
 #endif
@@ -196,9 +193,6 @@ static const struct printer printers[] = {
 #ifdef DLT_LTALK
        { ltalk_if_print,       DLT_LTALK },
 #endif
-#if defined(DLT_PFLOG) && defined(HAVE_NET_PFVAR_H)
-       { pflog_if_print,       DLT_PFLOG },
-#endif
 #ifdef DLT_FR
        { fr_if_print,          DLT_FR },
 #endif
@@ -343,6 +337,12 @@ static const struct ndo_printer ndo_printers[] = {
 #endif
 #ifdef DLT_HDLC
        { chdlc_if_print,       DLT_HDLC },
+#endif
+#ifdef DLT_PPP_ETHER
+       { pppoe_if_print,       DLT_PPP_ETHER },
+#endif
+#if defined(DLT_PFLOG) && defined(HAVE_NET_PFVAR_H)
+       { pflog_if_print,       DLT_PFLOG },
 #endif
        { NULL,                 0 },
 };