Browse Source

Fix ethsock_is_unplugged

It would return `true`, even if the status was actually
`PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE`.
Joseph C. Lehner 1 year ago
parent
commit
dab3625db4
1 changed files with 3 additions and 2 deletions
  1. 3 2
      ethsock.c

+ 3 - 2
ethsock.c

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