From 78b8c3061c3d038fb1aef25c625a9d44aa08e02f Mon Sep 17 00:00:00 2001 From: Ted Lemon Date: Tue, 16 Sep 1997 18:12:32 +0000 Subject: [PATCH] If sa_len is zero, skip interface. Add remove_protocol. Fix automatic/manual interface selection. --- common/dispatch.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/common/dispatch.c b/common/dispatch.c index 4a669a079..c88db81dd 100644 --- a/common/dispatch.c +++ b/common/dispatch.c @@ -42,7 +42,7 @@ #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" @@ -100,9 +100,12 @@ void discover_interfaces (state) /* 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; @@ -112,10 +115,11 @@ void discover_interfaces (state) 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, ':'))) { @@ -306,6 +310,10 @@ void discover_interfaces (state) 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); @@ -704,3 +712,21 @@ void add_protocol (name, fd, handler, local) 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); + } + } +} -- 2.47.3