From: Ted Lemon Date: Fri, 9 May 1997 08:21:25 +0000 (+0000) Subject: Move parse_host_name to parse.c. Add support for recording client-supplied and... X-Git-Tag: DHCP-970602~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ccf5778aac72d9fcf117ac6d37be7c2fc57d4201;p=thirdparty%2Fdhcp.git Move parse_host_name to parse.c. Add support for recording client-supplied and locally-derived hostname in lease file --- diff --git a/server/confpars.c b/server/confpars.c index b8adf9a2d..08ab80dac 100644 --- a/server/confpars.c +++ b/server/confpars.c @@ -42,7 +42,7 @@ #ifndef lint static char copyright[] = -"$Id: confpars.c,v 1.40 1997/03/06 19:29:39 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: confpars.c,v 1.41 1997/05/09 08:21:25 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -539,60 +539,6 @@ void parse_host_declaration (cfile, group) enter_host (host); } -/* hostname :== identifier | hostname DOT identifier */ - -char *parse_host_name (cfile) - FILE *cfile; -{ - char *val; - int token; - int len = 0; - char *s; - char *t; - pair c = (pair)0; - - /* Read a dotted hostname... */ - do { - /* Read a token, which should be an identifier. */ - token = next_token (&val, cfile); - if (!is_identifier (token) && token != NUMBER) { - parse_warn ("expecting an identifier in hostname"); - skip_to_semi (cfile); - return (char *)0; - } - /* Store this identifier... */ - if (!(s = (char *)malloc (strlen (val) + 1))) - error ("can't allocate temp space for hostname."); - strcpy (s, val); - c = cons ((caddr_t)s, c); - len += strlen (s) + 1; - /* Look for a dot; if it's there, keep going, otherwise - we're done. */ - token = peek_token (&val, cfile); - if (token == DOT) - token = next_token (&val, cfile); - } while (token == DOT); - - /* Assemble the hostname together into a string. */ - if (!(s = (char *)malloc (len))) - error ("can't allocate space for hostname."); - t = s + len; - *--t = 0; - while (c) { - pair cdr = c -> cdr; - int l = strlen ((char *)(c -> car)); - t -= l; - memcpy (t, (char *)(c -> car), l); - /* Free up temp space. */ - free (c -> car); - free (c); - c = cdr; - if (t != s) - *--t = '.'; - } - return s; -} - /* class-declaration :== STRING LBRACE parameters declarations RBRACE */ @@ -1145,7 +1091,8 @@ TIME parse_timestamp (cfile) | TIMESTAMP date | HARDWARE hardware-parameter | UID hex_numbers SEMI - | HOST hostname SEMI + | HOSTNAME hostname SEMI + | CLIENT_HOSTNAME hostname SEMI | CLASS identifier SEMI | DYNAMIC_BOOTP SEMI */ @@ -1273,6 +1220,25 @@ struct lease *parse_lease_declaration (cfile) lease.flags |= ABANDONED_LEASE; break; + case HOSTNAME: + seenbit = 512; + lease.hostname = parse_host_name (cfile); + if (!lease.hostname) { + seenbit = 0; + return (struct lease *)0; + } + break; + + case CLIENT_HOSTNAME: + seenbit = 512; + lease.client_hostname = + parse_host_name (cfile); + if (!lease.client_hostname) { + seenbit = 0; + return (struct lease *)0; + } + break; + default: skip_to_semi (cfile); seenbit = 0;