diff options
Diffstat (limited to 'contrib/isc-dhcp/common')
-rw-r--r-- | contrib/isc-dhcp/common/alloc.c | 7 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/bpf.c | 69 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/conflex.c | 22 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/dhcp-options.5 | 236 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/dispatch.c | 271 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/lpf.c | 287 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/memory.c | 88 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/nit.c | 22 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/parse.c | 8 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/print.c | 14 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/socket.c | 40 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/tables.c | 6 | ||||
-rw-r--r-- | contrib/isc-dhcp/common/upf.c | 22 |
13 files changed, 879 insertions, 213 deletions
diff --git a/contrib/isc-dhcp/common/alloc.c b/contrib/isc-dhcp/common/alloc.c index 172fcea606dd..a9584622a6ba 100644 --- a/contrib/isc-dhcp/common/alloc.c +++ b/contrib/isc-dhcp/common/alloc.c @@ -3,7 +3,7 @@ Memory allocation... */ /* - * Copyright (c) 1995, 1996 The Internet Software Consortium. + * Copyright (c) 1995, 1996, 1998 The Internet Software Consortium. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: alloc.c,v 1.13 1997/05/09 07:56:13 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$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"; #endif /* not lint */ #include "dhcpd.h" @@ -57,7 +57,8 @@ VOIDPTR dmalloc (size, name) VOIDPTR foo = (VOIDPTR)malloc (size); if (!foo) warn ("No memory for %s.", name); - memset (foo, 0, size); + else + memset (foo, 0, size); return foo; } diff --git a/contrib/isc-dhcp/common/bpf.c b/contrib/isc-dhcp/common/bpf.c index e47aa1f7822c..ba42a43903cd 100644 --- a/contrib/isc-dhcp/common/bpf.c +++ b/contrib/isc-dhcp/common/bpf.c @@ -3,8 +3,8 @@ BPF socket interface code, originally contributed by Archie Cobbs. */ /* - * Copyright (c) 1995, 1996 The Internet Software Consortium. - * All rights reserved. + * Copyright (c) 1995, 1996, 1998, 1999 + * The Internet Software Consortium. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -42,22 +42,31 @@ #ifndef lint static char copyright[] = -"$Id: bpf.c,v 1.19 1997/10/20 21:47:13 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: bpf.c,v 1.19.2.6 1999/02/09 04:46:59 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" -#if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE) -#include <sys/ioctl.h> -#include <sys/uio.h> +#if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE) \ + || defined (USE_LPF_RECEIVE) +# if defined (USE_LPF_RECEIVE) +# include <asm/types.h> +# include <linux/filter.h> +# define bpf_insn sock_filter /* Linux: dare to be gratuitously different. */ +# else +# include <sys/ioctl.h> +# include <sys/uio.h> + +# include <net/bpf.h> +# if defined (NEED_OSF_PFILT_HACKS) +# include <net/pfilt.h> +# endif +# endif -#include <net/bpf.h> -#ifdef NEED_OSF_PFILT_HACKS -#include <net/pfilt.h> -#endif #include <netinet/in_systm.h> #include "includes/netinet/ip.h" #include "includes/netinet/udp.h" #include "includes/netinet/if_ether.h" +#endif /* Reinitializes the specified interface after an address change. This is not required for packet-filter APIs. */ @@ -80,6 +89,7 @@ void if_reinitialize_receive (info) Opens a packet filter for each interface and adds it to the select mask. */ +#if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE) int if_register_bpf (info) struct interface_info *info; { @@ -99,6 +109,11 @@ int if_register_bpf (info) if (errno == EBUSY) { continue; } else { + if (!b) + error ("No bpf devices.%s%s%s", + " Please read the README", + " section for your operating", + " system."); error ("Can't find free bpf: %m"); } } else { @@ -137,12 +152,12 @@ void if_register_send (info) } #endif /* USE_BPF_SEND */ -#ifdef USE_BPF_RECEIVE +#if defined (USE_BPF_RECEIVE) || defined (USE_LPF_RECEIVE) /* Packet filter program... XXX Changes to the filter program may require changes to the constant offsets used in if_register_send to patch the BPF program! XXX */ -struct bpf_insn filter [] = { +struct bpf_insn dhcp_bpf_filter [] = { /* Make sure this is an IP packet... */ BPF_STMT (BPF_LD + BPF_H + BPF_ABS, 12), BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_IP, 0, 8), @@ -169,6 +184,10 @@ struct bpf_insn filter [] = { BPF_STMT(BPF_RET+BPF_K, 0), }; +int dhcp_bpf_filter_len = sizeof dhcp_bpf_filter / sizeof (struct bpf_insn); +#endif + +#if defined (USE_BPF_RECEIVE) void if_register_receive (info) struct interface_info *info; { @@ -220,13 +239,13 @@ void if_register_receive (info) info -> rbuf_len = 0; /* Set up the bpf filter program structure. */ - p.bf_len = sizeof filter / sizeof (struct bpf_insn); - p.bf_insns = filter; + p.bf_len = dhcp_bpf_filter_len; + p.bf_insns = dhcp_bpf_filter; /* Patch the server port into the BPF program... XXX changes to filter program may require changes to the insn number(s) used below! XXX */ - filter [8].k = ntohs (local_port); + dhcp_bpf_filter [8].k = ntohs (local_port); if (ioctl (info -> rfdesc, BIOCSETF, &p) < 0) error ("Can't install packet filter program: %m"); @@ -255,6 +274,10 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) unsigned char buf [256]; struct iovec iov [2]; + if (!strcmp (interface -> name, "fallback")) + return send_fallback (interface, packet, raw, + len, from, to, hto); + /* Assemble the headers... */ assemble_hw_header (interface, buf, &bufp, hto); assemble_udp_ip_header (interface, buf, &bufp, from.s_addr, @@ -383,4 +406,20 @@ ssize_t receive_packet (interface, buf, len, from, hfrom) } while (!length); return 0; } + +int can_unicast_without_arp () +{ + return 1; +} + +void maybe_setup_fallback () +{ + struct interface_info *fbi; + fbi = setup_fallback (); + if (fbi) { + if_register_fallback (fbi); + add_protocol ("fallback", fallback_interface -> wfdesc, + fallback_discard, fallback_interface); + } +} #endif diff --git a/contrib/isc-dhcp/common/conflex.c b/contrib/isc-dhcp/common/conflex.c index eedfa054b662..c84daad6bcb8 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 1997/10/29 18:32:53 mellon Exp $ Copyright (c) 1995, 1996, 1997 The Internet Software Consortium. All rights reserved.\n"; +"$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"; #endif /* not lint */ #include "dhcpd.h" @@ -362,6 +362,8 @@ static int intern (atom, dfv) return ALIAS; if (!strcasecmp (atom + 1, "bandoned")) return ABANDONED; + if (!strcasecmp (atom + 1, "uthoritative")) + return AUTHORITATIVE; break; case 'b': if (!strcasecmp (atom + 1, "ackoff-cutoff")) @@ -417,6 +419,8 @@ static int intern (atom, dfv) return FILENAME; if (!strcasecmp (atom + 1, "ixed-address")) return FIXED_ADDR; + if (!strcasecmp (atom + 1, "ddi")) + return FDDI; break; case 'g': if (!strcasecmp (atom + 1, "iaddr")) @@ -462,6 +466,8 @@ static int intern (atom, dfv) return NETMASK; if (!strcasecmp (atom + 1, "ext-server")) return NEXT_SERVER; + if (!strcasecmp (atom + 1, "ot")) + return TOKEN_NOT; break; case 'o': if (!strcasecmp (atom + 1, "ption")) @@ -526,12 +532,18 @@ static int intern (atom, dfv) return TOKEN_RING; break; case 'u': + if (!strncasecmp (atom + 1, "se", 2)) { + if (!strcasecmp (atom + 3, "r-class")) + return USER_CLASS; + if (!strcasecmp (atom + 3, "-host-decl-names")) + return USE_HOST_DECL_NAMES; + if (!strcasecmp (atom + 3, + "-lease-addr-for-default-route")) + return USE_LEASE_ADDR_FOR_DEFAULT_ROUTE; + break; + } if (!strcasecmp (atom + 1, "id")) return UID; - if (!strcasecmp (atom + 1, "ser-class")) - return USER_CLASS; - if (!strcasecmp (atom + 1, "se-host-decl-names")) - return USE_HOST_DECL_NAMES; if (!strcasecmp (atom + 1, "nknown-clients")) return UNKNOWN_CLIENTS; break; diff --git a/contrib/isc-dhcp/common/dhcp-options.5 b/contrib/isc-dhcp/common/dhcp-options.5 index eb90ed6eac9b..3375c507f14d 100644 --- a/contrib/isc-dhcp/common/dhcp-options.5 +++ b/contrib/isc-dhcp/common/dhcp-options.5 @@ -1,6 +1,6 @@ .\" dhcp-options.5 .\" -.\" Copyright (c) 1995, 1996, 1997 The Internet Software Consortium. +.\" Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -126,7 +126,8 @@ no checking is done to ensure the correctness of the entered data. .PP The standard options are: .PP - \fBoption subnet-mask\fR \fIip-address\fR\fB;\fR +.B option subnet-mask \fIip-address\fR\fB;\fR +.RS 0.25i .PP The subnet mask option specifies the client's subnet mask as per RFC 950. If no subnet mask option is provided anywhere in scope, as a @@ -136,114 +137,162 @@ for the network on which an address is being assigned. However, subnet-mask option declaration that is in scope for the address being assigned will override the subnet mask specified in the subnet declaration. +.RE .PP - \fBoption time-offset\fR \fIint32\fR\fB;\fR +.B option time-offset \fIint32\fR\fB;\fR +.RS 0.25i .PP The time-offset option specifies the offset of the client's subnet in seconds from Coordinated Universal Time (UTC). +.RE .PP - \fBoption routers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR +.B option routers \fIip-address\fR [\fB,\fR \fIip-address\fR... +]\fB;\fR +.RS 0.25i .PP The routers option specifies a list of IP addresses for routers on the client's subnet. Routers should be listed in order of preference. +.RE .PP - \fBoption time-servers\fR \fIip-address [, \fIip-address\fR ... ]\fB;\fR +.B option time-servers \fIip-address\fR [, \fIip-address\fR... +]\fB;\fR +.RS 0.25i .PP The time-server option specifies a list of RFC 868 time servers available to the client. Servers should be listed in order of preference. +.RE .PP - \fBoption\fR \fBien116-name-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]; +.B option \fBien116-name-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR... +]; +.RS 0.25i .PP The ien116-name-servers option specifies a list of IEN 116 name servers available to the client. Servers should be listed in order of preference. +.RE .PP - \fBoption\fR \fBdomain-name-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR +.B option \fBdomain-name-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR... +]\fB;\fR +.RS 0.25i .PP The domain-name-servers option specifies a list of Domain Name System (STD 13, RFC 1035) name servers available to the client. Servers should be listed in order of preference. +.RE .PP - \fBoption\fR \fBlog-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR +.B option \fBlog-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR... +]\fB;\fR +.RS 0.25i .PP The log-server option specifies a list of MIT-LCS UDP log servers available to the client. Servers should be listed in order of preference. +.RE .PP - \fBoption\fR \fBcookie-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR +.B option \fBcookie-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR... +]\fB;\fR +.RS 0.25i .PP The cookie server option specifies a list of RFC 865 cookie servers available to the client. Servers should be listed in order of preference. +.RE .PP - \fBoption\fR \fBlpr-servers\fR \fIip-address \fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR +.B option \fBlpr-servers\fR \fIip-address \fR [\fB,\fR \fIip-address\fR... +]\fB;\fR +.RS 0.25i .PP The LPR server option specifies a list of RFC 1179 line printer servers available to the client. Servers should be listed in order of preference. +.RE .PP - \fBoption\fR \fBimpress-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR +.B option \fBimpress-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR... +]\fB;\fR +.RS 0.25i .PP The impress-server option specifies a list of Imagen Impress servers available to the client. Servers should be listed in order of preference. +.RE .PP - \fBoption\fR \fBresource-location-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR +.B option \fBresource-location-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR... +]\fB;\fR +.RS 0.25i .PP This option specifies a list of RFC 887 Resource Location servers available to the client. Servers should be listed in order of preference. +.RE .PP - \fBoption\fR \fBhost-name\fR \fIstring\fR\fB;\fR +.B option \fBhost-name\fR \fIstring\fR\fB;\fR +.RS 0.25i .PP This option specifies the name of the client. The name may or may not be qualified with the local domain name (it is preferable to use the domain-name option to specify the domain name). See RFC 1035 for character set restrictions. +.RE .PP - \fBoption\fR \fBboot-size\fR \fIuint16\fR\fB;\fR +.B option \fBboot-size\fR \fIuint16\fR\fB;\fR +.RS 0.25i .PP This option specifies the length in 512-octet blocks of the default boot image for the client. +.RE .PP - \fBoption\fR \fBmerit-dump\fR \fIstring\fR\fB;\fR +.B option \fBmerit-dump\fR \fIstring\fR\fB;\fR +.RS 0.25i .PP This option specifies the path-name of a file to which the client's core image should be dumped in the event the client crashes. The path is formatted as a character string consisting of characters from the NVT ASCII character set. +.RE .PP - \fBoption\fR \fBdomain-name\fR \fIstring\fR\fB;\fR +.B option \fBdomain-name\fR \fIstring\fR\fB;\fR +.RS 0.25i .PP This option specifies the domain name that client should use when resolving hostnames via the Domain Name System. +.RE .PP - \fBoption\fR \fBswap-server\fR \fIip-address\fR\fB;\fR +.B option \fBswap-server\fR \fIip-address\fR\fB;\fR +.RS 0.25i .PP This specifies the IP address of the client's swap server. +.RE .PP - \fBoption\fR \fBroot-path\fR \fIstring\fB;\fR\fR +.B option \fBroot-path\fR \fIstring\fB;\fR\fR +.RS 0.25i .PP This option specifies the path-name that contains the client's root disk. The path is formatted as a character string consisting of characters from the NVT ASCII character set. +.RE .PP - \fBoption\fR \fBip-forwarding\fR \fIflag\fR\fB;\fR +.B option \fBip-forwarding\fR \fIflag\fR\fB;\fR +.RS 0.25i .PP This option specifies whether the client should configure its IP layer for packet forwarding. A value of 0 means disable IP forwarding, and a value of 1 means enable IP forwarding. +.RE .PP - \fBoption\fR \fBnon-local-source-routing\fR \fIflag\fR\fB;\fR +.B option \fBnon-local-source-routing\fR \fIflag\fR\fB;\fR +.RS 0.25i .PP This option specifies whether the client should configure its IP layer to allow forwarding of datagrams with non-local source routes (see Section 3.3.5 of [4] for a discussion of this topic). A value of 0 means disallow forwarding of such datagrams, and a value of 1 means allow forwarding. +.RE .PP - \fBoption\fR \fBpolicy-filter\fR \fIip-address ip-address\fR [\fB,\fR \fIip-address ip-address\fR ... ]\fB;\fR +.B option \fBpolicy-filter\fR \fIip-address ip-address\fR [\fB,\fR \fIip-address ip-address\fR... +]\fB;\fR +.RS 0.25i .PP This option specifies policy filters for non-local source routing. The filters consist of a list of IP addresses and masks which specify @@ -253,36 +302,49 @@ Any source routed datagram whose next-hop address does not match one of the filters should be discarded by the client. .PP See STD 3 (RFC1122) for further information. +.RE .PP - \fBoption\fR \fBmax-dgram-reassembly\fR \fIuint16\fR\fB;\fR +.B option \fBmax-dgram-reassembly\fR \fIuint16\fR\fB;\fR +.RS 0.25i .PP This option specifies the maximum size datagram that the client should be prepared to reassemble. The minimum value legal value is 576. +.RE .PP - \fBoption\fR \fBdefault-ip-ttl\fR \fIuint8;\fR +.B option \fBdefault-ip-ttl\fR \fIuint8;\fR +.RS 0.25i .PP This option specifies the default time-to-live that the client should use on outgoing datagrams. +.RE .PP - \fBoption\fR \fBpath-mtu-aging-timeout\fR \fIuint32\fR\fB;\fR +.B option \fBpath-mtu-aging-timeout\fR \fIuint32\fR\fB;\fR +.RS 0.25i .PP This option specifies the timeout (in seconds) to use when aging Path MTU values discovered by the mechanism defined in RFC 1191. +.RE .PP - \fBoption\fR \fBpath-mtu-plateau-table\fR \fIuint16\fR [\fB,\fR \fIuint16\fR ... ]\fB;\fR +.B option \fBpath-mtu-plateau-table\fR \fIuint16\fR [\fB,\fR \fIuint16\fR... +]\fB;\fR +.RS 0.25i .PP This option specifies a table of MTU sizes to use when performing Path MTU Discovery as defined in RFC 1191. The table is formatted as a list of 16-bit unsigned integers, ordered from smallest to largest. The minimum MTU value cannot be smaller than 68. +.RE .PP - \fBoption\fR \fBinterface-mtu\fR \fIuint16\fR\fB;\fR +.B option \fBinterface-mtu\fR \fIuint16\fR\fB;\fR +.RS 0.25i .PP This option specifies the MTU to use on this interface. The minimum legal value for the MTU is 68. +.RE .PP - \fBoption\fR \fBall-subnets-local\fR \fIflag\fR\fB;\fR +.B option \fBall-subnets-local\fR \fIflag\fR\fB;\fR +.RS 0.25i .PP This option specifies whether or not the client may assume that all subnets of the IP network to which the client is connected use the @@ -290,41 +352,54 @@ same MTU as the subnet of that network to which the client is directly connected. A value of 1 indicates that all subnets share the same MTU. A value of 0 means that the client should assume that some subnets of the directly connected network may have smaller MTUs. +.RE .PP - \fBoption\fR \fBbroadcast-address\fR \fIip-address\fR\fB;\fR +.B option \fBbroadcast-address\fR \fIip-address\fR\fB;\fR +.RS 0.25i .PP This option specifies the broadcast address in use on the client's subnet. Legal values for broadcast addresses are specified in section 3.2.1.3 of STD 3 (RFC1122). +.RE .PP - \fBoption\fR \fBperform-mask-discovery\fR \fIflag\fR\fB;\fR +.B option \fBperform-mask-discovery\fR \fIflag\fR\fB;\fR +.RS 0.25i .PP This option specifies whether or not the client should perform subnet mask discovery using ICMP. A value of 0 indicates that the client should not perform mask discovery. A value of 1 means that the client should perform mask discovery. +.RE .PP - \fBoption\fR \fBmask-supplier\fR \fIflag\fR\fB;\fR +.B option \fBmask-supplier\fR \fIflag\fR\fB;\fR +.RS 0.25i .PP This option specifies whether or not the client should respond to subnet mask requests using ICMP. A value of 0 indicates that the client should not respond. A value of 1 means that the client should respond. +.RE .PP - \fBoption\fR \fBrouter-discovery\fR \fIflag\fR\fB;\fR +.B option \fBrouter-discovery\fR \fIflag\fR\fB;\fR +.RS 0.25i .PP This option specifies whether or not the client should solicit routers using the Router Discovery mechanism defined in RFC 1256. A value of 0 indicates that the client should not perform router discovery. A value of 1 means that the client should perform router discovery. +.RE .PP - \fBoption\fR \fBrouter-solicitation-address\fR \fIip-address\fR\fB;\fR +.B option \fBrouter-solicitation-address\fR \fIip-address\fR\fB;\fR +.RS 0.25i .PP This option specifies the address to which the client should transmit router solicitation requests. +.RE .PP - \fBoption\fR \fBstatic-routes\fR \fIip-address ip-address\fR [\fB,\fR \fIip-address ip-address\fR ... ]\fB;\fR +.B option \fBstatic-routes\fR \fIip-address ip-address\fR [\fB,\fR \fIip-address ip-address\fR... +]\fB;\fR +.RS 0.25i .PP This option specifies a list of static routes that the client should install in its routing cache. If multiple routes to the same @@ -339,106 +414,161 @@ The default route (0.0.0.0) is an illegal destination for a static route. To specify the default route, use the .B routers option. +.RE .PP - \fBoption\fR \fBtrailer-encapsulation\fR \fIflag\fR\fB;\fR +.B option \fBtrailer-encapsulation\fR \fIflag\fR\fB;\fR +.RS 0.25i .PP This option specifies whether or not the client should negotiate the use of trailers (RFC 893 [14]) when using the ARP protocol. A value of 0 indicates that the client should not attempt to use trailers. A value of 1 means that the client should attempt to use trailers. +.RE .PP - \fBoption\fR \fBarp-cache-timeout\fR \fIuint32\fR\fB;\fR +.B option \fBarp-cache-timeout\fR \fIuint32\fR\fB;\fR +.RS 0.25i .PP This option specifies the timeout in seconds for ARP cache entries. +.RE .PP - \fBoption\fR \fBieee802-3-encapsulation\fR \fIflag\fR\fB;\fR +.B option \fBieee802-3-encapsulation\fR \fIflag\fR\fB;\fR +.RS 0.25i .PP This option specifies whether or not the client should use Ethernet Version 2 (RFC 894) or IEEE 802.3 (RFC 1042) encapsulation if the interface is an Ethernet. A value of 0 indicates that the client should use RFC 894 encapsulation. A value of 1 means that the client should use RFC 1042 encapsulation. +.RE .PP - \fBoption\fR \fBdefault-tcp-ttl\fR \fIuint8\fR\fB;\fR +.B option \fBdefault-tcp-ttl\fR \fIuint8\fR\fB;\fR +.RS 0.25i .PP This option specifies the default TTL that the client should use when sending TCP segments. The minimum value is 1. +.RE .PP - \fBoption\fR \fBtcp-keepalive-interval\fR \fIuint32\fR\fB;\fR +.B option \fBtcp-keepalive-interval\fR \fIuint32\fR\fB;\fR +.RS 0.25i .PP This option specifies the interval (in seconds) that the client TCP should wait before sending a keepalive message on a TCP connection. The time is specified as a 32-bit unsigned integer. A value of zero indicates that the client should not generate keepalive messages on connections unless specifically requested by an application. +.RE .PP - \fBoption\fR \fBtcp-keepalive-garbage\fR \fIflag\fR\fB;\fR +.B option \fBtcp-keepalive-garbage\fR \fIflag\fR\fB;\fR +.RS 0.25i .PP This option specifies the whether or not the client should send TCP keepalive messages with a octet of garbage for compatibility with older implementations. A value of 0 indicates that a garbage octet should not be sent. A value of 1 indicates that a garbage octet should be sent. +.RE .PP - \fBoption\fR \fBnis-domain\fR \fIstring\fR\fB;\fR +.B option \fBnis-domain\fR \fIstring\fR\fB;\fR +.RS 0.25i .PP This option specifies the name of the client's NIS (Sun Network Information Services) domain. The domain is formatted as a character string consisting of characters from the NVT ASCII character set. +.RE .PP - \fBoption\fR \fBnis-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR +.B option \fBnis-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 - \fBoption\fR \fBntp-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR +.B option \fBntp-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 NTP (RFC 1035) servers available to the client. Servers should be listed in order of preference. +.RE .PP - \fBoption\fR \fBnetbios-name-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR +.B option \fBnetbios-name-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR... +]\fB;\fR +.RS 0.25i .PP The NetBIOS name server (NBNS) option specifies a list of RFC -1001/1002 NBNS name servers listed in order of preference. +1001/1002 NBNS name servers listed in order of preference. NetBIOS +Name Service is currently more commonly referred to as WINS. WINS +servers can be specified using the netbios-name-servers option. +.RE .PP - \fBoption\fR \fBnetbios-dd-server\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR +.B option \fBnetbios-dd-server\fR \fIip-address\fR [\fB,\fR \fIip-address\fR... +]\fB;\fR +.RS 0.25i .PP The NetBIOS datagram distribution server (NBDD) option specifies a list of RFC 1001/1002 NBDD servers listed in order of preference. +.RE .PP - \fBoption\fR \fBnetbios-node-type\fR \fIuint8\fR\fB;\fR +.B option \fBnetbios-node-type\fR \fIuint8\fR\fB;\fR +.RS 0.25i .PP The NetBIOS node type option allows NetBIOS over TCP/IP clients which are configurable to be configured as described in RFC 1001/1002. The value is specified as a single octet which identifies the client type. -A value of 1 corresponds to a NetBIOS B-node; a value of 2 corresponds -to a P-node; a value of 4 corresponds to an M-node; a value of 8 -corresponds to an H-node. .PP - \fBoption\fR \fBnetbios-scope\fR \fIstring\fR\fB;\fR +Possible node types are: +.PP +.TP 5 +.I 1 +B-node: Broadcast - no WINS +.TP +.I 2 +P-node: Peer - WINS only. +.TP +.I 4 +M-node: Mixed - broadcast, then WINS +.TP +.I 8 +H-node: Hybrid - WINS, then broadcast +.RE +.PP +.B option +.B netbios-scope +.I string\fB;\fR +.RS 0.25i .PP The NetBIOS scope option specifies the NetBIOS over TCP/IP scope parameter for the client as specified in RFC 1001/1002. See RFC1001, RFC1002, and RFC1035 for character-set restrictions. +.RE .PP - \fBoption\fR \fBfont-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR +.B option \fBfont-servers\fR \fIip-address\fR [\fB,\fR \fIip-address\fR... +]\fB;\fR +.RS 0.25i .PP This option specifies a list of X Window System Font servers available to the client. Servers should be listed in order of preference. +.RE .PP - \fBoption\fR \fBx-display-manager\fR \fIip-address\fR [\fB,\fR \fIip-address\fR ... ]\fB;\fR +.B option \fBx-display-manager\fR \fIip-address\fR [\fB,\fR \fIip-address\fR... +]\fB;\fR +.RS 0.25i .PP This option specifies a list of systems that are running the X Window System Display Manager and are available to the client. Addresses should be listed in order of preference. +.RE .PP - \fBoption\fR \fBdhcp-client-identifier\fR \fIdata-string\fR\fB;\fR +.B option \fBdhcp-client-identifier\fR \fIdata-string\fR\fB;\fR +.RS 0.25i .PP 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 .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 92fd579b70ab..0a383a04d48c 100644 --- a/contrib/isc-dhcp/common/dispatch.c +++ b/contrib/isc-dhcp/common/dispatch.c @@ -3,7 +3,7 @@ Network input dispatcher... */ /* - * Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. + * Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,13 +42,13 @@ #ifndef lint static char copyright[] = -"$Id: dispatch.c,v 1.47.2.2 1998/06/25 21:11:28 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: dispatch.c,v 1.47.2.9 1999/02/05 20:23:50 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" #include <sys/ioctl.h> -struct interface_info *interfaces, *dummy_interfaces; +struct interface_info *interfaces, *dummy_interfaces, *fallback_interface; struct protocol *protocols; struct timeout *timeouts; static struct timeout *free_timeouts; @@ -57,7 +57,6 @@ void (*bootp_packet_handler) PROTO ((struct interface_info *, struct dhcp_packet *, int, unsigned int, struct iaddr, struct hardware *)); -static void got_one PROTO ((struct protocol *)); int quiet_interface_discovery; /* Use the SIOCGIFCONF ioctl to get a list of all the attached interfaces. @@ -83,9 +82,6 @@ void discover_interfaces (state) #ifdef ALIAS_NAMES_PERMUTED char *s; #endif -#ifdef USE_FALLBACK - static struct shared_network fallback_network; -#endif /* Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. */ if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) @@ -110,9 +106,7 @@ void discover_interfaces (state) else ir = INTERFACE_REQUESTED; - /* Cycle through the list of interfaces looking for IP addresses. - Go through twice; once to count the number of addresses, and a - second time to copy them into an array of addresses. */ + /* Cycle through the list of interfaces looking for IP addresses. */ for (i = 0; i < ic.ifc_len;) { struct ifreq *ifp = (struct ifreq *)((caddr_t)ic.ifc_req + i); #ifdef HAVE_SA_LEN @@ -187,59 +181,6 @@ void discover_interfaces (state) if (ifp -> ifr_addr.sa_family == AF_INET) { struct iaddr addr; -#if defined (SIOCGIFHWADDR) && !defined (AF_LINK) - struct ifreq ifr; - struct sockaddr sa; - int b, sk; - - /* Read the hardware address from this interface. */ - ifr = *ifp; - if (ioctl (sock, SIOCGIFHWADDR, &ifr) < 0) - error ("Can't get hardware address for %s: %m", - ifr.ifr_name); - - sa = *(struct sockaddr *)&ifr.ifr_hwaddr; - - switch (sa.sa_family) { -#ifdef ARPHRD_LOOPBACK - case ARPHRD_LOOPBACK: - /* ignore loopback interface */ - break; -#endif - - case ARPHRD_ETHER: - tmp -> hw_address.hlen = 6; - tmp -> hw_address.htype = ARPHRD_ETHER; - memcpy (tmp -> hw_address.haddr, - sa.sa_data, 6); - break; - -#ifndef ARPHRD_IEEE802 -# define ARPHRD_IEEE802 HTYPE_IEEE802 -#endif - case ARPHRD_IEEE802: - tmp -> hw_address.hlen = 6; - tmp -> hw_address.htype = ARPHRD_IEEE802; - memcpy (tmp -> hw_address.haddr, - sa.sa_data, 6); - break; - -#ifdef ARPHRD_METRICOM - case ARPHRD_METRICOM: - tmp -> hw_address.hlen = 6; - tmp -> hw_address.htype = ARPHRD_METRICOM; - memcpy (tmp -> hw_address.haddr, - sa.sa_data, 6); - - break; -#endif - - default: - error ("%s: unknown hardware address type %d", - ifr.ifr_name, sa.sa_family); - } -#endif /* defined (SIOCGIFHWADDR) && !defined (AF_LINK) */ - /* Get a pointer to the address... */ memcpy (&foo, &ifp -> ifr_addr, sizeof ifp -> ifr_addr); @@ -312,6 +253,157 @@ void discover_interfaces (state) } } +#if defined (LINUX_SLASHPROC_DISCOVERY) + /* On Linux, interfaces that don't have IP addresses don't show up + in the SIOCGIFCONF syscall. We got away with this prior to + Linux 2.1 because we would give each interface an IP address of + 0.0.0.0 before trying to boot, but that doesn't work after 2.1 + because we're using LPF, because we can't configure interfaces + with IP addresses of 0.0.0.0 anymore (grumble). This only + matters for the DHCP client, of course - the relay agent and + server should only care about interfaces that are configured + with IP addresses anyway. + + The PROCDEV_DEVICE (/proc/net/dev) is a kernel-supplied file + that, when read, prints a human readable network status. We + extract the names of the network devices by skipping the first + two lines (which are header) and then parsing off everything + up to the colon in each subsequent line - these lines start + with the interface name, then a colon, then a bunch of + statistics. Yes, Virgina, this is a kludge, but you work + with what you have. */ + + if (state == DISCOVER_UNCONFIGURED) { + FILE *proc_dev; + char buffer [256]; + struct ifreq *tif; + int skip = 2; + + proc_dev = fopen (PROCDEV_DEVICE, "r"); + if (!proc_dev) + error ("%s: %m", PROCDEV_DEVICE); + + while (fgets (buffer, sizeof buffer, proc_dev)) { + char *name = buffer; + char *sep; + + /* Skip the first two blocks, which are header + lines. */ + if (skip) { + --skip; + continue; + } + + sep = strrchr (buffer, ':'); + if (sep) + *sep = '\0'; + while (*name == ' ') + name++; + + /* See if we've seen an interface that matches + this one. */ + for (tmp = interfaces; tmp; tmp = tmp -> next) + if (!strcmp (tmp -> name, name)) + break; + + /* If we found one, and it already has an ifreq + structure, nothing more to do.. */ + if (tmp && tmp -> ifp) + continue; + + /* Make up an ifreq structure. */ + tif = (struct ifreq *)malloc (sizeof (struct ifreq)); + if (!tif) + error ("no space to remember ifp."); + memset (tif, 0, sizeof (struct ifreq)); + strcpy (tif -> ifr_name, name); + + /* Now, if we just needed the ifreq structure, hook + it in and move on. */ + if (tmp) { + tmp -> ifp = tif; + continue; + } + + /* Otherwise, allocate one. */ + tmp = ((struct interface_info *) + dmalloc (sizeof *tmp, "discover_interfaces")); + if (!tmp) + error ("Insufficient memory to %s %s", + "record interface", name); + memset (tmp, 0, sizeof *tmp); + strcpy (tmp -> name, name); + + tmp -> ifp = tif; + tmp -> flags = ir; + tmp -> next = interfaces; + interfaces = tmp; + } + fclose (proc_dev); + } +#endif + + /* Now cycle through all the interfaces we found, looking for + hardware addresses. */ +#if defined (SIOCGIFHWADDR) && !defined (AF_LINK) + for (tmp = interfaces; tmp; tmp = tmp -> next) { + struct ifreq ifr; + struct sockaddr sa; + int b, sk; + + /* Read the hardware address from this interface. */ + ifr = *tmp -> ifp; + if (ioctl (sock, SIOCGIFHWADDR, &ifr) < 0) + continue; + + sa = *(struct sockaddr *)&ifr.ifr_hwaddr; + + switch (sa.sa_family) { +#ifdef ARPHRD_LOOPBACK + case ARPHRD_LOOPBACK: + /* ignore loopback interface */ + break; +#endif + + case ARPHRD_ETHER: + tmp -> hw_address.hlen = 6; + tmp -> hw_address.htype = ARPHRD_ETHER; + memcpy (tmp -> hw_address.haddr, sa.sa_data, 6); + break; + +#ifndef ARPHRD_IEEE802 +# define ARPHRD_IEEE802 HTYPE_IEEE802 +#endif + case ARPHRD_IEEE802: + tmp -> hw_address.hlen = 6; + tmp -> hw_address.htype = ARPHRD_IEEE802; + memcpy (tmp -> hw_address.haddr, sa.sa_data, 6); + break; + +#ifndef ARPHRD_FDDI +# define ARPHRD_FDDI HTYPE_FDDI +#endif + case ARPHRD_FDDI: + tmp -> hw_address.hlen = 16; + tmp -> hw_address.htype = HTYPE_FDDI; /* XXX */ + memcpy (tmp -> hw_address.haddr, sa.sa_data, 16); + break; + +#ifdef ARPHRD_METRICOM + case ARPHRD_METRICOM: + tmp -> hw_address.hlen = 6; + tmp -> hw_address.htype = ARPHRD_METRICOM; + memcpy (tmp -> hw_address.haddr, sa.sa_data, 6); + break; +#endif + + default: + error ("%s: unknown hardware address type %d", + ifr.ifr_name, sa.sa_family); + } + } +#endif /* defined (SIOCGIFHWADDR) && !defined (AF_LINK) */ + /* If we're just trying to get a list of interfaces that we might be able to configure, we can quit now. */ if (state == DISCOVER_UNCONFIGURED) @@ -375,14 +467,26 @@ void discover_interfaces (state) close (sock); -#ifdef USE_FALLBACK - strcpy (fallback_interface.name, "fallback"); - fallback_interface.shared_network = &fallback_network; - fallback_network.name = "fallback-net"; - if_register_fallback (&fallback_interface); - add_protocol ("fallback", fallback_interface.wfdesc, - fallback_discard, &fallback_interface); -#endif + maybe_setup_fallback (); +} + +struct interface_info *setup_fallback () +{ + fallback_interface = + ((struct interface_info *) + dmalloc (sizeof *fallback_interface, "discover_interfaces")); + if (!fallback_interface) + error ("Insufficient memory to record fallback interface."); + memset (fallback_interface, 0, sizeof *fallback_interface); + strcpy (fallback_interface -> name, "fallback"); + fallback_interface -> shared_network = + new_shared_network ("parse_statement"); + if (!fallback_interface -> shared_network) + error ("No memory for shared subnet"); + memset (fallback_interface -> shared_network, 0, + sizeof (struct shared_network)); + fallback_interface -> shared_network -> name = "fallback-net"; + return fallback_interface; } void reinitialize_interfaces () @@ -394,24 +498,17 @@ void reinitialize_interfaces () if_reinitialize_send (ip); } -#ifdef USE_FALLBACK - if_reinitialize_fallback (&fallback_interface); -#endif + if (fallback_interface) + if_reinitialize_send (fallback_interface); interfaces_invalidated = 1; } #ifdef USE_POLL -/* Wait for packets to come in using poll(). Anyway, when a packet - comes in, call receive_packet to receive the packet and possibly - strip hardware addressing information from it, and then call - do_packet to try to do something with it. - - As you can see by comparing this with the code that uses select(), - below, this is gratuitously complex. Quelle surprise, eh? This is - SysV we're talking about, after all, and even in the 90's, it - wouldn't do for SysV to make networking *easy*, would it? Rant, - rant... */ +/* Wait for packets to come in using poll(). When a packet comes in, + call receive_packet to receive the packet and possibly strip hardware + addressing information from it, and then call through the + bootp_packet_handler hook to try to do something with it. */ void dispatch () { @@ -499,8 +596,8 @@ void dispatch () #else /* Wait for packets to come in using select(). When one does, call receive_packet to receive the packet and possibly strip hardware - addressing information from it, and then call do_packet to try to - do something with it. */ + addressing information from it, and then call through the + bootp_packet_handler hook to try to do something with it. */ void dispatch () { @@ -566,7 +663,7 @@ void dispatch () } #endif /* USE_POLL */ -static void got_one (l) +void got_one (l) struct protocol *l; { struct sockaddr_in from; diff --git a/contrib/isc-dhcp/common/lpf.c b/contrib/isc-dhcp/common/lpf.c new file mode 100644 index 000000000000..7c6ff74d628e --- /dev/null +++ b/contrib/isc-dhcp/common/lpf.c @@ -0,0 +1,287 @@ +/* lpf.c + + Linux packet filter code, contributed by Brian Murrel at Interlinx + Support Services in Vancouver, B.C. */ + +/* + * Copyright (c) 1995, 1996, 1998, 1999 + * The Internet Software Consortium. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of The Internet Software Consortium nor the names + * of its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND + * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This software has been written for the Internet Software Consortium + * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie + * Enterprises. To learn more about the Internet Software Consortium, + * see ``http://www.vix.com/isc''. To learn more about Vixie + * Enterprises, see ``http://www.vix.com''. + */ + +#ifndef lint +static char copyright[] = +"$Id: lpf.c,v 1.1.2.4 1999/02/09 04:51:05 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; +#endif /* not lint */ + +#include "dhcpd.h" +#if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE) +#include <sys/ioctl.h> +#include <sys/uio.h> + +#include <asm/types.h> +#include <linux/filter.h> +#include <linux/if_ether.h> +#include <netinet/in_systm.h> +#include "includes/netinet/ip.h" +#include "includes/netinet/udp.h" +#include "includes/netinet/if_ether.h" + +/* Reinitializes the specified interface after an address change. This + is not required for packet-filter APIs. */ + +#ifdef USE_LPF_SEND +void if_reinitialize_send (info) + struct interface_info *info; +{ +} +#endif + +#ifdef USE_LPF_RECEIVE +void if_reinitialize_receive (info) + struct interface_info *info; +{ +} +#endif + +/* Called by get_interface_list for each interface that's discovered. + Opens a packet filter for each interface and adds it to the select + mask. */ + +int if_register_lpf (info) + struct interface_info *info; +{ + int sock; + char filename[50]; + int b; + struct sockaddr sa; + + /* Make an LPF socket. */ + 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", + "in your kernel configuration"); + error("Open a socket for LPF: %m"); + } + + /* Bind to the interface name */ + memset (&sa, 0, sizeof sa); + sa.sa_family = AF_PACKET; + strncpy (sa.sa_data, (const char *)info -> ifp, sizeof sa.sa_data); + 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", + "in your kernel configuration"); + error("Bind socket to interface: %m"); + } + + return sock; +} +#endif /* USE_LPF_SEND || USE_LPF_RECEIVE */ + +#ifdef USE_LPF_SEND +void if_register_send (info) + struct interface_info *info; +{ + /* If we're using the lpf API for sending and receiving, + we don't need to register this interface twice. */ +#ifndef USE_LPF_RECEIVE + info -> wfdesc = if_register_lpf (info, interface); +#else + info -> wfdesc = info -> rfdesc; +#endif + if (!quiet_interface_discovery) + note ("Sending on LPF/%s/%s/%s", + info -> name, + print_hw_addr (info -> hw_address.htype, + info -> hw_address.hlen, + info -> hw_address.haddr), + (info -> shared_network ? + info -> shared_network -> name : "unattached")); +} +#endif /* USE_LPF_SEND */ + +#ifdef USE_LPF_RECEIVE +/* Defined in bpf.c. We can't extern these in dhcpd.h without pulling + in bpf includes... */ +extern struct sock_filter dhcp_bpf_filter []; +extern int dhcp_bpf_filter_len; + +void if_register_receive (info) + struct interface_info *info; +{ + struct sock_fprog p; + + /* Open a LPF device and hang it on this interface... */ + info -> rfdesc = if_register_lpf (info); + + /* Set up the bpf filter program structure. This is defined in + bpf.c */ + p.len = dhcp_bpf_filter_len; + p.filter = dhcp_bpf_filter; + + /* Patch the server port into the LPF program... + XXX changes to filter program may require changes + to the insn number(s) used below! XXX */ + dhcp_bpf_filter [8].k = ntohs (local_port); + + if (setsockopt (info -> rfdesc, SOL_SOCKET, SO_ATTACH_FILTER, &p, + sizeof p) < 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", + "in your kernel configuration"); + error ("Can't install packet filter program: %m"); + } + if (!quiet_interface_discovery) + note ("Listening on LPF/%s/%s/%s", + info -> name, + print_hw_addr (info -> hw_address.htype, + info -> hw_address.hlen, + info -> hw_address.haddr), + (info -> shared_network ? + info -> shared_network -> name : "unattached")); +} +#endif /* USE_LPF_RECEIVE */ + +#ifdef USE_LPF_SEND +ssize_t send_packet (interface, packet, raw, len, from, to, hto) + struct interface_info *interface; + struct packet *packet; + struct dhcp_packet *raw; + size_t len; + struct in_addr from; + struct sockaddr_in *to; + struct hardware *hto; +{ + int bufp = 0; + unsigned char buf [1500]; + struct sockaddr sa; + + if (!strcmp (interface -> name, "fallback")) + return send_fallback (interface, packet, raw, + len, from, to, hto); + + /* Assemble the headers... */ + assemble_hw_header (interface, buf, &bufp, hto); + assemble_udp_ip_header (interface, buf, &bufp, from.s_addr, + to -> sin_addr.s_addr, to -> sin_port, + (unsigned char *)raw, len); + memcpy (buf + bufp, raw, len); + + /* For some reason, SOCK_PACKET sockets can't be connected, + so we have to do a sentdo every time. */ + memset (&sa, 0, sizeof sa); + sa.sa_family = AF_PACKET; + strncpy (sa.sa_data, + (const char *)interface -> ifp, sizeof sa.sa_data); + + return sendto (interface -> wfdesc, buf, bufp + len, 0, + &sa, sizeof sa); +} +#endif /* USE_LPF_SEND */ + +#ifdef USE_LPF_RECEIVE +ssize_t receive_packet (interface, buf, len, from, hfrom) + struct interface_info *interface; + unsigned char *buf; + size_t len; + struct sockaddr_in *from; + struct hardware *hfrom; +{ + int nread; + int length = 0; + int offset = 0; + unsigned char ibuf [1500]; + int bufix = 0; + + length = read (interface -> rfdesc, ibuf, sizeof ibuf); + if (length <= 0) + return length; + + bufix = 0; + /* Decode the physical header... */ + offset = decode_hw_header (interface, ibuf, bufix, hfrom); + + /* If a physical layer checksum failed (dunno of any + physical layer that supports this, but WTH), skip this + packet. */ + if (offset < 0) { + return 0; + } + + bufix += offset; + length -= offset; + + /* Decode the IP and UDP headers... */ + offset = decode_udp_ip_header (interface, ibuf, bufix, + from, (unsigned char *)0, length); + + /* If the IP or UDP checksum was bad, skip the packet... */ + if (offset < 0) + return 0; + + bufix += offset; + length -= offset; + + /* Copy out the data in the packet... */ + memcpy (buf, &ibuf [bufix], length); + return length; +} + +int can_unicast_without_arp () +{ + return 1; +} + +void maybe_setup_fallback () +{ + struct interface_info *fbi; + fbi = setup_fallback (); + if (fbi) { + if_register_fallback (fbi); + add_protocol ("fallback", fallback_interface -> wfdesc, + fallback_discard, fallback_interface); + } +} +#endif diff --git a/contrib/isc-dhcp/common/memory.c b/contrib/isc-dhcp/common/memory.c index 59cbe5dafc01..871fe0772d4a 100644 --- a/contrib/isc-dhcp/common/memory.c +++ b/contrib/isc-dhcp/common/memory.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: memory.c,v 1.35.2.2 1998/06/25 21:11:30 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: memory.c,v 1.35.2.3 1998/11/24 22:32:43 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -357,36 +357,59 @@ struct subnet *find_grouped_subnet (share, addr) return (struct subnet *)0; } +int subnet_inner_than (subnet, scan, warnp) + struct subnet *subnet, *scan; + int warnp; +{ + if (addr_eq (subnet_number (subnet -> net, scan -> netmask), + scan -> net) || + addr_eq (subnet_number (scan -> net, subnet -> netmask), + subnet -> net)) { + char n1buf [16]; + int i, j; + for (i = 0; i < 32; i++) + if (subnet -> netmask.iabuf [3 - (i >> 3)] + & (1 << (i & 7))) + break; + for (j = 0; j < 32; j++) + if (scan -> netmask.iabuf [3 - (j >> 3)] & + (1 << (j & 7))) + break; + strcpy (n1buf, piaddr (subnet -> net)); + if (warnp) + warn ("%ssubnet %s/%d conflicts with subnet %s/%d", + "Warning: ", n1buf, 32 - i, + piaddr (scan -> net), 32 - j); + if (i < j) + return 1; + } + return 0; +} + /* Enter a new subnet into the subnet list. */ void enter_subnet (subnet) struct subnet *subnet; { - struct subnet *scan; + struct subnet *scan, *prev = (struct subnet *)0; /* Check for duplicates... */ for (scan = subnets; scan; scan = scan -> next_subnet) { - if (addr_eq (subnet_number (subnet -> net, scan -> netmask), - scan -> net) || - addr_eq (subnet_number (scan -> net, subnet -> netmask), - subnet -> net)) { - char n1buf [16]; - int i, j; - for (i = 0; i < 32; i++) - if (subnet -> netmask.iabuf [3 - (i >> 3)] - & (1 << (i & 7))) - break; - for (j = 0; j < 32; j++) - if (scan -> netmask.iabuf [3 - (j >> 3)] - & (1 << (j & 7))) - break; - strcpy (n1buf, piaddr (subnet -> net)); - error ("subnet %s/%d conflicts with subnet %s/%d", - n1buf, i, piaddr (scan -> net), j); + /* When we find a conflict, make sure that the + subnet with the narrowest subnet mask comes + first. */ + if (subnet_inner_than (subnet, scan, 1)) { + if (prev) { + prev -> next_subnet = subnet; + } else + subnets = subnet; + subnet -> next_subnet = scan; + return; } + prev = scan; } - /* XXX Sort the nets into a balanced tree to make searching quicker. */ + /* XXX use the BSD radix tree code instead of a linked list. */ subnet -> next_subnet = subnets; subnets = subnet; } @@ -626,8 +649,10 @@ void release_lease (lease) struct lease lt; lt = *lease; - lt.ends = cur_time; - supersede_lease (lease, <, 1); + if (lt.ends > cur_time) { + lt.ends = cur_time; + supersede_lease (lease, <, 1); + } } /* Abandon the specified lease (set its timeout to infinity and its @@ -896,16 +921,21 @@ void dump_subnets () struct shared_network *s; struct subnet *n; + note ("Subnets:"); + for (n = subnets; n; n = n -> next_subnet) { + debug (" Subnet %s", piaddr (n -> net)); + debug (" netmask %s", + piaddr (n -> netmask)); + } + note ("Shared networks:"); for (s = shared_networks; s; s = s -> next) { - for (n = subnets; n; n = n -> next_sibling) { - debug ("Subnet %s", piaddr (n -> net)); - debug (" netmask %s", - piaddr (n -> netmask)); - } + note (" %s", s -> name); for (l = s -> leases; l; l = l -> next) { print_lease (l); } - debug ("Last Lease:"); - print_lease (s -> last_lease); + if (s -> last_lease) { + debug (" Last Lease:"); + print_lease (s -> last_lease); + } } } diff --git a/contrib/isc-dhcp/common/nit.c b/contrib/isc-dhcp/common/nit.c index 0633f1d393b0..1801bb9f3579 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 1997/10/20 21:47:13 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: nit.c,v 1.15.2.1 1998/12/20 18:27:44 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -264,6 +264,10 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) int hw_end; struct sockaddr_in foo; + if (!strcmp (interface -> name, "fallback")) + return send_fallback (interface, packet, raw, + len, from, to, hto); + /* Start with the sockaddr struct... */ junk = (struct sockaddr *)&buf [0]; bufp = ((unsigned char *)&junk -> sa_data [0]) - &buf [0]; @@ -344,4 +348,20 @@ ssize_t receive_packet (interface, buf, len, from, hfrom) memcpy (buf, &ibuf [bufix], length); return length; } + +int can_unicast_without_arp () +{ + return 1; +} + +void maybe_setup_fallback () +{ + struct interface_info *fbi; + fbi = setup_fallback (); + if (fbi) { + if_register_fallback (fbi); + add_protocol ("fallback", fallback_interface -> wfdesc, + fallback_discard, fallback_interface); + } +} #endif diff --git a/contrib/isc-dhcp/common/parse.c b/contrib/isc-dhcp/common/parse.c index 97bfa877b17e..d750ec53434d 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.1 1998/06/25 21:11:31 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$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"; #endif /* not lint */ #include "dhcpd.h" @@ -222,6 +222,9 @@ void parse_hardware_param (cfile, hardware) case TOKEN_RING: hardware -> htype = HTYPE_IEEE802; break; + case FDDI: + hardware -> htype = HTYPE_FDDI; + break; default: parse_warn ("expecting a network hardware type"); skip_to_semi (cfile); @@ -247,6 +250,9 @@ void parse_hardware_param (cfile, hardware) hardware -> hlen = hlen; memcpy ((unsigned char *)&hardware -> haddr [0], t, hardware -> hlen); + if (hlen < sizeof hardware -> haddr) + memset (&hardware -> haddr [hlen], 0, + (sizeof hardware -> haddr) - hlen); free (t); } diff --git a/contrib/isc-dhcp/common/print.c b/contrib/isc-dhcp/common/print.c index ed51b15841b1..4a2b464862d6 100644 --- a/contrib/isc-dhcp/common/print.c +++ b/contrib/isc-dhcp/common/print.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: print.c,v 1.16.2.1 1998/06/25 21:11:31 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: print.c,v 1.16.2.2 1998/11/24 22:39:35 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -76,26 +76,26 @@ void print_lease (lease) struct tm *t; char tbuf [32]; - debug (" Lease %s", + debug (" Lease %s", piaddr (lease -> ip_addr)); t = gmtime (&lease -> starts); strftime (tbuf, sizeof tbuf, "%D %H:%M:%S", t); - debug (" start %s", tbuf); + debug (" start %s", tbuf); t = gmtime (&lease -> ends); strftime (tbuf, sizeof tbuf, "%D %H:%M:%S", t); - debug (" end %s", tbuf); + debug (" end %s", tbuf); t = gmtime (&lease -> timestamp); strftime (tbuf, sizeof tbuf, "%D %H:%M:%S", t); - debug (" stamp %s", tbuf); + debug (" stamp %s", tbuf); - debug (" hardware addr = %s", + debug (" hardware addr = %s", print_hw_addr (lease -> hardware_addr.htype, lease -> hardware_addr.hlen, lease -> hardware_addr.haddr)); - debug (" host %s ", + debug (" host %s ", lease -> host ? lease -> host -> name : "<none>"); } diff --git a/contrib/isc-dhcp/common/socket.c b/contrib/isc-dhcp/common/socket.c index b317ff2ba255..b2ae5b4cae97 100644 --- a/contrib/isc-dhcp/common/socket.c +++ b/contrib/isc-dhcp/common/socket.c @@ -3,8 +3,8 @@ BSD socket interface code... */ /* - * Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. - * All rights reserved. + * Copyright (c) 1995, 1996, 1997, 1998, 1999 + * The Internet Software Consortium. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -50,7 +50,7 @@ #ifndef lint static char copyright[] = -"$Id: socket.c,v 1.26.2.2 1998/06/25 21:11:32 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: socket.c,v 1.26.2.6 1999/02/03 19:46:04 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -102,7 +102,7 @@ int if_register_socket (info) int sock; int flag; -#ifndef SO_BINDTODEVICE +#if !defined (SO_BINDTODEVICE) && !defined (USE_FALLBACK) /* Make sure only one interface is registered. */ if (once) error ("The standard socket API can only support %s", @@ -136,9 +136,10 @@ int if_register_socket (info) if (bind (sock, (struct sockaddr *)&name, sizeof name) < 0) error ("Can't bind to dhcp address: %m"); -#ifdef SO_BINDTODEVICE +#if defined (SO_BINDTODEVICE) /* Bind this socket to this interface. */ - if (setsockopt (sock, SOL_SOCKET, SO_BINDTODEVICE, + if (info -> ifp && + setsockopt (sock, SOL_SOCKET, SO_BINDTODEVICE, (char *)(info -> ifp), sizeof *(info -> ifp)) < 0) { error("setting SO_BINDTODEVICE"); } @@ -236,7 +237,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom) } #endif /* USE_SOCKET_RECEIVE */ -#ifdef USE_SOCKET_FALLBACK +#ifdef USE_SOCKET_SEND /* This just reads in a packet and silently discards it. */ void fallback_discard (protocol) @@ -253,4 +254,27 @@ void fallback_discard (protocol) if (status < 0) warn ("fallback_discard: %m"); } -#endif /* USE_SOCKET_RECEIVE */ +#endif /* USE_SOCKET_SEND */ + +#if defined (USE_SOCKET_SEND) && !defined (USE_SOCKET_FALLBACK) +int can_unicast_without_arp () +{ + return 0; +} + +/* If we have SO_BINDTODEVICE, set up a fallback interface; otherwise, + do not. */ + +void maybe_setup_fallback () +{ +#if defined (SO_BINDTODEVICE) + struct interface_info *fbi; + fbi = setup_fallback (); + if (fbi) { + fbi -> wfdesc = if_register_socket (fbi); + add_protocol ("fallback", + fbi -> wfdesc, fallback_discard, fbi); + } +#endif +} +#endif /* USE_SOCKET_SEND && !USE_SOCKET_FALLBACK */ diff --git a/contrib/isc-dhcp/common/tables.c b/contrib/isc-dhcp/common/tables.c index bdbba1b78d14..abbff6f4cbe7 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.1 1998/06/25 21:11:32 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$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"; #endif /* not lint */ #include "dhcpd.h" @@ -78,7 +78,7 @@ struct option dhcp_options [256] = { { "lpr-servers", "IA", &dhcp_universe, 9 }, { "impress-servers", "IA", &dhcp_universe, 10 }, { "resource-location-servers", "IA", &dhcp_universe, 11 }, - { "host-name", "t", &dhcp_universe, 12 }, + { "host-name", "X", &dhcp_universe, 12 }, { "boot-size", "S", &dhcp_universe, 13 }, { "merit-dump", "t", &dhcp_universe, 14 }, { "domain-name", "t", &dhcp_universe, 15 }, @@ -418,7 +418,7 @@ char *hardware_types [] = { "unknown-5", "token-ring", "unknown-7", - "unknown-8", + "fddi", "unknown-9", "unknown-10", "unknown-11", diff --git a/contrib/isc-dhcp/common/upf.c b/contrib/isc-dhcp/common/upf.c index 498b6e6cde1b..7da9aff62ee8 100644 --- a/contrib/isc-dhcp/common/upf.c +++ b/contrib/isc-dhcp/common/upf.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: upf.c,v 1.3 1997/10/20 21:47:15 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: upf.c,v 1.3.2.1 1998/12/20 18:29:48 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -232,6 +232,10 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) unsigned char buf [256]; struct iovec iov [2]; + if (!strcmp (interface -> name, "fallback")) + return send_fallback (interface, packet, raw, + len, from, to, hto); + /* Assemble the headers... */ assemble_hw_header (interface, buf, &bufp, hto); assemble_udp_ip_header (interface, buf, &bufp, from.s_addr, @@ -295,4 +299,20 @@ ssize_t receive_packet (interface, buf, len, from, hfrom) memcpy (buf, &ibuf [bufix], length); return length; } + +int can_unicast_without_arp () +{ + return 1; +} + +void maybe_setup_fallback () +{ + struct interface_info *fbi; + fbi = setup_fallback (); + if (fbi) { + if_register_fallback (fbi); + add_protocol ("fallback", fallback_interface -> wfdesc, + fallback_discard, fallback_interface); + } +} #endif |