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

Function _pv_set_tm_branch_field

modules/tm/tm.c:2755–2863  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2753
2754
2755static inline int _pv_set_tm_branch_field(struct sip_msg* msg,
2756 pv_param_t *param,int op, pv_value_t *val, int field)
2757{
2758 struct cell *t;
2759 int idx, idxf;
2760 int_str attr_val;
2761 int attr_name;
2762 unsigned int *flags;
2763 unsigned short attr_flags;
2764 struct usr_avp **old_list, *avp;
2765 int active_indexing = 0;
2766
2767 if(msg==NULL || param==NULL)
2768 return -1;
2769
2770 if (route_type!=BRANCH_ROUTE && route_type!=ONREPLY_ROUTE &&
2771 route_type!=FAILURE_ROUTE) {
2772 LM_ERR("illegal route type %d\n",route_type);
2773 return -1;
2774 }
2775
2776 t = get_t();
2777 if (t==NULL || t==T_UNDEFINED)
2778 return -1;
2779
2780 /* get the index */
2781 if (param->pvn.type & BRANCH_IDX_ACTIVE_MASK) {
2782 active_indexing = 1;
2783 param->pvn.type &= ~BRANCH_IDX_ACTIVE_MASK;
2784 }
2785 if (pv_get_spec_index(msg, param, &idx, &idxf)!=0) {
2786 LM_ERR("invalid index\n");
2787 return -1;
2788 }
2789
2790 if (idxf==PV_IDX_ALL) {
2791 LM_ERR("STAR/ALL index not supported\n");
2792 return -1;
2793 }
2794
2795 if (idxf==0 && idx==0) {
2796 /* no index used at all, return for the current branch */
2797 idx = get_branch_index();
2798 } else {
2799 /* must be numerical index */
2800 if (active_indexing)
2801 idx += t->first_branch;
2802 if (idx<0) {
2803 /* index from the end */
2804 if (-idx > t->nr_of_outgoings) /* underflow */
2805 return -1;
2806 idx = t->nr_of_outgoings + idx;
2807 } else
2808 if (idx >= t->nr_of_outgoings) /*overflow*/
2809 return -1;
2810 }
2811
2812 /* we have a valid TM-branch index now */

Callers 2

pv_set_tm_branch_flagFunction · 0.85
pv_set_tm_branch_attrFunction · 0.85

Calls 8

get_tFunction · 0.85
pv_get_spec_indexFunction · 0.85
get_branch_indexFunction · 0.85
pv_get_avp_nameFunction · 0.85
set_avp_listFunction · 0.85
search_first_avpFunction · 0.85
destroy_avpFunction · 0.85
add_avpFunction · 0.85

Tested by

no test coverage detected