42int main (
int,
char **);
44static void usage (
char *s) {
46 "Usage: %s [-s <server ip>] [-p <port>]", s);
50static void fail_on_error(isc_result_t status,
const char* message) {
52 fprintf (stderr,
"%s: %s\n",
53 message, isc_result_totext (status));
86 char* ip_address =
"127.0.0.1";
88 char* hostname =
"cltest2.host";
92 for (i = 1; i < argc; i++) {
93 if (!strcmp (argv[i],
"-s")) {
95 }
else if (!strcmp (argv [i],
"-p")) {
97 }
else if (argv[i][0] ==
'-') {
104 fail_on_error(status ,
"can't initialize dhcpctl");
109 fail_on_error(status ,
"connect failed");
114 fail_on_error(status ,
"new oject failed");
117 fail_on_error(status ,
"cant set host name");
128 fail_on_error(status ,
"can't set client id");
132 fail_on_error(status,
"open(create) failed");
135 fail_on_error(status,
"wait after open(create)");
145 fail_on_error(status,
"initial open failed, waiting for completion");
151 fail_on_error(status,
"can't disconnect");
155 fail_on_error(status ,
"can't reconnect");
159 fail_on_error(status ,
"can't refresh");
162 fail_on_error(status ,
"wait after refresh failed");
168 fail_on_error(status,
"can't disconnect");
176 if (status == ISC_R_TIMEDOUT) {
177 printf (
"Retry timed connect\n");
183 fail_on_error(status ,
"can't reconnect");
187 fail_on_error(status ,
"can't disconnect");
195 isc_result_t waitstatus;
196 struct timeval use_timeout;
199 use_timeout.tv_sec =
timeout->tv_sec;
200 use_timeout.tv_usec =
timeout->tv_usec;
208 printf (
"wait retry #%d\n", tries);
210 use_timeout.tv_sec = 30;
211 use_timeout.tv_usec = 0;
221 if (status != ISC_R_TIMEDOUT) {
222 fprintf (stderr,
"timed wait failed: %s\n", isc_result_totext (status));
225 }
while (--retries > 0);
227 return (ISC_R_TIMEDOUT);
238 printf (
"%s:\n",msg);
239 for (i = 0; i <
object->nvalues; i++) {
265 sizeof(hex_buf), hex_buf);
266 printf(
"%s\n", hex_buf);
277isc_result_t
find_class (
struct class **c,
const char *n,
const char *f,
int l)
void bootp(struct packet *packet)
void dhcp(struct packet *packet)
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)
isc_result_t wait_with_retry(dhcpctl_handle handle, struct timeval *timeout, int retries)
void print_object(char *msg, dhcpctl_handle handle)
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)
void print_hex_or_string(unsigned len, const u_int8_t *data, unsigned limit, char *buf)
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_timed_connect(dhcpctl_handle *connection, const char *server_name, int port, dhcpctl_handle authinfo, struct timeval *t)
dhcpctl_status dhcpctl_disconnect(dhcpctl_handle *connection, int force)
dhcpctl_status dhcpctl_timed_wait_for_completion(dhcpctl_handle h, dhcpctl_status *s, struct timeval *t)
dhcpctl_status dhcpctl_initialize()
dhcpctl_status dhcpctl_set_string_value(dhcpctl_handle h, const char *value, const char *value_name)
dhcpctl_status dhcpctl_open_object(dhcpctl_handle, dhcpctl_handle, int)
dhcpctl_status dhcpctl_new_object(dhcpctl_handle *, dhcpctl_handle, const char *)
omapi_object_t * dhcpctl_handle
void dhcpv6(struct packet *)
#define ISC_R_NOTIMPLEMENTED
struct __omapi_object omapi_object_t
struct __omapi_generic_object omapi_generic_object_t
struct omapi_typed_data_t::@005330231110240362320041053235346164005276246221::@131374275124060200224243254021133345104025056044 buffer
union omapi_typed_data_t::@005330231110240362320041053235346164005276246221 u
omapi_data_string_t * name
omapi_typed_data_t * value