<div dir="ltr">No, i was trying to fill msg-&gt;via2 using parse_via() but now, im
gonna try with a pre-script callback function (didnt known of their
existence) <br>
<br>
Thanks Daniel<br><br><div class="gmail_quote">On Tue, Sep 16, 2008 at 1:58 PM, Daniel-Constantin Mierla <span dir="ltr">&lt;<a href="mailto:miconda@gmail.com">miconda@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br>
<br>
On 09/16/08 18:42, Francisco Seratti wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
All my work is done in a module, and im parsing the Via header into (struct via_body *)via2 of the struct sip_msg of the reply message. That struct is used when forward_reply() is called:<br>
<br>
forward.c:568<br>
 &nbsp; &nbsp;/* we have to forward the reply stateless, so we need second via -bogdan*/<br>
 &nbsp; &nbsp;if (parse_headers( msg, HDR_VIA2_F, 0 )==-1<br>
 &nbsp; &nbsp; &nbsp; &nbsp;|| (msg-&gt;via2==0) || (msg-&gt;via2-&gt;error!=PARSE_OK))<br>
 &nbsp; &nbsp;{<br>
 &nbsp; &nbsp; &nbsp; &nbsp;/* no second via =&gt; error */<br>
 &nbsp; &nbsp; &nbsp; &nbsp;LM_ERR(&quot;no 2nd via found in reply\n&quot;);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;goto error;<br>
 &nbsp; &nbsp;}<br>
</blockquote>
<br></div>
do you fill msg-&gt;via2 by yourself? Do you set the appropriate header flag?<br>
<br>
Cheers,<br>
Daniel<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c">
<br>
<br>
On Tue, Sep 16, 2008 at 12:28 PM, Daniel-Constantin Mierla &lt;<a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a> &lt;mailto:<a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>&gt;&gt; wrote:<br>

<br>
 &nbsp; &nbsp;Hello,<br>
<br>
<br>
 &nbsp; &nbsp;On 09/16/08 18:05, Francisco Seratti wrote:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Hello,<br>
 &nbsp; &nbsp; &nbsp; &nbsp; Im trying to hide my network topology by adding/removing Via<br>
 &nbsp; &nbsp; &nbsp; &nbsp;headers. I can remove the correct header, but when adding it,<br>
 &nbsp; &nbsp; &nbsp; &nbsp;in replies, im having trouble with the parse_via() function<br>
 &nbsp; &nbsp; &nbsp; &nbsp;and i cant figure out where&#39;s the problem.<br>
 &nbsp; &nbsp; &nbsp; &nbsp;To the moment, request are coming out from the proxy with only<br>
 &nbsp; &nbsp; &nbsp; &nbsp;one Via (the proxy addr), but when replies come in, they are<br>
 &nbsp; &nbsp; &nbsp; &nbsp;discarded because no 2nd via is found. So, im &quot;saving&quot; the<br>
 &nbsp; &nbsp; &nbsp; &nbsp;removed Via from the request, to be inserted later in the<br>
 &nbsp; &nbsp; &nbsp; &nbsp;response (using parse_via() into &nbsp;struct via_body *via2 of the<br>
 &nbsp; &nbsp; &nbsp; &nbsp;sip_msg).<br>
 &nbsp; &nbsp; &nbsp; &nbsp;The point is parse_via() waits 3 args: start of the header,<br>
 &nbsp; &nbsp; &nbsp; &nbsp;some &quot;end&quot; pointer, and the via_body struct for saving parsed<br>
 &nbsp; &nbsp; &nbsp; &nbsp;data. I think my problem is in that end pointer, as i could<br>
 &nbsp; &nbsp; &nbsp; &nbsp;see in msg_parse.c:116 it is the end of the entire msg, but<br>
 &nbsp; &nbsp; &nbsp; &nbsp;not sure.<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Ive tried many, many ways but i cant finally get via parsing<br>
 &nbsp; &nbsp; &nbsp; &nbsp;OK. Im getting &quot;ERROR:core:parse_via: &nbsp;invalid via - end of<br>
 &nbsp; &nbsp; &nbsp; &nbsp;header in state 14&quot; or different states (16). (i guarantee via<br>
 &nbsp; &nbsp; &nbsp; &nbsp;header is well formed).<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Could someone orientate me, to know where im failiing??<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Askme for any extra data if you need, thanks a lot!<br>
<br>
 &nbsp; &nbsp;the problem is that changes done to sip messages are not effective<br>
 &nbsp; &nbsp;in the script. Even if you add a via in the reply message, the<br>
 &nbsp; &nbsp;script interpreter works only on the sip message received, which<br>
 &nbsp; &nbsp;has only one via, therefore, openser does not have an address<br>
 &nbsp; &nbsp;where to forward the reply and discards it.<br>
<br>
 &nbsp; &nbsp;I assume you develop some module to hide the topology and have the<br>
 &nbsp; &nbsp;add/remove via logic there. You can try to register a pre-script<br>
 &nbsp; &nbsp;callback and add at least one via there. This callback is executed<br>
 &nbsp; &nbsp;before running the config script. There you can modify the<br>
 &nbsp; &nbsp;original sip message and re-initiate the entire sip message parsing.<br>
<br>
 &nbsp; &nbsp;Cheers,<br>
 &nbsp; &nbsp;Daniel<br>
<br>
 &nbsp; &nbsp;--  &nbsp; &nbsp;Daniel-Constantin Mierla<br>
 &nbsp; &nbsp;<a href="http://www.asipto.com" target="_blank">http://www.asipto.com</a><br>
<br>
<br></div></div>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
Devel mailing list<br>
<a href="mailto:Devel@lists.kamailio.org" target="_blank">Devel@lists.kamailio.org</a><br>
<a href="http://lists.kamailio.org/cgi-bin/mailman/listinfo/devel" target="_blank">http://lists.kamailio.org/cgi-bin/mailman/listinfo/devel</a><br>
 &nbsp;<br>
</blockquote><div><div></div><div class="Wj3C7c">
<br>
-- <br>
Daniel-Constantin Mierla<br>
<a href="http://www.asipto.com" target="_blank">http://www.asipto.com</a><br>
<br>
</div></div></blockquote></div><br></div>