MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / set_msg_branch_attr

Function set_msg_branch_attr

dset.c:933–970  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

931
932
933int set_msg_branch_attr(unsigned int b_idx, int name_id,
934 unsigned short flags, int_str val)
935{
936 struct dset_ctx *dsct = get_dset_ctx();
937 struct usr_avp **attrs;
938 struct usr_avp *avp;
939 struct usr_avp** old_list;
940
941 /* if we have to set an ATTR for RURI branch, we need to have the dset
942 * allocated (as the attr holder is there) */
943 if (dsct==NULL && (b_idx!=0 || (b_idx==0 && _dst_malloc(&dsct)<0)) )
944 return -1;
945
946 if (b_idx==0)
947 attrs = &(dsct->ruri_attrs);
948 else if (b_idx-1 < get_dset_size())
949 attrs = &dsct->branches[b_idx - 1].branch.attrs;
950 else {
951 LM_DBG("index %d out of rante (available branches %d)\n",
952 b_idx, get_dset_size() );
953 return -1;
954 }
955
956 LM_DBG("setting attr [%d] on branch %d/ptr=%p\n",name_id, b_idx, attrs);
957
958 /* operate on the list of ATTRS/AVPS of the branch */
959 old_list = set_avp_list( attrs );
960
961 if ( (avp=search_first_avp( 0, name_id, NULL, 0))!=NULL )
962 destroy_avp(avp);
963
964 if ( !(flags&AVP_VAL_NULL) )
965 add_avp( flags, name_id, val);
966
967 set_avp_list( old_list );
968
969 return 1;
970}
971
972
973struct usr_avp **ruri_branch_attrs_head(void)

Callers 2

pv_set_msg_branch_attrFunction · 0.85
push_branchFunction · 0.85

Calls 6

_dst_mallocFunction · 0.85
get_dset_sizeFunction · 0.85
set_avp_listFunction · 0.85
search_first_avpFunction · 0.85
destroy_avpFunction · 0.85
add_avpFunction · 0.85

Tested by

no test coverage detected