dect
/
libpcap
Archived
13
0
Fork 0
Commit Graph

43 Commits

Author SHA1 Message Date
Guy Harris b019cc06cb Check whether we have <linux/compiler.h>.
Not all distributions have it in /usr/include; I guess the ones that
don't have it have versions of other kernel headers that don't require
it.
2010-11-25 14:06:01 -08:00
Guy Harris 0920898be2 Include <linux/compiler.h> before including <linux/usbdevice_fs.h>.
Some versions of the Linux kernel require that.
2010-11-25 13:49:16 -08:00
Guy Harris 85089fea57 Do filtering on USB and Bluetooth capturing.
Do the standard userland filtering on USB and Bluetooth captures, rather
than returning "success" when the filter is installed without doing
anything with the filter.

Also, squelch some "dereferencing type-punned pointer will break
strict-aliasing rules" warnings in pcap-bt-linux.c, by using memcpy
rather than pointer-casting.
2010-06-04 10:48:16 -07:00
Guy Harris 62b9af0706 From Márton Németh:
The usbmon text interface was moved from
	/sys/kernel/debug/usbmon to /sys/kernel/debug/usb/usbmon as of
	patch

		http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=f49ce96f11112a84c16ac217490ebd6f8d9a8977 .

	Please add this new directory also into the search list when
	finding USB devices.

Get rid of older address for Gisle Vanem; convert Love's address to
UTF-8 (as it is in the tcpdump CREDITS file).
2009-11-03 14:50:40 -08:00
Guy Harris 71dac45765 If an activate routine fails, it needs to clean up the pcap_t, close
anything it's opened, etc..

In addition, the op pointers need to be restored to the un-activated
state; do that in pcap_activate() if the call to the activate op fails.

Also, in the common cleanup code, set the fd's to -1.
2009-09-21 10:45:09 -07:00
Guy Harris ef9aa50d23 Set ps_ifdrop after ps_drop, so we process the statistics in order. 2009-09-07 16:49:59 -07:00
Guy Harris 3efa666174 For Linux, add to the pcap_md structure a pointer to a memory-mapped
region and the size of the region; use that pointer rather than the bp
or buffer member (that means we don't have to worry about
pcap_cleanup_live_common() attempting to free that buffer).  Use the
saved size when unmapping the memory-mapped region.

Use that for Linux USB memory-mapped access as well - and unmap the
memory-mapped region when we close the pcap_t, because we *do* have to
unmap it.
2009-07-11 11:59:04 -07:00
Guy Harris bbd8be8360 Older Linux kernels have different member names for "struct
usbdevfs_ctrltransfer"; check for that and handle it.

