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);
112 #ifdef DEBUG_PROTOCOL
113 log_debug (
"omapi_protocol_send_intro()");
121 return ISC_R_NOTCONNECTED;
140 p -> next_xid = random ();
144 #ifdef DEBUG_PROTOCOL
145 extern const char *omapi_message_op_name(
int);
172 #ifdef DEBUG_PROTOCOL
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;
784 #ifdef DEBUG_PROTOCOL
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);