<br><br><div class="gmail_quote">On Sat, Sep 18, 2010 at 11:49 AM, mayamatakeshi <span dir="ltr"><<a href="mailto:mayamatakeshi@gmail.com">mayamatakeshi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br><div class="gmail_quote"><div class="im">On Sat, Sep 18, 2010 at 7:57 AM, Stefano Pisani <span dir="ltr"><<a href="mailto:stefano.pisani@omnianet.it" target="_blank">stefano.pisani@omnianet.it</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
No I don't.<br>
I want that opensis uses same port of registration for INVITE.<br>
i.e. the client is register on port 5061, opensips uses from port 5061<br>
for INVITE<br></blockquote></div><div><br>If you are dealing with more than 2 ports, this might get complicated.<br>But in case of just 2 ports, you could check the ReceivedPort and set a bflag during handling of the REGISTER request:<br>
<br>if($Rp == 5060) {<br> setbflag(BFLAG_RECEIVED_ON_PORT_5060);<br>}<br><br>The bflags are saved with the registration, so you can check them in a branch_route called after lookup and force the port to be used to relay the request:<br>
<br>if (lookup("location")) {<br> t_on_branch("USER_BRANCH");<br> if (!t_relay()) {<br> sl_reply_error();<br> exit;<br> }<br>}<br><br>branch_route [USER_BRANCH] {<br> if (isbflagset(BFLAG_RECEIVED_ON_PORT_5060)) {<br>
force_send_socket(MY_IP_ADDRESS:5060);<br> } else {<br> force_send_socket(MY_IP_ADDRESS:5061);<br> }<br>}<br></div></div><br>(obs: I actually, never tested this. I'm writing from my recollections of similar problems I had to deal with).<br>
<br>
</blockquote></div><br>I looked at the docs. I'm not sure but maybe, the socket where the message was received will be available in the branch_route as $(branch(socket)):<br><br><a href="http://www.opensips.org/Resources/DocsCoreVar16#toc16">http://www.opensips.org/Resources/DocsCoreVar16#toc16</a><br>
<br>At least I can see this info being stored in the location table and I expect the branch processing to load it as it does with the bflags.<br>So maybe you can use just $(branch(socket)) in the call to force_send_socket:<br>
<br>force_send_socket($(branch(socket)));<br><br>(I don't know if it is necessary to remove the "sip:" prefix from the socket info).<br><br>