| 3766 | } |
| 3767 | |
| 3768 | static int pv_set_msg_branch_attr(struct sip_msg* msg, pv_param_t *param, |
| 3769 | int op, pv_value_t *val) |
| 3770 | { |
| 3771 | int idx, idxf; |
| 3772 | int size, n, attr_name; |
| 3773 | unsigned short attr_flags; |
| 3774 | int_str attr_val; |
| 3775 | |
| 3776 | if (msg==NULL || param==NULL) { |
| 3777 | LM_ERR("bad parameters\n"); |
| 3778 | return -1; |
| 3779 | } |
| 3780 | |
| 3781 | if (msg->first_line.type == SIP_REPLY) |
| 3782 | return -1; |
| 3783 | |
| 3784 | if(pv_get_avp_name(msg, param, &attr_name, &attr_flags)!=0) { |
| 3785 | LM_ALERT("BUG in getting dst AVP name\n"); |
| 3786 | return -1; |
| 3787 | } |
| 3788 | |
| 3789 | /* get the index */ |
| 3790 | if (pv_get_spec_index(msg, param, &idx, &idxf)!=0) { |
| 3791 | LM_ERR("invalid index\n"); |
| 3792 | return -1; |
| 3793 | } |
| 3794 | |
| 3795 | if(idxf==PV_IDX_ALL) { |
| 3796 | LM_ERR("SCRIPT BUG - * not allowed in branch assignment\n"); |
| 3797 | return -1; |
| 3798 | } |
| 3799 | |
| 3800 | size = get_dset_size() + 1 /* ruri branch*/; |
| 3801 | /* if no branch set, consider the last one */ |
| 3802 | if (idxf==0 && idx==0) |
| 3803 | idx = size - 1; |
| 3804 | |
| 3805 | /* numerical index */ |
| 3806 | if (idx<0) { |
| 3807 | /* index from the end */ |
| 3808 | if (-idx > size) |
| 3809 | return -1; |
| 3810 | idx = size + idx; |
| 3811 | } |
| 3812 | |
| 3813 | if (!val || val->flags&PV_VAL_NULL) { |
| 3814 | attr_val.n = 0; //useless, makes compiler happy |
| 3815 | attr_flags |= AVP_VAL_NULL; |
| 3816 | } else |
| 3817 | if(val->flags&PV_TYPE_INT) { |
| 3818 | attr_val.n = val->ri; |
| 3819 | } else { |
| 3820 | attr_val.s = val->rs; |
| 3821 | attr_flags |= AVP_VAL_STR; |
| 3822 | } |
| 3823 | |
| 3824 | n = set_msg_branch_attr(idx, attr_name, attr_flags, attr_val); |
| 3825 |
nothing calls this directly
no test coverage detected