]> The Tcpdump Group git mirrors - tcpdump/commitdiff
NDOize FDDI, MPCP, Token Ring, VQP and Zephyr decoders
authorDenis Ovsienko <[email protected]>
Fri, 14 Mar 2014 12:10:54 +0000 (16:10 +0400)
committerDenis Ovsienko <[email protected]>
Fri, 14 Mar 2014 12:10:54 +0000 (16:10 +0400)
interface.h
netdissect.h
print-ether.c
print-fddi.c
print-llc.c
print-mpcp.c
print-token.c
print-udp.c
print-vqp.c
print-zephyr.c
tcpdump.c

index 757e13815e7287a7aef074f7b3f1d3d538e55408..5a46b5cc873e3abea9a3ebe4b3453b7f6f9e628b 100644 (file)
@@ -182,10 +182,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 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 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);
-extern u_int fddi_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int fr_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int mfr_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int fr_print(register const u_char *, u_int);
 extern u_int fr_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int mfr_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int fr_print(register const u_char *, u_int);
@@ -230,7 +226,6 @@ 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 prism_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void q933_print(const u_char *, u_int);
 extern u_int ppp_bsdos_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);
 extern void rip_print(const u_char *, u_int);
 extern u_int sl_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int sl_bsdos_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void rip_print(const u_char *, u_int);
 extern u_int sl_if_print(const struct pcap_pkthdr *, const u_char *);
 extern u_int sl_bsdos_if_print(const struct pcap_pkthdr *, const u_char *);
@@ -271,7 +266,6 @@ extern void l2tp_print(const u_char *, u_int);
 extern void vrrp_print(const u_char *, u_int, const u_char *, int);
 extern void slow_print(const u_char *, u_int);
 extern void sflow_print(const u_char *, u_int);
 extern void vrrp_print(const u_char *, u_int, const u_char *, int);
 extern void slow_print(const u_char *, u_int);
 extern void sflow_print(const u_char *, u_int);
-extern void mpcp_print(const u_char *, u_int);
 extern void cfm_print(const u_char *, u_int);
 extern void pgm_print(const u_char *, u_int, const u_char *);
 extern void cdp_print(const u_char *, u_int, u_int);
 extern void cfm_print(const u_char *, u_int);
 extern void pgm_print(const u_char *, u_int, const u_char *);
 extern void cdp_print(const u_char *, u_int, u_int);
@@ -283,7 +277,6 @@ 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_lsp_ping_print(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_lsp_ping_print(const u_char *, u_int);
-extern void zephyr_print(const u_char *, 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);
 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);
index cd6c36180f486497135c233a061aa5f4c809aceb..50780f2df04d0ef24e375f50b7bd6a79ab54324d 100644 (file)
@@ -410,6 +410,13 @@ 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 *);
 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 *);
+extern u_int token_print(netdissect_options *, const u_char *, u_int, u_int);
+extern u_int token_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void vqp_print(netdissect_options *, register const u_char *, register u_int);
+extern void zephyr_print(netdissect_options *, const u_char *, int);
+extern void fddi_print(netdissect_options *, const u_char *, u_int, u_int);
+extern u_int fddi_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void mpcp_print(netdissect_options *, const u_char *, u_int);
 
 /* stuff that has not yet been rototiled */
 extern const u_char * ns_nprint (register const u_char *, register const u_char *);
 
 /* stuff that has not yet been rototiled */
 extern const u_char * ns_nprint (register const u_char *, register const u_char *);
@@ -438,9 +445,6 @@ extern void dvmrp_print(netdissect_options *,const u_char *, u_int);
 extern void egp_print(netdissect_options *,const u_char *, u_int,
                      const u_char *);
 
 extern void egp_print(netdissect_options *,const u_char *, u_int,
                      const u_char *);
 
