dect
/
libpcap
Archived
13
0
Fork 0
Commit Graph

41 Commits

Author SHA1 Message Date
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 1e574aa6fd Indicate when "pcap_next()" returns NULL, and that, unfortunately, you
don't know whether that happens because of an error or because no
packets were available at the time.
2002-12-17 07:32:55 +00:00
guy d1d0fe1d98 Add support for RFC 2625 IP-over-Fibre Channel, mapping all the Linux
ARPHRD_FC* types to it.
2002-10-18 08:46:13 +00:00
guy 7a30eb46ce On Solaris, if the "to_ms" argument is zero, we don't do an SBIOCSTIME;
if, as I suspect is the case, that causes no timeout to be set, and if
that's the same as explicitly clearing the timeout with SBIOCCTIME, that
would appear to mean that it'd wait forever for a full chunk's worth of
packets to arrive.
2002-09-18 19:07:57 +00:00
guy 6782a9f4a7 Document that a zero value of the timeout argument to "pcap_open_live()"
can have one of two different behaviors, depending on the OS (it means
"don't return from a read until enough data has arrived" on BSD and
Digital/Tru64 UNIX, and means "return immediately" on Solaris, for
example, at least according to the man pages on Digital/Tru64 UNIX and
Solaris and the code in BSD).
2002-09-18 18:56:57 +00:00
guy ffabca7439 Emphasize that you get only "caplen" bytes of data in the callback from
"pcap_dispatch()" and "pcap_loop()", give more details on the effect of
the "snaplen" argument to "pcap_open_live()", and suggest 65535 as a
value if you want to capture the entire packet.
2002-09-12 19:42:03 +00:00
guy 23bfb470c5 Explain, in more detail, the "netmask" argument to "pcap_compile()"; in
particular, point out that it's only used when checking for IPv4
broadcast addresses, and that if you don't care whether those checks are
done correctly, you can supply 0 if the netmask isn't known or isn't
available.
2002-09-06 21:14:46 +00:00
guy 243b20ec55 Add SunATM support, based on code from Yen Yen Lim at North Dakota State
University.
2002-07-11 09:06:30 +00:00
guy 0d02000200 Add support for Frame Relay as a link-layer type; the header is the
standard Q.922 Frame Relay header with a 2-byte address field.
2002-07-11 08:12:34 +00:00
guy c546e795dd Expand the description of the arguments to the callback for
"pcap_dispatch()", giving the members of a "struct pcap_pkthdr", and
specifying which of those arguments are "const" pointers.

Describe the return value of "pcap_loop()".
2002-05-22 08:03:36 +00:00
guy 86c2a855bf Minor tweak to the synopsis for "pcap_setnonblock()" to make it look
more like the other synopses, and note that it returns 0 on success.
2001-12-29 21:57:07 +00:00
guy 4ad66bbfb4 Note that "pcap_stats()" isn't supported on savefiles, as savefiles
don't include statistics.
2001-12-10 06:35:00 +00:00
guy fde2e99495 Move the description of "pcap_[sg]etnonblock()" immediately after the
description of the routines to open captures, so that non-blocking mode
is described before "pcap_dispatch()" is described.
2001-12-09 08:58:28 +00:00
guy a82f1618b8 Add APIs to put a "pcap_t" into or out of non-blocking mode, and to get
the current state of non-blocking mode; this allows us to implement, for
example, memory-mapped capture devices, where "pcap_read()" uses
"select()" or "poll()" to wait for packets to arrive, and hide that
implementation detail from applications using this API
("pcap_setnonblock()" would set or clear a non-blocking mode flag in the
"pcap_t", and the "select()" or "poll()" would not be done if the
"pcap_t" is in non-blocking mode).
2001-12-09 05:10:02 +00:00
guy d71c1c4045 In the description of "pcap_datalink()", enumerate the link-layer types,
and give a description of the link-layer header if it's not directly
implied by the link-layer type.
2001-10-28 03:54:57 +00:00
guy db79c69108 Make the "is_loopback" field of a "pcap_if" structure a general "flags"
field, and make a PCAP_IF_LOOPBACK flag be the first flag bit in that
field, specifying whether the interface is a loopback interface; this
allows us to add more flags without changing the layout of the
structure.
2001-10-28 02:31:49 +00:00
guy 6e796fb8ba Fix a typo and a formatting nit. 2001-10-13 06:28:53 +00:00
mcr f3d3a0b363 clarified use of pcap_dump(3) parameters. 2001-10-12 21:43:29 +00:00
guy 9c0a593a2e From Scott Gifford:
Add a new "pcap_findalldevs()" routine to get a list of all
	interfaces that can be opened with "pcap_open_live()", and a
	"pcap_freealldevs()" routine to free the list.

	Make "pcap_lookupdev()" use it, which also arranges that it will
	not return a device that cannot be opened by "pcap_open_live()".

	Allow the "any" device to be opened, on Linux, with "promisc"
	non-zero; ignore the request for promiscuity, and return a
	warning message indicating that promiscuous mode isn't supported
	on the "any" device.

