dect
/
libpcap
Archived
13
0
Fork 0
Commit Graph

88 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
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 b4b664817b Add limited support for reading pcap-ng files.
All sections of the file must have the same byte order, so that the
result of pcap_is_swapped() is the same throughout the file; all
interfaces in the file must have the same link-layer type and snapshot
length, so that pcap_datalink() and pcap_snapshot() can return a single
value for the entire file; and all interfaces must have the same time
resolution and offset.
2010-01-09 16:58:15 -08: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 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
test 32c168dad4 Added a critical section on Windows to make pcap_compile thread safe.
This is a temporary patch that can be removed when we will make the
lexer, parser and code generator fully reentrant.
2009-07-15 11:57:07 -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 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 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 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 73e8fef161 Zero-copy BPF support, from Christian Peron. 2008-09-16 00:20:23 +00:00
guy c6eedee1a5 From Patrick McHardy:
The tpacket_hdr is not clean for 64 bit kernel/32 bit userspace and
is not extendable because the struct sockaddr_ll following it is
expected at a fixed offset.

Linux 2.6.27-rc supports a new tpacket frame header that removes these
two limitations. Convert the mmap ring support to support both formats
and probe for availability of the new version.
2008-08-06 07:49:19 +00:00
guy 83206d9b13 Fix more patches@tcpdump.org references to point to the SourceForge
site.
2008-05-30 01:43:21 +00:00
guy 757827db5f packaging/pcap.spec is generated from packaging/pcap.spec.in; don't
check in the generated version, and don't put it into the distribution.

Fix a bunch of references to tcpdump-workers@tcpdump.org to refer to the
new address, tcpdump-workers@lists.tcpdump.org.

Fix a reference to the pcap man page from the pcap-filter(4) man page.

Note that patches should be submitted on the SourceForge site, not sent
to the spam-trap patches@tcpdump.org list.
2008-05-30 01:35:33 +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 cb44cb0520 Support for libdlpi, and for enabling "passive mode" on Solaris systems
that support it, from Sagun Shakya.
2008-03-13 18:13:57 +00:00
guy f57d847d09 The SITA code in pcap-linux.c shares very little with the Linux code;
move it into pcap-sita.c, and make --with-sita set the pcap type to
"sita", so we build pcap-sita.c instead of, rather than in addition to,
pcap-linux.c.

Use "bpf_u_int32" rather than "ulong" in the SITA code, as it's intended
to be 32 bits long (the "l" in "htonl()" and "ntohl()" is historical -
they work on 32-bit quantities, and the "l" dates back to the days when
32-bit processors were a bit newer and 16-bit Unix was more common).

Those changes also, at least in theory, makes the SITA support work on
other Unix-compatible platforms; note that in README.sita.

Clean up pcap-sita.c, making routines no longer called outside it
static, folding trivial wrappers, and fixing various warnings.