-extern void token_if_print(u_char *,const struct pcap_pkthdr *,const u_char *);
-extern void fddi_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-
 extern void icmp_print(netdissect_options *,const u_char *, u_int,
                       const u_char *);
 extern void hsrp_print(netdissect_options *ndo,
 extern void icmp_print(netdissect_options *,const u_char *, u_int,
                       const u_char *);
 extern void hsrp_print(netdissect_options *ndo,
@@ -552,8 +556,6 @@ 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);
 
 extern void dhcp6_print(netdissect_options *,const u_char *,
                        u_int, u_int16_t, u_int16_t);
 
-extern void zephyr_print(netdissect_options * ndo,
-                        const u_char *cp, int length);
 #endif /* 0 */
 
 #endif /*INET6*/
 #endif /* 0 */
 
 #endif /*INET6*/
index b2ca0d13ae4d99b980aa4f87887e29da537ae9ef..a092c47e0632bc9350caf9bf8f8acf72d0b62fa7 100644 (file)
@@ -383,7 +383,7 @@ ethertype_print(netdissect_options *ndo,
                return (1);
 
        case ETHERTYPE_MPCP:
                return (1);
 
        case ETHERTYPE_MPCP:
-               mpcp_print(/*ndo,*/p, length);
+               mpcp_print(ndo, p, length);
                return (1);
 
        case ETHERTYPE_SLOW:
                return (1);
 
        case ETHERTYPE_SLOW:
index 3a99657a787d4cb19e6c1303c143a2aea6a926b3..0d740089c7c8db7586829150963e3016a41346cf 100644 (file)
 
 #include <tcpdump-stdinc.h>
 
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
 #include <string.h>
 
 #include "interface.h"
 #include "addrtoname.h"
 #include <string.h>
 
 #include "interface.h"
 #include "addrtoname.h"
-#include "ethertype.h"
-
 #include "ether.h"
 
 /*
 #include "ether.h"
 
 /*
@@ -160,67 +157,67 @@ static const u_char fddi_bit_swap[] = {
  * Print FDDI frame-control bits
  */
 static inline void
  * Print FDDI frame-control bits
  */
 static inline void
-print_fddi_fc(u_char fc)
+print_fddi_fc(netdissect_options *ndo, u_char fc)
 {
        switch (fc) {
 
        case FDDIFC_VOID:                         /* Void frame */
 {
        switch (fc) {
 
        case FDDIFC_VOID:                         /* Void frame */
-               printf("void ");
+               ND_PRINT((ndo, "void "));
                break;
 
        case FDDIFC_NRT:                          /* Nonrestricted token */
                break;
 
        case FDDIFC_NRT:                          /* Nonrestricted token */
-               printf("nrt ");
+               ND_PRINT((ndo, "nrt "));
                break;
 
        case FDDIFC_RT:                           /* Restricted token */
                break;
 
        case FDDIFC_RT:                           /* Restricted token */
-               printf("rt ");
+               ND_PRINT((ndo, "rt "));
                break;
 
        case FDDIFC_SMT_INFO:                     /* SMT Info */
                break;
 
        case FDDIFC_SMT_INFO:                     /* SMT Info */
-               printf("info ");
+               ND_PRINT((ndo, "info "));
                break;
 
        case FDDIFC_SMT_NSA:                      /* SMT Next station adrs */
                break;
 
        case FDDIFC_SMT_NSA:                      /* SMT Next station adrs */
-               printf("nsa ");
+               ND_PRINT((ndo, "nsa "));
                break;
 
        case FDDIFC_MAC_BEACON:                   /* MAC Beacon frame */
                break;
 
        case FDDIFC_MAC_BEACON:                   /* MAC Beacon frame */
-               printf("beacon ");
+               ND_PRINT((ndo, "beacon "));
                break;
 
        case FDDIFC_MAC_CLAIM:                    /* MAC Claim frame */
                break;
 
        case FDDIFC_MAC_CLAIM:                    /* MAC Claim frame */
-               printf("claim ");
+               ND_PRINT((ndo, "claim "));
                break;
 
        default:
                switch (fc & FDDIFC_CLFF) {
 
                case FDDIFC_MAC:
                break;
 
        default:
                switch (fc & FDDIFC_CLFF) {
 
                case FDDIFC_MAC:
-                       printf("mac%1x ", fc & FDDIFC_ZZZZ);
+                       ND_PRINT((ndo, "mac%1x ", fc & FDDIFC_ZZZZ));
                        break;
 
                case FDDIFC_SMT:
                        break;
 
                case FDDIFC_SMT:
-                       printf("smt%1x ", fc & FDDIFC_ZZZZ);
+                       ND_PRINT((ndo, "smt%1x ", fc & FDDIFC_ZZZZ));
                        break;
 
                case FDDIFC_LLC_ASYNC:
                        break;
 
                case FDDIFC_LLC_ASYNC:
-                       printf("async%1x ", fc & FDDIFC_ZZZZ);
+                       ND_PRINT((ndo, "async%1x ", fc & FDDIFC_ZZZZ));
                        break;
 
                case FDDIFC_LLC_SYNC:
                        break;
 
                case FDDIFC_LLC_SYNC:
-                       printf("sync%1x ", fc & FDDIFC_ZZZZ);
+                       ND_PRINT((ndo, "sync%1x ", fc & FDDIFC_ZZZZ));
                        break;
 
                case FDDIFC_IMP_ASYNC:
                        break;
 
                case FDDIFC_IMP_ASYNC:
-                       printf("imp_async%1x ", fc & FDDIFC_ZZZZ);
+                       ND_PRINT((ndo, "imp_async%1x ", fc & FDDIFC_ZZZZ));
                        break;
 
                case FDDIFC_IMP_SYNC:
                        break;
 
                case FDDIFC_IMP_SYNC:
-                       printf("imp_sync%1x ", fc & FDDIFC_ZZZZ);
+                       ND_PRINT((ndo, "imp_sync%1x ", fc & FDDIFC_ZZZZ));
                        break;
 
                default:
                        break;
 
                default:
-                       printf("%02x ", fc);
+                       ND_PRINT((ndo, "%02x ", fc));
                        break;
                }
        }
                        break;
                }
        }
@@ -252,42 +249,43 @@ extract_fddi_addrs(const struct fddi_header *fddip, char *fsrc, char *fdst)
  * Print the FDDI MAC header
  */
 static inline void
  * Print the FDDI MAC header
  */
 static inline void
-fddi_hdr_print(register const struct fddi_header *fddip, register u_int length,
-          register const u_char *fsrc, register const u_char *fdst)
+fddi_hdr_print(netdissect_options *ndo,
+               register const struct fddi_header *fddip, register u_int length,
+               register const u_char *fsrc, register const u_char *fdst)
 {
        const char *srcname, *dstname;
 
        srcname = etheraddr_string(fsrc);
        dstname = etheraddr_string(fdst);
 
 {
        const char *srcname, *dstname;
 
        srcname = etheraddr_string(fsrc);
        dstname = etheraddr_string(fdst);
 
-       if (vflag)
-               (void) printf("%02x %s %s %d: ",
+       if (ndo->ndo_vflag)
+               ND_PRINT((ndo, "%02x %s %s %d: ",
                       fddip->fddi_fc,
                       srcname, dstname,
                       fddip->fddi_fc,
                       srcname, dstname,
-                      length);
-       else if (qflag)
-               printf("%s %s %d: ", srcname, dstname, length);
+                      length));
+       else if (ndo->ndo_qflag)
+               ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
        else {
        else {
-               (void) print_fddi_fc(fddip->fddi_fc);
-               (void) printf("%s %s %d: ", srcname, dstname, length);
+               print_fddi_fc(ndo, fddip->fddi_fc);
+               ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
        }
 }
 
 static inline void
        }
 }
 
 static inline void
-fddi_smt_print(const u_char *p _U_, u_int length _U_)
+fddi_smt_print(netdissect_options *ndo, const u_char *p _U_, u_int length _U_)
 {
 {
-       printf("<SMT printer not yet implemented>");
+       ND_PRINT((ndo, "<SMT printer not yet implemented>"));
 }
 
 void
 }
 
 void
-fddi_print(const u_char *p, u_int length, u_int caplen)
+fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
 {
        const struct fddi_header *fddip = (const struct fddi_header *)p;
        struct ether_header ehdr;
        u_short extracted_ethertype;
 
        if (caplen < FDDI_HDRLEN) {
 {
        const struct fddi_header *fddip = (const struct fddi_header *)p;
        struct ether_header ehdr;
        u_short extracted_ethertype;
 
        if (caplen < FDDI_HDRLEN) {
-               printf("[|fddi]");
+               ND_PRINT((ndo, "[|fddi]"));
                return;
        }
 
                return;
        }
 
@@ -296,8 +294,8 @@ fddi_print(const u_char *p, u_int length, u_int caplen)
         */
        extract_fddi_addrs(fddip, (char *)ESRC(&ehdr), (char *)EDST(&ehdr));
 
         */
        extract_fddi_addrs(fddip, (char *)ESRC(&ehdr), (char *)EDST(&ehdr));
 
-       if (eflag)
-               fddi_hdr_print(fddip, length, ESRC(&ehdr), EDST(&ehdr));
+       if (ndo->ndo_eflag)
+               fddi_hdr_print(ndo, fddip, length, ESRC(&ehdr), EDST(&ehdr));
 
        /* Skip over FDDI MAC header */
        length -= FDDI_HDRLEN;
 
        /* Skip over FDDI MAC header */
        length -= FDDI_HDRLEN;
@@ -313,25 +311,25 @@ fddi_print(const u_char *p, u_int length, u_int caplen)
                         * Some kinds of LLC packet we cannot
                         * handle intelligently
                         */
                         * Some kinds of LLC packet we cannot
                         * handle intelligently
                         */
-                       if (!eflag)
-                               fddi_hdr_print(fddip, length + FDDI_HDRLEN,
+                       if (!ndo->ndo_eflag)
+                               fddi_hdr_print(ndo, fddip, length + FDDI_HDRLEN,
                                    ESRC(&ehdr), EDST(&ehdr));
                        if (extracted_ethertype) {
                                    ESRC(&ehdr), EDST(&ehdr));
                        if (extracted_ethertype) {
-                               printf("(LLC %s) ",
-                       etherproto_string(htons(extracted_ethertype)));
+                               ND_PRINT((ndo, "(LLC %s) ",
+                       etherproto_string(htons(extracted_ethertype))));
                        }
                        }
-                       if (!suppress_default_print)
-                               default_print(p, caplen);
+                       if (!ndo->ndo_suppress_default_print)
+                               ndo->ndo_default_print(ndo, p, caplen);
                }
        } else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT)
                }
        } else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT)
-               fddi_smt_print(p, caplen);
+               fddi_smt_print(ndo, p, caplen);
        else {
                /* Some kinds of FDDI packet we cannot handle intelligently */
        else {
                /* Some kinds of FDDI packet we cannot handle intelligently */
-               if (!eflag)
-                       fddi_hdr_print(fddip, length + FDDI_HDRLEN, ESRC(&ehdr),
+               if (!ndo->ndo_eflag)
+                       fddi_hdr_print(ndo, fddip, length + FDDI_HDRLEN, ESRC(&ehdr),
                            EDST(&ehdr));
                            EDST(&ehdr));
-               if (!suppress_default_print)
-                       default_print(p, caplen);
+               if (!ndo->ndo_suppress_default_print)
+                       ndo->ndo_default_print(ndo, p, caplen);
        }
 }
 
        }
 }
 
@@ -342,9 +340,9 @@ fddi_print(const u_char *p, u_int length, u_int caplen)
  * is the number of bytes actually captured.
  */
 u_int
  * is the number of bytes actually captured.
  */
 u_int
