dect
/
libpcap
Archived
13
0
Fork 0
Commit Graph

75 Commits

Author SHA1 Message Date
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
risso ee9e2f0c05 Since the maximum error message size of libpcap is PCAP_ERRBUF_SIZE, this prevents having problems when using printf() to print the buffer, since the buffer will always be zero-terminated. 2002-08-20 15:33:31 +00:00
guy 2f5ea0384c Add prototypes for routines now exported to other parts of libpcap from
"inet.c".
2002-08-02 03:25:32 +00:00
risso 6831542ec7 Added support for Win32, based on WinPcap. 2002-08-01 08:33:01 +00:00
guy 3d856fe865 Leave it up to the platform-dependent "get interface list" code to
figure out how big the addresses are, as the way that's done is, well,
platform-dependent....
2002-07-30 08:12:13 +00:00
guy 2dcac1bb6b Put the different implementations of "pcap_findalldevs()" into separate
source files, rather than having a pile of #ifdefs in "inet.c".  Add
code to the configure script to determine which implementation to use on
the platform for which libpcap is being built.

Add a "pcap_findalldevs()" implementation for Solaris 8 and later that
handles IPv6 addresses.
2002-07-27 18:45:34 +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
itojun 5918c491c1 whitespace cleanup 2002-06-11 17:04:44 +00:00
guy 8d039ab3b6 Define MSG_TRUNC as 0x20 if it's not defined, so that if this is
compiled on a system that doesn't have it, it'll use it on systems that
do have it.

On systems with MSG_TRUNC support (i.e., 2.2 and later kernels), there's
no need to read in the entire packet in order to find out how large it
is, so just allocate a buffer big enough for a snapshot length's worth
of data, and just read that much data.

There's no need for a "readlen" member of the "pcap_md" structure, as
the byte count to "recvfrom()" is just the "bufsize" member of the
"pcap_t" structure.
2001-08-24 07:46:52 +00:00
guy 5b0a98d641 Add support for a new link layer type DLT_LINUX_SLL, for use when doing
live captures with a "cooked" (SOCK_DGRAM) rather than a "raw"
(SOCK_RAW) PF_PACKET socket; it includes a bunch of the fields from the
"struct sockaddr_ll" you get in a "recvfrom()", including the Ethernet
protocol field.

This requires us to rewrite the BPF program if we're stuffing it into
the kernel; as long as we're doing *ex post facto* rewriting, we might
as well also do the "ret <snaplen>" -> "ret 65535" fixup there as well,
rather than in the code generator.
2000-12-21 10:29:21 +00:00
guy c9452a7666 Clean up promiscuous mode, when using SOCK_PACKET, as best we can;
remember which pcap_t's were opened (with SOCK_PACKET) in promiscuous
mode on interfaces not already in promiscuous mode, turn promiscuous
mode off when closing such a pcap_t, and arrange that, when the program
exits, all pcap_t's of that sort not already closed have their
interfaces taken out of promiscuous mode.  (It's not sufficient to do
this on exit - applications may close a pcap_t without exiting, e.g.
Ethereal.)

This won't always work right (if somebody else requests promiscuous mode
after it's opened by libpcap, we'll turn promiscuous mode off when we
close the pcap_t, and if the program doesn't exit cleanly, it won't
clean up the interfaces), but neither of those problems are fixable -
the only way to get things to work correctly is to use PF_PACKET
sockets, which requires a 2.2 or later kernel.

On a 2.0[.x] kernel, when doing a "recvfrom()" on a SOCK_PACKET socket
to read a captured packet, don't pass a byte count value based on the
snapshot length - "recvfrom()" won't return the actual packet length if
you do that.  (2.2 and later kernels will return the actual packet
length if MSG_TRUNC is passed in.)
2000-12-16 10:43:26 +00:00
guy ad7e091f5d Declare "install_bpf_program()" in "pcap-int.h", not "gencode.h"; it has
nothing to do with generating code, and "gencode.h" isn't included by
all "pcap-XXX.c" modules, whilst "pcap-int.h" is.
2000-11-04 10:09:55 +00:00
guy 188fee53cc If we're receiving packets from a PF_PACKET socket, check whether the
interface index of the interface for the packet is the interface index
of the loopback interface and, if it is, check if the packet is an
outgoing packet; if so, ignore it, as we'll also be seeing that packet
as a received packet.

