summaryrefslogtreecommitdiff
path: root/sbin/dhclient/dispatch.c
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-02-24 14:49:09 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-02-24 14:49:09 +0000
commita9931a4f66026e211071467c1bf51b1ef2ea1c78 (patch)
tree606710cb712eb40f79e20009ac76751d06e5d411 /sbin/dhclient/dispatch.c
parent41b2d8b213713bf9aa59b74ed082728c54ce2593 (diff)
discover_interfaces doesn't run in multiple modes any more - kill unreachable
code, partitally server-only
Diffstat (limited to 'sbin/dhclient/dispatch.c')
-rw-r--r--sbin/dhclient/dispatch.c66
1 files changed, 3 insertions, 63 deletions
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c
index 500f8160ecf..37cb233a8ed 100644
--- a/sbin/dhclient/dispatch.c
+++ b/sbin/dhclient/dispatch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dispatch.c,v 1.12 2004/02/24 11:35:39 henning Exp $ */
+/* $OpenBSD: dispatch.c,v 1.13 2004/02/24 14:49:08 henning Exp $ */
/* Network input dispatcher... */
@@ -71,11 +71,10 @@ int quiet_interface_discovery;
* what subnet it's on, and add it to the list of interfaces.
*/
void
-discover_interfaces(int state)
+discover_interfaces(void)
{
struct interface_info *tmp;
struct interface_info *last, *next;
- struct subnet *subnet;
struct sockaddr_in foo;
struct ifreq *tif;
struct ifaddrs *ifap, *ifa;
@@ -83,30 +82,16 @@ discover_interfaces(int state)
if (getifaddrs(&ifap) != 0)
error("getifaddrs failed");
- /* Cycle through the list of interfaces looking for IP addresses. */
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
- /*
- * See if this is the sort of interface we want to deal
- * with. Skip loopback, point-to-point and down
- * interfaces, except don't skip down interfaces if
- * we're trying to get a list of configurable
- * interfaces.
- */
if ((ifa->ifa_flags & IFF_LOOPBACK) ||
(ifa->ifa_flags & IFF_POINTOPOINT) ||
- (!(ifa->ifa_flags & IFF_UP) &&
- state != DISCOVER_UNCONFIGURED))
+ (!(ifa->ifa_flags & IFF_UP)))
continue;
- /* See if we've seen an interface that matches this one. */
for (tmp = interfaces; tmp; tmp = tmp->next)
if (!strcmp(tmp->name, ifa->ifa_name))
break;
- /*
- * If there isn't already an interface by this name,
- * allocate one.
- */
if (!tmp) {
tmp = dmalloc(sizeof(*tmp), "discover_interfaces");
if (!tmp)
@@ -134,18 +119,9 @@ discover_interfaces(int state)
} else if (ifa->ifa_addr->sa_family == AF_INET) {
struct iaddr addr;
- /* Get a pointer to the address... */
bcopy(ifa->ifa_addr, &foo, sizeof(foo));
-
- /* We don't want the loopback interface. */
if (foo.sin_addr.s_addr == htonl(INADDR_LOOPBACK))
continue;
-
- /*
- * If this is the first real IP address we've
- * found, keep a pointer to ifreq structure in
- * which we found it.
- */
if (!tmp->ifp) {
int len = IFNAMSIZ + ifa->ifa_addr->sa_len;
tif = malloc(len);
@@ -157,8 +133,6 @@ discover_interfaces(int state)
tmp->ifp = tif;
tmp->primary_address = foo.sin_addr;
}
-
- /* Grab the address... */
addr.len = 4;
memcpy(addr.iabuf, &foo.sin_addr.s_addr, addr.len);
}
@@ -169,21 +143,10 @@ discover_interfaces(int state)
* hardware addresses.
*/
- /*
- * If we're just trying to get a list of interfaces that we might
- * be able to configure, we can quit now.
- */
- if (state == DISCOVER_UNCONFIGURED)
- return;
-
/* Weed out the interfaces that did not have IP addresses. */
last = NULL;
for (tmp = interfaces; tmp; tmp = next) {
next = tmp->next;
- if ((tmp->flags & INTERFACE_AUTOMATIC) &&
- state == DISCOVER_REQUESTED)
- tmp->flags &=
- ~(INTERFACE_AUTOMATIC | INTERFACE_REQUESTED);
if (!tmp->ifp || !(tmp->flags & INTERFACE_REQUESTED)) {
if ((tmp->flags & INTERFACE_REQUESTED))
error("%s: not found", tmp->name);
@@ -204,29 +167,6 @@ discover_interfaces(int state)
memcpy(&foo, &tmp->ifp->ifr_addr, sizeof(tmp->ifp->ifr_addr));
- /* We must have a subnet declaration for each interface. */
- if (!tmp->shared_network && (state == DISCOVER_SERVER)) {
- warn("No subnet declaration for %s (%s).",
- tmp->name, inet_ntoa(foo.sin_addr));
- warn("Please write a subnet declaration in your %s",
- "dhcpd.conf file for the");
- error("network segment to which interface %s %s",
- tmp->name, "is attached.");
- }
-
- /* Find subnets that don't have valid interface
- addresses... */
- for (subnet = (tmp->shared_network ?
- tmp->shared_network->subnets : NULL);
- subnet; subnet = subnet->next_sibling)
- if (!subnet->interface_address.len) {
- /* Set the interface address for this subnet
- to the first address we found. */
- subnet->interface_address.len = 4;
- memcpy(subnet->interface_address.iabuf,
- &foo.sin_addr.s_addr, 4);
- }
-
/* Register the interface... */
if_register_receive(tmp);
if_register_send(tmp);