-fddi_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+fddi_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
 {
 {
-       fddi_print(p, h->len, h->caplen);
+       fddi_print(ndo, p, h->len, h->caplen);
 
        return (FDDI_HDRLEN);
 }
 
        return (FDDI_HDRLEN);
 }
index c5bda71e87058b83f33c691807703b0837ce42f9..9a1f9dcfd7d7ace8bf3c563bb66c0adb388592f6 100644 (file)
@@ -488,7 +488,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
                         * What remains is an 802.5 Token Ring
                         * packet.
                         */
                         * What remains is an 802.5 Token Ring
                         * packet.
                         */
-                       token_print(p, length, caplen);
+                       token_print(gndo, p, length, caplen);
                        return (1);
 
                case PID_RFC2684_FDDI_FCS:
                        return (1);
 
                case PID_RFC2684_FDDI_FCS:
@@ -508,7 +508,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
                        /*
                         * What remains is an FDDI packet.
                         */
                        /*
                         * What remains is an FDDI packet.
                         */
-                       fddi_print(p, length, caplen);
+                       fddi_print(gndo, p, length, caplen);
                        return (1);
 
                case PID_RFC2684_BPDU:
                        return (1);
 
                case PID_RFC2684_BPDU:
index 59fb5163cf2293a232319f575a0fd37b94a21f67..a61e0531164e019fbe2240ea8b8844b5c1e0018c 100644 (file)
 
 #include <tcpdump-stdinc.h>
 
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "interface.h"
+#include "netdissect.h"
 #include "extract.h"
 #include "extract.h"
-#include "ether.h"
 
 #define MPCP_TIMESTAMP_LEN        4
 #define MPCP_TIMESTAMP_DURATION_LEN 2
 
 #define MPCP_TIMESTAMP_LEN        4
 #define MPCP_TIMESTAMP_DURATION_LEN 2
@@ -126,7 +121,7 @@ static const struct tok mpcp_reg_ack_flag_values[] = {
 };
 
 void
 };
 
 void
