From fe849040b52ab4f49e3f55272ed48c4cc80dcafd Mon Sep 17 00:00:00 2001 From: Ted Lemon Date: Wed, 20 Oct 1999 16:47:04 +0000 Subject: [PATCH] Handle 'allow bootp' and 'allow booting' correctly. Unicast if possible. --- server/bootp.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/server/bootp.c b/server/bootp.c index 224e93e5..a5dce15b 100644 --- a/server/bootp.c +++ b/server/bootp.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: bootp.c,v 1.55 1999/10/07 06:36:29 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: bootp.c,v 1.56 1999/10/20 16:47:04 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -134,22 +134,19 @@ void bootp (packet) hp -> group, subnet -> group); /* Drop the request if it's not allowed for this client. */ - if (evaluate_boolean_option_cache (packet, lease, - packet -> options, options, - lookup_option (&server_universe, - options, - SV_ALLOW_BOOTP))) { + if ((oc = lookup_option (&server_universe, options, SV_ALLOW_BOOTP)) && + !evaluate_boolean_option_cache (packet, lease, + packet -> options, options, oc)) { log_info ("%s: bootp disallowed", msgbuf); option_state_dereference (&options, "bootrequest"); static_lease_dereference (lease, "bootrequest"); return; } - if (evaluate_boolean_option_cache (packet, lease, - packet -> options, options, - lookup_option (&server_universe, - options, - SV_ALLOW_BOOTING))) { + if ((oc = lookup_option (&server_universe, + options, SV_ALLOW_BOOTING)) && + !evaluate_boolean_option_cache (packet, lease, + packet -> options, options, oc)) { log_info ("%s: booting disallowed", msgbuf); option_state_dereference (&options, "bootrequest"); static_lease_dereference (lease, "bootrequest"); @@ -317,6 +314,16 @@ void bootp (packet) from, &to, &hto); return; } + + /* If it comes from a client that already knows its address + and is not requesting a broadcast response, and we can + unicast to a client without using the ARP protocol, sent it + directly to that client. */ + } else if (!(raw.flags & htons (BOOTP_BROADCAST)) && + can_unicast_without_arp (packet -> interface)) { + to.sin_addr = raw.yiaddr; + to.sin_port = remote_port; + /* Otherwise, broadcast it on the local network. */ } else { to.sin_addr = limited_broadcast;