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 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 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 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 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 *);
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 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*/
return (1);
case ETHERTYPE_MPCP:
- mpcp_print(/*ndo,*/p, length);
+ mpcp_print(ndo, p, length);
return (1);
case ETHERTYPE_SLOW:
#include <tcpdump-stdinc.h>
-#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
-#include "ethertype.h"
-
#include "ether.h"
/*
* 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 */
- printf("void ");
+ ND_PRINT((ndo, "void "));
break;
case FDDIFC_NRT: /* Nonrestricted token */
- printf("nrt ");
+ ND_PRINT((ndo, "nrt "));
break;
case FDDIFC_RT: /* Restricted token */
- printf("rt ");
+ ND_PRINT((ndo, "rt "));
break;
case FDDIFC_SMT_INFO: /* SMT Info */
- printf("info ");
+ ND_PRINT((ndo, "info "));
break;
case FDDIFC_SMT_NSA: /* SMT Next station adrs */
- printf("nsa ");
+ ND_PRINT((ndo, "nsa "));
break;
case FDDIFC_MAC_BEACON: /* MAC Beacon frame */
- printf("beacon ");
+ ND_PRINT((ndo, "beacon "));
break;
case FDDIFC_MAC_CLAIM: /* MAC Claim frame */
- printf("claim ");
+ ND_PRINT((ndo, "claim "));
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:
- printf("smt%1x ", fc & FDDIFC_ZZZZ);
+ ND_PRINT((ndo, "smt%1x ", fc & FDDIFC_ZZZZ));
break;
case FDDIFC_LLC_ASYNC:
- printf("async%1x ", fc & FDDIFC_ZZZZ);
+ ND_PRINT((ndo, "async%1x ", fc & FDDIFC_ZZZZ));
break;
case FDDIFC_LLC_SYNC:
- printf("sync%1x ", fc & FDDIFC_ZZZZ);
+ ND_PRINT((ndo, "sync%1x ", fc & FDDIFC_ZZZZ));
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:
- printf("imp_sync%1x ", fc & FDDIFC_ZZZZ);
+ ND_PRINT((ndo, "imp_sync%1x ", fc & FDDIFC_ZZZZ));
break;
default:
- printf("%02x ", fc);
+ ND_PRINT((ndo, "%02x ", fc));
break;
}
}
* 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);
- if (vflag)
- (void) printf("%02x %s %s %d: ",
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "%02x %s %s %d: ",
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 {
- (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
-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
-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) {
- printf("[|fddi]");
+ ND_PRINT((ndo, "[|fddi]"));
return;
}
*/
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;
* 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) {
- 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)
- fddi_smt_print(p, caplen);
+ fddi_smt_print(ndo, p, caplen);
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));
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ndo->ndo_default_print(ndo, p, caplen);
}
}
* 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);
}
* 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:
/*
* What remains is an FDDI packet.
*/
- fddi_print(p, length, caplen);
+ fddi_print(gndo, p, length, caplen);
return (1);
case PID_RFC2684_BPDU:
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
-#include "ether.h"
#define MPCP_TIMESTAMP_LEN 4
#define MPCP_TIMESTAMP_DURATION_LEN 2
};
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;
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);
- 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) {
- 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);
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;
- printf("\n\tGrant Numbers %u, Flags [ %s ]",
+ ND_PRINT((ndo, "\n\tGrant Numbers %u, Flags [ %s ]",
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++) {
- 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;
- 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),
- EXTRACT_16BITS(mpcp.grant->duration));
+ EXTRACT_16BITS(mpcp.grant->duration)));
tptr += sizeof(const struct mpcp_grant_t);
}
- if (!TTEST2(*tptr, MPCP_TIMESTAMP_DURATION_LEN))
+ if (!ND_TTEST2(*tptr, MPCP_TIMESTAMP_DURATION_LEN))
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:
- 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;
- 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++) {
- if (!TTEST2(*tptr, MPCP_REPORT_REPORTBITMAP_LEN))
+ if (!ND_TTEST2(*tptr, MPCP_REPORT_REPORTBITMAP_LEN))
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,
- 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) {
- if (!TTEST2(*tptr, MPCP_TIMESTAMP_DURATION_LEN))
+ if (!ND_TTEST2(*tptr, MPCP_TIMESTAMP_DURATION_LEN))
goto trunc;
- printf("\n\t Q%u Report, Duration %u ticks",
+ ND_PRINT((ndo, "\n\t Q%u Report, Duration %u ticks",
report,
- EXTRACT_16BITS(tptr));
+ EXTRACT_16BITS(tptr)));
tptr+=MPCP_TIMESTAMP_DURATION_LEN;
}
report++;
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;
- 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),
- mpcp.reg_req->pending_grants);
+ mpcp.reg_req->pending_grants));
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;
- 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),
- mpcp.reg->echoed_pending_grants);
+ mpcp.reg->echoed_pending_grants));
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;
- 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),
- EXTRACT_16BITS(mpcp.reg_ack->echoed_sync_time));
+ EXTRACT_16BITS(mpcp.reg_ack->echoed_sync_time)));
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:
- printf("\n\t[|MPCP]");
+ ND_PRINT((ndo, "\n\t[|MPCP]"));
}
/*
* Local Variables:
#include <tcpdump-stdinc.h>
-#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
-#include "ethertype.h"
-
#include "ether.h"
/*
* 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);
- 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,
- length);
+ length));
else
- printf("%s %s %d: ", srcname, dstname, length);
+ ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
}
static const char *broadcast_indicator[] = {
};
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;
trp = (const struct token_header *)p;
if (caplen < TOKEN_HDRLEN) {
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
return hdr_len;
}
/* 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) {
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
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;
}
- 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++)
- 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 {
- 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++)
- 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 {
- 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 */
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) {
- 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 */
- 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));
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ndo->ndo_default_print(ndo, p, caplen);
}
return (hdr_len);
}
* 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));
}
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
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)
#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"
};
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;
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) {
- 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 */
- 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,
- len);
+ len));
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,
- len);
+ len));
/* skip VQP Common header */
tptr+=sizeof(const struct vqp_common_header_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),
- vqp_obj_type, vqp_obj_len);
+ vqp_obj_type, vqp_obj_len));
/* basic sanity check */
if (vqp_obj_type == 0 || vqp_obj_len ==0) {
}
/* 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:
- 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:
/* 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:
- 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;
}
return;
trunc:
- printf("\n\t[|VQP]");
+ ND_PRINT((ndo, "\n\t[|VQP]"));
}
#include <string.h>
#include <stdlib.h>
-#include "interface.h"
+#include "netdissect.h"
struct z_packet {
char *version;
{ Z_PACKET_STAT, "stat" }
};
-char z_buf[256];
+static char z_buf[256];
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;
- if (*pptr > (char *) snapend)
+ if (*pptr > (char *) ndo->ndo_snapend)
return NULL;
s = *pptr;
- while (*pptr <= (char *) snapend && *len >= 0 && **pptr) {
+ while (*pptr <= (char *) ndo->ndo_snapend && *len >= 0 && **pptr) {
(*pptr)++;
(*len)--;
}
(*pptr)++;
(*len)--;
- if (*len < 0 || *pptr > (char *) snapend)
+ if (*len < 0 || *pptr > (char *) ndo->ndo_snapend)
return NULL;
return s;
}
}
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;
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) \
PARSE_FIELD_STR(z.multi_uid);
if (lose) {
- printf(" [|zephyr] (%d)", length);
+ ND_PRINT((ndo, " [|zephyr] (%d)", length));
return;
}
- printf(" zephyr");
+ ND_PRINT((ndo, " zephyr"));
if (strncmp(z.version+4, "0.2", 3)) {
- printf(" v%s", z.version+4);
+ ND_PRINT((ndo, " v%s", z.version+4));
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"))
- 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"))
- printf(" hide");
+ ND_PRINT((ndo, " hide"));
else if (!strcmp(z.opcode, "USER_UNHIDE"))
- printf(" unhide");
+ ND_PRINT((ndo, " unhide"));
else
- printf(" locate %s", z.inst);
+ ND_PRINT((ndo, " locate %s", z.inst));
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;
}
!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") ? "" :
- "-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 (!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")) {
- printf(" ret");
+ ND_PRINT((ndo, " ret"));
return;
}
if (!strcmp(z.opcode, "GIMMEDEFS")) {
- printf(" gimme-defs");
+ ND_PRINT((ndo, " gimme-defs"));
return;
}
if (!strcmp(z.opcode, "CLEARSUB")) {
- printf(" clear-subs");
+ ND_PRINT((ndo, " clear-subs"));
return;
}
- printf(" %s", str_to_lower(z.opcode));
+ ND_PRINT((ndo, " %s", str_to_lower(z.opcode)));
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"))
- printf(" realm add-subs");
+ ND_PRINT((ndo, " realm add-subs"));
if (!strcmp(z.opcode, "REQ_SUBSCRIBE"))
- printf(" realm req-subs");
+ ND_PRINT((ndo, " realm req-subs"));
if (!strcmp(z.opcode, "RLM_SUBSCRIBE"))
- printf(" realm rlm-sub");
+ ND_PRINT((ndo, " realm rlm-sub"));
if (!strcmp(z.opcode, "RLM_UNSUBSCRIBE"))
- printf(" realm rlm-unsub");
+ ND_PRINT((ndo, " realm rlm-unsub"));
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")) {
- printf(" get-client-stats");
+ ND_PRINT((ndo, " get-client-stats"));
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")) {
- printf(" flush_locs");
+ ND_PRINT((ndo, " flush_locs"));
return;
}
!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;
}
}
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)
- printf(" op %s", z.opcode);
- return;
+ ND_PRINT((ndo, " op %s", z.opcode));
}
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 },
#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 },
#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 },
};