If we don't handle the arphrd type of an interface, and fall back on
cooked mode, report the arphrd type, so we know what type we should
consider supporting (if that type can't be supported well, e.g.  if you
don't get any link-layer header, as happens with PPP, we'd be silent).
2000-10-25 07:46:49 +00:00
guy 7e4d6babb8 Not all systems running on Alpha processors add 3 bytes of padding to
FDDI headers to align the payload on a 4-byte boundary; for example,
Linux/Alpha doesn't appear to do so, which causes filter expressions not
to work correctly on FDDI on Linux/Alpha.

The "__alpha" test was really intended to check for DEC
OSF/1^H^H^H^H^H^H^H^H^HDigital UNIX^H^H^H^H^H^H^H^H^H^H^H^H Tru64 UNIX,
so test "__osf__" instead.
2000-09-19 03:28:10 +00:00
guy 74ab49bec1 Add comments telling people not to gratuitously change the capture file
format (file header or per-packet header format, or interpretation of
any of the fields in those headers) without getting a new magic number
from "tcpdump-workers@tcpdump.org", and to make sure that libpcap can
still read files with the existing magic numbers, not just files with
the new magic number and record formats.

(There have been at least three libpcap changes I know of that have
changed the header formats, or the interpretation of fields in those
headers, without changing the magic number.  I would like not to ever
have any other such changes happen ever again.)
2000-09-14 09:49:28 +00:00
guy 84f822f4d8 Pick up, from the FreeBSD libpcap, changes to surround all declarations with
#ifdef __cplusplus
	extern "C" {
	#endif

		...

	#ifdef __cplusplus
	}
	#endif

so that C++ code can include these header files and correctly call the
C-language routines they declare.
2000-07-29 07:36:41 +00:00
guy 884ed98aed Add support for reading capture files from programs using Alexey
Kuznetzov's patched version of libpcap; we ignore the additional fields
it adds to the per-packet header.  Red Hat Linux 6.2 uses that patched
version, and some other Linux distributions might do so as well.

(This won't handle an early version of his patch, which changed the
per-packet header but didn't change the magic number; that early version
appears in Red Hat Linux 6.1.

Doing that requires a heuristic test, wherein we assume the file is
standard libpcap and try to read the first and second records, and, if
the header of the second record looks like garbage, assume that the file
came from that early version, and that we're therefore reading random
packet data when we think we're reading the header of the second packet.

As we don't then want to seek back to the first packet, because we want
to continue to allow libpcap-based programs such as tcpdump to read from
pipes, we'd have to buffer data from the file so that we can go back and
re-read it.  I leave this for later.)
2000-07-18 03:43:47 +00:00
itojun acc7a22687 re-correct fallback strlcpy(). do not choke on z == 0. 2000-07-04 00:22:03 +00:00
itojun 8cb4bb315b correct fallback strlcpy() macro. 2000-07-04 00:10:47 +00:00
torsten 94de442535 Merged the Linux v2.2 packet support into the main trunk (from
tag linux-2-2-packet). Please test this code :)
2000-06-08 06:40:09 +00:00
itojun c86640a4b3 do not use strlcpy() if the platform does not supply one.
linkage of third-party source code can fail if the third-party code does
not have AC_REPLACE_FUNCS(strlcpy).  (exapmle: ethereal)

XXX the macro is ugly
2000-05-04 13:34:24 +00:00
assar 44a0e923bd (pcap_tinmeval): a new struct with the timeval as it's stored on disk
(pcap_sf_pkthdr): the packet header stored on disk
1999-11-21 01:10:20 +00:00
itojun 7fe3c1111a IPv6 packet filtering code.
./configure --enable-ipv6 (requires getaddrinfo(3) and getnameinfo(3)).

TODO: make it work even without getaddrinfo(3) or getnameinfo(3)
(or, tcpdump/configure.in should provide alternative version by
AC_REPLACE_FUNCS)
TODO: make IPv6 filtering code work by default
TODO: make "protochain" friendly with optimization
1999-10-19 15:18:28 +00:00
mcr b11ddf8a9b Initial revision 1999-10-07 23:46:40 +00:00