-mpcp_print(register const u_char *pptr, register u_int length) {
+mpcp_print(netdissect_options *ndo, register const u_char *pptr, register u_int length) {
 
     union {
         const struct mpcp_common_header_t *common_header;
 
     union {
         const struct mpcp_common_header_t *common_header;
@@ -145,16 +140,16 @@ mpcp_print(register const u_char *pptr, register u_int length) {
     tptr=pptr;
     mpcp.common_header = (const struct mpcp_common_header_t *)pptr;
 
     tptr=pptr;
     mpcp.common_header = (const struct mpcp_common_header_t *)pptr;
 
-    if (!TTEST2(*tptr, sizeof(const struct mpcp_common_header_t)))
+    if (!ND_TTEST2(*tptr, sizeof(const struct mpcp_common_header_t)))
         goto trunc;
     opcode = EXTRACT_16BITS(mpcp.common_header->opcode);
         goto trunc;
     opcode = EXTRACT_16BITS(mpcp.common_header->opcode);
-    printf("MPCP, Opcode %s", tok2str(mpcp_opcode_values, "Unknown (%u)", opcode));
+    ND_PRINT((ndo, "MPCP, Opcode %s", tok2str(mpcp_opcode_values, "Unknown (%u)", opcode)));
     if (opcode != MPCP_OPCODE_PAUSE) {
     if (opcode != MPCP_OPCODE_PAUSE) {
-        printf(", Timestamp %u ticks", EXTRACT_32BITS(mpcp.common_header->timestamp));
+        ND_PRINT((ndo, ", Timestamp %u ticks", EXTRACT_32BITS(mpcp.common_header->timestamp)));
     }
     }
-    printf(", length %u", length);
+    ND_PRINT((ndo, ", length %u", length));
 
 
-    if (!vflag)
+    if (!ndo->ndo_vflag)
         return;
 
     tptr += sizeof(const struct mpcp_common_header_t);
         return;
 
     tptr += sizeof(const struct mpcp_common_header_t);
@@ -164,57 +159,57 @@ mpcp_print(register const u_char *pptr, register u_int length) {
         break;
 
     case MPCP_OPCODE_GATE:
         break;
 
     case MPCP_OPCODE_GATE:
-       if (!TTEST2(*tptr, MPCP_GRANT_NUMBER_LEN))
+       if (!ND_TTEST2(*tptr, MPCP_GRANT_NUMBER_LEN))
            goto trunc;
         grant_numbers = *tptr & MPCP_GRANT_NUMBER_MASK;
            goto trunc;
         grant_numbers = *tptr & MPCP_GRANT_NUMBER_MASK;
-        printf("\n\tGrant Numbers %u, Flags [ %s ]",
+        ND_PRINT((ndo, "\n\tGrant Numbers %u, Flags [ %s ]",
                grant_numbers,
                bittok2str(mpcp_grant_flag_values,
                           "?",
                grant_numbers,
                bittok2str(mpcp_grant_flag_values,
                           "?",
-                          *tptr &~ MPCP_GRANT_NUMBER_MASK));
+                          *tptr &~ MPCP_GRANT_NUMBER_MASK)));
         tptr++;
 
         for (grant = 1; grant <= grant_numbers; grant++) {
         tptr++;
 
         for (grant = 1; grant <= grant_numbers; grant++) {
-            if (!TTEST2(*tptr, sizeof(const struct mpcp_grant_t)))
+            if (!ND_TTEST2(*tptr, sizeof(const struct mpcp_grant_t)))
                 goto trunc;
             mpcp.grant = (const struct mpcp_grant_t *)tptr;
                 goto trunc;
             mpcp.grant = (const struct mpcp_grant_t *)tptr;
-            printf("\n\tGrant #%u, Start-Time %u ticks, duration %u ticks",
+            ND_PRINT((ndo, "\n\tGrant #%u, Start-Time %u ticks, duration %u ticks",
                    grant,
                    EXTRACT_32BITS(mpcp.grant->starttime),
                    grant,
                    EXTRACT_32BITS(mpcp.grant->starttime),
-                   EXTRACT_16BITS(mpcp.grant->duration));
+                   EXTRACT_16BITS(mpcp.grant->duration)));
             tptr += sizeof(const struct mpcp_grant_t);
         }
 
             tptr += sizeof(const struct mpcp_grant_t);
         }
 
-       if (!TTEST2(*tptr, MPCP_TIMESTAMP_DURATION_LEN))
+       if (!ND_TTEST2(*tptr, MPCP_TIMESTAMP_DURATION_LEN))
            goto trunc;
            goto trunc;
-        printf("\n\tSync-Time %u ticks", EXTRACT_16BITS(tptr));
+        ND_PRINT((ndo, "\n\tSync-Time %u ticks", EXTRACT_16BITS(tptr)));
         break;
 
 
     case MPCP_OPCODE_REPORT:
         break;
 
 
     case MPCP_OPCODE_REPORT:
-       if (!TTEST2(*tptr, MPCP_REPORT_QUEUESETS_LEN))
+       if (!ND_TTEST2(*tptr, MPCP_REPORT_QUEUESETS_LEN))
            goto trunc;
         queue_sets = *tptr;
         tptr+=MPCP_REPORT_QUEUESETS_LEN;
            goto trunc;
         queue_sets = *tptr;
         tptr+=MPCP_REPORT_QUEUESETS_LEN;
-        printf("\n\tTotal Queue-Sets %u", queue_sets);
+        ND_PRINT((ndo, "\n\tTotal Queue-Sets %u", queue_sets));
 
         for (queue_set = 1; queue_set < queue_sets; queue_set++) {
 
         for (queue_set = 1; queue_set < queue_sets; queue_set++) {
-            if (!TTEST2(*tptr, MPCP_REPORT_REPORTBITMAP_LEN))
+            if (!ND_TTEST2(*tptr, MPCP_REPORT_REPORTBITMAP_LEN))
                 goto trunc;
             report_bitmap = *(tptr);
                 goto trunc;
             report_bitmap = *(tptr);
-            printf("\n\t  Queue-Set #%u, Report-Bitmap [ %s ]",
+            ND_PRINT((ndo, "\n\t  Queue-Set #%u, Report-Bitmap [ %s ]",
                    queue_sets,
                    queue_sets,
-                   bittok2str(mpcp_report_bitmap_values, "Unknown", report_bitmap));
+                   bittok2str(mpcp_report_bitmap_values, "Unknown", report_bitmap)));
             tptr++;
 
             report=1;
             while (report_bitmap != 0) {
                 if (report_bitmap & 1) {
             tptr++;
 
             report=1;
             while (report_bitmap != 0) {
                 if (report_bitmap & 1) {
-                    if (!TTEST2(*tptr, MPCP_TIMESTAMP_DURATION_LEN))
+                    if (!ND_TTEST2(*tptr, MPCP_TIMESTAMP_DURATION_LEN))
                         goto trunc;
                         goto trunc;
-                    printf("\n\t    Q%u Report, Duration %u ticks",
+                    ND_PRINT((ndo, "\n\t    Q%u Report, Duration %u ticks",
                            report,
                            report,
-                           EXTRACT_16BITS(tptr));
+                           EXTRACT_16BITS(tptr)));
                     tptr+=MPCP_TIMESTAMP_DURATION_LEN;
                 }
                 report++;
                     tptr+=MPCP_TIMESTAMP_DURATION_LEN;
                 }
                 report++;
@@ -224,47 +219,47 @@ mpcp_print(register const u_char *pptr, register u_int length) {
         break;
 
     case MPCP_OPCODE_REG_REQ:
         break;
 
     case MPCP_OPCODE_REG_REQ:
-        if (!TTEST2(*tptr, sizeof(const struct mpcp_reg_req_t)))
+        if (!ND_TTEST2(*tptr, sizeof(const struct mpcp_reg_req_t)))
             goto trunc;
         mpcp.reg_req = (const struct mpcp_reg_req_t *)tptr;
             goto trunc;
         mpcp.reg_req = (const struct mpcp_reg_req_t *)tptr;
-        printf("\n\tFlags [ %s ], Pending-Grants %u",
+        ND_PRINT((ndo, "\n\tFlags [ %s ], Pending-Grants %u",
                bittok2str(mpcp_reg_req_flag_values, "Reserved", mpcp.reg_req->flags),
                bittok2str(mpcp_reg_req_flag_values, "Reserved", mpcp.reg_req->flags),
-               mpcp.reg_req->pending_grants);
+               mpcp.reg_req->pending_grants));
         break;
 
     case MPCP_OPCODE_REG:
         break;
 
     case MPCP_OPCODE_REG:
-        if (!TTEST2(*tptr, sizeof(const struct mpcp_reg_t)))
+        if (!ND_TTEST2(*tptr, sizeof(const struct mpcp_reg_t)))
             goto trunc;
         mpcp.reg = (const struct mpcp_reg_t *)tptr;
             goto trunc;
         mpcp.reg = (const struct mpcp_reg_t *)tptr;
-        printf("\n\tAssigned-Port %u, Flags [ %s ]" \
+        ND_PRINT((ndo, "\n\tAssigned-Port %u, Flags [ %s ]" \
                "\n\tSync-Time %u ticks, Echoed-Pending-Grants %u",
                EXTRACT_16BITS(mpcp.reg->assigned_port),
                bittok2str(mpcp_reg_flag_values, "Reserved", mpcp.reg->flags),
                EXTRACT_16BITS(mpcp.reg->sync_time),
                "\n\tSync-Time %u ticks, Echoed-Pending-Grants %u",
                EXTRACT_16BITS(mpcp.reg->assigned_port),
                bittok2str(mpcp_reg_flag_values, "Reserved", mpcp.reg->flags),
                EXTRACT_16BITS(mpcp.reg->sync_time),
-               mpcp.reg->echoed_pending_grants);
+               mpcp.reg->echoed_pending_grants));
         break;
 
     case MPCP_OPCODE_REG_ACK:
         break;
 
     case MPCP_OPCODE_REG_ACK:
-        if (!TTEST2(*tptr, sizeof(const struct mpcp_reg_ack_t)))
+        if (!ND_TTEST2(*tptr, sizeof(const struct mpcp_reg_ack_t)))
             goto trunc;
         mpcp.reg_ack = (const struct mpcp_reg_ack_t *)tptr;
             goto trunc;
         mpcp.reg_ack = (const struct mpcp_reg_ack_t *)tptr;
-        printf("\n\tEchoed-Assigned-Port %u, Flags [ %s ]" \
+        ND_PRINT((ndo, "\n\tEchoed-Assigned-Port %u, Flags [ %s ]" \
                "\n\tEchoed-Sync-Time %u ticks",
                EXTRACT_16BITS(mpcp.reg_ack->echoed_assigned_port),
                bittok2str(mpcp_reg_ack_flag_values, "Reserved", mpcp.reg_ack->flags),
                "\n\tEchoed-Sync-Time %u ticks",
                EXTRACT_16BITS(mpcp.reg_ack->echoed_assigned_port),
                bittok2str(mpcp_reg_ack_flag_values, "Reserved", mpcp.reg_ack->flags),
-               EXTRACT_16BITS(mpcp.reg_ack->echoed_sync_time));
+               EXTRACT_16BITS(mpcp.reg_ack->echoed_sync_time)));
         break;
 
     default:
         /* unknown opcode - hexdump for now */
         break;
 
     default:
         /* unknown opcode - hexdump for now */
-        print_unknown_data(gndo,pptr, "\n\t", length);
+        print_unknown_data(ndo,pptr, "\n\t", length);
         break;
     }
 
     return;
 
 trunc:
         break;
     }
 
     return;
 
 trunc:
-    printf("\n\t[|MPCP]");
+    ND_PRINT((ndo, "\n\t[|MPCP]"));
 }
 /*
  * Local Variables:
 }
 /*
  * Local Variables:
index 50eb6c0f4d1a961271f11011f800527b83f8a06b..24e1603e92da2bd1e78ea632e61101cea26ebedf 100644 (file)
 
 #include <tcpdump-stdinc.h>
 
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
 #include <string.h>
 
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
 #include <string.h>
 
 #include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
-#include "ethertype.h"
-
 #include "ether.h"
 
 /*
 #include "ether.h"
 
 /*
@@ -106,22 +103,23 @@ extract_token_addrs(const struct token_header *trp, char *fsrc, char *fdst)
  * Print the TR MAC header
  */
 static inline void
  * Print the TR MAC header
  */
 static inline void
-token_hdr_print(register const struct token_header *trp, register u_int length,
-          register const u_char *fsrc, register const u_char *fdst)
+token_hdr_print(netdissect_options *ndo,
+                register const struct token_header *trp, register u_int length,
+                register const u_char *fsrc, register const u_char *fdst)
 {
        const char *srcname, *dstname;
 
        srcname = etheraddr_string(fsrc);
        dstname = etheraddr_string(fdst);
 
 {
        const char *srcname, *dstname;
 
        srcname = etheraddr_string(fsrc);
        dstname = etheraddr_string(fdst);
 
-       if (vflag)
-               (void) printf("%02x %02x %s %s %d: ",
+       if (ndo->ndo_vflag)
+               ND_PRINT((ndo, "%02x %02x %s %s %d: ",
                       trp->token_ac,
                       trp->token_fc,
                       srcname, dstname,
                       trp->token_ac,
                       trp->token_fc,
                       srcname, dstname,
-                      length);
+                      length));
        else
        else
-               printf("%s %s %d: ", srcname, dstname, length);
+               ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
 }
 
 static const char *broadcast_indicator[] = {
 }
 
 static const char *broadcast_indicator[] = {
@@ -147,7 +145,7 @@ static const char *largest_frame[] = {
 };
 
 u_int
 };
 
 u_int
-token_print(const u_char *p, u_int length, u_int caplen)
+token_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
 {
        const struct token_header *trp;
        u_short extracted_ethertype;
 {
        const struct token_header *trp;
        u_short extracted_ethertype;
@@ -158,7 +156,7 @@ token_print(const u_char *p, u_int length, u_int caplen)
        trp = (const struct token_header *)p;
 
        if (caplen < TOKEN_HDRLEN) {
        trp = (const struct token_header *)p;
 
        if (caplen < TOKEN_HDRLEN) {
-               printf("%s", tstr);
+               ND_PRINT((ndo, "%s", tstr));
                return hdr_len;
        }
 
                return hdr_len;
        }
 
@@ -172,36 +170,36 @@ token_print(const u_char *p, u_int length, u_int caplen)
                /* Clear source-routed bit */
                *ESRC(&ehdr) &= 0x7f;
 
                /* Clear source-routed bit */
                *ESRC(&ehdr) &= 0x7f;
 
-               if (eflag)
-                       token_hdr_print(trp, length, ESRC(&ehdr), EDST(&ehdr));
+               if (ndo->ndo_eflag)
+                       token_hdr_print(ndo, trp, length, ESRC(&ehdr), EDST(&ehdr));
 
                if (caplen < TOKEN_HDRLEN + 2) {
 
                if (caplen < TOKEN_HDRLEN + 2) {
-                       printf("%s", tstr);
+                       ND_PRINT((ndo, "%s", tstr));
                        return hdr_len;
                }
                route_len = RIF_LENGTH(trp);
                hdr_len += route_len;
                if (caplen < hdr_len) {
                        return hdr_len;
                }
                route_len = RIF_LENGTH(trp);
                hdr_len += route_len;
                if (caplen < hdr_len) {
-                       printf("%s", tstr);
+                       ND_PRINT((ndo, "%s", tstr));
                        return hdr_len;
                }
                        return hdr_len;
                }
-               if (vflag) {
-                       printf("%s ", broadcast_indicator[BROADCAST(trp)]);
-                       printf("%s", direction[DIRECTION(trp)]);
+               if (ndo->ndo_vflag) {
+                       ND_PRINT((ndo, "%s ", broadcast_indicator[BROADCAST(trp)]));
+                       ND_PRINT((ndo, "%s", direction[DIRECTION(trp)]));
 
                        for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
 
                        for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
-                               printf(" [%d:%d]", RING_NUMBER(trp, seg),
-                                   BRIDGE_NUMBER(trp, seg));
+                               ND_PRINT((ndo, " [%d:%d]", RING_NUMBER(trp, seg),
+                                   BRIDGE_NUMBER(trp, seg)));
                } else {
                } else {
-                       printf("rt = %x", EXTRACT_16BITS(&trp->token_rcf));
+                       ND_PRINT((ndo, "rt = %x", EXTRACT_16BITS(&trp->token_rcf)));
 
                        for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
 
                        for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
-                               printf(":%x", EXTRACT_16BITS(&trp->token_rseg[seg]));
+                               ND_PRINT((ndo, ":%x", EXTRACT_16BITS(&trp->token_rseg[seg])));
                }
                }
-               printf(" (%s) ", largest_frame[LARGEST_FRAME(trp)]);
+               ND_PRINT((ndo, " (%s) ", largest_frame[LARGEST_FRAME(trp)]));
        } else {
        } else {
-               if (eflag)
-                       token_hdr_print(trp, length, ESRC(&ehdr), EDST(&ehdr));
+               if (ndo->ndo_eflag)
+                       token_hdr_print(ndo, trp, length, ESRC(&ehdr), EDST(&ehdr));
        }
 
        /* Skip over token ring MAC header and routing information */
        }
 
        /* Skip over token ring MAC header and routing information */
@@ -215,25 +213,25 @@ token_print(const u_char *p, u_int length, u_int caplen)
                if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
                    &extracted_ethertype) == 0) {
                        /* ether_type not known, print raw packet */
                if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
                    &extracted_ethertype) == 0) {
                        /* ether_type not known, print raw packet */
-                       if (!eflag)
-                               token_hdr_print(trp,
+                       if (!ndo->ndo_eflag)
+                               token_hdr_print(ndo, trp,
                                    length + TOKEN_HDRLEN + route_len,
                                    ESRC(&ehdr), EDST(&ehdr));
                        if (extracted_ethertype) {
                                    length + TOKEN_HDRLEN + route_len,
                                    ESRC(&ehdr), EDST(&ehdr));
                        if (extracted_ethertype) {
-                               printf("(LLC %s) ",
-                       etherproto_string(htons(extracted_ethertype)));
+                               ND_PRINT((ndo, "(LLC %s) ",
+                       etherproto_string(htons(extracted_ethertype))));
                        }
                        }
-                       if (!suppress_default_print)
-                               default_print(p, caplen);
+                       if (!ndo->ndo_suppress_default_print)
+                               ndo->ndo_default_print(ndo, p, caplen);
                }
        } else {
                /* Some kinds of TR packet we cannot handle intelligently */
                /* XXX - dissect MAC packets if frame type is 0 */
                }
        } else {
                /* Some kinds of TR packet we cannot handle intelligently */
                /* XXX - dissect MAC packets if frame type is 0 */
-               if (!eflag)
-                       token_hdr_print(trp, length + TOKEN_HDRLEN + route_len,
+               if (!ndo->ndo_eflag)
+                       token_hdr_print(ndo, trp, length + TOKEN_HDRLEN + route_len,
                            ESRC(&ehdr), EDST(&ehdr));
                            ESRC(&ehdr), EDST(&ehdr));
-               if (!suppress_default_print)
-                       default_print(p, caplen);
+               if (!ndo->ndo_suppress_default_print)
+                       ndo->ndo_default_print(ndo, p, caplen);
        }
        return (hdr_len);
 }
        }
        return (hdr_len);
 }
@@ -245,7 +243,7 @@ token_print(const u_char *p, u_int length, u_int caplen)
  * is the number of bytes actually captured.
  */
 u_int
  * is the number of bytes actually captured.
  */
 u_int
-token_if_print(const struct pcap_pkthdr *h, const u_char *p)
+token_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
 {
-       return (token_print(p, h->len, h->caplen));
+       return (token_print(ndo, p, h->len, h->caplen));
 }
 }
