]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Use scoping correctly.
authorTed Lemon <source@isc.org>
Wed, 11 Nov 1998 07:48:23 +0000 (07:48 +0000)
committerTed Lemon <source@isc.org>
Wed, 11 Nov 1998 07:48:23 +0000 (07:48 +0000)
client/clparse.c
client/dhclient.c

index e4d4be497b377f973da39d6746a2b2a1cc7de86c..63143549eb8bbca49283fb9b420f1a82419bec86 100644 (file)
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: clparse.c,v 1.20 1998/11/09 02:42:58 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: clparse.c,v 1.21 1998/11/11 07:48:23 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -98,6 +98,14 @@ int read_client_conf ()
        top_level_config.requested_options = default_requested_options;
        top_level_config.requested_lease = 7200;
 
+       top_level_config.on_receipt = new_group ("read_client_conf");
+       if (!top_level_config.on_receipt)
+               error ("no memory for top-level on_receipt group");
+
+       top_level_config.on_transmission = new_group ("read_client_conf");
+       if (!top_level_config.on_transmission)
+               error ("no memory for top-level on_transmission group");
+
        if ((cfile = fopen (path_dhclient_conf, "r")) != NULL) {
                do {
                        token = peek_token (&val, cfile);
@@ -202,7 +210,7 @@ void parse_client_statement (cfile, ip, config)
 
        switch (peek_token (&val, cfile)) {
              case SEND:
-               p = &config -> on_transmission;
+               p = &config -> on_transmission -> statements;
                op = supersede_option_statement;
              do_option:
                token = next_token (&val, cfile);
@@ -217,22 +225,22 @@ void parse_client_statement (cfile, ip, config)
                return;
 
              case DEFAULT:
-               p = &config -> on_receipt;
+               p = &config -> on_receipt -> statements;
                op = default_option_statement;
                goto do_option;
 
              case SUPERSEDE:
-               p = &config -> on_receipt;
+               p = &config -> on_receipt -> statements;
                op = supersede_option_statement;
                goto do_option;
 
              case APPEND:
-               p = &config -> on_receipt;
+               p = &config -> on_receipt -> statements;
                op = append_option_statement;
                goto do_option;
 
              case PREPEND:
-               p = &config -> on_receipt;
+               p = &config -> on_receipt -> statements;
                op = prepend_option_statement;
                goto do_option;
 
@@ -338,11 +346,11 @@ void parse_client_statement (cfile, ip, config)
                                skip_to_semi (cfile);
                        }
                } else {
-                       if (!config -> on_receipt) {
-                               config -> on_receipt = stmt;
+                       if (!config -> on_receipt -> statements) {
+                               config -> on_receipt -> statements = stmt;
                        } else {
                                struct executable_statement *s;
-                               for (s = config -> on_receipt;
+                               for (s = config -> on_receipt -> statements;
                                     s -> next; s = s -> next)
                                        ;
                                s -> next = stmt;
@@ -584,9 +592,11 @@ void make_client_config (client, config)
                                      "make_client_config")));
        if (!client -> config)
                error ("no memory for client config\n");
-       memset (client -> config, 0,
-               sizeof *(client -> config));
        memcpy (client -> config, config, sizeof *config);
+       client -> config -> on_receipt =
+               clone_group (config -> on_receipt, "make_client_config");
+       client -> config -> on_transmission =
+               clone_group (config -> on_transmission, "make_client_config");
 }
 
 /* client-lease-statement :==
@@ -758,7 +768,7 @@ void parse_client_lease_declaration (cfile, lease, ipp, clientp)
                        break;
                }
                for (client = ip -> client; client; client = client -> next)
-                       if (!strcmp (client -> name, val))
+                       if (client -> name && !strcmp (client -> name, val))
                                break;
                if (!client)
                        parse_warn ("lease specified for unknown pseudo.");
index f50505640d58b5ecc5ead95086d0404d1c6fa1c7..5f25afa2d54e7b83ca2f12bb78fb374d3e6436c1 100644 (file)
@@ -56,7 +56,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: dhclient.c,v 1.52 1998/11/09 02:43:23 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: dhclient.c,v 1.53 1998/11/11 07:48:20 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -129,6 +129,18 @@ int main (argc, argv, envp)
                        no_daemon = 1;
                } else if (!strcmp (argv [i], "-D")) {
                        save_scripts = 1;
+                } else if (!strcmp (argv [i], "-pf")) {
+                        if (++i == argc)
+                                usage ();
+                        path_dhclient_pid = argv [i];
+                } else if (!strcmp (argv [i], "-cf")) {
+                        if (++i == argc)
+                                usage ();
+                        path_dhclient_conf = argv [i];
+                } else if (!strcmp (argv [i], "-lf")) {
+                        if (++i == argc)
+                                usage ();
+                        path_dhclient_db = argv [i];
                } else if (argv [i][0] == '-') {
                    usage ();
                } else {
@@ -282,6 +294,13 @@ void classify (packet, class)
 {
 }
 
+int unbill_class (lease, class)
+       struct lease *lease;
+       struct class *class;
+{
+       return 0;
+}
+
 /* Individual States:
  * 
  * Each routine is called from the dhclient_state_machine() in one of
@@ -767,7 +786,7 @@ void dhcpoffer (packet)
        /* If we're not receptive to an offer right now, or if the offer
           has an unrecognizable transaction id, then just drop it. */
        if (!client ||
-           ip -> client -> state != S_SELECTING ||
+           client -> state != S_SELECTING ||
            (packet -> interface -> hw_address.hlen !=
             packet -> raw -> hlen) ||
            (memcmp (packet -> interface -> hw_address.haddr,
@@ -1400,7 +1419,7 @@ void send_release (cpp)
                warn ("send_packet: %m");
 }
 
-void make_client_options (client, lease, type, sid, rip, prl, statements,
+void make_client_options (client, lease, type, sid, rip, prl,
                          options)
        struct client_state *client;
        struct client_lease *lease;
@@ -1408,7 +1427,6 @@ void make_client_options (client, lease, type, sid, rip, prl, statements,
        struct option_cache *sid;
        struct iaddr *rip;
        u_int32_t *prl;
-       struct executable_statement *statements;
        struct option_state *options;
 {
        int i;
@@ -1496,9 +1514,11 @@ void make_client_options (client, lease, type, sid, rip, prl, statements,
                                           going to use oc again */
 
        /* Run statements that need to be run on transmission. */
-       if (statements)
-               execute_statements ((struct packet *)0,
-                                   &lease -> options, options, statements);
+       if (client -> config -> on_transmission)
+               execute_statements_in_scope
+                       ((struct packet *)0, &lease -> options, options,
+                        client -> config -> on_transmission,
+                        (struct group *)0);
 }
 
 void make_discover (client, lease)
@@ -1516,7 +1536,6 @@ void make_discover (client, lease)
                             lease, &discover, (struct option_cache *)0,
                             lease ? &lease -> address : (struct iaddr *)0,
                             client -> config -> requested_options,
-                            client -> config -> on_transmission,
                             &options);
 
        /* Set up the option buffer... */
@@ -1576,7 +1595,6 @@ void make_request (client, lease)
                              ? &lease -> address
                              : (struct iaddr *)0),
                             client -> config -> requested_options,
-                            client -> config -> on_transmission,
                             &options);
 
        /* Set up the option buffer... */
@@ -1637,7 +1655,7 @@ void make_decline (client, lease)
                            DHO_DHCP_SERVER_IDENTIFIER);
        make_client_options (client, lease, &decline, oc,
                             &lease -> address, (u_int32_t *)0,
-                            (struct executable_statement *)0, &options);
+                            &options);
 
        /* Set up the option buffer... */
        client -> packet_length =
@@ -1689,7 +1707,7 @@ void make_release (client, lease)
                            DHO_DHCP_SERVER_IDENTIFIER);
        make_client_options (client, lease, &request, oc,
                             &lease -> address, (u_int32_t *)0,
-                            (struct executable_statement *)0, &options);
+                            &options);
 
        /* Set up the option buffer... */
        client -> packet_length =
@@ -1997,9 +2015,10 @@ void script_write_params (client, prefix, lease)
                fprintf (scriptFile, "export %sserver_name\n", prefix);
        }
 
-       execute_statements ((struct packet *)0, &lease -> options,
-                           &lease -> options,
-                           client -> config -> on_receipt);
+       execute_statements_in_scope ((struct packet *)0, &lease -> options,
+                                    &lease -> options,
+                                    client -> config -> on_receipt,
+                                    (struct group *)0);
 
        for (i = 0; i < OPTION_HASH_SIZE; i++) {
                pair hp;