dect
/
libpcap
Archived
13
0
Fork 0
Commit Graph

196 Commits

Author SHA1 Message Date
Guy Harris fa4435e65c Add support for setting the time stamp type for a capture.
Based on a patch from Scott Mcmillan <scott.a.mcmillan@intel.com>.

(Second part of the commit.)
2010-08-22 17:36:27 -07:00
Guy Harris 3c13ac2cc3 Fix previous checkin. 2010-08-06 14:58:16 -07:00
Jon Smirl 41bfc71e21 Use DLT_IEEE802_15_4_NOFCS for 802.15.4 interfaces.
Reviewed-By: Guy Harris <guy@alum.mit.edu>
2010-08-06 14:43:05 -07:00
Guy Harris 59b866591a Clean up indentation. 2010-05-18 17:50:49 -07:00
andy-1 073a8b37f9 Ignore /sys/net/dev files if we get ENODEV for them, not just ENXIO.
Both of them are indications that there's no such interface, so the file
probably corresponds to something other than a device.

Reviewed-By: Guy Harris <guy@alum.mit.edu>
2010-04-27 23:33:23 -07:00
Christian Bell e1539bdbcb Add Myricom SNF API support as a new pcap device.
This patch adds support for our NICs when run in a specialized capture mode.
It is diffed against the current master.

The Myricom Sniffer10G software uses Myri-10G programmable Network Interface
Cards (NICs), a firmware extension, a specialized driver and a user-level
library (libsnf) to enable sustained capture of 10-Gigabit Ethernet traffic.
Small-packet coalescing and an efficient zero-copy path to host memory allow
Sniffer10G to capture streams at line rate for all Ethernet packet sizes.

Optionally, libpcap can be used concurrently by multiple processes on a single
NIC port to partition the incoming traffic across processes.  While the Linux
kernel enables this through multiple receive queues, the difference is that the
myri_snf driver cooperates with libsnf to set up multiple queues that are each
independently accessible through user-space.

More information here: http://www.myri.com/scs/SNF/doc

Signed-off-by: Guy Harris <guy@alum.mit.edu>
2010-01-26 11:58:37 -08:00
Guy Harris 1715346ad0 Ignore directories in /sys/class/net. 2010-01-10 11:05:00 -08:00
Guy Harris a9a939af2a Correctly handle errors other than problems reading /sys/class/net. 2010-01-10 11:01:56 -08:00
Guy Harris 1eb25ea82a Fix some errors in the previous checkin. 2010-01-10 10:59:22 -08:00
Guy Harris 81a96c3226 Scan /sys/class/net if we have it.
It's a bit easier to scan than /proc/net/dev, as it's a directory.
2010-01-10 10:56:25 -08:00
Guy Harris 2fd233b16d On Linux, always at least try to scan /proc/net/dev.
If we fail to open it, we just drive on, so it's not a fatal error; yes,
it'll slow us down a little, but it's probably not much, and most Linux
kernels probably have it in any case.
2010-01-10 00:32:13 -08:00
Guy Harris 27636b9a98 Include <ctype.h>, as we use macros from it.
Also, use isascii() to avoid surprises from characters with the 8th bit
set, rather than playing signed vs. unsigned character games.
2010-01-09 18:50:52 -08:00
Guy Harris 6831a81489 Scan /proc/net/dev on Linux regardless of how we get the interface list.
It's a Linuxism, so it's not necessary on other platforms, and is useful
even if we have getifaddrs().
2010-01-09 18:46:02 -08:00
Felix Obenhuber 1c1816f670 Add support for CANbus capture.
Signed-off-by: Guy Harris <guy@alum.mit.edu>
2009-12-29 01:04:20 -08:00
Guy Harris 26384d5fc7 Fix typo^Wbraino. 2009-10-12 17:06:11 -07:00
Guy Harris bf7491046a In pcap_read_linux_mmap(), if there are no frames available, call poll()
even if we're in non-blocking mode, to pick up any error indications -
in that case, use a timeout of 0, so poll() doesn't block.

