dect
/
libpcap
Archived
13
0
Fork 0
Commit Graph

54 Commits

Author SHA1 Message Date
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 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 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 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 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
itojun 142ff8d0c7 correct "protochain" processing. 2000-11-09 06:20:05 +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 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 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 98a503e843 Improved VLAN support, from Peter Jeremy - "vlan" filtering keyword,
letting you filter based on the VLAN to which a packet belongs, and an
improvement to the printing of VLAN packets (adding an extra space to
separate the VLAN priority and flags from the next stuff printed).
2000-10-22 04:15:55 +00:00
guy 2c961ff224 Get rid of the PCAP_ENCAP_ values - if an application uses them, that
application won't build with any other version of libpcap, which means
that a lot of applications won't use them.  In addition,
"pcap_linktype()" needs to return DLT_ values, so that platforms that
build libpcap as a shared library won't break binary compatibility if
they update to this version of libpcap.

Instead, we map from DLT_ values to LINKTYPE_ values when writing
savefiles, and map from LINKTYPE_ values to DLT_ values when reading
savefiles, so that savefiles don't have platform-dependent DLT_ values
in the header as the link type, they have platform-independent LINKTYPE_
values.

This means we don't need to make DLT_ATM_RFC1483, DLT_RAW, etc. have
platform-independent values starting at 100 - only the values in the
savefile header need to be like that.
2000-10-12 03:53:57 +00:00
guy fd7f1bf605 Include <string.h> to declare various string-manipulating routines. 2000-10-10 04:53:08 +00:00
guy 79e2793fb3 Make "gen_protochain()", as it's not used outside "gencode.c", and
declare it before it's defined.
2000-10-06 04:52:53 +00:00
guy 6ef0c9a172 Add definitions of Ethernet types from
"linux-includes/netinet/if_ether.h" to "ethertype.h", and remove
includes of <netinet/if_ether.h> from files that only include it to get
ETHERTYPE_ values defined.
2000-09-23 07:26:27 +00:00
guy 8439f66a3f In "init_linktype()", map DLT_ codes that don't have the same value as
the equivalent PCAP_ENCAP_ codes to the corresponding PCAP_ENCAP_ code
so that the code generator need check only the PCAP_ENCAP_ codes.

Handle PCAP_ENCAP_PPP_HDLC just like PCAP_ENCAP_PPP.
2000-09-18 06:39:44 +00:00
guy 781fae3571 Introduce a set of PCAP_ENCAP_ codes to specify packet encapsulations.
For those PCAP_ENCAP_ codes corresponding to DLT_ codes that are
(believed to be) the same in all BSDs, the PCAP_ENCAP_ codes have the
same values as the corresponding DLT_ codes.

For those PCAP_ENCAP_ codes corresponding to DLT_ codes that were added
in libpcap 0.5 as "non-kernel" DLT_ codes, or had their values changed
in libpcap 0.5 in order to cope with the fact that those DLT_ codes
have different values in different systems, the PCAP_ENCAP_ codes have
the same values as the corresponding DLT_ codes.

We add some additional PCAP_ENCAP_ codes to handle IEEE 802.11 (which
currently has its link-layer information turned into an Ethernet header
by at least some of the BSDs, but John Hawkinson at MIT wants to add a
DLT_ value for 802.11 and pass up the full link-layer header) and the
Classical IP encapsulation for ATM on Linux (which isn't always the same
as DLT_ATM_RFC1483, from what I can tell, alas).

"pcap-bpf.c" maps DLT_ codes to PCAP_ENCAP_ codes, so as not to supply
to libpcap's callers any DLT_ codes other than the ones that have the
same values on all platforms; it supplies PCAP_ENCAP_ codes for all
others.

In libpcap's "bpf/net/bpf.h", we define the DLT_ values that aren't the
same on all platforms with the new values starting at 100 (to keep them
out of the way of the values various BSDs might assign to them), as we
did in 0.5, but do so only if they're not already defined; platforms
with <net/bpf.h> headers that come with the kernel (e.g., the BSDs)
should define them with the values that they have always had on that
platform, *not* with the values we used in 0.5.

