aboutsummaryrefslogtreecommitdiff
path: root/testprogs
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2019-10-22 18:33:00 -0700
committerGuy Harris <guy@alum.mit.edu>2019-10-22 18:33:00 -0700
commitdbf104891fb386cfdad9e9dcbd18c553fb02d37d (patch)
tree72c90a14be87090057c203e8870054534deb4e6f /testprogs
parentdfc9b5a23e05c26878abe61610629e742ca9b3c7 (diff)
Don't fail the preferred interface has no IPv4 address.
That's not a fatal condition, unlike, for example, pcap_lookupnet() getting a system call error trying to fetch the interface's IPv4 address.
Diffstat (limited to 'testprogs')
-rw-r--r--testprogs/findalldevstest.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/testprogs/findalldevstest.c b/testprogs/findalldevstest.c
index 3d69e334..092fd045 100644
--- a/testprogs/findalldevstest.c
+++ b/testprogs/findalldevstest.c
@@ -157,8 +157,24 @@ int main(int argc _U_, char **argv _U_)
{
if (pcap_lookupnet(alldevs->name, &net, &mask, errbuf) < 0)
{
- fprintf(stderr,"Error in pcap_lookupnet: %s\n",errbuf);
- exit_status = 2;
+ /*
+ * XXX - this doesn't distinguish between "a real error
+ * occurred" and "this interface doesn't *have* an IPv4
+ * address". The latter shouldn't be treated as an error.
+ *
+ * We look for the interface name, followed by a colon and
+ * a space, and, if we find it,w e see if what follows it
+ * is "no IPv4 address assigned".
+ */
+ size_t devnamelen = strlen(alldevs->name);
+ if (strncmp(errbuf, alldevs->name, devnamelen) == 0 &&
+ strncmp(errbuf + devnamelen, ": ", 2) == 0 &&
+ strcmp(errbuf + devnamelen + 2, "no IPv4 address assigned") == 0)
+ printf("Preferred device is not on an IPv4 network\n");
+ else {
+ fprintf(stderr,"Error in pcap_lookupnet: %s\n",errbuf);
+ exit_status = 2;
+ }
}
else
{