39 const char *server_name,
43 isc_result_t rstatus, status;
47 log_debug (
"omapi_protocol_connect(%s port=%d)", server_name, port);
51 status = omapi_protocol_allocate (&obj,
MDL);
57 omapi_protocol_dereference (&obj,
MDL);
63 omapi_protocol_dereference (&obj,
MDL);
68 omapi_protocol_dereference (&obj,
MDL);
77 if (!obj -> default_auth) {
78 omapi_protocol_dereference (&obj,
MDL);
79 return ISC_R_NOMEMORY;
87 omapi_protocol_dereference (&obj,
MDL);
100 omapi_protocol_dereference (&obj,
MDL);
113 log_debug (
"omapi_protocol_send_intro()");
121 return ISC_R_NOTCONNECTED;
140 p -> next_xid = random ();
145extern const char *omapi_message_op_name(
int);
173 log_debug (
"omapi_protocol_send_message(): "
174 "op=%s handle=%#lx id=%#lx rid=%#lx",
175 omapi_message_op_name (m->
op),
176 (
long)(m ->
object ? m -> object ->
handle : m ->
handle),
177 (
long)p -> next_xid, (
long)m -> rid);
182 for (ra = p -> remote_auth_list; ra; ra = ra -> next) {
190 }
else if (p -> remote_auth_list) {
191 ra = p -> default_auth;
197 m -> authid = ra -> remote_handle;
215 "output-authenticator",
258 m ->
id = p -> next_xid++;
310 "output-signature", &signature);
318 (c, signature ->
value -> u.buffer.value,
319 signature ->
value -> u.buffer.len));
328 "output-authenticator",
337 omapi_protocol_reference (&m -> protocol_object, p,
MDL);
344 const char *name, va_list ap)
354#if defined (DEBUG_MEMORY_LEAKAGE)
355 unsigned long previous_outstanding = 0xDEADBEEF;
356 unsigned long connect_outstanding = 0xDEADBEEF;
361 return ISC_R_UNEXPECTED;
365 if (!strcmp (name,
"connect")) {
366#if defined (DEBUG_MEMORY_LEAKAGE)
367 connect_outstanding = dmalloc_outstanding;
381 if (!strcmp (name,
"status")) {
382 status = va_arg (ap, isc_result_t);
394 if (!strcmp (name,
"disconnect")) {
395#if defined (DEBUG_MEMORY_LEAKAGE)
396 if (connect_outstanding != 0xDEADBEEF) {
397 log_info (
"generation %ld: %ld new, %ld outstanding, %ld%s",
399 dmalloc_outstanding - previous_outstanding,
400 dmalloc_outstanding, dmalloc_longterm,
" long-term");
403#if defined (DEBUG_MEMORY_LEAKAGE)
404 dmalloc_dump_outstanding ();
406#if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY)
410 if (m -> protocol_object == p) {
421 if (strcmp (name,
"ready")) {
422 if (p -> inner && p -> inner -> type -> signal_handler)
423 return (*(p -> inner -> type -> signal_handler)) (h,
426 return ISC_R_NOTFOUND;
436 switch (p -> state) {
454 if (p -> default_auth) {
457 p -> default_auth -> a,
480#if defined (DEBUG_MEMORY_LEAKAGE)
481 if (previous_outstanding != 0xDEADBEEF) {
482 log_info (
"%s %ld: %ld new, %ld outstanding, %ld%s",
483 "generation", dmalloc_generation,
484 dmalloc_outstanding - previous_outstanding,
485 dmalloc_outstanding, dmalloc_longterm,
488#if (defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL))
489 dmalloc_dump_outstanding ();
491#if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY)
494#if defined (DEBUG_MEMORY_LEAKAGE)
496 previous_outstanding = dmalloc_outstanding;
511 if (p -> message -> authid) {
513 (&p -> message -> id_object, h,
514 p -> message -> authid));
516 p -> verify_result = status;
521 p -> message -> id_object);
531 p -> message -> h = th;
538 (0, c, (p -> header_size -
549 p -> reading_message_values = 1;
571 if (p -> reading_message_values) {
572 p -> reading_message_values = 0;
573 goto need_name_length;
579 if (p -> message -> authlen == 0)
599 return ISC_R_NOMEMORY;
622 goto insert_new_value;
629 return ISC_R_NOMEMORY;
639 p ->
value -> u.buffer.len);
642 if (p -> reading_message_values) {
645 p -> message -> id_object,
646 p -> name, p ->
value));
648 if (!p -> message ->
object) {
652 (&p -> message ->
object,
MDL));
660 p -> message -> id_object,
661 p -> name, p ->
value));
670 goto need_name_length;
674 if (p -> message -> id_object) {
686 "input-authenticator",
697 &p -> message -> authenticator,
699 p -> message -> authlen);
702 if (signature != NULL) {
706 return ISC_R_NOMEMORY;
709 (p -> message -> authenticator -> u.buffer.
value, c,
710 p -> message -> authlen);
713 if (p -> message -> id_object &&
714 ((signature ->
value -> u.buffer.len !=
715 p -> message -> authlen) ||
716 (memcmp (signature ->
value -> u.buffer.value,
717 p -> message -> authenticator -> u.buffer.
value,
718 p -> message -> authlen) != 0))) {
723 if (signature != NULL) {
732 p -> message ->
id, (
char *)0);
739 return ISC_R_NOMEMORY;
742 omapi_message_dereference (&p -> message,
MDL);
743#if defined (DEBUG_MEMORY_LEAKAGE)
744 log_info (
"generation %ld: %ld new, %ld outstanding, %ld%s",
746 dmalloc_outstanding - previous_outstanding,
747 dmalloc_outstanding, dmalloc_longterm,
" long-term");
749#if (defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL))
750 dmalloc_dump_outstanding ();
752#if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY)
755#if defined (DEBUG_MEMORY_LEAKAGE)
756 previous_outstanding = 0xDEADBEEF;
785 log_debug (
"omapi_protocol_add_auth(name=%s)",
789 if (p -> verify_auth) {
798 if (p -> default_auth && !p -> remote_auth_list) {
799 if (p -> default_auth -> a != ao) {
802 return ISC_R_UNEXPECTED;
805 p -> remote_auth_list = p -> default_auth;
806 p -> default_auth -> remote_handle =
handle;
813 return ISC_R_NOMEMORY;
821 r -> remote_handle =
handle;
822 r -> next = p -> remote_auth_list;
823 p -> remote_auth_list = r;
839 for (r = p -> remote_auth_list; r; r = r -> next)
840 if (r -> remote_handle ==
handle)
862 if (!
value -> u.object) {
865 for (r = p -> remote_auth_list; r; r = r -> next)
866 if (r -> a ==
value -> u.object)
872 p -> default_auth = r;
878 if (h -> inner && h -> inner -> type -> set_value)
879 return (*(h -> inner -> type -> set_value))
880 (h -> inner, id, name,
value);
881 return ISC_R_NOTFOUND;
896 if (!p -> default_auth)
897 return ISC_R_NOTFOUND;
900 p -> default_auth -> a,
MDL);
903 if (h -> inner && h -> inner -> type -> get_value)
904 return (*(h -> inner -> type -> get_value))
905 (h -> inner, id, name,
value);
906 return ISC_R_NOTFOUND;
917 omapi_message_dereference (&p -> message,
file,
line);
922 if (p -> default_auth && !p -> remote_auth_list)
925 while (p -> remote_auth_list) {
927 p -> remote_auth_list = p -> remote_auth_list -> next;
944 if (p -> inner && p -> inner -> type -> stuff_values)
945 return (*(p -> inner -> type -> stuff_values)) (c, id,
967 isc_result_t (*verify_addr)
970 isc_result_t (*verify_auth)
983 l -> verify_auth = verify_auth;
986 if (h -> outer != NULL) {
1001 isc_result_t status;
1005 status = omapi_protocol_listener_allocate (&obj,
MDL);
1012 omapi_protocol_listener_dereference (&obj,
MDL);
1017 omapi_protocol_listener_dereference (&obj,
MDL);
1022 obj -> insecure = 1;
1025 omapi_protocol_listener_dereference (&obj,
MDL);
1033 const char *name, va_list ap)
1035 isc_result_t status;
1045 if (strcmp (name,
"connect")) {
1046 if (p -> inner && p -> inner -> type -> signal_handler)
1047 return (*(p -> inner -> type -> signal_handler))
1048 (p -> inner, name, ap);
1049 return ISC_R_NOTFOUND;
1057 status = omapi_protocol_allocate (&obj,
MDL);
1061 obj -> verify_auth = p -> verify_auth;
1062 obj -> insecure = p -> insecure;
1067 omapi_protocol_dereference (&obj,
MDL);
1084 omapi_protocol_dereference (&obj,
MDL);
1096 if (h -> inner && h -> inner -> type -> set_value)
1097 return (*(h -> inner -> type -> set_value))
1098 (h -> inner, id, name,
value);
1099 return ISC_R_NOTFOUND;
1110 if (h -> inner && h -> inner -> type -> get_value)
1111 return (*(h -> inner -> type -> get_value))
1112 (h -> inner, id, name,
value);
1113 return ISC_R_NOTFOUND;
1134 if (p -> inner && p -> inner -> type -> stuff_values)
1135 return (*(p -> inner -> type -> stuff_values)) (c, id,
1142 isc_result_t waitstatus,
1143 unsigned rid,
const char *msg)
1145 isc_result_t status;
1160 omapi_message_dereference (&message,
MDL);
1167 omapi_message_dereference (&message,
MDL);
1172 "result", (
int)waitstatus);
1174 omapi_message_dereference (&message,
MDL);
1183 omapi_message_dereference (&message,
MDL);
1189 omapi_message_dereference (&message,
MDL);
1203 isc_result_t status;
1235 "notify-object", po);
1252 omapi_message_dereference (&message,
MDL);
1262 isc_result_t status;
1277 omapi_message_dereference (&message,
MDL);
1286 omapi_message_dereference (&message,
MDL);
1292 omapi_message_dereference (&message,
MDL);
1298 omapi_message_dereference (&message,
MDL);
1306 omapi_message_dereference (&message,
MDL);
1311 omapi_message_dereference (&message,
MDL);
isc_result_t omapi_connection_get_uint16(omapi_object_t *, u_int16_t *)
isc_result_t omapi_connection_put_uint32(omapi_object_t *, u_int32_t)
isc_result_t omapi_connection_copyout(unsigned char *, omapi_object_t *, unsigned)
isc_result_t omapi_connection_put_uint16(omapi_object_t *, u_int32_t)
isc_result_t omapi_connection_copyin(omapi_object_t *, const unsigned char *, unsigned)
isc_result_t omapi_connection_require(omapi_object_t *, unsigned)
isc_result_t omapi_connection_get_uint32(omapi_object_t *, u_int32_t *)
isc_result_t omapi_value_dereference(omapi_value_t **, const char *, int)
isc_result_t omapi_protocol_connect(omapi_object_t *, const char *, unsigned, omapi_object_t *)
isc_result_t omapi_generic_new(omapi_object_t **, const char *, int)
isc_result_t omapi_make_object_value(omapi_value_t **, omapi_data_string_t *, omapi_object_t *, const char *, int)
isc_result_t omapi_set_boolean_value(omapi_object_t *, omapi_object_t *, const char *, int)
#define OMAPI_OBJECT_ALLOC(name, stype, type)
isc_result_t omapi_set_value(omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_typed_data_t *)
isc_result_t omapi_message_process(omapi_object_t *, omapi_object_t *)
isc_result_t omapi_object_dereference(omapi_object_t **, const char *, int)
isc_result_t omapi_set_object_value(omapi_object_t *, omapi_object_t *, const char *, omapi_object_t *)
isc_result_t omapi_data_string_new(omapi_data_string_t **, unsigned, const char *, int)
isc_result_t omapi_message_register(omapi_object_t *)
#define OMAPI_NOTIFY_PROTOCOL
isc_result_t omapi_object_handle(omapi_handle_t *, omapi_object_t *)
struct __omapi_object omapi_object_t
isc_result_t omapi_disconnect(omapi_object_t *, int)
omapi_object_type_t * omapi_type_auth_key
isc_result_t omapi_set_value_str(omapi_object_t *, omapi_object_t *, const char *, omapi_typed_data_t *)
isc_result_t omapi_connect(omapi_object_t *, const char *, unsigned)
isc_result_t omapi_typed_data_dereference(omapi_typed_data_t **, const char *, int)
isc_result_t omapi_object_reference(omapi_object_t **, omapi_object_t *, const char *, int)
omapi_object_type_t * omapi_type_protocol
isc_result_t omapi_data_string_dereference(omapi_data_string_t **, const char *, int)
isc_result_t omapi_signal_in(omapi_object_t *, const char *,...)
isc_result_t omapi_signal(omapi_object_t *, const char *,...)
unsigned int omapi_handle_t
int omapi_ds_strcmp(omapi_data_string_t *, const char *)
isc_result_t omapi_listener_configure_security(omapi_object_t *, isc_result_t(*)(omapi_object_t *, omapi_addr_t *))
omapi_object_type_t * omapi_type_connection
isc_result_t omapi_set_string_value(omapi_object_t *, omapi_object_t *, const char *, const char *)
isc_result_t omapi_connection_output_auth_length(omapi_object_t *, unsigned *)
isc_result_t omapi_typed_data_new(const char *, int, omapi_typed_data_t **, omapi_datatype_t,...)
isc_result_t omapi_message_unregister(omapi_object_t *)
void * dmalloc(size_t, const char *, int)
isc_result_t omapi_stuff_values(omapi_object_t *, omapi_object_t *, omapi_object_t *)
void dfree(void *, const char *, int)
isc_result_t omapi_get_value_str(omapi_object_t *, omapi_object_t *, const char *, omapi_value_t **)
struct auth_key omapi_auth_key_t
omapi_object_type_t * omapi_type_protocol_listener
isc_result_t omapi_listen(omapi_object_t *, unsigned, int)
isc_result_t omapi_message_new(omapi_object_t **, const char *, int)
omapi_object_type_t * omapi_type_message
isc_result_t omapi_set_int_value(omapi_object_t *, omapi_object_t *, const char *, int)
struct __omapi_message_object omapi_message_object_t
int int int log_debug(const char *,...) __attribute__((__format__(__printf__
@ omapi_protocol_value_wait
@ omapi_protocol_signature_wait
@ omapi_protocol_value_length_wait
@ omapi_protocol_intro_wait
@ omapi_protocol_name_wait
@ omapi_protocol_header_wait
@ omapi_protocol_name_length_wait
struct __omapi_remote_auth omapi_remote_auth_t
omapi_message_object_t * omapi_registered_messages
#define OMAPI_PROTOCOL_VERSION
struct __omapi_protocol_object omapi_protocol_object_t
int int log_info(const char *,...) __attribute__((__format__(__printf__
isc_result_t omapi_protocol_lookup_auth(omapi_object_t **a, omapi_object_t *po, omapi_handle_t handle)
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_protocol_listener_stuff(omapi_object_t *c, omapi_object_t *id, omapi_object_t *p)
isc_result_t omapi_protocol_add_auth(omapi_object_t *po, omapi_object_t *ao, omapi_handle_t handle)
isc_result_t omapi_protocol_send_intro(omapi_object_t *h, unsigned ver, unsigned hsize)
isc_result_t omapi_protocol_signal_handler(omapi_object_t *h, const char *name, va_list ap)
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_protocol_send_update(omapi_object_t *po, omapi_object_t *id, unsigned rid, omapi_object_t *object)
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_boolean_t omapi_protocol_authenticated(omapi_object_t *h)
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_protocol_listener_signal(omapi_object_t *o, const char *name, va_list ap)
isc_result_t omapi_protocol_destroy(omapi_object_t *h, const char *file, int line)
isc_result_t omapi_protocol_listen(omapi_object_t *h, unsigned port, int max)
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_set_value(omapi_object_t *h, omapi_object_t *id, omapi_data_string_t *name, omapi_typed_data_t *value)
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_protocol_stuff_values(omapi_object_t *c, omapi_object_t *id, omapi_object_t *p)
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_listener_destroy(omapi_object_t *h, const char *file, int line)
#define DHCP_R_VERSIONMISMATCH
#define DHCP_R_INVALIDARG
#define DHCP_R_PROTOCOLERROR
#define DHCP_R_KEY_UNKNOWN
#define DHCP_R_INCOMPLETE
#define DHCP_R_INVALIDKEY
isc_result_t verify_result
omapi_typed_data_t * value