Changeset 1113:eb4ce68b6e5c in freeDiameter for libfdcore
- Timestamp:
- May 13, 2013, 8:17:13 PM (11 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- libfdcore
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdcore/config.c
r1107 r1113 85 85 FD_DUMP_HANDLE_OFFSET(); 86 86 87 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " {freeDiameter configuration}(@%p):\n", fd_g_config), return NULL);87 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "freeDiameter configuration:\n", fd_g_config), return NULL); 88 88 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Default trace level .... : %+d\n", fd_g_debug_lvl), return NULL); 89 89 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Configuration file ..... : %s\n", fd_g_config->cnf_file), return NULL); … … 99 99 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Local endpoints ........ : Default (use all available)\n"), return NULL); 100 100 } else { 101 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Local endpoints ........ : \n"), return NULL);102 CHECK_MALLOC_DO( fd_ep_dump( FD_DUMP_STD_PARAMS, 29, &fd_g_config->cnf_endpoints ), return NULL);101 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Local endpoints ........ : "), return NULL); 102 CHECK_MALLOC_DO( fd_ep_dump( FD_DUMP_STD_PARAMS, 0, 0, &fd_g_config->cnf_endpoints ), return NULL); 103 103 } 104 104 if (FD_IS_LIST_EMPTY(&fd_g_config->cnf_apps)) { 105 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Local applications ..... : (none) \n"), return NULL);105 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Local applications ..... : (none)"), return NULL); 106 106 } else { 107 107 struct fd_list * li = fd_g_config->cnf_apps.next; 108 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Local applications ..... : \n"), return NULL);108 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Local applications ..... : "), return NULL); 109 109 while (li != &fd_g_config->cnf_apps) { 110 110 struct fd_app * app = (struct fd_app *)li; 111 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " App: %u\t%s%s\tVnd: %u\n",111 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "App: %u,%s%s,Vnd:%u\t", 112 112 app->appid, 113 113 app->flags.auth ? "Au" : "--", … … 118 118 } 119 119 120 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Flags : - IP ........... : %s\n", fd_g_config->cnf_flags.no_ip4 ? "DISABLED" : "Enabled"), return NULL);120 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n Flags : - IP ........... : %s\n", fd_g_config->cnf_flags.no_ip4 ? "DISABLED" : "Enabled"), return NULL); 121 121 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " - IPv6 ......... : %s\n", fd_g_config->cnf_flags.no_ip6 ? "DISABLED" : "Enabled"), return NULL); 122 122 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " - Relay app .... : %s\n", fd_g_config->cnf_flags.no_fwd ? "DISABLED" : "Enabled"), return NULL); … … 588 588 589 589 } else { 590 TRACE_DEBUG(INFO,"Generating fresh Diffie-Hellman parameters of size %d (this takes some time)... ", fd_g_config->cnf_sec_data.dh_bits ?: GNUTLS_DEFAULT_DHBITS);590 LOG_D( "Generating fresh Diffie-Hellman parameters of size %d (this takes some time)... ", fd_g_config->cnf_sec_data.dh_bits ?: GNUTLS_DEFAULT_DHBITS); 591 591 CHECK_GNUTLS_DO( gnutls_dh_params_generate2( 592 592 fd_g_config->cnf_sec_data.dh_cache, -
libfdcore/endpoints.c
r1093 r1113 285 285 } 286 286 287 DECLARE_FD_DUMP_PROTOTYPE(fd_ep_dump_one, struct fd_endpoint * ep )287 DECLARE_FD_DUMP_PROTOTYPE(fd_ep_dump_one, int preamble, struct fd_endpoint * ep ) 288 288 { 289 289 FD_DUMP_HANDLE_OFFSET(); 290 290 291 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{ep}(@%p): ", ep), return NULL); 291 if (preamble) { 292 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{ep}(@%p): ", ep), return NULL); 293 } 292 294 293 295 if (!ep) { … … 297 299 298 300 CHECK_MALLOC_DO( fd_sa_dump_node_serv( FD_DUMP_STD_PARAMS, &ep->sa, NI_NUMERICHOST | NI_NUMERICSERV ), return NULL); 299 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " 300 (ep->flags & EP_FL_CONF) ? "C" : "-",301 (ep->flags & EP_FL_DISC) ? "D" : "-",302 (ep->flags & EP_FL_ADV) ? "A" : "-",303 (ep->flags & EP_FL_LL) ? "L" : "-",304 (ep->flags & EP_FL_PRIMARY) ? "P" : "-"), return NULL);301 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{%s%s%s%s%s}", 302 (ep->flags & EP_FL_CONF) ? "C" : "-", 303 (ep->flags & EP_FL_DISC) ? "D" : "-", 304 (ep->flags & EP_FL_ADV) ? "A" : "-", 305 (ep->flags & EP_FL_LL) ? "L" : "-", 306 (ep->flags & EP_FL_PRIMARY) ? "P" : "-"), return NULL); 305 307 return *buf; 306 308 } 307 309 308 DECLARE_FD_DUMP_PROTOTYPE(fd_ep_dump, int indent, struct fd_list * eps )310 DECLARE_FD_DUMP_PROTOTYPE(fd_ep_dump, int preamble, int indent, struct fd_list * eps ) 309 311 { 310 312 struct fd_list * li; … … 312 314 FD_DUMP_HANDLE_OFFSET(); 313 315 314 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%*s{eps}(@%p):", indent, "", eps), return NULL); 316 if (preamble) { 317 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%*s{eps}(@%p):", indent, "", eps), return NULL); 318 } 315 319 if (eps) { 316 320 for (li = eps->next; li != eps; li = li->next) { 317 321 struct fd_endpoint * ep = (struct fd_endpoint *)li; 318 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n%*s", indent+1, ""), return NULL); 319 CHECK_MALLOC_DO( fd_ep_dump_one( FD_DUMP_STD_PARAMS, ep ), return NULL); 320 } 321 } 322 } 323 322 if (preamble) { 323 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n%*s", indent+1, ""), return NULL); 324 } else if (li->prev != eps) { 325 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\t"), return NULL); 326 } 327 CHECK_MALLOC_DO( fd_ep_dump_one( FD_DUMP_STD_PARAMS, preamble, ep ), return NULL); 328 } 329 } 330 } 331 -
libfdcore/extensions.c
r1094 r1113 151 151 { 152 152 struct fd_ext_info * ext = (struct fd_ext_info *)li; 153 TRACE_DEBUG (INFO,"Loading : %s", ext->filename);153 LOG_D( "Loading : %s", ext->filename); 154 154 155 155 /* Load the extension */ … … 162 162 if (ext->handler == NULL) { 163 163 /* An error occured */ 164 TRACE_ERROR("Loading of extension %s failed: %s", ext->filename, dlerror());164 LOG_F("Loading of extension %s failed: %s", ext->filename, dlerror()); 165 165 #ifdef DEBUG 166 166 ext->handler = dlopen(ext->filename, RTLD_LAZY | RTLD_GLOBAL); … … 208 208 } 209 209 210 TRACE_DEBUG (INFO,"All extensions loaded.");210 LOG_N("All extensions loaded."); 211 211 212 212 /* We have finished. */ -
libfdcore/messages.c
r1103 r1113 314 314 } 315 315 316 static int fd_msg_send_int( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data, void (*expirecb)(void *, DiamId_t, size_t, struct msg **), const struct timespec *timeout ) 317 { 318 struct msg_hdr *hdr; 319 DiamId_t diamid; 320 size_t diamidlen; 321 322 /* Save the callback in the message, with the timeout */ 323 CHECK_FCT( fd_msg_anscb_associate( *pmsg, anscb, data, expirecb, timeout ) ); 324 325 /* If this is a new request, call the HOOK_MESSAGE_LOCAL hook */ 326 if ( (fd_msg_hdr(*pmsg, &hdr) == 0) 327 && (hdr->msg_flags & CMD_FLAG_REQUEST) 328 && (fd_msg_source_get(*pmsg, &diamid, &diamidlen) == 0) 329 && (diamid == NULL)) { 330 fd_hook_call(HOOK_MESSAGE_LOCAL, *pmsg, NULL, NULL, fd_msg_pmdl_get(*pmsg)); 331 } 332 333 /* Post the message in the outgoing queue */ 334 CHECK_FCT( fd_fifo_post(fd_g_outgoing, pmsg) ); 335 336 return 0; 337 } 338 316 339 /* Send a message and optionaly register a callback for an answer */ 317 340 int fd_msg_send ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data ) … … 320 343 CHECK_PARAMS( pmsg ); 321 344 322 /* Save the callback in the message */ 323 CHECK_FCT( fd_msg_anscb_associate( *pmsg, anscb, data, NULL, NULL /* we should maybe use a safeguard here like 1 hour or so? */ ) ); 324 325 /* Post the message in the outgoing queue */ 326 CHECK_FCT( fd_fifo_post(fd_g_outgoing, pmsg) ); 327 328 return 0; 345 return fd_msg_send_int(pmsg, anscb, data, NULL, NULL); 329 346 } 330 347 … … 335 352 CHECK_PARAMS( pmsg && expirecb && timeout ); 336 353 337 /* Save the callback in the message, with the timeout */ 338 CHECK_FCT( fd_msg_anscb_associate( *pmsg, anscb, data, expirecb, timeout ) ); 339 340 /* Post the message in the outgoing queue */ 341 CHECK_FCT( fd_fifo_post(fd_g_outgoing, pmsg) ); 342 343 return 0; 354 return fd_msg_send_int(pmsg, anscb, data, expirecb, timeout); 344 355 } 345 356 -
libfdcore/p_ce.c
r1103 r1113 650 650 *recv_cnx = NULL; 651 651 if (*cer) { 652 //fd_msg_log(FD_MSG_LOG_DROPPED, *cer, "An error occurred while rejecting a CER.");652 fd_hook_call(HOOK_MESSAGE_DROPPED, *cer, NULL, "An error occurred while rejecting this CER.", fd_msg_pmdl_get(*cer)); 653 653 fd_msg_free(*cer); 654 654 *cer = NULL; -
libfdcore/p_out.c
r1103 r1113 98 98 CHECK_FCT_DO(fd_fifo_post(fd_g_outgoing, &msg), 99 99 { 100 //fd_msg_log( FD_MSG_LOG_DROPPED, msg, "An error occurred while attempting to requeue this message during cancellation of the sending function");100 fd_hook_call(HOOK_MESSAGE_DROPPED, msg, NULL, "An error occurred while attempting to requeue this message during cancellation of the sending function", fd_msg_pmdl_get(msg)); 101 101 CHECK_FCT_DO(fd_msg_free(msg), /* What can we do more? */); 102 102 } ); … … 131 131 { 132 132 if (msg) { 133 //fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Internal error: Problem while sending (%s)", strerror(ret) ); 133 char buf[256]; 134 snprintf(buf, sizeof(buf), "Error while sending this message: s", strerror(ret)); 135 fd_hook_call(HOOK_MESSAGE_DROPPED, msg, NULL, buf, fd_msg_pmdl_get(msg)); 134 136 fd_msg_free(msg); 135 137 } … … 183 185 { 184 186 if (msg) { 185 //fd_msg_log( FD_MSG_LOG_DROPPED, *msg, "Internal error: Problem while sending (%s)", strerror(ret) ); 187 char buf[256]; 188 snprintf(buf, sizeof(buf), "Error while sending this message: s", strerror(ret)); 189 fd_hook_call(HOOK_MESSAGE_DROPPED, *msg, NULL, buf, fd_msg_pmdl_get(*msg)); 186 190 fd_msg_free(*msg); 187 191 *msg = NULL; -
libfdcore/p_psm.c
r1104 r1113 241 241 case FDEVP_CNX_INCOMING: { 242 242 struct cnx_incoming * evd = ev->data; 243 //fd_msg_log( FD_MSG_LOG_DROPPED, evd->cer, "Message discarded while cleaning peer state machine queue.");243 fd_hook_call(HOOK_MESSAGE_DROPPED, evd->cer, NULL, "Message discarded while cleaning peer state machine queue.", fd_msg_pmdl_get(evd->cer)); 244 244 CHECK_FCT_DO( fd_msg_free(evd->cer), /* continue */); 245 245 fd_cnx_destroy(evd->cnx); … … 577 577 char buf[128]; 578 578 snprintf(buf, sizeof(buf), "Received while peer state machine was in state %s.", STATE_STR(cur_state)); 579 LOG_E("%s",buf); 579 580 fd_hook_call(HOOK_MESSAGE_DROPPED, msg, peer, buf, fd_msg_pmdl_get(msg)); 580 581 fd_msg_free(msg); … … 590 591 if (ret != EBADMSG) { 591 592 CHECK_FCT_DO( ret, 592 { 593 LOG_E("%s: An unexpected error occurred while parsing a link-local message", peer->p_hdr.info.pi_diamid); 593 { 594 char buf[256]; 595 snprintf(buf, sizeof(buf), "%s: An unexpected error occurred while parsing a link-local message", peer->p_hdr.info.pi_diamid); 596 LOG_E("%s",buf); 597 fd_hook_call(HOOK_MESSAGE_DROPPED, msg, peer, buf, fd_msg_pmdl_get(msg)); 594 598 fd_msg_free(msg); 595 599 goto psm_end; … … 600 604 CHECK_FCT_DO( ret = fd_out_send(&error, NULL, peer, FD_CNX_ORDERED), ); 601 605 if (error) { 606 char buf[256]; 602 607 /* Only if an error occurred & the message was not saved / dumped */ 603 LOG_E("%s: error sending a message", peer->p_hdr.info.pi_diamid); 608 snprintf(buf, sizeof(buf), "%s: error sending a message", peer->p_hdr.info.pi_diamid); 609 LOG_E("%s",buf); 610 fd_hook_call(HOOK_MESSAGE_DROPPED, error, peer, buf, fd_msg_pmdl_get(error)); 604 611 CHECK_FCT_DO( fd_msg_free(error), goto psm_end); 605 612 } 606 613 } else { 614 char buf[256]; 607 615 /* We received an invalid answer, let's disconnect */ 608 LOG_E("%s: Received invalid answer to Base protocol message, disconnecting...", peer->p_hdr.info.pi_diamid); 616 snprintf(buf, sizeof(buf), "%s: Received invalid answer to Base protocol message, disconnecting...", peer->p_hdr.info.pi_diamid); 617 LOG_E("%s",buf); 609 618 CHECK_FCT_DO( fd_msg_free(msg), goto psm_end); 610 619 CHECK_FCT_DO( fd_event_send(peer->p_events, FDEVP_CNX_ERROR, 0, NULL), goto psm_reset ); … … 657 666 /* Cleanup the message if not done */ 658 667 if (msg) { 659 //fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Received un-handled non-routable command from peer '%s'.", peer->p_hdr.info.pi_diamid ); 668 char buf[256]; 669 snprintf(buf, sizeof(buf), "Received un-handled non-routable command from peer '%s'.", peer->p_hdr.info.pi_diamid); 670 LOG_E("%s",buf); 671 fd_hook_call(HOOK_MESSAGE_DROPPED, msg, NULL, buf, fd_msg_pmdl_get(msg)); 660 672 CHECK_FCT_DO( fd_msg_free(msg), /* continue */); 661 673 msg = NULL; … … 665 677 /* At this point the message must have been fully handled already */ 666 678 if (msg) { 667 //fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Internal error ('%s'): unhandled message.", peer->p_hdr.info.pi_diamid ); 679 char buf[256]; 680 snprintf(buf, sizeof(buf), "Internal error ('%s'): unhandled message.", peer->p_hdr.info.pi_diamid); 681 LOG_E("%s",buf); 682 fd_hook_call(HOOK_MESSAGE_DROPPED, msg, NULL, buf, fd_msg_pmdl_get(msg)); 668 683 fd_msg_free(msg); 669 684 } … … 732 747 char * buf = NULL; 733 748 size_t len = 0; 734 LOG_D("New remote endpoint(s): %s", fd_ep_dump(&buf, &len, NULL, 6, &peer->p_hdr.info.pi_endpoints) ?: "error");749 LOG_D("New remote endpoint(s): %s", fd_ep_dump(&buf, &len, NULL, 0, 0, &peer->p_hdr.info.pi_endpoints) ?: "error"); 735 750 free(buf); 736 751 } -
libfdcore/p_sr.c
r1110 r1113 119 119 /* If the callback did not dispose of the message, do it now */ 120 120 if (ed->request) { 121 //fd_msg_log(FD_MSG_LOG_DROPPED, ed->request, "Expiration period completed without an answer, and the expiry callback did not dispose of the message.");121 fd_hook_call(HOOK_MESSAGE_DROPPED, ed->request, NULL, "Expiration period completed without an answer, and the expiry callback did not dispose of the message.", fd_msg_pmdl_get(ed->request)); 122 122 CHECK_FCT_DO( fd_msg_free(ed->request), /* ignore */ ); 123 123 } … … 323 323 hdr->msg_flags |= CMD_FLAG_RETRANSMIT; 324 324 325 fd_hook_call(HOOK_MESSAGE_FAILOVER, sr->req, (struct fd_peer *)srlist->srs.o, NULL, fd_msg_pmdl_get(sr->req)); 326 325 327 /* Requeue for sending to another peer */ 326 328 CHECK_FCT_DO( ret = fd_fifo_post(fd_g_outgoing, &sr->req), 327 329 { 328 //fd_msg_log( FD_MSG_LOG_DROPPED, sr->req, "Internal error: error while requeuing during failover: %s", strerror(ret) ); 330 char buf[256]; 331 snprintf(buf, sizeof(buf), "Internal error: error while requeuing during failover: %s", strerror(ret)); 332 fd_hook_call(HOOK_MESSAGE_DROPPED, sr->req, NULL, buf, fd_msg_pmdl_get(sr->req)); 329 333 CHECK_FCT_DO(fd_msg_free(sr->req), /* What can we do more? */) 330 334 }); 331 335 } else { 332 336 /* Just free the request. */ 333 / /fd_msg_log( FD_MSG_LOG_DROPPED, sr->req, "Sent & unanswered local message discarded during failover." );337 /* fd_hook_call(HOOK_MESSAGE_DROPPED, sr->req, NULL, "Sent & unanswered local message discarded during failover.", fd_msg_pmdl_get(sr->req)); */ 334 338 CHECK_FCT_DO(fd_msg_free(sr->req), /* Ignore */); 335 339 } -
libfdcore/peers.c
r1103 r1113 242 242 /* Requeue all messages in the "out" queue */ 243 243 while ( fd_fifo_tryget(peer->p_tosend, &m) == 0 ) { 244 fd_hook_call(HOOK_MESSAGE_FAILOVER, m, peer, NULL, fd_msg_pmdl_get(m)); 244 245 CHECK_FCT_DO(fd_fifo_post(fd_g_outgoing, &m), 245 246 { 246 247 /* fallback: destroy the message */ 247 //fd_msg_log(FD_MSG_LOG_DROPPED, m, "Internal error: unable to requeue this message during failover process");248 fd_hook_call(HOOK_MESSAGE_DROPPED, m, NULL, "Internal error: unable to requeue this message during failover process", fd_msg_pmdl_get(m)); 248 249 CHECK_FCT_DO(fd_msg_free(m), /* What can we do more? */) 249 250 } ); -
libfdcore/queues.c
r1078 r1113 74 74 75 75 /* We got one! */ 76 //fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Message lost because framework is terminating.");76 fd_hook_call(HOOK_MESSAGE_DROPPED, msg, NULL, "Message lost because framework is terminating.", fd_msg_pmdl_get(msg)); 77 77 fd_msg_free(msg); 78 78 } -
libfdcore/routing_dispatch.c
r1103 r1113 393 393 394 394 if (!peer) { 395 //fd_msg_log(FD_MSG_LOG_DROPPED, *pmsg, "Unable to send error '%s' to deleted peer '%s' in reply to this message.", error_code, id); 395 char buf[256]; 396 snprintf(buf, sizeof(buf), "Unable to send error '%s' to deleted peer '%s' in reply to this message.", error_code, id); 397 fd_hook_call(HOOK_MESSAGE_DROPPED, *pmsg, NULL, buf, fd_msg_pmdl_get(*pmsg)); 396 398 fd_msg_free(*pmsg); 397 399 *pmsg = NULL; … … 496 498 497 499 /* Now, call any callback registered for the message */ 498 CHECK_FCT( fd_msg_dispatch ( &msgptr, sess, &action, &ec ) );500 CHECK_FCT( fd_msg_dispatch ( &msgptr, sess, &action, &ec, &em, &error) ); 499 501 500 502 /* Now, act depending on msg and action and ec */ … … 505 507 if (!fd_g_config->cnf_flags.no_fwd) { 506 508 /* requeue to fd_g_outgoing */ 509 fd_hook_call(HOOK_MESSAGE_ROUTING_FORWARD, msgptr, NULL, NULL, fd_msg_pmdl_get(msgptr)); 507 510 CHECK_FCT( fd_fifo_post(fd_g_outgoing, &msgptr) ); 508 511 break; … … 519 522 520 523 if (!is_req) { 521 //fd_msg_log( FD_MSG_LOG_DROPPED, msgptr, "Internal error: Answer received to locally issued request, but not handled by any handler.");524 fd_hook_call(HOOK_MESSAGE_DROPPED, msgptr, NULL, "Internal error: Answer received to locally issued request, but not handled by any handler.", fd_msg_pmdl_get(msgptr)); 522 525 fd_msg_free(msgptr); 523 526 break; … … 532 535 CHECK_FCT( fd_fifo_post(fd_g_outgoing, &msgptr) ); 533 536 } 537 } else if (em) { 538 fd_hook_call(HOOK_MESSAGE_DROPPED, error, NULL, em, fd_msg_pmdl_get(error)); 539 fd_msg_free(error); 534 540 } 535 541 … … 555 561 /* Handle incorrect bits */ 556 562 if (is_req && is_err) { 563 fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, "R & E bits were set", fd_msg_pmdl_get(msgptr)); 557 564 CHECK_FCT( return_error( &msgptr, "DIAMETER_INVALID_HDR_BITS", "R & E bits were set", NULL) ); 558 565 return 0; … … 573 580 /* Check if we have local support for the message application */ 574 581 if ( (hdr->msg_appl == 0) || (hdr->msg_appl == AI_RELAY) ) { 575 TRACE_DEBUG(INFO, "Received a routable message with application id 0 or " _stringize(AI_RELAY) " (relay)," 576 " returning DIAMETER_APPLICATION_UNSUPPORTED"); 582 fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, "Received a routable message with application id 0 or " _stringize(AI_RELAY) " (relay)", fd_msg_pmdl_get(msgptr)); 577 583 CHECK_FCT( return_error( &msgptr, "DIAMETER_APPLICATION_UNSUPPORTED", "Routable message with application id 0 or relay", NULL) ); 578 584 return 0; … … 601 607 { 602 608 if (error_info.pei_errcode) { 609 fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, error_info.pei_message ?: error_info.pei_errcode, fd_msg_pmdl_get(msgptr)); 603 610 CHECK_FCT( return_error( &msgptr, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) ); 604 611 return 0; 605 612 } else { 613 fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, "Unspecified error while parsing Destination-Host AVP", fd_msg_pmdl_get(msgptr)); 606 614 return ret; 607 615 } … … 621 629 { 622 630 if (error_info.pei_errcode) { 631 fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, error_info.pei_message ?: error_info.pei_errcode, fd_msg_pmdl_get(msgptr)); 623 632 CHECK_FCT( return_error( &msgptr, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) ); 624 633 return 0; 625 634 } else { 635 fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, "Unspecified error while parsing Destination-Realm AVP", fd_msg_pmdl_get(msgptr)); 626 636 return ret; 627 637 } … … 643 653 { 644 654 if (error_info.pei_errcode) { 655 fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, error_info.pei_message ?: error_info.pei_errcode, fd_msg_pmdl_get(msgptr)); 645 656 CHECK_FCT( return_error( &msgptr, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) ); 646 657 return 0; 647 658 } else { 659 fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, "Unspecified error while parsing User-Name AVP", fd_msg_pmdl_get(msgptr)); 648 660 return ret; 649 661 } … … 668 680 /* Handle the missing routing AVPs first */ 669 681 if ( is_dest_realm == UNKNOWN ) { 682 fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, "Non-routable message not supported (invalid bit ? missing Destination-Realm ?)", fd_msg_pmdl_get(msgptr)); 670 683 CHECK_FCT( return_error( &msgptr, "DIAMETER_COMMAND_UNSUPPORTED", "Non-routable message not supported (invalid bit ? missing Destination-Realm ?)", NULL) ); 671 684 return 0; … … 676 689 if (is_local_app == YES) { 677 690 /* Ok, give the message to the dispatch thread */ 691 fd_hook_call(HOOK_MESSAGE_ROUTING_LOCAL, msgptr, NULL, NULL, fd_msg_pmdl_get(msgptr)); 678 692 CHECK_FCT( fd_fifo_post(fd_g_local, &msgptr) ); 679 693 } else { 680 694 /* We don't support the application, reply an error */ 695 fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, "Application unsupported", fd_msg_pmdl_get(msgptr)); 681 696 CHECK_FCT( return_error( &msgptr, "DIAMETER_APPLICATION_UNSUPPORTED", NULL, NULL) ); 682 697 } … … 687 702 if ((is_dest_host == NO) || (is_dest_realm == NO)) { 688 703 if (fd_g_config->cnf_flags.no_fwd) { 704 fd_hook_call(HOOK_MESSAGE_ROUTING_ERROR, msgptr, NULL, "Message for another realm/host", fd_msg_pmdl_get(msgptr)); 689 705 CHECK_FCT( return_error( &msgptr, "DIAMETER_UNABLE_TO_DELIVER", "I am not a Diameter agent", NULL) ); 690 706 return 0; … … 700 716 { 701 717 /* If the process failed, we assume it is because of the AVP format */ 718 fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, "Failed to process decorated NAI", fd_msg_pmdl_get(msgptr)); 702 719 CHECK_FCT( return_error( &msgptr, "DIAMETER_INVALID_AVP_VALUE", "Failed to process decorated NAI", un) ); 703 720 return 0; … … 713 730 if (is_local_app == YES) { 714 731 /* Handle localy since we are able to */ 732 fd_hook_call(HOOK_MESSAGE_ROUTING_LOCAL, msgptr, NULL, NULL, fd_msg_pmdl_get(msgptr)); 715 733 CHECK_FCT(fd_fifo_post(fd_g_local, &msgptr) ); 716 734 return 0; … … 719 737 if (fd_g_config->cnf_flags.no_fwd) { 720 738 /* We return an error */ 739 fd_hook_call(HOOK_MESSAGE_ROUTING_ERROR, msgptr, NULL, "Application unsupported", fd_msg_pmdl_get(msgptr)); 721 740 CHECK_FCT( return_error( &msgptr, "DIAMETER_APPLICATION_UNSUPPORTED", NULL, NULL) ); 722 741 return 0; … … 736 755 if ((!qry_src) && (!is_err)) { 737 756 /* The message is a normal answer to a request issued localy, we do not call the callbacks chain on it. */ 757 fd_hook_call(HOOK_MESSAGE_ROUTING_LOCAL, msgptr, NULL, NULL, fd_msg_pmdl_get(msgptr)); 738 758 CHECK_FCT(fd_fifo_post(fd_g_local, &msgptr) ); 739 759 return 0; … … 764 784 CHECK_FCT_DO( ret = (*rh->rt_fwd_cb)(rh->cbdata, &msgptr), 765 785 { 766 //fd_msg_log( FD_MSG_LOG_DROPPED, msgptr, "Internal error: a FWD routing callback returned an error (%s)", strerror(ret)); 786 char buf[256]; 787 snprintf(buf, sizeof(buf), "A FWD routing callback returned an error: %s", strerror(ret)); 788 fd_hook_call(HOOK_MESSAGE_ROUTING_ERROR, msgptr, NULL, buf, fd_msg_pmdl_get(msgptr)); 789 fd_hook_call(HOOK_MESSAGE_DROPPED, msgptr, NULL, buf, fd_msg_pmdl_get(msgptr)); 767 790 fd_msg_free(msgptr); 768 791 msgptr = NULL; 792 break; 769 793 } ); 770 794 } … … 780 804 /* Now pass the message to the next step: either forward to another peer, or dispatch to local extensions */ 781 805 if (is_req || qry_src) { 806 fd_hook_call(HOOK_MESSAGE_ROUTING_FORWARD, msgptr, NULL, NULL, fd_msg_pmdl_get(msgptr)); 782 807 CHECK_FCT(fd_fifo_post(fd_g_outgoing, &msgptr) ); 783 808 } else { 809 fd_hook_call(HOOK_MESSAGE_ROUTING_LOCAL, msgptr, NULL, NULL, fd_msg_pmdl_get(msgptr)); 784 810 CHECK_FCT(fd_fifo_post(fd_g_local, &msgptr) ); 785 811 } … … 823 849 CHECK_FCT( fd_peer_getbyid( qry_src, qry_src_len, 0, (void *) &peer ) ); 824 850 if (fd_peer_getstate(peer) != STATE_OPEN) { 825 //fd_msg_log( FD_MSG_LOG_DROPPED, msgptr, "Unable to forward answer to deleted / closed peer '%s'.", qry_src); 851 char buf[128]; 852 snprintf(buf, sizeof(buf), "Unable to forward answer to deleted / closed peer '%s'.", qry_src); 853 fd_hook_call(HOOK_MESSAGE_ROUTING_ERROR, msgptr, NULL, buf, fd_msg_pmdl_get(msgptr)); 854 fd_hook_call(HOOK_MESSAGE_DROPPED, msgptr, NULL, buf, fd_msg_pmdl_get(msgptr)); 826 855 fd_msg_free(msgptr); 827 856 return 0; … … 908 937 CHECK_FCT_DO( ret = (*rh->rt_out_cb)(rh->cbdata, msgptr, candidates), 909 938 { 910 //fd_msg_log( FD_MSG_LOG_DROPPED, msgptr, "Internal error: an OUT routing callback returned an error (%s)", strerror(ret)); 939 char buf[256]; 940 snprintf(buf, sizeof(buf), "An OUT routing callback returned an error: %s", strerror(ret)); 941 fd_hook_call(HOOK_MESSAGE_ROUTING_ERROR, msgptr, NULL, buf, fd_msg_pmdl_get(msgptr)); 942 fd_hook_call(HOOK_MESSAGE_DROPPED, msgptr, NULL, buf, fd_msg_pmdl_get(msgptr)); 911 943 fd_msg_free(msgptr); 912 944 msgptr = NULL; … … 956 988 /* If the message has not been sent, return an error */ 957 989 if (msgptr) { 958 //fd_msg_log( FD_MSG_LOG_NODELIVER, msgptr, "No suitable candidate to route the message to.");990 fd_hook_call(HOOK_MESSAGE_ROUTING_ERROR, msgptr, NULL, "No remaining suitable candidate to route the message to", fd_msg_pmdl_get(msgptr)); 959 991 return_error( &msgptr, "DIAMETER_UNABLE_TO_DELIVER", "No suitable candidate to route the message to", NULL); 960 992 } -
libfdcore/server.c
r1103 r1113 94 94 95 95 /* Dump all servers information */ 96 DECLARE_FD_DUMP_PROTOTYPE(fd_servers_dump )96 DECLARE_FD_DUMP_PROTOTYPE(fd_servers_dump, int details) 97 97 { 98 98 struct fd_list * li, *cli; … … 104 104 enum s_state st = get_status(s); 105 105 106 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{server}(@%p)'%s': %s, %s, %s", s, fd_cnx_getid(s->conn), 107 IPPROTO_NAME( s->proto ), 108 s->secur ? "Secur" : "NotSecur", 109 (st == NOT_CREATED) ? "Thread not created" : 110 ((st == RUNNING) ? "Thread running" : 111 ((st == TERMINATED) ? "Thread terminated" : 112 "Thread status unknown"))), return NULL); 113 /* Dump the client list of this server */ 114 CHECK_POSIX_DO( pthread_mutex_lock(&s->clients_mtx), ); 115 for (cli = s->clients.next; cli != &s->clients; cli = cli->next) { 116 struct client * c = (struct client *)cli; 117 char bufts[128]; 118 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {client}(@%p)'%s': to:%s", c, fd_cnx_getid(c->conn), fd_log_time(&c->ts, bufts, sizeof(bufts))), break); 119 } 120 CHECK_POSIX_DO( pthread_mutex_unlock(&s->clients_mtx), ); 121 122 if (li->next != &FD_SERVERS) { 123 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n"), return NULL); 106 if (details) { 107 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "{server}(@%p)'%s': %s, %s, %s", s, fd_cnx_getid(s->conn), 108 IPPROTO_NAME( s->proto ), 109 s->secur ? "Secur" : "NotSecur", 110 (st == NOT_CREATED) ? "Thread not created" : 111 ((st == RUNNING) ? "Thread running" : 112 ((st == TERMINATED) ? "Thread terminated" : 113 "Thread status unknown"))), return NULL); 114 /* Dump the client list of this server */ 115 CHECK_POSIX_DO( pthread_mutex_lock(&s->clients_mtx), ); 116 for (cli = s->clients.next; cli != &s->clients; cli = cli->next) { 117 struct client * c = (struct client *)cli; 118 char bufts[128]; 119 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n {client}(@%p)'%s': to:%s", c, fd_cnx_getid(c->conn), fd_log_time(&c->ts, bufts, sizeof(bufts))), break); 120 } 121 CHECK_POSIX_DO( pthread_mutex_unlock(&s->clients_mtx), ); 122 123 if (li->next != &FD_SERVERS) { 124 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "\n"), return NULL); 125 } 126 } else { 127 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "'%s'(%s,%s) ", fd_cnx_getid(s->conn), 128 IPPROTO_NAME( s->proto ), s->secur ? "Secur" : "NotSecur"), return NULL); 124 129 } 125 130 } … … 446 451 size_t len = 0, offset = 0; 447 452 CHECK_MALLOC_DO( fd_dump_extend( &buf, &len, &offset , "Local server address(es): "), ); 448 CHECK_MALLOC_DO( fd_ep_dump( &buf, &len, &offset, 5, &fd_g_config->cnf_endpoints ), );453 CHECK_MALLOC_DO( fd_ep_dump( &buf, &len, &offset, 0, 0, &fd_g_config->cnf_endpoints ), ); 449 454 LOG_N("%s", buf ?: "Error dumping addresses"); 450 455 free(buf);
Note: See TracChangeset
for help on using the changeset viewer.