index c65c70c4c74ae831a0191a16133b30e59be6babf..bb11e95be66a11544f7b0e1e5c5c7ca9964089ec 100644 (file)
@@ -608,7 +608,7 @@ udp_print(register const u_char *bp, u_int length,
                else if (dport == VAT_PORT)
                        vat_print((const void *)(up + 1), up);
                else if (ISPORT(ZEPHYR_SRV_PORT) || ISPORT(ZEPHYR_CLT_PORT))
                else if (dport == VAT_PORT)
                        vat_print((const void *)(up + 1), up);
                else if (ISPORT(ZEPHYR_SRV_PORT) || ISPORT(ZEPHYR_CLT_PORT))
-                       zephyr_print((const void *)(up + 1), length);
+                       zephyr_print(gndo, (const void *)(up + 1), length);
                /*
                 * Since there are 10 possible ports to check, I think
                 * a <> test would be more efficient
                /*
                 * Since there are 10 possible ports to check, I think
                 * a <> test would be more efficient
@@ -660,7 +660,7 @@ udp_print(register const u_char *bp, u_int length,
                 else if (ISPORT(LMP_PORT))
                        lmp_print((const u_char *)(up + 1), length);
                else if (ISPORT(VQP_PORT))
                 else if (ISPORT(LMP_PORT))
                        lmp_print((const u_char *)(up + 1), length);
                else if (ISPORT(VQP_PORT))
-                       vqp_print((const u_char *)(up + 1), length);
+                       vqp_print(gndo, (const u_char *)(up + 1), length);
                 else if (ISPORT(SFLOW_PORT))
                         sflow_print((const u_char *)(up + 1), length);
                else if (dport == LWAPP_CONTROL_PORT)
                 else if (ISPORT(SFLOW_PORT))
                         sflow_print((const u_char *)(up + 1), length);
                else if (dport == LWAPP_CONTROL_PORT)
index 8935545919056399ac4f41db4b4f69c75868a89f..3245b33206d022824f3d7ebd57df2d3a02bea4b8 100644 (file)
 
 #include <tcpdump-stdinc.h>
 
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "interface.h"
+#include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
 
 #include "extract.h"
 #include "addrtoname.h"
 
@@ -101,7 +97,7 @@ static const struct tok vqp_obj_values[] = {
 };
 
 void
 };
 
 void
-vqp_print(register const u_char *pptr, register u_int len)
+vqp_print(netdissect_options *ndo, register const u_char *pptr, register u_int len)
 {
     const struct vqp_common_header_t *vqp_common_header;
     const struct vqp_obj_tlv_t *vqp_obj_tlv;
 {
     const struct vqp_common_header_t *vqp_common_header;
     const struct vqp_obj_tlv_t *vqp_obj_tlv;
@@ -115,38 +111,38 @@ vqp_print(register const u_char *pptr, register u_int len)
     tptr=pptr;
     tlen = len;
     vqp_common_header = (const struct vqp_common_header_t *)pptr;
     tptr=pptr;
     tlen = len;
     vqp_common_header = (const struct vqp_common_header_t *)pptr;
-    TCHECK(*vqp_common_header);
+    ND_TCHECK(*vqp_common_header);
 
     /*
      * Sanity checking of the header.
      */
     if (VQP_EXTRACT_VERSION(vqp_common_header->version) != VQP_VERSION) {
 
     /*
      * Sanity checking of the header.
      */
     if (VQP_EXTRACT_VERSION(vqp_common_header->version) != VQP_VERSION) {
-       printf("VQP version %u packet not supported",
-               VQP_EXTRACT_VERSION(vqp_common_header->version));
+       ND_PRINT((ndo, "VQP version %u packet not supported",
+               VQP_EXTRACT_VERSION(vqp_common_header->version)));
        return;
     }
 
     /* in non-verbose mode just lets print the basic Message Type */
        return;
     }
 
     /* in non-verbose mode just lets print the basic Message Type */
-    if (vflag < 1) {
-        printf("VQPv%u %s Message, error-code %s (%u), length %u",
+    if (ndo->ndo_vflag < 1) {
+        ND_PRINT((ndo, "VQPv%u %s Message, error-code %s (%u), length %u",
                VQP_EXTRACT_VERSION(vqp_common_header->version),
                tok2str(vqp_msg_type_values, "unknown (%u)",vqp_common_header->msg_type),
                tok2str(vqp_error_code_values, "unknown (%u)",vqp_common_header->error_code),
               vqp_common_header->error_code,
                VQP_EXTRACT_VERSION(vqp_common_header->version),
                tok2str(vqp_msg_type_values, "unknown (%u)",vqp_common_header->msg_type),
                tok2str(vqp_error_code_values, "unknown (%u)",vqp_common_header->error_code),
               vqp_common_header->error_code,
-               len);
+               len));
         return;
     }
 
     /* ok they seem to want to know everything - lets fully decode it */
     nitems = vqp_common_header->nitems;
         return;
     }
 
     /* ok they seem to want to know everything - lets fully decode it */
     nitems = vqp_common_header->nitems;
-    printf("\n\tVQPv%u, %s Message, error-code %s (%u), seq 0x%08x, items %u, length %u",
+    ND_PRINT((ndo, "\n\tVQPv%u, %s Message, error-code %s (%u), seq 0x%08x, items %u, length %u",
            VQP_EXTRACT_VERSION(vqp_common_header->version),
           tok2str(vqp_msg_type_values, "unknown (%u)",vqp_common_header->msg_type),
           tok2str(vqp_error_code_values, "unknown (%u)",vqp_common_header->error_code),
           vqp_common_header->error_code,
            EXTRACT_32BITS(&vqp_common_header->sequence),
            nitems,
            VQP_EXTRACT_VERSION(vqp_common_header->version),
           tok2str(vqp_msg_type_values, "unknown (%u)",vqp_common_header->msg_type),
           tok2str(vqp_error_code_values, "unknown (%u)",vqp_common_header->error_code),
           vqp_common_header->error_code,
            EXTRACT_32BITS(&vqp_common_header->sequence),
            nitems,
-           len);
+           len));
 
     /* skip VQP Common header */
     tptr+=sizeof(const struct vqp_common_header_t);
 
     /* skip VQP Common header */
     tptr+=sizeof(const struct vqp_common_header_t);
@@ -160,9 +156,9 @@ vqp_print(register const u_char *pptr, register u_int len)
         tptr+=sizeof(struct vqp_obj_tlv_t);
         tlen-=sizeof(struct vqp_obj_tlv_t);
 
         tptr+=sizeof(struct vqp_obj_tlv_t);
         tlen-=sizeof(struct vqp_obj_tlv_t);
 
-        printf("\n\t  %s Object (0x%08x), length %u, value: ",
+        ND_PRINT((ndo, "\n\t  %s Object (0x%08x), length %u, value: ",
                tok2str(vqp_obj_values, "Unknown", vqp_obj_type),
                tok2str(vqp_obj_values, "Unknown", vqp_obj_type),
-               vqp_obj_type, vqp_obj_len);
+               vqp_obj_type, vqp_obj_len));
 
         /* basic sanity check */
         if (vqp_obj_type == 0 || vqp_obj_len ==0) {
 
         /* basic sanity check */
         if (vqp_obj_type == 0 || vqp_obj_len ==0) {
@@ -170,12 +166,12 @@ vqp_print(register const u_char *pptr, register u_int len)
         }
 
         /* did we capture enough for fully decoding the object ? */
         }
 
         /* did we capture enough for fully decoding the object ? */
-        if (!TTEST2(*tptr, vqp_obj_len))
+        if (!ND_TTEST2(*tptr, vqp_obj_len))
             goto trunc;
 
         switch(vqp_obj_type) {
        case VQP_OBJ_IP_ADDRESS:
             goto trunc;
 
         switch(vqp_obj_type) {
        case VQP_OBJ_IP_ADDRESS:
-            printf("%s (0x%08x)", ipaddr_string(tptr), EXTRACT_32BITS(tptr));
+            ND_PRINT((ndo, "%s (0x%08x)", ipaddr_string(tptr), EXTRACT_32BITS(tptr)));
             break;
             /* those objects have similar semantics - fall through */
         case VQP_OBJ_PORT_NAME:
             break;
             /* those objects have similar semantics - fall through */
         case VQP_OBJ_PORT_NAME:
@@ -187,11 +183,11 @@ vqp_print(register const u_char *pptr, register u_int len)
             /* those objects have similar semantics - fall through */
        case VQP_OBJ_MAC_ADDRESS:
        case VQP_OBJ_MAC_NULL:
             /* those objects have similar semantics - fall through */
        case VQP_OBJ_MAC_ADDRESS:
        case VQP_OBJ_MAC_NULL:
-             printf("%s", etheraddr_string(tptr));
+             ND_PRINT((ndo, "%s", etheraddr_string(tptr)));
               break;
         default:
               break;
         default:
-            if (vflag <= 1)
-                print_unknown_data(gndo,tptr, "\n\t    ", vqp_obj_len);
+            if (ndo->ndo_vflag <= 1)
+                print_unknown_data(ndo,tptr, "\n\t    ", vqp_obj_len);
             break;
         }
        tptr += vqp_obj_len;
             break;
         }
        tptr += vqp_obj_len;
@@ -200,5 +196,5 @@ vqp_print(register const u_char *pptr, register u_int len)
     }
     return;
 trunc:
     }
     return;
 trunc:
