Fix ethsock_is_unplugged

It would return `true`, even if the status was actually
`PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE`.
This commit is contained in:
Joseph C. Lehner 2022-11-01 13:56:16 +01:00
parent ae9d8fa325
commit dab3625db4

View file

@ -586,14 +586,15 @@ bool ethsock_is_wifi(struct ethsock *sock)
bool ethsock_is_unplugged(struct ethsock *sock) bool ethsock_is_unplugged(struct ethsock *sock)
{ {
#ifdef PCAP_IF_WIRELESS #ifdef PCAP_IF_CONNECTION_STATUS
bpf_u_int32 flags; bpf_u_int32 flags;
if (!intf_get_pcap_flags(sock->intf, &flags)) { if (!intf_get_pcap_flags(sock->intf, &flags)) {
return false; return false;
} }
return flags & PCAP_IF_CONNECTION_STATUS_DISCONNECTED; return (flags & PCAP_IF_CONNECTION_STATUS)
== PCAP_IF_CONNECTION_STATUS_DISCONNECTED;
#else #else
#warning "libpcap version is < 1.9.0" #warning "libpcap version is < 1.9.0"
return false; return false;