summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* linux: throw in a temporary hack to squelch MSAN warnings.libpcap-1.9Guy Harris2020-05-071-0/+11
| | | | (cherry picked from commit 858a202b939671ad315396b9f09a27a58cfb31ca)
* Remove an unused variableFrancois-Xavier Le Bail2020-05-041-1/+0
| | | | | | | The warning was: ./pcap-linux.c:3622:8: warning: unused variable 'protocol' int protocol = pcap_protocol(handle); ^
* Define _GNU_SOURCE on most platforms.Guy Harris2020-04-261-2/+6
| | | | | | | Don't assume only Linux and Cygwin are using GNU libc; GNU/HURD and Debian's kFreeBSD do. (cherry picked from commit 20348670d5f3f8746d85a9892aa312e7591da4de)
* Fix compiler warnings on MSYS2/CygwinOrgad Shaneh2020-04-261-1/+1
| | | | | | | | | | | | ./fmtutils.c:114:20: warning: initialization of 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion] 114 | char *errstring = strerror_r(errnum, strerror_buf, PCAP_ERRBUF_SIZE); | ^~~~~~~~~~ CMake executes the test for strerror_r with GNU_SOURCE defined, but the actual application did not define it. (cherry picked from commit 004d48aa51a5ec5488f477a7b318459ac1a09e26)
* Remove duplicate wordsFrancois-Xavier Le Bail2020-04-232-4/+4
| | | | [skip ci]
* Check for invalid IPv4 addresses.Guy Harris2020-04-132-2/+16
| | | | This should fix GitHub issue #893.
* More cleanups.Guy Harris2019-11-301-79/+97
| | | | | | | | | | | | | | | | Take an else clause for which the if clause returns out and put it at the top level. Rename activate_mmap() to setup_mmapped(), as it does part, not all, of the activation process. Put a bit more of that process into it, so it finishes the process (except for the final "set the protocol so packets are seen" part). Add a setup_non_mmapped() routine that finishes the non-memory-mapped setup process (except for the final "set the protocol so packets are seen" part). (backported from commit 769533f18b0f855acf6477841cb01f20b8dfd3a8)
* Make the code a bit more like the master branch.Guy Harris2019-11-301-15/+22
|
* Rename the activate routines to indicate what type of socket they handle.Guy Harris2019-11-291-10/+10
|
* Plug another memory leak.Guy Harris2019-11-281-1/+5
| | | | | | | | Again, if ibv_get_device_list() returns a non-null pointer, and sets the "number of devices" value to 0, we still have to free the list pointed to by the non-null pointer. (cherry picked from commit daa83500c5128404c76787996596306e97e6df91)
* Plug a memory leak.Guy Harris2019-11-281-3/+2
| | | | | | | | | | | | | | | | | | | | | If ibv_get_device_list() returns null, there's obviously no device list to free, so we can just return - and, as ibv_free_device_list() is not guaranteed to do nothing when passed a null pointer and, in fact, will try to dereference the null pointer, we *must* return without calling ibv_free_device_list(). However, if it returns a list, but there are no devices in the list, we still have to free the list - the list is terminated with a null pointer, so it's not empty. The loop for adding devices from the list will terminate immediately if numdev is 0, so don't bother to check whether it's zero, just run the loop, which will do nothing if numdev is 0, and fall through to free the device list. While we're at it, replace a goto with a break that does the same thing. (cherry picked from commit 3191c8b7bfd08088108e100411541a0a8b9ac936)
* Fix a typoFrancois-Xavier Le Bail2019-11-281-1/+1
| | | | | | [skip ci] (cherry picked from commit dd508736e4bd6be2b6b7bb1da1020a62c3e2544b)
* Fix a typolxy2019-11-281-1/+1
| | | | (cherry picked from commit 452002b25de5c2df6ed0855f5e7bc43d918c1a20)
* Remind people that if pcap_activate() fails, the pcap_t is still around.Guy Harris2019-11-282-0/+11
| | | | | | [skip ci] (cherry picked from commit b262e73dfdda6599b3b08750fcd6ff2a6a5a16c0)
* Fix the SOCK_PACKET handling.Guy Harris2019-11-211-8/+17
| | | | | There's no "bind to a protocol" support in SOCK_PACKET sockets; do that only for PF_PACKET sockets.
* Clean up the "set socket protocol only after packet ring configured" backport.Guy Harris2019-11-211-1/+6
| | | | | Add a comment from the original, and always open PF_PACKET sockets with a protocol of 0 in the activate code path.
* Revert "Put code to open PF_PACKET sockets into a common routine."Guy Harris2019-11-211-108/+42
| | | | | | This reverts commit 1ce0fdc186ef16ec42fecff9cfcda45010883b3e. Nice cleanup, but not necessary.
* Put code to open PF_PACKET sockets into a common routine.Guy Harris2019-11-211-42/+108
| | | | (backported from commit 818751a975fbd1894b975c5d5211c361fcb51f22)
* Set socket protocol only after packet ring configuredMark Marshall2019-11-201-24/+39
| | | | | | | | | | | | | | | | | When using the memory mapped packet receive path on Linux, we find that if the buffer is "large" we get a number of dropped packets. This number of packets is roughly proportional to the buffer size. It turns out that these packets are dropped by the kernel in the time period between the socket being opened and the ring parameter setup completing (this is where the kernel has to allocate the buffer memory). To prevent this, we can open the socket on protocol 0, which the kernel interprets to mean that we don't want to receive any packets at all (this is described when opening a memory mapped packet socket for TX only). We then set the correct protocol once everything is configured. Signed-off-by: Mark Marshall <mark.marshall@omicronenergy.com> (backported from commit 97f59a7d035397c7b4f4889ef5657be811b97e7a)
* If iface_bind() fails, that's a hard error.Guy Harris2019-11-201-15/+14
| | | | | | | | | | | | | | | If you can open a PF_PACKET socket, you don't need to fall back on PF_INET/SOCK_PACKET sockets, and we've already opened that socket by the time we call iface_bind(). Have iface_bind() return 0 on success and a PCAP_ERROR_ value on failure. If the bind() call fails with ENODEV, return PCAP_ERROR_NO_SUCH_DEVICE, otherwise return PCAP_ERROR. If getsockopt(SO_ERROR) fails, that's an error; if it succeeds, and supplies a pending error code, that's an error, too. (cherry picked from commit c3b7d60fc75835dd58f8410a458782aba8e7a360)
* Fix typo in pcap/pcap.h.Nan Xiao2019-11-201-1/+1
| | | | (cherry picked from commit 78ee739367e0a51e0c15fd5361baa1f113aca9ae)
* Make "{un}synced with the system clock" a property of more time stamp types.Guy Harris2019-11-173-13/+36
| | | | | | | | | | | | | | | Define PCAP_TSTAMP_HOST_{LOW,HI}PREC as synced with the system clock; add a new PCAP_TSTAMP_HOST_HIPREC_UNSYNCED type for high-precision time stamps not necessarily synced with the system clock. This should better match Npcap, including a proposed future "high precision and synced with the system clock" time stamps for Npcap on Windows 8 and later. (This may still not match what FreeBSD offers, but at least it removes an Npcap mismatch.) (cherry picked from commit bf0a7f8c86b95fc25a441cbc7969b4e2be2cbfaa)
* Use correct function name in outputting error information.Nan Xiao2019-11-173-3/+3
| | | | (cherry picked from commit c6b316144da97f81c0078d58fceed53fdb67f526)
* Fix typo in sf-pcap.c.Nan Xiao2019-11-171-1/+1
| | | | (cherry picked from commit 5c2d0460aa67ebdcf175a04bdefaccc25dda6c75)
* Fix typo in pcap/pcap.h.Nan Xiao2019-11-171-1/+1
| | | | (cherry picked from commit 9df3a2ff0602c9129407a1f6de677c606ea7c6a5)
* Do the check for a valid direction value in pcap_setdirection().Guy Harris2019-11-175-54/+50
| | | | | | | That way, we don't have to do the check in the individual setdirection op routines. (backported from commit ddbd32822b39dd2a5fb452cc1a7e9f5dd351b507)
* Let the common pcap code handle "setting the direction isn't supported".Guy Harris2019-11-091-7/+1
| | | | | | Just set the "set direction" operation pointer to null. (cherry picked from commit 108b0eecc5c876c4ce93e60207146add85fc978e)
* We don't check the direction, so don't support setting it.Guy Harris2019-11-091-8/+1
| | | | | | | | If there's a direction indicator in the packets we get, we should allow the direction to be set and should check it if it's "incoming only" or "outgoing only". Otherwise, we shouldn't allow the direction to be set. (cherry picked from commit 25a2cbb98b22171312ec894b906d56af6344dfeb)
* More pcap_setdirection() cleanups.Guy Harris2019-11-095-9/+55
| | | | | | | | | | Say "...on this device" for errors; it may be the OS's capture mechanism that doesn't support setting the direction, but there may be other devices on the system that *do* support it. Check the validity of the direction argument in more places. (backported from commit 2c2c323c392980edc4a1044f08d9c2889f336dd3)
* Cleaning spacesFrancois-Xavier Le Bail2019-11-096-16/+16
| | | | | | [skip ci] (cherry picked from commit 88a0f88dbe73f57b69940d1ede8d0eb375f13095)
* Cleaning spacesFrancois-Xavier Le Bail2019-11-095-16/+16
| | | | | | [skip ci] (cherry picked from commit b880df9ac467c6be1f14c94f97418e6848a5c9e5)
* Clean up direction setting.Guy Harris2019-11-091-20/+107
| | | | | | | | | Reject direction arguments other than PCAP_D_IN, PCAP_D_OUT, and PCAP_D_INOUT. De-nerdify some errors. (backported from commit f1d640602594a00a507e217defef41b55feb7acb)
* Have a less nerdy error message for "output only isn't supported here".Guy Harris2019-11-091-1/+1
| | | | (backported from commit 0f2aa024f9ddb0e42ee967f928995114380de89b)
* Add OpenBSD support for pcap_setdirection().Guy Harris2019-11-091-0/+26
| | | | (cherry picked from commit cd71247239d187a54bb357bdab1275941c02e5ee)
* Yes, we want to define _WIN32_WINNT as 0x0600; do so.Guy Harris2019-11-091-3/+3
| | | | | | Not doing so causes warnings about inet_ntop() not being declared. (cherry picked from commit 9d500076696f07f1f8def0466863e03a3fb6a3ce)
* Temporarily turn off the definition of _WIN32_WINNT as 0x0600.Guy Harris2019-11-091-3/+3
| | | | | | | Check whether that reproduces GitHub issue #877, to see if that definition fixes it. (cherry picked from commit a090f9ea4fb23f36472bafbd2bb5b3d8e9a7be33)
* Squelch more warnings.Guy Harris2019-11-091-2/+7
| | | | (cherry picked from commit b6d046190a6598b0d1a0c4db6f347a54876ca8ec)
* Squelch another warning.Guy Harris2019-11-091-1/+2
| | | | (cherry picked from commit 6906780633de1e39f4c8eeb3efdb75082baba5c8)
* Squelch another warning.Guy Harris2019-11-091-0/+6
| | | | (cherry picked from commit 05a230e94927df195ce9a05fe97e37f66cfbff0d)
* Fix another warning.Guy Harris2019-11-091-5/+4
| | | | | | We don't define pcap_fopen_offline() at all on Windows. (cherry picked from commit 9f205acde230e44c4f3f3215a00cc314037ba064)
* Note that we do *NOT* support the old msvcrt.dll.Guy Harris2019-11-091-0/+4
| | | | | | [skip ci] (cherry picked from commit 583efed06071766aa8d2c59c92e4eb5c22852ea9)
* Squelch another warning.Guy Harris2019-11-091-7/+7
| | | | | | | | | | pcap_fopen_offline() doesn't need to be defined as a function on Windows. That's the problem the previous checkin was trying to figure out, so undo it. (cherry picked from commit ce4f065ebaedd1a8687edfd47aa51a9233727800)
* Make sure BUILDING_PCAP is getting defined.Guy Harris2019-11-091-0/+4
| | | | (cherry picked from commit 901e2598bd2e2b83cdd6c190c5a5bfc968999460)
* Squelch more warnings in MinGW builds.Guy Harris2019-11-093-8/+23
| | | | (cherry picked from commit 3a0096146960ae89f8407858491c3f6c50260743)
* Squelch some warnings that popped up on MinGW.Guy Harris2019-11-093-24/+32
| | | | (backported from commit de5f2d8a91f6968d1865834001774c0459a6e56f)
* Fix installation if we have MinGW but don't have ln.Guy Harris2019-11-091-54/+62
| | | | | | | | | Don't try installing the man pages with MinGW if we don't have it. In the install_manpage_symlink() function, just *assume* we have LINK_EXECUTABLE. (cherry picked from commit 15e4e807487729f66a73694d1debdd173e794520)
* Put the MinGW bin directory in the path, not the root directory.Guy Harris2019-11-091-4/+3
| | | | (backported from commit 4abbc3c8e1d79c7c778db0f482dc44517cb75cd4)
* And one more down.Guy Harris2019-11-091-1/+1
| | | | (cherry picked from commit 82db0ec2feb888981d91d489948b0e75115db309)
* OK, one directory level down.Guy Harris2019-11-091-1/+1
| | | | (cherry picked from commit da66b9835c4f0061b67b3ede8749de35e176a670)
* OK, force AppVeyor to show a listing of the top-level MinGW directory.Guy Harris2019-11-091-6/+7
| | | | | | | | Trying to figure out how to set CMAKE_MAKE_PROGRAM to force it to look there for MinGW, and thus to look there for GCC rather than in C:\MinGW\bin. (backported from commit 116114176584ea6a17ccef261e2c8531f3246b35)