Document "pcap_findalldevs()" and "pcap_lookupdev()", and clean up some
items in the libpcap man page.
2001-10-08 01:06:20 +00:00
guy 0c2cc33435 Fix a typo. 2001-07-04 07:34:50 +00:00
fenner 0cc259467a Allow pcap_open_live() to return warnings in ebuf. 2001-04-30 16:10:51 +00:00
guy 15cc8e524f Fix the man page's description of "pcap_file()" and "pcap_fileno()" to
reflect reality.
2001-03-26 10:21:31 +00:00
guy fa4449caf2 Clarify what "pcap_next()" does, as per a suggestion by Michael T.
Stolarchuk.
2001-02-09 04:50:17 +00:00
guy 1ae6bd52d5 Note that captures on the "any" device won't be done in promiscuous
mode, regardless of the value of "promisc".
2001-01-18 04:41:45 +00:00
guy 71e02cbc34 Update the last modification date. 2001-01-03 22:52:26 +00:00
guy b542949711 Fix the description of "pcap_dispatch()" and "pcap_loop()" to reflect
reality ("pcap_dispatch()", on a live capture, never reads more than one
bufferful of packets).

Break the description of "pcap_dispatch()" into multiple paragraphs.

Move the description of "pcap_loop()" right after the descriptionof
"pcap_dispatch()", and note that "pcap_dump()" can be used as the
callback function for either of them.
2001-01-03 00:57:56 +00:00
guy 70121e5b65 Note that the read timeout in "pcap_open_live()" does *NOT* guarantee
that "pcap_dispatch()" will always return within that many milliseconds;
some platforms don't support a read timeout, meaning the read timeout
argument is ignored, and, on other platforms (SunOS 5.x and possibly
SunOS 4.x and 3.x), the timer starts when the first packet arrives, so
the timeout doesn't expire until at least one packet arrives.
2000-12-28 01:58:05 +00:00
guy 54b79fdd10 Note that:
"pcap_compile()" and "pcap_compile_nopcap()" return -1 on
	failure;

	if "pcap_compile()" or "pcap_setfilter()" fails, you can get the
	error string with "pcap_geterr()";

	if "pcap_compile_nopcap()" fails, you can't get the error
	string, but, as it's just a wrapper around "pcap_open_dead()",
	"pcap_compile()", and "pcap_close()", you can use those routines
	yourself if you want the error string;

	you have to use, or copy, the string you get back from
	"pcap_geterr()" before closing the "pcap_t" you hand to
	"pcap_geterr()", as the string you got back from "pcap_geterr()"
	doesn't remain valid after the "pcap_t" whence you got it is
	closed.
2000-12-12 09:31:45 +00:00
guy 82547471f7 When attaching a "bpf_program" to a "pcap_t" to use as a userland
filter, always attach a copy, as "pcap-linux.c" does; that way, after a
program uses "pcap_setfilter()", it can safely use "pcap_freecode()" to
free up the BPF instructions allocated by "pcap_compile()".  Also,
always free it up when the "pcap_t" is closed.

Get rid of the "pcap_t *" argument to "pcap_freecode()", as it's not
necessary.

Document "pcap_freecode()", for the benefit of programs that might
repeatedly compile filter programs and attach them, so that they can
free them up after attaching them and avoid leaking memory for them.
2000-10-28 00:01:26 +00:00
guy 6251821734 Document that a null pointer or "any", when specified as the "device"
argument to "pcap_open_live()", will, on Linux systems with a 2.2 or
later kernel, snoop on all interfaces.
2000-10-22 02:21:34 +00:00
guy 88541c9adf Get rid of the PCAP_ENCAP_ values - if an application uses them, that
application won't build with any other version of libpcap, which means
that a lot of applications won't use them.  In addition,
"pcap_linktype()" needs to return DLT_ values, so that platforms that
build libpcap as a shared library won't break binary compatibility if
they update to this version of libpcap.

Instead, we map from DLT_ values to LINKTYPE_ values when writing
savefiles, and map from LINKTYPE_ values to DLT_ values when reading
savefiles, so that savefiles don't have platform-dependent DLT_ values
in the header as the link type, they have platform-independent LINKTYPE_
values.

