dect
/
libpcap
Archived
13
0
Fork 0
Commit Graph

40 Commits

Author SHA1 Message Date
Stephen Donnelly 0ca4ea9a38 Updating Endace DAG ERF support.
- Ensure all 'MC' ERF types are handled correctly by DLT_ERF.

- Allow capture of ERF 'TYPE_IPV6' records as DLT_RAW.

- Add new ERF types

- Explicitly list known ERF types with no matching native DLT.
2009-05-04 16:32:52 +12: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 a45116b80c From Stephen Donnelly: fix some compile errors from the conversion to
the create/activate mode.
2008-04-08 03:00:14 +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 43b6c2d818 Explicitly check for a positive "cnt" argument, as at least some other
read_op loops do, to clarify that a zero or negative "cnt" value means
"loop until we run out of packets".
2008-02-02 20:42:35 +00:00
guy b7f2a2ee77 Fix a typo; this fixes bug 1854436. 2008-01-06 21:25:54 +00:00
guy da54d62ffd From Stephen Donnelly:
Changing the behaviour when the ERF type is unknown, and for ERF
	TYPE_PAD.

	Unknown ERF types can always be captured as DLT_ERF.  TYPE_PAD
	records are dropped silently.
2007-11-09 00:55:53 +00:00
guy 24bc44b0f2 From Stephen Donnelly:
support ERF extension headers;

	collect the ifdefs for different ERF types into a header
	to improve readability;

	add in a couple of new types.
2007-11-05 21:45:07 +00:00
guy 877d5fc4eb From Stephen Donnelly:
Clean up the configure output for the dag libraries a bit.

	Add Florent Drouin's changes for DLT_ERF.

	Some other DAG changes.
2007-10-30 10:16:45 +00:00
guy 05e4b27b14 From Stephen Donnelly:
* Improved error checking in dag_read().
     * More efficient dag_platform_finddevs().
     * Support for new DAG API function dag_get_stream_erf_types().
2007-10-04 23:06:25 +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 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 d5e7848c1e From Florent Drouin: clean up resources when an open fails.
In addition, clean up the allocation and freeing of the temporary
pathname string buffer.

Also, there's no need to set "md.device" (it's only used on Linux, and
even then used only with the old SOCK_PACKET sockets, where you have to
turn promiscuous mode off explicitly rather than having it turn off
automatically when you close the socket) or "md.timeout".
2007-02-01 02:58:39 +00:00
guy b4c382fd7e From Paolo Abeni:
The USB pseudo-header in DLT_USB_LINUX captures is in the host
	byte order for the machine on which the capture was done.  When
	reading a capture file, convert the pseudo-header to the host
	byte order of the host on which the file is being read.

	There's a 64-bit quantity in that pseudo-header; move the 64-bit
	byte-swap macro from the DAG code to pcap-int.h for use by other
	code.
2007-01-29 20:08:06 +00:00
guy 53bccbd2d7 From Stephen Donnelly: add support for new DAG ERF types. 2006-09-25 18:18:18 +00:00
guy b64aff479f From Stephen Donnelly:
If the DAG API supports asking a card for the set of ERF types
	it supports, use that capability, to handle cards that support
	multiple ERF types.  This is to support channelised/fractional
	T1/E1.

	Don't set the snapshot length - some DAG cards support multiple
	capture streams, but the snapshot length is global, so it'd
	affect other captures.

	Update README.dag.
2006-04-07 07:07:25 +00:00
guy d8d2d19c98 Stephen Donnely says MTP3 and SCCP don't belong in the list of DLT_
values for an HDLC link (MTP2 is what's usually run on those links, with
MTP3 atop it); remove them.  Also, boost dlt_count to match the number
of DLT_ values.
2005-07-10 22:09:16 +00:00
guy 7f34968ee3 From Stephen Donnelly: updates to the DAG support, to support their
updated API if available.
2005-07-07 06:55:19 +00:00
guy e987a615e2 From Pawel Pokrywka: add support for requesting that only received
packets, only sent packets, or all packets be accepted, with an
implementation for Linux.

Add an implementation for BPF platforms that support BIOCSSEESENT.
2005-05-03 18:53:58 +00:00
guy ff5da1a402 "install_bpf_program()" already sets "p->errbuf" to an error string if
it fails; there's no need for "dag_setfilter()" to do so.
2005-04-03 23:56:47 +00:00
guy 2dd3e0acd6 From Koryn Grant:
The DAG 4.2 OC-48 cards (and revisions thereof) produce ERF
	records that do not contain the trailing FCS.  However,
	pcap-dag.c assumed that there is an FCS and strips the final
	word of the packet.  This meant that packets captured with
	libpcap on a DAG 4.2 are truncated by four bytes, unless a
	magical environment variable (ERF_FCS_BITS) was set.  This patch
	autodetects when the DAG card is a 4.2, and turns off the
	FCS-stripping feature so that packets are no longer truncated.

	Also, include "dagnew.h" and "dagapi.h" with quotes, not angle
	brackets, as they should be in the user search path, not the
	system search path.
2005-01-21 10:11:39 +00:00
guy 597103eedc From Koryn Grant:
correctly detect a rare error condition and return a sensible
	error message instead of blindly continuing;

	clean up some endian-specific code.
