#ifndef lint
static char copyright[] =
-"$Id: dispatch.c,v 1.42 1997/06/02 22:31:30 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dispatch.c,v 1.43 1997/09/16 18:12:32 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
/* If we already have a list of interfaces, and we're running as
a DHCP server, the interfaces were requested. */
- if (interfaces &&
- (state == DISCOVER_SERVER || state == DISCOVER_RELAY))
+ if (interfaces && (state == DISCOVER_SERVER ||
+ state == DISCOVER_RELAY ||
+ state == DISCOVER_REQUESTED))
ir = 0;
+ else if (state == DISCOVER_UNCONFIGURED)
+ ir = INTERFACE_REQUESTED | INTERFACE_AUTOMATIC;
else
ir = INTERFACE_REQUESTED;
for (i = 0; i < ic.ifc_len;) {
struct ifreq *ifp = (struct ifreq *)((caddr_t)ic.ifc_req + i);
#ifdef HAVE_SA_LEN
- i += (sizeof ifp -> ifr_name) + ifp -> ifr_addr.sa_len;
-#else
- i += sizeof *ifp;
+ if (ifp -> ifr_addr.sa_len)
+ i += (sizeof ifp -> ifr_name) + ifp -> ifr_addr.sa_len;
+ else
#endif
+ i += sizeof *ifp;
#ifdef ALIAS_NAMES_PERMUTED
if ((s = strrchr (ifp -> ifr_name, ':'))) {
last = (struct interface_info *)0;
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) != ir)
error ("%s: not found", tmp -> name);
p -> next = protocols;
protocols = p;
}
+
+void remove_protocol (proto)
+ struct protocol *proto;
+{
+ struct protocol *p, *next, *prev;
+
+ prev = (struct protocol *)0;
+ for (p = protocols; p; p = next) {
+ next = p -> next;
+ if (p == proto) {
+ if (prev)
+ prev -> next = p -> next;
+ else
+ protocols = p -> next;
+ free (p);
+ }
+ }
+}