Don't declare variables in the middle of a block; some versions of GCC
appear to warn about that.
2009-07-04 15:04:59 -07:00
Guy Harris 3866e83123 From Roman Francoise: rename the USB-sniffing devices to "usbmonN", so
as not to collide with the "usbN" names for USB-based networking
devices.
2009-03-19 09:37:03 -07:00
Guy Harris 55685bd38c Revert to defining the USB stuff ourselves; whether there's a
<linux/usb_ch9.h> or <linux/usb/ch9.h> header depends on the version of
the kernel (and that assumes that one of those headers is even
installed, which isn't necessarily the case).
2009-01-03 12:12:12 -08:00
guy adcaff491d Get some USB information from <linux/usb/ch9.h> rather than defining it
ourselves.

Add some comments and other tweaks from another of Jon Smirl's patches.
2008-12-23 21:38:50 +00:00
guy a669335415 probe_devices() returns void (if calls fail, we just drive on); don't
try to return a value from it.
2008-12-23 20:55:28 +00:00
guy 5e3edce42f From Jon Smirl: when we start capturing, send GET DESCRIPTOR requests to
all devices on the bus, so we know what's out there already.  Cleaned up
a bit to directly include <linux/usbdevice_fs.h> and *not* to require
the USB library just to supply a header with USB definitions.
2008-12-23 20:49:26 +00:00
guy b908482137 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.
2008-12-23 20:13:29 +00:00
guy 687233847f ps_ifdrop is the number of packets dropped by the interface and not even
handed to the host; ps_drop is the number of packets dropped by the
capture mechanism because it ran out of buffer space.  We don't know the
former, so set it to 0; we *do* know the latter, but it's ps_drop, not
ps_ifdrop.
2008-12-23 19:05:26 +00:00
guy 87d0db882e From Jon Smirl:
try scanning the sysfs USB directory first and, if that
	directory doesn't exist, try the procfs USB directory, to handle
	newer kernels where the relevant director is in sysfs;

	use the data length, not the URB length, as the amount of data
	in the packet (the URB length is the amount of space *available*
	for the data, not the actual amount of data).

For the memory-mapped interface, include the padding after the URB and
setup header in the packet lengths, and return a different link-layer
type so that code reading the packets knows that padding is there.
2008-12-23 18:03:22 +00:00
guy dfc31b2781 From Roberto Mariani: add support for the snapshot length to the
memory-mapped interface.
2008-11-24 18:49:57 +00:00
guy 47dad25d57 From Roberto Mariani: get rid of some unused #defines.
Close the descriptor before returning with PCAP_ERROR_RFMON_NOTSUP.
2008-11-24 18:06:39 +00:00
guy dc52400769 Roberto Mariani:
put the transfer direction in the uppermost bit of the endpoint
	number, rather than the uppermost bit of the transfer type, when
	reading in text mode, just as is the case in binary mode;

	check the URB data length against 0 when deciding whether
	there's no URB tag.
2008-11-24 17:40:19 +00:00
guy 30b39d84b7 Fix typoes (sigh, using both "p" and "handle" for the pcap_t pointer in
different modules can lead to confusion).
2008-04-14 21:06:09 +00:00
guy 2527d1ac88 Turn close_op into cleanup_op; the routine that handles it can also be
used to clean up after a failed pcap_activate() call.  Convert the
existing close_op routines to cleanup_op routines, and use them to clean
up; rename pcap_close_common() to pcap_cleanup_live_common(), and use it
directly if there's no platform-dependent cleanup needed.  That means we
don't have to write the same cleanup code twice (and possibly forget
stuff in the version done on a failed pcap_activate() call).

Have the cleanup routines do whatever is necessary to indicate that
cleanup has been done, and not do any particular cleaning up if it's
already been done (i.e., don't free something if the pointer to it is
null and null out the pointer once it's been freed, don't close an FD if
it's -1 and set it to -1 once it's been closed, etc.).

For device types/platforms where we don't support monitor mode, check
for it and return PCAP_ERROR_RFMON_NOTSUP - but do so after we've
checked whether we can open the device, so we return "no such device" or
"permission denied" rather than "that device doesn't support monitor
mode" if we can't open the device in the first place.

Fix a comment.
2008-04-14 20:40:58 +00:00
guy d9b420231a From Paolo Abeni and me: split pcap_open_live() into a "get a pcap_t
handle" routine, an 'activate a pcap_t handle" routine, and some "set
the properties of the pcap_t handle" routines, so that, for example, the
buffer size can be set on a BPF device before the device is bound to an
interface.

Add additional routines to set monitor mode, and make at least an
initial attempt at supporting that on Linux, *BSD, and Mac OS X 10.4 and
10.5.  (Very much "initial" for Linux, which is a twisty little maze of
wireless drivers, many different.)

Have a "timeout" member of the pcap_md structure on all platforms, use
that on Windows instead of the "timeout" member of the pcap_t structure,
and get rid of the "timeout" member of that structure.
2008-04-04 19:37:44 +00:00
guy 988bc0da21 Treat a max_packets value of 0 the same way that we treat a max_packets
value of -1.
2008-02-02 20:50:31 +00:00
guy 1952d35b37 Handle the case where mmap()ped access to the USB buffer is used;
hopefully I'm inferring correctly from the mon_bin_poll() routine that,
even with purely-mmapped access, you can use select() or poll() to wait
for packets to arrive.
2007-12-14 08:02:40 +00:00
guy 25ccbe6e86 Don't use handle->fd before you've set it. 2007-12-14 07:52:32 +00:00
guy 82fa7a2f43 From Paolo Abeni: fix some comments. 2007-12-13 17:28:38 +00:00
guy baa8f1a126 From Kris Katterjohn, with some additional changes from Paolo Abeni: fix
some sscanf() calls:

	The first change involves a sscanf() that has '%n' in the format
	string, which shouldn't be checked for in the return value
	(stored in "ntok").  This is done correctly elsewhere in the code
	(and even commented on) such that the return value is checked for
	everything but the %n modifier.

	And a few lines after this, a sscanf() is done for '%d' and the
	return value is stored in "ret".  However, the same exact line
	from the above mishap is used here, not even checking the right
	variable or number of conversions! It checks "ntok" for 2 when
	it should check "ret" for 1.
