diff options
author | obrien <obrien@FreeBSD.org> | 1999-05-02 09:03:51 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 1999-05-02 09:03:51 +0000 |
commit | 76664fd3c5ed0bff5785e0d1beeab0742940552b (patch) | |
tree | 75c1496cd45733a402c0090488b97a6f92f09d2f /contrib/isc-dhcp/common | |
parent | ec73946e9e9092af9b1a8b19683a52740263c1df (diff) | |
download | FreeBSD-src-76664fd3c5ed0bff5785e0d1beeab0742940552b.zip FreeBSD-src-76664fd3c5ed0bff5785e0d1beeab0742940552b.tar.gz |
Virgin import of ISC-DHCP v2.0b1pl27
Diffstat (limited to 'contrib/isc-dhcp/common')
-rw-r--r-- | contrib/isc-dhcp/common/alloc.c | 4 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/bpf.c | 8 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/conflex.c | 4 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/dhcp-options.5 | 113 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/dispatch.c | 29 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/hash.c | 47 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/icmp.c | 4 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/inet.c | 7 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/lpf.c | 24 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/nit.c | 8 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/options.c | 70 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/packet.c | 84 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/parse.c | 5 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/raw.c | 40 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/socket.c | 12 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/tables.c | 30 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/upf.c | 10 |
17 files changed, 367 insertions, 132 deletions
diff --git a/contrib/isc-dhcp/common/alloc.c b/contrib/isc-dhcp/common/alloc.c index a958462..61d7572 100644 --- a/contrib/isc-dhcp/common/alloc.c +++ b/contrib/isc-dhcp/common/alloc.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: alloc.c,v 1.13.2.1 1998/11/24 22:17:15 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: alloc.c,v 1.13.2.2 1999/03/26 16:39:36 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -240,6 +240,8 @@ void free_lease_state (ptr, name) struct lease_state *ptr; char *name; { + if (ptr -> prl) + dfree (ptr -> prl, name); ptr -> next = free_lease_states; free_lease_states = ptr; } diff --git a/contrib/isc-dhcp/common/bpf.c b/contrib/isc-dhcp/common/bpf.c index 3823406..d1c3b1a 100644 --- a/contrib/isc-dhcp/common/bpf.c +++ b/contrib/isc-dhcp/common/bpf.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: bpf.c,v 1.19.2.8 1999/02/23 22:09:56 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: bpf.c,v 1.19.2.9 1999/03/29 22:07:12 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -418,6 +418,12 @@ int can_unicast_without_arp () return 1; } +int can_receive_unicast_unconfigured (ip) + struct interface_info *ip; +{ + return 1; +} + void maybe_setup_fallback () { struct interface_info *fbi; diff --git a/contrib/isc-dhcp/common/conflex.c b/contrib/isc-dhcp/common/conflex.c index c84daad..ddb78e6 100644 --- a/contrib/isc-dhcp/common/conflex.c +++ b/contrib/isc-dhcp/common/conflex.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: conflex.c,v 1.29.2.3 1999/02/09 04:49:04 mellon Exp $ Copyright (c) 1995, 1996, 1997 The Internet Software Consortium. All rights reserved.\n"; +"$Id: conflex.c,v 1.29.2.4 1999/04/06 14:58:55 mellon Exp $ Copyright (c) 1995, 1996, 1997 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -354,6 +354,8 @@ static int intern (atom, dfv) switch (tolower (atom [0])) { case 'a': + if (!strcasecmp (atom + 1, "lways-reply-rfc1048")) + return ALWAYS_REPLY_RFC1048; if (!strcasecmp (atom + 1, "ppend")) return APPEND; if (!strcasecmp (atom + 1, "llow")) diff --git a/contrib/isc-dhcp/common/dhcp-options.5 b/contrib/isc-dhcp/common/dhcp-options.5 index 3375c50..5e7ca00 100644 --- a/contrib/isc-dhcp/common/dhcp-options.5 +++ b/contrib/isc-dhcp/common/dhcp-options.5 @@ -103,9 +103,9 @@ enclosed in double quotes, or a series of octets specified in hexadecimal, seperated by colons. For example: .nf .sp 1 - option client-identifier "CLIENT-FOO"; + option dhcp-client-identifier "CLIENT-FOO"; or - option client-identifier 43:4c:49:45:54:2d:46:4f:4f; + option dhcp-client-identifier 43:4c:49:45:54:2d:46:4f:4f; .fi .PP The documentation for the various options mentioned below is taken @@ -569,6 +569,115 @@ This option can be used to specify the a DHCP client identifier in a host declaration, so that dhcpd can find the host record by matching against the client identifier. .RE +.B option \fBnisplus-domain\fR \fIstring\fR\fB;\fR +.RS 0.25i +.PP +This option specifies the name of the client's NIS+ domain. The +domain is formatted as a character string consisting of characters +from the NVT ASCII character set. +.RE +.B option \fBnisplus-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR... +]\fB;\fR +.RS 0.25i +.PP +This option specifies a list of IP addresses indicating NIS+ servers +available to the client. Servers should be listed in order of +preference. +.RE +.PP +.B option \fBtftp-server-name\fR \fIstring\fR\fB;\fR +.RS 0.25i +.PP +This option is used to identify a TFTP server and, if supported by the +client, should have the same effect as the \fBserver-name\fR +declaration. BOOTP clients are unlikely to support this option. +Some DHCP clients will support it, and others actually require it. +.RE +.PP +.B option \fBbootfile-name\fR \fIstring\fR\fB;\fR +.RS 0.25i +.PP +This option is used to identify a bootstrap file. If supported by the +client, it should have the same effect as the \fBfilename\fR +declaration. BOOTP clients are unlikely to support this option. Some +DHCP clients will support it, and others actually require it. +.RE +.PP +.B option \fBmobile-ip-home-agent\fR \fIip-address\fR [\fB,\fR +\fIip-address\fR... ]\fB;\fR +.RS 0.25i +.PP +This option specifies a list of IP addresses indicating mobile IP +home agents available to the client. Agents should be listed in +order of preference, although normally there will be only one such +agent. +.RE +.PP +.B option \fBsmtp-server\fR \fIip-address\fR [\fB,\fR +\fIip-address\fR... ]\fB;\fR +.RS 0.25i +.PP +The SMTP server option specifies a list of SMTP servers available to +the client. Servers should be listed in order of preference. +.RE +.PP +.B option \fBpop-server\fR \fIip-address\fR [\fB,\fR +\fIip-address\fR... ]\fB;\fR +.RS 0.25i +.PP +The POP3 server option specifies a list of POP3 available to the +client. Servers should be listed in order of preference. +.RE +.PP +.B option \fBnntp-server\fR \fIip-address\fR [\fB,\fR +\fIip-address\fR... ]\fB;\fR +.RS 0.25i +.PP +The NNTP server option specifies a list of NNTP available to the +client. Servers should be listed in order of preference. +.RE +.PP +.B option \fBwww-server\fR \fIip-address\fR [\fB,\fR +\fIip-address\fR... ]\fB;\fR +.RS 0.25i +.PP +The WWW server option specifies a list of WWW available to the +client. Servers should be listed in order of preference. +.RE +.PP +.B option \fBfinger-server\fR \fIip-address\fR [\fB,\fR +\fIip-address\fR... ]\fB;\fR +.RS 0.25i +.PP +The Finger server option specifies a list of Finger available to the +client. Servers should be listed in order of preference. +.RE +.PP +.B option \fBirc-server\fR \fIip-address\fR [\fB,\fR +\fIip-address\fR... ]\fB;\fR +.RS 0.25i +.PP +The IRC server option specifies a list of IRC available to the +client. Servers should be listed in order of preference. +.RE +.PP +.B option \fBstreettalk-server\fR \fIip-address\fR [\fB,\fR +\fIip-address\fR... ]\fB;\fR +.RS 0.25i +.PP +The StreetTalk server option specifies a list of StreetTalk servers +available to the client. Servers should be listed in order of +preference. +.RE +.PP +.B option \fBstreetalk-directory-assistance-server\fR \fIip-address\fR [\fB,\fR +\fIip-address\fR... ]\fB;\fR +.RS 0.25i +.PP +The StreetTalk Directory Assistance (STDA) server option specifies a +list of STDA servers available to the client. Servers should be +listed in order of preference. +.RE .SH SEE ALSO dhcpd.conf(5), dhcpd.leases(5), dhclient.conf(5), dhcpd(8), dhclient(8), RFC2132, RFC2131. diff --git a/contrib/isc-dhcp/common/dispatch.c b/contrib/isc-dhcp/common/dispatch.c index becf4da..cdf7ef5 100644 --- a/contrib/isc-dhcp/common/dispatch.c +++ b/contrib/isc-dhcp/common/dispatch.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: dispatch.c,v 1.47.2.12 1999/02/23 17:37:00 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dispatch.c,v 1.47.2.14 1999/03/29 22:16:36 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -74,7 +74,6 @@ void discover_interfaces (state) struct ifreq ifr; int i; int sock; - int address_count = 0; struct subnet *subnet; struct shared_network *share; struct sockaddr_in foo; @@ -356,6 +355,9 @@ void discover_interfaces (state) case ARPHRD_TUNNEL: /* ignore tunnel interfaces. */ #endif +#ifdef HAVE_ARPHRD_ROSE + case ARPHRD_ROSE: +#endif #ifdef HAVE_ARPHRD_LOOPBACK case ARPHRD_LOOPBACK: /* ignore loopback interface */ @@ -368,7 +370,7 @@ void discover_interfaces (state) memcpy (tmp -> hw_address.haddr, sa.sa_data, 6); break; -#ifndef ARPHRD_IEEE802 +#ifndef HAVE_ARPHRD_IEEE802 # define ARPHRD_IEEE802 HTYPE_IEEE802 #endif case ARPHRD_IEEE802: @@ -377,7 +379,7 @@ void discover_interfaces (state) memcpy (tmp -> hw_address.haddr, sa.sa_data, 6); break; -#ifndef ARPHRD_FDDI +#ifndef HAVE_ARPHRD_FDDI # define ARPHRD_FDDI HTYPE_FDDI #endif case ARPHRD_FDDI: @@ -394,9 +396,26 @@ void discover_interfaces (state) break; #endif +#ifdef HAVE_ARPHRD_AX25 + case ARPHRD_AX25: + tmp -> hw_address.hlen = 6; + tmp -> hw_address.htype = ARPHRD_AX25; + memcpy (tmp -> hw_address.haddr, sa.sa_data, 6); + break; +#endif + +#ifdef HAVE_ARPHRD_NETROM + case ARPHRD_NETROM: + tmp -> hw_address.hlen = 6; + tmp -> hw_address.htype = ARPHRD_NETROM; + memcpy (tmp -> hw_address.haddr, sa.sa_data, 6); + break; +#endif + default: - error ("%s: unknown hardware address type %d", + warn ("%s: unknown hardware address type %d", ifr.ifr_name, sa.sa_family); + break; } } #endif /* defined (HAVE_SIOCGIFHWADDR) && !defined (HAVE_AF_LINK) */ diff --git a/contrib/isc-dhcp/common/hash.c b/contrib/isc-dhcp/common/hash.c index 8d362cb..58ed7c6 100644 --- a/contrib/isc-dhcp/common/hash.c +++ b/contrib/isc-dhcp/common/hash.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: hash.c,v 1.9.2.1 1998/06/25 21:11:29 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: hash.c,v 1.9.2.3 1999/04/09 17:39:41 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -67,23 +67,12 @@ static INLINE int do_hash (name, len, size) register int accum = 0; register unsigned char *s = name; int i = len; - if (i) { - while (i--) { - /* Add the character in... */ - accum += *s++; - /* Add carry back in... */ - while (accum > 255) { - accum = (accum & 255) + (accum >> 8); - } - } - } else { - while (*s) { - /* Add the character in... */ - accum += *s++; - /* Add carry back in... */ - while (accum > 255) { - accum = (accum & 255) + (accum >> 8); - } + while (i--) { + /* Add the character in... */ + accum += *s++; + /* Add carry back in... */ + while (accum > 255) { + accum = (accum & 255) + (accum >> 8); } } return accum % size; @@ -100,6 +89,8 @@ void add_hash (table, name, len, pointer) if (!table) return; + if (!len) + len = strlen ((char *)name); hashno = do_hash (name, len, table -> hash_count); bp = new_hash_bucket ("add_hash"); @@ -125,6 +116,8 @@ void delete_hash_entry (table, name, len) if (!table) return; + if (!len) + len = strlen ((char *)name); hashno = do_hash (name, len, table -> hash_count); @@ -157,19 +150,15 @@ unsigned char *hash_lookup (table, name, len) if (!table) return (unsigned char *)0; + + if (!len) + len = strlen ((char *)name); + hashno = do_hash (name, len, table -> hash_count); - if (len) { - for (bp = table -> buckets [hashno]; bp; bp = bp -> next) { - if (len == bp -> len - && !memcmp (bp -> name, name, len)) - return bp -> value; - } - } else { - for (bp = table -> buckets [hashno]; bp; bp = bp -> next) - if (!strcmp ((char *)bp -> name, (char *)name)) - return bp -> value; + for (bp = table -> buckets [hashno]; bp; bp = bp -> next) { + if (len == bp -> len && !memcmp (bp -> name, name, len)) + return bp -> value; } return (unsigned char *)0; } - diff --git a/contrib/isc-dhcp/common/icmp.c b/contrib/isc-dhcp/common/icmp.c index fb6cfad..a9d7ec4 100644 --- a/contrib/isc-dhcp/common/icmp.c +++ b/contrib/isc-dhcp/common/icmp.c @@ -43,7 +43,7 @@ #ifndef lint static char copyright[] = -"$Id: icmp.c,v 1.7.2.1 1998/06/25 21:11:29 mellon Exp $ Copyright (c) 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: icmp.c,v 1.7.2.2 1999/03/29 23:20:00 mellon Exp $ Copyright (c) 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -61,8 +61,6 @@ void icmp_startup (routep, handler) { struct protoent *proto; int protocol = 1; - struct sockaddr_in from; - int fd; int state; /* Only initialize icmp once. */ diff --git a/contrib/isc-dhcp/common/inet.c b/contrib/isc-dhcp/common/inet.c index b7c4ba4..527afbb 100644 --- a/contrib/isc-dhcp/common/inet.c +++ b/contrib/isc-dhcp/common/inet.c @@ -40,6 +40,11 @@ * Enterprises, see ``http://www.vix.com''. */ +#ifndef lint +static char copyright[] = +"$Id: inet.c,v 1.5.2.2 1999/04/24 16:48:10 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +#endif /* not lint */ + #include "dhcpd.h" /* Return just the network number of an internet address... */ @@ -114,7 +119,7 @@ struct iaddr broadcast_addr (subnet, mask) struct iaddr subnet; struct iaddr mask; { - int i, j, k; + int i; struct iaddr rv; if (subnet.len != mask.len) { diff --git a/contrib/isc-dhcp/common/lpf.c b/contrib/isc-dhcp/common/lpf.c index d31d6f3..4deecf8 100644 --- a/contrib/isc-dhcp/common/lpf.c +++ b/contrib/isc-dhcp/common/lpf.c @@ -43,7 +43,7 @@ #ifndef lint static char copyright[] = -"$Id: lpf.c,v 1.1.2.6 1999/02/23 22:09:55 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: lpf.c,v 1.1.2.8 1999/03/29 22:07:13 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -92,10 +92,12 @@ int if_register_lpf (info) if ((sock = socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_ALL))) < 0) { if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT || errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT || - errno == EAFNOSUPPORT) - error ("socket: %m - make sure %s %s!", - "CONFIG_PACKET and CONFIG_FILTER are defined", + errno == EAFNOSUPPORT || errno == EINVAL) { + warn ("socket: %m"); + error ("Make sure to set %s %s!", + "CONFIG_PACKET=y and CONFIG_FILTER=y", "in your kernel configuration"); + } error("Open a socket for LPF: %m"); } @@ -106,10 +108,12 @@ int if_register_lpf (info) if (bind (sock, &sa, sizeof sa)) { if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT || errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT || - errno == EAFNOSUPPORT) - error ("socket: %m - make sure %s %s!", - "CONFIG_PACKET and CONFIG_FILTER are defined", + errno == EAFNOSUPPORT || errno == EINVAL) { + warn ("bind: %m"); + error ("Set %s %s!", + "CONFIG_PACKET=y and CONFIG_FILTER=y", "in your kernel configuration"); + } error("Bind socket to interface: %m"); } @@ -280,6 +284,12 @@ int can_unicast_without_arp () return 1; } +int can_receive_unicast_unconfigured (ip) + struct interface_info *ip; +{ + return 1; +} + void maybe_setup_fallback () { struct interface_info *fbi; diff --git a/contrib/isc-dhcp/common/nit.c b/contrib/isc-dhcp/common/nit.c index 047f2a1..77f43b3 100644 --- a/contrib/isc-dhcp/common/nit.c +++ b/contrib/isc-dhcp/common/nit.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: nit.c,v 1.15.2.3 1999/02/23 22:09:54 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: nit.c,v 1.15.2.4 1999/03/29 22:07:14 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -360,6 +360,12 @@ int can_unicast_without_arp () return 1; } +int can_receive_unicast_unconfigured (ip) + struct interface_info *ip; +{ + return 1; +} + void maybe_setup_fallback () { struct interface_info *fbi; diff --git a/contrib/isc-dhcp/common/options.c b/contrib/isc-dhcp/common/options.c index 9d6b7f4..b1c463f 100644 --- a/contrib/isc-dhcp/common/options.c +++ b/contrib/isc-dhcp/common/options.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: options.c,v 1.26.2.3 1998/06/25 21:11:30 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: options.c,v 1.26.2.7 1999/03/30 02:57:47 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #define DHCP_OPTION_DATA @@ -119,7 +119,8 @@ void parse_option_buffer (packet, buffer, length) /* If we haven't seen this option before, just make space for it and copy it there. */ if (!packet -> options [code].data) { - if (!(t = (unsigned char *)malloc (len + 1))) + if (!(t = ((unsigned char *) + dmalloc (len + 1, "parse_option_buffer")))) error ("Can't allocate storage for option %s.", dhcp_options [code].name); /* Copy and NUL-terminate the option (in case it's an @@ -132,10 +133,9 @@ void parse_option_buffer (packet, buffer, length) /* If it's a repeat, concatenate it to whatever we last saw. This is really only required for clients, but what the heck... */ - t = (unsigned char *) - malloc (len - + packet -> options [code].len - + 1); + t = ((unsigned char *) + dmalloc (len + packet -> options [code].len + 1, + "parse_option_buffer")); if (!t) error ("Can't expand storage for option %s.", dhcp_options [code].name); @@ -145,7 +145,8 @@ void parse_option_buffer (packet, buffer, length) &s [2], len); packet -> options [code].len += len; t [packet -> options [code].len] = 0; - free (packet -> options [code].data); + dfree (packet -> options [code].data, + "parse_option_buffer"); packet -> options [code].data = t; } s += len + 2; @@ -157,13 +158,17 @@ void parse_option_buffer (packet, buffer, length) three seperate buffers if needed. This allows us to cons up a set of vendor options using the same routine. */ -int cons_options (inpacket, outpacket, options, overload, terminate, bootpp) +int cons_options (inpacket, outpacket, mms, + options, overload, terminate, bootpp, prl, prl_len) struct packet *inpacket; struct dhcp_packet *outpacket; + int mms; struct tree_cache **options; int overload; /* Overload flags that may be set. */ int terminate; int bootpp; + u_int8_t *prl; + int prl_len; { unsigned char priority_list [300]; int priority_len; @@ -178,21 +183,29 @@ int cons_options (inpacket, outpacket, options, overload, terminate, bootpp) use up to the minimum IP MTU size (576 bytes). */ /* XXX if a BOOTP client specifies a max message size, we will honor it. */ - if (inpacket && inpacket -> options [DHO_DHCP_MAX_MESSAGE_SIZE].data) { - main_buffer_size = - (getUShort (inpacket -> options - [DHO_DHCP_MAX_MESSAGE_SIZE].data) - - DHCP_FIXED_LEN); - /* Enforce a minimum packet size... */ - if (main_buffer_size < (576 - DHCP_FIXED_LEN)) - main_buffer_size = 576 - DHCP_FIXED_LEN; - if (main_buffer_size > sizeof buffer) - main_buffer_size = sizeof buffer; - } else if (bootpp) + if (!mms && + inpacket && + inpacket -> options [DHO_DHCP_MAX_MESSAGE_SIZE].data && + (inpacket -> options [DHO_DHCP_MAX_MESSAGE_SIZE].len >= + sizeof (u_int16_t))) + mms = getUShort (inpacket -> options + [DHO_DHCP_MAX_MESSAGE_SIZE].data); + + /* If the client has provided a maximum DHCP message size, + use that; otherwise, if it's BOOTP, only 64 bytes; otherwise + use up to the minimum IP MTU size (576 bytes). */ + /* XXX if a BOOTP client specifies a max message size, we will + honor it. */ + if (mms) + main_buffer_size = mms - DHCP_FIXED_LEN; + else if (bootpp) main_buffer_size = 64; else main_buffer_size = 576 - DHCP_FIXED_LEN; + if (main_buffer_size > sizeof buffer) + main_buffer_size = sizeof buffer; + /* Preload the option priority list with mandatory options. */ priority_len = 0; priority_list [priority_len++] = DHO_DHCP_MESSAGE_TYPE; @@ -212,9 +225,17 @@ int cons_options (inpacket, outpacket, options, overload, terminate, bootpp) prlen = (sizeof priority_list) - priority_len; memcpy (&priority_list [priority_len], - inpacket -> options - [DHO_DHCP_PARAMETER_REQUEST_LIST].data, prlen); + (inpacket -> options + [DHO_DHCP_PARAMETER_REQUEST_LIST].data), prlen); priority_len += prlen; + prl = priority_list; + } else if (prl) { + if (prl_len + priority_len > sizeof priority_list) + prl_len = (sizeof priority_list) - priority_len; + + memcpy (&priority_list [priority_len], prl, prl_len); + priority_len += prl_len; + prl = priority_list; } else { memcpy (&priority_list [priority_len], dhcp_option_default_priority_list, @@ -582,6 +603,7 @@ void do_packet (interface, packet, len, from_port, from, hfrom) struct hardware *hfrom; { struct packet tp; + int i; if (packet -> hlen > sizeof packet -> chaddr) { note ("Discarding packet with invalid hlen."); @@ -605,5 +627,11 @@ void do_packet (interface, packet, len, from_port, from, hfrom) dhcp (&tp); else bootp (&tp); + + /* Free the data associated with the options. */ + for (i = 0; i < 256; i++) { + if (tp.options [i].len && tp.options [i].data) + dfree (tp.options [i].data, "do_packet"); + } } diff --git a/contrib/isc-dhcp/common/packet.c b/contrib/isc-dhcp/common/packet.c index 069a76b..b5ad427 100644 --- a/contrib/isc-dhcp/common/packet.c +++ b/contrib/isc-dhcp/common/packet.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: packet.c,v 1.18.2.1 1998/06/26 18:20:44 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: packet.c,v 1.18.2.4 1999/04/24 15:31:47 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -72,6 +72,9 @@ u_int32_t checksum (buf, nbytes, sum) debug ("sum = %x", sum); #endif sum += (u_int16_t) ntohs(*((u_int16_t *)(buf + i))); + /* Add carry. */ + if (sum > 0xFFFF) + sum -= 0xFFFF; } /* If there's a single byte left over, checksum it, too. Network @@ -81,13 +84,15 @@ u_int32_t checksum (buf, nbytes, sum) debug ("sum = %x", sum); #endif sum += buf [i] << 8; + /* Add carry. */ + if (sum > 0xFFFF) + sum -= 0xFFFF; } return sum; } -/* Fold the upper sixteen bits of the checksum down into the lower bits, - complement the sum, and then put it into network byte order. */ +/* Finish computing the sum, and then put it into network byte order. */ u_int32_t wrapsum (sum) u_int32_t sum; @@ -96,17 +101,7 @@ u_int32_t wrapsum (sum) debug ("wrapsum (%x)", sum); #endif - while (sum > 0x10000) { - sum = (sum >> 16) + (sum & 0xFFFF); -#ifdef DEBUG_CHECKSUM_VERBOSE - debug ("sum = %x", sum); -#endif - sum += (sum >> 16); -#ifdef DEBUG_CHECKSUM_VERBOSE - debug ("sum = %x", sum); -#endif - } - sum = sum ^ 0xFFFF; + sum = ~sum & 0xFFFF; #ifdef DEBUG_CHECKSUM_VERBOSE debug ("sum = %x", sum); #endif @@ -194,17 +189,15 @@ void assemble_udp_ip_header (interface, buf, bufix, /* Compute UDP checksums, including the ``pseudo-header'', the UDP header and the data. */ -#if 0 udp.uh_sum = wrapsum (checksum ((unsigned char *)&udp, sizeof udp, checksum (data, len, checksum ((unsigned char *) &ip.ip_src, - sizeof ip.ip_src, + 2 * sizeof ip.ip_src, IPPROTO_UDP + (u_int32_t) ntohs (udp.uh_ulen))))); -#endif /* Copy the udp header into the buffer... */ memcpy (&buf [*bufix], &udp, sizeof udp); @@ -239,18 +232,25 @@ ssize_t decode_hw_header (interface, buf, bufix, from) /* UDP header and IP header decoded together for convenience. */ -ssize_t decode_udp_ip_header (interface, buf, bufix, from, data, len) +ssize_t decode_udp_ip_header (interface, buf, bufix, from, data, buflen) struct interface_info *interface; unsigned char *buf; int bufix; struct sockaddr_in *from; unsigned char *data; - int len; + int buflen; { struct ip *ip; struct udphdr *udp; u_int32_t ip_len = (buf [bufix] & 0xf) << 2; u_int32_t sum, usum; + static int ip_packets_seen; + static int ip_packets_bad_checksum; + static int udp_packets_seen; + static int udp_packets_bad_checksum; + static int udp_packets_length_checked; + static int udp_packets_length_overflow; + int len; ip = (struct ip *)(buf + bufix); udp = (struct udphdr *)(buf + bufix + ip_len); @@ -266,12 +266,23 @@ ssize_t decode_udp_ip_header (interface, buf, bufix, from, data, len) #endif /* USERLAND_FILTER */ /* Check the IP header checksum - it should be zero. */ + ++ip_packets_seen; if (wrapsum (checksum (buf + bufix, ip_len, 0))) { - note ("Bad IP checksum: %x", - wrapsum (checksum (buf + bufix, sizeof *ip, 0))); + ++ip_packets_bad_checksum; + if (ip_packets_seen > 4 && + (ip_packets_seen / ip_packets_bad_checksum) < 2) { + note ("%d bad IP checksums seen in %d packets", + ip_packets_bad_checksum, ip_packets_seen); + ip_packets_seen = ip_packets_bad_checksum = 0; + } return -1; } + /* Check the IP packet length. */ + if (ntohs (ip -> ip_len) != buflen) + debug ("ip length %d disagrees with bytes received %d.", + ntohs (ip -> ip_len), buflen); + /* Copy out the IP source address... */ memcpy (&from -> sin_addr, &ip -> ip_src, 4); @@ -281,10 +292,25 @@ ssize_t decode_udp_ip_header (interface, buf, bufix, from, data, len) if (!data) { data = buf + bufix + ip_len + sizeof *udp; - len -= ip_len + sizeof *udp; + len = ntohs (udp -> uh_ulen) - sizeof *udp; + ++udp_packets_length_checked; + if (len + data > buf + bufix + buflen) { + ++udp_packets_length_overflow; + if (udp_packets_length_checked > 4 && + (udp_packets_length_checked / + udp_packets_length_overflow) < 2) { + note ("%d udp packets in %d too long - dropped", + udp_packets_length_overflow, + udp_packets_length_checked); + udp_packets_length_overflow = + udp_packets_length_checked = 0; + } + return -1; + } + if (len + data != buf + bufix + buflen) + debug ("accepting packet with data after udp payload."); } -#if 0 usum = udp -> uh_sum; udp -> uh_sum = 0; @@ -292,16 +318,22 @@ ssize_t decode_udp_ip_header (interface, buf, bufix, from, data, len) checksum (data, len, checksum ((unsigned char *) &ip -> ip_src, - sizeof ip -> ip_src, + 2 * sizeof ip -> ip_src, IPPROTO_UDP + (u_int32_t) ntohs (udp -> uh_ulen))))); + udp_packets_seen++; if (usum && usum != sum) { - note ("Bad udp checksum: %x %x", usum, sum); + udp_packets_bad_checksum++; + if (udp_packets_seen > 4 && + (udp_packets_seen / udp_packets_bad_checksum) < 2) { + note ("%d bad udp checksums in %d packets", + udp_packets_bad_checksum, udp_packets_seen); + udp_packets_seen = udp_packets_bad_checksum = 0; + } return -1; } -#endif /* Copy out the port... */ memcpy (&from -> sin_port, &udp -> uh_sport, sizeof udp -> uh_sport); diff --git a/contrib/isc-dhcp/common/parse.c b/contrib/isc-dhcp/common/parse.c index d750ec5..fe02689 100644 --- a/contrib/isc-dhcp/common/parse.c +++ b/contrib/isc-dhcp/common/parse.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: parse.c,v 1.2.2.3 1998/12/22 22:43:22 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: parse.c,v 1.2.2.4 1999/03/29 22:18:53 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -192,9 +192,6 @@ int parse_ip_addr (cfile, addr) FILE *cfile; struct iaddr *addr; { - char *val; - int token; - addr -> len = 4; if (parse_numeric_aggregate (cfile, addr -> iabuf, &addr -> len, DOT, 10, 8)) diff --git a/contrib/isc-dhcp/common/raw.c b/contrib/isc-dhcp/common/raw.c index 2740c49..9274980 100644 --- a/contrib/isc-dhcp/common/raw.c +++ b/contrib/isc-dhcp/common/raw.c @@ -54,7 +54,7 @@ #ifndef lint static char copyright[] = -"$Id: raw.c,v 1.11.2.2 1999/02/23 22:09:54 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: raw.c,v 1.11.2.3 1999/04/06 16:00:24 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -81,6 +81,7 @@ void if_register_send (info) if (!quiet_interface_discovery) note ("Sending on %s, port %d", piaddr (info -> address), htons (local_port)); + if ((sock = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) error ("Can't create dhcp socket: %m"); @@ -104,7 +105,7 @@ void if_register_send (info) info -> shared_network -> name : "")); } -size_t send_packet (interface, packet, raw, len, from, to, hto) +ssize_t send_packet (interface, packet, raw, len, from, to, hto) struct interface_info *interface; struct packet *packet; struct dhcp_packet *raw; @@ -113,7 +114,7 @@ size_t send_packet (interface, packet, raw, len, from, to, hto) struct sockaddr_in *to; struct hardware *hto; { - unsigned char buf [256]; + unsigned char buf [1500]; int bufp = 0; struct iovec iov [2]; int result; @@ -122,16 +123,31 @@ size_t send_packet (interface, packet, raw, len, from, to, hto) assemble_udp_ip_header (interface, buf, &bufp, from.s_addr, to -> sin_addr.s_addr, to -> sin_port, (unsigned char *)raw, len); - - /* Fire it off */ - iov [0].iov_base = (char *)buf; - iov [0].iov_len = bufp; - iov [1].iov_base = (char *)raw; - iov [1].iov_len = len; - - result = writev(interface -> wfdesc, iov, 2); + if (len + bufp > sizeof buf) { + warn ("send_packet: packet too large (%s)", len + bufp); + return; + } + memcpy (buf + bufp, raw, len); + bufp += len; + result = sendto (interface -> wfdesc, (char *)buf, bufp, 0, + (struct sockaddr *)to, sizeof *to); if (result < 0) warn ("send_packet: %m"); return result; } -#endif /* USE_SOCKET_SEND */ + +int can_unicast_without_arp () +{ + return 1; +} + +void maybe_setup_fallback () +{ +} + +void if_reinitialize_send (info) + struct interface_info *info; +{ +} + +#endif /* USE_RAW_SEND */ diff --git a/contrib/isc-dhcp/common/socket.c b/contrib/isc-dhcp/common/socket.c index 8e1b274..3d1b8f4 100644 --- a/contrib/isc-dhcp/common/socket.c +++ b/contrib/isc-dhcp/common/socket.c @@ -50,7 +50,7 @@ #ifndef lint static char copyright[] = -"$Id: socket.c,v 1.26.2.10 1999/02/23 22:09:55 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: socket.c,v 1.26.2.11 1999/03/29 22:07:14 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -269,6 +269,16 @@ int can_unicast_without_arp () return 0; } +int can_receive_unicast_unconfigured (ip) + struct interface_info *ip; +{ +#if defined (SOCKET_CAN_RECEIVE_UNICAST_UNCONFIGURED) + return 1; +#else + return 0; +#endif +} + /* If we have SO_BINDTODEVICE, set up a fallback interface; otherwise, do not. */ diff --git a/contrib/isc-dhcp/common/tables.c b/contrib/isc-dhcp/common/tables.c index abbff6f..9274e38 100644 --- a/contrib/isc-dhcp/common/tables.c +++ b/contrib/isc-dhcp/common/tables.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: tables.c,v 1.13.2.3 1998/12/22 22:45:44 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: tables.c,v 1.13.2.4 1999/04/24 16:46:44 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -130,20 +130,20 @@ struct option dhcp_options [256] = { { "dhcp-client-identifier", "X", &dhcp_universe, 61 }, { "option-62", "X", &dhcp_universe, 62 }, { "option-63", "X", &dhcp_universe, 63 }, - { "option-64", "X", &dhcp_universe, 64 }, - { "option-65", "X", &dhcp_universe, 65 }, - { "option-66", "X", &dhcp_universe, 66 }, - { "option-67", "X", &dhcp_universe, 67 }, - { "option-68", "X", &dhcp_universe, 68 }, - { "option-69", "X", &dhcp_universe, 69 }, - { "option-70", "X", &dhcp_universe, 70 }, - { "option-71", "X", &dhcp_universe, 71 }, - { "option-72", "X", &dhcp_universe, 72 }, - { "option-73", "X", &dhcp_universe, 73 }, - { "option-74", "X", &dhcp_universe, 74 }, - { "option-75", "X", &dhcp_universe, 75 }, - { "option-76", "X", &dhcp_universe, 76 }, - { "dhcp-user-class-identifier", "t", &dhcp_universe, 77 }, + { "nisplus-domain", "t", &dhcp_universe, 64 }, + { "nisplus-servers", "IA", &dhcp_universe, 65 }, + { "tftp-server-name", "t", &dhcp_universe, 66 }, + { "bootfile-name", "t", &dhcp_universe, 67 }, + { "mobile-ip-home-agent", "IA", &dhcp_universe, 68 }, + { "smtp-server", "IA", &dhcp_universe, 69 }, + { "pop-server", "IA", &dhcp_universe, 70 }, + { "nntp-server", "IA", &dhcp_universe, 71 }, + { "www-server", "IA", &dhcp_universe, 72 }, + { "finger-server", "IA", &dhcp_universe, 73 }, + { "irc-server", "IA", &dhcp_universe, 74 }, + { "streettalk-server", "IA", &dhcp_universe, 75 }, + { "streettalk-directory-assistance-server", "IA", &dhcp_universe, 76 }, + { "user-class", "t", &dhcp_universe, 77 }, { "option-78", "X", &dhcp_universe, 78 }, { "option-79", "X", &dhcp_universe, 79 }, { "option-80", "X", &dhcp_universe, 80 }, diff --git a/contrib/isc-dhcp/common/upf.c b/contrib/isc-dhcp/common/upf.c index c172c62..70f8eff 100644 --- a/contrib/isc-dhcp/common/upf.c +++ b/contrib/isc-dhcp/common/upf.c @@ -1,6 +1,6 @@ /* upf.c - Ultrix PacketFilter interface code. + Ultrix PacketFilter interface code. */ /* * Copyright (c) 1995, 1996, 1997, 1998, 1999 @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: upf.c,v 1.3.2.3 1999/02/23 22:09:56 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +"$Id: upf.c,v 1.3.2.5 1999/03/29 22:07:13 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -311,6 +311,12 @@ int can_unicast_without_arp () return 1; } +int can_receive_unicast_unconfigured (ip) + struct interface_info *ip; +{ + return 1; +} + void maybe_setup_fallback () { struct interface_info *fbi; |