*
* Support and other services are available for ISC products - see
* http://www.isc.org for more information.
+ *
+ * This code was originally written by Ted Lemon. Elliot Poger wrote
+ * a state machine to fully implement the client side of the DHCP
+ * protocol. Ted Lemon then added the configuration file, stuffed the
+ * state machine into its own data structure so there could be more
+ * than one, and added the client scripting code to produce the first
+ * ISC release (2.0b1pl0) of the client.
*/
#ifndef lint
static char ocopyright[] =
-"$Id: dhclient.c,v 1.90 1999/11/20 18:36:03 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dhclient.c,v 1.91 2000/01/05 17:55:31 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
for (ip = interfaces; ip; ip = ip -> next) {
int junk;
memcpy (&junk,
- &ip -> hw_address.haddr [ip -> hw_address.hlen -
- sizeof seed], sizeof seed);
+ &ip -> hw_address.hbuf [ip -> hw_address.hlen -
+ sizeof seed], sizeof seed);
seed += junk;
}
srandom (seed + cur_time);
break;
}
if (!client ||
- (packet -> interface -> hw_address.hlen !=
+ (packet -> interface -> hw_address.hlen - 1 !=
packet -> raw -> hlen) ||
- (memcmp (packet -> interface -> hw_address.haddr,
+ (memcmp (&packet -> interface -> hw_address.hbuf [1],
packet -> raw -> chaddr, packet -> raw -> hlen))) {
#if defined (DEBUG)
log_debug ("DHCPACK in wrong transaction.");
has an unrecognizable transaction id, then just drop it. */
if (!client ||
client -> state != S_SELECTING ||
- (packet -> interface -> hw_address.hlen !=
+ (packet -> interface -> hw_address.hlen - 1 !=
packet -> raw -> hlen) ||
- (memcmp (packet -> interface -> hw_address.haddr,
+ (memcmp (&packet -> interface -> hw_address.hbuf [1],
packet -> raw -> chaddr, packet -> raw -> hlen))) {
#if defined (DEBUG)
log_debug ("%s in wrong transaction.", name);
/* If we're not receptive to an offer right now, or if the offer
has an unrecognizable transaction id, then just drop it. */
if (!client ||
- (packet -> interface -> hw_address.hlen !=
+ (packet -> interface -> hw_address.hlen - 1 !=
packet -> raw -> hlen) ||
- (memcmp (packet -> interface -> hw_address.haddr,
+ (memcmp (&packet -> interface -> hw_address.hbuf [1],
packet -> raw -> chaddr, packet -> raw -> hlen))) {
#if defined (DEBUG)
log_debug ("DHCPNAK in wrong transaction.");
client -> packet_length = BOOTP_MIN_LEN;
client -> packet.op = BOOTREQUEST;
- client -> packet.htype = client -> interface -> hw_address.htype;
- client -> packet.hlen = client -> interface -> hw_address.hlen;
+ client -> packet.htype = client -> interface -> hw_address.hbuf [0];
+ client -> packet.hlen = client -> interface -> hw_address.hlen - 1;
client -> packet.hops = 0;
client -> packet.xid = random ();
client -> packet.secs = 0; /* filled in by send_discover. */
memset (&(client -> packet.siaddr),
0, sizeof client -> packet.siaddr);
client -> packet.giaddr = giaddr;
- memcpy (client -> packet.chaddr,
- client -> interface -> hw_address.haddr,
- client -> interface -> hw_address.hlen);
+ if (client -> interface -> hw_address.hlen > 0)
+ memcpy (client -> packet.chaddr,
+ &client -> interface -> hw_address.hbuf [1],
+ (unsigned)(client -> interface -> hw_address.hlen - 1));
#ifdef DEBUG_PACKET
dump_packet (sendpkt);
client -> packet_length = BOOTP_MIN_LEN;
client -> packet.op = BOOTREQUEST;
- client -> packet.htype = client -> interface -> hw_address.htype;
- client -> packet.hlen = client -> interface -> hw_address.hlen;
+ client -> packet.htype = client -> interface -> hw_address.hbuf [0];
+ client -> packet.hlen = client -> interface -> hw_address.hlen - 1;
client -> packet.hops = 0;
client -> packet.xid = client -> xid;
client -> packet.secs = 0; /* Filled in by send_request. */
memset (&client -> packet.siaddr, 0,
sizeof client -> packet.siaddr);
client -> packet.giaddr = giaddr;
- memcpy (client -> packet.chaddr,
- client -> interface -> hw_address.haddr,
- client -> interface -> hw_address.hlen);
+ if (client -> interface -> hw_address.hlen > 0)
+ memcpy (client -> packet.chaddr,
+ &client -> interface -> hw_address.hbuf [1],
+ (unsigned)(client -> interface -> hw_address.hlen - 1));
#ifdef DEBUG_PACKET
dump_packet (sendpkt);
option_state_dereference (&options, "make_decline");
client -> packet.op = BOOTREQUEST;
- client -> packet.htype = client -> interface -> hw_address.htype;
- client -> packet.hlen = client -> interface -> hw_address.hlen;
+ client -> packet.htype = client -> interface -> hw_address.hbuf [0];
+ client -> packet.hlen = client -> interface -> hw_address.hlen - 1;
client -> packet.hops = 0;
client -> packet.xid = client -> xid;
client -> packet.secs = 0; /* Filled in by send_request. */
sizeof client -> packet.siaddr);
client -> packet.giaddr = giaddr;
memcpy (client -> packet.chaddr,
- client -> interface -> hw_address.haddr,
+ &client -> interface -> hw_address.hbuf [1],
client -> interface -> hw_address.hlen);
#ifdef DEBUG_PACKET
option_state_dereference (&options, "make_decline");
client -> packet.op = BOOTREQUEST;
- client -> packet.htype = client -> interface -> hw_address.htype;
- client -> packet.hlen = client -> interface -> hw_address.hlen;
+ client -> packet.htype = client -> interface -> hw_address.hbuf [0];
+ client -> packet.hlen = client -> interface -> hw_address.hlen - 1;
client -> packet.hops = 0;
client -> packet.xid = random ();
client -> packet.secs = 0;
sizeof client -> packet.siaddr);
client -> packet.giaddr = giaddr;
memcpy (client -> packet.chaddr,
- client -> interface -> hw_address.haddr,
+ &client -> interface -> hw_address.hbuf [0],
client -> interface -> hw_address.hlen);
#ifdef DEBUG_PACKET
#ifndef lint
static char copyright[] =
-"$Id: bpf.c,v 1.31 1999/10/12 16:00:26 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: bpf.c,v 1.32 2000/01/05 17:57:30 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
if (!quiet_interface_discovery)
log_info ("Sending on BPF/%s/%s%s%s",
info -> name,
- print_hw_addr (info -> hw_address.htype,
- info -> hw_address.hlen,
- info -> hw_address.haddr),
+ print_hw_addr (info -> hw_address.hbuf [0],
+ info -> hw_address.hlen - 1,
+ &info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
if (!quiet_interface_discovery)
log_info ("Listening on BPF/%s/%s%s%s",
info -> name,
- print_hw_addr (info -> hw_address.htype,
- info -> hw_address.hlen,
- info -> hw_address.haddr),
+ print_hw_addr (info -> hw_address.hbuf [0],
+ info -> hw_address.hlen - 1,
+ &info -> hw_address.hbuf [1]),
(info -> shared_network ? "/" : ""),
(info -> shared_network ?
info -> shared_network -> name : ""));
#ifndef lint
static char copyright[] =
-"$Id: ethernet.c,v 1.3 1999/11/11 16:10:57 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: ethernet.c,v 1.4 2000/01/05 18:01:15 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
{
struct ether_header eh;
- if (to && to -> hlen == 6) /* XXX */
- memcpy (eh.ether_dhost, to -> haddr, sizeof eh.ether_dhost);
+ if (to && to -> hlen == 7) /* XXX */
+ memcpy (eh.ether_dhost, &to -> hbuf [1],
+ sizeof eh.ether_dhost);
else
memset (eh.ether_dhost, 0xff, sizeof (eh.ether_dhost));
- if (interface -> hw_address.hlen == sizeof (eh.ether_shost))
- memcpy (eh.ether_shost, interface -> hw_address.haddr,
+ if (interface -> hw_address.hlen - 1 == sizeof (eh.ether_shost))
+ memcpy (eh.ether_shost, &interface -> hw_address.hbuf [1],
sizeof (eh.ether_shost));
else
memset (eh.ether_shost, 0x00, sizeof (eh.ether_shost));
if (ntohs (eh.ether_type) != ETHERTYPE_IP)
return -1;
#endif
- memcpy (from -> haddr, eh.ether_shost, sizeof (eh.ether_shost));
- from -> htype = ARPHRD_ETHER;
- from -> hlen = sizeof eh.ether_shost;
+ memcpy (&from -> hbuf [1], eh.ether_shost, sizeof (eh.ether_shost));
+ from -> hbuf [0] = ARPHRD_ETHER;
+ from -> hlen = (sizeof eh.ether_shost) + 1;
- return sizeof eh;
+ return ETHER_HEADER_SIZE;
}
#endif /* PACKET_DECODING */