2007-11-30 19:53:06 +00:00
guy 7b5c683168 From Paolo Abeni: fix copyrights. 2007-09-14 01:55:49 +00:00
guy 42fe978417 Add RCS IDs. 2007-04-01 21:43:55 +00:00
guy 62bf880d23 From Florent Drouin: don't crash if the open of the USB bus directory
fails.
2007-02-01 03:17:20 +00:00
guy 6db2ddb56a From Paolo Abeni:
The attached patch cleans up usb_platform_finddevs(), removing
	the dependency on debugfs.  There are also some other minor
	cleanups in the pcap-usb-linux.c file (unused variables removed
	and indentation fix).
2007-01-17 19:31:00 +00:00
guy 31d7c82a44 Use DLT_USB_LINUX as the link-layer type, as we now supply the Linux
header.
2006-12-20 08:21:10 +00:00
guy d959f6403d From Paolo Abeni: add support for the binary USB sniffing interface in
Linux.  The USB sniffing code for Linux now supplies a per-packet header
based on the one supplied by the Linux binary sniffing interface, so we
add a new DLT_ value and use that.

Fix his e-mail address, and add him to the credits.
2006-12-20 03:30:32 +00:00
guy ed2b2e24ef Capitalize "USB". 2006-12-04 23:01:25 +00:00
guy 24f60579bc From Paolo Abeni:
The attached patch fix an off by one in current usb sniffing
	code.  It also substitute the kernel-provided timestamp with
	gettimeofday.  The kernel provided timestamp use 32 bits to
	represent a struct timeval (8 bits for tv_sec and 24 for
	tv_usec), so it's content is quite misleading.
2006-10-15 18:20:26 +00:00
guy 455aff8ba9 Move the Linux Bluetooth and USB declarations to a header file.
Clean up some comments.

Protect all references to the USB stuff from the common Linux code with
PCAP_SUPPORT_USB, just as references to the Bluetooth code are protected
with PCAP_SUPPORT_BT.
2006-10-13 17:46:45 +00:00
guy 50ce2663e8 From Paolo Abeni: Bluetooth support. 2006-10-13 17:34:53 +00:00
guy 08f2f1703b From Paolo Abeni:
The attached patch fix the parsing of setup data fields in current
implementation of usb_read_data.

Currently the "setup header is present" field is not marked so the
relevant fields are ignored from caller.

The patch contains also a little indentation fix, always in the same
function.
2006-10-12 08:04:08 +00:00
guy efab3781c8 From Paolo Abeni: the USB setup header is defined in the USB
specification with a specific layout; use that layout.
2006-10-11 09:22:27 +00:00
guy a631fe8a83 From Paolo Abeni: fix a compile problem. 2006-10-05 17:51:01 +00:00
guy 748adf9a88 From Paolo Abeni - fix a couple of problems:
- the snaplen parameter is just ignored.
	- the raw data received from usb port is partially corrupted.
2006-10-05 16:22:52 +00:00
guy 084bcf12ea Put the public libpcap headers into a pcap subdirectory in both the
source directory and the target include directory, and have include
files at the top-level directory to include those headers, for backwards
compatibility.

Update the FILES and INSTALL.txt files to reflect current reality.
2006-10-04 18:09:21 +00:00
hannes dc03d28d88 from Paolo Abeni <paolo.abeni@email.com>: USB capturing support on linux 2006-10-04 15:50:26 +00:00