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);
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);
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);
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 *);
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);
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 *);
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);
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 *,
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);
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);
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);
return (1);
case ARCTYPE_IPX:
- ipx_print(p, length);
+ ipx_print(ndo, p, length);
return (1);
default:
#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 */
case ETHERTYPE_IPX:
ND_PRINT((ndo, "(NOV-ETHII) "));
- ipx_print(/*ndo,*/p, length);
+ ipx_print(ndo, p, length);
return (1);
case ETHERTYPE_ISO:
case ETHERTYPE_PPPOES:
case ETHERTYPE_PPPOED2:
case ETHERTYPE_PPPOES2:
- pppoe_print(/*ndo,*/p, length);
+ pppoe_print(ndo, p, length);
return (1);
case ETHERTYPE_EAPOL:
case ETHERTYPE_MPLS:
case ETHERTYPE_MPLS_MULTI:
- mpls_print(/*ndo,*/p, length);
+ mpls_print(ndo, p, length);
return (1);
case ETHERTYPE_TIPC:
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);
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:
#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;
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;
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);
}
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));
}
#include <tcpdump-stdinc.h>
-#include <stdlib.h>
#include <stdio.h>
-#include <string.h>
#include "interface.h"
#include "addrtoname.h"
#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 *
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
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;
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));
}
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);
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);
if (eflag)
printf("IPX 802.3: ");
- ipx_print(p, length);
+ ipx_print(gndo, p, length);
return (1);
}
if (eflag)
printf("IPX 802.2: ");
- ipx_print(p+3, length-3);
+ ipx_print(gndo, p+3, length-3);
return (1);
}
#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"
* 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;
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));
* 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;
return;
trunc:
- printf("[|MPLS]");
+ ND_PRINT((ndo, "[|MPLS]"));
}
break;
case BSD_AFNUM_IPX:
- ipx_print(p, length);
+ ipx_print(ndo, p, length);
break;
default:
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
+#include "netdissect.h"
#include "extract.h"
-#include "interface.h"
static const char tstr[] = "[|pflog]";
#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;
/* 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;
#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
#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);
}
(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;
#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");
#endif
case PPP_MPLS_UCAST:
case PPP_MPLS_MCAST:
- mpls_print(p, length);
+ mpls_print(gndo, p, length);
break;
}
goto printx;
#endif
case PPP_MPLS_UCAST:
case PPP_MPLS_MCAST:
- mpls_print(p, length);
+ mpls_print(gndo, p, length);
break;
}
goto printx;
#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 */
#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;
}
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];
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) {
* 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;
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;
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 */
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);
}
#ifdef INET6
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#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)
{
#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;
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;
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 */
/*
* Ethernet_802.3 IPX frame.
*/
- ipx_print(p, length);
+ ipx_print(gndo, p, length);
break;
case LINUX_SLL_P_802_2:
#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
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;
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));
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)) {
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;
}
}
if (packettype) {
switch (packettype) {
case PT_ZMTP1:
- zmtp1_print(bp, length);
+ zmtp1_print(gndo, bp, length);
break;
}
return;
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,
(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))
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
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" : "-",
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"
*/
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);
}
#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
#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
#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 },
};