summaryrefslogtreecommitdiff
path: root/pcap-dbus.c
Commit message (Collapse)AuthorAgeFilesLines
* Handle the pcap_t+private data in a fashion that makes fewer assumptions.Guy Harris2020-07-011-1/+1
| | | | | | | | | | | | | | | 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.
* Remove some workarounds for old compilers.Guy Harris2019-08-091-11/+11
| | | | | | | | | | | | | Require Visual Studio 2015 or later; fail if we don't have it, and remove checks for older versions. That means we have C99-compliant snprintf() and vsnprintf(); require them when configuring for UN*X, and then use them directly, rather than having wrappers for systems lacking them. If we're using MSVC, skip the tests for options to request C99 compatibility - either we have VS 2015, which is sufficient, or we don't, in which case we fail.
* Squelch more narrowing warnings.Guy Harris2018-09-121-1/+1
|
* Clean up the declaration of the packet-filtering routines.Guy Harris2018-08-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If net/bpf.h declares bpf_filter() one way and libpcap defines it another way, even pcap-bpf.c needs a declaration that matches how libpcap defines it, not how net/bpf.h (mistakenly) declares it. ("Mistakenly" because it should *not* be declaring the kernel's version of bpf_filter() unless it's being used in a *kernel* build; other *BSDs, and macOS, declare it only in kernel builds by testing for a #define such as KERNEL or KERNEL_PRIVATE, but NetBSD doesn't - it *should*, but it doesn't.) So we rename the internal-to-pcap filtering routine as pcap_filter(), which is not exported from libpcap, and have bpf_filter() be a wrapper around pcap_filter() that is exported. Use pcap_filter(), rather than bpf_filter(), for all filtering inside libpcap (except for filtering that uses bpf_filter_with_aux_data(), which we rename pcap_filter_with_aux_data()). Do the same for bpf_validate(), which is *also* declared in net/bpf.h, even for non-kernel builds, in NetBSD. As we're not exporting pcap_filter_with_aux_data(), don't even *declare* it in a public header; don't declare struct bpf_aux_data in a public header, either. That way we can change it without worrying about breaking APIs or ABIs; we may do that if, for example, we want to support the "inbound" and "outbound" filters when reading pcapng files, adding a direction indicator to that structure. Declare bpf_filter() in pcap/bpf.h even on NetBSD and QNX; pcap-bpf.c doesn't include pcap/bpf.h (it sets a #define to force pcap/pcap.h not to include it), so we won't get any collisions if net/bpf.h (which it does include) declares it. The only collisions will occur in programs that include *both* pcap/pcap.h or pcap/bpf.h *and* net/bpf.h, and that will occur only if net/bpf.h declares bpf_filter() even when building userland code, and the correct fix for *that* is to fix net/bpf.h not to declare them in non-kernel builds.
* Add more interface flags to pcap_findalldevs().Guy Harris2018-04-291-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We add: PCAP_IF_WIRELESS, which indicates whether the interface is "wireless" or not. PCAP_IF_CONNECTION_STATUS, which is a bitmask for a two-bit field that can have one of the values: PCAP_IF_CONNECTION_STATUS_UNKNOWN if the status of whether the interface is "connected" or "disconnected" is unknown; PCAP_IF_CONNECTION_STATUS_CONNECTED if the interface is "connected"; PCAP_IF_CONNECTION_STATUS_DISCONNECTED if the interface is "disconnected"; PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE if the notion of "connected" or "disconnected" doesn't apply to this interface. Take that into account when sorting interfaces in the interface list, penalizing "disconnected" interfaces, as you won't see traffic on them if they're not wireless and you'd have to be in some form of "monitor mode" to see traffic on them if they're wireless. This should address GitHub issue #700.
* Fix a set of trivial unused warningsJoerg Mayer2018-04-041-1/+1
|
* Use the right name for calls to wait for events.Guy Harris2018-01-201-3/+3
| | | | | | For the epoll mechanism, the call to wait for events is epoll_wait() (and epoll_pwait()); for the kqueue mechanism, the call to wait for events is kevent() (and additional calls in Darwin-based systems).
* Set the [gs]set non-blocking mode handlers up front on Windows.Guy Harris2017-10-011-2/+0
|
* Set the nonblock function pointer on Windows as well.Guy Harris2017-10-011-2/+0
| | | | | The function we're using just says "you can't do that", and can do so on UN*X and Windows.
* Catch attempts to get or set non-blocking mode before we're activated,Guy Harris2017-10-011-0/+11
| | | | just as we do after we're activated.
* Explicitly reject non-blocking mode on D-Bus and rpcap.Guy Harris2017-10-011-2/+24
| | | | | | | We currently don't support non-blocking mode on either of those, so have routines that return errors for pcap_getnonblock() and pcap_setnonblock(); you can't set those function pointers to null to say "we don't support it".
* Explain why you can't do select/poll/epoll/kqueue stuff etc. for D-Bus.Guy Harris2017-10-011-0/+22
| | | | | | That'd require a new API and the ability to have multiple selectable FDs for a single pcap_t *and* for the set of FDs to be able to change over time.
* excluded unavailable members of pcap_t on windowsAli Abdulkadir2017-10-021-0/+4
|
* Always include <config.h> rather than "config.h".Guy Harris2017-08-181-1/+1
| | | | | | | | This can prevent bizarre failures if, for example, you've done a configuration in the top-level source directory, leaving behind one config.h file, and then do an out-of-tree build in another directory, with different configuration options. This way, we always pick up the same config.h, in the build directory.
* Make the checks and adjustment of the snapshot length module-dependent.Guy Harris2017-06-011-0/+8
| | | | | | | | | | | | | Also, initialize the snapshot length to 0, meaning "not specified", so that the default snapshot length, if not specified, is also module-dependent. That way, D-Bus has a maximum and default of 128MB, as that's the maximum message size, but other capture devices have the current MAXIMUM_SNAPLEN, so we can handle full-size D-Bus messages without advertising an overly-large snapshot length for other devices, potentially causing libpcap and programs using it or reading libpcap files to allocate overly-large buffers for other capture devices.
* Support setting non-blocking mode before activating.Guy Harris2017-02-251-0/+1
| | | | | | | | | | | | | | | | | | We just set a flag and attempt to set non-blocking mode after activating. If a module can't support non-blocking mode, it should set the set non-blocking operator in the create routine, so a pre-activation call will fail the same way a post-activation call fails. While we're at it: Have the get non-blocking and set non-blocking modes not take an error buffer as an argument; they have the error buffer in the pcap_t to set. pcap_getnonblock() and pcap_setnonblock() just copy the error from there to the argument passed in. Make sure we set the cleanup op pointer when appropriate.
* Have a pcap_if_list_t structure for use by the findalldevs code.Guy Harris2017-01-181-3/+3
| | | | | | | It's not part of the API, but it's an internal structure used by the findalldevs code. Currently, it just has a pointer to the beginning of the list, but it could change in order to speed up the process of adding to the list.
* Clean up findalldevs code.Guy Harris2016-12-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Have a routine that unconditionally adds a device to the list of devices, without bothering to check whether there's already a device with that name, and a separate routine that does the check and, if it doesn't find the device, calls the routine to add ti. That avoids scanning the entire list in cases where we know the search will fail. The only reasons for doing the check are that we're on a platform where we find the list of interfaces by a call that returns a list of *addresses*, with an interface name attached to each address, and 1) for each address, we need to make sure we don't already have the interface, create it if we don't, and add the address to the now-guaranteed-to-exist entry for the interface; 2) we might have to make a *separate* call to enumerate interfaces, to find interfaces with *no* addresses, and that call also enumerates the ones that *do* have addresses, and we don't want to create a duplicate entry for them. Change some findalldevs helper routines to have "dev" rather than "if" in the name, as not all devices are regular network interfaces. For the DAG findalldevs routine, make sure it always provides an error message if it fails. We don't need add_addr_to_iflist() or get_if_description() on Windows, so don't define them on Windows. Update comments to reflect reality.
* Squelch more signed vs. unsigned comparison warnings.Guy Harris2016-07-251-1/+1
|
* make more pcap_create_common() fixesDenis Ovsienko2016-06-301-1/+1
| | | | | | | | | * CAN bus over USB on Linux * DAG * D-Bus * Septel * SNF * TurboCap
* Rename opt.source to opt.device.Guy Harris2016-06-291-2/+2
| | | | | | | For local captures, it's jut the device. If we add remote capture support, we'll be handed a URL, and will split the URL into multiple components, and will store the various components in the opt structure, with the path of the URL being opt.device.
* Use pcap_snprintf() instead of snprintf().Guy Harris2015-11-031-9/+9
| | | | | | | | | | | On UN*Xes with snprintf(), we just #define pcap_snprintf to snprintf. On UN*Xes without snprintf(), we provide our own, but call it pcap_snprintf(). On Windows, we have a routine that wraps _snprintf(), with C99 semantics (ensuring null termination if the string won't fit), called pcap_snprintf(), and use that.
* Fix warnings as "C++ style comments are not allowed in ISO C90"Francois-Xavier Le Bail2015-09-051-1/+1
|
* Delete trailing spaces/tabsFrancois-Xavier Le Bail2015-03-081-6/+6
|
* More findalldevs fixes.Guy Harris2013-09-291-4/+2
|
* Rename the "private" member of a pcap_t to avoid C++ issues.Guy Harris2013-08-071-5/+5
| | | | | "private" is a C++ keyword; rename the "private" member of a pcap_t to "priv" to avoid that, as per Gisle Vanem's suggestion.
* Move platform-dependent pcap_t data out of the pcap_t structure.Guy Harris2013-05-061-26/+34
| | | | | | | | | | | | | | | Put the private data right after the pcap_t structure, with a pointer to it in the pcap_t. The initial goal is to allow new pcap modules to be added without having to hack pcap-int.h. In the longer term, we may want to freeze the pcap_t structure, except possibly for adding new method pointers at the end, and provide an ABI for adding modules. We also put the stuff used by the read path at the beginning of the pcap_t structure, to try to keep it on the same set of cache lines.
* pcap-int.h must be included before pcap-dbus.h, to get pcap_t etc. defined.Guy Harris2013-04-121-1/+1
|
* Add a pcap-dbus.h header and include it in pcap-dbus.c and pcap.c.Guy Harris2013-04-121-4/+6
| | | | | | | | That way, we ensure that the same function prototypes are seen when dbus_create() and dbus_findalldevs() are defined and when they're used. Also, add pcap-dbus.c to the list of "extra" files in Makefile.in, so it goes into the release tarball.
* Pick up some fixes from a comment for the SourceForge bug for D-Bus support.Guy Harris2013-04-121-1/+1
| | | | | | | | | | Fix the help message for --enable-dbus to say --enable-dbus, not --enable-can, and call pcap_cleanup_live_common() rather than the nonexistent pcap_live_cleanup_common(). Also, say "D-Bus capture" in the help message, to spell it correctly and to clarify that we're only adding support for capturing on D-Bus (not adding support for libpcap using D-Bus for some purpose or another).
* pcap-dbus code from Jakub ZawadzkiMichael Richardson2013-04-121-0/+271