44isc_result_t
find_class (
struct class **c,
const char *n,
const char *f,
int l)
72static void usage (
const char *s) {
73 fprintf (stderr,
"Usage: %s\n", s);
77static void check (isc_result_t status,
const char *func) {
79 fprintf (stderr,
"%s: %s\n", func, isc_result_totext (status));
85main(
int argc,
char **argv) {
86 isc_result_t status, waitstatus;
91 const char *name = 0, *algorithm =
"hmac-md5";
94 const char *server =
"127.0.0.1";
111 for (i = 1; i < argc; i++) {
116 openlog (isc_file_basename(
progname),
120 fprintf (stderr,
"dhcpctl_initialize: %s\n",
121 isc_result_totext (status));
125 memset (&oh, 0,
sizeof oh);
129 }
else if (oh == NULL) {
130 printf (
"obj: <null>\n");
142 (
int)(r -> rtype -> u .
buffer . len),
146 for (i = 0; i < g -> nvalues; i++) {
149 if (!g -> values [i])
152 printf (
"%.*s = ", (
int)v -> name -> len,
159 switch (v ->
value -> type) {
162 v ->
value -> u . integer);
166 printf (
"\"%.*s\"\n",
167 (
int) v ->
value -> u.buffer.len,
168 v ->
value -> u.buffer.value);
174 sizeof(hex_buf), hex_buf);
175 printf(
"%s\n", hex_buf);
185 fputs (
"> ", stdout);
187 if (fgets (buf,
sizeof(buf), stdin) == NULL)
190 status =
new_parse (&cfile, -1, buf, strlen(buf),
"<STDIN>", 1);
191 check(status,
"new_parse()");
206 printf (
"Commands:\n");
207 printf (
" port <server omapi port>\n");
208 printf (
" server <server address>\n");
209 printf (
" key <key name> <key value>\n");
210 printf (
" connect\n");
211 printf (
" disconnect\n");
212 printf (
" new <object-type>\n");
213 printf (
" set <name> = <value>\n");
214 printf (
" create\n");
216 printf (
" update\n");
217 printf (
" unset <name>\n");
218 printf (
" refresh\n");
219 printf (
" remove\n");
227 se = getservbyname (val,
"tcp");
229 port = ntohs (se -> s_port);
231 printf (
"unknown service name: %s\n", val);
234 }
else if (token ==
NUMBER) {
238 printf (
"usage: port <port>\n");
241 token =
next_token (&val, (
unsigned *)0, cfile);
243 printf (
"usage: port <server>\n");
250 token =
next_token (&val, (
unsigned *)0, cfile);
252 int alen = (
sizeof buf) - 1;
257 if (len + 1 > alen) {
259 printf (
"usage: server <server>\n");
264 token =
next_token (&val, (
unsigned *)0, cfile);
268 token =
next_token (&val, (
unsigned *)0, cfile);
276 token =
next_token (&val, (
unsigned *)0, cfile);
280 token =
next_token (&val, (
unsigned *)0, cfile);
288 token =
next_token (&val, (
unsigned *)0, cfile);
292 token =
next_token (&val, (
unsigned *)0, cfile);
303 printf (
"usage: server <server>\n");
310 printf (
"no memory to store server name.\n");
317 token =
next_token (&val, (
unsigned *)0, cfile);
319 printf (
"usage: server <server>\n");
327 token =
next_token (&val, (
unsigned *)0, cfile);
329 printf (
"missing or invalid algorithm name\n");
330 printf (
"usage: key-algoritm <algorithm name>\n");
337 printf (
"no memory for algorithm name.\n");
345 token =
next_token (&val, (
unsigned *)0, cfile);
347 printf (
"extra information after %s\n", algorithm);
348 printf (
"usage: key-algorithm <algorithm name>\n");
356 token =
peek_token(&val, (
unsigned *)0, cfile);
358 token =
next_token (&val, (
unsigned *)0, cfile);
360 printf (
"usage: key <name> <value>\n");
366 printf (
"no memory for key name.\n");
374 printf (
"usage: key <name> <value>\n");
381 memset (&secret, 0,
sizeof secret);
387 token =
next_token (&val, (
unsigned *)0, cfile);
389 printf (
"usage: key <name> <value>\n");
397 token =
next_token (&val, (
unsigned *)0, cfile);
399 printf (
"usage: connect\n");
414 "Cannot create authenticator: %s\n",
415 isc_result_totext (status));
420 memset (&connection, 0,
sizeof connection);
422 server, port, authenticator);
424 fprintf (stderr,
"dhcpctl_connect: %s\n",
425 isc_result_totext (status));
432 token =
next_token (&val, (
unsigned *)0, cfile);
434 printf (
"usage: disconnect\n");
439 if (!connected || !connection) {
440 fprintf (stderr,
"not connected\n");
446 fprintf (stderr,
"dhcpctl_disconnect: %s\n",
447 isc_result_totext (status));
454 token =
next_token (&val, (
unsigned *)0, cfile);
456 printf (
"usage: new <object-type>\n");
461 printf (
"an object is already open.\n");
467 printf (
"not connected.\n");
474 printf (
"can't create object: %s\n",
475 isc_result_totext (status));
479 token =
next_token (&val, (
unsigned *)0, cfile);
481 printf (
"usage: new <object-type>\n");
488 token =
next_token (&val, (
unsigned *)0, cfile);
490 printf (
"usage: close\n");
496 printf (
"not connected.\n");
502 printf (
"not open.\n");
511 token =
next_token (&val, (
unsigned *)0, cfile);
515 printf (
"usage: set <name> = <value>\n");
521 printf (
"no open object.\n");
527 printf (
"not connected.\n");
533 strlcpy (s1, val,
sizeof(s1));
536 strncat (s1, val,
sizeof(s1)-strlen(s1)-1);
539 token =
next_token (&val, (
unsigned *)0, cfile);
543 token =
next_token (&val, (
unsigned *)0, cfile);
547 token =
next_token (&val, (
unsigned *)0, cfile);
552 token =
peek_token (&val, (
unsigned *)0, cfile);
556 else if (token ==
DOT) {
560 int intval = atoi (val);
563 "dotted octet > 255: %s",
570 (
unsigned *)0, cfile);
575 (
unsigned *)0, cfile)) ==
DOT)
577 }
while (token ==
NUMBER);
584 token =
next_token (&val, (
unsigned *)0, cfile);
598 (
unsigned *)0, cfile);
602 (
unsigned *)0, cfile);
603 }
while (token ==
NUMBER ||
606 (
unsigned)(s - buf), s1);
610 printf (
"invalid value.\n");
619 token =
next_token (&val, (
unsigned *)0, cfile);
623 printf (
"usage: unset <name>\n");
629 printf (
"no open object.\n");
635 printf (
"not connected.\n");
641 strlcpy (s1, val,
sizeof(s1));
644 strncat (s1, val,
sizeof(s1)-strlen(s1)-1);
647 token =
next_token (&val, (
unsigned *)0, cfile);
658 token =
next_token (&val, (
unsigned *)0, cfile);
660 printf (
"usage: %s\n", val);
666 printf (
"not connected.\n");
672 printf (
"you must make a new object first!\n");
689 printf (
"can't open object: %s\n",
690 isc_result_totext (status));
697 token =
next_token (&val, (
unsigned *)0, cfile);
699 printf (
"usage: %s\n", val);
705 printf (
"not connected.\n");
711 printf (
"you haven't opened an object yet!\n");
723 printf (
"can't update object: %s\n",
724 isc_result_totext (status));
731 token =
next_token (&val, (
unsigned *)0, cfile);
733 printf (
"usage: remove\n");
739 printf (
"not connected.\n");
744 printf (
"no object.\n");
755 printf (
"can't destroy object: %s\n",
756 isc_result_totext (status));
763 token =
next_token (&val, (
unsigned *)0, cfile);
765 printf (
"usage: refresh\n");
771 printf (
"not connected.\n");
776 printf (
"no object.\n");
787 printf (
"can't refresh object: %s\n",
788 isc_result_totext (status));
enum dhcp_token peek_token(const char **rval, unsigned *rlen, struct parse *cfile)
enum dhcp_token next_token(const char **rval, unsigned *rlen, struct parse *cfile)
isc_result_t end_parse(struct parse **cfile)
isc_result_t new_parse(struct parse **cfile, int file, char *inbuf, unsigned buflen, const char *name, int eolp)
void skip_to_semi(struct parse *cfile)
int parse_warn(struct parse *cfile, const char *fmt,...)
void convert_num(struct parse *cfile, unsigned char *buf, const char *str, int base, unsigned size)
int parse_base64(struct data_string *data, struct parse *cfile)
char * parse_host_name(struct parse *cfile)
void print_hex_or_string(unsigned len, const u_int8_t *data, unsigned limit, char *buf)
dhcpctl_status dhcpctl_wait_for_completion(dhcpctl_handle h, dhcpctl_status *s)
dhcpctl_status dhcpctl_object_refresh(dhcpctl_handle connection, dhcpctl_handle h)
dhcpctl_status dhcpctl_connect(dhcpctl_handle *connection, const char *server_name, int port, dhcpctl_handle authinfo)
dhcpctl_status dhcpctl_object_update(dhcpctl_handle connection, dhcpctl_handle h)
dhcpctl_status dhcpctl_set_int_value(dhcpctl_handle h, int value, const char *value_name)
dhcpctl_status dhcpctl_disconnect(dhcpctl_handle *connection, int force)
dhcpctl_status dhcpctl_object_remove(dhcpctl_handle connection, dhcpctl_handle h)
dhcpctl_status dhcpctl_set_null_value(dhcpctl_handle h, const char *value_name)
dhcpctl_status dhcpctl_initialize()
dhcpctl_status dhcpctl_set_string_value(dhcpctl_handle h, const char *value, const char *value_name)
dhcpctl_status dhcpctl_set_data_value(dhcpctl_handle h, const char *value, unsigned len, const char *value_name)
dhcpctl_status dhcpctl_open_object(dhcpctl_handle, dhcpctl_handle, int)
dhcpctl_status dhcpctl_new_authenticator(dhcpctl_handle *, const char *, const char *, const unsigned char *, unsigned)
dhcpctl_status dhcpctl_new_object(dhcpctl_handle *, dhcpctl_handle, const char *)
omapi_object_t * dhcpctl_handle
#define dhcpctl_null_handle
#define DHCPD_LOG_FACILITY
void dhcpv6(struct packet *)
#define ISC_R_NOTIMPLEMENTED
isc_result_t omapi_object_dereference(omapi_object_t **, const char *, int)
struct __omapi_object omapi_object_t
void * dmalloc(size_t, const char *, int)
struct __omapi_generic_object omapi_generic_object_t
void bootp(struct packet *packet)
void dhcp(struct packet *packet)
int main(int argc, char **argv)
int parse_allow_deny(struct option_cache **oc, struct parse *cfile, int flag)
int check_collection(struct packet *p, struct lease *l, struct collection *c)
void classify(struct packet *packet, struct class *class)
isc_result_t dhcp_set_control_state(control_object_state_t oldstate, control_object_state_t newstate)
isc_result_t find_class(struct class **c, const char *n, const char *f, int l)
const unsigned char * data
struct omapi_typed_data_t::@005330231110240362320041053235346164005276246221::@131374275124060200224243254021133345104025056044 buffer
union omapi_typed_data_t::@005330231110240362320041053235346164005276246221 u
omapi_typed_data_t * value