extern void hex_print_with_offset(const char *, const u_char *, u_int, u_int);
extern void hex_print(const char *, const u_char *, u_int);
extern void telnet_print(const u_char *, u_int);
-extern int ethertype_print(u_short, const u_char *, u_int, u_int);
extern int llc_print(const u_char *, u_int, u_int, const u_char *,
const u_char *, u_short *);
extern int snap_print(const u_char *, u_int, u_int, u_int);
extern u_int pflog_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int arcnet_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int arcnet_linux_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void ether_print(const u_char *, u_int, u_int,
- void (*)(const u_char *), const u_char *);
-extern u_int ether_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 *bp2);
extern void rrcp_print(netdissect_options *,const u_char *, u_int);
+extern void ether_print(netdissect_options *,
+ const u_char *, u_int, u_int,
+ void (*)(netdissect_options *, const u_char *),
+ const u_char *);
+
+extern u_int ether_if_print(netdissect_options *,
+ const struct pcap_pkthdr *,const u_char *);
+
+extern int ethertype_print(netdissect_options *,u_short, const u_char *,
+ u_int, u_int);
+
/* stuff that has not yet been rototiled */
#if 0
extern void ascii_print(netdissect_options *,u_int);
u_int, u_int);
extern void hex_print(netdissect_options *,const char *, u_int);
extern void telnet_print(netdissect_options *,const u_char *, u_int);
-extern int ethertype_print(netdissect_options *,u_short, const u_char *,
- u_int, u_int);
extern int llc_print(netdissect_options *,
const u_char *, u_int, u_int, const u_char *,
const u_char *, u_short *);
const u_char *);
extern void arcnet_if_print(u_char*,const struct pcap_pkthdr *,const u_char *);
-extern void ether_if_print(u_char *,const struct pcap_pkthdr *,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 *);
p += FIREWIRE_HDRLEN;
ether_type = EXTRACT_16BITS(&fp->firewire_type);
- if (ethertype_print(ether_type, p, length, caplen) == 0) {
+ if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
ap1394_hdr_print((u_char *)fp, length + FIREWIRE_HDRLEN);
"@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.106 2008-02-06 10:47:53 guy Exp $ (LBL)";
#endif
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
};
static inline void
-ether_hdr_print(register const u_char *bp, u_int length)
+ether_hdr_print(netdissect_options *ndo,
+ const u_char *bp, u_int length)
{
register const struct ether_header *ep;
u_int16_t ether_type;
etheraddr_string(EDST(ep)));
ether_type = EXTRACT_16BITS(&ep->ether_type);
- if (!qflag) {
+ if (!ndo->ndo_qflag) {
if (ether_type <= ETHERMTU)
(void)printf(", 802.3");
else
* frame's protocol, and an argument to pass to that function.
*/
void
-ether_print(const u_char *p, u_int length, u_int caplen,
- void (*print_encap_header)(const u_char *), const u_char *encap_header_arg)
+ether_print(netdissect_options *ndo,
+ const u_char *p, u_int length, u_int caplen,
+ void (*print_encap_header)(netdissect_options *ndo, const u_char *), const u_char *encap_header_arg)
{
struct ether_header *ep;
u_int orig_length;
return;
}
- if (eflag) {
+ if (ndo->ndo_eflag) {
if (print_encap_header != NULL)
- (*print_encap_header)(encap_header_arg);
- ether_hdr_print(p, length);
+ (*print_encap_header)(ndo, encap_header_arg);
+ ether_hdr_print(ndo, p, length);
}
orig_length = length;
if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
&extracted_ether_type) == 0) {
/* ether_type not known, print raw packet */
- if (!eflag) {
+ if (!ndo->ndo_eflag) {
if (print_encap_header != NULL)
- (*print_encap_header)(encap_header_arg);
- ether_hdr_print((u_char *)ep, orig_length);
+ (*print_encap_header)(ndo, encap_header_arg);
+ ether_hdr_print(ndo, (u_char *)ep, orig_length);
}
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ndo->ndo_default_print(ndo, p, caplen);
}
} else if (ether_type == ETHERTYPE_8021Q) {
/*
printf("[|vlan]");
return;
}
- if (eflag) {
+ if (ndo->ndo_eflag) {
u_int16_t tag = EXTRACT_16BITS(p);
printf("vlan %u, p %u%s, ",
}
ether_type = EXTRACT_16BITS(p + 2);
- if (eflag && ether_type > ETHERMTU)
+ if (ndo->ndo_eflag && ether_type > ETHERMTU)
printf("ethertype %s, ", tok2str(ethertype_values,"0x%04x", ether_type));
p += 4;
length -= 4;
if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
&extracted_ether_type) == 0) {
/* ether_type not known, print raw packet */
- if (!eflag) {
+ if (!ndo->ndo_eflag) {
if (print_encap_header != NULL)
- (*print_encap_header)(encap_header_arg);
- ether_hdr_print((u_char *)ep, orig_length);
+ (*print_encap_header)(ndo, encap_header_arg);
+ ether_hdr_print(ndo, (u_char *)ep, orig_length);
}
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ndo->ndo_default_print(ndo, p, caplen);
}
} else {
- if (ethertype_print(ether_type, p, length, caplen) == 0) {
+ if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
- if (!eflag) {
+ if (!ndo->ndo_eflag) {
if (print_encap_header != NULL)
- (*print_encap_header)(encap_header_arg);
- ether_hdr_print((u_char *)ep, orig_length);
+ (*print_encap_header)(ndo, encap_header_arg);
+ ether_hdr_print(ndo, (u_char *)ep, orig_length);
}
- 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
-ether_if_print(const struct pcap_pkthdr *h, const u_char *p)
+ether_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
+ const u_char *p)
{
- ether_print(p, h->len, h->caplen, NULL, NULL);
+ ether_print(ndo, p, h->len, h->caplen, NULL, NULL);
return (ETHER_HDRLEN);
}
*/
int
-ethertype_print(u_short ether_type, const u_char *p, u_int length, u_int caplen)
+ethertype_print(netdissect_options *ndo,
+ u_short ether_type, const u_char *p,
+ u_int length, u_int caplen)
{
switch (ether_type) {
case ETHERTYPE_IP:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
return (1);
#ifdef INET6
case ETHERTYPE_IPV6:
- ip6_print(p, length);
+ ip6_print(/*ndo,*/ p, length);
return (1);
#endif /*INET6*/
case ETHERTYPE_ARP:
case ETHERTYPE_REVARP:
- arp_print(gndo, p, length, caplen);
+ arp_print(ndo, p, length, caplen);
return (1);
case ETHERTYPE_DN:
- decnet_print(p, length, caplen);
+ decnet_print(/*ndo,*/p, length, caplen);
return (1);
case ETHERTYPE_ATALK:
- if (vflag)
+ if (ndo->ndo_vflag)
fputs("et1 ", stdout);
- atalk_print(p, length);
+ atalk_print(/*ndo,*/p, length);
return (1);
case ETHERTYPE_AARP:
- aarp_print(p, length);
+ aarp_print(/*ndo,*/p, length);
return (1);
case ETHERTYPE_IPX:
printf("(NOV-ETHII) ");
- ipx_print(p, length);
+ ipx_print(/*ndo,*/p, length);
return (1);
case ETHERTYPE_ISO:
- isoclns_print(p+1, length-1, length-1);
+ isoclns_print(/*ndo,*/p+1, length-1, length-1);
return(1);
case ETHERTYPE_PPPOED:
case ETHERTYPE_PPPOES:
case ETHERTYPE_PPPOED2:
case ETHERTYPE_PPPOES2:
- pppoe_print(p, length);
+ pppoe_print(/*ndo,*/p, length);
return (1);
case ETHERTYPE_EAPOL:
- eap_print(gndo, p, length);
+ eap_print(ndo, p, length);
return (1);
case ETHERTYPE_RRCP:
- rrcp_print(gndo, p - 14 , length + 14);
+ rrcp_print(ndo, p - 14 , length + 14);
return (1);
case ETHERTYPE_PPP:
if (length) {
printf(": ");
- ppp_print(p, length);
+ ppp_print(/*ndo,*/p, length);
}
return (1);
case ETHERTYPE_MPCP:
- mpcp_print(p, length);
+ mpcp_print(/*ndo,*/p, length);
return (1);
case ETHERTYPE_SLOW:
- slow_print(p, length);
+ slow_print(/*ndo,*/p, length);
return (1);
case ETHERTYPE_CFM:
case ETHERTYPE_CFM_OLD:
- cfm_print(p, length);
+ cfm_print(/*ndo,*/p, length);
return (1);
case ETHERTYPE_LLDP:
- lldp_print(p, length);
+ lldp_print(/*ndo,*/p, length);
return (1);
case ETHERTYPE_LOOPBACK:
case ETHERTYPE_MPLS:
case ETHERTYPE_MPLS_MULTI:
- mpls_print(p, length);
+ mpls_print(/*ndo,*/p, length);
return (1);
case ETHERTYPE_LAT:
if (eflag)
fr_hdr_print(length, addr_len, dlci, flags, extracted_ethertype);
- if (ethertype_print(extracted_ethertype,
+ if (ethertype_print(gndo, extracted_ethertype,
p+addr_len+ETHERTYPE_LEN,
length-addr_len-ETHERTYPE_LEN,
length-addr_len-ETHERTYPE_LEN) == 0)
isoclns_print(bp, len, len);
break;
case ETHERTYPE_TEB:
- ether_print(bp, len, len, NULL, NULL);
+ ether_print(gndo, bp, len, len, NULL, NULL);
break;
default:
printf("gre-proto-0x%x", prot);
else if (!eflag)
printf("IP ");
- if ((u_char *)(ipds->ip + 1) > snapend) {
+ if ((u_char *)(ipds->ip + 1) > ndo->ndo_snapend) {
printf("[|ip]");
return;
}
* Cut off the snapshot length to the end of the IP payload.
*/
ipend = bp + ipds->len;
- if (ipend < snapend)
- snapend = ipend;
+ if (ipend < ndo->ndo_snapend)
+ ndo->ndo_snapend = ipend;
ipds->len -= hlen;
printf(")");
}
- if (!Kflag && (u_char *)ipds->ip + hlen <= snapend) {
+ if (!Kflag && (u_char *)ipds->ip + hlen <= ndo->ndo_snapend) {
sum = in_cksum((const u_short *)ipds->ip, hlen, 0);
if (sum != 0) {
ip_sum = EXTRACT_16BITS(&ipds->ip->ip_sum);
p+=l2info.header_len;
/* this DLT contains nothing but raw ethernet frames */
- ether_print(p, l2info.length, l2info.caplen, NULL, NULL);
+ ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL);
return l2info.header_len;
}
#endif
p+=l2info.header_len;
/* this DLT contains nothing but raw Ethernet frames */
- ether_print(p, l2info.length, l2info.caplen, NULL, NULL);
+ ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL);
return l2info.header_len;
}
#endif
extracted_ethertype = EXTRACT_16BITS(p);
/* this DLT contains nothing but raw PPPoE frames,
* prepended with a type field*/
- if (ethertype_print(extracted_ethertype,
+ if (ethertype_print(gndo, extracted_ethertype,
p+ETHERTYPE_LEN,
l2info.length-ETHERTYPE_LEN,
l2info.caplen-ETHERTYPE_LEN) == 0)
if (l2info.direction != JUNIPER_BPF_PKT_IN && /* ether-over-1483 encaps ? */
(EXTRACT_32BITS(l2info.cookie) & ATM2_GAP_COUNT_MASK)) {
- ether_print(p, l2info.length, l2info.caplen, NULL, NULL);
+ ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL);
return l2info.header_len;
}
};
static void
-lane_hdr_print(const u_char *bp)
+lane_hdr_print(netdissect_options *ndo, const u_char *bp)
{
(void)printf("lecid:%x ", EXTRACT_16BITS(bp));
}
* Now print the encapsulated frame, under the assumption
* that it's an Ethernet frame.
*/
- ether_print(p, length, caplen, lane_hdr_print, p - 2);
+ ether_print(gndo, p, length, caplen, lane_hdr_print, p - 2);
}
u_int
* Cisco hardware; the protocol ID is
* an Ethernet protocol type.
*/
- ret = ethertype_print(et, p, length, caplen);
+ ret = ethertype_print(gndo, et, p, length, caplen);
if (ret)
return (ret);
break;
* but used 0x000000 and an Ethernet
* packet type for AARP packets.
*/
- ret = ethertype_print(et, p, length, caplen);
+ ret = ethertype_print(gndo, et, p, length, caplen);
if (ret)
return (ret);
}
/*
* What remains is an Ethernet packet.
*/
- ether_print(p, length, caplen, NULL, NULL);
+ ether_print(gndo, p, length, caplen, NULL, NULL);
return (1);
case PID_RFC2684_802_5_FCS:
caplen -= 4;
goto recurse;
} else {
- if (ethertype_print(ether_type, p, length, caplen) == 0) {
+ if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
sll_print(sllp, length + SLL_HDR_LEN);
if (!suppress_default_print)
default_print(p, caplen);
- } else if (ethertype_print(ether_type, p, length, caplen) == 0) {
+ } else if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
symantec_hdr_print((u_char *)sp, length + sizeof (struct symantec_header));
#ifdef DLT_ARCNET_LINUX
{ arcnet_linux_if_print, DLT_ARCNET_LINUX },
#endif
- { ether_if_print, DLT_EN10MB },
{ token_if_print, DLT_IEEE802 },
#ifdef DLT_LANE8023
{ lane_if_print, DLT_LANE8023 },
};
static struct ndo_printer ndo_printers[] = {
+ { ether_if_print, DLT_EN10MB },
#ifdef DLT_IPNET
{ ipnet_if_print, DLT_IPNET },
#endif