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

Function _pv_get_tm_branch_field

modules/tm/tm.c:2553–2691  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2551
2552
2553static inline int _pv_get_tm_branch_field(struct sip_msg *msg,
2554 pv_param_t *param, pv_value_t *res, int field)
2555{
2556 struct cell *t;
2557 int idx, idxf;
2558 int_str attr_val;
2559 int attr_name;
2560 unsigned short attr_flags;
2561 struct usr_avp **old_list, *avp;
2562 int active_indexing = 0;
2563
2564 if(msg==NULL || res==NULL)
2565 return -1;
2566
2567 t = get_t();
2568 if (t==NULL || t==T_UNDEFINED)
2569 return -1;
2570
2571 /* get the index */
2572 if (param->pvn.type & BRANCH_IDX_ACTIVE_MASK) {
2573 active_indexing = 1;
2574 param->pvn.type &= ~BRANCH_IDX_ACTIVE_MASK;
2575 }
2576 if (pv_get_spec_index(msg, param, &idx, &idxf)!=0) {
2577 LM_ERR("invalid index\n");
2578 return -1;
2579 }
2580
2581 if (idxf==PV_IDX_ALL) {
2582 LM_ERR("STAR/ALL index not supported\n");
2583 return -1;
2584 }
2585
2586 if (idxf==0 && idx==0) {
2587 /* no index used at all, return for the current branch */
2588 idx = get_branch_index();
2589 } else {
2590 /* must be numerical index */
2591 if (active_indexing)
2592 idx += t->first_branch;
2593 if (idx<0) {
2594 /* index from the end */
2595 if (-idx > t->nr_of_outgoings) /* underflow */
2596 return pv_get_null(NULL, NULL, res);
2597 idx = t->nr_of_outgoings + idx;
2598 } else
2599 if (idx >= t->nr_of_outgoings) /*overflow*/
2600 return pv_get_null(NULL, NULL, res);
2601 }
2602
2603 /* we have a valid TM-branch index now */
2604 switch (field) {
2605 case BR_URI_ID: /* return URI */
2606 res->rs = TM_BRANCH(t,idx).uri;
2607 res->flags = PV_VAL_STR;
2608 break;
2609 case BR_Q_ID: /* return Q */
2610 res->rs.s = q2str(TM_BRANCH(t,idx).q, (unsigned int*)&res->rs.len);

Callers 10

pv_get_tm_branch_uriFunction · 0.85
pv_get_tm_branch_duriFunction · 0.85
pv_get_tm_branch_qFunction · 0.85
pv_get_tm_branch_pathFunction · 0.85
pv_get_tm_branch_flagsFunction · 0.85
pv_get_tm_branch_flagFunction · 0.85
pv_get_tm_branch_sockFunction · 0.85
pv_get_tm_branch_attrFunction · 0.85
pv_get_tm_branch_typeFunction · 0.85

Calls 10

get_tFunction · 0.85
pv_get_spec_indexFunction · 0.85
get_branch_indexFunction · 0.85
pv_get_nullFunction · 0.85
q2strFunction · 0.85
bitmask_to_flag_listFunction · 0.85
pv_get_avp_nameFunction · 0.85
set_avp_listFunction · 0.85
search_first_avpFunction · 0.85
sint2strFunction · 0.85

Tested by

no test coverage detected