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

Function pv_get_xto_attr

pvar.c:1047–1111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1045}
1046
1047static int pv_get_xto_attr(struct sip_msg *msg, pv_param_t *param,
1048 pv_value_t *res, struct to_body *xto, int type)
1049{
1050 struct sip_uri *uri;
1051 if(xto==NULL)
1052 return -1;
1053
1054 if(param->pvn.u.isname.name.n==1) /* uri */
1055 return pv_get_strval(msg, param, res, &xto->uri);
1056
1057 if(param->pvn.u.isname.name.n==4) /* tag */
1058 {
1059 if (xto->tag_value.s==NULL || xto->tag_value.len<=0)
1060 {
1061 LM_DBG("no Tag parameter\n");
1062 return pv_get_null(msg, param, res);
1063 }
1064 return pv_get_strval(msg, param, res, &xto->tag_value);
1065 }
1066
1067 if(param->pvn.u.isname.name.n==5) /* display name */
1068 {
1069 if(xto->display.s==NULL || xto->display.len<=0)
1070 {
1071 LM_DBG("no Display name\n");
1072 return pv_get_null(msg, param, res);
1073 }
1074 return pv_get_strval(msg, param, res, &xto->display);
1075 }
1076
1077 if(type==0)
1078 {
1079 if((uri=parse_to_uri(msg))==NULL)
1080 {
1081 LM_ERR("cannot parse To URI\n");
1082 return pv_get_null(msg, param, res);
1083 }
1084 } else {
1085 if((uri=parse_from_uri(msg))==NULL)
1086 {
1087 LM_ERR("cannot parse From URI\n");
1088 return pv_get_null(msg, param, res);
1089 }
1090 }
1091
1092 if(param->pvn.u.isname.name.n==2) /* username */
1093 {
1094 if(uri->user.s==NULL || uri->user.len<=0)
1095 {
1096 LM_DBG("no username\n");
1097 return pv_get_null(msg, param, res);
1098 }
1099 return pv_get_strval(msg, param, res, &uri->user);
1100 } else if(param->pvn.u.isname.name.n==3) /* domain */ {
1101 if(uri->host.s==NULL || uri->host.len<=0)
1102 {
1103 LM_DBG("no domain\n");
1104 return pv_get_null(msg, param, res);

Callers 2

pv_get_to_attrFunction · 0.85
pv_get_from_attrFunction · 0.85

Calls 4

pv_get_strvalFunction · 0.85
pv_get_nullFunction · 0.85
parse_to_uriFunction · 0.85
parse_from_uriFunction · 0.85

Tested by

no test coverage detected