aboutsummaryrefslogtreecommitdiff
path: root/fad-getad.c
Commit message (Collapse)AuthorAgeFilesLines
* Prefix routines declared in pcap-int.h with pcap_.Guy Harris2023-05-261-1/+1
| | | | | This avoids potential and, in one case (SIMH), actual collisions with names in other libraries or in applications using libpcap.
* Don't use ctype.h macros.Guy Harris2019-08-311-2/+1
| | | | | | | | | | | | | | | Some of them are locale-dependent, and all of them run the risk of failing if you hand them a char with the 8th bit set. Define our own locale-independent macros that can be handed any integral value. Don't include <ctype.h>. This should address the issue in GitHub pull request #839, and should also catch any (highly unlikely) cases in which something other than Boring Old Space And Tab and, sometimes, CR and LF are treated as white space. (No, we don't want FF or VT treated as white space.)
* Pass the "get additional flags" function to the findalldevs helpers.Guy Harris2018-04-301-1/+2
| | | | | This lets us make it a static function - or eliminate it entirely for pcap-null.c.
* Use AC_CHECK_TYPES and AC_CHECK_MEMBERS.Guy Harris2018-01-201-6/+6
| | | | | | | | | Rather than rolling our own autoconf macros to test for the existence of data types and structure members, use AC_CHECK_TYPES and AC_CHECK_MEMBERS. That cleans the configure script code up a bit, and makes it a bit more like the CMakeLists.txt file.
* Update to reflect the name change for Apple's UNIX-for-Macs.Guy Harris2018-01-081-1/+1
| | | | | | | | Use "macOS" except when referring to versions that came out when it was still called "Mac OS X" or "OS X". Rename README.macosx to README.macos. Update some comments while we're at it.
* Add a routine to format error messages with an errno-based message at the end.Guy Harris2017-11-151-2/+2
| | | | | | | | | | | | | | 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.
* 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.
* Rename a routine to match find_or_add_if().Guy Harris2017-01-201-1/+1
| | | | Rename add_addr_to_iflist() to add_addr_to_if().
* Pass IFF_ flags to add_addr_to_iflist().Guy Harris2017-01-181-2/+1
| | | | | | | | It's only used on UN*Xes, so it's only used on systems that have IFF_ flags; have add_addr_to_iflist() do the mapping to PCAP_IF_ flags. That restores the workaround for systems lacking IFF_LOOPBACK and the "don't even try" for systems lacking IFF_UP or IFF_RUNNING.
* Have a pcap_if_list_t structure for use by the findalldevs code.Guy Harris2017-01-181-14/+2
| | | | | | | 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.
* Cope with the NetBSD issue in a different way.Guy Harris2016-08-071-13/+0
| | | | | | | Define DLT_USB the way we used to, and undefine DLT_MATCHING_MAX before defining it. (We arguably never should have exported it, as the only code that should be using it is the LINKTYPE_ <-> DLT_ converting code, but....)
* Cope with a NetBSD annoyance.Guy Harris2016-08-071-0/+13
|
* Let the platform decide how to check capturable interfaces.Guy Harris2016-06-281-30/+41
| | | | | | | | | | | | | | | | | | | (Git's annoying policy of expecting a short one-line description of every change means that the first line isn't very explanatory.) Make pcap_findalldevs_interfaces() take as an argument a function that's used to check whether an interface can be captured on or not, rather than doing the check by trying to open the device for capturing. This lets pcap_findalldevs() find interfaces even if you don't have permission to capture on them; that way, instead of users saying "why isn't {tcpdump -D, tshark -D, dumpcap -D, Wireshark, etc.} showing me any interfaces?", they'll say "why am I getting a 'you don't have permissions' error when I try to capture on this interface?", which is a better description of the underlying problem. On some platforms, it also avoids a bunch of extra work when getting a list of interfaces.
* Split out the UN*X flags to pcap flags mapping.Guy Harris2016-01-251-1/+2
| | | | | | | | | | | | Add an if_flags_to_pcap_flags() routine to map the interface name (if necessary) and IFF_ flags to PCAP_IF_ flags, and call that in the platform-specific routines. That means that the calls to add to the interface list don't need to use IFF_ flags, which are UN*Xisms. Move the routines that update the interface list to fad-helpers.c, leaving just the legacy APIs in inet.c. Update finalldevstest to print out all the flags.
* Use pcap_snprintf() instead of snprintf().Guy Harris2015-11-031-1/+1
| | | | | | | | | | | 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/update some comments.Guy Harris2014-01-111-22/+25
|
* Don't exclude interfaces that aren't up.Guy Harris2014-01-101-10/+0
| | | | | | | | | | | On some platforms, you can capture on those interfaces, which might be useful if you want to start a capture before the interface is up, so that the capture starts capturing as soon as it's up. Those interfaces will not appear in the interface list on platforms where you can't open them for capturing, and they'll now be sorted after the interfaces that *are* up, so there's not much harm in including them.
* remove libpcap's own CVS keywordsDenis Ovsienko2014-01-031-5/+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.
* Don't try to handle AF_PACKET on Solaris.Guy Harris2013-04-061-4/+10
|
* Have non-interface modules take responsibility for identifying their devices.Guy Harris2012-06-111-12/+1
| | | | | | | | | | | | | | 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().
* Handle Linux, which has linux/*.h and netpacket/*.h headers that can collide.Guy Harris2011-06-111-8/+10
| | | | | | | | | If we have <netpacket/packet.h>, just include that to get stuff such as struct sockaddr_ll; otherwise, just fall back on the way we used to do it, with <netpacket/if_packet.h> on LynxOS and <linux/types.h> and <linux/if_packet.h> on Linux. If we try to include <netpacket/packet.h> if we have it and <linux/if_packet.h> if we have it, we get collisions between their different structure definitions and the compile fails.
* Handle Solaris 11, which has AF_PACKET but not (all?) linux/*.h includes.Darren Reed2011-06-041-4/+8
| | | | | | | | | | | | | | This set of diffs is required to correct a problem when compiling libpcap on Solaris 11 due to the assumption that the presence of AF_PACKET implies certain header files are in certain positions. The failure (without the patch) is demonstrated as follows: gcc -O2 -fpic -I. -DHAVE_CONFIG_H -D_U_="__attribute__((unused))" -g -O2 -c ./fad-getad.c ./fad-getad.c:69:27: linux/types.h: No such file or directory ./fad-getad.c:70:31: linux/if_packet.h: No such file or directory Reviewed-By: Guy Harris <guy@alum.mit.edu>
* Add a #include required on RHEL5.Chris Maynard2010-04-011-2/+5
|
* From RCB-ISIS on SourceForge: handle LynxOS, which has AF_PACKET butguy2007-09-141-2/+6
| | | | puts the if_packet.h header in a different directory from Linux.
* From Don Ebright: add support for Linux logical interfaces.guy2005-04-081-1/+33
|
* From Dean Gaudet <dean@arctic.org>: handle AF_PACKET addresses on OSesguy2004-11-041-1/+10
| | | | that have them (Linux).
* Don't rely on SA_LEN to check whether it's passed a null pointer (itguy2004-03-111-13/+34
| | | | | | | | might be supplied by the OS, and the OS might supply a version that doesn't check); instead, check for null pointers before doing anything with the address at all. This also means we don't supply a netmask if the address is null; that makes sense, as a netmask makes no sense without an address.
* Add _U_ to "rcsid[]" definitions, to eliminate "unused variable"guy2003-11-151-2/+2
| | | | warnings from newer versions of GCC.
* From Mike Wiacek: have "get_sa_len()" return 0 if the "addr" pointerguy2003-09-101-1/+3
| | | | | passed to it is NULL, as it might be if, for example, the address or the netmask isn't supplied.
* sa_len for netmask is undefined.itojun2003-09-101-2/+2
|
* Alas, there are some versions of GNU libc that don't have "SA_LEN()"; atguy2003-02-251-4/+28
| | | | | least for those that also have "getifaddrs()", we have to get the size by looking at the address family.
* From Kazushi Sugyo: address pointers in entries returned byguy2002-10-191-2/+2
| | | | | | "getifaddrs()" can be null, so make "SA_LEN()" return 0 if the argument is null, rather than dereferencing the argument and crashing if it's null.
* From an anonymous Sourceforge user: include <net/if.h> to declare theguy2002-08-261-1/+3
| | | | IFF_ flags.
* Leave it up to the platform-dependent "get interface list" code toguy2002-07-301-7/+47
| | | | | figure out how big the addresses are, as the way that's done is, well, platform-dependent....
* Put the different implementations of "pcap_findalldevs()" into separateguy2002-07-271-0/+154
source files, rather than having a pile of #ifdefs in "inet.c". Add code to the configure script to determine which implementation to use on the platform for which libpcap is being built. Add a "pcap_findalldevs()" implementation for Solaris 8 and later that handles IPv6 addresses.