dect
/
libpcap
Archived
13
0
Fork 0
Commit Graph

71 Commits

Author SHA1 Message Date
guy 0446821e49 Make some arguments const pointers if that makes sense.
Add some additional checks to bpf_validate(), from OpenBSD.

Use bpf_validate() in install_bpf_program(), so we validate programs
even when they're being processed by userland filters; we make
bpf_validate() not reject backward branches, as we use them for the
protochain operator.

For BPF, don't assume that, just because no_optimize was set, we have a
program that we can't hand to the kernel; the user of the application
might have specified no optimization (e.g., tcpdump with -O), or we
might have generated code to handle 802.11 headers (the optimizer can't
handle that code).  Instead, try handing the filter to the kernel and,
if that fails, try it in userland.

Get rid of BPF_MAXINSNS - we don't have a limit on program size in
libpcap.
2008-01-02 04:16:46 +00:00
guy 91326ea08c Don't assume that p->fcode.bpf_insns remains unchanged while processing
a bufferfull of packets - it could get changed in a callback routine.
2007-12-05 23:37:26 +00:00
guy 4f278d5429 Check for "/dev/bpf"; if we find it, use BPF as the capture mechanism,
and assume it's a cloning device.
2007-06-15 17:55:50 +00:00
guy a6186fa56d Pick up changes from NetBSD:
several files:

	date: 2006/02/27 15:53:24;  author: drochner;  state: Exp;
	avoid shadowing globals, for WARNS=2

	date: 2006/02/27 15:55:30;  author: drochner;  state: Exp;
	minor constification, good for WARNS=3 now

	date: 2006/02/27 15:57:17;  author: drochner;  state: Exp;
	NetBSD adaption:

		...

	-const pcap_strerror() for consistency


    gencode.c:

	date: 2006/04/26 09:24:33;  author: tron;  state: Exp;
	Add missing "const" keywords to match declarations in "pcap.h".

	date: 2006/10/15 19:27:21;  author: christos;  state: Exp;
	add a volatile variable to prevent vfork/longjmp clobbering.

    optimize.c:

	date: 2006/05/17 17:48:36;  author: drochner;  state: Exp;
	Make the optimizer use unsigned numbers as the kernel does.
	While it is not agreed on that purely unsigned arithmetics is nice,
	different behaviour of optimized and unoptimized code is less desirable.

    pcap-bpf.c:

	date: 2006/02/27 15:51:38;  author: drochner;  state: Exp;
	pull in from NetBSD's libpcap: use cloning bpf device on NetBSD

