comparison libfdcore/routing_dispatch.c @ 1154:0b95a3afbfc3

Return DIAMETER_LOOP_DETECTED if local peer is already in the Route-Record AVP of a new received request.
author Sebastien Decugis <sdecugis@freediameter.net>
date Mon, 27 May 2013 17:22:40 +0800
parents 1af09cc156d6
children 56c36d1007b4
comparison
equal deleted inserted replaced
1153:7a7ec1ad0c44 1154:0b95a3afbfc3
585 struct fd_app * app; 585 struct fd_app * app;
586 CHECK_FCT( fd_app_check(&fd_g_config->cnf_apps, hdr->msg_appl, &app) ); 586 CHECK_FCT( fd_app_check(&fd_g_config->cnf_apps, hdr->msg_appl, &app) );
587 is_local_app = (app ? YES : NO); 587 is_local_app = (app ? YES : NO);
588 } 588 }
589 589
590 /* Parse the message for Dest-Host and Dest-Realm */ 590 /* Parse the message for Dest-Host, Dest-Realm, and Route-Record */
591 CHECK_FCT( fd_msg_browse(msgptr, MSG_BRW_FIRST_CHILD, &avp, NULL) ); 591 CHECK_FCT( fd_msg_browse(msgptr, MSG_BRW_FIRST_CHILD, &avp, NULL) );
592 while (avp) { 592 while (avp) {
593 struct avp_hdr * ahdr; 593 struct avp_hdr * ahdr;
594 struct fd_pei error_info; 594 struct fd_pei error_info;
595 int ret; 595 int ret;
661 } ); 661 } );
662 ASSERT( ahdr->avp_value ); 662 ASSERT( ahdr->avp_value );
663 un = avp; 663 un = avp;
664 un_val = ahdr->avp_value; 664 un_val = ahdr->avp_value;
665 break; 665 break;
666
667 case AC_ROUTE_RECORD:
668 /* Parse this AVP */
669 CHECK_FCT_DO( ret = fd_msg_parse_dict ( avp, fd_g_config->cnf_dict, &error_info ),
670 {
671 if (error_info.pei_errcode) {
672 fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, error_info.pei_message ?: error_info.pei_errcode, fd_msg_pmdl_get(msgptr));
673 CHECK_FCT( return_error( &msgptr, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) );
674 return 0;
675 } else {
676 fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, "Unspecified error while parsing Route-Record AVP", fd_msg_pmdl_get(msgptr));
677 return ret;
678 }
679 } );
680 ASSERT( ahdr->avp_value );
681 /* Is this our own name ? */
682 if (!fd_os_almostcasesrch(ahdr->avp_value->os.data, ahdr->avp_value->os.len, fd_g_config->cnf_diamid, fd_g_config->cnf_diamid_len, NULL)) {
683 /* Yes: then we must return DIAMETER_LOOP_DETECTED according to Diameter RFC */
684 char * error = "DIAMETER_LOOP_DETECTED";
685 fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, error, fd_msg_pmdl_get(msgptr));
686 CHECK_FCT( return_error( &msgptr, error, NULL, NULL) );
687 return 0;
688 }
689 break;
690
691
666 } 692 }
667 } 693 }
668 694
669 /* Stop when we found all 3 AVPs -- they are supposed to be at the beginning of the message, so this should be fast */ 695 /* Stop when we found all 3 AVPs -- they are supposed to be at the beginning of the message, so this should be fast */
670 if ((is_dest_host != UNKNOWN) && (is_dest_realm != UNKNOWN) && un) 696 if ((is_dest_host != UNKNOWN) && (is_dest_realm != UNKNOWN) && un)
"Welcome to our mercurial repository"