-    printf("\n\t[|VQP]");
+    ND_PRINT((ndo, "\n\t[|VQP]"));
 }
 }
index a08ab04ca253df61581223a4be09c0eada14935d..0142a4a8700ffcb6e96a0fd6050568b6fd90ac08 100644 (file)
@@ -30,7 +30,7 @@
 #include <string.h>
 #include <stdlib.h>
 
 #include <string.h>
 #include <stdlib.h>
 
-#include "interface.h"
+#include "netdissect.h"
 
 struct z_packet {
     char *version;
 
 struct z_packet {
     char *version;
@@ -77,26 +77,26 @@ static const struct tok z_types[] = {
     { Z_PACKET_STAT,           "stat" }
 };
 
     { Z_PACKET_STAT,           "stat" }
 };
 
-char z_buf[256];
+static char z_buf[256];
 
 static char *
 
 static char *
-parse_field(char **pptr, int *len)
+parse_field(netdissect_options *ndo, char **pptr, int *len)
 {
     char *s;
 
     if (*len <= 0 || !pptr || !*pptr)
        return NULL;
 {
     char *s;
 
     if (*len <= 0 || !pptr || !*pptr)
        return NULL;
-    if (*pptr > (char *) snapend)
+    if (*pptr > (char *) ndo->ndo_snapend)
        return NULL;
 
     s = *pptr;
        return NULL;
 
     s = *pptr;
-    while (*pptr <= (char *) snapend && *len >= 0 && **pptr) {
+    while (*pptr <= (char *) ndo->ndo_snapend && *len >= 0 && **pptr) {
        (*pptr)++;
        (*len)--;
     }
     (*pptr)++;
     (*len)--;
        (*pptr)++;
        (*len)--;
     }
     (*pptr)++;
     (*len)--;
-    if (*len < 0 || *pptr > (char *) snapend)
+    if (*len < 0 || *pptr > (char *) ndo->ndo_snapend)
        return NULL;
     return s;
 }
        return NULL;
     return s;
 }
@@ -127,7 +127,7 @@ str_to_lower(char *string)
 }
 
 void
 }
 
 void
