dect
/
libpcap
Archived
13
0
Fork 0
Commit Graph

1517 Commits

Author SHA1 Message Date
fenner cae054001c Optimize out "jset #0" (always false) and "jset #ffffffff" (always true). 2001-11-12 22:02:50 +00:00
fenner 1c20fa1fee Zero out IPv6 mask before using it. This fixes expressions like
'net 2002::/16', which were previously non-deterministic based on
the previous contents of memory.

Reported by:	Pekka Savola <pekkas@netcore.fi>
2001-11-12 21:59:44 +00:00
fenner 98181e94fc Don't optimize away "sub #0" as it may be required to recognize
the code that is generated for e.g. 'icmp[0] > 0'.
2001-11-12 21:57:06 +00:00
guy 366751fb69 Close a file descriptor leak, as per a patch that comes with Nessus and
Pavel Kankovsky's suggested fix to that patch.
2001-11-11 22:32:28 +00:00
guy 88d9e6cb24 Reserve DLT_ type 118 for Cisco internal use, as per a request from
Gilbert Ramirez of Cisco.

More explicitly reserve 116 and 117 as well.
2001-11-02 08:03:39 +00:00
guy c781d3d992 Fix a call to "pcap_add_if()" that wasn't give a null-pointer
description argument.
2001-10-28 20:40:43 +00:00
guy dfc0d14d3b Add a description to the entry for the "any" device. 2001-10-28 20:31:05 +00:00
guy d71c1c4045 In the description of "pcap_datalink()", enumerate the link-layer types,
and give a description of the link-layer header if it's not directly
implied by the link-layer type.
2001-10-28 03:54:57 +00:00
guy db79c69108 Make the "is_loopback" field of a "pcap_if" structure a general "flags"
field, and make a PCAP_IF_LOOPBACK flag be the first flag bit in that
field, specifying whether the interface is a loopback interface; this
allows us to add more flags without changing the layout of the
structure.
2001-10-28 02:31:49 +00:00
guy c3736d4ff8 When using SOCK_PACKET sockets, which don't support cooked mode, reject
any link-layer types that would get mapped to cooked mode.
2001-10-25 18:09:59 +00:00
guy bc61a9fd37 We weren't returning a warning if the interface had an ARPHRD_ type we
didn't handle; fix the code to do so.

