diff options
author | Ted Lemon <source@isc.org> | 2001-06-27 00:31:20 +0000 |
---|---|---|
committer | Ted Lemon <source@isc.org> | 2001-06-27 00:31:20 +0000 |
commit | d758ad8cac9c00c70cfe4dd459bf7e87c268c579 (patch) | |
tree | 85d7e10e40b0e1061a40f45ef0e9f44073346482 /dhcpctl | |
parent | 07b958004f4e39f9b222115b1b050044a2434ea1 (diff) | |
download | isc-dhcp-d758ad8cac9c00c70cfe4dd459bf7e87c268c579.tar.gz |
Merge changes between 3.0rc7 and 3.0rc8pl2.
Diffstat (limited to 'dhcpctl')
-rw-r--r-- | dhcpctl/Makefile.dist | 22 | ||||
-rw-r--r-- | dhcpctl/cltest.c | 2 | ||||
-rw-r--r-- | dhcpctl/dhcpctl.3 | 15 | ||||
-rw-r--r-- | dhcpctl/dhcpctl.c | 47 | ||||
-rw-r--r-- | dhcpctl/dhcpctl.h | 1 | ||||
-rw-r--r-- | dhcpctl/omshell.c | 106 | ||||
-rw-r--r-- | dhcpctl/remote.c | 2 |
7 files changed, 167 insertions, 28 deletions
diff --git a/dhcpctl/Makefile.dist b/dhcpctl/Makefile.dist index 79391f14..8686ecf6 100644 --- a/dhcpctl/Makefile.dist +++ b/dhcpctl/Makefile.dist @@ -17,11 +17,11 @@ # http://www.isc.org for more information. # -CATMANPAGES = dhcpctl.cat3 -SEDMANPAGES = dhcpctl.man3 +CATMANPAGES = dhcpctl.cat3 omshell.cat1 +SEDMANPAGES = dhcpctl.man3 omshell.man1 SRC = dhcpctl.c callback.c remote.c OBJ = dhcpctl.o callback.o remote.o -MAN = dhcpctl.3 +MAN = dhcpctl.3 omshell.1 HDRS = dhcpctl.h INCLUDES = $(BINDINC) -I$(TOP)/includes @@ -42,8 +42,9 @@ libdhcpctl.a: $(OBJ) ar cruv libdhcpctl.a $(OBJ) $(RANLIB) libdhcpctl.a -install: all - for dir in $(LIBDIR) $(LIBMANDIR) $(INCDIR); do \ +install: all $(CATMANPAGES) + for dir in $(LIBDIR) $(LIBMANDIR) $(INCDIR) $(USRMANDIR) \ + $(USERBINDIR); do \ foo=""; \ for bar in `echo $(DESTDIR)$${dir} |tr / ' '`; do \ foo=$${foo}/$$bar; \ @@ -63,6 +64,10 @@ install: all $(MANINSTALL) $(MANFROM) $${prefix}.$(MANCAT)$${suffix} $(MANTO) \ $(DESTDIR)$(LIBMANDIR)/$${prefix}$(LIBMANEXT); \ done + $(INSTALL) omshell $(DESTDIR)$(USERBINDIR) + $(CHMOD) 755 $(DESTDIR)$(USERBINDIR)/omshell + $(MANINSTALL) $(MANFROM) omshell.$(MANCAT)1 $(MANTO) \ + $(DESTDIR)$(USRMANDIR)/omshell$(USRMANEXT) depend: $(MKDEP) $(INCLUDES) $(PREDEFINES) $(SRC) @@ -91,4 +96,11 @@ dhcpctl.man3: dhcpctl.3 sed -e "s#ETCDIR#$(ETC)#g" -e "s#DBDIR#$(VARDB)#g" \ -e "s#RUNDIR#$(VARRUN)#g" < dhcpctl.3 >dhcpctl.man3 +omshell.cat1: omshell.man1 + nroff -man omshell.man1 >omshell.cat1 + +omshell.man1: omshell.1 + sed -e "s#ETCDIR#$(ETC)#g" -e "s#DBDIR#$(VARDB)#g" \ + -e "s#RUNDIR#$(VARRUN)#g" < omshell.1 >omshell.man1 + # Dependencies (semi-automatically-generated) diff --git a/dhcpctl/cltest.c b/dhcpctl/cltest.c index 821ae4be..4589ecd1 100644 --- a/dhcpctl/cltest.c +++ b/dhcpctl/cltest.c @@ -42,7 +42,7 @@ #include <stdlib.h> #include <string.h> #include <stdarg.h> -#include <isc/result.h> +#include <isc-dhcp/result.h> #include "dhcpctl.h" int main (int, char **); diff --git a/dhcpctl/dhcpctl.3 b/dhcpctl/dhcpctl.3 index 3c752812..0111a0c1 100644 --- a/dhcpctl/dhcpctl.3 +++ b/dhcpctl/dhcpctl.3 @@ -2,7 +2,7 @@ .\" .\" Project: DHCP .\" File: dhcpctl.3 -.\" RCSId: $Id: dhcpctl.3,v 1.3 2001/04/16 17:44:11 tamino Exp $ +.\" RCSId: $Id: dhcpctl.3,v 1.4 2001/06/27 00:30:03 mellon Exp $ .\" .\" Copyright (C) 2000 Nominum, Inc. .\" @@ -389,8 +389,8 @@ macro defined in .Fn dhcpctl_data_string_dereference deallocates a data string created by .Fn omapi_data_string_new . -The memory for the object won't be compelely deallocated until the last -reference is released. +The memory for the object won't be freed until the last reference is +released. .Sh EXAMPLES .Pp The following program will connect to the DHCP server running on the local @@ -460,4 +460,11 @@ int main (int argc, char **argv) { } .Ed .Sh SEE ALSO -omapi-intro(1) +.SH SEE ALSO +omapi(3), omshell(3), dhcpd(8), dhclient(8), dhcpd.conf(5), dhclient.conf(5). +.SH AUTHOR +.B dhcpctl +was written by Ted Lemon of Nominum, Inc. Information about Nominum +and support contracts for DHCP and BIND can be found at +.B http://www.nominum.com. This preliminary documentation was +written by James Brister of Nominum, Inc. diff --git a/dhcpctl/dhcpctl.c b/dhcpctl/dhcpctl.c index 9e3fafa3..4560b84d 100644 --- a/dhcpctl/dhcpctl.c +++ b/dhcpctl/dhcpctl.c @@ -267,7 +267,6 @@ dhcpctl_status dhcpctl_set_value (dhcpctl_handle h, dhcpctl_data_string value, omapi_typed_data_t *tv = (omapi_typed_data_t *)0; omapi_data_string_t *name = (omapi_data_string_t *)0; int len; - int ip; status = omapi_data_string_new (&name, strlen (value_name), MDL); if (status != ISC_R_SUCCESS) @@ -302,7 +301,6 @@ dhcpctl_status dhcpctl_set_string_value (dhcpctl_handle h, const char *value, omapi_typed_data_t *tv = (omapi_typed_data_t *)0; omapi_data_string_t *name = (omapi_data_string_t *)0; int len; - int ip; status = omapi_data_string_new (&name, strlen (value_name), MDL); if (status != ISC_R_SUCCESS) @@ -323,10 +321,10 @@ dhcpctl_status dhcpctl_set_string_value (dhcpctl_handle h, const char *value, /* dhcpctl_set_buffer_value - Sets a NUL-terminated ASCII value on an object referred to by - a dhcpctl_handle. like dhcpctl_set_value, but saves the - trouble of creating a data_string for a NUL-terminated string. - Does not update the server - just sets the value on the handle. */ + Sets a value on an object referred to by a dhcpctl_handle. like + dhcpctl_set_value, but saves the trouble of creating a data_string + for string for which we have a buffer and length. Does not update + the server - just sets the value on the handle. */ dhcpctl_status dhcpctl_set_data_value (dhcpctl_handle h, const char *value, unsigned len, @@ -335,7 +333,6 @@ dhcpctl_status dhcpctl_set_data_value (dhcpctl_handle h, isc_result_t status; omapi_typed_data_t *tv = (omapi_typed_data_t *)0; omapi_data_string_t *name = (omapi_data_string_t *)0; - int ip; unsigned ll; ll = strlen (value_name); @@ -358,6 +355,29 @@ dhcpctl_status dhcpctl_set_data_value (dhcpctl_handle h, return status; } +/* dhcpctl_set_null_value + + Sets a null value on an object referred to by a dhcpctl_handle. */ + +dhcpctl_status dhcpctl_set_null_value (dhcpctl_handle h, + const char *value_name) +{ + isc_result_t status; + omapi_data_string_t *name = (omapi_data_string_t *)0; + unsigned ll; + + ll = strlen (value_name); + status = omapi_data_string_new (&name, ll, MDL); + if (status != ISC_R_SUCCESS) + return status; + memcpy (name -> value, value_name, ll); + + status = omapi_set_value (h, (omapi_object_t *)0, name, + (omapi_typed_data_t *)0); + omapi_data_string_dereference (&name, MDL); + return status; +} + /* dhcpctl_set_boolean_value Sets a boolean value on an object - like dhcpctl_set_value, @@ -370,7 +390,6 @@ dhcpctl_status dhcpctl_set_boolean_value (dhcpctl_handle h, int value, omapi_typed_data_t *tv = (omapi_typed_data_t *)0; omapi_data_string_t *name = (omapi_data_string_t *)0; int len; - int ip; status = omapi_data_string_new (&name, strlen (value_name), MDL); if (status != ISC_R_SUCCESS) @@ -401,7 +420,6 @@ dhcpctl_status dhcpctl_set_int_value (dhcpctl_handle h, int value, omapi_typed_data_t *tv = (omapi_typed_data_t *)0; omapi_data_string_t *name = (omapi_data_string_t *)0; int len; - int ip; status = omapi_data_string_new (&name, strlen (value_name), MDL); if (status != ISC_R_SUCCESS) @@ -508,6 +526,17 @@ dhcpctl_status dhcpctl_object_refresh (dhcpctl_handle connection, status = omapi_protocol_send_message (connection -> outer, (omapi_object_t *)0, message, (omapi_object_t *)0); + + /* We don't want to send the contents of the object down the + wire, but we do need to reference it so that we know what + to do with the update. */ + status = omapi_set_object_value (message, (omapi_object_t *)0, + "object", h); + if (status != ISC_R_SUCCESS) { + omapi_object_dereference (&message, MDL); + return status; + } + omapi_object_dereference (&message, MDL); return status; } diff --git a/dhcpctl/dhcpctl.h b/dhcpctl/dhcpctl.h index 8cfe133a..398f0ead 100644 --- a/dhcpctl/dhcpctl.h +++ b/dhcpctl/dhcpctl.h @@ -87,6 +87,7 @@ dhcpctl_status dhcpctl_set_string_value (dhcpctl_handle, const char *, const char *); dhcpctl_status dhcpctl_set_data_value (dhcpctl_handle, const char *, unsigned, const char *); +dhcpctl_status dhcpctl_set_null_value (dhcpctl_handle, const char *); dhcpctl_status dhcpctl_set_boolean_value (dhcpctl_handle, int, const char *); dhcpctl_status dhcpctl_set_int_value (dhcpctl_handle, int, const char *); dhcpctl_status dhcpctl_object_update (dhcpctl_handle, dhcpctl_handle); diff --git a/dhcpctl/omshell.c b/dhcpctl/omshell.c index bbcd2073..cdff29b6 100644 --- a/dhcpctl/omshell.c +++ b/dhcpctl/omshell.c @@ -47,7 +47,7 @@ #include <stdlib.h> #include <stdarg.h> #include <string.h> -#include <isc/result.h> +#include <isc-dhcp/result.h> #include "dhcpctl.h" #include "dhcpd.h" @@ -69,9 +69,7 @@ int check_collection (struct packet *p, struct lease *l, struct collection *c) void classify (struct packet *packet, struct class *class) { } static void usage (char *s) { - fprintf (stderr, - "Usage: %s [-n <username>] [-p <password>] " - "[-a <algorithm>] [-P <port>]\n", s); + fprintf (stderr, "Usage: %s\n", s); exit (1); } @@ -109,10 +107,10 @@ int main (int argc, char **argv, char **envp) /* Initially, log errors to stderr as well as to syslogd. */ #ifdef SYSLOG_4_2 - openlog ("dhcpd", LOG_NDELAY); + openlog ("omshell", LOG_NDELAY); log_priority = DHCPD_LOG_FACILITY; #else - openlog ("dhcpd", LOG_NDELAY, DHCPD_LOG_FACILITY); + openlog ("omshell", LOG_NDELAY, DHCPD_LOG_FACILITY); #endif status = dhcpctl_initialize (); if (status != ISC_R_SUCCESS) { @@ -145,9 +143,16 @@ int main (int argc, char **argv, char **envp) for (i = 0; i < g -> nvalues; i++) { omapi_value_t *v = g -> values [i]; + if (!g -> values [i]) + continue; + printf ("%.*s = ", (int)v -> name -> len, v -> name -> value); + if (!v -> value) { + printf ("<null>\n"); + continue; + } switch (v -> value -> type) { case omapi_datatype_int: printf ("%d\n", @@ -502,7 +507,8 @@ int main (int argc, char **argv, char **envp) s = buf; val = buf; do { - convert_num (cfile, s, val, 16, 8); + convert_num (cfile, (unsigned char *)s, + val, 16, 8); ++s; token = next_token (&val, (unsigned *)0, cfile); @@ -525,6 +531,39 @@ int main (int argc, char **argv, char **envp) goto set_usage; break; + case UNSET: + token = next_token (&val, (unsigned *)0, cfile); + + if ((!is_identifier (token) && token != STRING)) { + unset_usage: + printf ("usage: unset <name>\n"); + skip_to_semi (cfile); + break; + } + + if (!oh) { + printf ("no open object.\n"); + skip_to_semi (cfile); + break; + } + + if (!connected) { + printf ("not connected.\n"); + skip_to_semi (cfile); + break; + } + + s1[0] = '\0'; + strncat (s1, val, sizeof(s1)-1); + + token = next_token (&val, (unsigned *)0, cfile); + if (token != END_OF_FILE && token != EOL) + goto unset_usage; + + dhcpctl_set_null_value (oh, s1); + break; + + case TOKEN_CREATE: case TOKEN_OPEN: i = token; @@ -580,6 +619,12 @@ int main (int argc, char **argv, char **envp) break; } + if (!oh) { + printf ("you haven't opened an object yet!\n"); + skip_to_semi (cfile); + break; + } + status = dhcpctl_object_update(connection, oh); if (status == ISC_R_SUCCESS) status = dhcpctl_wait_for_completion @@ -597,14 +642,18 @@ int main (int argc, char **argv, char **envp) case REMOVE: token = next_token (&val, (unsigned *)0, cfile); if (token != END_OF_FILE && token != EOL) { - printf ("usage: %s\n", val); + printf ("usage: remove\n"); skip_to_semi (cfile); break; } if (!connected) { printf ("not connected.\n"); - skip_to_semi (cfile); + break; + } + + if (!oh) { + printf ("no object.\n"); break; } @@ -619,6 +668,38 @@ int main (int argc, char **argv, char **envp) isc_result_totext (status)); break; } + omapi_object_dereference (&oh, MDL); + break; + + case REFRESH: + token = next_token (&val, (unsigned *)0, cfile); + if (token != END_OF_FILE && token != EOL) { + printf ("usage: refresh\n"); + skip_to_semi (cfile); + break; + } + + if (!connected) { + printf ("not connected.\n"); + break; + } + + if (!oh) { + printf ("no object.\n"); + break; + } + + status = dhcpctl_object_refresh(connection, oh); + if (status == ISC_R_SUCCESS) + status = dhcpctl_wait_for_completion + (oh, &waitstatus); + if (status == ISC_R_SUCCESS) + status = waitstatus; + if (status != ISC_R_SUCCESS) { + printf ("can't refresh object: %s\n", + isc_result_totext (status)); + break; + } break; } @@ -626,3 +707,10 @@ int main (int argc, char **argv, char **envp) exit (0); } + +/* Sigh */ +isc_result_t dhcp_set_control_state (control_object_state_t oldstate, + control_object_state_t newstate) +{ + return ISC_R_SUCCESS; +} diff --git a/dhcpctl/remote.c b/dhcpctl/remote.c index 6750b704..308c8758 100644 --- a/dhcpctl/remote.c +++ b/dhcpctl/remote.c @@ -307,6 +307,8 @@ isc_result_t dhcpctl_remote_signal_handler (omapi_object_t *o, if (!strcmp (name, "updated")) { p -> waitstatus = ISC_R_SUCCESS; + if (o -> inner -> type == omapi_type_generic) + omapi_generic_clear_flags (o -> inner); return omapi_signal_in (o -> inner, "ready"); } if (!strcmp (name, "status")) { |