dect
/
libpcap
Archived
13
0
Fork 0
Commit Graph

248 Commits

Author SHA1 Message Date
guy 15cc8e524f Fix the man page's description of "pcap_file()" and "pcap_fileno()" to
reflect reality.
2001-03-26 10:21:31 +00:00
guy 534381a041 Attempt to put the link-layer payload of packets on a 4-byte boundary,
as is done in some other "pcap-XXX.c" modules.
2001-03-20 05:50:33 +00:00
guy 67e19bff40 Add Jason Thorpe's name to the list of contributors. 2001-02-25 00:54:05 +00:00
mcr 4ed17921a9 added english versions of many common fields (from thorpej) 2001-02-24 18:21:14 +00:00
guy cae3c555e6 Patch from NetBSD, by Klaus Klein <kleink@netbsd.org>, to support "vrrp"
as an IP protocol, like "udp", "tcp", "icmp", "pim", etc..
2001-02-21 09:33:03 +00:00
guy bc0425f86c Patch from Onno van der Linden <onno@simplex.nl> to support Token Ring
on DLPI systems.
2001-02-21 09:07:40 +00:00
itojun ae09ab3412 ignore non-IP address. 2001-02-12 09:33:21 +00:00
guy fa4449caf2 Clarify what "pcap_next()" does, as per a suggestion by Michael T.
Stolarchuk.
2001-02-09 04:50:17 +00:00
guy b0dcde29f7 Add a "netbeui" keyword, which selects NetBEUI packets (LLC packets with
0xf0 as the DSAP and SSAP).

Let "ipx" work on non-Ethernet 802.2 frames - we assume they're always
frames with the IPX DSAP.
2001-01-28 09:44:48 +00:00
guy e191909508 Pick up the "README.tru64" file from Ethereal, and change it to refer to
tcpdump, for the benefit of Digital^H^H^H^H^H^H^HTru64 UNIX users.
2001-01-24 06:52:52 +00:00
guy a6e177c611 Patch from Igor Khristophorov <igor@atdot.org> to handle adaptive SLIP
interfaces on Linux just like standard SLIP interfaces.
2001-01-20 07:47:53 +00:00
guy 1ae6bd52d5 Note that captures on the "any" device won't be done in promiscuous
mode, regardless of the value of "promisc".
2001-01-18 04:41:45 +00:00
guy fa766cfb0c Patch from Lorenzo Cavallaro <sullivan@sikurezza.org> to create
$(DESTDIR)/$(mandir)/man3 before installing the libpcap man page, if
that directory doesn't already exist.
2001-01-18 04:05:12 +00:00
guy 952a563412 Some platforms that lack <netpacket/packet.h> define PF_PACKET but don't
support PF_PACKET sockets, and, in particular, don't define in
<linux/if_packet.h> any of the stuff needed by the code to handle
PF_PACKET sockets.  Define HAVE_PF_PACKET_SOCKETS if either

	1) we have <netpacket/packet.h>

or

	2) PF_PACKET is defined *and* PACKET_HOST is defined by
	   <linux/if_packet.h>

and use HAVE_PF_PACKET_SOCKETS, not PF_PACKET, be what we use in #ifdefs
to conditionally compile in support for PF_PACKET sockets.

Not all platforms define ARPHRD_SIT, either; #define it if it's not
already defined.
2001-01-18 03:58:22 +00:00
guy 8a6db7a7d5 Sigh. Not all systems have <netinet/if_ether.h> - for example, at least
some libc5 Linux systems don't - so we have to check whether it exists,
and include it only if it does.
2001-01-17 18:18:48 +00:00
guy 9c3650645f At least some libc5 systems don't have <netinet/if_ether.h> but do have
<net/if_arp.h>, and the stuff we want is in <net/if_arp.h>, so include
that rather than <netinet/if_ether.h>.

At least some libc5 systems don't have <netpacket/packet.h>, but have a
<sys/socket.h> that includes <linux/socket.h>, and the latter defines
SO_ATTACH_FILTER if the kernel is a 2.2 or later kernel, so there exist
systems that have SO_ATTACH_FILTER defined but don't have
<netpacket/packet.h>.  Work around that by:

	checking whether we have PF_PACKET sockets by checking whether
	PF_PACKET is defined, not whether we have <netpacket/packet.h>
	(but we still check whether we have <netpacket/packet.h> before
	including it);

	if PF_PACKET is defined but we don't have <netpacket/packet.h>,
	include <linux/if_packet.h> to get the relevant definitions.
2001-01-17 07:42:37 +00:00
guy 2f454fd004 Check for all four types of IPX frame on DLT_LINUX_SLL captures. 2001-01-15 00:03:40 +00:00
guy 79762d33da I've seen captures with all four different flavors of IPX frames on
Ethernet, so, at least on Ethernet, when checking for IPX frames, check
for all of them, including Ethernet_II and Ethernet_SNAP.