(Code using this version of libpcap should check for the new PCAP_ENCAP_
codes; those are given the values that the corresponding DLT_ values had
in 0.5, so code that checks for them will handle 0.5 libpcap files
correctly even if the platform defines DLT_RAW, say, as something other
than 101.  If that code also checks for DLT_RAW - which means it can't
just use a switch statement, as DLT_RAW might be defined as 101 if the
platform doesn't itself define DLT_RAW with some other value - then it
will also handle old DLT_RAW captures, as long as they were made on the
same platform or on another platform that used the same value for
DLT_RAW.  It can't handle captures from a platform that uses that value
for another DLT_ code, but that's always been the case, and isn't easily
fixable.)

The intent here is to decouple the values that are returned by
"pcap_datalink()" and put into the header of tcpdump/libpcap save files
from the DLT_ values returned by BIOCGDLT in BSD kernels, allowing the
BSDs to assign values to DLT_ codes, in their kernels, as they choose,
without creating more incompatibilities between tcpdump/libpcap save
files from different platforms.
2000-09-17 04:04:36 +00:00
torsten 64c7184aa6 Fixed the BPF compiler for Linux. The BPF code used to truncate the
packets after the snaplen. On Linux this hinders us from inquiring
the original packet size so I removed that feature for Linux builds.
2000-08-06 01:22:39 +00:00
guy c8c2e7e65b Token Ring support, from various patches. Also add "tr" as an alias for
"ether", "fddi", "link", etc..
2000-07-25 05:50:08 +00:00
guy 0d0297bdd1 Older versions of Flex (e.g., 2.5.2, which at least one user had) dump
core if the YY_FLUSH_BUFFER macro is called when there's no current
buffer (e.g., before any scanning has been done).

So, instead, when using Flex, we use "yy_scan_string()" to specify that
the scanner should read from the filter expression string, rather than
defining our own YY_INPUT macro, and we add a "lex_cleanup()" routine,
called after parsing is complete, to delete the buffer allocated by
"yy_scan_string()", which arranges that, when we next hand the scanner a
string, it doesn't then return to the parser cruft left over from the
previous parse.
2000-07-13 06:51:56 +00:00
assar 0e2f8c8892 add config.h, remove gnuc.h. remove __dead 2000-07-11 00:37:04 +00:00
assar 95cd5942c1 remove non-stdc code
remove unused variable warning
2000-07-01 03:32:50 +00:00
assar 2dffac5060 handle no link-layer
From Darren Reed <darrenr@reed.wattle.id.au>
2000-06-26 05:10:40 +00:00
itojun 299da87b7d -Wall -Werror clean. 2000-06-03 16:29:42 +00:00
itojun eb3914c790 nuke strcpy, one more. 2000-04-27 11:16:54 +00:00
itojun 6abf10866e nuke strcpy() 2000-04-27 11:16:19 +00:00
itojun a906e591fb revert renaming of pcap_nametoaddrinfo to pcap_nametoaddr. this gets
painful when upgrading old libpcap to tcpdump.org pcap (function rename
usually requires shlib major number bump, while api addition only require
minor)
2000-04-27 09:18:57 +00:00
itojun 20d9e08cde do not use sprintf(). always use snprintf().
from NetBSD/OpenBSD src/lib/libpcap.

use freeifaddrs() if exists.
2000-04-27 09:11:11 +00:00
assar 4343a38646 (gen_proto_abbrev): add fallback definition for IPPROTO_IGMP and use
constant
2000-04-01 11:44:59 +00:00
assar c9e00ba444 remove superfluous line for igrp. From Rick Jones <raj@cup.hp.com> 2000-04-01 11:37:45 +00:00
itojun e3ddb0ce0f improve message on ip{,6} host foo failure 2000-03-01 14:07:02 +00:00
itojun d27ad07fae fix "ip host foo" or "ip6 host foo" where foo has both A and AAAA records.
FreeBSD PR: 17083
2000-03-01 03:37:24 +00:00
fenner b04bc7d664 Eliminate duplicated word in comment. 2000-01-29 21:01:27 +00:00
mcr e660fb6947 This adds a new function that allows using the bpf compiler without
having a pcap open.  One could argue that this and the existing
	compiler should be factored in common routines, but I was trying to
	make it clear that this wouldn't break the existing code.
	from Greg Troxel <gdt@ir.bbn.com>
1999-12-08 19:54:03 +00:00
itojun 5b7ead9173 add configure option --disable-protochain, to make Arne happier. 1999-11-01 15:56:40 +00:00
itojun a1c72596a3 fix protochain operator on IPv4/v6. 1999-11-01 13:47:51 +00:00