]> The Tcpdump Group git mirrors - libpcap/commitdiff
"connected"/"disconnected" doesn't apply to loopback devices.
authorGuy Harris <[email protected]>
Tue, 1 May 2018 07:42:47 +0000 (00:42 -0700)
committerGuy Harris <[email protected]>
Tue, 1 May 2018 07:42:47 +0000 (00:42 -0700)
pcap-dlpi.c
pcap-libdlpi.c
pcap-pf.c

index 15bdd743f0e5e98cccbc35223f4823725fe09f66..430051e8d5ee12d8831f390c8665878249134add 100644 (file)
@@ -1053,10 +1053,22 @@ static int
 get_if_flags(const char *name _U_, bpf_u_int32 *flags _U_, char *errbuf _U_)
 {
        /*
-        * Nothing we can do.
-        * XXX - is there a way to find out whether an adapter has
-        * something plugged into it?
+        * Nothing we can do other than mark loopback devices as "the
+        * connected/disconnected status doesn't apply".
+        *
+        * XXX - on Solaris, can we do what the dladm command does,
+        * i.e. get a connected/disconnected indication from a kstat?
+        * (Note that you can also get the link speed, and possibly
+        * other information, from a kstat as well.)
         */
+       if (*flags & PCAP_IF_LOOPBACK) {
+               /*
+                * Loopback devices aren't wireless, and "connected"/
+                * "disconnected" doesn't apply to them.
+                */
+               *flags |= PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE;
+               return (0);
+       }
        return (0);
 }
 
index d11b6fdd303c20d8f09692be9ec778bd2febd5fa..a0d16693f6c2e26022e6df18b0891185ce1ea58c 100644 (file)
@@ -291,10 +291,22 @@ static int
 get_if_flags(const char *name _U_, bpf_u_int32 *flags _U_, char *errbuf _U_)
 {
        /*
-        * Nothing we can do.
-        * XXX - is there a way to find out whether an adapter has
-        * something plugged into it?
+        * Nothing we can do other than mark loopback devices as "the
+        * connected/disconnected status doesn't apply".
+        *
+        * XXX - on Solaris, can we do what the dladm command does,
+        * i.e. get a connected/disconnected indication from a kstat?
+        * (Note that you can also get the link speed, and possibly
+        * other information, from a kstat as well.)
         */
+       if (*flags & PCAP_IF_LOOPBACK) {
+               /*
+                * Loopback devices aren't wireless, and "connected"/
+                * "disconnected" doesn't apply to them.
+                */
+               *flags |= PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE;
+               return (0);
+       }
        return (0);
 }
 
index 59808647940ef496f0d09b0ba63dc6d1cfb87e78..fde97bacd05ecfd21c54f653b418c28d9aa5e708 100644 (file)
--- a/pcap-pf.c
+++ b/pcap-pf.c
@@ -562,10 +562,20 @@ static int
 get_if_flags(const char *name _U_, bpf_u_int32 *flags _U_, char *errbuf _U_)
 {
        /*
-        * Nothing we can do.
+        * Nothing we can do other than mark loopback devices as "the
+        * connected/disconnected status doesn't apply".
+        *
         * XXX - is there a way to find out whether an adapter has
         * something plugged into it?
         */
+       if (*flags & PCAP_IF_LOOPBACK) {
+               /*
+                * Loopback devices aren't wireless, and "connected"/
+                * "disconnected" doesn't apply to them.
+                */
+               *flags |= PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE;
+               return (0);
+       }
        return (0);
 }