I think, there is somewhere a bug in the add_header function.<br><br>Because if I try to get the from Header (get_header(req, "From"); ) of an INVITE message I get the following output (with manipulated get_header() below):
<br><br>This is 0. for run: INVITE <a href="mailto:sip:4961319208114@hecker.dynalias.com">sip:4961319208114@hecker.dynalias.com</a> SIP/2.0<br>Via: SIP/2.0/UDP <a href="http://192.168.178.31:5060">192.168.178.31:5060</a>;branch=z9hG4bK436ce926;rport
<br>From: "asterisk" <<a href="mailto:sip:asterisk@192.168.178.31">sip:asterisk@192.168.178.31</a>>;tag=as2e3188a0<br>To: <<a href="mailto:sip:4961319208114@hecker.dynalias.com">sip:4961319208114@hecker.dynalias.com
</a>><br>Contact: <<a href="mailto:sip:asterisk@192.168.178.31">sip:asterisk@192.168.178.31</a>><br>Call-ID: <a href="mailto:1ab26a851ba858441987f18d5beab90e@192.168.178.31">1ab26a851ba858441987f18d5beab90e@192.168.178.31
</a><br>CSeq: 102 INVITE<br>User-Agent: Asterisk PBX<br>Max-Forwards: 70<br> <br>This is 1. for run: Via: SIP/2.0/UDP <a href="http://192.168.178.31:5060">192.168.178.31:5060</a>;branch=z9hG4bK436ce926;rport<br>From: "asterisk" <
<a href="mailto:sip:asterisk@192.168.178.31">sip:asterisk@192.168.178.31</a>>;tag=as2e3188a0<br>To: <<a href="mailto:sip:4961319208114@hecker.dynalias.com">sip:4961319208114@hecker.dynalias.com</a>><br>Contact: <
<a href="mailto:sip:asterisk@192.168.178.31">sip:asterisk@192.168.178.31</a>><br>Call-ID: <a href="mailto:1ab26a851ba858441987f18d5beab90e@192.168.178.31">1ab26a851ba858441987f18d5beab90e@192.168.178.31</a><br>CSeq: 102 INVITE
<br>User-Agent: Asterisk PBX<br>Max-Forwards: 70<br> <br>This is 2. for run: (null) <br>Segmentation fault (core dumped)<br><br>with the following code:<br>static const char *__get_header(const struct sip_request *req, const char *name, int *start)
<br>{<br> int pass;<br><br> for (pass = 0; name && pass < 2;pass++) {<br> int x, len = strlen(name);<br> for (x=*start; x<req->headers; x++) {<br> ast_verbose("This is %d for run: %s \n", x, req->header[x]);
<br> if (!strncasecmp(req->header[x], name, len)) { <br> char *r = req->header[x] + len; /* skip name */<br> <br> if (pedanticsipchecking)<br> r = ast_skip_blanks(r);
<br> if (*r == ':') {<br> *start = x+1;<br> return ast_skip_blanks(r+1);<br> }<br> }<br> }<br> if (pass == 0) /* Try aliases */
<br> name = find_alias(name, NULL);<br> }<br> /* Don't return NULL, so get_header is always a valid pointer */<br> return "";<br>}<br><br>So, if it finds the right line segfault occurs because the header[2] pointer is set to null.
<br><br>But I'm not good enough to find the reason, why this pointer isn't set up correctly..<br>Any hints?<br><br>Thank you!<br><br><br><div><span class="gmail_quote">On 15/03/07, <b class="gmail_sendername">Thomas Hecker
</b> <<a href="mailto:thomas.hecker@gmail.com">thomas.hecker@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>at the end of chan_sip.c's initreqprep() function all the headers are added to the sip message:<br><br> add_header(req, "To", to);<br> ast_string_field_set(p, exten, l);<br> build_contact(p);
<br> add_header(req, "Contact", p->our_contact);<br> add_header(req, "Call-ID", p->callid);<br> add_header(req, "CSeq", tmp);<br> add_header(req, "User-Agent", global_useragent);
<br> add_header(req, "Max-Forwards", DEFAULT_MAX_FORWARDS);<br><br>But when I try to get one of these values with a call to <br> get_header(req, "Contact") subsequent to the add_headers I get a segmentation fault.
<br><br>Anybody has an Idea why?<br><br>Thank you very much!<br><span class="sg">Thomas Hecker<br>
</span></blockquote></div><br>