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

Function pv_get_ppi_attr

pvar.c:1351–1403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1349}
1350
1351static int pv_get_ppi_attr(struct sip_msg *msg, pv_param_t *param,
1352 pv_value_t *res)
1353{
1354 struct sip_uri *uri;
1355
1356 if(msg==NULL)
1357 return -1;
1358
1359 if(parse_ppi_header(msg) < 0) {
1360 LM_DBG("no P-Preferred-Identity header\n");
1361 return pv_get_null(msg, param, res);
1362 }
1363
1364 if(msg->ppi == NULL || get_ppi(msg) == NULL) {
1365 LM_DBG("no P-Preferred-Identity header\n");
1366 return pv_get_null(msg, param, res);
1367 }
1368
1369 if(param->pvn.u.isname.name.n == 1) { /* uri */
1370 return pv_get_strval(msg, param, res, &(get_ppi(msg)->uri));
1371 }
1372
1373 if(param->pvn.u.isname.name.n==4) { /* display name */
1374 if(get_ppi(msg)->display.s == NULL ||
1375 get_ppi(msg)->display.len <= 0) {
1376 LM_DBG("no P-Preferred-Identity display name\n");
1377 return pv_get_null(msg, param, res);
1378 }
1379 return pv_get_strval(msg, param, res, &(get_ppi(msg)->display));
1380 }
1381
1382 if((uri=parse_ppi_uri(msg))==NULL) {
1383 LM_ERR("cannot parse P-Preferred-Identity URI\n");
1384 return pv_get_null(msg, param, res);
1385 }
1386
1387 if(param->pvn.u.isname.name.n==2) { /* username */
1388 if(uri->user.s==NULL || uri->user.len<=0) {
1389 LM_DBG("no P-Preferred-Identity username\n");
1390 return pv_get_null(msg, param, res);
1391 }
1392 return pv_get_strval(msg, param, res, &uri->user);
1393 } else if(param->pvn.u.isname.name.n==3) { /* domain */
1394 if(uri->host.s==NULL || uri->host.len<=0) {
1395 LM_DBG("no P-Preferred-Identity domain\n");
1396 return pv_get_null(msg, param, res);
1397 }
1398 return pv_get_strval(msg, param, res, &uri->host);
1399 }
1400
1401 LM_ERR("unknown specifier\n");
1402 return pv_get_null(msg, param, res);
1403}
1404
1405static int pv_get_pai(struct sip_msg *msg, pv_param_t *param,
1406 pv_value_t *res)

Callers

nothing calls this directly

Calls 4

parse_ppi_headerFunction · 0.85
pv_get_nullFunction · 0.85
pv_get_strvalFunction · 0.85
parse_ppi_uriFunction · 0.85

Tested by

no test coverage detected