# HG changeset patch # User Luke Mewburn # Date 1582068253 -39600 # Node ID c8057892e56bc06bd82ae4a34c444bbc32f93fd9 # Parent 67c263056d78fc5ccf755e053d92ed86a0dca451 adapt extensions to fd_msg_search_avp(struct avp) Remove now-unnecessary fd_avp_search_avp() implementations now that fd_msg_search_avp() can be used. TODO: rt_rewrite.fdx still uses own version because that does extra validation and logging (that may or may not be necessary). diff -r 67c263056d78 -r c8057892e56b contrib/test_Gx/main_gx.c --- a/contrib/test_Gx/main_gx.c Wed Feb 19 10:20:20 2020 +1100 +++ b/contrib/test_Gx/main_gx.c Wed Feb 19 10:24:13 2020 +1100 @@ -700,53 +700,6 @@ } -/* Search a given AVP model in an AVP (extracted from libfreediameter/message.c ) */ -int fd_avp_search_avp ( struct avp * groupedavp, struct dict_object * what, struct avp ** avp ) -{ - struct avp * nextavp; - struct avp_hdr * nextavphdr; - struct dict_avp_data dictdata; - - - TRACE_ENTRY("%p %p %p", groupedavp, what, avp); - - CHECK_FCT( fd_dict_getval(what, &dictdata) ); - - // Loop only in the group AVP - CHECK_FCT( fd_msg_browse(groupedavp, MSG_BRW_FIRST_CHILD, (void *)&nextavp, NULL) ); - CHECK_FCT( fd_msg_avp_hdr( nextavp, &nextavphdr ) ); - - while (nextavphdr) { - - if ( (nextavphdr->avp_code == dictdata.avp_code) && (nextavphdr->avp_vendor == dictdata.avp_vendor) ) // always 0 if no Vendor flag - { - break; - } - - // Otherwise move to next AVP in the grouped AVP - CHECK_FCT( fd_msg_browse(nextavp, MSG_BRW_NEXT, (void *)&nextavp, NULL) ); - - if(nextavp!=NULL) - { - CHECK_FCT( fd_msg_avp_hdr( nextavp, &nextavphdr ) ); - } - else - nextavphdr=NULL; - } - if (avp) - *avp = nextavp; - - if (avp && nextavp) { - struct dictionary * dict; - CHECK_FCT( fd_dict_getdict( what, &dict) ); - CHECK_FCT_DO( fd_msg_parse_dict( nextavp, dict, NULL ), ); - } - - if (avp || nextavp) - return 0; - else - return ENOENT; -} static int cca_cb( struct msg ** msg, struct avp * t_avp , @@ -784,7 +737,7 @@ CHECK_FCT(fd_msg_search_avp ( *msg, chrg_rule_grp, &g_avp )); - CHECK_FCT(fd_avp_search_avp(g_avp, chrg_rule_name, &avp)); + CHECK_FCT(fd_msg_search_avp(g_avp, chrg_rule_name, &avp)); if(avp) { CHECK_FCT(fd_msg_avp_hdr(avp, &avpdata)); diff -r 67c263056d78 -r c8057892e56b extensions/app_sip/app_sip.h --- a/extensions/app_sip/app_sip.h Wed Feb 19 10:20:20 2020 +1100 +++ b/extensions/app_sip/app_sip.h Wed Feb 19 10:24:13 2020 +1100 @@ -110,8 +110,6 @@ void DigestCalcResponse(HASHHEX HA1,char * pszNonce,char * pszNonceCount,char * pszCNonce,char * pszQop,char * pszMethod,char * pszDigestUri,HASHHEX HEntity,HASHHEX Response); void DigestCalcResponseAuth(HASHHEX HA1,char * pszNonce,char * pszNonceCount,char * pszCNonce,char * pszQop,char * pszMethod,char * pszDigestUri,HASHHEX HEntity,HASHHEX Response); -int fd_avp_search_avp ( struct avp * groupedavp, struct dict_object * what, struct avp ** avp ); - //thread procedure void *rtr_socket(void *); void *ppr_socket(void *); diff -r 67c263056d78 -r c8057892e56b extensions/app_sip/libapp_sip.c --- a/extensions/app_sip/libapp_sip.c Wed Feb 19 10:20:20 2020 +1100 +++ b/extensions/app_sip/libapp_sip.c Wed Feb 19 10:24:13 2020 +1100 @@ -66,54 +66,6 @@ return; } - -/* Search a given AVP model in an AVP (extracted from libfreediameter/message.c ) */ -int fd_avp_search_avp ( struct avp * groupedavp, struct dict_object * what, struct avp ** avp ) -{ - struct avp * nextavp; - struct avp_hdr * nextavphdr; - struct dict_avp_data dictdata; - - - TRACE_ENTRY("%p %p %p", groupedavp, what, avp); - - CHECK_FCT( fd_dict_getval(what, &dictdata) ); - - // Loop only in the group AVP - CHECK_FCT( fd_msg_browse(groupedavp, MSG_BRW_FIRST_CHILD, (void *)&nextavp, NULL) ); - CHECK_FCT( fd_msg_avp_hdr( nextavp, &nextavphdr ) ); - - while (nextavphdr) { - - if ( (nextavphdr->avp_code == dictdata.avp_code) && (nextavphdr->avp_vendor == dictdata.avp_vendor) ) // always 0 if no Vendor flag - { - break; - } - - // Otherwise move to next AVP in the grouped AVP - CHECK_FCT( fd_msg_browse(nextavp, MSG_BRW_NEXT, (void *)&nextavp, NULL) ); - - if(nextavp!=NULL) - { - CHECK_FCT( fd_msg_avp_hdr( nextavp, &nextavphdr ) ); - } - else - nextavphdr=NULL; - } - if (avp) - *avp = nextavp; - - if (avp && nextavp) { - struct dictionary * dict; - CHECK_FCT( fd_dict_getdict( what, &dict) ); - CHECK_FCT_DO( fd_msg_parse_dict( nextavp, dict, NULL ), ); - } - - if (avp || nextavp) - return 0; - else - return ENOENT; -} struct avp_hdr *walk_digest(struct avp *avp, int avp_code) { struct avp_hdr *temphdr=NULL; diff -r 67c263056d78 -r c8057892e56b extensions/app_sip/multimediaauth.c --- a/extensions/app_sip/multimediaauth.c Wed Feb 19 10:20:20 2020 +1100 +++ b/extensions/app_sip/multimediaauth.c Wed Feb 19 10:24:13 2020 +1100 @@ -320,7 +320,7 @@ //CHECK_FCT(fd_msg_browse ( avp, MSG_BRW_WALK, &avp, NULL) ); - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_CNonce, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_CNonce, &a2 )); if(a2!=NULL) found_cnonce=1; @@ -457,7 +457,7 @@ char * digest_username=NULL, *digest_uri=NULL, *digest_response=NULL, *digest_realm=NULL, *digest_nonce=NULL, *digest_method=NULL, *digest_qop=NULL, *digest_algorithm=NULL, *digest_cnonce=NULL, *digest_noncecount=NULL; - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Nonce, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Nonce, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); @@ -486,7 +486,7 @@ } } - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Response, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Response, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); @@ -500,7 +500,7 @@ } } - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Realm, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Realm, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); @@ -514,7 +514,7 @@ } } - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Method, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Method, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); @@ -530,7 +530,7 @@ else digest_method=""; - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_URI, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_URI, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); @@ -544,7 +544,7 @@ } } - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_QOP, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_QOP, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); @@ -559,7 +559,7 @@ } else digest_qop=NULL; - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Algorithm, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Algorithm, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); @@ -574,7 +574,7 @@ } else digest_algorithm=NULL; - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_CNonce, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_CNonce, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); @@ -589,7 +589,7 @@ } else digest_cnonce=""; - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Nonce_Count, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Nonce_Count, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); @@ -604,7 +604,7 @@ } else digest_noncecount=""; - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Username, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Username, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); diff -r 67c263056d78 -r c8057892e56b extensions/rt_rewrite/rt_rewrite.c --- a/extensions/rt_rewrite/rt_rewrite.c Wed Feb 19 10:20:20 2020 +1100 +++ b/extensions/rt_rewrite/rt_rewrite.c Wed Feb 19 10:24:13 2020 +1100 @@ -86,6 +86,7 @@ return; } +/* TODO: convert to fd_msg_search_avp ? */ static int fd_avp_search_avp(msg_or_avp *where, struct dict_object *what, struct avp **avp) { struct avp *nextavp; diff -r 67c263056d78 -r c8057892e56b extensions/test_sip/multimediaauth.c --- a/extensions/test_sip/multimediaauth.c Wed Feb 19 10:20:20 2020 +1100 +++ b/extensions/test_sip/multimediaauth.c Wed Feb 19 10:24:13 2020 +1100 @@ -335,7 +335,7 @@ //CHECK_FCT(fd_msg_browse ( avp, MSG_BRW_WALK, &avp, NULL) ); - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_CNonce, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_CNonce, &a2 )); if(a2!=NULL) found_cnonce=1; @@ -472,7 +472,7 @@ char * digest_username=NULL, *digest_uri=NULL, *digest_response=NULL, *digest_realm=NULL, *digest_nonce=NULL, *digest_method=NULL, *digest_qop=NULL, *digest_algorithm=NULL, *digest_cnonce=NULL, *digest_noncecount=NULL; - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Nonce, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Nonce, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); @@ -501,7 +501,7 @@ } } - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Response, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Response, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); @@ -515,7 +515,7 @@ } } - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Realm, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Realm, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); @@ -529,7 +529,7 @@ } } - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Method, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Method, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); @@ -545,7 +545,7 @@ else digest_method=""; - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_URI, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_URI, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); @@ -559,7 +559,7 @@ } } - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_QOP, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_QOP, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); @@ -574,7 +574,7 @@ } else digest_qop=NULL; - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Algorithm, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Algorithm, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); @@ -589,7 +589,7 @@ } else digest_algorithm=NULL; - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_CNonce, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_CNonce, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); @@ -604,7 +604,7 @@ } else digest_cnonce=""; - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Nonce_Count, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Nonce_Count, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) ); @@ -619,7 +619,7 @@ } else digest_noncecount=""; - CHECK_FCT(fd_avp_search_avp (avp, sip_dict.Digest_Username, &a2 )); + CHECK_FCT(fd_msg_search_avp (avp, sip_dict.Digest_Username, &a2 )); if(a2!=NULL) { CHECK_FCT( fd_msg_avp_hdr( a2, &digestheader ) );