-zephyr_print(const u_char *cp, int length)
+zephyr_print(netdissect_options *ndo, const u_char *cp, int length)
 {
     struct z_packet z;
     char *parse = (char *) cp;
 {
     struct z_packet z;
     char *parse = (char *) cp;
@@ -145,7 +145,7 @@ zephyr_print(const u_char *cp, int length)
     z.recipient = 0;
 
 #define PARSE_STRING                           \
     z.recipient = 0;
 
 #define PARSE_STRING                           \
-       s = parse_field(&parse, &parselen);     \
+       s = parse_field(ndo, &parse, &parselen);        \
        if (!s) lose = 1;
 
 #define PARSE_FIELD_INT(field)                 \
        if (!s) lose = 1;
 
 #define PARSE_FIELD_INT(field)                 \
@@ -179,38 +179,38 @@ zephyr_print(const u_char *cp, int length)
     PARSE_FIELD_STR(z.multi_uid);
 
     if (lose) {
     PARSE_FIELD_STR(z.multi_uid);
 
     if (lose) {
-       printf(" [|zephyr] (%d)", length);
+       ND_PRINT((ndo, " [|zephyr] (%d)", length));
        return;
     }
 
        return;
     }
 
-    printf(" zephyr");
+    ND_PRINT((ndo, " zephyr"));
     if (strncmp(z.version+4, "0.2", 3)) {
     if (strncmp(z.version+4, "0.2", 3)) {
-       printf(" v%s", z.version+4);
+       ND_PRINT((ndo, " v%s", z.version+4));
        return;
     }
 
        return;
     }
 
-    printf(" %s", tok2str(z_types, "type %d", z.kind));
+    ND_PRINT((ndo, " %s", tok2str(z_types, "type %d", z.kind)));
     if (z.kind == Z_PACKET_SERVACK) {
        /* Initialization to silence warnings */
        char *ackdata = NULL;
        PARSE_FIELD_STR(ackdata);
        if (!lose && strcmp(ackdata, "SENT"))
     if (z.kind == Z_PACKET_SERVACK) {
        /* Initialization to silence warnings */
        char *ackdata = NULL;
        PARSE_FIELD_STR(ackdata);
        if (!lose && strcmp(ackdata, "SENT"))
-           printf("/%s", str_to_lower(ackdata));
+           ND_PRINT((ndo, "/%s", str_to_lower(ackdata)));
     }
     }
-    if (*z.sender) printf(" %s", z.sender);
+    if (*z.sender) ND_PRINT((ndo, " %s", z.sender));
 
     if (!strcmp(z.class, "USER_LOCATE")) {
        if (!strcmp(z.opcode, "USER_HIDE"))
 
     if (!strcmp(z.class, "USER_LOCATE")) {
        if (!strcmp(z.opcode, "USER_HIDE"))
-           printf(" hide");
+           ND_PRINT((ndo, " hide"));
        else if (!strcmp(z.opcode, "USER_UNHIDE"))
        else if (!strcmp(z.opcode, "USER_UNHIDE"))
-           printf(" unhide");
+           ND_PRINT((ndo, " unhide"));
        else
        else
-           printf(" locate %s", z.inst);
+           ND_PRINT((ndo, " locate %s", z.inst));
        return;
     }
 
     if (!strcmp(z.class, "ZEPHYR_ADMIN")) {
        return;
     }
 
     if (!strcmp(z.class, "ZEPHYR_ADMIN")) {
-       printf(" zephyr-admin %s", str_to_lower(z.opcode));
+       ND_PRINT((ndo, " zephyr-admin %s", str_to_lower(z.opcode)));
        return;
     }
 
        return;
     }
 
@@ -220,79 +220,79 @@ zephyr_print(const u_char *cp, int length)
                !strcmp(z.opcode, "SUBSCRIBE_NODEFS") ||
                !strcmp(z.opcode, "UNSUBSCRIBE")) {
 
                !strcmp(z.opcode, "SUBSCRIBE_NODEFS") ||
                !strcmp(z.opcode, "UNSUBSCRIBE")) {
 
-               printf(" %ssub%s", strcmp(z.opcode, "SUBSCRIBE") ? "un" : "",
+               ND_PRINT((ndo, " %ssub%s", strcmp(z.opcode, "SUBSCRIBE") ? "un" : "",
                                   strcmp(z.opcode, "SUBSCRIBE_NODEFS") ? "" :
                                   strcmp(z.opcode, "SUBSCRIBE_NODEFS") ? "" :
-                                                                  "-nodefs");
+                                                                  "-nodefs"));
                if (z.kind != Z_PACKET_SERVACK) {
                    /* Initialization to silence warnings */
                    char *c = NULL, *i = NULL, *r = NULL;
                    PARSE_FIELD_STR(c);
                    PARSE_FIELD_STR(i);
                    PARSE_FIELD_STR(r);
                if (z.kind != Z_PACKET_SERVACK) {
                    /* Initialization to silence warnings */
                    char *c = NULL, *i = NULL, *r = NULL;
                    PARSE_FIELD_STR(c);
                    PARSE_FIELD_STR(i);
                    PARSE_FIELD_STR(r);
-                   if (!lose) printf(" %s", z_triple(c, i, r));
+                   if (!lose) ND_PRINT((ndo, " %s", z_triple(c, i, r)));
                }
                return;
            }
 
            if (!strcmp(z.opcode, "GIMME")) {
                }
                return;
            }
 
            if (!strcmp(z.opcode, "GIMME")) {
-               printf(" ret");
+               ND_PRINT((ndo, " ret"));
                return;
            }
 
            if (!strcmp(z.opcode, "GIMMEDEFS")) {
                return;
            }
 
            if (!strcmp(z.opcode, "GIMMEDEFS")) {
-               printf(" gimme-defs");
+               ND_PRINT((ndo, " gimme-defs"));
                return;
            }
 
            if (!strcmp(z.opcode, "CLEARSUB")) {
                return;
            }
 
            if (!strcmp(z.opcode, "CLEARSUB")) {
-               printf(" clear-subs");
+               ND_PRINT((ndo, " clear-subs"));
                return;
            }
 
                return;
            }
 
