aboutsummaryrefslogtreecommitdiff
path: root/pcap-airpcap.c
Commit message (Collapse)AuthorAgeFilesLines
* airpcap: format an error message if we run out of memory.Guy Harris2023-06-241-1/+4
| | | | | | If we can't allocate the list of DLT_ values, format a message; if PCAP_ERROR is returned, the caller will expect pcap_geterr() to return a pointer to an appropriate error message.
* Prefix routines declared in pcap-int.h with pcap_.Guy Harris2023-05-261-3/+3
| | | | | This avoids potential and, in one case (SIMH), actual collisions with names in other libraries or in applications using libpcap.
* struct pcap: Update buffer type from "void *" to "u_char *"Francois-Xavier Le Bail2023-05-181-1/+1
| | | | | | | | | | | | | | | | | | | | | This change should avoid these cppcheck warnings: pcap-hurd.c:77:18: warning: 'p->buffer' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [arithOperationsOnVoidPointer] pkt = p->buffer + offsetof(struct net_rcv_msg, packet) ^ pcap-hurd.c:78:8: warning: 'p->buffer+offsetof(struct net_rcv_msg,packet)' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [arithOperationsOnVoidPointer] + sizeof(struct packet_header) - ETH_HLEN; ^ pcap-hurd.c:79:25: warning: 'p->buffer' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [arithOperationsOnVoidPointer] memmove(pkt, p->buffer + offsetof(struct net_rcv_msg, header), ^ Remove some '(u_char *)' casts accordingly.
* Make sure no read routine process more than INT_MAX packets.Guy Harris2022-01-261-0/+3
| | | | | | | | | | | | | | | | | | | 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.
* airpcap: don't treat the absence of airpcap.dll as an error.Guy Harris2021-02-251-2/+9
| | | | | Most users probably won't have it installed, so treat its absence as an indication that they don't have an AirPcap device.
* Clean up allocation of some lists.Guy Harris2020-09-271-1/+1
| | | | | | | | 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.
* airpcap: squelch some warnings about enum values not handled in switches.Guy Harris2020-07-031-0/+1
| | | | Treat AIRPCAP_LT_UNKNOWN as meaning the link-layer type is unknown.
* 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.
* airpcap: fix an snprintf() call.Guy Harris2020-06-171-1/+1
| | | | | | | The argument to the format should be airpcap_errbuf, which is where the call to AirpcapGetDeviceList() put the raw error string. Found by cppcheck as run by fxlb.
* Remove some trailing tabsFrancois-Xavier Le Bail2020-06-171-3/+2
| | | | | | Moreover: Remove some spaces before tabs. Remove an extra blank line.
* npf, airpcap: fill in ps_capt iff _WIN32 is defined.Guy Harris2020-05-301-1/+5
| | | | | | | | struct pcap_stat has a ps_capt member iff _WIN32 is defined, so fill in our structure's ps_capt member iff _WIN32 is defined. (We *never* fill it in for pcap_stat(), as we cannot guarantee, *even on Windows*, that a structure passed to us will have them; we fill in a structure that *we* set up for pcap_next_ex(), so we don't have to worry about that.)
* airpcap: don't check for -1 being returned from device_is_airpcap().Guy Harris2020-05-301-4/+0
| | | | | device_is_airpcap() doesn't return -1, so there's no need to check for it.
* airpcap: have our own breakloop routine.Guy Harris2020-05-301-0/+19
| | | | | Have it set the read event, just as the NPF code does, so that, if we're blocking on a read, pcap_breakloop will wake us up.
* airpcap: set the initial DLT_ based on the current link type.Guy Harris2020-05-301-2/+45
| | | | | It's not guaranteed to be 802.11+radiotap; it can be configured with the AirPcap configuration tool.
* airpcap: remove some code copied-and-pasted from another file.Guy Harris2020-05-291-6/+0
| | | | | Some Sun code ay impose a minimum snapshot length of 96, but AirPcap doesn't.
* Fix more AirPcap API calls.Guy Harris2020-05-291-2/+2
| | | | Found, like the previous ones, by @gvanem.
* airpcap: make all AirPcap calls through function pointers.Guy Harris2020-05-291-4/+8
| | | | | | | | | | | | We load the AirPcap DLL at run time, rather than statically linking with it, so we must make all calls to AirPcap routines through function pointers set when we first load the DLL. Call AirPcapClose() and AirpcapFreeDeviceList() through the existing pointers. Add a new pointer for AirpcapSetDeviceMacFlags(), set it at DLL load time, and call through that pointer.
* airpcap: change a cast to squelch a warning.Guy Harris2020-05-081-1/+1
| | | | | The argument in question is of type PBYTE, whatever that might be, not char *.
* Support AirPcap devices with a pcap module.Guy Harris2020-05-071-0/+984
This allows us to update the support for newer APIs in the future - and in the present, with pcap_set_datalink() - and would allow Npcap to remove its AirPcap support. Add another test program, while we're at it.