dect
/
libpcap
Archived
13
0
Fork 0
Commit Graph

117 Commits

Author SHA1 Message Date
Patrick McHardy 481ab2d4a6 Merge branch 'master' of git://bpf.tcpdump.org/libpcap
Conflicts:
	pcap/bpf.h

Signed-off-by: Patrick McHardy <kaber@trash.net>
2011-01-10 14:44:29 +01:00
Gianluca Varenni cc1a80e41e Fixes to compile WinPcap under MINGW32 and MINGW64. 2010-10-15 01:42:59 -07:00
Patrick McHardy f6e28f8d19 Import pcap-dect-linux
Signed-off-by: Patrick McHardy <kaber@trash.net>
2010-10-15 02:21:10 +02:00
Guy Harris 74b7b4259f Return PCAP_ERROR_PROMISC_PERM_DENIED if you have permission to open the
DLPI device but don't have permission to put the interface in
promiscuous mode; some systems using DLPI work that way.

Change the libdlpi code to return a warning if you *are* using
physical promiscuous mode and you fail to turn on SAP promiscuous mode,
not if you *aren't* using physical promiscuous mode and you fail to turn
on SAP promiscuous mode; that matches with the no-libdlpi code does, and
matches what the comment says.

Pull dlattachreq up into dl_doattach().
2010-09-21 02:07:05 -07:00
Guy Harris ce38b0cd9b If the specified time stamp type isn't supported, treat that as a warning. 2010-08-22 19:09:50 -07:00
Guy Harris fa4435e65c Add support for setting the time stamp type for a capture.
Based on a patch from Scott Mcmillan <scott.a.mcmillan@intel.com>.

(Second part of the commit.)
2010-08-22 17:36:27 -07:00
Guy Harris 6cb3ad9219 New DLT_IEEE802_15_4_NOFCS for 802.15.4 without FCS.
Requested by Jon Smirl.
2010-08-06 14:12:16 -07:00
Guy Harris 06446f52c4 Include headers that should cause u_int64_t to be defined. 2010-01-26 19:50:36 -08:00
Guy Harris add31c2e28 Add DLT_IPV4 and DLT_IPV6.
DLT_IPV4 and DLT_IPV6 are like DLT_RAW, except that you know the version
of IP.

Also, get rid of some duplicate stuff for DLT_IPNET in savefile.c.
2010-01-04 12:06:40 -08:00
Guy Harris b0c5f4c658 Un-split a line. 2009-12-29 11:53:32 -08:00
Guy Harris 86ed15cc8b Add DLT_CAN_SOCKETCAN, for capturing on the Controller Area Network with
Linux SocketCAN.
2009-10-11 10:16:21 -07:00
Guy Harris 71dac45765 If an activate routine fails, it needs to clean up the pcap_t, close
anything it's opened, etc..

In addition, the op pointers need to be restored to the un-activated
state; do that in pcap_activate() if the call to the activate op fails.

Also, in the common cleanup code, set the fd's to -1.
2009-09-21 10:45:09 -07:00
Guy Harris 8b04d928b6 No, that's not an issue - it'll be a strdup() in any case, and safe to
free.  Revert previous change.
2009-08-11 22:10:51 -07:00
Guy Harris ddea9de623 When using pcap_create_common() in pcap_fopen_offline(), leave
p->opt.source null, so that we don't try to free a constant string when
we close the pcap_t.
2009-08-11 22:09:06 -07:00
Guy Harris 96fece483a From Dustin Spicuzza: if the activate routine doesn't supply an error
message, supply the error message corresponding to the activate
routine's return status, for the benefit of programs that don't handle
different error returns differently.
2009-08-11 21:31:18 -07:00
Guy Harris efeaba4650 The pcap_activate() man page says:
If PCAP_WARNING_PROMISC_NOTSUP, PCAP_ERROR_NO_SUCH_DEVICE, or
	PCAP_ERROR_PERM_DENIED is returned, pcap_geterr() or
	pcap_perror() may be called with p as an argument to fetch or
	display an message giving additional details about the problem
	that might be useful for debugging the problem if it's
	unexpected.

