mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-31 06:15:55 +00:00
If sa_len is zero, skip interface. Add remove_protocol. Fix automatic/manual interface selection.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user