Add an "llc.h" file with LLC SAP values, taken from tcpdump's "llc.h"
file, and use those, rather than defining them ourselves in "gencode.c".
2001-01-14 21:26:52 +00:00
guy d4869582d0 Handle STP (under the assumption that the "Bridging PDU"s that go over
PPP are Spanning Tree Protocol Bridging PDUs) and IPX over PPP.
2001-01-14 08:09:58 +00:00
guy d17596dbd9 Add "ipx", which checks for the LLC SAP for IPX as well as, on Ethernet,
for "Novell 802.3" frames, which are 802.3 frames (i.e., the type/length
field is a length field, i.e. it's <= ETHERMTU) with 0xFFFF as the first
2 bytes.  We don't yet check for ETHERTYPE_IPX as well.

When checking for OSI packets on Linux cooked captures, check for 802.2
frames by testing the packet type for LINUX_SLL_P_802_2 rather than by
checking whether the type field is <= ETHERMTU (it's always a type field
in DLT_LINUX_SLL captures).
2001-01-14 07:57:47 +00:00
guy c3c2ed00d5 Generate code to check for LLC SAP values on Linux cooked captures.
Set "off_linktype" to the correct value for the offset of the Ethernet
type field in the fake header for Linux cooked captures, so that the
correct code is generated for tests of that field.
2001-01-14 05:30:07 +00:00
guy 2b3dac284e Support checking for protocols specified by an LLC SAP on FDDI, Token
Ring, and RFC 1483-style ATM, as well as on Ethernet.

Support checking for LLC SAP protocols other than OSI protocols on
Ethernet - for now, we check only the DSAP on those, rather than
checking both the DSAP and SSAP as we do for OSI, as I think, in some
cases, the SSAP isn't the same as the DSAP.

When generating protocol type checks on link-layer types with no type
field, where packets are always IP (SLIP, BSD/OS SLIP, raw IP), generate
a "test" that always succeeds if the protocol being checked for is IP or
IPv6 and a "test" that always fails otherwise.  (We originally did
"gen_true()" if the protocol is IP, and bogusly generated code to check
the field at an offset of -1 otherwise; a subsequent change caused us
always to do "gen_true()", but that doesn't properly handle attempts to
check for other protocols - those attempts should generate code that
always fails, meaning that if you try to look for ARP packets in such a
capture the BPF compiler will return "expression rejects all packets" as
an error - and still generated extra code not all of which was removed
by the optimizer.  The current code generates no *more* BPF code.)

Add "stp", which checks for the LLC SAP for the Spanning Tree Protocol.
2001-01-14 04:34:51 +00:00
guy 90018ebb80 Summary of changes for 0.6. 2001-01-10 04:10:33 +00:00
guy af32a655e1 Add some additional entries. 2001-01-10 04:06:44 +00:00
guy 71e02cbc34 Update the last modification date. 2001-01-03 22:52:26 +00:00
guy 60ac80bd7a Remove the "select()" from the code path for reading live captures on
Linux; Linux isn't the only platform whose kernel doesn't support a
read timeout, and even some that *do* don't start the timer until at
least one packet has arrived (Solaris, for example), so no portable
application can depend on "pcap_dispatch()", say, blocking for no longer
than the timeout - they must do a "select()" themselves.  For
applications that do the "select()" themselves, or that don't need the
timeout for polling (tcpdump, for example), doing a "select()" in
libpcap just adds another system call to the code path.
2001-01-03 01:06:16 +00:00
guy b542949711 Fix the description of "pcap_dispatch()" and "pcap_loop()" to reflect
reality ("pcap_dispatch()", on a live capture, never reads more than one
bufferful of packets).

Break the description of "pcap_dispatch()" into multiple paragraphs.

Move the description of "pcap_loop()" right after the descriptionof
"pcap_dispatch()", and note that "pcap_dump()" can be used as the
callback function for either of them.
2001-01-03 00:57:56 +00:00
guy 70121e5b65 Note that the read timeout in "pcap_open_live()" does *NOT* guarantee
that "pcap_dispatch()" will always return within that many milliseconds;
some platforms don't support a read timeout, meaning the read timeout
argument is ignored, and, on other platforms (SunOS 5.x and possibly
SunOS 4.x and 3.x), the timer starts when the first packet arrives, so
the timeout doesn't expire until at least one packet arrives.
2000-12-28 01:58:05 +00:00
guy 042a2010bb Remove "stamp-h" and "stamp-h.in" on a "make distclean", as is done for
tcpdump.
2000-12-23 20:06:15 +00:00
guy 7574015989 It's a bit more convenient for Ethereal if the "sll_protocol" field is
at the end of the link-layer header; put it there.

Put in a comment indicating that the layout of the link-layer header
shouldn't be changed; if a new header is necessary, a new DLL_ type
should be introduced for it.
2000-12-23 07:50:18 +00:00
guy 5d92f34251 Fix a typo. 2000-12-23 03:04:06 +00:00
guy 1e22a6ef45 Put the LINUX_SLL_P_ definitions back, and check for at least some of
them in "print-sll.c" - as a cooked-mode capture may be reading from
non-Ethernet, non-802.x devices, it may well see some
ETH_P_/LINUX_SLL_P_ types that don't mean "this is an 802.2 LLC frame".

We currently assume that the ETH_P_ values won't change in the kernel,
so we don't have to explicitly map them.
2000-12-22 22:34:16 +00:00
guy a4af073aa0 Check for "ippp" devices, as well as "isdn" and "isdY" devices, when
deciding whether to punt to cooked mode.
2000-12-22 12:30:04 +00:00
guy 54b14dde63 Just copy over the "sll_protocol" field - if it's not an Ethernet type,
we just treat the frame as an LLC frame (if we care about Novell
IPX-over-raw-802.3 frames, we'd have to handle them by checking for
0xFFFF as the first word - but we'd also have to do that when dissecting
Ethernet frames).
2000-12-22 12:24:20 +00:00
guy dba6f764bb Update a comment. 2000-12-22 12:14:48 +00:00
guy cf54e028ce Explicitly map PACKET_ values to LINUX_SLL_ values, so that even if a
future Linux kernel changes the PACKET_ values out from under us, the
values recorded in the packet header in DLT_LINUX_SLL captures does
*not* change.

Don't map ETH_P_802_2 to the packet length, map it and ETH_P_802_3 to
standardized LINUX_SLL_P_ values, so that even if a future Linux kernel
changes the ETH_P_ values out from under us, the values recorded in the
packet header in DLT_LINUX_SLL captures does *not* change, and so that
you don't have to be running on Linux to be able to handle DLT_LINUX_SLL
captures.
2000-12-22 12:11:36 +00:00
guy db46beec77 "depend" should depend on "bpf_filter.c", so that we make the
appropriate "bpf_filter.c" symlink before building the dependencies, so
that the dependencies include those for "bpf_filter.c".
2000-12-22 11:54:48 +00:00
guy 4ee46797c7 Patch from Olaf Kirch to add support for ARPHRD_TUNNEL (or at least for
some tunnels).
2000-12-22 11:53:27 +00:00
guy 0a56cf15a9 Declare "pfopen()" in "lbl/os-osf4.h", as Digital don't seem to have
bothered to declare it anywhere in a system header file.
2000-12-22 11:51:33 +00:00
guy d6752d37e8 Regenerate "config.h.in" and "configure". 2000-12-22 11:42:18 +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 892c4a4436 Put in a comment noting that we should, perhaps, declare
"ether_hostton()" in "lbl/os-XXX.h" files rather than in "nametoaddr.c".
2000-12-18 03:45:34 +00:00
guy 839690365f As per many suggestions, the most recent in mail to
"patches@tcpdump.org" by Jonathan Wilkins
<jwilkins@madscience.dyndns.org>, we don't declare "ether_hostton()" on
FreeBSD - it's declared in <net/ethernet.h> in 3.0 and later, and is
declared with the first argument as "const char *" in 4.0 and later so
that if we declare it with the first argument as "char *" we get errors.
(If we declare it with "const char *", you get errors on FreeBSD 3.x and
other systems that *don't* declare it with "const char *".)

XXX - should it go, instead, into "lbl/os-XXX.h" files, for those OS
versions that don't declare it, and not be declared at all here?
2000-12-18 03:42:39 +00:00
guy 6fc6ca1eb5 Improve the error message printed if you try to use the "any" device on
a system where only SOCK_PACKET works.
2000-12-18 00:20:51 +00:00
fenner 109075a904 Update config.guess and config.sub to revision 2000-12-15
from ftp://ftp.gnu.org/gnu/config/
2000-12-17 15:16:50 +00:00
guy 61d8355611 Add "config.h" and ".devel". 2000-12-17 08:11:20 +00:00
guy d394d8f49f Get rid of "config.h" and "bpf_filter.c" on a "make distclean". 2000-12-17 07:25:40 +00:00
guy d9d04b6303 Use 50, not 113, for the link layer type in NetBSD DLT_PPP_SERIAL
capture files; NetBSD uses 50, and, hopefully, nobody else will use 50
for something else.
2000-12-16 22:19:12 +00:00
guy 7928a0e823 Handle DLT_NULL correctly - the AF_ value is in host byte order, which
means that we should "htonl()" it before using it in BPF expressions
*but*, if we're reading a capture file from a machine with the opposite
byte order from ours, we should byte-swap it before "htonl()"ing it.

Handle OpenBSD DLT_LOOP as well - it's like DLT_NULL except that the AF_
value is in *network* byte order.

Don't support checking for inbound or outbound packets except on those
data link types that supply an inbound/outbound qualifier (DLT_SLIP and
DLT_PPP) - this came from OpenBSD's libpcap, delta 1.12 to "gencode.c".
2000-12-16 21:31:10 +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