From b9084821372f987dbc1eccec360e2f3eadb270aa Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 23 Dec 2008 20:13:29 +0000 Subject: [PATCH] Update CHANGES for USB fixes. Update CREDITS to give Jon Smirl credit for some of the USB fixes. Rename DLT_USB_LINUX_MMAP to DLT_USB_LINUX_MMAPPED, and declare a structure for the header of packets in DLT_USB_LINUX_MMAPPED captures. --- CHANGES | 5 +++-- CREDITS | 1 + gencode.c | 6 +++--- pcap-usb-linux.c | 8 ++++---- pcap.c | 4 ++-- pcap/bpf.h | 4 ++-- pcap/usb.h | 26 +++++++++++++++++++++----- savefile.c | 12 ++++++------ 8 files changed, 42 insertions(+), 24 deletions(-) diff --git a/CHANGES b/CHANGES index 4910100..5bf491d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,6 @@ -@(#) $Header: /tcpdump/master/libpcap/CHANGES,v 1.71 2008-12-15 00:27:54 guy Exp $ (LBL) +@(#) $Header: /tcpdump/master/libpcap/CHANGES,v 1.72 2008-12-23 20:13:29 guy Exp $ (LBL) -Mon. December 15, 2008. ken@netfunctional.ca. Summary for 1.0.1 libpcap release +Tue. December 23, 2008. ken@netfunctional.ca. Summary for 1.0.1 libpcap release Install headers unconditionally, and include vlan.h/bluetooth.h if enabled Autoconf fixes+cleanup Support enabling/disabling bluetooth (--{en,dis}able-bluetooth) @@ -10,6 +10,7 @@ Mon. December 15, 2008. ken@netfunctional.ca. Summary for 1.0.1 libpcap rel attempt to open it in Monitor mode Add support for snapshot length for USB Memory-Mapped Interface Fix configure and build on recent Linux kernels + Fixes for Linux USB capture DLT: Add DLT_LINUX_EVDEV DLT: Add DLT_GSMTAP_UM DLT: Add DLT_GSMTAP_ABIS diff --git a/CREDITS b/CREDITS index e940731..f19de4d 100644 --- a/CREDITS +++ b/CREDITS @@ -58,6 +58,7 @@ Additional people who have contributed patches: Joerg Mayer John Bankier Jon Lindgren + Jon Smirl Juergen Schoenwaelder Jung-uk Kim Kazushi Sugyo diff --git a/gencode.c b/gencode.c index b39d6f3..d3cd009 100644 --- a/gencode.c +++ b/gencode.c @@ -21,7 +21,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.308 2008-12-23 18:03:22 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.309 2008-12-23 20:13:29 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -1508,7 +1508,7 @@ init_linktype(p) off_nl_nosnap = -1; return; - case DLT_USB_LINUX_MMAP: + case DLT_USB_LINUX_MMAPPED: /* * Currently, only raw "link[N:M]" filtering is supported. */ @@ -3370,7 +3370,7 @@ gen_linktype(proto) case DLT_USB: case DLT_USB_LINUX: - case DLT_USB_LINUX_MMAP: + case DLT_USB_LINUX_MMAPPED: bpf_error("USB link-layer type filtering not implemented"); case DLT_BLUETOOTH_HCI_H4: diff --git a/pcap-usb-linux.c b/pcap-usb-linux.c index e8c3972..d399c75 100644 --- a/pcap-usb-linux.c +++ b/pcap-usb-linux.c @@ -34,7 +34,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/pcap-usb-linux.c,v 1.29 2008-12-23 19:05:26 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-usb-linux.c,v 1.30 2008-12-23 20:13:29 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -255,7 +255,7 @@ usb_activate(pcap_t* handle) /* binary api is available, try to use fast mmap access */ if (usb_mmap(handle)) { - handle->linktype = DLT_USB_LINUX_MMAP; + handle->linktype = DLT_USB_LINUX_MMAPPED; handle->stats_op = usb_stats_linux_bin; handle->read_op = usb_read_linux_mmap; handle->cleanup_op = usb_cleanup_linux_mmap; @@ -733,8 +733,8 @@ usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_ch clen = hdr->data_len; /* get packet info from header*/ - pkth.caplen = clen + MMAPPED_USB_HEADER_SIZE; - pkth.len = hdr->data_len + MMAPPED_USB_HEADER_SIZE; + pkth.caplen = clen + sizeof(pcap_usb_header_mmapped); + pkth.len = hdr->data_len + sizeof(pcap_usb_header_mmapped); pkth.ts.tv_sec = hdr->ts_sec; pkth.ts.tv_usec = hdr->ts_usec; diff --git a/pcap.c b/pcap.c index b51bbf2..0adbe34 100644 --- a/pcap.c +++ b/pcap.c @@ -33,7 +33,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.127 2008-12-23 18:03:22 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.128 2008-12-23 20:13:29 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -624,7 +624,7 @@ static struct dlt_choice dlt_choices[] = { DLT_CHOICE(DLT_AX25_KISS, "AX.25 with KISS header"), DLT_CHOICE(DLT_IEEE802_15_4_NONASK_PHY, "IEEE 802.15.4 with non-ASK PHY data"), DLT_CHOICE(DLT_MPLS, "MPLS with label as link-layer header"), - DLT_CHOICE(DLT_USB_LINUX_MMAP, "USB with padded Linux header"), + DLT_CHOICE(DLT_USB_LINUX_MMAPPED, "USB with padded Linux header"), DLT_CHOICE_SENTINEL }; diff --git a/pcap/bpf.h b/pcap/bpf.h index bbb8790..e1194bb 100644 --- a/pcap/bpf.h +++ b/pcap/bpf.h @@ -37,7 +37,7 @@ * * @(#)bpf.h 7.1 (Berkeley) 5/7/91 * - * @(#) $Header: /tcpdump/master/libpcap/pcap/bpf.h,v 1.31 2008-12-23 18:03:22 guy Exp $ (LBL) + * @(#) $Header: /tcpdump/master/libpcap/pcap/bpf.h,v 1.32 2008-12-23 20:13:29 guy Exp $ (LBL) */ /* @@ -848,7 +848,7 @@ struct bpf_version { * USB packets, beginning with a Linux USB header, with the USB header * padded to 64 bytes; required for memory-mapped access. */ -#define DLT_USB_LINUX_MMAP 220 +#define DLT_USB_LINUX_MMAPPED 220 /* diff --git a/pcap/usb.h b/pcap/usb.h index 4c038eb..d7de2bd 100644 --- a/pcap/usb.h +++ b/pcap/usb.h @@ -30,7 +30,7 @@ * Basic USB data struct * By Paolo Abeni * - * @(#) $Header: /tcpdump/master/libpcap/pcap/usb.h,v 1.8 2008-12-23 18:12:46 guy Exp $ + * @(#) $Header: /tcpdump/master/libpcap/pcap/usb.h,v 1.9 2008-12-23 20:13:29 guy Exp $ */ #ifndef _PCAP_USB_STRUCTS_H__ @@ -68,8 +68,6 @@ typedef struct _usb_setup { /* * Header prepended by linux kernel to each event. * Appears at the front of each packet in DLT_USB_LINUX captures. - * Appears at the front of each packet, followed by padding to a multiple - * of 64 bytes, in DLT_USB_LINUX_MMAP captures. */ typedef struct _usb_header { u_int64_t id; @@ -89,8 +87,26 @@ typedef struct _usb_header { } pcap_usb_header; /* - * In DLT_USB_LINUX_MMAP captures, the header is padded to 64 bytes. + * Header prepended by linux kernel to each event, plus padding in the + * internal buffer. + * Appears at the front of each packet in DLT_USB_LINUX_MMAPPED captures. */ -#define MMAPPED_USB_HEADER_SIZE ((sizeof (pcap_usb_header) + 63) & ~63) +typedef struct _usb_header_mmapped { + u_int64_t id; + u_int8_t event_type; + u_int8_t transfer_type; + u_int8_t endpoint_number; + u_int8_t device_address; + u_int16_t bus_id; + char setup_flag;/*if !=0 the urb setup header is not present*/ + char data_flag; /*if !=0 no urb data is present*/ + int64_t ts_sec; + int32_t ts_usec; + int32_t status; + u_int32_t urb_len; + u_int32_t data_len; /* amount of urb data really present in this event*/ + pcap_usb_setup setup; + u_int8_t padding[16]; +} pcap_usb_header_mmapped; #endif diff --git a/savefile.c b/savefile.c index 59070cd..f6d4101 100644 --- a/savefile.c +++ b/savefile.c @@ -30,7 +30,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.182 2008-12-23 18:03:22 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.183 2008-12-23 20:13:29 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -674,7 +674,7 @@ static const char rcsid[] _U_ = * USB packets, beginning with a Linux USB header, with the USB header * padded to 64 bytes; required for memory-mapped access. */ -#define LINKTYPE_USB_LINUX_MMAP 220 +#define LINKTYPE_USB_LINUX_MMAPPED 220 static struct linktype_map { @@ -992,7 +992,7 @@ static struct linktype_map { { DLT_MPLS, LINKTYPE_MPLS }, /* USB with padded Linux header */ - { DLT_USB_LINUX_MMAP, LINKTYPE_USB_LINUX_MMAP }, + { DLT_USB_LINUX_MMAPPED, LINKTYPE_USB_LINUX_MMAPPED }, { -1, -1 } }; @@ -1564,16 +1564,16 @@ sf_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char *buf, u_int buflen) } /* - * The DLT_USB_LINUX and DLT_USB_LINUX_MMAP headers are in host + * The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host * byte order when capturing (it's supplied directly from a * memory-mapped buffer shared by the kernel). * - * When reading a DLT_USB_LINUX or DLT_USB_LINUX_MMAP capture file, + * When reading a DLT_USB_LINUX or DLT_USB_LINUX_MMAPPED capture file, * we need to convert it from the capturing host's byte order to * the reading host's byte order. */ if (p->sf.swapped && - (p->linktype == DLT_USB_LINUX || p->linktype == DLT_USB_LINUX_MMAP)) { + (p->linktype == DLT_USB_LINUX || p->linktype == DLT_USB_LINUX_MMAPPED)) { pcap_usb_header* uhdr = (pcap_usb_header*) buf; /* * The URB id is a totally opaque value; do we really need to