diff options
Diffstat (limited to 'dhcpctl')
-rw-r--r-- | dhcpctl/callback.c | 5 | ||||
-rw-r--r-- | dhcpctl/cltest.c | 2 | ||||
-rw-r--r-- | dhcpctl/dhcpctl.3 | 51 | ||||
-rw-r--r-- | dhcpctl/dhcpctl.c | 6 | ||||
-rw-r--r-- | dhcpctl/dhcpctl.h | 4 | ||||
-rw-r--r-- | dhcpctl/omshell.1 | 1 | ||||
-rw-r--r-- | dhcpctl/omshell.c | 70 | ||||
-rw-r--r-- | dhcpctl/remote.c | 5 |
8 files changed, 70 insertions, 74 deletions
diff --git a/dhcpctl/callback.c b/dhcpctl/callback.c index 46428fee..5ab28c37 100644 --- a/dhcpctl/callback.c +++ b/dhcpctl/callback.c @@ -66,7 +66,7 @@ dhcpctl_status dhcpctl_set_callback (dhcpctl_handle h, void *data, omapi_object_reference (&callback -> object, h, MDL); callback -> data = data; callback -> callback = func; - + return ISC_R_SUCCESS; } @@ -93,7 +93,7 @@ isc_result_t dhcpctl_callback_get_value (omapi_object_t *h, { if (h -> type != dhcpctl_callback_type) return DHCP_R_INVALIDARG; - + if (h -> inner && h -> inner -> type -> get_value) return (*(h -> inner -> type -> get_value)) (h -> inner, id, name, value); @@ -159,4 +159,3 @@ isc_result_t dhcpctl_callback_stuff_values (omapi_object_t *c, p -> inner); return ISC_R_SUCCESS; } - diff --git a/dhcpctl/cltest.c b/dhcpctl/cltest.c index 0e180dde..ea03d3b3 100644 --- a/dhcpctl/cltest.c +++ b/dhcpctl/cltest.c @@ -99,7 +99,7 @@ int main (argc, argv) int mode = undefined; const char *interface = 0; const char *action; - + for (i = 1; i < argc; i++) { if (!strcmp (argv[i], "-u")) { mode = up; diff --git a/dhcpctl/dhcpctl.3 b/dhcpctl/dhcpctl.3 index 98d8294a..dcc08992 100644 --- a/dhcpctl/dhcpctl.3 +++ b/dhcpctl/dhcpctl.3 @@ -3,7 +3,7 @@ .\" Project: DHCP .\" File: dhcpctl.3 .\" RCSId: $Id: dhcpctl.3,v 1.9 2011/04/25 23:43:16 sar Exp $ -.\" +.\" .\" Copyright (c) 2011,2014 by Internet Systems Consortium, Inc. ("ISC") .\" Copyright (c) 2004,2009 by Internet Systems Consortium, Inc. ("ISC") .\" Copyright (c) 2000-2003 by Internet Software Consortium @@ -26,9 +26,9 @@ .\" Newmarket, NH 03857 USA .\" <info@isc.org> .\" https://www.isc.org/ -.\" +.\" .\" Description: dhcpctl man page. -.\" +.\" .\" .Dd Nov 15, 2000 .Dt DHCPCTL 3 @@ -207,8 +207,8 @@ with and manipulate a running ISC DHCP server. All functions return a value of The return values reflects the result of operations to local data structures. If an operation fails on the server for any reason, then the error result will be returned through the -second parameter of the -.Fn dhcpctl_wait_for_completion +second parameter of the +.Fn dhcpctl_wait_for_completion call. .\" .\" @@ -241,13 +241,13 @@ of the request as processed on the server is returned via the second parameter. .Bd -literal -offset indent s = dhcpctl_wait_for_completion(cxn, &wv); -if (s != ISC_R_SUCCESS) +if (s != ISC_R_SUCCESS) local_failure(s); else if (wv != ISC_R_SUCCESS) server_failure(wc); .Ed .Pp -The call to +The call to .Fn dhcpctl_wait_for_completion won't return until the remote message processing completes or the connection to the server is lost. @@ -290,7 +290,7 @@ The .Fn dhcpctl_set_boolean_value , and .Fn dhcpctl_set_int_value -functions all set a value on the object handle. +functions all set a value on the object handle. .\" .\" .\" @@ -319,7 +319,7 @@ handle. .\" .\" .Pp -The +The .Fn dhcpctl_set_callback function sets up a user-defined function to be called when an event completes on the given object handle. This is needed for asynchronous handling of @@ -327,23 +327,23 @@ events, versus the synchronous handling given by .Fn dhcpctl_wait_for_completion . When the function is called the first parameter is the object the event arrived for, the second is the status of the message that was processed, the -third is the same value as the second parameter given to +third is the same value as the second parameter given to .Fn dhcpctl_set_callback . .\" .\" .\" .Pp -The +The .Fn dhcpctl_new_authenticator creates a new authenticator object to be used for signing the messages -that cross over the network. The +that cross over the network. The .Dq name , .Dq algorithm , -and +and .Dq secret values must all match what the server uses and are defined in its configuration file. The created object is returned through the first parameter -and must be used as the 4th parameter to +and must be used as the 4th parameter to .Fn dhcpctl_connect . Note that the 'secret' value must not be base64 encoded, which is different from how the value appears in the dhcpd.conf file. @@ -352,11 +352,11 @@ from how the value appears in the dhcpd.conf file. .\" .Pp .Fn dhcpctl_new_object -creates a local handle for an object on the server. The +creates a local handle for an object on the server. The .Dq object_type -parameter is the ascii name of the type of object being accessed. e.g. +parameter is the ascii name of the type of object being accessed. e.g. .Qq lease . -This function only sets up local data structures, it does not queue any +This function only sets up local data structures, it does not queue any messages to be sent to the remote side, .Fn dhcpctl_open_object @@ -385,22 +385,22 @@ was also specified .\" .\" .Pp -The +The .Fn omapi_data_string_new function allocates a new .Ft dhcpctl_data_string -object. The data string will be large enough to hold +object. The data string will be large enough to hold .Dq length bytes of data. The -.Dq file +.Dq file and .Dq lineno arguments are the source file location the call is made from, typically by -using the +using the .Dv __FILE__ and .Dv __LINE__ -macros or the +macros or the .Dv MDL macro defined in . @@ -414,11 +414,11 @@ deallocates a data string created by The memory for the object won't be freed until the last reference is released. .Sh EXAMPLES -.Pp +.Pp The following program will connect to the DHCP server running on the local host and will get the details of the existing lease for IP address 10.0.0.101. It will then print out the time the lease is due to expire. Note -that most error checking has been omitted for brevity. +that most error checking has been omitted for brevity. .Bd -literal -offset indent #include <sys/time.h> #include <stdio.h> @@ -446,7 +446,7 @@ int main (int argc, char **argv) { dhcpctl_connect (&connection, "127.0.0.1", 7911, 0); - + dhcpctl_new_object (&lease, connection, "lease"); @@ -492,4 +492,3 @@ omapi(3), omshell(1), dhcpd(8), dhclient(8), dhcpd.conf(5), dhclient.conf(5). is maintained by ISC. To learn more about Internet Systems Consortium, see .B https://www.isc.org - diff --git a/dhcpctl/dhcpctl.c b/dhcpctl/dhcpctl.c index 0f800216..3c78bc19 100644 --- a/dhcpctl/dhcpctl.c +++ b/dhcpctl/dhcpctl.c @@ -86,7 +86,7 @@ dhcpctl_status dhcpctl_initialize () synchronous returns nonzero status code if it didn't connect, zero otherwise stores connection handle through connection, which can be used - for subsequent access to the specified server. + for subsequent access to the specified server. server_name is the name of the server, and port is the TCP port on which it is listening. authinfo is the handle to an object containing authentication @@ -150,7 +150,7 @@ dhcpctl_status dhcpctl_wait_for_completion (dhcpctl_handle h, synchronous returns zero if the call succeeded, a nonzero status code if - it didn't. + it didn't. result is the address of an empty data string (initialized with bzero or cleared with data_string_forget). On successful completion, the addressed data string will contain @@ -232,7 +232,7 @@ dhcpctl_status dhcpctl_get_boolean (int *result, isc_result_t status; dhcpctl_data_string data = (dhcpctl_data_string)0; int rv; - + status = dhcpctl_get_value (&data, h, value_name); if (status != ISC_R_SUCCESS) return status; diff --git a/dhcpctl/dhcpctl.h b/dhcpctl/dhcpctl.h index 94ab6129..3c0da74b 100644 --- a/dhcpctl/dhcpctl.h +++ b/dhcpctl/dhcpctl.h @@ -87,7 +87,7 @@ isc_result_t dhcpctl_callback_set_value (omapi_object_t *, omapi_object_t *, omapi_typed_data_t *); isc_result_t dhcpctl_callback_get_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, - omapi_value_t **); + omapi_value_t **); isc_result_t dhcpctl_callback_destroy (omapi_object_t *, const char *, int); isc_result_t dhcpctl_callback_signal_handler (omapi_object_t *, const char *, va_list); @@ -107,7 +107,7 @@ isc_result_t dhcpctl_remote_set_value (omapi_object_t *, omapi_object_t *, omapi_typed_data_t *); isc_result_t dhcpctl_remote_get_value (omapi_object_t *, omapi_object_t *, omapi_data_string_t *, - omapi_value_t **); + omapi_value_t **); isc_result_t dhcpctl_remote_destroy (omapi_object_t *, const char *, int); isc_result_t dhcpctl_remote_signal_handler (omapi_object_t *, const char *, va_list); diff --git a/dhcpctl/omshell.1 b/dhcpctl/omshell.1 index 02fb3874..ab484cda 100644 --- a/dhcpctl/omshell.1 +++ b/dhcpctl/omshell.1 @@ -341,4 +341,3 @@ dhcpctl(3), omapi(3), dhcpd(8), dhclient(8), dhcpd.conf(5), dhclient.conf(5). is maintained by ISC. To learn more about Internet Systems Consortium, see .B https://www.isc.org - diff --git a/dhcpctl/omshell.c b/dhcpctl/omshell.c index 31fa9367..d5d31aa8 100644 --- a/dhcpctl/omshell.c +++ b/dhcpctl/omshell.c @@ -81,7 +81,7 @@ static void check (isc_result_t status, const char *func) { } } -int +int main(int argc, char **argv) { isc_result_t status, waitstatus; dhcpctl_handle connection; @@ -132,7 +132,7 @@ main(int argc, char **argv) { dhcpctl_remote_object_t *r = (dhcpctl_remote_object_t *)oh; omapi_generic_object_t *g = (omapi_generic_object_t *)(r -> inner); - + printf ("obj: "); if (r -> rtype -> type != omapi_datatype_string) { @@ -142,16 +142,16 @@ main(int argc, char **argv) { (int)(r -> rtype -> u . buffer . len), r -> rtype -> u . buffer . value); } - + 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; @@ -161,20 +161,20 @@ main(int argc, char **argv) { printf ("%d\n", v -> value -> u . integer); break; - + case omapi_datatype_string: printf ("\"%.*s\"\n", (int) v -> value -> u.buffer.len, v -> value -> u.buffer.value); break; - + case omapi_datatype_data: print_hex_or_string(v->value->u.buffer.len, v->value->u.buffer.value, sizeof(hex_buf), hex_buf); printf("%s\n", hex_buf); break; - + case omapi_datatype_object: printf ("<obj>\n"); break; @@ -189,18 +189,18 @@ main(int argc, char **argv) { status = new_parse (&cfile, -1, buf, strlen(buf), "<STDIN>", 1); check(status, "new_parse()"); - + token = next_token (&val, (unsigned *)0, cfile); switch (token) { default: parse_warn (cfile, "unknown token: %s", val); skip_to_semi (cfile); break; - + case END_OF_FILE: case ENDOFLINE: /* EOL: */ break; - + case TOKEN_HELP: case QUESTIONMARK: /* '?': */ printf ("Commands:\n"); @@ -218,7 +218,7 @@ main(int argc, char **argv) { printf (" remove\n"); skip_to_semi (cfile); break; - + case PORT: token = next_token (&val, (unsigned *)0, cfile); if (is_identifier (token)) { @@ -433,13 +433,13 @@ main(int argc, char **argv) { printf ("usage: new <object-type>\n"); break; } - + if (oh) { printf ("an object is already open.\n"); skip_to_semi (cfile); break; } - + if (!connected) { printf ("not connected.\n"); skip_to_semi (cfile); @@ -452,7 +452,7 @@ main(int argc, char **argv) { isc_result_totext (status)); break; } - + token = next_token (&val, (unsigned *)0, cfile); if (token != END_OF_FILE && token != EOL) { printf ("usage: new <object-type>\n"); @@ -481,7 +481,7 @@ main(int argc, char **argv) { break; } omapi_object_dereference (&oh, MDL); - + break; case TOKEN_SET: @@ -493,13 +493,13 @@ main(int argc, char **argv) { skip_to_semi (cfile); break; } - + if (oh == NULL) { printf ("no open object.\n"); skip_to_semi (cfile); break; } - + if (!connected) { printf ("not connected.\n"); skip_to_semi (cfile); @@ -512,7 +512,7 @@ main(int argc, char **argv) { s1[0] = 0; strncat (s1, val, sizeof(s1)-strlen(s1)-1); #endif - + token = next_token (&val, (unsigned *)0, cfile); if (token != EQUAL) goto set_usage; @@ -523,7 +523,7 @@ main(int argc, char **argv) { dhcpctl_set_string_value (oh, val, s1); token = next_token (&val, (unsigned *)0, cfile); break; - + case NUMBER: strcpy (buf, val); token = peek_token (&val, (unsigned *)0, cfile); @@ -561,7 +561,7 @@ main(int argc, char **argv) { token = next_token (&val, (unsigned *)0, cfile); badnum: break; - + case NUMBER_OR_NAME: strcpy (buf, val); cshl: @@ -587,11 +587,11 @@ main(int argc, char **argv) { printf ("invalid value.\n"); skip_to_semi (cfile); } - + if (token != END_OF_FILE && token != EOL) goto set_usage; break; - + case UNSET: token = next_token (&val, (unsigned *)0, cfile); @@ -601,13 +601,13 @@ main(int argc, char **argv) { 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); @@ -620,7 +620,7 @@ main(int argc, char **argv) { s1[0] = 0; strncat (s1, val, sizeof(s1)-strlen(s1)-1); #endif - + token = next_token (&val, (unsigned *)0, cfile); if (token != END_OF_FILE && token != EOL) goto unset_usage; @@ -628,7 +628,7 @@ main(int argc, char **argv) { dhcpctl_set_null_value (oh, s1); break; - + case TOKEN_CREATE: case TOKEN_OPEN: i = token; @@ -638,7 +638,7 @@ main(int argc, char **argv) { skip_to_semi (cfile); break; } - + if (!connected) { printf ("not connected.\n"); skip_to_semi (cfile); @@ -655,7 +655,7 @@ main(int argc, char **argv) { i = DHCPCTL_CREATE | DHCPCTL_EXCL; else i = 0; - + status = dhcpctl_open_object (oh, connection, i); if (status == ISC_R_SUCCESS) status = dhcpctl_wait_for_completion @@ -667,7 +667,7 @@ main(int argc, char **argv) { isc_result_totext (status)); break; } - + break; case UPDATE: @@ -677,7 +677,7 @@ main(int argc, char **argv) { skip_to_semi (cfile); break; } - + if (!connected) { printf ("not connected.\n"); skip_to_semi (cfile); @@ -701,7 +701,7 @@ main(int argc, char **argv) { isc_result_totext (status)); break; } - + break; case REMOVE: @@ -711,7 +711,7 @@ main(int argc, char **argv) { skip_to_semi (cfile); break; } - + if (!connected) { printf ("not connected.\n"); break; @@ -743,7 +743,7 @@ main(int argc, char **argv) { skip_to_semi (cfile); break; } - + if (!connected) { printf ("not connected.\n"); break; @@ -765,7 +765,7 @@ main(int argc, char **argv) { isc_result_totext (status)); break; } - + break; } end_parse (&cfile); diff --git a/dhcpctl/remote.c b/dhcpctl/remote.c index a35e5ce1..0ec119a4 100644 --- a/dhcpctl/remote.c +++ b/dhcpctl/remote.c @@ -164,7 +164,7 @@ dhcpctl_status dhcpctl_new_object (dhcpctl_handle *h, flags include: DHCPCTL_CREATE - if the object doesn't exist, create it DHCPCTL_UPDATE - update the object on the server using the - attached parameters + attached parameters DHCPCTL_EXCL - error if the object exists and DHCPCTL_CREATE was also specified */ @@ -281,7 +281,7 @@ isc_result_t dhcpctl_remote_get_value (omapi_object_t *h, { if (h -> type != dhcpctl_remote_type) return DHCP_R_INVALIDARG; - + if (h -> inner && h -> inner -> type -> get_value) return (*(h -> inner -> type -> get_value)) (h -> inner, id, name, value); @@ -352,4 +352,3 @@ isc_result_t dhcpctl_remote_stuff_values (omapi_object_t *c, p -> inner); return ISC_R_SUCCESS; } - |