| 931 | |
| 932 | |
| 933 | int 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 | |
| 973 | struct usr_avp **ruri_branch_attrs_head(void) |
no test coverage detected