From: Ted Lemon Date: Thu, 27 Jun 1996 19:07:45 +0000 (+0000) Subject: Weed out unrequested interfaces if some interfaces were specifically requested; crash... X-Git-Tag: BETA_4_6~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d3f6c8b073765fb24df41ffab179c8e37069f456;p=thirdparty%2Fdhcp.git Weed out unrequested interfaces if some interfaces were specifically requested; crash and burn if an interface specified on the command line is now found. --- diff --git a/common/dispatch.c b/common/dispatch.c index da822557f..15927b509 100644 --- a/common/dispatch.c +++ b/common/dispatch.c @@ -69,6 +69,7 @@ void discover_interfaces () struct subnet *subnet; struct shared_network *share; struct sockaddr_in *foo; + int ir; #ifdef USE_FALLBACK static struct shared_network fallback_network; #endif @@ -85,6 +86,11 @@ void discover_interfaces () if (i < 0) error ("ioctl: SIOCGIFCONF: %m"); + if (interfaces) + ir = 0; + else + ir = INTERFACE_REQUESTED; + /* Cycle through the list of interfaces looking for IP addresses. Go through twice; once to count the number if addresses, and a second time to copy them into an array of addresses. */ @@ -112,6 +118,7 @@ void discover_interfaces () memset (tmp, 0, sizeof *tmp); strcpy (tmp -> name, ifp -> ifr_name); tmp -> next = interfaces; + tmp -> flags = ir; interfaces = tmp; } @@ -196,7 +203,9 @@ void discover_interfaces () /* Weed out the interfaces that did not have IP addresses. */ last = (struct interface_info *)0; for (tmp = interfaces; tmp; tmp = tmp -> next) { - if (!tmp -> tif) { + if (!tmp -> tif || !(tmp -> flags & INTERFACE_REQUESTED)) { + if (tmp -> flags & INTERFACE_REQUESTED) + error ("%s: not found", tmp -> name); if (!last) interfaces = interfaces -> next; else diff --git a/dispatch.c b/dispatch.c index da822557f..15927b509 100644 --- a/dispatch.c +++ b/dispatch.c @@ -69,6 +69,7 @@ void discover_interfaces () struct subnet *subnet; struct shared_network *share; struct sockaddr_in *foo; + int ir; #ifdef USE_FALLBACK static struct shared_network fallback_network; #endif @@ -85,6 +86,11 @@ void discover_interfaces () if (i < 0) error ("ioctl: SIOCGIFCONF: %m"); + if (interfaces) + ir = 0; + else + ir = INTERFACE_REQUESTED; + /* Cycle through the list of interfaces looking for IP addresses. Go through twice; once to count the number if addresses, and a second time to copy them into an array of addresses. */ @@ -112,6 +118,7 @@ void discover_interfaces () memset (tmp, 0, sizeof *tmp); strcpy (tmp -> name, ifp -> ifr_name); tmp -> next = interfaces; + tmp -> flags = ir; interfaces = tmp; } @@ -196,7 +203,9 @@ void discover_interfaces () /* Weed out the interfaces that did not have IP addresses. */ last = (struct interface_info *)0; for (tmp = interfaces; tmp; tmp = tmp -> next) { - if (!tmp -> tif) { + if (!tmp -> tif || !(tmp -> flags & INTERFACE_REQUESTED)) { + if (tmp -> flags & INTERFACE_REQUESTED) + error ("%s: not found", tmp -> name); if (!last) interfaces = interfaces -> next; else