summaryrefslogtreecommitdiff
path: root/client/clparse.c
diff options
context:
space:
mode:
authorShawn Routhier <sar@isc.org>2014-05-16 15:24:48 -0700
committerShawn Routhier <sar@isc.org>2014-05-16 15:24:48 -0700
commit79818c93448403843280bcb9b3d33f70461828c7 (patch)
tree215d4b43dade7f0a837c2a783bb84622f854310f /client/clparse.c
parent63c8800c3cb7adafde12d56cfa4c599907dc516c (diff)
downloadisc-dhcp-79818c93448403843280bcb9b3d33f70461828c7.tar.gz
[master] Add -df option to client code to help share DUIDs
Add the "-df <duid file>" option to the client code in order to make it easier to share DUIDs between a v4 instance and a v6 instance. This option instructs the client to search the duid file for a DUID if it didn't find one in the main lease file. In addition add the infrastructure for running ATF tests for the client and write some ATF tests for this patch.
Diffstat (limited to 'client/clparse.c')
-rw-r--r--client/clparse.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/client/clparse.c b/client/clparse.c
index 646229f1..320c42f5 100644
--- a/client/clparse.c
+++ b/client/clparse.c
@@ -246,6 +246,45 @@ int read_client_conf_file (const char *name, struct interface_info *ip,
/* lease-file :== client-lease-statements END_OF_FILE
client-lease-statements :== <nil>
+ | client-lease-statements LEASE client-lease-statement
+ * This routine looks through a lease file and only tries to parse
+ * the duid statements.
+ */
+
+void read_client_duid ()
+{
+ int file;
+ isc_result_t status;
+ struct parse *cfile;
+ const char *val;
+ int token;
+
+ /* Open the lease file. If we can't open it, just return -
+ we can safely trust the server to remember our state. */
+ if ((file = open (path_dhclient_duid, O_RDONLY)) < 0)
+ return;
+
+ cfile = NULL;
+ status = new_parse(&cfile, file, NULL, 0, path_dhclient_duid, 0);
+ if (status != ISC_R_SUCCESS || cfile == NULL)
+ return;
+
+ while ((token = next_token(&val, NULL, cfile)) != END_OF_FILE) {
+ /*
+ * All we care about is DUIDs - if we get anything else
+ * just toss it and continue looking for DUIDs until we
+ * run out of file.
+ */
+ if (token == DEFAULT_DUID) {
+ parse_client_default_duid(cfile);
+ }
+ }
+
+ end_parse(&cfile);
+}
+
+/* lease-file :== client-lease-statements END_OF_FILE
+ client-lease-statements :== <nil>
| client-lease-statements LEASE client-lease-statement */
void read_client_leases ()