-           printf(" %s", str_to_lower(z.opcode));
+           ND_PRINT((ndo, " %s", str_to_lower(z.opcode)));
            return;
        }
 
        if (!strcmp(z.inst, "HM")) {
            return;
        }
 
        if (!strcmp(z.inst, "HM")) {
-           printf(" %s", str_to_lower(z.opcode));
+           ND_PRINT((ndo, " %s", str_to_lower(z.opcode)));
            return;
        }
 
        if (!strcmp(z.inst, "REALM")) {
            if (!strcmp(z.opcode, "ADD_SUBSCRIBE"))
            return;
        }
 
        if (!strcmp(z.inst, "REALM")) {
            if (!strcmp(z.opcode, "ADD_SUBSCRIBE"))
-               printf(" realm add-subs");
+               ND_PRINT((ndo, " realm add-subs"));
            if (!strcmp(z.opcode, "REQ_SUBSCRIBE"))
            if (!strcmp(z.opcode, "REQ_SUBSCRIBE"))
-               printf(" realm req-subs");
+               ND_PRINT((ndo, " realm req-subs"));
            if (!strcmp(z.opcode, "RLM_SUBSCRIBE"))
            if (!strcmp(z.opcode, "RLM_SUBSCRIBE"))
-               printf(" realm rlm-sub");
+               ND_PRINT((ndo, " realm rlm-sub"));
            if (!strcmp(z.opcode, "RLM_UNSUBSCRIBE"))
            if (!strcmp(z.opcode, "RLM_UNSUBSCRIBE"))
-               printf(" realm rlm-unsub");
+               ND_PRINT((ndo, " realm rlm-unsub"));
            return;
        }
     }
 
     if (!strcmp(z.class, "HM_CTL")) {
            return;
        }
     }
 
     if (!strcmp(z.class, "HM_CTL")) {
-       printf(" hm_ctl %s", str_to_lower(z.inst));
-       printf(" %s", str_to_lower(z.opcode));
+       ND_PRINT((ndo, " hm_ctl %s", str_to_lower(z.inst)));
+       ND_PRINT((ndo, " %s", str_to_lower(z.opcode)));
        return;
     }
 
     if (!strcmp(z.class, "HM_STAT")) {
        if (!strcmp(z.inst, "HMST_CLIENT") && !strcmp(z.opcode, "GIMMESTATS")) {
        return;
     }
 
     if (!strcmp(z.class, "HM_STAT")) {
        if (!strcmp(z.inst, "HMST_CLIENT") && !strcmp(z.opcode, "GIMMESTATS")) {
-           printf(" get-client-stats");
+           ND_PRINT((ndo, " get-client-stats"));
            return;
        }
     }
 
     if (!strcmp(z.class, "WG_CTL")) {
            return;
        }
     }
 
     if (!strcmp(z.class, "WG_CTL")) {
-       printf(" wg_ctl %s", str_to_lower(z.inst));
-       printf(" %s", str_to_lower(z.opcode));
+       ND_PRINT((ndo, " wg_ctl %s", str_to_lower(z.inst)));
+       ND_PRINT((ndo, " %s", str_to_lower(z.opcode)));
        return;
     }
 
     if (!strcmp(z.class, "LOGIN")) {
        if (!strcmp(z.opcode, "USER_FLUSH")) {
        return;
     }
 
     if (!strcmp(z.class, "LOGIN")) {
        if (!strcmp(z.opcode, "USER_FLUSH")) {
-           printf(" flush_locs");
+           ND_PRINT((ndo, " flush_locs"));
            return;
        }
 
            return;
        }
 
@@ -302,7 +302,7 @@ zephyr_print(const u_char *cp, int length)
            !strcmp(z.opcode, "REALM-ANNOUNCED") ||
            !strcmp(z.opcode, "NET-VISIBLE") ||
            !strcmp(z.opcode, "NET-ANNOUNCED")) {
            !strcmp(z.opcode, "REALM-ANNOUNCED") ||
            !strcmp(z.opcode, "NET-VISIBLE") ||
            !strcmp(z.opcode, "NET-ANNOUNCED")) {
-           printf(" set-exposure %s", str_to_lower(z.opcode));
+           ND_PRINT((ndo, " set-exposure %s", str_to_lower(z.opcode)));
            return;
        }
     }
            return;
        }
     }
@@ -310,8 +310,7 @@ zephyr_print(const u_char *cp, int length)
     if (!*z.recipient)
        z.recipient = "*";
 
     if (!*z.recipient)
        z.recipient = "*";
 
-    printf(" to %s", z_triple(z.class, z.inst, z.recipient));
+    ND_PRINT((ndo, " to %s", z_triple(z.class, z.inst, z.recipient)));
     if (*z.opcode)
     if (*z.opcode)
-       printf(" op %s", z.opcode);
-    return;
+       ND_PRINT((ndo, " op %s", z.opcode));
 }
 }
index fab11fe5ad2e23c03f3feb8dd78b340c3c494023..37c76e2a8bf792e7f9f297782f3a55b035aecb06 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -167,7 +167,6 @@ struct ndo_printer {
 
 
 static const struct printer printers[] = {
 
 
 static const struct printer printers[] = {
-       { token_if_print,       DLT_IEEE802 },
        { sl_if_print,          DLT_SLIP },
 #ifdef DLT_SLIP_BSDOS
        { sl_bsdos_if_print,    DLT_SLIP_BSDOS },
        { sl_if_print,          DLT_SLIP },
 #ifdef DLT_SLIP_BSDOS
        { sl_bsdos_if_print,    DLT_SLIP_BSDOS },
@@ -179,7 +178,6 @@ static const struct printer printers[] = {
 #ifdef DLT_PPP_BSDOS
        { ppp_bsdos_if_print,   DLT_PPP_BSDOS },
 #endif
 #ifdef DLT_PPP_BSDOS
        { ppp_bsdos_if_print,   DLT_PPP_BSDOS },
 #endif
-       { fddi_if_print,        DLT_FDDI },
        { atm_if_print,         DLT_ATM_RFC1483 },
 #ifdef DLT_PPP_SERIAL
        { ppp_hdlc_if_print,    DLT_PPP_SERIAL },
        { atm_if_print,         DLT_ATM_RFC1483 },
 #ifdef DLT_PPP_SERIAL
        { ppp_hdlc_if_print,    DLT_PPP_SERIAL },
@@ -344,6 +342,8 @@ static const struct ndo_printer ndo_printers[] = {
 #if defined(DLT_PFLOG) && defined(HAVE_NET_PFVAR_H)
        { pflog_if_print,       DLT_PFLOG },
 #endif
 #if defined(DLT_PFLOG) && defined(HAVE_NET_PFVAR_H)
        { pflog_if_print,       DLT_PFLOG },
 #endif
+       { token_if_print,       DLT_IEEE802 },
+       { fddi_if_print,        DLT_FDDI },
        { NULL,                 0 },
 };
 
        { NULL,                 0 },
 };