]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Move parse_host_name to parse.c. Add support for recording client-supplied and...
authorTed Lemon <source@isc.org>
Fri, 9 May 1997 08:21:25 +0000 (08:21 +0000)
committerTed Lemon <source@isc.org>
Fri, 9 May 1997 08:21:25 +0000 (08:21 +0000)
server/confpars.c

index b8adf9a2d1363158e37129b17f3d1c9327b7a9d3..08ab80daceb1e7660cf27f4224e0650c9a0b0f4d 100644 (file)
@@ -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;