Remove the word "Warning" from the warning - tcpdump will add it when it
prints the warning, as will Ethereal and Tethereal.
2001-10-25 08:27:18 +00:00
guy 03c414f542 Don't print the warning for an ARP type not supported by libpcap, return
it in the error message buffer, as is done for warnings in other
implementations of "pcap_open_live()".
2001-10-25 06:46:14 +00:00
mcr 8ccdbcd8e5 started 0.7 CHANGES. 2001-10-23 04:37:31 +00:00
guy 6e796fb8ba Fix a typo and a formatting nit. 2001-10-13 06:28:53 +00:00
guy daa93e7a2d Add "stamp-h" and "stamp-h.in" to ".cvsignore"; they're already in
tcpdump's ".cvsignore".
2001-10-13 05:29:27 +00:00
fenner 26f0ba1e04 Add some optimizer debugging (not compiled by default) 2001-10-13 04:23:28 +00:00
mcr f3d3a0b363 clarified use of pcap_dump(3) parameters. 2001-10-12 21:43:29 +00:00
guy 5ad8d9d9e2 As suggested by Hyung Sik Yoon <hsyn@kr.ibm.com>, use 2 rather than 0 as
the SAP on AIX if a SAP of 1537 doesn't work; he says that 2 works on
Token Ring but 0 doesn't.
2001-10-12 06:43:42 +00:00
guy d5735e2448 Split off the code to scan "/proc/net/dev" into a separate routine, and
don't call it if we've already had an error.
2001-10-10 06:46:50 +00:00
guy 519b0b5a59 If we have "/proc/net/dev", and don't have <ifaddrs.h> (i.e., don't have
"getifaddrs()"), after processing the list returned by SIOCGIFCONF, scan
"/proc/net/dev" for interface names, and add to the list of interfaces
entries for those interfaces, with no associated addresses (if the
interfaces were already added, with addresses, from the list returned by
SIOCGIFCONF, they won't get added again).

Clean up the error handling a bit.
2001-10-09 05:43:19 +00:00
guy 5a85948f80 We don't actually use HAVE_FREEIFADDRS, so there's no point in checking
whether we have "freeifaddrs()" (we don't check whether we have
"getifaddrs()", and if we have "getifaddrs()" but not "freeifaddrs()",
we're stuck with leaking memory).

Give the "any" device an instance number of INT_MAX, so it shows up
after all other non-loopback devices.

"getifaddrs()" sometimes appears to supply a destination address even
for non-point-to-point interfaces (it did so on a FreeBSD 4.1 system);
don't use the broadcast address it supplies if an interface isn't a
broadcast interface, and don't use the destination address it supplies
if an interface isn't a point-to-point interface.

If we had an error constructing the list of interfaces, don't attempt to
add the "any" device to the list.
2001-10-09 03:53:38 +00:00
guy 79aeeee5ae Check in the updated configure script, from the following change to
aclocal.m4:

	revision 1.73
	date: 2001/09/14 08:08:15;  author: torsten;  state: Exp;  lines: +2 -2
	The Itanium does not like unaligned memory accesses (the Linux kernel
	warns about them and probably performance suffers). Therefore I added
	the cpu to the list of systems where unaligned access should be avoided.
	See also http://bugs.debian.org/112152
2001-10-08 10:19:55 +00:00
guy 2ae227c882 Bump the version to 0.7. 2001-10-08 08:17:03 +00:00
guy 9c0a593a2e From Scott Gifford:
Add a new "pcap_findalldevs()" routine to get a list of all
	interfaces that can be opened with "pcap_open_live()", and a
	"pcap_freealldevs()" routine to free the list.

	Make "pcap_lookupdev()" use it, which also arranges that it will
	not return a device that cannot be opened by "pcap_open_live()".

	Allow the "any" device to be opened, on Linux, with "promisc"
	non-zero; ignore the request for promiscuity, and return a
	warning message indicating that promiscuous mode isn't supported
	on the "any" device.

Document "pcap_findalldevs()" and "pcap_lookupdev()", and clean up some
items in the libpcap man page.
2001-10-08 01:06:20 +00:00
guy 2de302a362 ARPHRD_ARP doesn't uniquely specify the header that will appear on
packets before the network-layer header; we already deal with that in
tcpdump, and we could probably try to deal with that in the code
generator, but it's less of a pain to just punt to DLT_LINUX_SLL.
2001-09-23 22:43:57 +00:00
fenner ecead9709d Reset the VLAN flags when compiling a new expression.
This allows correct compilation of multiple expressions
 containing the "vlan" keyword in the same program.

Reported by:	Jon Dugan <jdugan@ncsa.uiuc.edu>, on the bro@lbl.gov list
2001-09-20 00:24:24 +00:00
torsten 6aa0217fdb The Itanium does not like unaligned memory accesses (the Linux kernel
warns about them and probably performance suffers). Therefore I added
the cpu to the list of systems where unaligned access should be avoided.
See also http://bugs.debian.org/112152
2001-09-14 08:08:15 +00:00
fenner 9156c4fbfd Revert to catching only bogus ethernet addresses that end in a colon,
since the updated expression caught the "4:2" in "ip[4:2]".
2001-09-14 01:40:57 +00:00
guy c8c9f4c3aa Reflect the renaming of "INSTALL" to "INSTALL.txt". 2001-09-09 19:36:25 +00:00
guy 7acd15ba8d Reserve 116 for IP Filter capture files and 117 for OpenBSD DLT_PFLOG. 2001-09-09 05:02:28 +00:00
guy b57608cf35 LINKTYPE_IEEE802_11 and LINKTYPE_LOOP, and DLT_IEEE802_11, are no longer
reserved for future use; they're being used.

Move other currently-being-used LINKTYPE_ values above the "reserved for
future use" comment, to make it clear which types are reserved and which
are already in use.

Note that 100 through 103 shouldn't be used for new DLT_ types.
2001-09-09 04:27:18 +00:00
guy ba047e2bd0 Add a DLT_ value and a link-layer type value for savefiles for Acorn
Econet.
2001-09-05 04:27:23 +00:00
guy 545afab583 Changes from Pavel Kankovsky to reset the kernel filter in
"pcap_setfilter()" if we're not using a kernel filter, in case a
previous call to "pcap_setfilter()" had succeeded in adding a kernel
filter, as if we're doing userland filtering we need to get rid of all
kernel filters that might discard packets that'd pass the userland
filter.
2001-08-30 03:08:43 +00:00
guy cec0453730 Patch, based on a patch from Pavel Kankovsky <kan@dcit.cz>, to flush all
packets queued up on the socket when we set a kernel filter on the
socket, so that if there are any queue-up packets that wouldn't have
passed the new filter, we don't see them.  (Some other packet capture
mechanisms do this automatically; this prevents tcpdump, for example,
from showing or saving, when run with a filter, some packets that
wouldn't have passed the filter.)

XXX - do we have to do this on any other platforms?

Choose whether to compile in the code to modify filter programs for use
in the kernel, and to flush queued-up packet and set a kernel filter, on
whether SO_ATTACH_FILTER is defined (i.e., on whether we have kernel
filter support in our build environment), rather than on whether
HAVE_PF_PACKET_SOCKETS is defined (i.e., on whether we have PF_PACKET
support in our build environment), as we choose whether to *use* that
code based on whether SO_ATTACH_FILTER is defined.
2001-08-25 05:08:26 +00:00
guy 96943e6868 In "pcap_read_packet()", always use "handle->buffer + handle->offset" as
the pointer to the beginning of the link-layer header; never use just
"handle->buffer", as, if "handle->offset" is non-zero (as is the case
with many link-layer types, including Ethernet), "handle->buffer"
doesn't point to the beginning of the link-layer header.
2001-08-24 09:27:14 +00:00
guy 8d039ab3b6 Define MSG_TRUNC as 0x20 if it's not defined, so that if this is
compiled on a system that doesn't have it, it'll use it on systems that
do have it.

On systems with MSG_TRUNC support (i.e., 2.2 and later kernels), there's
no need to read in the entire packet in order to find out how large it
is, so just allocate a buffer big enough for a snapshot length's worth
of data, and just read that much data.

There's no need for a "readlen" member of the "pcap_md" structure, as
the byte count to "recvfrom()" is just the "bufsize" member of the
"pcap_t" structure.
2001-08-24 07:46:52 +00:00
guy 626de160d6 Move the code to allocate the packet buffer into "pcap_open_live()", so
that we don't have almost-duplicate code in "live_open_old()" and
"live_open_new()".  This fixes a bug wherein "live_open_new()" wasn't
making the buffer size the maximum of "enough to hold packets of the MTU
obtained from the socket" and "the snapshot length" (for some reason,
"recvfrom()" was copying more data than the MTU obtained from the
socket).
2001-08-23 16:36:41 +00:00
fenner 6b8e18fa5a The rev 1.79 commit somehow undid the changes from 1.75.
Put them back.
2001-08-20 18:24:16 +00:00
fenner 144240e695 Fix some lexer bugs:
- Bad ethernet addresses no longer have to end with a colon
- Host names no longer have to be at least two characters long
- Bad tokens no longer have to end with an "i"
2001-08-20 18:17:29 +00:00
guy 380a3dbf49 From Scott Barron <sb125499@ohiou.edu>: use the
SOL_PACKET/PACKET_STATISTICS "getsockopt()" call, on Linux kernels that
support it, to get packet statistics, so that we can report the number
of dropped packets, and always use <linux/if_packet.h> to get
definitions for PF_PACKET sockets, so that we don't depend on glibc's
header files having been updated to support all the latest shiniest
kernel features (many systems with 2.4[.x] kernels don't have a
<netpacket/packet.h> that defines "struct tpacket_stats", for example,
so we wouldn't have been able to support that kernel feature on those
systems).
2001-07-29 18:25:46 +00:00
guy 11c1cf8ee2 Add comments to "pcap_stats()" indicating what the counters mean on the
various platforms (assuming the vendors' documentation is correct and
that I've correctly interpreted it).
2001-07-29 01:22:40 +00:00
guy a891a1d5d0 On AIX, if binding to the SAP 1537 fails, try binding to 0; Token Ring
devices appear to reject attempts to bind to 1537, perhaps because Token
Ring devices use SAPs rather than Ethertypes and 1537 isn't a valid SAP
value.

Try to supply a string rather than a numerical value for various DLPI
errors, and to supply a string rather than a numerical value for
unexpected DLPI primitives.

Cast the argument to <ctype.h> macros to "unsigned char", to eliminate
GCC warnings and to keep the macros from referring outside an array when
handed bytes with the 8th bit set.
2001-07-28 23:12:48 +00:00
guy b92ebafe8e Cast the argument to <ctype.h> macros to "unsigned char", to eliminate
GCC warnings and to keep the macros from referring outside an array when
handed bytes with the 8th bit set.
2001-07-28 22:56:34 +00:00
guy 7fd1de18e7 Add ENDT_SLIP, ENDT_PPP, ENDT_LOOPBACK, and ENDT_TRN to the case
statement checking the link-layer type.

Give an error if we see a link-layer type we don't handle, rather than
assuming Ethernet - there's no guarantee that the framing is Ethernet
framing.

If we succeeded in opening the packetfilter device, but had an error
later, close the device before returning from "pcap_open_live()".
2001-07-28 22:53:07 +00:00
guy 0c2cc33435 Fix a typo. 2001-07-04 07:34:50 +00:00
guy ca3fec5964 Fix a memory leak found by Miklos Szeredi
<Miklos.Szeredi@eth.ericsson.se> - "pcap_ether_aton()" allocates memory
for the MAC address, but we don't free it when we're done with it.

Code inspection revealed that there's a similar problem with
"pcap_ether_hostton()"; fix that as well.
2001-07-03 19:15:47 +00:00
guy db2a1d1e5e The "dl_module_id_1" and "dl_module_id_2" members of a
"dl_hp_ppa_info_t" are arrays of "u_char" (or "u_int8_t"), presumably to
get around the problems of signed characters; this causes complaints
from HP's C compiler if we pass them as an argument to "strcmp()", so
cast them to "const char *".
2001-06-27 05:22:44 +00:00
guy 70836ff6e9 Put a "return (0);" into "__pcap_nametodnaddr()" to squelch complaints
the Digital^H^H^H^H^H^H^HTru64 UNIX C compiler.
2001-06-27 05:11:48 +00:00
guy 7aa547ff09 Change from NetBSD, by Martin Husemann <martin@netbsd.org>:
Adapt to (temporary) DLT_PPP_ETHER useage by the pppoe code in tree
	now. This needs to be fixed when a generic PPP sheme is implemented.
2001-06-20 07:12:38 +00:00
itojun b63de9ed9e bsdi3 does not have IF_NAMESIZE (kame/bsdi3 has it). have last-resort #define. 2001-06-18 23:43:16 +00:00