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

Function parse_from_header

parser/parse_from.c:46–90  ·  view source on GitHub ↗

* This method is used to parse the from header. It was decided not to parse * anything in core that is not *needed* so this method gets called by * rad_acc module and any other modules that needs the FROM header. * * params: msg : sip msg * returns =0 on success, * <0 on failure. */

Source from the content-addressed store, hash-verified

44 * <0 on failure.
45 */
46int parse_from_header( struct sip_msg *msg)
47{
48 struct to_body* from_b;
49
50 if ( !msg->from && ( parse_headers(msg,HDR_FROM_F,0)==-1 || !msg->from)) {
51 LM_ERR("bad msg or missing FROM header\n");
52 goto error;
53 }
54
55 /* maybe the header is already parsed! */
56 if (msg->from->parsed)
57 return 0;
58
59 /* bad luck! :-( - we have to parse it */
60 /* first, get some memory */
61 from_b = pkg_malloc(sizeof(struct to_body));
62 if (from_b == 0) {
63 LM_ERR("out of pkg_memory\n");
64 goto error;
65 }
66
67 /* now parse it!! */
68 memset(from_b, 0, sizeof(struct to_body));
69 parse_to(msg->from->body.s,msg->from->body.s+msg->from->body.len+1,from_b);
70 if (from_b->error == PARSE_ERROR) {
71 LM_ERR("bad from header\n");
72 pkg_free(from_b);
73 set_err_info(OSER_EC_PARSER, OSER_EL_MEDIUM,
74 "error parsing From header");
75 set_err_reply(400, "bad header");
76 goto error;
77 }
78 /* REGISTER doesn't have a from tag :( -bogdan
79 if (from_b->tag_value.len==0 || from_b->tag_value.s==0) {
80 LM_ERR("missing TAG value\n");
81 free_to(from_b);
82 goto error;
83 }
84 */
85 msg->from->parsed = from_b;
86
87 return 0;
88error:
89 return -1;
90}
91
92/**
93 *

Callers 15

pv_get_from_attrFunction · 0.85
pv_get_acc_usernameFunction · 0.85
set_sl_branchFunction · 0.85
validate_msgFunction · 0.85
allow_routingFunction · 0.85
allow_uriFunction · 0.85
restore_uriFunction · 0.85
replace_callbackFunction · 0.85
restore_uris_replyFunction · 0.85
w_replace_fromFunction · 0.85
Notify2XmppFunction · 0.85
update_contactFunction · 0.85

Calls 3

parse_toFunction · 0.85
set_err_infoFunction · 0.85
set_err_replyFunction · 0.85

Tested by

no test coverage detected