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

Function pv_get_msg_branch_attr

pvar.c:2315–2371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2313}
2314
2315static int pv_get_msg_branch_attr(struct sip_msg *msg, pv_param_t *param,
2316 pv_value_t *res)
2317{
2318 int idx, idxf;
2319 int size, n, attr_name;
2320 unsigned short attr_flags;
2321 int_str val;
2322
2323 if(msg==NULL || res==NULL || param==NULL)
2324 return -1;
2325
2326 if (pv_get_avp_name(msg, param, &attr_name, &attr_flags)!=0) {
2327 LM_ALERT("BUG in getting dst AVP name\n");
2328 return -1;
2329 }
2330
2331 /* get the index */
2332 if (pv_get_spec_index(msg, param, &idx, &idxf)!=0) {
2333 LM_ERR("invalid index\n");
2334 return -1;
2335 }
2336
2337 if (idxf==PV_IDX_ALL) {
2338 /* ALL - not supported */
2339 LM_ERR("ALL index not supported for attrs\n");
2340 return -1;
2341 }
2342
2343 size = get_dset_size() + 1 /* ruri branch*/;
2344 /* if no branch set, consider the last one */
2345 if (idxf==0 && idx==0)
2346 idx = size - 1;
2347
2348 /* numerical index */
2349 if (idx<0) {
2350 /* index from the end */
2351 if (-idx > size)
2352 return -1;
2353 idx = size + idx;
2354 }
2355
2356 n = get_msg_branch_attr( idx, attr_name, &attr_flags, &val);
2357 if ( n<0 || attr_flags&AVP_VAL_NULL)
2358 return pv_get_null(msg, param, res);
2359
2360 res->flags = PV_VAL_STR;
2361
2362 if (attr_flags & AVP_VAL_STR) {
2363 res->rs = val.s;
2364 } else {
2365 res->rs.s = sint2str(val.n, &res->rs.len);
2366 res->ri = val.n;
2367 res->flags |= PV_VAL_INT|PV_TYPE_INT;
2368 }
2369
2370 return 0;
2371}
2372

Callers

nothing calls this directly

Calls 6

pv_get_avp_nameFunction · 0.85
pv_get_spec_indexFunction · 0.85
get_dset_sizeFunction · 0.85
get_msg_branch_attrFunction · 0.85
pv_get_nullFunction · 0.85
sint2strFunction · 0.85

Tested by

no test coverage detected