dect
/
libpcap
Archived
13
0
Fork 0
Commit Graph

362 Commits

Author SHA1 Message Date
guy 89c05cd79f <pcap.h> include <sys/time.h>, and "pcap-int.h" includes <pcap.h>, so
there's no need to include <sys/time.h> ourselves.

No UNIX-specific functions are used here, so there's no need to include
<unistd.h>.
2002-04-09 07:49:07 +00:00
guy 5ba1adf267 No UNIX-specific functions are used here, so there's no need to include
<unistd.h>.
2002-04-09 07:44:46 +00:00
guy 55dba26a62 Indicate why we have incomplete definitions for "struct mbuf" and
"struct rtentry" (in <net/if.h> on some systems, e.g.  Digital UNIX 4.0,
there are prototypes for kernel functions that include "struct mbuf *"
and "struct rtentry *" arguments, and they are included even if you're
just user-mode code).

We don't need to include <netinet/if_ether.h> unless we have
"ether_hostton()", and we don't need to include <net/if.h> unless we're
including <netinet/if_ether.h>, and we don't need to define "struct
mbuf" or "struct rtentry" unless we're including <net/if.h>.
2002-04-09 07:41:19 +00:00
guy 9328cdfd19 Indicate why we have incomplete definitions for "struct mbuf" and
"struct rtentry" (in <net/if.h> on some systems, e.g.  Digital UNIX 4.0,
there are prototypes for kernel functions that include "struct mbuf *"
and "struct rtentry *" arguments, and they are included even if you're
just user-mode code).
2002-04-09 07:37:59 +00:00
guy da10d3ec7f Include <netdb.h> before <pcap-namedb.h>, as <netdb.h> is included to
define a structure used by <pcap-namedb.h>, and include <sys/socket.h>
before <netdb.h>, as <sys/socket.h> is included to define a structure
used by <netdb.h> (only a pointer to the first structure is used in
<pcap-namedb.h>, and only a pointer to the second structure is used by
<netdb.h>, so code will compile no matter which order you include them
in, but it's a bit cleaner to include <sys/socket.h> before <netdb.h>
and to include <netdb.h> before <pcap-namedb.h>).  Indicate why we're
including <netdb.h> and <sys/socket.h>.
2002-04-07 00:42:51 +00:00
guy 67a0588585 No need to include <sys/socket.h> twice. 2002-04-07 00:22:30 +00:00
guy 1d35b4b590 Include <netdb.h> before <pcap-namedb.h>, as <netdb.h> is included to
define a structure used by <pcap-namedb.h> (only a pointer to the
structure is used in <pcap-namedb.h>, so code will compile no matter
which order you include them in, but it's a bit cleaner to include
<netdb.h> first).  Indicate why we're including <netdb.h>.
2002-04-07 00:04:37 +00:00
guy 705943d1bc There's no need to include <sys/socket.h> twice. 2002-04-06 23:57:52 +00:00
guy 8d52bdae65 There's no need to include <netdb.h> twice. 2002-04-06 23:27:33 +00:00
guy fdaba9c2a6 <pcap.h> includes <sys/types.h> and <sys/time.h>; there's no need to
include it in these files, as they either include "pcap-int.h", which
includes <pcap.h>, or they include <pcap.h> directly.
2002-03-24 23:21:51 +00:00
guy 7346580de5 Add a LINKTYPE_ value for Fibre Channel, as per a request from Don Lee
<donlee@cray.com>.
2002-03-08 11:24:32 +00:00
guy 5913ea0fe4 Add a DLT_ value for Fibre Channel, as per a request from Don Lee
<donlee@cray.com>.
2002-03-08 11:16:34 +00:00
guy 1e108f2bca Handle 64-bit mode in IRIX, where "snoop_timestamp" in a "struct
snoopheader" is a "struct irix5_timeval" rather than a "struct timeval",
by copying the "tv_sec" and "tv_usec" members of that structure to the
time stamp in a "struct pcap_hdr".
2002-03-08 11:10:40 +00:00
guy 03550aa8e2 Add support for gigabit Ethernet interfaces on SGI machines, from David
Kaelbling <drk@sgi.com>.
2002-03-07 11:39:13 +00:00
guy a579c1219c Support for ARPHRD_RAWHDLC, as used by, for example, the Cyclades PC300
synchronous board in Raw HDLC mode, from Octavian Cerna
<tavy@ylabs.com>.
2002-03-07 11:27:57 +00:00
guy 0c86142e99 From John Bankier <jbankier@rainfinity.com>: the buffer into which we
read packets is "p->bufsize" bytes long, not MAXDLBUF bytes long
("p->bufsize" is set to (MAXDLBUF * sizeof sizeof(bpf_u_int32))), so
supply that as the "maxlen" value in the "data" argument to "getmsg()".
2002-03-05 04:05:56 +00:00
guy c9f3b70d22 The "sbh_timestamp" member of an "sb_hdr" structure isn't necessarily a
"struct timeval" - on Solaris 7 and 8, when compiling in LP64 or I32LPx
mode, it's a "struct timeval32" (presumably so that bufmod doesn't have
to worry about whether the stream is being read by a 32-bit program or a
64-bit program).  Set the "struct timeval" "pkthdr.ts" by copying the
individual members rather than by doing a structure assignment.
2002-02-22 11:49:13 +00:00
guy 6c3ce3a573 Bug fixes from Graeme Hewson <ghewson@cix.compulink.co.uk>:
1. During termination processing set up by atexit() under a 2.0.x
   kernel, if a socket had been previously closed and the handle freed
   due to an error, pcap_close_all() and pcap_close_linux() would
   nevertheless try to work with these structures and then crash.
   pcap_close_linux() is now called directly when necessary during
   error processing.

