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

Function parse_call_info_header

parser/parse_call_info.c:45–121  ·  view source on GitHub ↗

* This method is used to parse Call-Info header. * * params: msg : sip msg * returns 0 on success, * -1 on failure. */

Source from the content-addressed store, hash-verified

43 * -1 on failure.
44 */
45int parse_call_info_header( struct sip_msg *msg )
46{
47 struct call_info_body *callinfo_b, *old_callinfo_b=NULL;
48 struct to_body *call_info_b;
49 struct hdr_field *call_info;
50 void **parsed;
51 char *tmp, *end, *start;
52 unsigned int len;
53
54 if ( !msg->call_info &&
55 (parse_headers(msg, HDR_CALL_INFO_F,0)==-1 || !msg->call_info)) {
56 return -1;
57 }
58
59 call_info=msg->call_info;
60
61 /* maybe the header is already parsed! */
62 if (call_info->parsed)
63 return 0;
64
65 parsed = &(call_info->parsed);
66
67 while(*parsed == NULL)
68{
69
70 len = call_info->body.len+1;
71 start = call_info->body.s;
72 end = start + len;
73 LM_DBG("parsing the whole body [%.*s]\n", len, call_info->body.s);
74
75 for( tmp=call_info->body.s; tmp<=end; tmp++) {
76 if (*tmp == ',' || tmp==end) {
77 LM_DBG("[%.*s]\n",(int)(tmp-start),start);
78
79 callinfo_b = pkg_malloc(sizeof(struct call_info_body));
80 if (callinfo_b == NULL) {
81 LM_ERR("out of pkg_memory\n");
82 goto error;
83 }
84 memset(callinfo_b, 0, sizeof(struct call_info_body));
85
86 /* now parse it!! */
87 call_info_b = &(callinfo_b->call_info_body);
88 parse_to(start, tmp, call_info_b);
89 if (call_info_b->error == PARSE_ERROR) {
90 LM_ERR("bad Call-Info header\n");
91 pkg_free(call_info_b);
92 set_err_info(OSER_EC_PARSER, OSER_EL_MEDIUM,
93 "error parsing Call-Info header");
94 set_err_reply(400, "bad header");
95 goto error;
96 }
97
98 /* Save the first parsed body */
99 if (*parsed == NULL)
100 *parsed = callinfo_b;
101 else
102 old_callinfo_b->next = callinfo_b;

Callers 7

sca_dialog_sendpublishFunction · 0.85
sca_validate_call_outFunction · 0.85
sca_tm_sendpublishFunction · 0.85
callinfo_hdr_checkerFunction · 0.85
lineseize_subs_handlFunction · 0.85
get_app_indexFunction · 0.85
sca_logic_notifyFunction · 0.85

Calls 3

parse_toFunction · 0.85
set_err_infoFunction · 0.85
set_err_replyFunction · 0.85

Tested by

no test coverage detected