Don't test individual exceptional-condition bits in the poll() return
unless one of them is set, so we just do one test in the typical (no
exceptional condition) case.
2009-10-12 16:24:57 -07:00
Guy Harris e6b89d9420 If we get POLLERR when polling a socket in memory-mapped mode, do a
recv() on the socket to get the error code.
2009-10-11 22:15:24 -07:00
Guy Harris 86ecdb83e0 Fix typo. 2009-10-02 14:07:11 -07:00
Guy Harris e9de4b862e When reading from a BPF device, if we get ENXIO, which means "The device
went down" on at least some OSes, return a message indicating that.

When reading from a Linux PF_PACKET socket, if we get ENETDOWN, which
means "The device went down", return a message indicating that.

When doing a poll() on a PF_PACKET socket, check for various "something
happened on this, but it's not readable" conditions.
2009-10-11 20:12:34 -07:00
Guy Harris 2fbb5a5e31 Copy the right value to the ps_ifdrop statistic. 2009-09-21 10:26:37 -07:00
Guy Harris d2ec25429b Note some other ways to get link statistics. 2009-09-07 17:52:55 -07:00
Guy Harris 806f42441a Note that we might not get an interface drop count from /proc/net/dev. 2009-09-07 16:49:10 -07:00
Guy Harris 2032d35228 From Dustin Spicuzza: support ps_ifdrop on Linux, using /proc/net/dev.
Fix the title of the pcap_stats man page, and give more detail - and a
lot of caveats.
2009-09-07 16:23:15 -07:00
Guy Harris efeaba4650 The pcap_activate() man page says:
If PCAP_WARNING_PROMISC_NOTSUP, PCAP_ERROR_NO_SUCH_DEVICE, or
	PCAP_ERROR_PERM_DENIED is returned, pcap_geterr() or
	pcap_perror() may be called with p as an argument to fetch or
	display an message giving additional details about the problem
	that might be useful for debugging the problem if it's
	unexpected.

but we weren't always setting the error string in question.  Do so.

In pcap_open_live(), if the open fails with PCAP_ERROR, include the
device name in the error string, and if it fails with
PCAP_ERROR_NO_SUCH_DEVICE or PCAP_ERROR_PERM_DENIED, include the device
name and both error messages in the error string.
2009-07-30 20:58:08 -07:00
Guy Harris 6e614204bb Get rid of unused variable. 2009-07-24 12:04:09 -07:00
Guy Harris a5b84cdc4f From Peter Volkov:
Fix typo

    pkt_for_oneshot is not difined anywhere, but oneshot_userdata is.
2009-07-22 23:53:22 -07:00
Guy Harris 6de2dedb10 Fix typo. 2009-07-16 15:10:42 -07:00
Guy Harris 34e950492a When doing Linux mmapped capture:
Allocate a buffer into which to copy a packet, and have the
	callback for pcap_next() and pcap_next_ex() copy to that buffer
	and return a pointer to that buffer; we can't return the packet
	data pointer passed to the callback, as, once the callback
	returns, that buffer can be overwritten, even before you read
	the next packet.

	Don't tweak filter programs passed into the kernel to return
	65535 on success - we don't have to, as we're not reading
	packets with recvfrom(), and we don't want to, as, if we return
	the actual snapshot length, the kernel will copy less data to
	the ring buffer.

	Truncate the packet snapshot length to the specified length, as
	we might not have a filter to do that.
2009-07-16 15:08:12 -07:00
Guy Harris f27e3da547 From Dustin Spicuzza:
- Fixed bug where create_ring would fail for particular snaplen and
  buffer size combinations
- Changed ring allocation to retry with 5% less buffer size instead of
  50%