but we weren't always setting the error string in question.  Do so.

In pcap_open_live(), if the open fails with PCAP_ERROR, include the
device name in the error string, and if it fails with
PCAP_ERROR_NO_SUCH_DEVICE or PCAP_ERROR_PERM_DENIED, include the device
name and both error messages in the error string.
2009-07-30 20:58:08 -07:00
Guy Harris 34e950492a When doing Linux mmapped capture:
Allocate a buffer into which to copy a packet, and have the
	callback for pcap_next() and pcap_next_ex() copy to that buffer
	and return a pointer to that buffer; we can't return the packet
	data pointer passed to the callback, as, once the callback
	returns, that buffer can be overwritten, even before you read
	the next packet.

	Don't tweak filter programs passed into the kernel to return
	65535 on success - we don't have to, as we're not reading
	packets with recvfrom(), and we don't want to, as, if we return
	the actual snapshot length, the kernel will copy less data to
	the ring buffer.

	Truncate the packet snapshot length to the specified length, as
	we might not have a filter to do that.
2009-07-16 15:08:12 -07:00
guy b908482137 Update CHANGES for USB fixes.
Update CREDITS to give Jon Smirl credit for some of the USB fixes.

Rename DLT_USB_LINUX_MMAP to DLT_USB_LINUX_MMAPPED, and declare a
structure for the header of packets in DLT_USB_LINUX_MMAPPED captures.
2008-12-23 20:13:29 +00:00
guy 87d0db882e From Jon Smirl:
try scanning the sysfs USB directory first and, if that
	directory doesn't exist, try the procfs USB directory, to handle
	newer kernels where the relevant director is in sysfs;

	use the data length, not the URB length, as the amount of data
	in the packet (the URB length is the amount of space *available*
	for the data, not the actual amount of data).

