]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Add support for alias declaration
authorTed Lemon <source@isc.org>
Sat, 22 Feb 1997 12:25:32 +0000 (12:25 +0000)
committerTed Lemon <source@isc.org>
Sat, 22 Feb 1997 12:25:32 +0000 (12:25 +0000)
client/clparse.c
client/dhclient.c
clparse.c
common/conflex.c
conflex.c
dhclient.c
dhcpd.h
dhctoken.h
includes/dhcpd.h
includes/dhctoken.h

index 5dc9bd783e422b9af8db1e87a677c8209f5ba628..80ad82a5969e4e66ef3cb9b231832906bfa1fcb5 100644 (file)
@@ -3,7 +3,7 @@
    Parser for dhclient config and lease files... */
 
 /*
- * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium.
+ * Copyright (c) 1997 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: clparse.c,v 1.3 1997/02/22 08:38:32 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: clparse.c,v 1.4 1997/02/22 12:23:22 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -113,7 +113,7 @@ int read_client_conf ()
 
 /* lease-file :== client-lease-statements EOF
    client-lease-statements :== <nil>
-                    | client-lease-statements client-lease-statement */
+                    | client-lease-statements LEASE client-lease-statement */
 
 void read_client_leases ()
 {
@@ -152,7 +152,8 @@ void read_client_leases ()
        SELECT_TIMEOUT number |
        SCRIPT string |
        interface-declaration |
-       client-lease-statement */
+       LEASE client-lease-statement |
+       ALIAS client-lease-statement */
 
 void parse_client_statement (cfile, ip, config)
        FILE *cfile;
@@ -222,6 +223,10 @@ void parse_client_statement (cfile, ip, config)
                parse_client_lease_statement (cfile, 1);
                return;
 
+             case ALIAS:
+               parse_client_lease_statement (cfile, 2);
+               return;
+
              default:
                parse_warn ("expecting a statement.");
                skip_to_semi (cfile);
@@ -434,7 +439,7 @@ void make_client_config (ip, config)
 }
 
 /* client-lease-statement :==
-       LEASE RBRACE client-lease-declarations LBRACE
+       RBRACE client-lease-declarations LBRACE
 
        client-lease-declarations :==
                <nil> |
@@ -489,6 +494,12 @@ void parse_client_lease_statement (cfile, is_static)
        if (!ip -> client)
                make_client_state (ip);
 
+       /* If this is an alias lease, it doesn't need to be sorted in. */
+       if (is_static == 2) {
+               ip -> client -> alias = lease;
+               return;
+       }
+
        /* The last lease in the lease file on a particular interface is
           the active lease for that interface.    Of course, we don't know
           what the last lease in the file is until we've parsed the whole
index 922c4c245d49f31dee987bc1d4b2052d2efe694d..150547b8b18a4fab4894b1fcf8ddabe8852eb843 100644 (file)
@@ -56,7 +56,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: dhclient.c,v 1.25 1997/02/22 08:44:15 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhclient.c,v 1.26 1997/02/22 12:24:28 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -185,6 +185,9 @@ int main (argc, argv, envp)
                /* Call the script with the list of interfaces. */
                for (ip = interfaces; ip; ip = ip -> next) {
                        script_init (ip, "PREINIT", (struct string_list *)0);
+                       if (ip -> client -> alias)
+                               script_write_params (ip, "alias_",
+                                                    ip -> client -> alias);
                        script_go (ip);
                }
        }
@@ -430,6 +433,8 @@ void dhcpack (packet)
        if (ip -> client -> active)
                script_write_params (ip, "old_", ip -> client -> active);
        script_write_params (ip, "new_", ip -> client -> new);
+       if (ip -> client -> alias)
+               script_write_params (ip, "alias_", ip -> client -> alias);
        script_go (ip);
 
        /* Replace the old active lease with the new one. */
@@ -855,6 +860,9 @@ void state_panic (ip)
                                     ip -> client -> active -> medium);
                        script_write_params (ip, "new_",
                                             ip -> client -> active);
+                       if (ip -> client -> alias)
+                               script_write_params (ip, "alias_",
+                                                    ip -> client -> alias);
 
                        /* If the old lease is still good and doesn't
                           yet need renewal, go into BOUND state and
@@ -908,6 +916,8 @@ void state_panic (ip)
           and try again later. */
        note ("No working leases in persistent database - sleeping.\n");
        script_init (ip, "FAIL", (struct string_list *)0);
