From: Michael Richardson Date: Sun, 10 Jan 2010 19:36:07 +0000 (-0500) Subject: This commit makes ipnet_if_print the first NDO aware top-level X-Git-Tag: tcpdump-4.1.0~44 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/b45fabd132061f97cee56458ef623d9063190833 This commit makes ipnet_if_print the first NDO aware top-level printer. Merge commit 'origin/master' Conflicts: netdissect.h --- b45fabd132061f97cee56458ef623d9063190833 diff --cc netdissect.h index 86b66a09,dd9f4b96..7e87555c --- a/netdissect.h +++ b/netdissect.h @@@ -437,9 -437,6 +437,8 @@@ extern void lwres_print(netdissect_opti extern void pptp_print(netdissect_options *,const u_char *, u_int); #endif - extern void ipnet_print(netdissect_options *,const u_char *, u_int, u_int); +extern u_int ipnet_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *); + #if 0 #ifdef INET6 extern void ip6_print(netdissect_options *,const u_char *, u_int); diff --cc print-ipnet.c index 32aaeae6,3a5b5a1a..957bd4f5 --- a/print-ipnet.c +++ b/print-ipnet.c @@@ -91,9 -91,9 +91,10 @@@ ipnet_print(struct netdissect_options * * is the number of bytes actually captured. */ u_int - ipnet_if_print(struct netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) -ipnet_if_print(const struct pcap_pkthdr *h, const u_char *p) ++ipnet_if_print(struct netdissect_options *ndo, ++ const struct pcap_pkthdr *h, const u_char *p) { - ipnet_print(gndo, p, h->len, h->caplen); + ipnet_print(ndo, p, h->len, h->caplen); return (sizeof(ipnet_hdr_t)); } diff --cc tcpdump.c index b0c5ad6c,d50feb08..c60cb6b4 --- a/tcpdump.c +++ b/tcpdump.c @@@ -268,35 -259,37 +268,41 @@@ static struct printer printers[] = { juniper_services_print, DLT_JUNIPER_SERVICES }, #endif #ifdef DLT_JUNIPER_ETHER - { juniper_ether_print, DLT_JUNIPER_ETHER }, + { juniper_ether_print, DLT_JUNIPER_ETHER }, #endif #ifdef DLT_JUNIPER_PPP - { juniper_ppp_print, DLT_JUNIPER_PPP }, + { juniper_ppp_print, DLT_JUNIPER_PPP }, #endif #ifdef DLT_JUNIPER_FRELAY - { juniper_frelay_print, DLT_JUNIPER_FRELAY }, + { juniper_frelay_print, DLT_JUNIPER_FRELAY }, #endif #ifdef DLT_JUNIPER_CHDLC - { juniper_chdlc_print, DLT_JUNIPER_CHDLC }, + { juniper_chdlc_print, DLT_JUNIPER_CHDLC }, #endif #ifdef DLT_MFR - { mfr_if_print, DLT_MFR }, + { mfr_if_print, DLT_MFR }, #endif #if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H) - { bt_if_print, DLT_BLUETOOTH_HCI_H4_WITH_PHDR}, + { bt_if_print, DLT_BLUETOOTH_HCI_H4_WITH_PHDR}, #endif #if defined(HAVE_PCAP_USB_H) && defined(DLT_USB_LINUX) - { usb_linux_print, DLT_USB_LINUX}, + { usb_linux_print, DLT_USB_LINUX}, #endif #if defined(HAVE_PCAP_USB_H) && defined(DLT_USB_LINUX_MMAPPED) - { usb_linux_print, DLT_USB_LINUX_MMAPPED}, + { usb_linux_print, DLT_USB_LINUX_MMAPPED}, #endif + { NULL, 0 }, +}; + +static struct ndo_printer ndo_printers[] = { #ifdef DLT_IPNET - { ipnet_if_print, DLT_IPNET }, + { ipnet_if_print, DLT_IPNET }, + #endif + #ifdef DLT_IPV4 + { raw_if_print, DLT_IPV4 }, + #endif + #ifdef DLT_IPV6 + { raw_if_print, DLT_IPV6 }, #endif { NULL, 0 }, }; @@@ -314,21 -307,10 +320,23 @@@ lookup_printer(int type /* NOTREACHED */ } +static if_ndo_printer +lookup_ndo_printer(int type) +{ + struct ndo_printer *p; + + for (p = ndo_printers; p->f; ++p) + if (type == p->type) + return p->f; + + return NULL; + /* NOTREACHED */ +} + static pcap_t *pd; + static int supports_monitor_mode; + extern int optind; extern int opterr; extern char *optarg;