2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-31 06:15:55 +00:00

Copy the entire chaddr field, even if the length is shorter than the total. This works around a bug in certain Microsoft clients. If the options aren't valid, just copy the option buffer from the incoming packet into the outgoing packet. This lets NeXT boxes boot. Adjust calling conventions for cons_options.

This commit is contained in:
Ted Lemon
1998-02-06 01:05:39 +00:00
parent 36f5cb7ca4
commit d8ae14c614

View File

@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
"$Id: bootp.c,v 1.28 1997/09/16 18:17:55 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
"$Id: bootp.c,v 1.29 1998/02/06 01:05:39 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -222,32 +222,41 @@ void bootp (packet)
memset (&raw, 0, sizeof raw);
outgoing.raw = &raw;
/* Come up with a list of options that we want to send to this
client. Start with the per-subnet options, and then override
those with client-specific options. */
memcpy (options, subnet -> group -> options, sizeof options);
for (i = 0; i < 256; i++) {
if (hp -> group -> options [i])
options [i] = hp -> group -> options [i];
}
/* Pack the options into the buffer. Unlike DHCP, we can't
pack options into the filename and server name buffers. */
outgoing.packet_length =
cons_options (packet, outgoing.raw, options, 0, 0, 1);
if (outgoing.packet_length < BOOTP_MIN_LEN)
/* If we didn't get a known vendor magic number on the way in,
just copy the input options to the output. */
if (!packet -> options_valid) {
memcpy (outgoing.raw -> options,
packet -> raw -> options, DHCP_OPTION_LEN);
outgoing.packet_length = BOOTP_MIN_LEN;
} else {
/* Come up with a list of options that we want to send
to this client. Start with the per-subnet options,
and then override those with client-specific
options. */
memcpy (options, subnet -> group -> options, sizeof options);
for (i = 0; i < 256; i++) {
if (hp -> group -> options [i])
options [i] = hp -> group -> options [i];
}
/* Pack the options into the buffer. Unlike DHCP, we
can't pack options into the filename and server
name buffers. */
outgoing.packet_length =
cons_options (packet, outgoing.raw, 0, options,
(struct agent_options *)0, 0, 0, 1);
if (outgoing.packet_length < BOOTP_MIN_LEN)
outgoing.packet_length = BOOTP_MIN_LEN;
}
/* Take the fields that we care about... */
raw.op = BOOTREPLY;
raw.htype = packet -> raw -> htype;
raw.hlen = packet -> raw -> hlen;
memcpy (raw.chaddr, packet -> raw -> chaddr, raw.hlen);
memset (&raw.chaddr [raw.hlen], 0,
(sizeof raw.chaddr) - raw.hlen);
memcpy (raw.chaddr, packet -> raw -> chaddr, sizeof raw.chaddr);
raw.hops = packet -> raw -> hops;
raw.xid = packet -> raw -> xid;
raw.secs = packet -> raw -> secs;