start PV set functions *********/
| 3227 | |
| 3228 | /********* start PV set functions *********/ |
| 3229 | static int pv_set_avp(struct sip_msg* msg, pv_param_t *param, |
| 3230 | int op, pv_value_t *val) |
| 3231 | { |
| 3232 | int avp_name; |
| 3233 | int_str avp_val; |
| 3234 | int flags; |
| 3235 | unsigned short name_type; |
| 3236 | int idx, idxf; |
| 3237 | |
| 3238 | if(param==NULL) |
| 3239 | { |
| 3240 | LM_ERR("bad parameters\n"); |
| 3241 | return -1; |
| 3242 | } |
| 3243 | |
| 3244 | if(pv_get_avp_name(msg, param, &avp_name, &name_type)!=0) |
| 3245 | { |
| 3246 | LM_ALERT("BUG in getting dst AVP name\n"); |
| 3247 | goto error; |
| 3248 | } |
| 3249 | |
| 3250 | /* get the index */ |
| 3251 | if(pv_get_spec_index(msg, param, &idx, &idxf)!=0) |
| 3252 | { |
| 3253 | LM_ERR("invalid index\n"); |
| 3254 | return -1; |
| 3255 | } |
| 3256 | |
| 3257 | if(val == NULL) |
| 3258 | { |
| 3259 | if(op == COLONEQ_T || idxf == PV_IDX_ALL) |
| 3260 | destroy_avps(name_type, avp_name, 1); |
| 3261 | else |
| 3262 | { |
| 3263 | destroy_index_avp(name_type, avp_name, idx); |
| 3264 | } |
| 3265 | return 0; |
| 3266 | } |
| 3267 | |
| 3268 | if(op == COLONEQ_T || idxf == PV_IDX_ALL) |
| 3269 | destroy_avps(name_type, avp_name, 1); |
| 3270 | |
| 3271 | flags = name_type; |
| 3272 | if(val->flags&PV_TYPE_INT) |
| 3273 | { |
| 3274 | avp_val.n = val->ri; |
| 3275 | } else { |
| 3276 | avp_val.s = val->rs; |
| 3277 | flags |= AVP_VAL_STR; |
| 3278 | } |
| 3279 | |
| 3280 | if(idxf == PV_IDX_INT || idxf == PV_IDX_PVAR) /* if the avp is indexed */ |
| 3281 | { |
| 3282 | if(replace_avp(flags, avp_name, avp_val, idx)< 0) |
| 3283 | { |
| 3284 | LM_ERR("Failed to replace avp\n"); |
| 3285 | goto error; |
| 3286 | } |
nothing calls this directly
no test coverage detected