summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-05-01 00:42:47 -0700
committerGuy Harris <guy@alum.mit.edu>2018-05-01 00:42:47 -0700
commit2dc58add44c75164d0a5dd5290462adaf7bd0f86 (patch)
tree4d05d8469a27c73100046407797b5c241de75fca
parentbbb8a1c1a868a9a2963b562183330e89e55680d3 (diff)
downloadlibpcap-2dc58add44c75164d0a5dd5290462adaf7bd0f86.tar.gz
"connected"/"disconnected" doesn't apply to loopback devices.
-rw-r--r--pcap-dlpi.c18
-rw-r--r--pcap-libdlpi.c18
-rw-r--r--pcap-pf.c12
3 files changed, 41 insertions, 7 deletions
diff --git a/pcap-dlpi.c b/pcap-dlpi.c
index 15bdd743..430051e8 100644
--- a/pcap-dlpi.c
+++ b/pcap-dlpi.c
@@ -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);
}
diff --git a/pcap-libdlpi.c b/pcap-libdlpi.c
index d11b6fdd..a0d16693 100644
--- a/pcap-libdlpi.c
+++ b/pcap-libdlpi.c
@@ -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);
}
diff --git a/pcap-pf.c b/pcap-pf.c
index 59808647..fde97bac 100644
--- 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);
}