Put the routines used by fad-sita.c and defined by pcap-sita.c into
pcap-sita.h.  Remove from pcap-sita.h the files that are now static to
pcap-sita.c.  Include pcap-sita.h in both fad-sita.c and pcap-sita.c, so
that we do cross-file prototype checking.
2008-01-06 20:23:17 +00:00
guy 3a0937cfba On Win32, have pcap_setbuff, pcap_setmode, and pcap_setmintocopy ops, so
add-on capture mechanisms can supply their own code for that.
2007-10-17 18:52:41 +00:00
guy afbb1ce722 Based on work from Florent Drouin, split the 32-bit link-layer type
field in a capture file into:

	a 16-bit link-layer type field (it's 16 bits in pcap-NG, and
	that'll probably be enough for the foreseeable future);

	a 10-bit "class" field, indicating the group of link-layer type
	values to which the link-layer type belongs - class 0 is for
	regular DLT_ values, and class 0x224 grandfathers in the NetBSD
	"raw address family" link-layer types;

	a 6-bit "extension" field, storing information about the
	capture, such an indication of whether the packets include an
	FCS and, if so, how many bytes of FCS are present.
2007-09-29 19:33:29 +00:00
guy def1775664 We assign the result of sizeof to sf.hdrsize; make it a size_t. 2007-09-29 00:29:14 +00:00
gianluca cb7780ffe0 Added an alternate definition for SWAPLL for Visual Studio 6. VC6 does not
support the LL suffix for 64bit integers.
2007-09-27 18:01:13 +00:00
guy 92aa745a42 Include <pcap/pcap.h>, as that's now where we're putting it. 2007-09-24 23:26:12 +00:00
guy 6b492f4765 <pcap.h> does its own 'extern "C"'ification; move it outside our 'extern
"C"'ification, just in case some libpcap/WinPcap add-on includes C++
code.
2007-09-24 23:24:02 +00:00
guy deed686cc8 On NetBSD, include <sys/param.h>; we need it to declare
__NetBSD_Version__.
2007-03-11 21:44:12 +00:00
guy b4c382fd7e From Paolo Abeni:
The USB pseudo-header in DLT_USB_LINUX captures is in the host
	byte order for the machine on which the capture was done.  When
	reading a capture file, convert the pseudo-header to the host
	byte order of the host on which the file is being read.

	There's a 64-bit quantity in that pseudo-header; move the 64-bit
	byte-swap macro from the DAG code to pcap-int.h for use by other
	code.
2007-01-29 20:08:06 +00:00
gianluca 65518d8b3f Updated the copyright notice. 2006-02-22 17:09:02 +00:00
guy 3adb2d4f0d Clean up some comments, and give more details so people understand what
they do, and don't, have to do about 32-bit vs. 64-bit platforms in
libpcap.
2006-02-09 22:26:12 +00:00
guy 8fe5fce9e4 Don't double-count received packets on Linux systems that support the
PACKET_STATISTICS getsockopt() argument on PF_PACKET sockets.
2005-11-24 19:27:42 +00:00
guy 7f34968ee3 From Stephen Donnelly: updates to the DAG support, to support their
updated API if available.
2005-07-07 06:55:19 +00:00
guy 75b14d240d OK, we'll be putting out 0.9.2 soon, so add the API changes back in
again.
2005-07-07 01:57:00 +00:00
guy 5e92dec088 0.9's already been released, so, for better or worse, we're stuck with
the old names.
2005-07-05 22:31:57 +00:00
guy 727beef298 Rename "direction_t" to "pcap_direction_t", and rename "D_IN" and
"D_OUT" to "PCAP_D_IN" and "PCAP_D_OUT", to avoid potential namespace
collisions, as per a suggestion by Dean Gaudet.
2005-07-05 22:12:17 +00:00
guy e987a615e2 From Pawel Pokrywka: add support for requesting that only received
packets, only sent packets, or all packets be accepted, with an
implementation for Linux.

Add an implementation for BPF platforms that support BIOCSSEESENT.
2005-05-03 18:53:58 +00:00
guy fa084ff222 Define PCAP_FDDIPAD *before* you use it. 2005-04-07 02:47:34 +00:00
mcr 6a1948624f only define PCAPPAD on NetBSD newer than 1.6 2005-04-07 01:24:18 +00:00
guy f8a76d1d76 From Gisle Vanem: MS-DOS support. 2004-12-18 08:52:08 +00:00
guy f4531c5cf3 From Gisle Vanem:
don't include <sys/time.h>, as it's included, if necessary, by
	pcap.h;

	constify some arguments.
2004-12-17 20:32:35 +00:00
guy 3573dfdacc Put the FDDI padding (if any) into the pcap_t structure on platforms
that require it, and make pcap_fddipad private to the code generator, as
that's the only place that needs it (ideally, all *its* state should be
local as well).  This makes opening an FDDI device, on platforms where
the padding is supplied as part of the packet, and opening other types
of devices or opening savefiles in the same program work better, as you
don't have to be sure you compile the filter for a given pcap_t before
opening the next pcap_t.
2004-12-15 00:25:08 +00:00
guy e5aebee6d8 Add a "pcap_close_common()" routine which can be used as the close
routine for some pcap-XXX.c files and can be called by the close routine
in other pcap-XXX.c files.
2004-10-19 07:06:11 +00:00
guy 3a35ed338c From Brian Ginsbach: "dlt_list" is assigned a "u_int *" value, so make
it a "u_int *".
2004-04-07 18:41:00 +00:00
guy cec387867a Add support for sending packets on HP-UX if DL_HP_RAWDLS (for "raw
mode") is defined.
2004-04-03 20:52:41 +00:00
guy 2d2890dd37 Add support for sending packets; includes contributions from Mark
Pizzolato <List-tcpdump-workers@subscriptions.pizzolato.net>.
2004-03-23 19:18:04 +00:00
guy ac7d685b85 "selectable_fd" doesn't make sense on Windows; we no longer set it on
Win32 in "savefile.c", so we no longer need to have it in the structure
on Win32.
2003-12-21 22:00:10 +00:00
risso 671d587acd Define the selectable_fd member of struct pcap in Windows. selectable_fd is needed under Windows for offline captures, if it's not defined, savefile.c refuses to compile. 2003-12-20 10:24:52 +00:00
guy fcadc89577 From Albert Chin <china@thewrittenword.com>: on platforms that lack
"snprintf()", include one in libpcap with the name "pcap_snprintf()", so
applications don't have to supply their own "snprintf()" on those
platforms in order to use libpcap.
2003-12-15 01:35:03 +00:00
guy c98ffbcabf Add a "pcap_get_selectable_fd()" API to get an FD on which you can do a
"select()" or "poll()" - or -1 if that won't work.
2003-11-21 10:19:33 +00:00
guy 2c618b93a0 Add "getnonblock" and "setnonblock" operations, and set the function
pointers appropriately, rather than using #ifdefs and run-time checks.

Get rid of declaration of non-existent "pcap_set_datalink_platform()"
routine.
2003-11-20 02:02:38 +00:00
guy 028bb1b31d From Koryn Grant <koryn@endace.com> - DAG support enhancements and fixes:
Added support for nonblocking operation.

	Added support for processing more than a single packet in
	pcap_dispatch().

	Fixed bug in loss counter code.

	Improved portability of loss counter code (e.g. use UINT_MAX
	instead of 0xffff).

	Removed unused local variables.

	Added required headers (ctype.h, limits.h, unistd.h,
	netinet/in.h).

	Changed semantics to match those of standard pcap on linux.
		- packets rejected by the filter are not counted.
2003-11-20 01:21:25 +00:00