--- src/contrib/tcpdump/interface.h 2010-10-29 11:56:04.000000000 -0400 +++ src/contrib/tcpdump/interface.h 2010-12-01 17:39:31.000000000 -0500 @@ -319,6 +319,7 @@ extern void sip_print(const u_char *, u_int); extern void syslog_print(const u_char *, u_int); extern u_int bt_if_print(const struct pcap_pkthdr *, const u_char *); +extern u_int usb_bsd_print(const struct pcap_pkthdr *, const u_char *); extern u_int usb_linux_48_byte_print(const struct pcap_pkthdr *, const u_char *); extern u_int usb_linux_64_byte_print(const struct pcap_pkthdr *, const u_char *); --- src/contrib/tcpdump/print-usb.c 2010-10-29 11:56:04.000000000 -0400 +++ src/contrib/tcpdump/print-usb.c 2010-12-01 18:41:25.000000000 -0500 @@ -32,9 +32,113 @@ #include "interface.h" -#if defined(HAVE_PCAP_USB_H) && defined(DLT_USB_LINUX) +#ifdef HAVE_PCAP_USB_H #include +/* XXX */ +#define DLT_USB_BSD DLT_USB +#ifdef DLT_USB_BSD +#include +#include + +/* returns direction: 1=inbound 2=outbound -1=invalid */ +static int +get_bsd_direction(int transfer_type, int event_type) +{ + int direction; + + direction = -1; + switch (transfer_type) { + case UE_BULK: + case UE_CONTROL: + case UE_ISOCHRONOUS: + switch (event_type) { + case USBPF_XFERTAP_SUBMIT: + direction = 2; + break; + case USBPF_XFERTAP_DONE: + direction = 1; + break; + default: + direction = -1; + } + break; + case UE_INTERRUPT: + switch (event_type) { + case USBPF_XFERTAP_SUBMIT: + direction = 1; + break; + case USBPF_XFERTAP_DONE: + direction = 2; + break; + default: + direction = -1; + } + break; + default: + direction = -1; + } + + return (direction); +} + +static void +usb_bsd_header_print(const struct usbpf_pkthdr *uh) +{ + int direction; + + switch (uh->up_xfertype) { + case UE_ISOCHRONOUS: + printf("ISOCHRONOUS"); + break; + case UE_INTERRUPT: + printf("INTERRUPT"); + break; + case UE_CONTROL: + printf("CONTROL"); + break; + case UE_BULK: + printf("BULK"); + break; + default: + printf(" ?"); + } + + switch (uh->up_type) { + case USBPF_XFERTAP_SUBMIT: + printf(" SUBMIT"); + break; + case USBPF_XFERTAP_DONE: + printf(" COMPLETE"); + break; + default: + printf(" ?"); + } + + direction = get_bsd_direction(uh->up_xfertype, uh->up_type); + if (direction == 1) + printf(" from"); + else if (direction == 2) + printf(" to"); + printf(" %d:%d:%d", le32toh(uh->up_busunit), uh->up_address, uh->up_endpoint & 0x7f); +} + +u_int +usb_bsd_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + + if (h->caplen < sizeof(struct usbpf_pkthdr)) { + printf("[|usb]"); + return(sizeof(struct usbpf_pkthdr)); + } + + usb_bsd_header_print((const struct usbpf_pkthdr *)p); + + return (sizeof(struct usbpf_pkthdr)); +} +#endif /* DLT_USB_BSD */ + +#if defined(DLT_USB_LINUX) || defined(DLT_USB_LINUX_MMAPPED) /* returns direction: 1=inbound 2=outbound -1=invalid */ static int get_direction(int transfer_type, int event_type) @@ -126,6 +230,7 @@ printf(" %d:%d:%d", uh->bus_id, uh->device_address, uh->endpoint_number & 0x7f); } +#ifdef DLT_USB_LINUX /* * This is the top level routine of the printer for captures with a * 48-byte header. @@ -146,6 +251,7 @@ return(sizeof(pcap_usb_header)); } +#endif /* DLT_USB_LINUX */ #ifdef DLT_USB_LINUX_MMAPPED /* @@ -170,5 +276,6 @@ } #endif /* DLT_USB_LINUX_MMAPPED */ -#endif /* defined(HAVE_PCAP_USB_H) && defined(DLT_USB_LINUX) */ +#endif /* defined(DLT_USB_LINUX) || defined(DLT_USB_LINUX_MMAPPED) */ +#endif /* HAVE_PCAP_USB_H */ --- src/contrib/tcpdump/tcpdump.c 2010-10-29 11:56:04.000000000 -0400 +++ src/contrib/tcpdump/tcpdump.c 2010-12-01 18:17:18.000000000 -0500 @@ -288,6 +288,11 @@ { bt_if_print, DLT_BLUETOOTH_HCI_H4_WITH_PHDR}, #endif #ifdef HAVE_PCAP_USB_H +/* XXX */ +#define DLT_USB_BSD DLT_USB +#ifdef DLT_USB_BSD + { usb_bsd_print, DLT_USB_BSD }, +#endif #ifdef DLT_USB_LINUX { usb_linux_48_byte_print, DLT_USB_LINUX}, #endif /* DLT_USB_LINUX */ --- src/lib/libpcap/Makefile 2010-11-01 17:05:00.000000000 -0400 +++ src/lib/libpcap/Makefile 2010-12-01 18:34:43.000000000 -0500 @@ -14,7 +14,7 @@ # Old compatibility headers INCS= pcap.h pcap-int.h pcap-namedb.h pcap-bpf.h -PCAPINCS= pcap/pcap.h pcap/namedb.h pcap/bpf.h +PCAPINCS= pcap/pcap.h pcap/namedb.h pcap/bpf.h pcap/usb.h PCAPINCSDIR= ${INCLUDEDIR}/pcap INCSGROUPS= INCS PCAPINCS --- src/usr.sbin/tcpdump/tcpdump/Makefile 2010-11-01 17:04:58.000000000 -0400 +++ src/usr.sbin/tcpdump/tcpdump/Makefile 2010-12-01 16:55:30.000000000 -0500 @@ -30,8 +30,8 @@ print-sip.c print-sl.c print-sll.c \ print-slow.c print-snmp.c print-stp.c print-sunatm.c print-sunrpc.c \ print-symantec.c print-syslog.c print-tcp.c print-telnet.c print-tftp.c \ - print-timed.c print-token.c print-udld.c print-udp.c print-vjc.c \ - print-vqp.c print-vrrp.c print-vtp.c \ + print-timed.c print-token.c print-udld.c print-udp.c print-usb.c \ + print-vjc.c print-vqp.c print-vrrp.c print-vtp.c \ print-wb.c print-zephyr.c setsignal.c tcpdump.c util.c \ print-smb.c signature.c smbutil.c \ version.c --- src/usr.sbin/tcpdump/tcpdump/config.h 2010-11-01 17:04:58.000000000 -0400 +++ src/usr.sbin/tcpdump/tcpdump/config.h 2010-12-01 16:53:43.000000000 -0500 @@ -174,7 +174,7 @@ #define HAVE_PCAP_LIB_VERSION 1 /* Define to 1 if you have the header file. */ -/* #undef HAVE_PCAP_USB_H */ +#define HAVE_PCAP_USB_H 1 /* Define to 1 if you have the `pfopen' function. */ /* #undef HAVE_PFOPEN */