dect
/
libpcap
Archived
13
0
Fork 0
Commit Graph

1517 Commits

Author SHA1 Message Date
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
guy 84533f55bf The stuff in the "linux-include" directory is no longer needed, as we no
longer depend on the OS's header files for packet format and packet
field value definitions; get rid of the stuff in that directory.
2000-12-16 09:05:11 +00:00
guy 54b79fdd10 Note that:
"pcap_compile()" and "pcap_compile_nopcap()" return -1 on
	failure;

	if "pcap_compile()" or "pcap_setfilter()" fails, you can get the
	error string with "pcap_geterr()";

	if "pcap_compile_nopcap()" fails, you can't get the error
	string, but, as it's just a wrapper around "pcap_open_dead()",
	"pcap_compile()", and "pcap_close()", you can use those routines
	yourself if you want the error string;

	you have to use, or copy, the string you get back from
	"pcap_geterr()" before closing the "pcap_t" you hand to
	"pcap_geterr()", as the string you got back from "pcap_geterr()"
	doesn't remain valid after the "pcap_t" whence you got it is
	closed.
2000-12-12 09:31:45 +00:00
guy e20bbc40f7 If the user specifies an Ethernet address in an expression such as
"ether host XX:XX:XX:XX:XX:XX", but the device on which you're capturing
isn't a device with Ethernet-style link-layer addresses, report
"ethernet addresses supported only on ethernet, FDDI or token ring", not
"ethernet address used in non-ether expression", as the error.
2000-12-12 08:08:38 +00:00
guy 26f7f272c0 Make "pcap_compile_nopcap()" a wrapper around "pcap_open_dead()" and
"pcap_compile()", rather than a routine that duplicates a lot of code in
"pcap_compile()", so that we don't run the risk of having
"pcap_compile_nopcap()" fail to take actions that "pcap_compile()"
takes.
2000-12-12 03:26:16 +00:00
mcr 7ec14224d6 preliminary edits for 0.6 2000-12-08 07:01:11 +00:00
guy a91d72d3ed The Linux 2.4 kernel supplies ARPHRD_IEEE802_TR, rather than
ARPHRD_IEEE802, as the hardware type for Token Ring interfaces.  Map
both of them to DLT_IEEE802 (as that has become the DLT_ type for Token
Ring, the fact that it just says "802", not "802_5" or whatever,
nonwithstanding), and, if ARPHRD_IEEE802_TR isn't defined, define it
with the value it has in 2.4 (so that the resulting libpcap will work on
a 2.4 system regardless of whether the system on which it was built
defined ARPHRD_IEEE802_TR).
2000-12-03 09:07:27 +00:00
guy 21e33731db Update the platform-specific information for various platforms.
Add a "README.linux" file discussing the packet socket and socket
filtering kernel options.
2000-12-01 07:47:07 +00:00
guy dc543edc9a Fix a couple of error messages. 2000-11-22 05:32:55 +00:00
itojun 20784fd22c netbsd 1.5 -> 1.6
Fix a hairy optimizer bug that causes the expression:
'ip and ((icmp and dst host 1.1.1.1 and not host 2.2.2.2) or (host 1.1.1.1 and src host 3.3.3.3))'
to compile incorrectly.  Details about to be mailed to LBL.
2000-11-19 13:37:20 +00:00
guy ef0a3b3d38 Add a DLT_IEEE802_11 for use by any platform that provides raw 802.11
link-layer headers on capture.  (Nothing uses it yet, but hopefully this
will make it less likely that they'll use different DLT_ names or
values.)
2000-11-15 05:36:48 +00:00
guy e9c32982c8 Oops! I gave LINKTYPE_PPP_HDLC the same value as LINKTYPE_FR, which is
Not Good.  Give LINKTYPE_PPP_HDLC 113 instead, as nothing else uses it.
2000-11-15 05:31:05 +00:00
itojun 142ff8d0c7 correct "protochain" processing. 2000-11-09 06:20:05 +00:00
guy ad7e091f5d Declare "install_bpf_program()" in "pcap-int.h", not "gencode.h"; it has
nothing to do with generating code, and "gencode.h" isn't included by
all "pcap-XXX.c" modules, whilst "pcap-int.h" is.
2000-11-04 10:09:55 +00:00
guy 525b970802 Patch from Arkadiusz Miskiewicz <misiek@pld.org.pl> to handle ARPHRD_SIT
(IPv6-inside-IPv4 tunnel).
2000-11-04 07:19:22 +00:00
guy 7d16400ec5 When reporting an unknown data link type, print it in decimal, not hex,
as DLT_ values are defined with decimal values in "net/bpf.h".

