extern void krb_print(const u_char *);
extern u_int llap_print(const u_char *, u_int);
extern u_int ltalk_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void msdp_print(const unsigned char *, u_int);
extern void nfsreply_print(const u_char *, u_int, const u_char *);
extern void nfsreply_print_noaddr(const u_char *, u_int, const u_char *);
extern void nfsreq_print(const u_char *, u_int, const u_char *);
extern void ns_print(const u_char *, u_int, int);
extern const u_char * ns_nprint (register const u_char *, register const u_char *);
extern void ntp_print(const u_char *, u_int);
-extern u_int null_if_print(const struct pcap_pkthdr *, const u_char *);
extern void openflow_print(const u_char *, const u_int);
extern void ospf_print(const u_char *, u_int, const u_char *);
extern void olsr_print (const u_char *, u_int, int);
extern void lwapp_control_print(const u_char *, u_int, int);
extern void lwapp_data_print(const u_char *, u_int);
extern void eigrp_print(const u_char *, u_int);
-extern void mobile_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 void udld_print(netdissect_options *, const u_char *, u_int);
extern void hsrp_print(netdissect_options *, const u_char *, u_int);
extern void igrp_print(netdissect_options *, const u_char *, u_int);
+extern void msdp_print(netdissect_options *, const u_char *, u_int);
+extern u_int null_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void mobile_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 *);
break;
case IPPROTO_MOBILE:
- mobile_print(ipds->cp, ipds->len);
+ mobile_print(ndo, ipds->cp, ipds->len);
break;
case IPPROTO_PIM:
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
* Deencapsulate and print a mobile-tunneled IP datagram
*/
void
-mobile_print(const u_char *bp, u_int length)
+mobile_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
const struct mobile_ip *mob;
struct cksum_vec vec[1];
mob = (const struct mobile_ip *)bp;
- if (length < MOBILE_SIZE || !TTEST(*mob)) {
- fputs("[|mobile]", stdout);
+ if (length < MOBILE_SIZE || !ND_TTEST(*mob)) {
+ ND_PRINT((ndo, "[|mobile]"));
return;
}
- fputs("mobile: ", stdout);
+ ND_PRINT((ndo, "mobile: "));
proto = EXTRACT_16BITS(&mob->proto);
crc = EXTRACT_16BITS(&mob->hcheck);
}
if (osp) {
- fputs("[S] ",stdout);
- if (vflag)
- (void)printf("%s ",ipaddr_string(&mob->osrc));
+ ND_PRINT((ndo, "[S] "));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "%s ", ipaddr_string(&mob->osrc)));
} else {
- fputs("[] ",stdout);
+ ND_PRINT((ndo, "[] "));
}
- if (vflag) {
- (void)printf("> %s ",ipaddr_string(&mob->odst));
- (void)printf("(oproto=%d)",proto>>8);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "> %s ", ipaddr_string(&mob->odst)));
+ ND_PRINT((ndo, "(oproto=%d)", proto>>8));
}
vec[0].ptr = (const u_int8_t *)(void *)mob;
vec[0].len = osp ? 12 : 8;
if (in_cksum(vec, 1)!=0) {
- (void)printf(" (bad checksum %d)",crc);
+ ND_PRINT((ndo, " (bad checksum %d)", crc));
}
-
- return;
}
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#define MSDP_TYPE_MAX 7
void
-msdp_print(const unsigned char *sp, u_int length)
+msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
{
unsigned int type, len;
- TCHECK2(*sp, 3);
+ ND_TCHECK2(*sp, 3);
/* See if we think we're at the beginning of a compound packet */
type = *sp;
len = EXTRACT_16BITS(sp + 1);
if (len > 1500 || len < 3 || type == 0 || type > MSDP_TYPE_MAX)
goto trunc; /* not really truncated, but still not decodable */
- (void)printf(" msdp:");
+ ND_PRINT((ndo, " msdp:"));
while (length > 0) {
- TCHECK2(*sp, 3);
+ ND_TCHECK2(*sp, 3);
type = *sp;
len = EXTRACT_16BITS(sp + 1);
- if (len > 1400 || vflag)
- printf(" [len %u]", len);
+ if (len > 1400 || ndo->ndo_vflag)
+ ND_PRINT((ndo, " [len %u]", len));
if (len < 3)
goto trunc;
sp += 3;
case 1: /* IPv4 Source-Active */
case 3: /* IPv4 Source-Active Response */
if (type == 1)
- (void)printf(" SA");
+ ND_PRINT((ndo, " SA"));
else
- (void)printf(" SA-Response");
- TCHECK(*sp);
- (void)printf(" %u entries", *sp);
+ ND_PRINT((ndo, " SA-Response"));
+ ND_TCHECK(*sp);
+ ND_PRINT((ndo, " %u entries", *sp));
if ((u_int)((*sp * 12) + 8) < len) {
- (void)printf(" [w/data]");
- if (vflag > 1) {
- (void)printf(" ");
- ip_print(gndo, sp + *sp * 12 + 8 - 3,
+ ND_PRINT((ndo, " [w/data]"));
+ if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, " "));
+ ip_print(ndo, sp + *sp * 12 + 8 - 3,
len - (*sp * 12 + 8));
}
}
break;
case 2:
- (void)printf(" SA-Request");
- TCHECK2(*sp, 5);
- (void)printf(" for %s", ipaddr_string(sp + 1));
+ ND_PRINT((ndo, " SA-Request"));
+ ND_TCHECK2(*sp, 5);
+ ND_PRINT((ndo, " for %s", ipaddr_string(sp + 1)));
break;
case 4:
- (void)printf(" Keepalive");
+ ND_PRINT((ndo, " Keepalive"));
if (len != 3)
- (void)printf("[len=%d] ", len);
+ ND_PRINT((ndo, "[len=%d] ", len));
break;
case 5:
- (void)printf(" Notification");
+ ND_PRINT((ndo, " Notification"));
break;
default:
- (void)printf(" [type=%d len=%d]", type, len);
+ ND_PRINT((ndo, " [type=%d len=%d]", type, len));
break;
}
sp += (len - 3);
}
return;
trunc:
- (void)printf(" [|msdp]");
+ ND_PRINT((ndo, " [|msdp]"));
}
/*
#include <tcpdump-stdinc.h>
-#include <stdio.h>
#include <string.h>
#include "interface.h"
-
-#include "ip.h"
-#ifdef INET6
-#include "ip6.h"
-#endif
#include "af.h"
/*
((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))
static inline void
-null_hdr_print(u_int family, u_int length)
+null_hdr_print(netdissect_options *ndo, u_int family, u_int length)
{
- if (!qflag) {
- (void)printf("AF %s (%u)",
- tok2str(bsd_af_values,"Unknown",family),family);
+ if (!ndo->ndo_qflag) {
+ ND_PRINT((ndo, "AF %s (%u)",
+ tok2str(bsd_af_values,"Unknown",family),family));
} else {
- (void)printf("%s",
- tok2str(bsd_af_values,"Unknown AF %u",family));
+ ND_PRINT((ndo, "%s",
+ tok2str(bsd_af_values,"Unknown AF %u",family)));
}
- (void)printf(", length %u: ", length);
+ ND_PRINT((ndo, ", length %u: ", length));
}
/*
* is the number of bytes actually captured.
*/
u_int
-null_if_print(const struct pcap_pkthdr *h, const u_char *p)
+null_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
u_int family;
if (caplen < NULL_HDRLEN) {
- printf("[|null]");
+ ND_PRINT((ndo, "[|null]"));
return (NULL_HDRLEN);
}
if ((family & 0xFFFF0000) != 0)
family = SWAPLONG(family);
- if (eflag)
- null_hdr_print(family, length);
+ if (ndo->ndo_eflag)
+ null_hdr_print(ndo, family, length);
length -= NULL_HDRLEN;
caplen -= NULL_HDRLEN;
switch (family) {
case BSD_AFNUM_INET:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
#ifdef INET6
case BSD_AFNUM_INET6_BSD:
case BSD_AFNUM_INET6_FREEBSD:
case BSD_AFNUM_INET6_DARWIN:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
#endif
default:
/* unknown AF_ value */
- if (!eflag)
- null_hdr_print(family, length + NULL_HDRLEN);
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_eflag)
+ null_hdr_print(ndo, family, length + NULL_HDRLEN);
+ if (!ndo->ndo_suppress_default_print)
+ ndo->ndo_default_print(ndo, p, caplen);
}
return (NULL_HDRLEN);
*/
ns_print(bp + 2, length - 2, 0);
} else if (sport == MSDP_PORT || dport == MSDP_PORT) {
- msdp_print(bp, length);
+ msdp_print(gndo, bp, length);
} else if (sport == RPKI_RTR_PORT || dport == RPKI_RTR_PORT) {
rpki_rtr_print(bp, length);
}
{ ppp_bsdos_if_print, DLT_PPP_BSDOS },
#endif
{ fddi_if_print, DLT_FDDI },
- { null_if_print, DLT_NULL },
-#ifdef DLT_LOOP
- { null_if_print, DLT_LOOP },
-#endif
{ raw_if_print, DLT_RAW },
{ atm_if_print, DLT_ATM_RFC1483 },
#ifdef DLT_C_HDLC
#endif
#ifdef DLT_IP_OVER_FC
{ ipfc_if_print, DLT_IP_OVER_FC },
+#endif
+ { null_if_print, DLT_NULL },
+#ifdef DLT_LOOP
+ { null_if_print, DLT_LOOP },
#endif
{ NULL, 0 },
};