Have the configure script check for paths.h, so that we can include it
only if we have it, and use the cloning BPF device only if we're on
NetBSD *and* _PATH_BPF is defined (hopefully this will keep us from
using it on versions of NetBSD that don't have a cloning BPF device; if,
in the future, other OSes with BPF get cloning BPF devices, we can make
this work for them as well).
2007-06-11 10:04:24 +00:00
guy 83a6a8ab27 From Jung-uk Kim: add support for new FreeBSD BIOCSDIRECTION ioctl. 2007-03-26 01:38:25 +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
guy 859204c1e8 From Sam Leffler and Jason Evans: fix the allocation of the buffer for
the list of link-layer types.
2006-01-22 05:28:12 +00:00
guy d9d1f9154e select() should work on BPF devices on Tiger; it's poll() and kqueues
that don't work.
2005-07-10 10:54:45 +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 da6c782f50 Sigh. In OS X 10.4 (and 10.4.1), "select()" and "poll()" don't work on
any character devices, including BPF devices.
2005-06-04 02:51:45 +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 b51227ccf4 Include <sys/cfgodm.h> rather than <odmi.h> in the hopes that it'll
suppress some compiler warnings (and work on AIX 4.3 as well as 5.x).
2005-04-21 02:41:12 +00:00
hannes c71f20189b from TANAKA Shin-ya <zstanaka@archer.livedoor.com>:
fix a typo
2005-04-12 20:46:28 +00:00
guy 16889bae3e On the platforms where we do in-kernel filtering and can read more than
one packet from the kernel at a time, when the filter is changed, clear
the libpcap buffer to discard packets read from the kernel before the
filter was changed.
2005-02-26 21:58:05 +00:00
guy e6c1698e5e Install an initial filter that accepts all packets; you need a filter in
order to tell the kernel what the snapshot length is.
2005-02-24 08:59:38 +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 16aa6d8892 Don't skip the FDDI padding before running a filter in userland - the
filter code was generated assuming that the packet would be preceded by
FDDI padding, if any.
2004-12-14 23:55:30 +00:00
guy 8a3038c58e Strip off the FDDI padding on NetBSD before processing the packet. 2004-12-14 23:33:57 +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 cb55faad8f Rather than not turning the "use complete headers" flag on OS X, we
catch the error you get from unpatched OS X when you turn that flag on,
and, if we get that error, turn the flag off and try again.  This adapts
to systems that have been patched to make that flag work, and would also
adapt to Apple fixing that bug.
2004-10-05 07:23:39 +00:00
guy 82281a6f1e From Matthew Luckie <mjl@luckie.org.nz>: FreeBSD version numbers from
"uname()" end with "-RELEASE" (or "-CURRENT" or "-STABLE" or...), so
check the first 4 characters of the release number string for the
version number followed by "-".
2004-09-15 08:01:21 +00:00
guy b7875f7aec As noted by Rob Deker, we weren't checking the "i"th member of the DLT
list against DLT_EN10MB, we were comparing the list pointer against it.
2004-06-05 00:42:13 +00:00
guy 229ab726f9 Update a comment to suggest how to detect the OS X broken BIOCSHDRCMPLT
at run time, so we automatically adapt to systems with Jeff Nathan's fix
or to future OS X releases if they fix the bug.
2004-03-31 01:03:00 +00:00
guy 55a1578cbe Get rid of an out-of-date comment.
Add a comment noting why we don't do BIOCSHDRCMPLT on OS X.
2004-03-24 19:52:46 +00:00
guy 0efb0602ff From Mark Pizzolato: do a BIOCSHDRCMPLT so that the link-layer header we
supply is sent without the source address being overwritten.
2004-03-24 07:00: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
itojun 86c7fc47a5 TRUE/FALSE may not be defined 2003-12-24 08:26:24 +00:00
guy 619a9fe31b For devices that we have some reason to believe are real live Ethernet
devices, offer DLT_DOCSIS as one of the choices of link-layer type, and
support setting that type as meaning just "set libpcap's notion of the
link-layer type to DLT_DOCSIS" without telling the driver to use
DLT_DOCSIS.
2003-12-18 23:32:31 +00:00
guy 331c11bf5b We use userland filters if the filter contains backward branches (for
protochain); that means we need to do userland filtering, which we
hadn't been doing.
2003-11-22 00:06:05 +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 30e89f192a Add _U_ to "rcsid[]" definitions, to eliminate "unused variable"
warnings from newer versions of GCC.
2003-11-15 23:23:57 +00:00
guy 991d444f71 Add a "pcap_breakloop()" API to break out of the loop in
"pcap_dispatch()" and "pcap_loop()".
2003-11-04 07:05:32 +00:00
guy cd0d893ef9 Add a "read" function pointer to the pcap_t structure, which handles
reading packets from a pcap_t, and make "pcap_read()" call it.  That
removes the last place where we have to check for a pcap_t that refers
to a DAG card rather than a live capture, so get rid of the "is_dag" flag.
2003-07-25 05:32:02 +00:00
guy 08658f1c93 Add a "set_datalink" function pointer to the pcap_t structure, whichhandles
setting a filter for a pcap_t.  Have "pcap_set_datalink()" call it,
rather than explicitly calling "pcap_set_datalink_platform()".
2003-07-25 05:07:01 +00:00
guy cd2807e08d Add a "setfilter" function pointer to the pcap_t structure, which
handles setting a filter for a pcap_t.  Have "pcap_setfilter()" call it,
rather than being a per-platform function.  The per-platform functions
don't need to check for an offline capture any more, as they're not
called for an offline capture (and the ones that just call
"install_bpf_program()" don't need to exist at all).
2003-07-25 04:42:02 +00:00
guy 9792990eb8 Add a "stats" function pointer to the pcap_t structure, which handles
getting statistics for a pcap_t.  Have "pcap_stats()" call it, rather
than being a per-platform function; have stats routines for non-live
pcap_t's that return an error.
2003-07-25 04:04:56 +00:00
guy e648c9e593 Add a "close" function pointer to the pcap_t structure, which handles
the platform-dependent part of closing a pcap_t (and the
live-vs-savefile part as well, so that function must close the file
descriptor and free up any buffers allocated).

In the Digital UNIX support, add in a check for a memory allocation
failure.
2003-07-25 03:25:45 +00:00
guy 77cade932c From Jesper Peterson <jesper@endace.com>: support for capturing from
Endace DAG devices.
2003-07-23 05:29:19 +00:00
guy 27a1815f96 From Shaun Clowes:
It appears that the reason why a read from a BPF device
	sometimes gets EFAULT on AIX might be that the pages into which
	you're reading haven't been ZFODded into existence the first
	time a read is done; "memset()"ting the buffer to all zeroes
	appears to mostly mitigate the problem, so we do that on AIX.

	Fix an error in a "sysconfig()" call.
2003-04-17 06:35:34 +00:00
guy ef67e8fa3f Add support for loopback devices on AIX (under the assumption that they
have a DLT_NULL-style link-layer header).
2003-03-28 08:08:11 +00:00
fenner bb7cf360b1 Don't make the bpf buffer smaller than the default. 2003-02-25 21:58:48 +00:00
guy f4129e990d Use "odm_err_msg()" to get the error message string corresponding to ODM
errors.

Check for "odm_terminate()" failing.

Fix a typo.

Remove spaces between casts and variables, to match the style used
elsewhere.
2003-02-11 06:19:26 +00:00
guy aedf01b20f From Shaun <delius@progsoc.uts.edu.au>: on AIX, load the BPF driver and
create the BPF device nodes if necessary, and rename our "bpf.h" to
"pcap-bpf.h" and install it in "/usr/include", so that "pcap-bpf.c" gets
the system's bpf.h file if it includes <net/bpf.h> - on AIX, it needs to
get an AIX-specific structure from that header in order to support
loading the driver and creating the nodes.

Update "packaging/pcap.spec".
2003-02-11 01:46:05 +00:00
guy 8cd68a0fa4 From Yoann Vandoorselaere <yoann@prelude-ids.org>: make the "device"
argument to "pcap_open_live()" a "const" pointer.

Constify some additional device name arguments, and update the man page
to reflect some arguments that were already consts.
2002-12-22 02:36:48 +00:00
guy 482fa426bc NetBSD support for multiple data link types on an interface, from David
Young <dyoung@ojctech.com>, with some minor changes by Jason R.  Thorpe
<thorpej@netbsd.org>, and further changes by me to support it on BPF
systems lacking BIOCGDLTLIST and other platforms lacking an equivalent
feature.

Update Jason Thorpe's e-mail address (Zembu is going away, if it hasn't
done so already).

Add APIs to map DLT names to DLT values and vice versa.
2002-12-19 09:05:45 +00:00
guy 6d1a64f8b0 From Jon Lindgren <jonl@yubyub.net>, based on a note from Don Ebright
<Don.Ebright@compuware.com>: ignore EFAULT from a BPF read in AIX.
2002-10-08 07:18:07 +00:00
guy 48b3b4cdfb Get rid of an old comment (yes, including <net/if_types.h> is the right
thing to do on AIX to get the IFT_ values, at least on the AIX 4.3.3 or
so that I tried it on), and add some new comments about IBM's tcpdump
forcibly enabling BPF and asking whether AIX uses seconds/nanoseconds or
seconds/microseconds for timeouts.
2002-08-03 20:26:14 +00:00