mirror of
https://github.com/the-tcpdump-group/tcpdump.git
synced 2024-11-23 18:14:29 +08:00
Better report errors from stub routines in macOS 14 (Sonoma) libpcap.
Some routines that are built only if libpcap 1.10.x is built with remote capture support, but that are unconditionally declared in pcap/pcap.h, now have stub implementations in macOS 14 that always fail and set the error string to "not supported". (This was probably done because those routines are now declared as "weakly linked symbols": https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html om macOS 14.) This means CMakeLists.txt finds them when you build on Sonoma, so we end up calling them. For all code that calls the routines in question, if the any of the routines in question fail, check for an error string of "not supported", and report that error as it with "Remote capture not supported", so as to make the cause of failure clearer. Fix the misindentation of a closing bracket while we're at it.
This commit is contained in:
parent
59d7ea4b86
commit
2a3bc5716d
29
tcpdump.c
29
tcpdump.c
@ -563,8 +563,21 @@ show_remote_devices_and_exit(void)
|
||||
int i;
|
||||
|
||||
if (pcap_findalldevs_ex(remote_interfaces_source, NULL, &devlist,
|
||||
ebuf) < 0)
|
||||
ebuf) < 0) {
|
||||
if (strcmp(ebuf, "not supported") == 0) {
|
||||
/*
|
||||
* macOS 14's pcap_findalldevs_ex(), which is a
|
||||
* stub that always returns -1 with an error
|
||||
* message of "not supported".
|
||||
*
|
||||
* In this case, as we passed it an rpcap://
|
||||
* URL, treat that as meaning "remote capture
|
||||
* not supported".
|
||||
*/
|
||||
error("Remote capture not supported");
|
||||
}
|
||||
error("%s", ebuf);
|
||||
}
|
||||
for (i = 0, dev = devlist; dev != NULL; i++, dev = dev->next) {
|
||||
printf("%d.%s", i+1, dev->name);
|
||||
if (dev->description != NULL)
|
||||
@ -1269,6 +1282,18 @@ open_interface(const char *device, netdissect_options *ndo, char *ebuf)
|
||||
pflag ? 0 : PCAP_OPENFLAG_PROMISCUOUS, timeout, NULL,
|
||||
ebuf);
|
||||
if (pc == NULL) {
|
||||
/*
|
||||
* macOS 14's pcap_pcap_open(), which is a
|
||||
* stub that always returns NULL with an error
|
||||
* message of "not supported".
|
||||
*
|
||||
* In this case, as we passed it an rpcap://
|
||||
* URL, treat that as meaning "remote capture
|
||||
* not supported".
|
||||
*/
|
||||
if (strcmp(ebuf, "not supported") == 0)
|
||||
error("Remote capture not supported");
|
||||
|
||||
/*
|
||||
* If this failed with "No such device" or "The system
|
||||
* cannot find the device specified", that means
|
||||
@ -1438,7 +1463,7 @@ open_interface(const char *device, netdissect_options *ndo, char *ebuf)
|
||||
if (status != 0)
|
||||
error("%s: pcap_setdirection() failed: %s",
|
||||
device, pcap_geterr(pc));
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_PCAP_SETDIRECTION */
|
||||
#else /* HAVE_PCAP_CREATE */
|
||||
*ebuf = '\0';
|
||||
|
Loading…
Reference in New Issue
Block a user