aboutsummaryrefslogtreecommitdiff
path: root/pcap-sita.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix spellingJosh Soref2023-06-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* 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.
* Fix spaces before tabs in indentationFrancois-Xavier Le Bail2023-02-151-1/+1
|
* Fix some typosFrancois-Xavier Le Bail2022-07-041-1/+1
| | | | [skip ci]
* SITA: Fix a typo in a variable nameFrancois-Xavier Le Bail2022-03-021-1/+1
|
* Fix some spelling. [skip ci]Denis Ovsienko2020-10-091-4/+4
|
* Handle the pcap_t+private data in a fashion that makes fewer assumptions.Guy Harris2020-07-011-1/+9
| | | | | | | | | | | | | | | 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.
* SITA: Remove an unmatched ')'Francois-Xavier Le Bail2020-06-171-1/+1
| | | | | | | | | | Found with cppcheck. The error was: Checking pcap-sita.c ... pcap-sita.c:699:60: error: Unmatched ')'. Configuration: ''. [syntaxError] bigger_buffer = realloc(iff->name, strlen(newname) + 1)); ^
* Use strdup to make mallocated copies of strings.Guy Harris2020-03-271-13/+6
|
* Let the common pcap code handle "setting the direction isn't supported".Guy Harris2019-11-081-7/+1
| | | | Just set the "set direction" operation pointer to null.
* Fix a typoFrancois-Xavier Le Bail2019-10-251-1/+1
| | | | [skip ci]
* Remove some workarounds for old compilers.Guy Harris2019-08-091-5/+5
| | | | | | | | | | | | | 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.
* Provide out own strlcpy() and strlcat() routines if necessary.Guy Harris2018-10-161-1/+1
| | | | | | | | | | | | | | We now depend on the *full* semantics of those routines, including the return value being usable for truncation checks. If we're building for a UN*X that has them, define pcap_strl{cpy,cat} to be strl{cpy,cat}. If we're building for Windows using MSVC, define pcap_strl{cpy,cat}, not strl{cpy,cat}. Otherwise, build our won versions of pcap_strl{cpy,cat} from BSD-derived source code.
* Squelch more narrowing warnings.Guy Harris2018-09-121-1/+1
|
* Add a routine to format error messages with an errno-based message at the end.Guy Harris2017-11-151-12/+29
| | | | | | | | | | | | | | That routine will use strerror_s() or strerror_r() if available, in a fashion that's thread-safe. Otherwise, it falls back on pcap_strerror(). Use it in both libpcap and rpcapd. Given that we check for errors in strerror_r(), hopefully this will squelch warnings with newer version of GCC and GNU libc; whilst the macOS (and other BSD-flavored?) strerror_r() always fills in a message, that's not required by the Single UNIX Specification, as far as I can tell, so we apparently really *do* need to check for errors.
* No need to generate version.c or pcap_version.h.Guy Harris2017-10-031-2/+0
| | | | We can get the project version from config.h, so do so.
* Push pcap_lib_version() into the pcap-XXX.c files.Guy Harris2017-09-061-3/+5
| | | | | | | | This lets us move the Windows version to pcap-win32.c, so we don't have to include packet32.h in pcap.c. It also gets rid of some #ifdefs, and lets us construct the version string on UN*X platforms, and MS-DOS, at compile time.
* 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/+12
| | | | | | | | | | | | | 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.
* Allow a platform to add information to the version string.Guy Harris2017-05-161-0/+9
| | | | | For example, on Linux, we add information about memory-mapped capture support; see comments on GitHub issue #600.
* Have a pcap_if_list_t structure for use by the findalldevs code.Guy Harris2017-01-181-4/+4
| | | | | | | 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.
* pcap_create_interface() needs the interface name on Linux.Guy Harris2016-06-301-1/+1
| | | | | So pass it the interface name, and use the name passed to it rather than the name in the pcap_t - which hasn't yet been set at that point.
* Don't have pcap_create_common() set opt.device.Guy Harris2016-06-301-2/+2
| | | | | | | Instead, have pcap_create() do so. Also have pcap_create() on Windows handle converting a little-endian UCS-2/UTF-16 string to ASCII.
* Rename opt.source to opt.device.Guy Harris2016-06-291-1/+1
| | | | | | | 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.
* Have pcap_platform_finddevs() do all the "find local interfaces" work.Guy Harris2016-06-261-1/+24
| | | | | | | | | | Rename pcap_findalldevs_interfaces() to pcap_platform_finddevs(), now that pcap_findalldevs() calls pcap_platform_finddevs() to find *all* the local interfaces. Move it from fad-sita.c to pcap-sita.c, and get rid of fad-sita.c. Update INSTALL.txt to reflect the disappearance of fad-sita.c and fad-win32.c.
* Use pcap_snprintf() instead of snprintf().Guy Harris2015-11-031-16/+16
| | | | | | | | | | | 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.
* More fixes for realloc() failures.Bill Parker2015-09-221-4/+11
| | | | | Again, assign the result to a temporary variable, and overwrite the original only if the realloc succeeds.
* Make the buffer member of a pcap_t a void *.Guy Harris2015-08-091-1/+1
| | | | | | | | | | | Yes, in some sense, it's an array of bytes - on modern processors, *all* data is ultimately an array of bytes - but different modules will use it in different ways, not all of which will be an undifferentiated array of bytes. This squelches a complaint from the Clang static analyzer. Clean up some code while we're at it.
* Fix errors introduced by my previous change.Bill Parker2015-07-241-2/+2
|
* Delete trailing spaces/tabsFrancois-Xavier Le Bail2015-03-081-4/+4
|
* remove libpcap's own CVS keywordsDenis Ovsienko2014-01-031-2/+0
| | | | | | This change removes CVS keywords that express that the file belongs to libpcap repository. All such keywords represented the revision and timestamp by the end of 2008 or even older.
* Move platform-dependent pcap_t data out of the pcap_t structure.Guy Harris2013-05-061-38/+48
| | | | | | | | | | | | | | | 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.
* Add sanity checking for malloc, etcBill Parker2012-09-041-8/+39
| | | | | | This update adds sanity checking to malloc requests and replaces deprecated bzero() function calls with memset() which is ISO/ANSI/Posix compliant
* Have non-interface modules take responsibility for identifying their devices.Guy Harris2012-06-111-2/+2
| | | | | | | | | | | | | | Have a table of routines to do pcap_create() for devices that aren't regular network interfaces. Try each of those in succession until one says "it's mine" (whether it succeeds or fails); if none do, do a pcap_create() for a regular interface. Have those routines do more stringent tests of the name - don't just accept any name that has a particular substring anywhere in it. That reduces the likelihood of a false match (as happened with the CANbus module when somebody renamed their Ethernet interface "canopy"). Have the table also include routines for pcap_findalldevs().
* Turn close_op into cleanup_op; the routine that handles it can also beguy2008-04-141-3/+4
| | | | | | | | | | | | | | | | | | | | | | | used to clean up after a failed pcap_activate() call. Convert the existing close_op routines to cleanup_op routines, and use them to clean up; rename pcap_close_common() to pcap_cleanup_live_common(), and use it directly if there's no platform-dependent cleanup needed. That means we don't have to write the same cleanup code twice (and possibly forget stuff in the version done on a failed pcap_activate() call). Have the cleanup routines do whatever is necessary to indicate that cleanup has been done, and not do any particular cleaning up if it's already been done (i.e., don't free something if the pointer to it is null and null out the pointer once it's been freed, don't close an FD if it's -1 and set it to -1 once it's been closed, etc.). For device types/platforms where we don't support monitor mode, check for it and return PCAP_ERROR_RFMON_NOTSUP - but do so after we've checked whether we can open the device, so we return "no such device" or "permission denied" rather than "that device doesn't support monitor mode" if we can't open the device in the first place. Fix a comment.
* From Paolo Abeni and me: split pcap_open_live() into a "get a pcap_tguy2008-04-041-23/+26
| | | | | | | | | | | | | | | | handle" routine, an 'activate a pcap_t handle" routine, and some "set the properties of the pcap_t handle" routines, so that, for example, the buffer size can be set on a BPF device before the device is bound to an interface. Add additional routines to set monitor mode, and make at least an initial attempt at supporting that on Linux, *BSD, and Mac OS X 10.4 and 10.5. (Very much "initial" for Linux, which is a twisty little maze of wireless drivers, many different.) Have a "timeout" member of the pcap_md structure on all platforms, use that on Windows instead of the "timeout" member of the pcap_t structure, and get rid of the "timeout" member of that structure.
* The SITA code in pcap-linux.c shares very little with the Linux code;guy2008-01-061-28/+99
| | | | | | | | | | | | | | | | | | | | | | move it into pcap-sita.c, and make --with-sita set the pcap type to "sita", so we build pcap-sita.c instead of, rather than in addition to, pcap-linux.c. Use "bpf_u_int32" rather than "ulong" in the SITA code, as it's intended to be 32 bits long (the "l" in "htonl()" and "ntohl()" is historical - they work on 32-bit quantities, and the "l" dates back to the days when 32-bit processors were a bit newer and 16-bit Unix was more common). Those changes also, at least in theory, makes the SITA support work on other Unix-compatible platforms; note that in README.sita. Clean up pcap-sita.c, making routines no longer called outside it static, folding trivial wrappers, and fixing various warnings. Put the routines used by fad-sita.c and defined by pcap-sita.c into pcap-sita.h. Remove from pcap-sita.h the files that are now static to pcap-sita.c. Include pcap-sita.h in both fad-sita.c and pcap-sita.c, so that we do cross-file prototype checking.
* SITA ACN support, from Fulko Hew.guy2007-10-201-0/+905