Cast the last argument to "gen_cmp()" to "bpf_int32", not "long", as
it's a "bpf_int32".
2000-10-30 06:06:53 +00:00
guy daef269870 Add a #define for the LSAP value for SNAP. 2000-10-29 05:53:21 +00:00
guy 00357a902a Handle "iso" as a PPP link-layer type. 2000-10-28 10:28:15 +00:00
guy 195ad572d1 Allow "clnp", as well as "esis" and "isis", as OSI protocols for which
we can check.
2000-10-28 10:18:39 +00:00
guy f4cbadac41 Allow "iso proto esis" and "iso proto isis" (as the FreeBSD man page
claims are allowed, even though the FreeBSD tcpdump doesn't support
them).
2000-10-28 10:05:46 +00:00
guy be6af9e0ad Catch attempts to filter on ISO hosts (we don't support that) and to
apply "esis" or "isis" to host names.
2000-10-28 09:43:56 +00:00
guy af30d75a3e Tony Li's changes, from FreeBSD, to support filtering for OSI packets
and for ESIS and ISIS packets.
2000-10-28 09:30:20 +00:00
guy 14972aa99d Handle for DLT_PPP all the protocol types we handle for DLT_PPP_BSDOS. 2000-10-28 09:06:06 +00:00
guy 54b2ab13c2 Patch from Monroe Williams <monroe@pobox.com>, submitted with NetBSD PR
#5228, to correctly check for Appletalk for EtherTalk phase II - they
use 802.3 with LLC SNAP packets, rather than D/I/X Ethernet packets.

His patch made "atalk" check for Appletalk ARP as well as other
Appletalk packets; I've instead added a separate "aarp" packet type,
leaving "atalk" checking only for ETHERTYPE_ATALK, so you can check for
ETHERTYPE_ATALK, ETHERTYPE_AARP, or both.
2000-10-28 08:19:29 +00:00
guy 8c16ead778 Fix from Jefferson Ogata <jogata@nodc.noaa.gov> - "count_stmts()" wasn't
counting any extra jumps required by a flowgraph node (the conditional
jump instructions have an 8-bit offset; if the target is more than 256
instructions away, we generate a nearby "jump always" to the target, and
jump to that instead).
2000-10-28 01:22:52 +00:00
guy 82547471f7 When attaching a "bpf_program" to a "pcap_t" to use as a userland
filter, always attach a copy, as "pcap-linux.c" does; that way, after a
program uses "pcap_setfilter()", it can safely use "pcap_freecode()" to
free up the BPF instructions allocated by "pcap_compile()".  Also,
always free it up when the "pcap_t" is closed.

Get rid of the "pcap_t *" argument to "pcap_freecode()", as it's not
necessary.

Document "pcap_freecode()", for the benefit of programs that might
repeatedly compile filter programs and attach them, so that they can
free them up after attaching them and avoid leaking memory for them.
2000-10-28 00:01:26 +00:00
guy 188fee53cc If we're receiving packets from a PF_PACKET socket, check whether the
interface index of the interface for the packet is the interface index
of the loopback interface and, if it is, check if the packet is an
outgoing packet; if so, ignore it, as we'll also be seeing that packet
as a received packet.

If we don't handle the arphrd type of an interface, and fall back on
cooked mode, report the arphrd type, so we know what type we should
consider supporting (if that type can't be supported well, e.g.  if you
don't get any link-layer header, as happens with PPP, we'd be silent).
2000-10-25 07:46:49 +00:00
guy 5c4a950507 Clean up the lexical analyzer if we return normally from
"pcap_compile()", not just if we return with an error, so that we don't
leak memory by allocating a Flex buffer for the expression to be parsed
but not freeing it.
2000-10-25 07:28:22 +00:00
guy c900791477 The Linux "pcap_setfilter()" makes a copy of the filter it's handed, and
installs that copy; when closing a pcap_t on Linux, free that copy.
2000-10-25 06:59:09 +00:00
guy fd8a7488b1 If we're reading from a savefile, don't try to install a kernel packet
filter.

It appears that "recvfrom()", in 2.2 and later kernels, doesn't check
whether the starting buffer address plus the byte count goes into an
unmapped region of the address space - it (or code it calls) presumably
only checks the locations into which it's actually copying data - so
there doesn't appear to be, on systems with 2.2 and later kernels, any
need to ensure that the buffer size is at least large as the snapshot
length.  We therefore only do so if we're using the old
PF_INET/SOCK_PACKET mechanism; if we're using PF_PACKET, we're on a
2.2 or later kernel, so we don't do it there.
2000-10-25 05:59:04 +00:00
fenner 72f94b6459 Eliminate __P(). 2000-10-23 19:32:20 +00:00
guy 4bff247486 Oh, well, maybe *next* time I'll remember that the names are in
alphabetical order by first then last name.
2000-10-22 04:18:44 +00:00