| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|\
| |
| | |
Add support for Realtek (Ethertype) DSA data
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Realtek switchtag rtl4a (4 bytes long, protocol 0xA) and rtl8_4 (8 bytes
long, protocol 0x04) are Ethertype DSA tags, inserted in the Ethernet
header similar to an 802.1Q tag. Both shares the same Ethertype 0x8899
as other Realtek proprietary protocols.
Realtek switchtag rtl8_4t is identical to rtl8_4 but positioned before
the CRC, at the end of the Ethernet frame.
|
| |
| |
| |
| |
| |
| |
| | |
If map_arphrd_to_dlt() fails, free sock_fd before returning the error
status, as we do elsewhere.
Fixes Coverity CID 1539177.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* amount
* anymore
* authentication
* availability
* bracket
* captured
* casted
* communications
* compliant
* configurable
* cumulate
* deinitialize
* descriptors
* didn't
* disassembler
* disassociate
* distributions
* divvy
* doing
* entries
* everything
* explicitly
* explosion
* expression
* extracting
* failed
* family
* find
* github
* global
* implementations
* incorrectly
* intel
* interlocked
* justifying
* know
* launched
* libraries
* malloced
* mask
* maximum
* network
* nonexistent
* number
* occurred
* optimizer
* overflow
* overwrite lower
* packet
* packetfilter
* packets
* parse hosts
* payload
* phase
* programmers
* promiscuous
* protocol
* receiving
* redefinition
* sampling
* savefile
* schwartz
* should
* snapshot
* something
* specifies
* straightforward
* stream
* subdir
* support
* surrogate
* suse
* system is
* test with
* than
* those
* unmaintained
* valid
* way
* western
* wireshark
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
|
| |
| |
| |
| |
| |
| |
| |
| | |
Some code already was doing that (for example, pcap-bpf.c if fetching
the DLT list with an ioctl), and, if you can't allocate a DLT_ list,
which is usually pretty small, you may have other memory allocation
problems later, so letting the program open an interface (and not get a
correct list of all link-layer types supported) may not be worth it.
|
| |
| |
| |
| |
| |
| |
| | |
The only thing DLT_LINUX_SLL2 adds is the interface index and, if we're
falling back on cooked captures just because we don't have a DLT_ to
which to map the ARPHRD_ type, we're capturing on a single device and
the interface index adds no additional information.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Don't overwrite PCAP_WARNING_ codes with 0 (success).
While we're at it, clean up some leftovers from when we supported older
Linux kernels and failures to, for example, set up PF_PACKET sockets or
to set up a memory-mapped buffer meant "fall back on older mechanisms"
rather than "fail".
|
| |
| |
| |
| |
| |
| | |
Only test for "I don't know what DLT to map this ARPHRD to" case once
and, if we don't know that, set the error message and arrange that we
return PCAP_WARNING.
|
| |
| |
| |
| |
| |
| |
| |
| | |
There's no good run-time test, so we test at configure time, by checking
whether /usr/include/inet/ipnet.h exists and contains IPNET_ANY_LINK.
See https://github.com/the-tcpdump-group/tcpdump/issues/1057#issuecomment-1584088911
We make a common routine to use to add that device.
|
| |
| |
| |
| |
| | |
This avoids potential and, in one case (SIMH), actual collisions with
names in other libraries or in applications using libpcap.
|
| | |
|
| |
| |
| |
| | |
32-bit code.
|
| | |
|
|\ \
| | |
| | | |
Close the eventfd if we are non-blocking
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The eventfd is used to break out of a poll() before it
times out, used by pcap_breakloop(). If we are non-blocking,
then the eventfd is never needed, so we close it. (And
open a new eventfd if we switch to blocking).
|
| | |
| | |
| | |
| | | |
[skip ci]
|
|/ /
| |
| |
| | |
[skip ci]
|
| |
| |
| |
| |
| | |
Don't just do it if we're using DLT_LINUX_SLL2 up front; that can be
changed by the software using libpcap at any point.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Its function is to set up the socket for capture, so call it
setup_socket(). "pf_packet" in "activate_pf_packet()" iss redundant, as
the only type of socket we now support is PF_PACKET (we dropped support
for systems without PF_PACKET sockets a while ago), and it doesn't do a
full activation, it just does some socket setup.
|
| |
| |
| |
| |
| |
| |
| | |
Don't bother checking whether it's supported; if it's not, we just fail.
Update a comment to reflect that, as we require 2.6.27 or later, we
always use memory-mapped capture and we always use PACKET_RESERVE.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
We require Linux 2.6.27 or later, and that version has PACKET_AUXDATA.
Also update a question to reflect that 1) the build will fail before
that point if it's not building for 2.6.27 or later, so auxiliary data
is guaranteed to be supported and 2) it appears that, for memory-mapped
capture - which is all we support - the auxiliary data is provided
regardless of whether it's enabled.
This was noticed in issue #1105; the PACKET_AUXDATA support wasn't
getting compiled in.
|
| |
| |
| |
| |
| |
| |
| | |
The change to the linktype might change the offset at which to insert
VLAN tags (or change it to -1, meaning "don't insert VLAN tags").
This should fix issue #1105.
|
| |
| |
| |
| | |
If there's no more information to provide, provide an empty string.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Provide a suggestion for PCAP_ERROR_PERM_DENIED and
PCAP_ERROR_PROMISC_PERM_DENIED; the suggestion may be nothing more than
"you might require root permission", but at least it's something.
Note also what we were trying to do, to indicate that the problem might
be that you need root permission to set promiscuous mode even if you
don't need it to capture, or that you need CAP_NET_ADMIN permission to
change the time stamp mode of an adapter on Linux even though you don't
need it to capture. (The latter was done as per the discussion in issue
and that triggered the same double-free bug that failing to set up the
memory-mapped ring buffer caused in issue #1054.)
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
iface_get_ts_info() does use an ethtool ioctl whose name ends with
GET_TS_INFO to fetch information about the adapter's time stamping
support, but the goal is to get the types of time stamping we support.
Rename it to iface_get_ts_types() to make it clearer what it does.
Update a comment to express a hope that said ioctl has been fixed not to
lie as much as it did when I sent that message to linux-netdev back in
2016 (the ixgbe driver appears to have been fixed).
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Always define an internal iface_get_ts_info() routine to fetch the time
stamp types, even if there's no support for time stamp types - in that
case, we simply don't set any time stamp types.
This gets rid of an #ifdef in pcap_create_interface(), and avoids some
potention "argument not used" warnings.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
If attempting to set a kernel filter gets ENOMEM, print a message
suggesting that they increase the value of the net.core.optmem_max
sysctl.
See GitHub issue #1089 for an example of a complicated but not too
complicated filter that exceeds the default "other/option memory per
socket" maximum.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Some read routines don't read a single bufferful of packets and process
just those packets; if packets continue to be made available, they could
conceivably process an arbitrary number of packets.
That would mean that the packet count overflows; either that makes it
look like a negative number, making it look as if an error occurred, or
makes it look like a too-small positive number.
This can't be fixed by making the count 64-bit, as it ultimately gets
returned by pcap_dispatch(), which is defined to return an int.
Instead, if the maximum packet count argument to those routines is a
value that means "no maximum", we set the maximum to INT_MAX. Those
routines are *not* defined to loop forever, so this isn't an issue.
This should fix issue #1087.
|
|
|
|
|
|
|
|
| |
This reverts commit e9eaad85f3888c72f79de705fae7e0768d8a622d.
We only need to do this for CAN FD frames; readers of the frames can use
thse heuristics to determine whether to trust the len8_dlc field without
our help.
|
|
|
|
|
|
| |
We already clean it up for CAN FD frames; clean it up for classic CAN
frames as well, to allow heuristics to be used to try to guess whether
the len8_dlc field was filled in.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If the protocol is CAN FD, clear out all bits in the flags field other
than the defined ones, and clear out the two reserved fields.
If the protocol is *not* CAN FD, clear the CAN FD flag, to make sure the
packet is interpreted as classic CAN, not CAN FD.
This is done just in case the kernel or driver put uninitialized junk in
the reserved bits of the CAN header, as has apparently happened in at
least some LINKTYPE_CAN_SOCKETCAN captures, to allow programs reading
those captures to attempt to distinguish "CANFD_FDF is set because the
frame is an FD frame" from "CANFD_FDF is set because the fd_flags field
contains uninitialized junk".
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Don't provide a DLT_LINUX_SLL header. Instead, tweak the header
provided by the kernel to 1) put the "CAN ID and flags" field in host
byte order, as that's what DLT_CAN_SOCKETCAN specifies and 2) check
whether the protocol field provided as metadata (which we normally
incorporate into a DLT_LINUX_SLL header) is CAN FD rather than CAN and,
if it's CAN FD, set the CANFD_FDF flag in the DLT_CAN_SOCKETCAN header's
flags field, to indicate to the reader of the packets that it's CAN FD
rather than CAN classic.
This addresses GitHub issue #1052.
Incorporates some changes from GitHub pull request #1035.
|
|
|
|
| |
That avoids double-free crashes on certain errors; see GitHub issue
|
|
|
|
|
|
|
|
| |
The protocol field is big-endian, not host-endian (it's big-endian in an
sk_buff, and that makes it all the way to userland), so convert it to
host order before comparing with the CAN and CAN FD protocol types.
This addresses part of GitHub issue #1051.
|
| |
|
|
|
|
|
|
|
|
| |
Not all compilers that are used to compile code to run on Linux have
these builtins. For example, older versions of GCC don't, and at least
some people are doing cross-builds for MIPS with older versions of GCC.
This should fix GitHub issue #1003.
|
| |
|
|
|
|
| |
[skip ci]
|
| |
|
|
|
|
|
|
|
|
| |
Always heck wehther the allocation succeeds, and fail if it doesn't.
Set the count of elements of the list only if the list was successfully
allocated. For stylistic consistency, also seet it after we've set all
the elements of the list.
|
|
|
|
| |
Restore and clarify the removed note, fix a couple unrelated issues.
|
| |
|
|\
| |
| | |
Linux: proper memory sync for PACKET_MMAP.
|
| |
| |
| |
| |
| |
| |
| | |
Release and acquire packets using GCC builtins (compatible with
many other common-place compilers).
Should fix #898.
|
| |
| |
| |
| |
| |
| |
| | |
This should fix GitHub issue #941 by getting rid of the code with the
issue; see it for a discussion of why we're getting rid of it (tl;dr:
the wireless extensions stuff is old and tired and netlink should be
used instead).
|
| |
| |
| |
| |
| |
| |
| | |
That's what's been done for a while with BPF and what we're now doing
for NPF in WinPcap and Npcap.
[skip ci]
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The sizeof operator and alignof macro can be given a type "name" that's
anonymous, e.g. sizeof(struct { int a; char *b; }). Have
pcap_create_common() and pcap_open_offline_common() take, as arguments,
the total size of a structure containing both the pcap_t and the private
data as members, and the offset of the private data in that structure,
and define macros that calculate those given, as an argument, the data
type of the private data.
This avoids making assumptions about the alignment of those two items
within the structure; that *might* fix GitHub issue #940 if the issue is
that the ARM compiler being used does 16-byte alignment of the private
structure, rather than the 8-byte alignment we were wiring in.
|
|
|
|
|
|
|
|
|
|
| |
It *should* never succeed, but 1) you never know and 2) that gets newer
versions of GCC, and Coverity, to stop whining that we're not checking
the return value of read().
(We can't check of the write() to the event FD without adding a new API
that's like pcap_breakloop() but that 1) returns a success/error
indication and 2) provides an error message.)
|