+       if (ip -> client -> alias)
+               script_write_params (ip, "alias_", ip -> client -> alias);
        script_go (ip);
        ip -> client -> state = S_INIT;
        add_timeout (cur_time + ip -> client -> config -> retry_interval,
@@ -932,6 +942,9 @@ void send_request (ip)
                /* Run the client script with the new parameters. */
                script_init (ip, "EXPIRE", (struct string_list *)0);
                script_write_params (ip, "old_", ip -> client -> active);
+               if (ip -> client -> alias)
+                       script_write_params (ip, "alias_",
+                                            ip -> client -> alias);
                script_go (ip);
 
                ip -> client -> state = S_INIT;
index 5dc9bd783e422b9af8db1e87a677c8209f5ba628..80ad82a5969e4e66ef3cb9b231832906bfa1fcb5 100644 (file)
--- a/clparse.c
+++ b/clparse.c
@@ -3,7 +3,7 @@
    Parser for dhclient config and lease files... */
 
 /*
- * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium.
+ * Copyright (c) 1997 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: clparse.c,v 1.3 1997/02/22 08:38:32 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: clparse.c,v 1.4 1997/02/22 12:23:22 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -113,7 +113,7 @@ int read_client_conf ()
 
 /* lease-file :== client-lease-statements EOF
    client-lease-statements :== <nil>
-                    | client-lease-statements client-lease-statement */
+                    | client-lease-statements LEASE client-lease-statement */
 
 void read_client_leases ()
 {
@@ -152,7 +152,8 @@ void read_client_leases ()
        SELECT_TIMEOUT number |
        SCRIPT string |
        interface-declaration |
-       client-lease-statement */
+       LEASE client-lease-statement |
+       ALIAS client-lease-statement */
 
 void parse_client_statement (cfile, ip, config)
        FILE *cfile;
@@ -222,6 +223,10 @@ void parse_client_statement (cfile, ip, config)
                parse_client_lease_statement (cfile, 1);
                return;
 
+             case ALIAS:
+               parse_client_lease_statement (cfile, 2);
+               return;
+
              default:
                parse_warn ("expecting a statement.");
                skip_to_semi (cfile);
@@ -434,7 +439,7 @@ void make_client_config (ip, config)
 }
 
 /* client-lease-statement :==
-       LEASE RBRACE client-lease-declarations LBRACE
+       RBRACE client-lease-declarations LBRACE
 
        client-lease-declarations :==
                <nil> |
@@ -489,6 +494,12 @@ void parse_client_lease_statement (cfile, is_static)
        if (!ip -> client)
                make_client_state (ip);
 
+       /* If this is an alias lease, it doesn't need to be sorted in. */
+       if (is_static == 2) {
+               ip -> client -> alias = lease;
+               return;
+       }
+
        /* The last lease in the lease file on a particular interface is
           the active lease for that interface.    Of course, we don't know
           what the last lease in the file is until we've parsed the whole
index 490c9678e5e56de1daef50e90e7bd423992941c1..a13f2660568165fad79859c3e3d3ad3cfd5b4938 100644 (file)
@@ -3,7 +3,7 @@
    Lexical scanner for dhcpd config file... */
 
 /*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
+ * Copyright (c) 1995, 1996, 1997 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: conflex.c,v 1.21 1997/02/22 08:29:24 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: conflex.c,v 1.22 1997/02/22 12:23:40 mellon Exp $ Copyright (c) 1995, 1996, 1997 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -355,6 +355,8 @@ static int intern (atom, dfv)
              case 'a':
                if (!strcasecmp (atom + 1, "llow"))
                        return ALLOW;
+               if (!strcasecmp (atom + 1, "lias"))
+                       return ALIAS;
                break;
              case 'b':
                if (!strcasecmp (atom + 1, "ootp"))
index 490c9678e5e56de1daef50e90e7bd423992941c1..a13f2660568165fad79859c3e3d3ad3cfd5b4938 100644 (file)
--- a/conflex.c
+++ b/conflex.c
@@ -3,7 +3,7 @@
    Lexical scanner for dhcpd config file... */
 
 /*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
+ * Copyright (c) 1995, 1996, 1997 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: conflex.c,v 1.21 1997/02/22 08:29:24 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: conflex.c,v 1.22 1997/02/22 12:23:40 mellon Exp $ Copyright (c) 1995, 1996, 1997 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -355,6 +355,8 @@ static int intern (atom, dfv)
              case 'a':
                if (!strcasecmp (atom + 1, "llow"))
                        return ALLOW;
+               if (!strcasecmp (atom + 1, "lias"))
+                       return ALIAS;
                break;
              case 'b':
                if (!strcasecmp (atom + 1, "ootp"))
index 922c4c245d49f31dee987bc1d4b2052d2efe694d..150547b8b18a4fab4894b1fcf8ddabe8852eb843 100644 (file)
@@ -56,7 +56,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: dhclient.c,v 1.25 1997/02/22 08:44:15 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhclient.c,v 1.26 1997/02/22 12:24:28 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -185,6 +185,9 @@ int main (argc, argv, envp)
                /* Call the script with the list of interfaces. */
                for (ip = interfaces; ip; ip = ip -> next) {
                        script_init (ip, "PREINIT", (struct string_list *)0);
+                       if (ip -> client -> alias)
+                               script_write_params (ip, "alias_",
+                                                    ip -> client -> alias);
                        script_go (ip);
                }
        }
