exit (1);
}
+#if 0
/* Create a named group that contains the values we want to assign
to the host. */
memset (&group_handle, 0, sizeof group_handle);
printf ("group name = %.*s\n",
(int)groupname -> len,
groupname -> value);
+#endif
memset (&host_handle, 0, sizeof host_handle);
status = dhcpctl_new_object (&host_handle, connection, "host");
exit (1);
}
- cid -> value [0] = 0; cid -> value [1] = 0x10;
- cid -> value [2] = 0x5a; cid -> value [3] = 0xf8;
- cid -> value [4] = 0x00; cid -> value [5] = 0xbb;
+ memset (&cid -> value [0], 0, 6);
- doitagain:
status = dhcpctl_set_value (host_handle,
- cid, "dhcp-client-identifier");
-/*#else
- doitagain: */
- status = dhcpctl_set_string_value (host_handle, "gnorf",
- "name");
+ cid, "hardware-address");
if (status != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_set_value: %s\n",
isc_result_totext (status));
exit (1);
}
-/*#endif*/
- status = dhcpctl_set_value (host_handle, groupname, "group");
+ status = dhcpctl_set_string_value (host_handle, "gnorf",
+ "name");
if (status != ISC_R_SUCCESS) {
- fprintf (stderr, "dhcpctl_set_value: %s\n",
+ fprintf (stderr, "dhcpctl_set_string_value: %s\n",
isc_result_totext (status));
exit (1);
}
exit (1);
}
+#if 0
status = dhcpctl_set_string_value (host_handle, "\n\
option host-name \"bar\";\n\
option smtp-server 10.0.0.1;",
isc_result_totext (status));
exit (1);
}
+#endif
status = dhcpctl_open_object (host_handle, connection,
DHCPCTL_CREATE | DHCPCTL_EXCL);
status = dhcpctl_wait_for_completion (host_handle, &waitstatus);
if (status != ISC_R_SUCCESS) {
- fprintf (stderr, "dhcpctl_wait_for_completion: %s\n",
+ fprintf (stderr, "create: dhcpctl_wait_for_completion: %s\n",
isc_result_totext (status));
exit (1);
}
if (waitstatus != ISC_R_SUCCESS) {
- status = dhcpctl_open_object (host_handle, connection, 0);
- if (status != ISC_R_SUCCESS) {
- fprintf (stderr, "dhcpctl_open_object: %s\n",
- isc_result_totext (status));
- exit (1);
- }
- status = dhcpctl_wait_for_completion (host_handle,
- &waitstatus);
- if (status != ISC_R_SUCCESS) {
- fprintf (stderr, "dhcpctl_wait_for_completion: %s\n",
- isc_result_totext (status));
- exit (1);
- }
- if (waitstatus != ISC_R_SUCCESS) {
- fprintf (stderr, "dhcpctl_wait_for_completion: %s\n",
- isc_result_totext (waitstatus));
- exit (1);
- }
-
- status = dhcpctl_object_remove (connection, host_handle);
- if (status != ISC_R_SUCCESS) {
- fprintf (stderr, "dhcpctl_object_remove: %s\n",
- isc_result_totext (status));
- exit (1);
- }
- status = dhcpctl_wait_for_completion (host_handle,
- &waitstatus);
- if (status != ISC_R_SUCCESS) {
- fprintf (stderr,
- "remove: dhcpctl_wait_for_completion: %s\n",
- isc_result_totext (status));
- exit (1);
- }
- if (waitstatus != ISC_R_SUCCESS) {
- fprintf (stderr,
- "remove: dhcpctl_wait_for_completion: %s\n",
- isc_result_totext (waitstatus));
- exit (1);
- }
+ fprintf (stderr, "dhcpctl_open_object: %s\n",
+ isc_result_totext (waitstatus));
+ exit (1);
+ }
- omapi_object_dereference (&host_handle, MDL);
+ cid -> value [0] = 0; cid -> value [1] = 0x10;
+ cid -> value [2] = 0x5a; cid -> value [3] = 0xf8;
+ cid -> value [4] = 0x00; cid -> value [5] = 0xbb;
- status = dhcpctl_new_object (&host_handle, connection, "host");
- if (status != ISC_R_SUCCESS) {
- fprintf (stderr, "dhcpctl_new_object: %s\n",
- isc_result_totext (status));
- exit (1);
- }
+ status = dhcpctl_set_value (host_handle,
+ cid, "hardware-address");
+ if (status != ISC_R_SUCCESS) {
+ fprintf (stderr, "dhcpctl_set_value: %s\n",
+ isc_result_totext (status));
+ exit (1);
+ }
- goto doitagain;
+ status = dhcpctl_object_update (connection, host_handle);
+ if (status != ISC_R_SUCCESS) {
+ fprintf (stderr, "dhcpctl_object_update: %s\n",
+ isc_result_totext (status));
+ exit (1);
}
- memset (&result, 0, sizeof result);
- status = dhcpctl_get_value (&result, host_handle, "name");
+ status = dhcpctl_wait_for_completion (host_handle, &waitstatus);
if (status != ISC_R_SUCCESS) {
- fprintf (stderr, "dhcpctl_get_value: %s\n",
+ fprintf (stderr, "update: dhcpctl_wait_for_completion: %s\n",
isc_result_totext (status));
exit (1);
}
- printf ("host name = %.*s\n", (int)result -> len, result -> value);
+ if (waitstatus != ISC_R_SUCCESS) {
+ fprintf (stderr, "dhcpctl_object_update: %s\n",
+ isc_result_totext (waitstatus));
+ exit (1);
+ }
-#if 0
status = dhcpctl_object_remove (connection, host_handle);
if (status != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_object_remove: %s\n",
status = dhcpctl_wait_for_completion (host_handle,
&waitstatus);
if (status != ISC_R_SUCCESS) {
- fprintf (stderr, "remove: dhcpctl_wait_for_completion: %s\n",
+ fprintf (stderr,
+ "remove: dhcpctl_wait_for_completion: %s\n",
isc_result_totext (status));
exit (1);
}
if (waitstatus != ISC_R_SUCCESS) {
- fprintf (stderr, "remove: dhcpctl_wait_for_completion: %s\n",
+ fprintf (stderr,
+ "remove: dhcpctl_wait_for_completion: %s\n",
isc_result_totext (waitstatus));
exit (1);
}
-#endif
- /* Create a named group that contains the values we want to assign
- to the host. */
- memset (&lease_handle, 0, sizeof lease_handle);
- status = dhcpctl_new_object (&lease_handle, connection, "lease");
+ omapi_object_dereference (&host_handle, MDL);
+
+ status = dhcpctl_new_object (&host_handle, connection, "host");
if (status != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_new_object: %s\n",
isc_result_totext (status));
exit (1);
}
- memset (&ip_addr, 0, sizeof ip_addr);
- status = omapi_data_string_new (&ip_addr, 4, MDL);
+ memset (&cid -> value [0], 0, 6);
+
+ status = dhcpctl_set_value (host_handle,
+ cid, "hardware-address");
if (status != ISC_R_SUCCESS) {
- fprintf (stderr, "omapi_data_string_new: %s\n",
+ fprintf (stderr, "dhcpctl_set_value: %s\n",
isc_result_totext (status));
exit (1);
}
- ip_addr -> value [0] = 10; ip_addr -> value [1] = 0;
- ip_addr -> value [2] = 0; ip_addr -> value [3] = 4;
-
- status = dhcpctl_set_value (lease_handle, ip_addr, "ip-address");
+ status = dhcpctl_set_string_value (host_handle, "gnorf",
+ "name");
if (status != ISC_R_SUCCESS) {
- fprintf (stderr, "dhcpctl_set_value: %s\n",
+ fprintf (stderr, "dhcpctl_set_string_value: %s\n",
isc_result_totext (status));
exit (1);
}
- status = dhcpctl_open_object (lease_handle, connection, 0);
+ status = dhcpctl_open_object (host_handle, connection,
+ DHCPCTL_CREATE | DHCPCTL_EXCL);
if (status != ISC_R_SUCCESS) {
- fprintf (stderr, "dhcpctl_open_object: %s\n",
+ fprintf (stderr, "dhcpctl_open_object 2: %s\n",
isc_result_totext (status));
exit (1);
}
- status = dhcpctl_wait_for_completion (lease_handle, &waitstatus);
+ status = dhcpctl_wait_for_completion (host_handle, &waitstatus);
if (status != ISC_R_SUCCESS) {
- fprintf (stderr, "dhcpctl_wait_for_completion: %s\n",
+ fprintf (stderr, "create: dhcpctl_wait_for_completion: %s\n",
isc_result_totext (status));
exit (1);
}
+
if (waitstatus != ISC_R_SUCCESS) {
- fprintf (stderr, "lease object lookup: %s\n",
+ fprintf (stderr, "dhcpctl_open_object 2: %s\n",
isc_result_totext (waitstatus));
exit (1);
}
- memset (&identifier, 0, sizeof identifier);
- status = dhcpctl_get_value (&identifier, lease_handle,
- "dhcp-client-identifier");
- if (status == ISC_R_SUCCESS) {
- printf ("lease client-identifier = %02x",
- identifier -> value [0]);
- for (i = 1; i < identifier -> len; i++) {
- printf (":%02x", identifier -> value [i]);
- }
- putchar ('\n');
- } else {
- status = dhcpctl_get_value (&identifier, lease_handle,
- "hardware-address");
- if (status == ISC_R_SUCCESS) {
- printf ("lease hardware address = %02x",
- identifier -> value [0]);
- for (i = 1; i < identifier -> len; i++) {
- printf (":%02x", identifier -> value [i]);
- }
- putchar ('\n');
- dhcpctl_data_string_dereference (&identifier, MDL);
- status = dhcpctl_get_value (&identifier, lease_handle,
- "hardware-type");
- if (status == ISC_R_SUCCESS) {
- printf ("lease hardware type = %d\n",
- identifier -> value [0]);
- dhcpctl_data_string_dereference (&identifier,
- MDL);
- }
- } else {
- printf ("Unable to find identifier for lease.\n");
- }
- }
-
exit (0);
}