dect
/
libpcap
Archived
13
0
Fork 0
Commit Graph

157 Commits

Author SHA1 Message Date
Guy Harris dc0da695d7 From a quick look at the hostap driver, it appears that newer versions
support the Radiotap header.
2009-04-07 13:20:07 -07:00
Guy Harris 18d5f5efc1 Don't return PCAP_WARNING if mmapped capturing isn't supported. 2009-03-25 07:21:29 -07:00
Guy Harris 7326e1ad48 prev_pkt is in the pcap_md structure, not the pcap_t structure itself. 2009-03-25 08:53:58 -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 Harris 3866e83123 From Roman Francoise: rename the USB-sniffing devices to "usbmonN", so
as not to collide with the "usbN" names for USB-based networking
devices.
2009-03-19 09:37:03 -07:00
Guy Harris 0359240b1c From Tobias Poschwatta: correctly check the requested packet directions
when processing packets in memory-mapped mode.
2009-02-14 13:19:13 -08:00
guy ba23aa7b42 OK, let's try another approach - include <linux/if.h> rather than
<net/if.h>, in the hope that

	1) doing so won't cause some problem somewhere

and

	2) it'll have multiple-include protection

(this whole "glibc is a separate project from the kernel, so we'll
duplicate header files" thing has its downsides).
2008-12-14 22:00:57 +00:00
guy 080c13423a It appears that, at least with the 2.6.27.5 kernel (and maybe the 2.6.27
kernel in general), <linux/wireless.h> includes <net/if.h> and you get
multiple-definition errors if you include <net/if.h> before it.  Only
include <net/if.h> if you don't have <linux/wireless.h>.
2008-12-14 20:30:11 +00:00
guy 4486bda92d has_wext() isn't used if IW_MODE_MONITOR isn't defined, so don't define
it if IW_MODE_MONITOR isn't defined.
2008-12-14 20:03:59 +00:00
guy 1187832296 Return -1 for all failures to create a packet ring other than "this
kernel doesn't support the packet ring", and make sure we set
handle->errbuf in all such cases.
2008-11-19 17:36:52 +00:00
guy 5cf5f7c1c8 If attempting to turn memory-mapped access on fails for any reason other
than "the kernel doesn't support memory-mapped access to PF_PACKET
sockets", treat that as an error.  If it fails for that reason, don't
leave gunk behind in the pcap_t's error buffer.

Clean up the error messages a bit (the result of strerror() suffices; we
don't need the numeric value of errno, nor do we need the file
descriptor number of the socket on which we're working).
2008-11-19 10:01:30 +00:00
guy 8fa17a5a55 Fix the handling of the "any" device, including making it reject
attempts to open it in monitor mode.
2008-11-19 08:20:39 +00:00
guy 230cdec755 Don't do all the recvmsg() stuff if we don't have "struct
tpacket_auxdata".
2008-10-28 00:50:20 +00:00
guy ff2ebcf09a A pile of comments, from looking at aircrack-ng's airmon-ng, and
experimenting with an adapter with a mac80211 driver.
2008-09-22 01:12:34 +00:00
guy b1a458c84e Check whether the tpacket_auxdata structure has a tp_vlan_tci member
before using that member.

Don't define variables if we aren't going to use them.

If we have an unknown tpacket version (this "can't happen"), return an
error.
2008-08-06 08:29:07 +00:00
guy 8c970e4d60 From Patrick McHardy:
pcap-linux: fix invalid rcvbuf size

Libpcap issues a SO_RCVBUF when the buffer size if unspecified (zero).
The intention is to set it when its *not* zero.
2008-08-06 07:53:34 +00:00
guy 7eb4516342 From Patrick McHardy:
Similar to PACKET_AUXDATA for non-mmaped sockets, the VLAN TCI is
present in a new member of struct tpacket2_hdr. Use it to reconstruct
the VLAN header when necessary.
2008-08-06 07:51:29 +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 e59abf81d3 From Patrick McHardy:
VLAN packets sent over devices supporting VLAN tagging/stripping in
hardware don't have a VLAN header when they are received on packet
sockets. The VLAN TCI is available through the PACKET_AUXDATA cmsg,
reconstruct the entire header when necessary.
2008-08-06 07:45:00 +00:00
guy 59b463d614 From Patrick McHardy: Convert pcap-linux to use recvmsg() as preparation
for using PACKET_AUXDATA cmsgs.
2008-08-06 07:39:44 +00:00
guy 34624f128f When activating a device, return PCAP_ERROR_IFACE_NOT_UP if the device
isn't up, so applications can report that differently from a generic
error (the latter could mean there's a bug somewhere in libpcap).

When capturing on a device without mmap on Linux, ignore ENETDOWN, so
that we can continue to capture traffic if the interface goes down and
comes back up again; comments in the kernel indicate that we'll just
block waiting for packets if we try to receive from a socket that
delivered ENETDOWN, and, if we're using a memory-mapped buffer, we won't
even get notified of "network down" events.
2008-07-01 08:02:33 +00:00
guy ae8f708268 Handle ARPHRD_NONE, used by some tunnel devices, by mapping to DLT_RAW,
as it has a zero-length link-layer header.
2008-06-24 06:44:32 +00:00
guy f35ab115a6 Fix a typo (sigh, using both "p" and "handle" for the pcap_t pointer in
different modules can lead to confusion).
2008-04-14 21:04:51 +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 1fd4389877 Report PCAP_ERROR_PERM_DENIED if you don't have permission to open a
PF_PACKET socket.
2008-04-10 01:26:43 +00:00
guy a590c21380 Add some PCAP_WARNING return values for "success, but you might want to
know that..."; currently, only pcap_activate() returns them, but we
might want some more warning returns for some other calls, such as the
ones that set filters.  It's a little cleaner than "clear out the error
message buffer and, if it's not empty after a successful return, it has
a warning", and a little cleaner than spewing a warning to the standard
error (as that might not be visible to the user if they're running a GUI
application).
2008-04-09 21:26:12 +00:00
guy 216c64a7ce Add an error for "you don't have permission to open that device", as
that often means "sorry, this platform requires you to run as root or to
somehow tweak the system to give you capture privileges", and
applications might want to explain that in a way that does a better job
of letting the user know what they have to do.

Try to return or PCAP_ERROR_PERM_DENIED for open errors, rather than
just returning PCAP_ERROR, so that the application can, if it chooses,
try to explain the error better (as those two errors are the ones that
don't mean "there's probably some obscure OS or libpcap problem", but
mean, instead, "you made an error" or "you need to get permission to
capture").

Check for monitor mode *after* checking whether the device exists in the
first place; a non-existent device doesn't support monitor mode, but
that's because it doesn't, well, exist, and the latter would be a more
meaningful error.

Have pcap_open_live() supply an error message for return values other
than PCAP_ERROR, PCAP_ERROR_NO_SUCH_DEVICE, and PCAP_ERROR_PERM_DENIED -
those all supply error strings (PCAP_ERROR because it's for various OS
problems that might require debugging, and the other two because there
might be multiple causes).
2008-04-09 19:58:02 +00:00
guy b95b96d6da For Linux non-mmapped captures, Linux bluetooth captures, and Irix
captures, set the socket buffer size to the value specified by
pcap_set_buffer_size() if a value was set.

Clean up if memory buffer allocation fails on Linux.
2008-04-07 03:57:32 +00:00
guy 3df4925c28 Free the memory allocated for the Wireless Extensions private ioctl list
before returning.
2008-04-07 00:31:47 +00:00
guy 653586c5f7 The value you get back from a SIOCGIWPRIV querying how much stuff you
get back is in units of struct iw_priv_args, not in units of bytes.
2008-04-04 20:51:43 +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 45191202aa From Kris Katterjohn: explicitly check for socklen_t, don't just assume
glibc is the only Linux libc that defines socklen_t.
2008-03-14 09:09:13 +00:00
guy b3366dd5b4 From Hagen Paul Pfeifer: define some routines as static, to match the
way they're declared (and the way they're intended to be).
2008-02-08 01:34:49 +00:00
guy a27e58b244 Error messages returned in the pcap_t's error buffer shouldn't have a
newline in them.

If we're in cooked mode, the packet pointer argument we pass to the callback
should point to the beginning of the constructed sll header, not to the
packet data itself.  While we're at it, have a paranoid check to make
sure that we were given enough space to construct the sll header, so we
don't stomp on the tpacket header.
2008-02-02 22:25:51 +00:00
guy 92e587e157 From Alexander 'Leo' Bergolth: fix a typo.
Slightly obscure the e-mail addresses (better late than never, I guess).
2008-02-02 21:27:28 +00:00
guy 2acadd544c Treat a max_packets value of 0 the same way that we treat a max_packets
value of -1.
2008-02-02 20:56:48 +00:00
guy c0b1d4703d map_packet_type_to_sll_type() isn't used - and won't compile - if you
don't have PF_PACKET support; #ifdef it out.

Move the code to compute the buffer size into live_open_new() and
live_open_old(), as it's dependent on the mechanism being used; there's
little code shared between the two variants.
2008-01-24 20:20:08 +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 92c5d33d7a From Paolo Abeni: support for a memory-mapped capture buffer. 2008-01-05 22:32:31 +00:00
guy 5bf51391d4 From Kris Katterjohn: when building a SITA version of libpcap, don't
include dead code.
2007-11-18 04:37:27 +00:00
guy bb9a52d915 SITA ACN support, from Fulko Hew. 2007-10-20 01:15:14 +00:00
guy 9dc28aea3e Add DLT_AX25_KISS, for AX.25 with a KISS header, as per discussions in
the tcpdump-workers mailing list in early April, 2007.

Add Richard Stearn's support for DLT_AX25_KISS.
2007-10-05 01:40:14 +00:00
guy 455aff8ba9 Move the Linux Bluetooth and USB declarations to a header file.
Clean up some comments.

Protect all references to the USB stuff from the common Linux code with
PCAP_SUPPORT_USB, just as references to the Bluetooth code are protected
with PCAP_SUPPORT_BT.
2006-10-13 17:46:45 +00:00
guy 50ce2663e8 From Paolo Abeni: Bluetooth support. 2006-10-13 17:34:53 +00:00
guy 5ec4105685 Squelch another valgrind complaint. 2006-10-12 17:26:06 +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
hannes dc03d28d88 from Paolo Abeni <paolo.abeni@email.com>: USB capturing support on linux 2006-10-04 15:50:26 +00:00
guy f65831091d Squelch a valgrind warning. 2006-09-28 07:34:36 +00:00
guy 753370a49f Indicate *which* ioctl failed. 2006-09-18 17:32:30 +00:00