@@ -430,6 +433,8 @@ void dhcpack (packet)
        if (ip -> client -> active)
                script_write_params (ip, "old_", ip -> client -> active);
        script_write_params (ip, "new_", ip -> client -> new);
+       if (ip -> client -> alias)
+               script_write_params (ip, "alias_", ip -> client -> alias);
        script_go (ip);
 
        /* Replace the old active lease with the new one. */
@@ -855,6 +860,9 @@ void state_panic (ip)
                                     ip -> client -> active -> medium);
                        script_write_params (ip, "new_",
                                             ip -> client -> active);
+                       if (ip -> client -> alias)
+                               script_write_params (ip, "alias_",
+                                                    ip -> client -> alias);
 
                        /* If the old lease is still good and doesn't
                           yet need renewal, go into BOUND state and
@@ -908,6 +916,8 @@ void state_panic (ip)
           and try again later. */
        note ("No working leases in persistent database - sleeping.\n");
        script_init (ip, "FAIL", (struct string_list *)0);
+       if (ip -> client -> alias)
+               script_write_params (ip, "alias_", ip -> client -> alias);
        script_go (ip);
        ip -> client -> state = S_INIT;
        add_timeout (cur_time + ip -> client -> config -> retry_interval,
@@ -932,6 +942,9 @@ void send_request (ip)
                /* Run the client script with the new parameters. */
                script_init (ip, "EXPIRE", (struct string_list *)0);
                script_write_params (ip, "old_", ip -> client -> active);
+               if (ip -> client -> alias)
+                       script_write_params (ip, "alias_",
+                                            ip -> client -> alias);
                script_go (ip);
 
                ip -> client -> state = S_INIT;
diff --git a/dhcpd.h b/dhcpd.h
index b316fd04367d24addb37926f84abca29ad612a9d..6863b8b6d9e9e6ac6aecd5fc773b7237933784d8 100644 (file)
--- a/dhcpd.h
+++ b/dhcpd.h
@@ -3,7 +3,7 @@
    Definitions for dhcpd... */
 
 /*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
+ * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -130,6 +130,7 @@ struct lease {
 #define DISCOVER_RUNNING       0
 #define DISCOVER_SERVER                1
 #define DISCOVER_UNCONFIGURED  2
+#define DISCOVER_RELAY         3
 
 /* Group of declarations that share common parameters. */
 struct group {
@@ -252,6 +253,7 @@ struct client_state {
        struct client_lease *new;                              /* New lease. */
        struct client_lease *offered_leases;        /* Leases offered to us. */
        struct client_lease *leases;            /* Leases we currently hold. */
+       struct client_lease *alias;                          /* Alias lease. */
 
        enum dhcp_state state;          /* Current state for this interface. */
        struct iaddr destination;                   /* Where to send packet. */
index afc1978820811582c46eb8938f2c79533a90e0fd..b46611987219cb10e5ea88dd0ff4deda400e8fb6 100644 (file)
@@ -3,7 +3,7 @@
    Tokens for config file lexer and parser. */
 
 /*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
+ * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #define DEFAULT                314
 #define MEDIA          315
 #define MEDIUM         316
+#define ALIAS          317
 
 #define is_identifier(x)       ((x) >= FIRST_TOKEN &&  \
                                 (x) != STRING &&       \
index b316fd04367d24addb37926f84abca29ad612a9d..6863b8b6d9e9e6ac6aecd5fc773b7237933784d8 100644 (file)
@@ -3,7 +3,7 @@
    Definitions for dhcpd... */
 
 /*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
+ * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -130,6 +130,7 @@ struct lease {
 #define DISCOVER_RUNNING       0
 #define DISCOVER_SERVER                1
 #define DISCOVER_UNCONFIGURED  2
+#define DISCOVER_RELAY         3
 
 /* Group of declarations that share common parameters. */
 struct group {
@@ -252,6 +253,7 @@ struct client_state {
        struct client_lease *new;                              /* New lease. */
        struct client_lease *offered_leases;        /* Leases offered to us. */
        struct client_lease *leases;            /* Leases we currently hold. */
+       struct client_lease *alias;                          /* Alias lease. */
 
        enum dhcp_state state;          /* Current state for this interface. */
        struct iaddr destination;                   /* Where to send packet. */
index afc1978820811582c46eb8938f2c79533a90e0fd..b46611987219cb10e5ea88dd0ff4deda400e8fb6 100644 (file)
@@ -3,7 +3,7 @@
    Tokens for config file lexer and parser. */
 
 /*
- * Copyright (c) 1995, 1996 The Internet Software Consortium.
+ * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #define DEFAULT                314
 #define MEDIA          315
 #define MEDIUM         316
+#define ALIAS          317
 
 #define is_identifier(x)       ((x) >= FIRST_TOKEN &&  \
                                 (x) != STRING &&       \