forked from osmocom/wireshark
Distinguish "Interface went down" from "Interface disappeared".
Have separate errors for "the interface went down" on Linux and "the interface no longer exists" on *BSD/Darwin/Windows. Change-Id: I1951c647e88eb7ebeb20a72d9e03a2072168c8e5 Reviewed-on: https://code.wireshark.org/review/33794 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
9ad5dc26dd
commit
37ff9dacb9
18
dumpcap.c
18
dumpcap.c
|
@ -4051,6 +4051,9 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
|
|||
(At least you will if g_strerror() doesn't show a local translation
|
||||
of the error.)
|
||||
|
||||
Newer versions of libpcap maps that to just
|
||||
"The interface went down".
|
||||
|
||||
On FreeBSD, DragonFly BSD, and macOS, if a network adapter
|
||||
disappears while you're capturing on it, you'll get
|
||||
"read: Device not configured" error (ENXIO). (See previous
|
||||
|
@ -4062,21 +4065,24 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
|
|||
"read error: PacketReceivePacket failed".
|
||||
|
||||
Newer versions of libpcap map some or all of those to just
|
||||
"The interface went down" or "The interface disappeared".
|
||||
"The interface disappeared".
|
||||
|
||||
These should *not* be reported to the Wireshark developers. */
|
||||
char *cap_err_str;
|
||||
|
||||
cap_err_str = pcap_geterr(pcap_src->pcap_h);
|
||||
if (strcmp(cap_err_str, "The interface went down") == 0 ||
|
||||
strcmp(cap_err_str, "The interface disappeared") == 0 ||
|
||||
strcmp(cap_err_str, "recvfrom: Network is down") == 0 ||
|
||||
strcmp(cap_err_str, "read: Device not configured") == 0 ||
|
||||
strcmp(cap_err_str, "read: I/O error") == 0 ||
|
||||
strcmp(cap_err_str, "read error: PacketReceivePacket failed") == 0) {
|
||||
strcmp(cap_err_str, "recvfrom: Network is down") == 0) {
|
||||
report_capture_error("The network adapter on which the capture was being done "
|
||||
"is no longer running; the capture has stopped.",
|
||||
"");
|
||||
} else if (strcmp(cap_err_str, "The interface disappeared") == 0 ||
|
||||
strcmp(cap_err_str, "read: Device not configured") == 0 ||
|
||||
strcmp(cap_err_str, "read: I/O error") == 0 ||
|
||||
strcmp(cap_err_str, "read error: PacketReceivePacket failed") == 0) {
|
||||
report_capture_error("The network adapter on which the capture was being done "
|
||||
"is no longer attached; the capture has stopped.",
|
||||
"");
|
||||
} else {
|
||||
g_snprintf(errmsg, sizeof(errmsg), "Error while capturing packets: %s",
|
||||
cap_err_str);
|
||||
|
|
Loading…
Reference in New Issue