2009-07-15 13:16:36 -07:00
Guy Harris 6796b164fd Get rid of an assigned-to-but-unused variable. 2009-07-11 14:06:57 -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 1f14841bc0 In memory-mapped mode, when turning non-blocking mode on when it's off,
map all non-negative timeouts, including 0, to negative values, so that,
even with no timeout set, non-blocking mode will skip the poll() call.
2009-07-06 11:35:52 -07:00
Guy Harris 8844f5bad8 Squelch some compile warnings with older Linux kernels. 2009-07-04 14:17:36 -07:00
Guy Harris 703acf10e7 Not releasing a packet in Linux memory-mapped mode until we try to read
the next packet breaks select().  Back those changes out; we'll have to
fix the behavior of pcap_next* by making a copy of the packet.
2009-07-03 14:37:06 -07:00
Guy Harris 50894808ec If HAVE_PACKET_AUXDATA isn't defined, don't declare a variable that's
used only if HAVE_PACKET_AUXDATA is defined.
2009-07-02 12:31:02 -07:00
Guy Harris 5d86a7c3b2 Move some more stuff up before the first use. 2009-06-01 13:04:55 -07:00
Guy Harris 9a4ef64d76 Move up the definition of get_mac80211_phydev() before all its uses. 2009-06-01 13:03:05 -07:00
Guy Harris 102c1ff460 When checking whether a device will let you turn monitor mode on, assume
mac80211 devices will, regardless of whether they support the Wireless
Extensions - wmaster devices will let you turn monitor mode on but don't
appear to support the Wireless Extensions.

Support turning on monitor mode with libnl even if we don't have support
for the Wireless Extensions, just in case the Wireless Extensions go
away at some point in the future if every 802.11 device has a mac80211
driver.
2009-06-01 12:56:05 -07:00
Guy Harris 9f59acab41 To put mac80211 devices in monitor mode, create a "monN" device for the
underlying adapter, bring it up, and capture on that.

This means libpcap nees to be linked with -lnl.
2009-05-22 05:50:15 -07:00
Guy Harris dc0da695d7 From a quick look at the hostap driver, it appears that newer versions
support the Radiotap header.
2009-04-07 13:20:07 -07:00
Guy Harris 18d5f5efc1 Don't return PCAP_WARNING if mmapped capturing isn't supported. 2009-03-25 07:21:29 -07:00
Guy Harris 7326e1ad48 prev_pkt is in the pcap_md structure, not the pcap_t structure itself. 2009-03-25 08:53:58 -07:00
Guy Harris 64b88abf98 Move "union thdr" to pcap-int.h, as we use it in pcap-int.h. 2009-03-25 08:48:57 -07:00
Guy Harris 54ef309e92 In memory-mapped mode, don't release the packet as soon as the callback
finishes processing the packet; in some cases, such as pcap_next() and
pcap_next_ex(), the packet data is expected to be available after the
callback returns, and only discarded when the next packet is read.
2009-03-23 23:18:25 -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 0359240b1c From Tobias Poschwatta: correctly check the requested packet directions
when processing packets in memory-mapped mode.
2009-02-14 13:19:13 -08:00
guy ba23aa7b42 OK, let's try another approach - include <linux/if.h> rather than
<net/if.h>, in the hope that

	1) doing so won't cause some problem somewhere

and

	2) it'll have multiple-include protection

(this whole "glibc is a separate project from the kernel, so we'll
duplicate header files" thing has its downsides).
2008-12-14 22:00:57 +00:00
guy 080c13423a It appears that, at least with the 2.6.27.5 kernel (and maybe the 2.6.27
kernel in general), <linux/wireless.h> includes <net/if.h> and you get
multiple-definition errors if you include <net/if.h> before it.  Only
include <net/if.h> if you don't have <linux/wireless.h>.
2008-12-14 20:30:11 +00:00
guy 4486bda92d has_wext() isn't used if IW_MODE_MONITOR isn't defined, so don't define
it if IW_MODE_MONITOR isn't defined.
2008-12-14 20:03:59 +00:00
guy 1187832296 Return -1 for all failures to create a packet ring other than "this
kernel doesn't support the packet ring", and make sure we set
handle->errbuf in all such cases.
2008-11-19 17:36:52 +00:00