#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"
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
*/
| 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 */
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;