2. atexit() could get called more than once because the did_atexit
   flag wasn't being set.

3. If iface_get_arptype() returns an error because the ioctl() call
   failed (probably due to "no such device"), live_open_new() now
   returns a fatal error to pcap_open_live() and the call to
   live_open_old() is short-circuited.

4. Applications using libpcap would appear to listen on an interface
   that was down.

   a. iface_bind() and iface_bind_old() now check for pending errors
      after bind().  In turn, pcap_open_live() now returns an error
      status if there was a pending error after bind().

   b. After draining the socket, set_kernel_filter() now checks to see
      if the error was the expected EAGAIN and returns a fatal error
      to pcap_setfilter() if not.  In turn, pcap_setfilter() now
      returns an error status if there was a network error.

5. pcap_setfilter() was putting an error message into errbuf after a
   failed call to install_bpf_program().  This was unnecessary since
   install_bpf_program() puts its own error message into errbuf.
2002-02-22 09:20:11 +00:00
guy bb0918aeef Have "map_arphrd_to_dlt()" take a flag indicating whether it's OK to
return DLT_LINUX_SLL or not, and, if that flag is false, for those
interface types where we'd used DLT_LINUX_SLL, pick a DLT_ type that
works as well as possible in raw mode, or fail.

Pass 1 as that flag if we're using a PF_PACKET socket; pass 0 as that
flag if we're using a PF_INET/SOCK_PACKET socket.

For PF_INET/SOCK_PACKET sockets, try to get the link-layer type and map
it to a DLT_ value *before* turning promiscuous mode on, so that we
don't try to put the interface into promiscuous mode unless we know we
can handle its link-layer type (and thus that we can use the interface).
2002-02-10 00:05:14 +00:00
guy e1f3b3be1a From Solomon Peachy <pizza@shaftnet.org>: Linux 2.4.18pre4 defines
ARPHRD_IEEE80211_PRISM, for sniffing on Prism II-based 802.11 interfaces
and getting the special Prism header, so we should map it to
DLT_PRISM_HEADER.
2002-02-05 05:47:14 +00:00
guy 9f5a39497e Fix a typo in a comment. 2002-02-03 23:03:42 +00:00
guy fcfc446231 From Jan-Philip Velders <jpv@veldersjes.net>: Linux 2.0[.x] kernels
didn't define ARPHRD_HDLC - define it as per Linux 2.1.13, if it's not
defined.

