# HG changeset patch # User Sebastien Decugis # Date 1369646560 -28800 # Node ID 0b95a3afbfc378255628add563a4bb40157b9a90 # Parent 7a7ec1ad0c44a953920f78f97361844318f52d68 Return DIAMETER_LOOP_DETECTED if local peer is already in the Route-Record AVP of a new received request. diff -r 7a7ec1ad0c44 -r 0b95a3afbfc3 libfdcore/routing_dispatch.c --- a/libfdcore/routing_dispatch.c Thu May 23 16:11:35 2013 +0200 +++ b/libfdcore/routing_dispatch.c Mon May 27 17:22:40 2013 +0800 @@ -587,7 +587,7 @@ is_local_app = (app ? YES : NO); } - /* Parse the message for Dest-Host and Dest-Realm */ + /* Parse the message for Dest-Host, Dest-Realm, and Route-Record */ CHECK_FCT( fd_msg_browse(msgptr, MSG_BRW_FIRST_CHILD, &avp, NULL) ); while (avp) { struct avp_hdr * ahdr; @@ -663,6 +663,32 @@ un = avp; un_val = ahdr->avp_value; break; + + case AC_ROUTE_RECORD: + /* Parse this AVP */ + CHECK_FCT_DO( ret = fd_msg_parse_dict ( avp, fd_g_config->cnf_dict, &error_info ), + { + if (error_info.pei_errcode) { + fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, error_info.pei_message ?: error_info.pei_errcode, fd_msg_pmdl_get(msgptr)); + CHECK_FCT( return_error( &msgptr, error_info.pei_errcode, error_info.pei_message, error_info.pei_avp) ); + return 0; + } else { + fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, "Unspecified error while parsing Route-Record AVP", fd_msg_pmdl_get(msgptr)); + return ret; + } + } ); + ASSERT( ahdr->avp_value ); + /* Is this our own name ? */ + 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)) { + /* Yes: then we must return DIAMETER_LOOP_DETECTED according to Diameter RFC */ + char * error = "DIAMETER_LOOP_DETECTED"; + fd_hook_call(HOOK_MESSAGE_PARSING_ERROR, msgptr, NULL, error, fd_msg_pmdl_get(msgptr)); + CHECK_FCT( return_error( &msgptr, error, NULL, NULL) ); + return 0; + } + break; + + } }