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

Function parse_ppi_header

parser/parse_ppi.c:41–79  ·  view source on GitHub ↗

* This method is used to parse P-Preferred-Identity header (RFC 3325). * * params: msg : sip msg * returns 0 on success, * -1 on failure. */

Source from the content-addressed store, hash-verified

39 * -1 on failure.
40 */
41int parse_ppi_header( struct sip_msg *msg )
42{
43 struct to_body* ppi_b;
44
45 if ( !msg->ppi &&
46 (parse_headers(msg, HDR_PPI_F,0)==-1 || !msg->ppi)) {
47 goto error;
48 }
49
50 /* maybe the header is already parsed! */
51 if (msg->ppi->parsed)
52 return 0;
53
54 /* bad luck! :-( - we have to parse it */
55 /* first, get some memory */
56 ppi_b = pkg_malloc(sizeof(struct to_body));
57 if (ppi_b == 0) {
58 LM_ERR("out of pkg_memory\n");
59 goto error;
60 }
61
62 /* now parse it!! */
63 parse_multi_to(msg->ppi->body.s,
64 msg->ppi->body.s + msg->ppi->body.len+1,
65 ppi_b);
66 if (ppi_b->error == PARSE_ERROR) {
67 LM_ERR("bad P-Preferred-Identity header\n");
68 pkg_free(ppi_b);
69 set_err_info(OSER_EC_PARSER, OSER_EL_MEDIUM,
70 "error parsing PPI header");
71 set_err_reply(400, "bad header");
72 goto error;
73 }
74 msg->ppi->parsed = ppi_b;
75
76 return 0;
77error:
78 return -1;
79}
80
81
82/**

Callers 4

pv_get_ppi_attrFunction · 0.85
found_CBNFunction · 0.85
w_sip_captureFunction · 0.85
parse_ppi_uriFunction · 0.85

Calls 3

parse_multi_toFunction · 0.85
set_err_infoFunction · 0.85
set_err_replyFunction · 0.85

Tested by

no test coverage detected