diff options
-rw-r--r-- | usr.sbin/dhcpd/cdefs.h | 57 | ||||
-rw-r--r-- | usr.sbin/dhcpd/conflex.c | 604 | ||||
-rw-r--r-- | usr.sbin/dhcpd/dhcpd.c | 4 | ||||
-rw-r--r-- | usr.sbin/dhcpd/dhcpd.h | 584 | ||||
-rw-r--r-- | usr.sbin/dhcpd/dispatch.c | 11 | ||||
-rw-r--r-- | usr.sbin/dhcpd/hash.c | 124 | ||||
-rw-r--r-- | usr.sbin/dhcpd/icmp.c | 9 | ||||
-rw-r--r-- | usr.sbin/dhcpd/packet.c | 5 | ||||
-rw-r--r-- | usr.sbin/dhcpd/sysconf.h | 52 | ||||
-rw-r--r-- | usr.sbin/dhcpd/tree.c | 11 |
10 files changed, 590 insertions, 871 deletions
diff --git a/usr.sbin/dhcpd/cdefs.h b/usr.sbin/dhcpd/cdefs.h deleted file mode 100644 index 2bc67a5251a..00000000000 --- a/usr.sbin/dhcpd/cdefs.h +++ /dev/null @@ -1,57 +0,0 @@ -/* cdefs.h - - Standard C definitions... */ - -/* - * Copyright (c) 1996 The Internet Software Consortium. - * All Rights Reserved. - * Copyright (c) 1995 RadioMail Corporation. 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 RadioMail Corporation, 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 RADIOMAIL CORPORATION, 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 RADIOMAIL CORPORATION 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 was written for RadioMail Corporation by Ted Lemon - * under a contract with Vixie Enterprises. Further modifications have - * been made for the Internet Software Consortium under a contract - * with Vixie Laboratories. - */ - -#if (defined (__GNUC__) || defined (__STDC__)) && !defined (BROKEN_ANSI) -#define PROTO(x) x -#define KandR(x) -#define ANSI_DECL(x) x -#if defined (__GNUC__) -#define INLINE inline -#else -#define INLINE -#endif /* __GNUC__ */ -#else -#define PROTO(x) () -#define KandR(x) x -#define ANSI_DECL(x) -#define INLINE -#endif /* __GNUC__ || __STDC__ */ diff --git a/usr.sbin/dhcpd/conflex.c b/usr.sbin/dhcpd/conflex.c index cc7dde96aa3..2ea3289529e 100644 --- a/usr.sbin/dhcpd/conflex.c +++ b/usr.sbin/dhcpd/conflex.c @@ -1,6 +1,6 @@ -/* conflex.c +/* $OpenBSD: conflex.c,v 1.3 2004/04/14 00:56:02 henning Exp $ */ - Lexical scanner for dhcpd config file... */ +/* Lexical scanner for dhcpd config file... */ /* * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium. @@ -40,9 +40,10 @@ * Enterprises, see ``http://www.vix.com''. */ +#include <ctype.h> + #include "dhcpd.h" #include "dhctoken.h" -#include <ctype.h> int lexline; int lexchar; @@ -52,8 +53,8 @@ char *cur_line; char *tlname; int eol_token; -static char line1 [81]; -static char line2 [81]; +static char line1[81]; +static char line2[81]; static int lpos; static int line; static int tlpos; @@ -61,41 +62,35 @@ static int tline; static int token; static int ugflag; static char *tval; -static char tokbuf [1500]; - -#ifdef OLD_LEXER -char comments [4096]; -int comment_index; -#endif +static char tokbuf[1500]; +static int get_char(FILE *); +static int get_token(FILE *); +static void skip_to_eol(FILE *); +static int read_string(FILE *); +static int read_number(int, FILE *); +static int read_num_or_name(int, FILE *); +static int intern(char *, int); -static int get_char PROTO ((FILE *)); -static int get_token PROTO ((FILE *)); -static void skip_to_eol PROTO ((FILE *)); -static int read_string PROTO ((FILE *)); -static int read_number PROTO ((int, FILE *)); -static int read_num_or_name PROTO ((int, FILE *)); -static int intern PROTO ((char *, int)); - -void new_parse (name) - char *name; +void +new_parse(char *name) { tlname = name; lpos = line = 1; cur_line = line1; prev_line = line2; token_line = cur_line; - cur_line [0] = prev_line [0] = 0; + cur_line[0] = prev_line[0] = 0; warnings_occurred = 0; } -static int get_char (cfile) - FILE *cfile; +static int +get_char(FILE *cfile) { - int c = getc (cfile); + int c = getc(cfile); if (!ugflag) { if (c == '\n') { - if (cur_line == line1) { + if (cur_line == line1) { cur_line = line2; prev_line = line1; } else { @@ -104,74 +99,72 @@ static int get_char (cfile) } line++; lpos = 1; - cur_line [0] = 0; + cur_line[0] = 0; } else if (c != EOF) { if (lpos <= 81) { - cur_line [lpos - 1] = c; - cur_line [lpos] = 0; + cur_line[lpos - 1] = c; + cur_line[lpos] = 0; } lpos++; } } else ugflag = 0; - return c; + return (c); } -static int get_token (cfile) - FILE *cfile; +static int +get_token(FILE *cfile) { - int c; - int ttok; - static char tb [2]; - int l, p, u; + int c, ttok; + static char tb[2]; + int l, p, u; do { l = line; p = lpos; u = ugflag; - c = get_char (cfile); + c = get_char(cfile); - if (!(c == '\n' && eol_token) && isascii (c) && isspace (c)) + if (!(c == '\n' && eol_token) && isascii(c) && isspace(c)) continue; if (c == '#') { - skip_to_eol (cfile); + skip_to_eol(cfile); continue; } if (c == '"') { lexline = l; lexchar = p; - ttok = read_string (cfile); + ttok = read_string(cfile); break; } - if ((isascii (c) && isdigit (c)) || c == '-') { + if ((isascii(c) && isdigit(c)) || c == '-') { lexline = l; lexchar = p; - ttok = read_number (c, cfile); + ttok = read_number(c, cfile); break; - } else if (isascii (c) && isalpha (c)) { + } else if (isascii(c) && isalpha(c)) { lexline = l; lexchar = p; - ttok = read_num_or_name (c, cfile); + ttok = read_num_or_name(c, cfile); break; } else { lexline = l; lexchar = p; - tb [0] = c; - tb [1] = 0; + tb[0] = c; + tb[1] = 0; tval = tb; ttok = c; break; } } while (1); - return ttok; + return (ttok); } -int next_token (rval, cfile) - char **rval; - FILE *cfile; +int +next_token(char **rval, FILE *cfile) { - int rv; + int rv; if (token) { if (lexline != tline) @@ -181,46 +174,46 @@ int next_token (rval, cfile) rv = token; token = 0; } else { - rv = get_token (cfile); + rv = get_token(cfile); token_line = cur_line; } if (rval) *rval = tval; -#ifdef DEBUG_TOKENS - fprintf (stderr, "%s:%d ", tval, rv); -#endif - return rv; + + return (rv); } -int peek_token (rval, cfile) - char **rval; - FILE *cfile; +int +peek_token(char **rval, FILE *cfile) { - int x; + int x; if (!token) { tlpos = lexchar; tline = lexline; - token = get_token (cfile); + token = get_token(cfile); if (lexline != tline) token_line = prev_line; - x = lexchar; lexchar = tlpos; tlpos = x; - x = lexline; lexline = tline; tline = x; + x = lexchar; + lexchar = tlpos; + tlpos = x; + x = lexline; + lexline = tline; + tline = x; } if (rval) *rval = tval; -#ifdef DEBUG_TOKENS - fprintf (stderr, "(%s:%d) ", tval, token); -#endif - return token; + + return (token); } -static void skip_to_eol (cfile) - FILE *cfile; +static void +skip_to_eol(FILE *cfile) { - int c; + int c; + do { - c = get_char (cfile); + c = get_char(cfile); if (c == EOF) return; if (c == '\n') @@ -228,309 +221,306 @@ static void skip_to_eol (cfile) } while (1); } -static int read_string (cfile) - FILE *cfile; +static int +read_string(FILE *cfile) { - int i; - int bs = 0; - int c; + int i, c, bs = 0; - for (i = 0; i < sizeof tokbuf; i++) { - c = get_char (cfile); + for (i = 0; i < sizeof(tokbuf); i++) { + c = get_char(cfile); if (c == EOF) { - parse_warn ("eof in string constant"); + parse_warn("eof in string constant"); break; } if (bs) { bs = 0; - tokbuf [i] = c; + tokbuf[i] = c; } else if (c == '\\') bs = 1; else if (c == '"') break; else - tokbuf [i] = c; + tokbuf[i] = c; } - /* Normally, I'd feel guilty about this, but we're talking about - strings that'll fit in a DHCP packet here... */ - if (i == sizeof tokbuf) { - parse_warn ("string constant larger than internal buffer"); - --i; + /* + * Normally, I'd feel guilty about this, but we're talking about + * strings that'll fit in a DHCP packet here... + */ + if (i == sizeof(tokbuf)) { + parse_warn("string constant larger than internal buffer"); + i--; } - tokbuf [i] = 0; + tokbuf[i] = 0; tval = tokbuf; - return STRING; + return (STRING); } -static int read_number (c, cfile) - int c; - FILE *cfile; +static int +read_number(int c, FILE *cfile) { - int seenx = 0; - int i = 0; - int token = NUMBER; + int seenx = 0, i = 0, token = NUMBER; - tokbuf [i++] = c; - for (; i < sizeof tokbuf; i++) { - c = get_char (cfile); - if (!seenx && c == 'x') { + tokbuf[i++] = c; + for (; i < sizeof(tokbuf); i++) { + c = get_char(cfile); + if (!seenx && c == 'x') seenx = 1; - } else if (!isascii (c) || !isxdigit (c)) { - ungetc (c, cfile); + else if (!isascii(c) || !isxdigit(c)) { + ungetc(c, cfile); ugflag = 1; break; } - tokbuf [i] = c; + tokbuf[i] = c; } - if (i == sizeof tokbuf) { - parse_warn ("numeric token larger than internal buffer"); - --i; + if (i == sizeof(tokbuf)) { + parse_warn("numeric token larger than internal buffer"); + i--; } - tokbuf [i] = 0; + tokbuf[i] = 0; tval = tokbuf; - return token; + + return (token); } -static int read_num_or_name (c, cfile) - int c; - FILE *cfile; +static int +read_num_or_name(int c, FILE *cfile) { - int i = 0; - int rv = NUMBER_OR_NAME; - tokbuf [i++] = c; - for (; i < sizeof tokbuf; i++) { - c = get_char (cfile); - if (!isascii (c) || - (c != '-' && c != '_' && !isalnum (c))) { - ungetc (c, cfile); + int i = 0; + int rv = NUMBER_OR_NAME; + + tokbuf[i++] = c; + for (; i < sizeof(tokbuf); i++) { + c = get_char(cfile); + if (!isascii(c) || (c != '-' && c != '_' && !isalnum(c))) { + ungetc(c, cfile); ugflag = 1; break; } - if (!isxdigit (c)) + if (!isxdigit(c)) rv = NAME; - tokbuf [i] = c; + tokbuf[i] = c; } - if (i == sizeof tokbuf) { - parse_warn ("token larger than internal buffer"); - --i; + if (i == sizeof(tokbuf)) { + parse_warn("token larger than internal buffer"); + i--; } - tokbuf [i] = 0; + tokbuf[i] = 0; tval = tokbuf; - return intern (tval, rv); + + return (intern(tval, rv)); } -static int intern (atom, dfv) - char *atom; - int dfv; +static int +intern(char *atom, int dfv) { - if (!isascii (atom [0])) - return dfv; + if (!isascii(atom[0])) + return (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")) - return ALLOW; - if (!strcasecmp (atom + 1, "lias")) - return ALIAS; - if (!strcasecmp (atom + 1, "bandoned")) - return ABANDONED; - if (!strcasecmp (atom + 1, "uthoritative")) - return AUTHORITATIVE; + 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")) + return (ALLOW); + if (!strcasecmp(atom + 1, "lias")) + 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")) - return BACKOFF_CUTOFF; - if (!strcasecmp (atom + 1, "ootp")) - return BOOTP; - if (!strcasecmp (atom + 1, "ooting")) - return BOOTING; - if (!strcasecmp (atom + 1, "oot-unknown-clients")) - return BOOT_UNKNOWN_CLIENTS; - case 'c': - if (!strcasecmp (atom + 1, "lass")) - return CLASS; - if (!strcasecmp (atom + 1, "iaddr")) - return CIADDR; - if (!strcasecmp (atom + 1, "lient-identifier")) - return CLIENT_IDENTIFIER; - if (!strcasecmp (atom + 1, "lient-hostname")) - return CLIENT_HOSTNAME; + case 'b': + if (!strcasecmp(atom + 1, "ackoff-cutoff")) + return (BACKOFF_CUTOFF); + if (!strcasecmp(atom + 1, "ootp")) + return (BOOTP); + if (!strcasecmp(atom + 1, "ooting")) + return (BOOTING); + if (!strcasecmp(atom + 1, "oot-unknown-clients")) + return (BOOT_UNKNOWN_CLIENTS); + case 'c': + if (!strcasecmp(atom + 1, "lass")) + return (CLASS); + if (!strcasecmp(atom + 1, "iaddr")) + return (CIADDR); + if (!strcasecmp(atom + 1, "lient-identifier")) + return (CLIENT_IDENTIFIER); + if (!strcasecmp(atom + 1, "lient-hostname")) + return (CLIENT_HOSTNAME); break; - case 'd': - if (!strcasecmp (atom + 1, "omain")) - return DOMAIN; - if (!strcasecmp (atom + 1, "eny")) - return DENY; - if (!strncasecmp (atom + 1, "efault", 6)) { - if (!atom [7]) - return DEFAULT; - if (!strcasecmp (atom + 7, "-lease-time")) - return DEFAULT_LEASE_TIME; + case 'd': + if (!strcasecmp(atom + 1, "omain")) + return (DOMAIN); + if (!strcasecmp(atom + 1, "eny")) + return (DENY); + if (!strncasecmp(atom + 1, "efault", 6)) { + if (!atom[7]) + return (DEFAULT); + if (!strcasecmp(atom + 7, "-lease-time")) + return (DEFAULT_LEASE_TIME); break; } - if (!strncasecmp (atom + 1, "ynamic-bootp", 12)) { - if (!atom [13]) - return DYNAMIC_BOOTP; - if (!strcasecmp (atom + 13, "-lease-cutoff")) - return DYNAMIC_BOOTP_LEASE_CUTOFF; - if (!strcasecmp (atom + 13, "-lease-length")) - return DYNAMIC_BOOTP_LEASE_LENGTH; + if (!strncasecmp(atom + 1, "ynamic-bootp", 12)) { + if (!atom[13]) + return (DYNAMIC_BOOTP); + if (!strcasecmp(atom + 13, "-lease-cutoff")) + return (DYNAMIC_BOOTP_LEASE_CUTOFF); + if (!strcasecmp(atom + 13, "-lease-length")) + return (DYNAMIC_BOOTP_LEASE_LENGTH); break; } break; - case 'e': - if (!strcasecmp (atom + 1, "thernet")) - return ETHERNET; - if (!strcasecmp (atom + 1, "nds")) - return ENDS; - if (!strcasecmp (atom + 1, "xpire")) - return EXPIRE; + case 'e': + if (!strcasecmp(atom + 1, "thernet")) + return (ETHERNET); + if (!strcasecmp(atom + 1, "nds")) + return (ENDS); + if (!strcasecmp(atom + 1, "xpire")) + return (EXPIRE); break; - case 'f': - if (!strcasecmp (atom + 1, "ilename")) - return FILENAME; - if (!strcasecmp (atom + 1, "ixed-address")) - return FIXED_ADDR; - if (!strcasecmp (atom + 1, "ddi")) - return FDDI; + case 'f': + if (!strcasecmp(atom + 1, "ilename")) + 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")) - return GIADDR; - if (!strcasecmp (atom + 1, "roup")) - return GROUP; - if (!strcasecmp (atom + 1, "et-lease-hostnames")) - return GET_LEASE_HOSTNAMES; + case 'g': + if (!strcasecmp(atom + 1, "iaddr")) + return (GIADDR); + if (!strcasecmp(atom + 1, "roup")) + return (GROUP); + if (!strcasecmp(atom + 1, "et-lease-hostnames")) + return (GET_LEASE_HOSTNAMES); break; - case 'h': - if (!strcasecmp (atom + 1, "ost")) - return HOST; - if (!strcasecmp (atom + 1, "ardware")) - return HARDWARE; - if (!strcasecmp (atom + 1, "ostname")) - return HOSTNAME; + case 'h': + if (!strcasecmp(atom + 1, "ost")) + return (HOST); + if (!strcasecmp(atom + 1, "ardware")) + return (HARDWARE); + if (!strcasecmp(atom + 1, "ostname")) + return (HOSTNAME); break; - case 'i': - if (!strcasecmp (atom + 1, "nitial-interval")) - return INITIAL_INTERVAL; - if (!strcasecmp (atom + 1, "nterface")) - return INTERFACE; + case 'i': + if (!strcasecmp(atom + 1, "nitial-interval")) + return (INITIAL_INTERVAL); + if (!strcasecmp(atom + 1, "nterface")) + return (INTERFACE); break; - case 'l': - if (!strcasecmp (atom + 1, "ease")) - return LEASE; + case 'l': + if (!strcasecmp(atom + 1, "ease")) + return (LEASE); break; - case 'm': - if (!strcasecmp (atom + 1, "ax-lease-time")) - return MAX_LEASE_TIME; - if (!strncasecmp (atom + 1, "edi", 3)) { - if (!strcasecmp (atom + 4, "a")) - return MEDIA; - if (!strcasecmp (atom + 4, "um")) - return MEDIUM; + case 'm': + if (!strcasecmp(atom + 1, "ax-lease-time")) + return (MAX_LEASE_TIME); + if (!strncasecmp(atom + 1, "edi", 3)) { + if (!strcasecmp(atom + 4, "a")) + return (MEDIA); + if (!strcasecmp(atom + 4, "um")) + return (MEDIUM); break; } break; - case 'n': - if (!strcasecmp (atom + 1, "ameserver")) - return NAMESERVER; - if (!strcasecmp (atom + 1, "etmask")) - return NETMASK; - if (!strcasecmp (atom + 1, "ext-server")) - return NEXT_SERVER; - if (!strcasecmp (atom + 1, "ot")) - return TOKEN_NOT; + case 'n': + if (!strcasecmp(atom + 1, "ameserver")) + return (NAMESERVER); + if (!strcasecmp(atom + 1, "etmask")) + 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")) - return OPTION; - if (!strcasecmp (atom + 1, "ne-lease-per-client")) - return ONE_LEASE_PER_CLIENT; + case 'o': + if (!strcasecmp(atom + 1, "ption")) + return (OPTION); + if (!strcasecmp(atom + 1, "ne-lease-per-client")) + return (ONE_LEASE_PER_CLIENT); break; - case 'p': - if (!strcasecmp (atom + 1, "repend")) - return PREPEND; - if (!strcasecmp (atom + 1, "acket")) - return PACKET; + case 'p': + if (!strcasecmp(atom + 1, "repend")) + return (PREPEND); + if (!strcasecmp(atom + 1, "acket")) + return (PACKET); break; - case 'r': - if (!strcasecmp (atom + 1, "ange")) - return RANGE; - if (!strcasecmp (atom + 1, "equest")) - return REQUEST; - if (!strcasecmp (atom + 1, "equire")) - return REQUIRE; - if (!strcasecmp (atom + 1, "etry")) - return RETRY; - if (!strcasecmp (atom + 1, "enew")) - return RENEW; - if (!strcasecmp (atom + 1, "ebind")) - return REBIND; - if (!strcasecmp (atom + 1, "eboot")) - return REBOOT; - if (!strcasecmp (atom + 1, "eject")) - return REJECT; + case 'r': + if (!strcasecmp(atom + 1, "ange")) + return (RANGE); + if (!strcasecmp(atom + 1, "equest")) + return (REQUEST); + if (!strcasecmp(atom + 1, "equire")) + return (REQUIRE); + if (!strcasecmp(atom + 1, "etry")) + return (RETRY); + if (!strcasecmp(atom + 1, "enew")) + return (RENEW); + if (!strcasecmp(atom + 1, "ebind")) + return (REBIND); + if (!strcasecmp(atom + 1, "eboot")) + return (REBOOT); + if (!strcasecmp(atom + 1, "eject")) + return (REJECT); break; - case 's': - if (!strcasecmp (atom + 1, "earch")) - return SEARCH; - if (!strcasecmp (atom + 1, "tarts")) - return STARTS; - if (!strcasecmp (atom + 1, "iaddr")) - return SIADDR; - if (!strcasecmp (atom + 1, "ubnet")) - return SUBNET; - if (!strcasecmp (atom + 1, "hared-network")) - return SHARED_NETWORK; - if (!strcasecmp (atom + 1, "erver-name")) - return SERVER_NAME; - if (!strcasecmp (atom + 1, "erver-identifier")) - return SERVER_IDENTIFIER; - if (!strcasecmp (atom + 1, "elect-timeout")) - return SELECT_TIMEOUT; - if (!strcasecmp (atom + 1, "end")) - return SEND; - if (!strcasecmp (atom + 1, "cript")) - return SCRIPT; - if (!strcasecmp (atom + 1, "upersede")) - return SUPERSEDE; + case 's': + if (!strcasecmp(atom + 1, "earch")) + return (SEARCH); + if (!strcasecmp(atom + 1, "tarts")) + return (STARTS); + if (!strcasecmp(atom + 1, "iaddr")) + return (SIADDR); + if (!strcasecmp(atom + 1, "ubnet")) + return (SUBNET); + if (!strcasecmp(atom + 1, "hared-network")) + return (SHARED_NETWORK); + if (!strcasecmp(atom + 1, "erver-name")) + return (SERVER_NAME); + if (!strcasecmp(atom + 1, "erver-identifier")) + return (SERVER_IDENTIFIER); + if (!strcasecmp(atom + 1, "elect-timeout")) + return (SELECT_TIMEOUT); + if (!strcasecmp(atom + 1, "end")) + return (SEND); + if (!strcasecmp(atom + 1, "cript")) + return (SCRIPT); + if (!strcasecmp(atom + 1, "upersede")) + return (SUPERSEDE); break; - case 't': - if (!strcasecmp (atom + 1, "imestamp")) - return TIMESTAMP; - if (!strcasecmp (atom + 1, "imeout")) - return TIMEOUT; - if (!strcasecmp (atom + 1, "oken-ring")) - return TOKEN_RING; + case 't': + if (!strcasecmp(atom + 1, "imestamp")) + return (TIMESTAMP); + if (!strcasecmp(atom + 1, "imeout")) + return (TIMEOUT); + if (!strcasecmp(atom + 1, "oken-ring")) + 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, + 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; + return (USE_LEASE_ADDR_FOR_DEFAULT_ROUTE); break; } - if (!strcasecmp (atom + 1, "id")) - return UID; - if (!strcasecmp (atom + 1, "nknown-clients")) - return UNKNOWN_CLIENTS; + if (!strcasecmp(atom + 1, "id")) + return (UID); + if (!strcasecmp(atom + 1, "nknown-clients")) + return (UNKNOWN_CLIENTS); break; - case 'v': - if (!strcasecmp (atom + 1, "endor-class")) - return VENDOR_CLASS; + case 'v': + if (!strcasecmp(atom + 1, "endor-class")) + return (VENDOR_CLASS); break; - case 'y': - if (!strcasecmp (atom + 1, "iaddr")) - return YIADDR; + case 'y': + if (!strcasecmp(atom + 1, "iaddr")) + return (YIADDR); break; } - return dfv; + return (dfv); } diff --git a/usr.sbin/dhcpd/dhcpd.c b/usr.sbin/dhcpd/dhcpd.c index c03c12480e5..14f82da5ec7 100644 --- a/usr.sbin/dhcpd/dhcpd.c +++ b/usr.sbin/dhcpd/dhcpd.c @@ -51,7 +51,7 @@ static char url [] = "For info, please visit http://www.isc.org/dhcp-contrib.htm #include "dhcpd.h" #include "version.h" -static void usage PROTO ((char *)); +static void usage(char *); time_t cur_time; struct group root_group; @@ -206,7 +206,7 @@ int main (argc, argv) discover_interfaces (DISCOVER_SERVER); /* Initialize icmp support... */ - icmp_startup (1, lease_pinged); + icmp_startup(1, lease_pinged); #ifndef DEBUG if (daemon) { diff --git a/usr.sbin/dhcpd/dhcpd.h b/usr.sbin/dhcpd/dhcpd.h index 9a5e00b0bb3..98eb48511d3 100644 --- a/usr.sbin/dhcpd/dhcpd.h +++ b/usr.sbin/dhcpd/dhcpd.h @@ -96,12 +96,10 @@ extern int h_errno; #define PTRSIZE_64BIT #endif -#include "cdefs.h" #include "dhcp.h" #include "tree.h" #include "hash.h" #include "inet.h" -#include "sysconf.h" #define LOCAL_PORT 68 @@ -441,14 +439,14 @@ struct hardware_link { struct timeout { struct timeout *next; time_t when; - void (*func) PROTO ((void *)); + void (*func)(void *); void *what; }; struct protocol { struct protocol *next; int fd; - void (*handler) PROTO ((struct protocol *)); + void (*handler)(struct protocol *); void *local; }; @@ -516,240 +514,225 @@ typedef unsigned char option_mask [16]; /* External definitions... */ /* options.c */ - -void parse_options PROTO ((struct packet *)); -void parse_option_buffer PROTO ((struct packet *, unsigned char *, int)); -int cons_options PROTO ((struct packet *, struct dhcp_packet *, int, - struct tree_cache **, int, int, int, - u_int8_t *, int)); -int store_options PROTO ((unsigned char *, int, struct tree_cache **, - unsigned char *, int, int, int, int)); -char *pretty_print_option PROTO ((unsigned int, - unsigned char *, int, int, int)); -void do_packet PROTO ((struct interface_info *, - struct dhcp_packet *, int, - unsigned int, struct iaddr, struct hardware *)); +void parse_options(struct packet *); +void parse_option_buffer(struct packet *, unsigned char *, int); +int cons_options(struct packet *, struct dhcp_packet *, int, + struct tree_cache **, int, int, int, u_int8_t *, int); +int store_options(unsigned char *, int, struct tree_cache **, + unsigned char *, int, int, int, int); +char *pretty_print_option(unsigned int, unsigned char *, int, int, int); +void do_packet(struct interface_info *, struct dhcp_packet *, int, + unsigned int, struct iaddr, struct hardware *); /* errwarn.c */ extern int warnings_occurred; -void error (char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); -int warn (char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); -int note (char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); -int debug (char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); -int parse_warn (char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); +void error(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); +int warn(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); +int note(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); +int debug(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); +int parse_warn(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); /* dhcpd.c */ -extern time_t cur_time; -extern struct group root_group; +extern time_t cur_time; +extern struct group root_group; -extern u_int16_t local_port; -extern u_int16_t remote_port; -extern int log_priority; -extern int log_perror; +extern u_int16_t local_port; +extern u_int16_t remote_port; +extern int log_priority; +extern int log_perror; -extern char *path_dhcpd_conf; -extern char *path_dhcpd_db; -extern char *path_dhcpd_pid; +extern char *path_dhcpd_conf; +extern char *path_dhcpd_db; +extern char *path_dhcpd_pid; -int main PROTO ((int, char **)); -void cleanup PROTO ((void)); -void lease_pinged PROTO ((struct iaddr, u_int8_t *, int)); -void lease_ping_timeout PROTO ((void *)); +int main(int, char *[]); +void cleanup(void); +void lease_pinged(struct iaddr, u_int8_t *, int); +void lease_ping_timeout(void *); /* conflex.c */ -extern int lexline, lexchar; -extern char *token_line, *tlname; -extern char comments [4096]; -extern int comment_index; -extern int eol_token; -void new_parse PROTO ((char *)); -int next_token PROTO ((char **, FILE *)); -int peek_token PROTO ((char **, FILE *)); +extern int lexline, lexchar; +extern char *token_line, *tlname; +extern char comments [4096]; +extern int comment_index; +extern int eol_token; + +void new_parse(char *); +int next_token(char **, FILE *); +int peek_token(char **, FILE *); /* confpars.c */ -int readconf PROTO ((void)); -void read_leases PROTO ((void)); -int parse_statement PROTO ((FILE *, - struct group *, int, struct host_decl *, int)); -void parse_allow_deny PROTO ((FILE *, struct group *, int)); -void skip_to_semi PROTO ((FILE *)); -int parse_boolean PROTO ((FILE *)); -int parse_semi PROTO ((FILE *)); -int parse_lbrace PROTO ((FILE *)); -void parse_host_declaration PROTO ((FILE *, struct group *)); -char *parse_host_name PROTO ((FILE *)); -void parse_class_declaration PROTO ((FILE *, struct group *, int)); -void parse_lease_time PROTO ((FILE *, time_t *)); -void parse_shared_net_declaration PROTO ((FILE *, struct group *)); -void parse_subnet_declaration PROTO ((FILE *, struct shared_network *)); -void parse_group_declaration PROTO ((FILE *, struct group *)); -void parse_hardware_param PROTO ((FILE *, struct hardware *)); -char *parse_string PROTO ((FILE *)); -struct tree *parse_ip_addr_or_hostname PROTO ((FILE *, int)); -struct tree_cache *parse_fixed_addr_param PROTO ((FILE *)); -void parse_option_param PROTO ((FILE *, struct group *)); -time_t parse_timestamp PROTO ((FILE *)); -struct lease *parse_lease_declaration PROTO ((FILE *)); -void parse_address_range PROTO ((FILE *, struct subnet *)); -time_t parse_date PROTO ((FILE *)); -unsigned char *parse_numeric_aggregate PROTO ((FILE *, - unsigned char *, int *, - int, int, int)); -void convert_num PROTO ((unsigned char *, char *, int, int)); +int readconf(void); +void read_leases(void); +int parse_statement(FILE *, struct group *, int, struct host_decl *, int); +void parse_allow_deny(FILE *, struct group *, int); +void skip_to_semi(FILE *); +int parse_boolean(FILE *); +int parse_semi(FILE *); +int parse_lbrace(FILE *); +void parse_host_declaration(FILE *, struct group *); +char *parse_host_name(FILE *); +void parse_class_declaration(FILE *, struct group *, int); +void parse_lease_time(FILE *, time_t *); +void parse_shared_net_declaration(FILE *, struct group *); +void parse_subnet_declaration(FILE *, struct shared_network *); +void parse_group_declaration(FILE *, struct group *); +void parse_hardware_param(FILE *, struct hardware *); +char *parse_string(FILE *); + +struct tree *parse_ip_addr_or_hostname(FILE *, int); +struct tree_cache *parse_fixed_addr_param(FILE *); +void parse_option_param(FILE *, struct group *); +time_t parse_timestamp(FILE *); +struct lease *parse_lease_declaration(FILE *); +void parse_address_range(FILE *, struct subnet *); +time_t parse_date(FILE *); +unsigned char *parse_numeric_aggregate(FILE *, unsigned char *, int *, + int, int, int); +void convert_num(unsigned char *, char *, int, int); /* tree.c */ -pair cons PROTO ((caddr_t, pair)); -struct tree_cache *tree_cache PROTO ((struct tree *)); -struct tree *tree_host_lookup PROTO ((char *)); -struct dns_host_entry *enter_dns_host PROTO ((char *)); -struct tree *tree_const PROTO ((unsigned char *, int)); -struct tree *tree_concat PROTO ((struct tree *, struct tree *)); -struct tree *tree_limit PROTO ((struct tree *, int)); -int tree_evaluate PROTO ((struct tree_cache *)); +pair cons(caddr_t, pair); +struct tree_cache *tree_cache(struct tree *); +struct tree *tree_host_lookup(char *); +struct dns_host_entry *enter_dns_host(char *); +struct tree *tree_const(unsigned char *, int); +struct tree *tree_concat(struct tree *, struct tree *); +struct tree *tree_limit(struct tree *, int); +int tree_evaluate(struct tree_cache *); /* dhcp.c */ -extern int outstanding_pings; - -void dhcp PROTO ((struct packet *)); -void dhcpdiscover PROTO ((struct packet *)); -void dhcprequest PROTO ((struct packet *)); -void dhcprelease PROTO ((struct packet *)); -void dhcpdecline PROTO ((struct packet *)); -void dhcpinform PROTO ((struct packet *)); -void nak_lease PROTO ((struct packet *, struct iaddr *cip)); -void ack_lease PROTO ((struct packet *, struct lease *, unsigned int, time_t)); -void dhcp_reply PROTO ((struct lease *)); -struct lease *find_lease PROTO ((struct packet *, - struct shared_network *, int *)); -struct lease *mockup_lease PROTO ((struct packet *, - struct shared_network *, - struct host_decl *)); +extern int outstanding_pings; + +void dhcp(struct packet *); +void dhcpdiscover(struct packet *); +void dhcprequest(struct packet *); +void dhcprelease(struct packet *); +void dhcpdecline(struct packet *); +void dhcpinform(struct packet *); +void nak_lease(struct packet *, struct iaddr *cip); +void ack_lease(struct packet *, struct lease *, unsigned int, time_t); +void dhcp_reply(struct lease *); +struct lease *find_lease(struct packet *, struct shared_network *, int *); +struct lease *mockup_lease(struct packet *, struct shared_network *, + struct host_decl *); /* bootp.c */ -void bootp PROTO ((struct packet *)); +void bootp(struct packet *); /* memory.c */ -void enter_host PROTO ((struct host_decl *)); -struct host_decl *find_hosts_by_haddr PROTO ((int, unsigned char *, int)); -struct host_decl *find_hosts_by_uid PROTO ((unsigned char *, int)); -struct subnet *find_host_for_network PROTO ((struct host_decl **, - struct iaddr *, - struct shared_network *)); -void new_address_range PROTO ((struct iaddr, struct iaddr, - struct subnet *, int)); -extern struct subnet *find_grouped_subnet PROTO ((struct shared_network *, - struct iaddr)); -extern struct subnet *find_subnet PROTO ((struct iaddr)); -void enter_shared_network PROTO ((struct shared_network *)); -int subnet_inner_than PROTO ((struct subnet *, struct subnet *, int)); -void enter_subnet PROTO ((struct subnet *)); -void enter_lease PROTO ((struct lease *)); -int supersede_lease PROTO ((struct lease *, struct lease *, int)); -void release_lease PROTO ((struct lease *)); -void abandon_lease PROTO ((struct lease *, char *)); -struct lease *find_lease_by_uid PROTO ((unsigned char *, int)); -struct lease *find_lease_by_hw_addr PROTO ((unsigned char *, int)); -struct lease *find_lease_by_ip_addr PROTO ((struct iaddr)); -void uid_hash_add PROTO ((struct lease *)); -void uid_hash_delete PROTO ((struct lease *)); -void hw_hash_add PROTO ((struct lease *)); -void hw_hash_delete PROTO ((struct lease *)); -struct class *add_class PROTO ((int, char *)); -struct class *find_class PROTO ((int, unsigned char *, int)); -struct group *clone_group PROTO ((struct group *, char *)); -void write_leases PROTO ((void)); -void dump_subnets PROTO ((void)); +void enter_host(struct host_decl *); +struct host_decl *find_hosts_by_haddr(int, unsigned char *, int); +struct host_decl *find_hosts_by_uid(unsigned char *, int); +struct subnet *find_host_for_network(struct host_decl **, struct iaddr *, + struct shared_network *); +void new_address_range(struct iaddr, struct iaddr, struct subnet *, int); +extern struct subnet *find_grouped_subnet(struct shared_network *, + struct iaddr); +extern struct subnet *find_subnet(struct iaddr); +void enter_shared_network(struct shared_network *); +int subnet_inner_than(struct subnet *, struct subnet *, int); +void enter_subnet(struct subnet *); +void enter_lease(struct lease *); +int supersede_lease(struct lease *, struct lease *, int); +void release_lease(struct lease *); +void abandon_lease(struct lease *, char *); +struct lease *find_lease_by_uid(unsigned char *, int); +struct lease *find_lease_by_hw_addr(unsigned char *, int); +struct lease *find_lease_by_ip_addr(struct iaddr); +void uid_hash_add(struct lease *); +void uid_hash_delete(struct lease *); +void hw_hash_add(struct lease *); +void hw_hash_delete(struct lease *); +struct class *add_class(int, char *); +struct class *find_class(int, unsigned char *, int); +struct group *clone_group(struct group *, char *); +void write_leases(void); +void dump_subnets(void); /* alloc.c */ -void * dmalloc PROTO ((int, char *)); -void dfree PROTO ((void *, char *)); -struct packet *new_packet PROTO ((char *)); -struct dhcp_packet *new_dhcp_packet PROTO ((char *)); -struct tree *new_tree PROTO ((char *)); -struct tree_cache *new_tree_cache PROTO ((char *)); -struct hash_table *new_hash_table PROTO ((int, char *)); -struct hash_bucket *new_hash_bucket PROTO ((char *)); -struct lease *new_lease PROTO ((char *)); -struct lease *new_leases PROTO ((int, char *)); -struct subnet *new_subnet PROTO ((char *)); -struct class *new_class PROTO ((char *)); -struct shared_network *new_shared_network PROTO ((char *)); -struct group *new_group PROTO ((char *)); -struct protocol *new_protocol PROTO ((char *)); -struct lease_state *new_lease_state PROTO ((char *)); -struct domain_search_list *new_domain_search_list PROTO ((char *)); -struct name_server *new_name_server PROTO ((char *)); -struct string_list *new_string_list PROTO ((size_t size, char * name)); -void free_name_server PROTO ((struct name_server *, char *)); -void free_domain_search_list PROTO ((struct domain_search_list *, char *)); -void free_lease_state PROTO ((struct lease_state *, char *)); -void free_protocol PROTO ((struct protocol *, char *)); -void free_group PROTO ((struct group *, char *)); -void free_shared_network PROTO ((struct shared_network *, char *)); -void free_class PROTO ((struct class *, char *)); -void free_subnet PROTO ((struct subnet *, char *)); -void free_lease PROTO ((struct lease *, char *)); -void free_hash_bucket PROTO ((struct hash_bucket *, char *)); -void free_hash_table PROTO ((struct hash_table *, char *)); -void free_tree_cache PROTO ((struct tree_cache *, char *)); -void free_packet PROTO ((struct packet *, char *)); -void free_dhcp_packet PROTO ((struct dhcp_packet *, char *)); -void free_tree PROTO ((struct tree *, char *)); -void free_string_list PROTO ((struct string_list *, char *)); +void * dmalloc(int, char *); +void dfree(void *, char *); +struct packet *new_packet(char *); +struct dhcp_packet *new_dhcp_packet(char *); +struct tree *new_tree(char *); +struct tree_cache *new_tree_cache(char *); +struct hash_table *new_hash_table(int, char *); +struct hash_bucket *new_hash_bucket(char *); +struct lease *new_lease(char *); +struct lease *new_leases(int, char *); +struct subnet *new_subnet(char *); +struct class *new_class(char *); +struct shared_network *new_shared_network(char *); +struct group *new_group(char *); +struct protocol *new_protocol(char *); +struct lease_state *new_lease_state(char *); +struct domain_search_list *new_domain_search_list(char *); +struct name_server *new_name_server(char *); +struct string_list *new_string_list(size_t size, char * name); +void free_name_server(struct name_server *, char *); +void free_domain_search_list(struct domain_search_list *, char *); +void free_lease_state(struct lease_state *, char *); +void free_protocol(struct protocol *, char *); +void free_group(struct group *, char *); +void free_shared_network(struct shared_network *, char *); +void free_class(struct class *, char *); +void free_subnet(struct subnet *, char *); +void free_lease(struct lease *, char *); +void free_hash_bucket(struct hash_bucket *, char *); +void free_hash_table(struct hash_table *, char *); +void free_tree_cache(struct tree_cache *, char *); +void free_packet(struct packet *, char *); +void free_dhcp_packet(struct dhcp_packet *, char *); +void free_tree(struct tree *, char *); +void free_string_list(struct string_list *, char *); /* print.c */ -char *print_hw_addr PROTO ((int, int, unsigned char *)); -void print_lease PROTO ((struct lease *)); -void dump_raw PROTO ((unsigned char *, int)); -void dump_packet PROTO ((struct packet *)); -void hash_dump PROTO ((struct hash_table *)); +char *print_hw_addr(int, int, unsigned char *); +void print_lease(struct lease *); +void dump_raw(unsigned char *, int); +void dump_packet(struct packet *); +void hash_dump(struct hash_table *); /* bpf.c */ -int if_register_bpf PROTO ( (struct interface_info *)); -void if_reinitialize_send PROTO ((struct interface_info *)); -void if_register_send PROTO ((struct interface_info *)); -ssize_t send_packet PROTO ((struct interface_info *, - struct packet *, struct dhcp_packet *, size_t, - struct in_addr, - struct sockaddr_in *, struct hardware *)); -void if_reinitialize_receive PROTO ((struct interface_info *)); -void if_register_receive PROTO ((struct interface_info *)); -ssize_t receive_packet PROTO ((struct interface_info *, - unsigned char *, size_t, - struct sockaddr_in *, struct hardware *)); -int can_unicast_without_arp PROTO ((void)); -int can_receive_unicast_unconfigured PROTO ((struct interface_info *)); -void maybe_setup_fallback PROTO ((void)); +int if_register_bpf(struct interface_info *); +void if_reinitialize_send(struct interface_info *); +void if_register_send(struct interface_info *); +ssize_t send_packet(struct interface_info *, struct packet *, + struct dhcp_packet *, size_t, struct in_addr, struct sockaddr_in *, + struct hardware *); +void if_reinitialize_receive(struct interface_info *); +void if_register_receive(struct interface_info *); +ssize_t receive_packet(struct interface_info *, unsigned char *, size_t, + struct sockaddr_in *, struct hardware *); +int can_unicast_without_arp(void); +int can_receive_unicast_unconfigured(struct interface_info *); +void maybe_setup_fallback(void); /* dispatch.c */ extern struct interface_info *interfaces, *dummy_interfaces, *fallback_interface; extern struct protocol *protocols; extern int quiet_interface_discovery; -extern void (*bootp_packet_handler) PROTO ((struct interface_info *, - struct dhcp_packet *, int, - unsigned int, - struct iaddr, struct hardware *)); +extern void (*bootp_packet_handler)(struct interface_info *, + struct dhcp_packet *, int, unsigned int, struct iaddr, struct hardware *); extern struct timeout *timeouts; -void discover_interfaces PROTO ((int)); -struct interface_info *setup_fallback PROTO ((void)); -void reinitialize_interfaces PROTO ((void)); -void dispatch PROTO ((void)); -int locate_network PROTO ((struct packet *)); -void got_one PROTO ((struct protocol *)); -void add_timeout PROTO ((time_t, void (*) PROTO ((void *)), void *)); -void cancel_timeout PROTO ((void (*) PROTO ((void *)), void *)); -void add_protocol PROTO ((char *, int, - void (*) PROTO ((struct protocol *)), void *)); - -void remove_protocol PROTO ((struct protocol *)); +void discover_interfaces(int); +struct interface_info *setup_fallback(void); +void reinitialize_interfaces(void); +void dispatch(void); +int locate_network(struct packet *); +void got_one(struct protocol *); +void add_timeout(time_t, void (*)(void *), void *); +void cancel_timeout(void (*)(void *), void *); +void add_protocol (char *, int, void (*)(struct protocol *), void *); +void remove_protocol(struct protocol *); /* hash.c */ -struct hash_table *new_hash PROTO ((void)); -void add_hash PROTO ((struct hash_table *, unsigned char *, - int, unsigned char *)); -void delete_hash_entry PROTO ((struct hash_table *, unsigned char *, int)); -unsigned char *hash_lookup PROTO ((struct hash_table *, unsigned char *, int)); +struct hash_table *new_hash(void); +void add_hash(struct hash_table *, unsigned char *, int, unsigned char *); +void delete_hash_entry(struct hash_table *, unsigned char *, int); +unsigned char *hash_lookup(struct hash_table *, unsigned char *, int); /* tables.c */ extern struct option dhcp_options [256]; @@ -758,176 +741,45 @@ extern int sizeof_dhcp_option_default_priority_list; extern char *hardware_types [256]; extern struct hash_table universe_hash; extern struct universe dhcp_universe; -void initialize_universes PROTO ((void)); +void initialize_universes(void); /* convert.c */ -u_int32_t getULong PROTO ((unsigned char *)); -int32_t getLong PROTO ((unsigned char *)); -u_int16_t getUShort PROTO ((unsigned char *)); -int16_t getShort PROTO ((unsigned char *)); -void putULong PROTO ((unsigned char *, u_int32_t)); -void putLong PROTO ((unsigned char *, int32_t)); -void putUShort PROTO ((unsigned char *, unsigned int)); -void putShort PROTO ((unsigned char *, int)); +u_int32_t getULong(unsigned char *); +int32_t getLong(unsigned char *); +u_int16_t getUShort(unsigned char *); +int16_t getShort(unsigned char *); +void putULong(unsigned char *, u_int32_t); +void putLong(unsigned char *, int32_t); +void putUShort(unsigned char *, unsigned int); +void putShort(unsigned char *, int); /* inet.c */ -struct iaddr subnet_number PROTO ((struct iaddr, struct iaddr)); -struct iaddr ip_addr PROTO ((struct iaddr, struct iaddr, u_int32_t)); -struct iaddr broadcast_addr PROTO ((struct iaddr, struct iaddr)); -u_int32_t host_addr PROTO ((struct iaddr, struct iaddr)); -int addr_eq PROTO ((struct iaddr, struct iaddr)); -char *piaddr PROTO ((struct iaddr)); - -/* dhclient.c */ -extern char *path_dhclient_conf; -extern char *path_dhclient_db; -extern char *path_dhclient_pid; -extern int interfaces_requested; - -extern struct client_config top_level_config; - -void dhcpoffer PROTO ((struct packet *)); -void dhcpack PROTO ((struct packet *)); -void dhcpnak PROTO ((struct packet *)); - -void send_discover PROTO ((void *)); -void send_request PROTO ((void *)); -void send_release PROTO ((void *)); -void send_decline PROTO ((void *)); - -void state_reboot PROTO ((void *)); -void state_init PROTO ((void *)); -void state_selecting PROTO ((void *)); -void state_requesting PROTO ((void *)); -void state_bound PROTO ((void *)); -void state_panic PROTO ((void *)); - -void bind_lease PROTO ((struct interface_info *)); - -void make_discover PROTO ((struct interface_info *, struct client_lease *)); -void make_request PROTO ((struct interface_info *, struct client_lease *)); -void make_decline PROTO ((struct interface_info *, struct client_lease *)); -void make_release PROTO ((struct interface_info *, struct client_lease *)); - -void free_client_lease PROTO ((struct client_lease *)); -void rewrite_client_leases PROTO ((void)); -void write_client_lease PROTO ((struct interface_info *, - struct client_lease *, int)); - -void script_init PROTO ((struct interface_info *, char *, - struct string_list *)); -void script_write_params PROTO ((struct interface_info *, - char *, struct client_lease *)); -int script_go PROTO ((struct interface_info *)); -void client_envadd PROTO ((struct client_state *, - const char *, const char *, const char *, ...)); -void script_set_env (struct client_state *, const char *, const char *, - const char *); -void script_flush_env(struct client_state *); -int dhcp_option_ev_name (char *, size_t, struct option *); - -struct client_lease *packet_to_lease PROTO ((struct packet *)); -void go_daemon PROTO ((void)); -void write_client_pid_file PROTO ((void)); -void status_message PROTO ((struct sysconf_header *, void *)); -void client_location_changed PROTO ((void)); +struct iaddr subnet_number(struct iaddr, struct iaddr); +struct iaddr ip_addr(struct iaddr, struct iaddr, u_int32_t); +struct iaddr broadcast_addr(struct iaddr, struct iaddr); +u_int32_t host_addr(struct iaddr, struct iaddr); +int addr_eq(struct iaddr, struct iaddr); +char *piaddr(struct iaddr); /* db.c */ -int write_lease PROTO ((struct lease *)); -int commit_leases PROTO ((void)); -void db_startup PROTO ((void)); -void new_lease_file PROTO ((void)); +int write_lease(struct lease *); +int commit_leases(void); +void db_startup(void); +void new_lease_file(void); /* packet.c */ -u_int32_t checksum PROTO ((unsigned char *, unsigned, u_int32_t)); -u_int32_t wrapsum PROTO ((u_int32_t)); -void assemble_hw_header PROTO ((struct interface_info *, unsigned char *, - int *, struct hardware *)); -void assemble_udp_ip_header PROTO ((struct interface_info *, unsigned char *, - int *, u_int32_t, u_int32_t, unsigned int, - unsigned char *, int)); -ssize_t decode_hw_header PROTO ((struct interface_info *, unsigned char *, - int, struct hardware *)); -ssize_t decode_udp_ip_header PROTO ((struct interface_info *, unsigned char *, - int, struct sockaddr_in *, - unsigned char *, int)); - -/* ethernet.c */ -void assemble_ethernet_header PROTO ((struct interface_info *, unsigned char *, - int *, struct hardware *)); -ssize_t decode_ethernet_header PROTO ((struct interface_info *, - unsigned char *, - int, struct hardware *)); - -/* tr.c */ -void assemble_tr_header PROTO ((struct interface_info *, unsigned char *, - int *, struct hardware *)); -ssize_t decode_tr_header PROTO ((struct interface_info *, - unsigned char *, - int, struct hardware *)); - -/* route.c */ -void add_route_direct PROTO ((struct interface_info *, struct in_addr)); -void add_route_net PROTO ((struct interface_info *, struct in_addr, - struct in_addr)); -void add_route_default_gateway PROTO ((struct interface_info *, - struct in_addr)); -void remove_routes PROTO ((struct in_addr)); -void remove_if_route PROTO ((struct interface_info *, struct in_addr)); -void remove_all_if_routes PROTO ((struct interface_info *)); -void set_netmask PROTO ((struct interface_info *, struct in_addr)); -void set_broadcast_addr PROTO ((struct interface_info *, struct in_addr)); -void set_ip_address PROTO ((struct interface_info *, struct in_addr)); - -/* clparse.c */ -int read_client_conf PROTO ((void)); -void read_client_leases PROTO ((void)); -void parse_client_statement PROTO ((FILE *, struct interface_info *, - struct client_config *)); -int parse_X PROTO ((FILE *, u_int8_t *, int)); -int parse_option_list PROTO ((FILE *, u_int8_t *)); -void parse_interface_declaration PROTO ((FILE *, struct client_config *)); -struct interface_info *interface_or_dummy PROTO ((char *)); -void make_client_state PROTO ((struct interface_info *)); -void make_client_config PROTO ((struct interface_info *, - struct client_config *)); -void parse_client_lease_statement PROTO ((FILE *, int)); -void parse_client_lease_declaration PROTO ((FILE *, struct client_lease *, - struct interface_info **)); -struct option *parse_option_decl PROTO ((FILE *, struct option_data *)); -void parse_string_list PROTO ((FILE *, struct string_list **, int)); -int parse_ip_addr PROTO ((FILE *, struct iaddr *)); -void parse_reject_statement PROTO ((FILE *, struct client_config *)); - -/* dhcrelay.c */ -void relay PROTO ((struct interface_info *, struct dhcp_packet *, int, - unsigned int, struct iaddr, struct hardware *)); +void assemble_hw_header(struct interface_info *, unsigned char *, + int *, struct hardware *); +void assemble_udp_ip_header(struct interface_info *, unsigned char *, + int *, u_int32_t, u_int32_t, unsigned int, unsigned char *, int); +ssize_t decode_hw_header(struct interface_info *, unsigned char *, + int, struct hardware *); +ssize_t decode_udp_ip_header(struct interface_info *, unsigned char *, + int, struct sockaddr_in *, unsigned char *, int); +u_int32_t checksum(unsigned char *, unsigned, u_int32_t); +u_int32_t wrapsum(u_int32_t); /* icmp.c */ -void icmp_startup PROTO ((int, void (*) PROTO ((struct iaddr, - u_int8_t *, int)))); -int icmp_echorequest PROTO ((struct iaddr *)); -void icmp_echoreply PROTO ((struct protocol *)); - -/* dns.c */ -void dns_startup PROTO ((void)); -int ns_inaddr_lookup PROTO ((u_int16_t, struct iaddr)); -void dns_packet PROTO ((struct protocol *)); - -/* resolv.c */ -extern char path_resolv_conf []; -struct name_server *name_servers; -struct domain_search_list *domains; - -void read_resolv_conf PROTO ((time_t)); -struct sockaddr_in *pick_name_server PROTO ((void)); - -/* inet_addr.c */ -#ifdef NEED_INET_ATON -int inet_aton PROTO ((const char *, struct in_addr *)); -#endif - -/* sysconf.c */ -void sysconf_startup PROTO ((void (*) (struct sysconf_header *, void *))); -void sysconf_restart PROTO ((void *)); -void sysconf_message PROTO ((struct protocol *proto)); +void icmp_startup(int, void (*)(struct iaddr, u_int8_t *, int)); +int icmp_echorequest(struct iaddr *); +void icmp_echoreply(struct protocol *); diff --git a/usr.sbin/dhcpd/dispatch.c b/usr.sbin/dhcpd/dispatch.c index 4d1dd65a6b2..df01e73fb71 100644 --- a/usr.sbin/dhcpd/dispatch.c +++ b/usr.sbin/dhcpd/dispatch.c @@ -55,9 +55,8 @@ struct protocol *protocols; struct timeout *timeouts; static struct timeout *free_timeouts; static int interfaces_invalidated; -void (*bootp_packet_handler) PROTO ((struct interface_info *, - struct dhcp_packet *, int, unsigned int, - struct iaddr, struct hardware *)); +void (*bootp_packet_handler)(struct interface_info *, + struct dhcp_packet *, int, unsigned int, struct iaddr, struct hardware *); static int interface_status(struct interface_info *ifinfo); @@ -542,7 +541,7 @@ int locate_network (packet) void add_timeout (when, where, what) time_t when; - void (*where) PROTO ((void *)); + void (*where)(void *); void *what; { struct timeout *t, *q; @@ -603,7 +602,7 @@ void add_timeout (when, where, what) } void cancel_timeout (where, what) - void (*where) PROTO ((void *)); + void (*where)(void *); void *what; { struct timeout *t, *q; @@ -632,7 +631,7 @@ void cancel_timeout (where, what) void add_protocol (name, fd, handler, local) char *name; int fd; - void (*handler) PROTO ((struct protocol *)); + void (*handler)(struct protocol *); void *local; { struct protocol *p; diff --git a/usr.sbin/dhcpd/hash.c b/usr.sbin/dhcpd/hash.c index b4bba2186c9..5e974120d6a 100644 --- a/usr.sbin/dhcpd/hash.c +++ b/usr.sbin/dhcpd/hash.c @@ -1,6 +1,6 @@ -/* hash.c +/* $OpenBSD: hash.c,v 1.2 2004/04/14 00:56:02 henning Exp $ */ - Routines for manipulating hash tables... */ +/* Routines for manipulating hash tables... */ /* * Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. @@ -42,42 +42,38 @@ #include "dhcpd.h" -static int do_hash PROTO ((unsigned char *, int, int)); +static int do_hash(unsigned char *, int, int); -struct hash_table *new_hash () +struct hash_table * +new_hash(void) { - struct hash_table *rv = new_hash_table (DEFAULT_HASH_SIZE, "new_hash"); + struct hash_table *rv = new_hash_table(DEFAULT_HASH_SIZE, "new_hash"); if (!rv) - return rv; - memset (&rv -> buckets [0], 0, - DEFAULT_HASH_SIZE * sizeof (struct hash_bucket *)); - return rv; + return (rv); + memset(&rv->buckets[0], 0, + DEFAULT_HASH_SIZE * sizeof(struct hash_bucket *)); + return (rv); } -static int do_hash (name, len, size) - unsigned char *name; - int len; - int size; +static int +do_hash(unsigned char *name, int len, int size) { - register int accum = 0; - register unsigned char *s = name; + int accum = 0; + unsigned char *s = name; int i = len; + while (i--) { /* Add the character in... */ accum += *s++; /* Add carry back in... */ - while (accum > 255) { + while (accum > 255) accum = (accum & 255) + (accum >> 8); - } } - return accum % size; + return (accum % size); } -void add_hash (table, name, len, pointer) - struct hash_table *table; - int len; - unsigned char *name; - unsigned char *pointer; +void add_hash(struct hash_table *table, unsigned char *name, int len, + unsigned char *pointer) { int hashno; struct hash_bucket *bp; @@ -85,75 +81,71 @@ void add_hash (table, name, len, pointer) if (!table) return; if (!len) - len = strlen ((char *)name); + len = strlen((char *)name); - hashno = do_hash (name, len, table -> hash_count); - bp = new_hash_bucket ("add_hash"); + hashno = do_hash(name, len, table->hash_count); + bp = new_hash_bucket("add_hash"); if (!bp) { - warn ("Can't add %s to hash table.", name); + warn("Can't add %s to hash table.", name); return; } - bp -> name = name; - bp -> value = pointer; - bp -> next = table -> buckets [hashno]; - bp -> len = len; - table -> buckets [hashno] = bp; + bp->name = name; + bp->value = pointer; + bp->next = table->buckets[hashno]; + bp->len = len; + table->buckets[hashno] = bp; } -void delete_hash_entry (table, name, len) - struct hash_table *table; - int len; - unsigned char *name; +void +delete_hash_entry(struct hash_table *table, unsigned char *name, int len) { int hashno; - struct hash_bucket *bp, *pbp = (struct hash_bucket *)0; + struct hash_bucket *bp, *pbp = NULL; if (!table) return; if (!len) - len = strlen ((char *)name); - - hashno = do_hash (name, len, table -> hash_count); - - /* Go through the list looking for an entry that matches; - if we find it, delete it. */ - for (bp = table -> buckets [hashno]; bp; bp = bp -> next) { - if ((!bp -> len && - !strcmp ((char *)bp -> name, (char *)name)) || - (bp -> len == len && - !memcmp (bp -> name, name, len))) { - if (pbp) { - pbp -> next = bp -> next; - } else { - table -> buckets [hashno] = bp -> next; - } - free_hash_bucket (bp, "delete_hash_entry"); + len = strlen((char *)name); + + hashno = do_hash(name, len, table->hash_count); + + /* + * Go through the list looking for an entry that matches; if we + * find it, delete it. + */ + for (bp = table->buckets[hashno]; bp; bp = bp->next) { + if ((!bp->len && + !strcmp((char *)bp->name, (char *)name)) || + (bp->len == len && !memcmp(bp->name, name, len))) { + if (pbp) + pbp->next = bp->next; + else + table->buckets[hashno] = bp->next; + free_hash_bucket(bp, "delete_hash_entry"); break; } pbp = bp; /* jwg, 9/6/96 - nice catch! */ } } -unsigned char *hash_lookup (table, name, len) - struct hash_table *table; - unsigned char *name; - int len; +unsigned char * +hash_lookup(struct hash_table *table, unsigned char *name, int len) { int hashno; struct hash_bucket *bp; if (!table) - return (unsigned char *)0; + return (NULL); if (!len) - len = strlen ((char *)name); + len = strlen((char *)name); - hashno = do_hash (name, len, table -> hash_count); + hashno = do_hash(name, len, table->hash_count); - 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; + for (bp = table->buckets[hashno]; bp; bp = bp->next) + if (len == bp->len && !memcmp(bp->name, name, len)) + return (bp->value); + + return (NULL); } diff --git a/usr.sbin/dhcpd/icmp.c b/usr.sbin/dhcpd/icmp.c index 8a215e862e1..167d483c687 100644 --- a/usr.sbin/dhcpd/icmp.c +++ b/usr.sbin/dhcpd/icmp.c @@ -53,7 +53,7 @@ static int icmp_protocol_fd; void icmp_startup (routep, handler) int routep; - void (*handler) PROTO ((struct iaddr, u_int8_t *, int)); + void (*handler)(struct iaddr, u_int8_t *, int); { struct protoent *proto; int protocol = 1; @@ -134,7 +134,7 @@ void icmp_echoreply (protocol) int status, len; socklen_t salen; struct iaddr ia; - void (*handler) PROTO ((struct iaddr, u_int8_t *, int)); + void (*handler)(struct iaddr, u_int8_t *, int); salen = sizeof from; status = recvfrom (protocol -> fd, (char *)icbuf, sizeof icbuf, 0, @@ -159,9 +159,8 @@ void icmp_echoreply (protocol) /* If we were given a second-stage handler, call it. */ if (protocol -> local) { - handler = ((void (*) PROTO ((struct iaddr, - u_int8_t *, int))) - protocol -> local); + handler = ((void (*)(struct iaddr, u_int8_t *, int)) + protocol -> local); memcpy (ia.iabuf, &from.sin_addr, sizeof from.sin_addr); ia.len = sizeof from.sin_addr; diff --git a/usr.sbin/dhcpd/packet.c b/usr.sbin/dhcpd/packet.c index 9be6f300872..a87927096e6 100644 --- a/usr.sbin/dhcpd/packet.c +++ b/usr.sbin/dhcpd/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.1 2004/04/13 23:41:49 henning Exp $ */ +/* $OpenBSD: packet.c,v 1.2 2004/04/14 00:56:02 henning Exp $ */ /* Packet assembly code, originally contributed by Archie Cobbs. */ @@ -49,9 +49,6 @@ #define ETHER_HEADER_SIZE (ETHER_ADDR_LEN * 2 + sizeof(u_int16_t)) -u_int32_t checksum(unsigned char *, unsigned, u_int32_t); -u_int32_t wrapsum(u_int32_t); - void assemble_ethernet_header(struct interface_info *, unsigned char *, int *, struct hardware *); ssize_t decode_ethernet_header(struct interface_info *, unsigned char *, diff --git a/usr.sbin/dhcpd/sysconf.h b/usr.sbin/dhcpd/sysconf.h deleted file mode 100644 index 5feb4c75c70..00000000000 --- a/usr.sbin/dhcpd/sysconf.h +++ /dev/null @@ -1,52 +0,0 @@ -/* systat.h - - Definitions for systat protocol... */ - -/* - * Copyright (c) 1997 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''. - */ - -#define SYSCONF_SOCKET "/var/run/sysconf" - -struct sysconf_header { - u_int32_t type; /* Type of status message... */ - u_int32_t length; /* Length of message. */ -}; - -/* Message types... */ -#define NETWORK_LOCATION_CHANGED 1 - diff --git a/usr.sbin/dhcpd/tree.c b/usr.sbin/dhcpd/tree.c index cd69abd366f..76adec88127 100644 --- a/usr.sbin/dhcpd/tree.c +++ b/usr.sbin/dhcpd/tree.c @@ -42,12 +42,11 @@ #include "dhcpd.h" -static time_t tree_evaluate_recurse PROTO ((int *, unsigned char **, int *, - struct tree *)); -static time_t do_host_lookup PROTO ((int *, unsigned char **, int *, - struct dns_host_entry *)); -static void do_data_copy PROTO ((int *, unsigned char **, int *, - unsigned char *, int)); +static time_t tree_evaluate_recurse(int *, unsigned char **, int *, + struct tree *); +static time_t do_host_lookup(int *, unsigned char **, int *, + struct dns_host_entry *); +static void do_data_copy(int *, unsigned char **, int *, unsigned char *, int); pair cons (car, cdr) caddr_t car; |