For the memory-mapped interface, include the padding after the URB and
setup header in the packet lengths, and return a different link-layer
type so that code reading the packets knows that padding is there.
2008-12-23 18:03:22 +00:00
guy 8a49a4d47b New DLT_MPLS link-layer type, for MPLS packets with an MPLS label as the
link-layer header.
2008-12-21 19:28:56 +00:00
guy fe8a58a56d Generically refer to the top-of-tree version as 1.x.y. 2008-12-14 19:36:02 +00:00
guy f4af9ed692 Link-layer type for 802.15.4 with PHY-level preamble, SFD, and frame
length, as requested by Max Filippov <jcmvbkbc@gmail.com>.
2008-09-22 20:14:19 +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 d592f692d0 Add pcap_free_datalinks() - on Windows, something allocated in Vegas^Wa
library has to be freed by the library, as an application or other
library using that library might have been built with a different
version of the C runtime library.
2008-05-26 19:58:06 +00:00
guy 1f93b0fda9 Pick up pcap_offline_filter() from WinPcap.
Add pcap_compile() to the SEE ALSO section for pcap_setfilter().
2008-05-13 15:19:56 +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 c6aa29a8dc Rename pcap_errtostr() to pcap_statustostr(), and have it handle
PCAP_WARNING values as well.
2008-04-09 21:39:21 +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 a161340b6e Have a separate pcap_errtostr() routine to turn PCAP_ERROR_ values to
strings; leave pcap_strerror() for UN*X errnos.
2008-04-06 19:55:32 +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
gianluca c9c0634709 [from Gisle Vanem]
Fixed a typo in pcap_setmintocopy().
2007-11-06 16:20:53 +00:00
guy 3a0937cfba On Win32, have pcap_setbuff, pcap_setmode, and pcap_setmintocopy ops, so
add-on capture mechanisms can supply their own code for that.
2007-10-17 18:52:41 +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 afbb1ce722 Based on work from Florent Drouin, split the 32-bit link-layer type
field in a capture file into:

	a 16-bit link-layer type field (it's 16 bits in pcap-NG, and
	that'll probably be enough for the foreseeable future);

	a 10-bit "class" field, indicating the group of link-layer type
	values to which the link-layer type belongs - class 0 is for
	regular DLT_ values, and class 0x224 grandfathers in the NetBSD
	"raw address family" link-layer types;

	a 6-bit "extension" field, storing information about the
	capture, such an indication of whether the packets include an
	FCS and, if so, how many bytes of FCS are present.
2007-09-29 19:33:29 +00:00
guy fe7433245e New DLT for Bluetooth H:4 with pseudo-header giving direction.
Add support for additional link types to gencode.c, so we at least
support "link[N:M]" and an empty expression.

Sort the DLT_CHOICE values in order by the DLT_ value, add missing ones,
and fix some existing descriptions.
2007-09-19 02:40:34 +00:00
guy 6adab105af From OpenBSD: use calloc() to avoid malloc(n * m) overflows. 2007-09-12 21:29:13 +00:00
hannes 18341fc1b5 allocate DLT_JUNIPER_ST as per request from Hannes Gredler <hannes@juniper.net> 2007-09-10 20:17:18 +00:00
guy 56634b504f Update the WinPcap version number. 2007-06-22 06:45:54 +00:00
guy 0fd3a1a661 From Stephen Donnelly of Endace:
This patch introduces support for the DAG ERF type
	TYPE_COLOR_MC_HDLC_POS.

	The patch also allows appropriate DAG cards (DAG 3.7T, DAG 7.1S)
	to optionally produce DLT_MTP2_WITH_PHDR (139) traces when
	capturing from channelised HDLC links, as an alternative to
	DLT_MTP2 (140).  When using the new DLT, the 'DAG channel' is
	recorded in the pcap record pseudo header as the 'link_number'.

	Basic BPF filtering support for DLT_MTP2_WITH_PHDR is also
	added.

Fix some warnings.
2007-06-22 06:32:06 +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 d959f6403d From Paolo Abeni: add support for the binary USB sniffing interface in
Linux.  The USB sniffing code for Linux now supplies a per-packet header
based on the one supplied by the Linux binary sniffing interface, so we
add a new DLT_ value and use that.

Fix his e-mail address, and add him to the credits.
2006-12-20 03:30:32 +00:00
guy 8c2a49b75c DLT_ value added for the Bluetooth HCI UART transport layer for Paolo
Abeni.

Added DLT/DLT name table mappings and linktype values and DLT/linktype
mappings for USB and for the Bluetooth NCI UART transport layer.

Fix up indentation.
2006-10-13 08:46:23 +00:00
guy 09b4db222c Clean up indentation.
From Stephen Donnelly: add DLT_MTP2 to the table of DLT choices.
2006-09-25 18:16:55 +00:00
gianluca 3f0f487a1e Added a new DLT and LINKTYPE value for ARINC 653 Interpartition
Communication messages.
2006-07-27 21:02:57 +00:00
gianluca 303bc7bd43 Redefined DLT_CAN20B and LINKTYPE_CAN20B as #190 (as this is the
right value for CAN).
Added the definition of DLT_A429 and LINKTYPE_A429 as #184.
Added these two link layers in the global array dlt_choices.
2006-07-19 20:51:50 +00:00
hannes b7d2f597d1 add support for DLT_JUNIPER_VP 2006-05-18 08:40:52 +00:00
guy c1fca92559 From Daniele Orlandi <daniele@orlandi.com>: add support for capturing
LAPD frames with vISDN.
2006-01-22 20:11:26 +00:00
hannes 98a1d8cfbd add DLT/LINKTYPE for carrying FRF.16 Multi-link Frame Relay 2005-12-13 13:41:39 +00:00
hannes 9ab067e012 allocate 4 new DLTs on behalf of Juniper Networks, Inc. for
prepending meta-information like interface index, interface name
before a standard Ethernet, PPP, Frame Relay, C-HDLC Frame
2005-08-12 19:23:30 +00:00