2004-11-10 09:28:25 +00:00
guy 2d2890dd37 Add support for sending packets; includes contributions from Mark
Pizzolato <List-tcpdump-workers@subscriptions.pizzolato.net>.
2004-03-23 19:18:04 +00:00
guy 1c186556cd From Jesper Peterson: fix a couple of endianness problems. 2004-01-30 02:23:53 +00:00
guy fab5c982f2 From Jesper Peterson:
- don't auto-detect HDLC DLT on serial links, use
	  "pcap_set_datalink()" to choose the link-layer header

	- for ATM, allow selecting SUNATM rather than the default
	  RFC1483 with "pcap_set_datalink()"

	- reformat and otherwise clean up the code.
2004-01-05 18:18:54 +00:00
guy 619a9fe31b For devices that we have some reason to believe are real live Ethernet
devices, offer DLT_DOCSIS as one of the choices of link-layer type, and
support setting that type as meaning just "set libpcap's notion of the
link-layer type to DLT_DOCSIS" without telling the driver to use
DLT_DOCSIS.
2003-12-18 23:32:31 +00:00
guy c98ffbcabf Add a "pcap_get_selectable_fd()" API to get an FD on which you can do a
"select()" or "poll()" - or -1 if that won't work.
2003-11-21 10:19:33 +00:00
guy 2c618b93a0 Add "getnonblock" and "setnonblock" operations, and set the function
pointers appropriately, rather than using #ifdefs and run-time checks.

Get rid of declaration of non-existent "pcap_set_datalink_platform()"
routine.
2003-11-20 02:02:38 +00:00
guy 028bb1b31d From Koryn Grant <koryn@endace.com> - DAG support enhancements and fixes:
Added support for nonblocking operation.

	Added support for processing more than a single packet in
	pcap_dispatch().

	Fixed bug in loss counter code.

	Improved portability of loss counter code (e.g. use UINT_MAX
	instead of 0xffff).

	Removed unused local variables.

	Added required headers (ctype.h, limits.h, unistd.h,
	netinet/in.h).

	Changed semantics to match those of standard pcap on linux.
		- packets rejected by the filter are not counted.
2003-11-20 01:21:25 +00:00
guy 30e89f192a Add _U_ to "rcsid[]" definitions, to eliminate "unused variable"
warnings from newer versions of GCC.
2003-11-15 23:23:57 +00:00
guy 991d444f71 Add a "pcap_breakloop()" API to break out of the loop in
"pcap_dispatch()" and "pcap_loop()".
2003-11-04 07:05:32 +00:00
guy b583959753 From Jesper Peterson:
Fix the pcap-dag atexit() handler for non-execing child
	processes.  Previously a fork()/exit() would stop the packet
	capture (doh!).

	Add a couple of optimizations.
2003-10-02 07:07:49 +00:00
guy ff1b994eb7 From Jesper Peterson: for HDLC packet-over-SONET DAG captures, don't
assume Cisco HDLC, look at the first frame to see whether it has a
PPP-in-HDLC-like-frameing header, and use DLT_PPP_SERIAL for that and
DLT_CHDLC otherwise.
2003-08-18 22:00:16 +00:00
guy 0f2fcd859b Updates from Jesper Peterson. 2003-07-25 06:36:23 +00:00
guy cd0d893ef9 Add a "read" function pointer to the pcap_t structure, which handles
reading packets from a pcap_t, and make "pcap_read()" call it.  That
removes the last place where we have to check for a pcap_t that refers
to a DAG card rather than a live capture, so get rid of the "is_dag" flag.
2003-07-25 05:32:02 +00:00
guy 08658f1c93 Add a "set_datalink" function pointer to the pcap_t structure, whichhandles
setting a filter for a pcap_t.  Have "pcap_set_datalink()" call it,
rather than explicitly calling "pcap_set_datalink_platform()".
2003-07-25 05:07:01 +00:00
guy cd2807e08d Add a "setfilter" function pointer to the pcap_t structure, which
handles setting a filter for a pcap_t.  Have "pcap_setfilter()" call it,
rather than being a per-platform function.  The per-platform functions
don't need to check for an offline capture any more, as they're not
called for an offline capture (and the ones that just call
"install_bpf_program()" don't need to exist at all).
2003-07-25 04:42:02 +00:00
guy 9792990eb8 Add a "stats" function pointer to the pcap_t structure, which handles
getting statistics for a pcap_t.  Have "pcap_stats()" call it, rather
than being a per-platform function; have stats routines for non-live
pcap_t's that return an error.
2003-07-25 04:04:56 +00:00
guy e648c9e593 Add a "close" function pointer to the pcap_t structure, which handles
the platform-dependent part of closing a pcap_t (and the
live-vs-savefile part as well, so that function must close the file
descriptor and free up any buffers allocated).

In the Digital UNIX support, add in a check for a memory allocation
failure.
2003-07-25 03:25:45 +00:00
guy 77cade932c From Jesper Peterson <jesper@endace.com>: support for capturing from
Endace DAG devices.
2003-07-23 05:29:19 +00:00