40 const char *server_name,
44 isc_result_t rstatus, status;
48 log_debug (
"omapi_protocol_connect(%s port=%d)", server_name, port);
52 status = omapi_protocol_allocate (&obj,
MDL);
53 if (status != ISC_R_SUCCESS)
58 omapi_protocol_dereference (&obj,
MDL);
63 if (status != ISC_R_SUCCESS) {
64 omapi_protocol_dereference (&obj,
MDL);
68 if (status != ISC_R_SUCCESS) {
69 omapi_protocol_dereference (&obj,
MDL);
78 if (!obj -> default_auth) {
79 omapi_protocol_dereference (&obj,
MDL);
80 return ISC_R_NOMEMORY;
86 if (status != ISC_R_SUCCESS) {
88 omapi_protocol_dereference (&obj,
MDL);
97 status = ISC_R_SUCCESS;
101 omapi_protocol_dereference (&obj,
MDL);
113 #ifdef DEBUG_PROTOCOL 114 log_debug (
"omapi_protocol_send_intro()");
122 return ISC_R_NOTCONNECTED;
125 if (status != ISC_R_SUCCESS)
130 if (status != ISC_R_SUCCESS)
141 p -> next_xid = random ();
142 return ISC_R_SUCCESS;
145 #ifdef DEBUG_PROTOCOL 146 extern const char *omapi_message_op_name(
int);
173 #ifdef DEBUG_PROTOCOL 174 log_debug (
"omapi_protocol_send_message(): " 175 "op=%s handle=%#lx id=%#lx rid=%#lx",
176 omapi_message_op_name (m->
op),
177 (
long)(m ->
object ? m -> object -> handle : m -> handle),
178 (
long)p -> next_xid, (
long)m -> rid);
183 for (ra = p -> remote_auth_list; ra; ra = ra -> next) {
191 }
else if (p -> remote_auth_list) {
192 ra = p -> default_auth;
198 m -> authid = ra -> remote_handle;
201 if (status != ISC_R_SUCCESS)
207 if (status != ISC_R_SUCCESS) {
216 "output-authenticator",
218 if (status != ISC_R_SUCCESS) {
224 if (status != ISC_R_SUCCESS) {
232 if (status != ISC_R_SUCCESS) {
239 if (status != ISC_R_SUCCESS) {
251 ? m ->
object -> handle
253 if (status != ISC_R_SUCCESS) {
259 m ->
id = p -> next_xid++;
261 if (status != ISC_R_SUCCESS) {
269 if (status != ISC_R_SUCCESS) {
276 if (status != ISC_R_SUCCESS) {
284 if (status != ISC_R_SUCCESS) {
293 if (status != ISC_R_SUCCESS) {
302 if (status != ISC_R_SUCCESS) {
311 "output-signature", &signature);
312 if (status != ISC_R_SUCCESS) {
319 (c, signature -> value -> u.buffer.
value,
320 signature -> value -> u.buffer.len));
322 if (status != ISC_R_SUCCESS) {
329 "output-authenticator",
331 if (status != ISC_R_SUCCESS) {
338 omapi_protocol_reference (&m -> protocol_object, p,
MDL);
340 return ISC_R_SUCCESS;
345 const char *name, va_list ap)
355 #if defined (DEBUG_MEMORY_LEAKAGE) 356 unsigned long previous_outstanding = 0xDEADBEEF;
357 unsigned long connect_outstanding = 0xDEADBEEF;
362 return ISC_R_UNEXPECTED;
366 if (!strcmp (name,
"connect")) {
367 #if defined (DEBUG_MEMORY_LEAKAGE) 368 connect_outstanding = dmalloc_outstanding;
374 if (status != ISC_R_SUCCESS) {
378 return ISC_R_SUCCESS;
382 if (!strcmp (name,
"status")) {
383 status = va_arg (ap, isc_result_t);
384 if (status != ISC_R_SUCCESS) {
395 if (!strcmp (name,
"disconnect")) {
396 #if defined (DEBUG_MEMORY_LEAKAGE) 397 if (connect_outstanding != 0xDEADBEEF) {
398 log_info (
"generation %ld: %ld new, %ld outstanding, %ld%s",
400 dmalloc_outstanding - previous_outstanding,
401 dmalloc_outstanding, dmalloc_longterm,
" long-term");
404 #if defined (DEBUG_MEMORY_LEAKAGE) 405 dmalloc_dump_outstanding ();
407 #if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY) 411 if (m -> protocol_object == p) {
418 return ISC_R_SUCCESS;
422 if (strcmp (name,
"ready")) {
423 if (p -> inner && p -> inner -> type -> signal_handler)
424 return (*(p -> inner -> type -> signal_handler)) (h,
427 return ISC_R_NOTFOUND;
437 switch (p -> state) {
455 if (p -> default_auth) {
458 p -> default_auth -> a,
460 if (status != ISC_R_SUCCESS) {
481 #if defined (DEBUG_MEMORY_LEAKAGE) 482 if (previous_outstanding != 0xDEADBEEF) {
483 log_info (
"%s %ld: %ld new, %ld outstanding, %ld%s",
484 "generation", dmalloc_generation,
485 dmalloc_outstanding - previous_outstanding,
486 dmalloc_outstanding, dmalloc_longterm,
489 #if (defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL)) 490 dmalloc_dump_outstanding ();
492 #if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY) 495 #if defined (DEBUG_MEMORY_LEAKAGE) 497 previous_outstanding = dmalloc_outstanding;
501 if (status != ISC_R_SUCCESS) {
506 p -> verify_result = ISC_R_SUCCESS;
512 if (p -> message -> authid) {
514 (&p -> message -> id_object, h,
515 p -> message -> authid));
516 if (status != ISC_R_SUCCESS)
517 p -> verify_result = status;
522 p -> message -> id_object);
523 if (status != ISC_R_SUCCESS) {
532 p -> message -> h = th;
539 (0, c, (p -> header_size -
550 p -> reading_message_values = 1;
572 if (p -> reading_message_values) {
573 p -> reading_message_values = 0;
574 goto need_name_length;
580 if (p -> message -> authlen == 0)
591 (c, p -> message -> authlen) == ISC_R_SUCCESS)
598 if (status != ISC_R_SUCCESS) {
600 return ISC_R_NOMEMORY;
623 goto insert_new_value;
628 if (status != ISC_R_SUCCESS) {
630 return ISC_R_NOMEMORY;
640 p -> value -> u.buffer.len);
643 if (p -> reading_message_values) {
646 p -> message -> id_object,
647 p -> name, p -> value));
649 if (!p -> message ->
object) {
653 (&p -> message ->
object,
MDL));
654 if (status != ISC_R_SUCCESS) {
661 p -> message -> id_object,
662 p -> name, p -> value));
664 if (status != ISC_R_SUCCESS) {
671 goto need_name_length;
675 if (p -> message -> id_object) {
680 if (status != ISC_R_SUCCESS) {
687 "input-authenticator",
689 if (status != ISC_R_SUCCESS) {
698 &p -> message -> authenticator,
700 p -> message -> authlen);
702 if (status != ISC_R_SUCCESS) {
703 if (signature != NULL) {
707 return ISC_R_NOMEMORY;
710 (p -> message -> authenticator -> u.buffer.
value, c,
711 p -> message -> authlen);
714 if (p -> message -> id_object &&
715 ((signature -> value -> u.buffer.len !=
716 p -> message -> authlen) ||
717 (memcmp (signature -> value -> u.buffer.
value,
718 p -> message -> authenticator -> u.buffer.
value,
719 p -> message -> authlen) != 0))) {
724 if (signature != NULL) {
730 if (p -> verify_result != ISC_R_SUCCESS) {
733 p -> message ->
id, (
char *)0);
738 if (status != ISC_R_SUCCESS) {
740 return ISC_R_NOMEMORY;
743 omapi_message_dereference (&p -> message,
MDL);
744 #if defined (DEBUG_MEMORY_LEAKAGE) 745 log_info (
"generation %ld: %ld new, %ld outstanding, %ld%s",
747 dmalloc_outstanding - previous_outstanding,
748 dmalloc_outstanding, dmalloc_longterm,
" long-term");
750 #if (defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL)) 751 dmalloc_dump_outstanding ();
753 #if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY) 756 #if defined (DEBUG_MEMORY_LEAKAGE) 757 previous_outstanding = 0xDEADBEEF;
766 return ISC_R_SUCCESS;
785 #ifdef DEBUG_PROTOCOL 786 log_debug (
"omapi_protocol_add_auth(name=%s)",
790 if (p -> verify_auth) {
792 if (status != ISC_R_SUCCESS)
799 if (p -> default_auth && !p -> remote_auth_list) {
800 if (p -> default_auth -> a != ao) {
803 return ISC_R_UNEXPECTED;
806 p -> remote_auth_list = p -> default_auth;
807 p -> default_auth -> remote_handle = handle;
814 return ISC_R_NOMEMORY;
817 if (status != ISC_R_SUCCESS) {
822 r -> remote_handle = handle;
823 r -> next = p -> remote_auth_list;
824 p -> remote_auth_list = r;
826 return ISC_R_SUCCESS;
840 for (r = p -> remote_auth_list; r; r = r -> next)
841 if (r -> remote_handle == handle)
866 for (r = p -> remote_auth_list; r; r = r -> next)
867 if (r -> a == value -> u.
object)
873 p -> default_auth = r;
876 return ISC_R_SUCCESS;
879 if (h -> inner && h -> inner -> type -> set_value)
880 return (*(h -> inner -> type -> set_value))
881 (h -> inner,
id, name, value);
882 return ISC_R_NOTFOUND;
897 if (!p -> default_auth)
898 return ISC_R_NOTFOUND;
901 p -> default_auth -> a,
MDL);
904 if (h -> inner && h -> inner -> type -> get_value)
905 return (*(h -> inner -> type -> get_value))
906 (h -> inner, id, name, value);
907 return ISC_R_NOTFOUND;
918 omapi_message_dereference (&p -> message, file, line);
923 if (p -> default_auth && !p -> remote_auth_list)
924 dfree (p -> default_auth, file, line);
926 while (p -> remote_auth_list) {
928 p -> remote_auth_list = p -> remote_auth_list -> next;
930 dfree (r, file, line);
932 return ISC_R_SUCCESS;
945 if (p -> inner && p -> inner -> type -> stuff_values)
946 return (*(p -> inner -> type -> stuff_values)) (c, id,
948 return ISC_R_SUCCESS;
957 return isc_boolean_false;
959 return isc_boolean_false;
961 return isc_boolean_true;
968 isc_result_t (*verify_addr)
971 isc_result_t (*verify_auth)
984 l -> verify_auth = verify_auth;
987 if (h -> outer != NULL) {
1002 isc_result_t status;
1006 status = omapi_protocol_listener_allocate (&obj,
MDL);
1007 if (status != ISC_R_SUCCESS)
1012 if (status != ISC_R_SUCCESS) {
1013 omapi_protocol_listener_dereference (&obj,
MDL);
1017 if (status != ISC_R_SUCCESS) {
1018 omapi_protocol_listener_dereference (&obj,
MDL);
1023 obj -> insecure = 1;
1026 omapi_protocol_listener_dereference (&obj,
MDL);
1034 const char *name, va_list ap)
1036 isc_result_t status;
1046 if (strcmp (name,
"connect")) {
1047 if (p -> inner && p -> inner -> type -> signal_handler)
1048 return (*(p -> inner -> type -> signal_handler))
1049 (p -> inner, name, ap);
1050 return ISC_R_NOTFOUND;
1058 status = omapi_protocol_allocate (&obj,
MDL);
1059 if (status != ISC_R_SUCCESS)
1062 obj -> verify_auth = p -> verify_auth;
1063 obj -> insecure = p -> insecure;
1066 if (status != ISC_R_SUCCESS) {
1068 omapi_protocol_dereference (&obj,
MDL);
1075 if (status != ISC_R_SUCCESS)
1082 if (status != ISC_R_SUCCESS)
1085 omapi_protocol_dereference (&obj,
MDL);
1097 if (h -> inner && h -> inner -> type -> set_value)
1098 return (*(h -> inner -> type -> set_value))
1099 (h -> inner, id, name, value);
1100 return ISC_R_NOTFOUND;
1111 if (h -> inner && h -> inner -> type -> get_value)
1112 return (*(h -> inner -> type -> get_value))
1113 (h -> inner, id, name, value);
1114 return ISC_R_NOTFOUND;
1122 return ISC_R_SUCCESS;
1135 if (p -> inner && p -> inner -> type -> stuff_values)
1136 return (*(p -> inner -> type -> stuff_values)) (c, id,
1138 return ISC_R_SUCCESS;
1143 isc_result_t waitstatus,
1144 unsigned rid,
const char *msg)
1146 isc_result_t status;
1154 if (status != ISC_R_SUCCESS)
1160 if (status != ISC_R_SUCCESS) {
1161 omapi_message_dereference (&message,
MDL);
1167 if (status != ISC_R_SUCCESS) {
1168 omapi_message_dereference (&message,
MDL);
1173 "result", (
int)waitstatus);
1174 if (status != ISC_R_SUCCESS) {
1175 omapi_message_dereference (&message,
MDL);
1183 if (status != ISC_R_SUCCESS) {
1184 omapi_message_dereference (&message,
MDL);
1190 omapi_message_dereference (&message,
MDL);
1204 isc_result_t status;
1214 if (status == ISC_R_SUCCESS)
1218 if (status == ISC_R_SUCCESS)
1222 if ((flags &
OMAPI_CREATE) && (status == ISC_R_SUCCESS))
1226 if ((flags &
OMAPI_UPDATE) && (status == ISC_R_SUCCESS))
1230 if ((flags &
OMAPI_EXCL) && (status == ISC_R_SUCCESS))
1236 "notify-object", po);
1238 if (type && (status == ISC_R_SUCCESS))
1242 if (status == ISC_R_SUCCESS)
1245 if (status == ISC_R_SUCCESS) {
1248 if (status != ISC_R_SUCCESS)
1253 omapi_message_dereference (&message,
MDL);
1263 isc_result_t status;
1271 if (status != ISC_R_SUCCESS)
1277 if (status != ISC_R_SUCCESS) {
1278 omapi_message_dereference (&message,
MDL);
1286 if (status != ISC_R_SUCCESS) {
1287 omapi_message_dereference (&message,
MDL);
1292 if (status != ISC_R_SUCCESS) {
1293 omapi_message_dereference (&message,
MDL);
1297 "handle", (
int)handle);
1298 if (status != ISC_R_SUCCESS) {
1299 omapi_message_dereference (&message,
MDL);
1306 if (status != ISC_R_SUCCESS) {
1307 omapi_message_dereference (&message,
MDL);
1312 omapi_message_dereference (&message,
MDL);
#define OMAPI_PROTOCOL_VERSION
isc_result_t omapi_typed_data_new(const char *, int, omapi_typed_data_t **, omapi_datatype_t,...)
isc_result_t omapi_set_string_value(omapi_object_t *, omapi_object_t *, const char *, const char *)
omapi_message_object_t * omapi_registered_messages
isc_result_t omapi_protocol_signal_handler(omapi_object_t *h, const char *name, va_list ap)
omapi_object_type_t * omapi_type_connection
isc_result_t omapi_message_new(omapi_object_t **, const char *, int)
isc_result_t omapi_object_reference(omapi_object_t **, omapi_object_t *, const char *, int)
#define DHCP_R_PROTOCOLERROR
isc_result_t omapi_data_string_dereference(omapi_data_string_t **, const char *, int)
isc_result_t omapi_protocol_send_update(omapi_object_t *po, omapi_object_t *id, unsigned rid, omapi_object_t *object)
isc_result_t omapi_message_register(omapi_object_t *)
void * dmalloc(unsigned, const char *, int)
isc_result_t omapi_connection_copyin(omapi_object_t *, const unsigned char *, unsigned)
#define DHCP_R_INVALIDARG
omapi_typed_data_t * value
isc_result_t omapi_set_value(omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_typed_data_t *)
int int int log_debug(const char *,...) __attribute__((__format__(__printf__
isc_result_t omapi_protocol_stuff_values(omapi_object_t *c, omapi_object_t *id, omapi_object_t *p)
isc_result_t omapi_signal_in(omapi_object_t *, const char *,...)
isc_result_t omapi_protocol_add_auth(omapi_object_t *po, omapi_object_t *ao, omapi_handle_t handle)
isc_result_t omapi_set_object_value(omapi_object_t *, omapi_object_t *, const char *, omapi_object_t *)
isc_result_t verify_result
OMAPI_OBJECT_ALLOC(omapi_protocol, omapi_protocol_object_t, omapi_type_protocol)
isc_result_t omapi_protocol_listen(omapi_object_t *h, unsigned port, int max)
isc_result_t omapi_message_unregister(omapi_object_t *)
#define DHCP_R_INVALIDKEY
isc_result_t omapi_protocol_send_status(omapi_object_t *po, omapi_object_t *id, isc_result_t waitstatus, unsigned rid, const char *msg)
isc_result_t omapi_connection_output_auth_length(omapi_object_t *, unsigned *)
#define DHCP_R_KEY_UNKNOWN
isc_result_t omapi_connection_put_uint32(omapi_object_t *, u_int32_t)
omapi_object_type_t * omapi_type_protocol
isc_result_t omapi_get_value_str(omapi_object_t *, omapi_object_t *, const char *, omapi_value_t **)
isc_result_t omapi_connection_require(omapi_object_t *, unsigned)
isc_result_t omapi_protocol_send_message(omapi_object_t *po, omapi_object_t *id, omapi_object_t *mo, omapi_object_t *omo)
isc_result_t omapi_stuff_values(omapi_object_t *, omapi_object_t *, omapi_object_t *)
#define DHCP_R_VERSIONMISMATCH
isc_result_t omapi_set_boolean_value(omapi_object_t *, omapi_object_t *, const char *, int)
isc_result_t omapi_protocol_configure_security(omapi_object_t *h, isc_result_t(*verify_addr)(omapi_object_t *, omapi_addr_t *), isc_result_t(*verify_auth)(omapi_object_t *, omapi_auth_key_t *))
isc_result_t omapi_protocol_send_open(omapi_object_t *po, omapi_object_t *id, const char *type, omapi_object_t *object, unsigned flags)
isc_result_t omapi_object_dereference(omapi_object_t **, const char *, int)
isc_result_t omapi_signal(omapi_object_t *, const char *,...)
isc_result_t omapi_set_value_str(omapi_object_t *, omapi_object_t *, const char *, omapi_typed_data_t *)
isc_result_t omapi_generic_new(omapi_object_t **, const char *, int)
omapi_typed_data_t * value
isc_result_t omapi_protocol_lookup_auth(omapi_object_t **a, omapi_object_t *po, omapi_handle_t handle)
omapi_object_type_t * omapi_type_protocol_listener
void dfree(void *, const char *, int)
isc_result_t omapi_protocol_get_value(omapi_object_t *h, omapi_object_t *id, omapi_data_string_t *name, omapi_value_t **value)
isc_result_t omapi_connection_get_uint32(omapi_object_t *, u_int32_t *)
isc_result_t omapi_listener_configure_security(omapi_object_t *, isc_result_t(*)(omapi_object_t *, omapi_addr_t *))
isc_result_t omapi_protocol_listener_stuff(omapi_object_t *c, omapi_object_t *id, omapi_object_t *p)
int int log_info(const char *,...) __attribute__((__format__(__printf__
isc_result_t omapi_protocol_connect(omapi_object_t *, const char *, unsigned, omapi_object_t *)
isc_result_t omapi_object_handle(omapi_handle_t *, omapi_object_t *)
isc_result_t omapi_connect(omapi_object_t *, const char *, unsigned)
unsigned int omapi_handle_t
isc_result_t omapi_listen(omapi_object_t *, unsigned, int)
isc_result_t omapi_protocol_send_intro(omapi_object_t *h, unsigned ver, unsigned hsize)
isc_result_t omapi_value_dereference(omapi_value_t **, const char *, int)
isc_result_t omapi_message_process(omapi_object_t *, omapi_object_t *)
isc_result_t omapi_protocol_listener_get_value(omapi_object_t *h, omapi_object_t *id, omapi_data_string_t *name, omapi_value_t **value)
isc_result_t omapi_protocol_listener_signal(omapi_object_t *o, const char *name, va_list ap)
int omapi_ds_strcmp(omapi_data_string_t *, const char *)
isc_result_t omapi_connection_put_uint16(omapi_object_t *, u_int32_t)
isc_result_t omapi_data_string_new(omapi_data_string_t **, unsigned, const char *, int)
omapi_object_type_t * omapi_type_message
isc_result_t omapi_protocol_listener_set_value(omapi_object_t *h, omapi_object_t *id, omapi_data_string_t *name, omapi_typed_data_t *value)
isc_result_t omapi_connection_copyout(unsigned char *, omapi_object_t *, unsigned)
isc_result_t omapi_set_int_value(omapi_object_t *, omapi_object_t *, const char *, int)
#define DHCP_R_INCOMPLETE
isc_result_t omapi_connection_get_uint16(omapi_object_t *, u_int16_t *)
isc_result_t omapi_disconnect(omapi_object_t *, int)
isc_result_t omapi_protocol_listener_destroy(omapi_object_t *h, const char *file, int line)
isc_result_t omapi_protocol_set_value(omapi_object_t *h, omapi_object_t *id, omapi_data_string_t *name, omapi_typed_data_t *value)
omapi_object_type_t * omapi_type_auth_key
isc_result_t omapi_typed_data_dereference(omapi_typed_data_t **, const char *, int)
#define OMAPI_NOTIFY_PROTOCOL
isc_boolean_t omapi_protocol_authenticated(omapi_object_t *h)
isc_result_t omapi_protocol_destroy(omapi_object_t *h, const char *file, int line)
isc_result_t omapi_make_object_value(omapi_value_t **, omapi_data_string_t *, omapi_object_t *, const char *, int)