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

Function pv_get_avp

pvar.c:2703–2857  ·  view source on GitHub ↗

* */

Source from the content-addressed store, hash-verified

2701 *
2702 */
2703static int pv_get_avp(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
2704{
2705 unsigned short name_type;
2706 int avp_name;
2707 int_str avp_value;
2708 struct usr_avp *avp;
2709 int_str avp_value0;
2710 struct usr_avp *avp0;
2711 int idx;
2712 int idxf;
2713 char *p;
2714 int n=0;
2715
2716 if(msg==NULL || res==NULL || param==NULL)
2717 return -1;
2718
2719 /* get the name */
2720 if(pv_get_avp_name(msg, param, &avp_name, &name_type)!=0)
2721 {
2722 LM_ERR("invalid name\n");
2723 return -1;
2724 }
2725 /* get the index */
2726 if(pv_get_spec_index(msg, param, &idx, &idxf)!=0)
2727 {
2728 LM_ERR("invalid index\n");
2729 return -1;
2730 }
2731 if (idxf==PV_IDX_APPEND)
2732 return pv_get_null(msg, param, res);
2733
2734 if ((avp=search_first_avp(name_type, avp_name, &avp_value, 0))==0)
2735 return pv_get_null(msg, param, res);
2736 res->flags = PV_VAL_STR;
2737
2738 if (idxf!=PV_IDX_ALL && idx==0)
2739 {
2740 if(avp->flags & AVP_VAL_STR) {
2741 res->rs = avp_value.s;
2742 } else if(avp->flags & AVP_VAL_NULL) {
2743 res->flags |= PV_VAL_NULL;
2744 } else {
2745 res->rs.s = sint2str(avp_value.n, &res->rs.len);
2746 res->ri = avp_value.n;
2747 res->flags |= PV_VAL_INT|PV_TYPE_INT;
2748 }
2749 return 0;
2750 }
2751
2752 /* print the entire AVP array */
2753 if(idxf==PV_IDX_ALL)
2754 {
2755 p = pv_local_buf;
2756
2757 /* separately handle the first AVP */
2758 if(avp->flags & AVP_VAL_STR) {
2759 res->rs = avp_value.s;
2760 } else if(avp->flags & AVP_VAL_NULL) {

Callers

nothing calls this directly

Calls 5

pv_get_avp_nameFunction · 0.85
pv_get_spec_indexFunction · 0.85
pv_get_nullFunction · 0.85
search_first_avpFunction · 0.85
sint2strFunction · 0.85

Tested by

no test coverage detected