Changeset 1113:eb4ce68b6e5c in freeDiameter for libfdcore/routing_dispatch.c
- Timestamp:
- May 13, 2013, 8:17:13 PM (11 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.