2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-09-02 15:25:48 +00:00

If sa_len is zero, skip interface. Add remove_protocol. Fix automatic/manual interface selection.

This commit is contained in:
Ted Lemon
1997-09-16 18:12:32 +00:00
parent 62b2bc86a2
commit 78b8c3061c

View File

@@ -42,7 +42,7 @@
#ifndef lint #ifndef lint
static char copyright[] = 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 */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@@ -100,9 +100,12 @@ void discover_interfaces (state)
/* If we already have a list of interfaces, and we're running as /* If we already have a list of interfaces, and we're running as
a DHCP server, the interfaces were requested. */ a DHCP server, the interfaces were requested. */
if (interfaces && if (interfaces && (state == DISCOVER_SERVER ||
(state == DISCOVER_SERVER || state == DISCOVER_RELAY)) state == DISCOVER_RELAY ||
state == DISCOVER_REQUESTED))
ir = 0; ir = 0;
else if (state == DISCOVER_UNCONFIGURED)
ir = INTERFACE_REQUESTED | INTERFACE_AUTOMATIC;
else else
ir = INTERFACE_REQUESTED; ir = INTERFACE_REQUESTED;
@@ -112,10 +115,11 @@ void discover_interfaces (state)
for (i = 0; i < ic.ifc_len;) { for (i = 0; i < ic.ifc_len;) {
struct ifreq *ifp = (struct ifreq *)((caddr_t)ic.ifc_req + i); struct ifreq *ifp = (struct ifreq *)((caddr_t)ic.ifc_req + i);
#ifdef HAVE_SA_LEN #ifdef HAVE_SA_LEN
if (ifp -> ifr_addr.sa_len)
i += (sizeof ifp -> ifr_name) + ifp -> ifr_addr.sa_len; i += (sizeof ifp -> ifr_name) + ifp -> ifr_addr.sa_len;
#else else
i += sizeof *ifp;
#endif #endif
i += sizeof *ifp;
#ifdef ALIAS_NAMES_PERMUTED #ifdef ALIAS_NAMES_PERMUTED
if ((s = strrchr (ifp -> ifr_name, ':'))) { if ((s = strrchr (ifp -> ifr_name, ':'))) {
@@ -306,6 +310,10 @@ void discover_interfaces (state)
last = (struct interface_info *)0; last = (struct interface_info *)0;
for (tmp = interfaces; tmp; tmp = next) { for (tmp = interfaces; tmp; tmp = next) {
next = 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 -> ifp || !(tmp -> flags & INTERFACE_REQUESTED)) {
if ((tmp -> flags & INTERFACE_REQUESTED) != ir) if ((tmp -> flags & INTERFACE_REQUESTED) != ir)
error ("%s: not found", tmp -> name); error ("%s: not found", tmp -> name);
@@ -704,3 +712,21 @@ void add_protocol (name, fd, handler, local)
p -> next = protocols; p -> next = protocols;
protocols = p; 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);
}
}
}