Do the same with ARPHRD_FDDI, as that's not defined by 2.0, either.
2002-02-03 23:02:07 +00:00
guy da21ca14ff Link-layer type 121 reserved for Siemens HiPath HDLC, as per a request
from Tomas Kukosa <tomas.kukosa@anfdata.cz>.
2002-01-25 08:27:33 +00:00
mcr 8219275ef5 #ifdef to work around NetBSD dlt.h problem. 2002-01-22 23:36:19 +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 99f5637e53 Have "pcap_setnonblock()" just return 0 on success, not the new value of
the file descriptor flags; there's no guarantee that it will actually
*affect* the file descriptor flags (consider a memory-mapped capture
mechanism such as the Linux 2.4 mechanism, where all "non-blocking mode"
means is "don't do a 'select()' or 'poll()' if there aren't any new
packets in the memory-mapped buffer") or, in fact, that there are file
descriptor flags to affect (consider WinPcap).
2001-12-29 21:55:32 +00:00
guy 4c16994790 Free up both "registers" (scratch memory locations, really) used by an
arithmetic expression in a filter; otherwise, we leak registers when
compiling arithmetic expressions.
2001-12-18 09:10:49 +00:00
guy e2537440b7 Replace "target_cpu" and "target_os" with "host_cpu" and "host_os", as
per Maciej W. Rozycki's patch.
2001-12-10 08:33:41 +00:00
guy efc02fd2e3 Put more information into the comments for "pcap_stats()". 2001-12-10 07:14:14 +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 1a00bc6928 Fixes from Phil Wood:
Don't subtract "tp_drops" from "tp_packets" - "ps_recv", on BSD,
	at least, includes packets dropped due to lack of buffer space,
	so it should do so on Linux as well.

	The "len" argument to "getsockopt()" is a value-result
	parameter, initially containing the size of the buffer being
	supplied; set it before the call.

	Catch "getsockopt()" errors and, if it's an error other than
	EOPNOTSUPP, return an error.
2001-12-10 05:49:40 +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 b0ea1152b6 Add support for DLT_PRISM_HEADER. 2001-11-30 07:25:48 +00:00
guy cabc9945d9 Add in items for the new savefile types. 2001-11-28 07:16:53 +00:00
guy 87c019c9e2 Reserve link-layer types for Prism II 802.11 chip monitor mode
information plus 802.11 header (as per Tim Newsham's stuff) and for some
flavor of Aironet 802.11 link-layer header (as per Doug Ambrisko's
FreeBSD patches).
2001-11-28 05:50:05 +00:00
guy 4e83ece64c From Maciej W. Rozycki <macro@ds2.pg.gda.pl>: treat all MIPS and SPARC
platforms as always requiring strict alignment, rather than doing
configure-time testing with a sample program.
2001-11-25 02:22:06 +00:00
guy 28e545e149 Note that we now attempt to work around AIX BPF's weirdness, indicate
that there may be compile-time or run-time problems with the
workarounds, suggest that people send in a detailed report and fall back
on DLPI if they have those problems, and suggest that if they construct
fixes for the problems they send them to patches@tcpdump.org.

Fix the white space.
2001-11-17 21:29:58 +00:00
guy 035321a1ac Attempt to work around the ways in which AIX's BPF is unlike BSD's BPF.
Get rid of the mapping of OpenBSD's DLT_LOOP to DLT_NULL; we now handle
DLT_LOOP.
2001-11-17 21:24:09 +00:00
guy ee923fedbb AIX's DLPI devices are, at least in AIX 4.3 and later, in the
"/dev/dlpi" directory, not the "/dev" directory.
2001-11-17 21:07:59 +00:00
fenner e935ae5425 Regenerate. 2001-11-12 22:19:15 +00:00
fenner 93abe845e9 Add comments to BDEBUG and YYDEBUG for autoheader 2001-11-12 22:18:57 +00:00
fenner d1a8dfbe03 Add "const" for autoconf 2.52 compatability. Longer term solution:
go through aclocal.m4 and modernize it.
2001-11-12 22:18:01 +00:00
fenner 4da5bb94e1 Make it easy to turn on optimizer and parser debugging with
--enable-optimizer-dbg and --enable-yydebug
2001-11-12 22:08:46 +00:00
fenner 5795b0ba56 Eliminate duplicate prototypes. 2001-11-12 22:04:23 +00:00
fenner cae054001c Optimize out "jset #0" (always false) and "jset #ffffffff" (always true). 2001-11-12 22:02:50 +00:00
fenner 1c20fa1fee Zero out IPv6 mask before using it. This fixes expressions like
'net 2002::/16', which were previously non-deterministic based on
the previous contents of memory.

Reported by:	Pekka Savola <pekkas@netcore.fi>
2001-11-12 21:59:44 +00:00
fenner 98181e94fc Don't optimize away "sub #0" as it may be required to recognize
the code that is generated for e.g. 'icmp[0] > 0'.
2001-11-12 21:57:06 +00:00
guy 366751fb69 Close a file descriptor leak, as per a patch that comes with Nessus and
Pavel Kankovsky's suggested fix to that patch.
2001-11-11 22:32:28 +00:00
guy 88d9e6cb24 Reserve DLT_ type 118 for Cisco internal use, as per a request from
Gilbert Ramirez of Cisco.

More explicitly reserve 116 and 117 as well.
2001-11-02 08:03:39 +00:00