This means we don't need to make DLT_ATM_RFC1483, DLT_RAW, etc. have
platform-independent values starting at 100 - only the values in the
savefile header need to be like that.
2000-10-12 04:12:27 +00:00
guy 781fae3571 Introduce a set of PCAP_ENCAP_ codes to specify packet encapsulations.
For those PCAP_ENCAP_ codes corresponding to DLT_ codes that are
(believed to be) the same in all BSDs, the PCAP_ENCAP_ codes have the
same values as the corresponding DLT_ codes.

For those PCAP_ENCAP_ codes corresponding to DLT_ codes that were added
in libpcap 0.5 as "non-kernel" DLT_ codes, or had their values changed
in libpcap 0.5 in order to cope with the fact that those DLT_ codes
have different values in different systems, the PCAP_ENCAP_ codes have
the same values as the corresponding DLT_ codes.

We add some additional PCAP_ENCAP_ codes to handle IEEE 802.11 (which
currently has its link-layer information turned into an Ethernet header
by at least some of the BSDs, but John Hawkinson at MIT wants to add a
DLT_ value for 802.11 and pass up the full link-layer header) and the
Classical IP encapsulation for ATM on Linux (which isn't always the same
as DLT_ATM_RFC1483, from what I can tell, alas).

"pcap-bpf.c" maps DLT_ codes to PCAP_ENCAP_ codes, so as not to supply
to libpcap's callers any DLT_ codes other than the ones that have the
same values on all platforms; it supplies PCAP_ENCAP_ codes for all
others.

In libpcap's "bpf/net/bpf.h", we define the DLT_ values that aren't the
same on all platforms with the new values starting at 100 (to keep them
out of the way of the values various BSDs might assign to them), as we
did in 0.5, but do so only if they're not already defined; platforms
with <net/bpf.h> headers that come with the kernel (e.g., the BSDs)
should define them with the values that they have always had on that
platform, *not* with the values we used in 0.5.

(Code using this version of libpcap should check for the new PCAP_ENCAP_
codes; those are given the values that the corresponding DLT_ values had
in 0.5, so code that checks for them will handle 0.5 libpcap files
correctly even if the platform defines DLT_RAW, say, as something other
than 101.  If that code also checks for DLT_RAW - which means it can't
just use a switch statement, as DLT_RAW might be defined as 101 if the
platform doesn't itself define DLT_RAW with some other value - then it
will also handle old DLT_RAW captures, as long as they were made on the
same platform or on another platform that used the same value for
DLT_RAW.  It can't handle captures from a platform that uses that value
for another DLT_ code, but that's always been the case, and isn't easily
fixable.)

The intent here is to decouple the values that are returned by
"pcap_datalink()" and put into the header of tcpdump/libpcap save files
from the DLT_ values returned by BIOCGDLT in BSD kernels, allowing the
BSDs to assign values to DLT_ codes, in their kernels, as they choose,
without creating more incompatibilities between tcpdump/libpcap save
files from different platforms.
2000-09-17 04:04:36 +00:00
guy 099d57bfe9 Give it an SCCS/RCS ID.
Update the date.

Fix a couple of typos.
2000-07-25 06:20:37 +00:00
guy e7039d24f4 Merge in changes from the libpcap 0.5 branch:
Update to note that non-patch mail should be sent to
	"tcpdump-workers@tcpdump.org", and that patches should be sent to
	"patches@tcpdump.org".
2000-07-13 06:24:14 +00:00
assar 3e80c2e1e6 add pcap_open_dead 2000-06-26 08:14:48 +00:00
mcr 106dac54fb doc edits from Guy Harris and MCR 2000-06-16 17:50:17 +00:00
mcr b0c7a34385 *** empty log message *** 2000-06-11 16:46:21 +00:00
itojun 466c37aaa3 s/PCAP_ERRBUFF_SIZE/PCAP_ERRBUF_SIZE/ (fatal typo) 2000-04-27 14:24:11 +00:00
itojun 20d9e08cde do not use sprintf(). always use snprintf().
from NetBSD/OpenBSD src/lib/libpcap.

use freeifaddrs() if exists.
2000-04-27 09:11:11 +00:00
mcr e660fb6947 This adds a new function that allows using the bpf compiler without
having a pcap open.  One could argue that this and the existing
	compiler should be factored in common routines, but I was trying to
	make it clear that this wouldn't break the existing code.
	from Greg Troxel <gdt@ir.bbn.com>
1999-12-08 19:54:03 +00:00
mcr b11ddf8a9b Initial revision 1999-10-07 23:46:40 +00:00