... the code explained in my previous email...<br><br><br># Debugging mode:<br>debug=9<br>memlog=6<br>fork=yes<br>auto_aliases=no<br>log_stderror=no<br><br>disable_dns_blacklist=yes<br><br>listen=<a href="http://10.122.54.163:5060">10.122.54.163:5060</a><br>
# alias=OSIPS_REALM<br>#port=OSIPS_PORT<br><br><br>sip_warning=0<br>#server_header="SRV_SIGNATURE"<br>#user_agent_header="PP_USER_AGENT"<br><br>#mhomed=yes<br>#memlog=2<br>check_via=no<br>dns=off<br>rev_dns=off<br>
children=8<br>disable_tcp=yes<br>log_facility=LOG_LOCAL0<br># for more info: opensips -h<br><br># ------------------ module loading ----------------------------------<br><br>mpath="/opt/opensipsnotls/lib/opensips/modules/"<br>
<br>#loadmodule "db_mysql.so"<br>#loadmodule "xlog.so"<br>loadmodule "textops.so"<br>loadmodule "maxfwd.so"<br>loadmodule "rr.so"<br>loadmodule "sl.so"<br>loadmodule "tm.so"<br>
loadmodule "signaling.so"<br>loadmodule "b2b_entities.so"<br>loadmodule "b2b_logic.so"<br>loadmodule "usrloc.so"<br>loadmodule "registrar.so"<br>loadmodule "mi_fifo.so"<br>
loadmodule "dispatcher.so"<br>loadmodule "uri.so"<br><br># ----------------- setting module-specific parameters ---------------<br>modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")<br>
<br><br>#modparam("usrloc", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")<br>#modparam("usrloc", "db_mode", 2)<br><br>modparam("tm", "pass_provisional_replies", 1)<br>
<br>modparam("dispatcher", "list_file", "/opt/opensipsnotls/etc/opensips/dispatcher.list")<br><br>modparam("b2b_entities", "server_address", "sip:<a href="http://10.122.54.163:5060">10.122.54.163:5060</a>")<br>
<br>#modparam("b2b_logic", "script_scenario", "/home/anca/work/opensips/modules/b2b_logic/scenario_script.xml")<br>#modparam("b2b_logic", "extern_scenario", "/home/anca/work/opensips/modules/b2b_logic/scenario_extern.xml")<br>
modparam("b2b_entities", "script_req_route", "b2b_request")<br>modparam("b2b_entities", "script_reply_route", "b2b_reply")<br><br>route[b2b_request] {<br> xlog("b2b_request ($ci)\n");<br>
}<br><br><br>route[b2b_reply] {<br> xlog("b2b_reply ($ci)\n");<br>}<br><br><br>route {<br><br> xlog("mozaa - Here we go...");<br><br> if (!mf_process_maxfwd_header("10")) {<br> sl_send_reply("483","Too Many Hops");<br>
exit;<br> };<br><br> if (msg:len >= 2380 ) {<br> sl_send_reply("513", "Message too big");<br> exit;<br> };<br><br> if (!method=="REGISTER")<br> record_route();<br><br> # subsequent messages withing a dialog should take the<br>
# path determined by record-routing<br> if (loose_route()) {<br> # mark routing logic in request<br> xlog("mozaa - Is loose...");<br> append_hf("P-hint: rr-enforced\r\n"); <br> route(1);<br>
};<br><br> xlog("mozaa ft - [$ft]");<br> xlog("mozaa fu - [$fu]");<br> xlog("mozaa tt - [$tt]");<br> xlog("mozaa tu - [$tu]");<br> xlog("mozaa du - [$du]");<br> xlog("mozaa si - [$si]");<br>
xlog("mozaa src_ip - [$src_ip]");<br> if(has_totag()) {<br> xlog("mozaa - has to tag");<br> }<br><br> if(is_method("INVITE") && !has_totag() && <br> !(src_ip == "10.122.54.163" && src_port ==5060)) /* skip Invite messages generated by the server*/<br>
{<br> $var(to) = $tu;<br> $var(to) = $(var(to){s.substr,4,0});<br> $var(to) = $(var(to){s.select,0,@});<br> $var(proxy_public_addr) = $(var(to){s.select,1,@});<br><br> xlog("mozaa to - [$var(to)]");<br>
xlog("mozaa contact - $hdr(Contact)");<br><br> $var(from) = $fu;<br> $var(from) = $(var(from){s.substr,4,0});<br><br> if($var(to)=="VOIP_PROVIDER_PHONE_NUMBER") {<br> xlog("mozaa x - SPAIN");<br>
if ( subst('/^From:(.*)sip:[^@]*@[a-zA-Z0-9.]+(.*)$/From:\1sip:34$var(from)\2/ig') ) {<br> xlog("mozaa from modified!");<br> };<br> } else {<br>
xlog("mozaa x - USA");<br> }<br><br># ds_select_dst("1", "0");<br><br> xlog("mozaa - Launching top hiding scenario");<br><br> b2b_init_request("top hiding");<br>
exit;<br> };<br><br># route(1);<br>}<br><br><br>route[1] {<br> # send it out now; use stateful forwarding as it works reliably<br> # even for UDP2TCP<br><br> xlog("mozaa - In route 1");<br> if (!t_relay()) {<br>
sl_reply_error();<br> };<br> exit;<br>}<br><br>local_route {<br><br> $var(to) = $tu;<br> $var(to) = $(var(to){s.substr,4,0});<br> $var(to) = $(var(to){s.select,0,@});<br><br> xlog("mozaa ft - local_route - [$ft]");<br>
xlog("mozaa fu - local_route - [$fu]");<br> xlog("mozaa tt - local_route - [$tt]");<br> xlog("mozaa tu - local_route - [$tu]");<br> xlog("mozaa du - local_route - [$du]");<br>
xlog("mozaa - local_route - to - [$var(to)]");<br><br> if (is_method("INVITE")) {<br><br> if($var(to)=="VOIP_PROVIDER_PHONE_NUMBER") {<br> xlog("mozaa x - local_route - SPAIN");<br>
if ( subst('/^From:(.*)sip:[^@]*@[a-zA-Z0-9.]+(.*)$/From:\1sip:34$var(from)\2/ig') ) {<br> xlog("mozaa - local_route - from modified!");<br> };<br> append_hf("P-Preferred-Service: app1\r\n");<br>
} else {<br> xlog("mozaa x - local_route - USA");<br> append_hf("P-Preferred-Service: app2\r\n");<br> }<br><br> ## THIS IS WHERE I TRY TO ESTABLISH THE DESTINATION OF THE INVITE REQUEST SENT BY THE B2BUA MODULE <br>
## TO THE INTERNAL IP OF MY JAIN SLEE SERVER (THE CALLEE IN THE TOP HIDING SCENARIO EXAMPLE)<br><br> xlog("mozaa - local_route - du before update = $du");<br> ##ds_select_dst("1", "0");<br>
##$du = "sip:<a href="http://10.253.22.143:5060">10.253.22.143:5060</a>";<br> rewriteuri("sip:<a href="http://10.253.22.143:5060">10.253.22.143:5060</a>");<br> xlog("mozaa - local_route - du after update = $du");<br>
<br> exit;<br> }<br><br>## if (is_method("BYE") ) {<br> ## acc_log_request("internally generated BYE");<br> ## }<br>}<br><br><div class="gmail_quote">On Mon, Oct 18, 2010 at 4:29 PM, David Santiago <span dir="ltr"><<a href="mailto:david.santiago@almiralabs.com">david.santiago@almiralabs.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;">Hi again,<br><br>I have made several changes to the script so that I can successfully add, for instance, a custom header to the INVITE request that the b2bua generates after receiving an external one. I'm doing it in a local_route block which is the supposed way to process an outgoing INVITE request that is going to be sent by the b2bua module, right?<br>
<br>but.. I'm not being able to set the destination of such INVITE to the place I want. I have tried the following:<br><ul><li>ds_select_dst() function: it works in the main route block, but it cannot be used in a local_route block.</li>
<li>modifying $du variable. I can successfully modify this variable, but it has no effect on where the INVITE is being sent to.</li><li>rewriteuri() function: same result as modifying $du variable.<br></li></ul>I need that outgoing INVITE to be sent to a specific host and port, but I do not see how to modify the current behaviour which is that the INVITE is being sent to the public ip address of the opensips server, which in turn generates a loop as that INVITE is processed by the b2bua and a new INVITE is sent out to that same address again.<br>
<br><br>Regards,<br><font color="#888888">David</font><div><div></div><div class="h5"><br><br><div class="gmail_quote">On Thu, Oct 14, 2010 at 9:08 AM, Anca Vamanu <span dir="ltr"><<a href="mailto:anca@opensips.org" target="_blank">anca@opensips.org</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;">
Hi David,<br>
<br>
The dispatcher is working right - just that if you use b2bua it doesn't<br>
have no effect as it does not use the newly set $du. Since it is sent<br>
again to your opensips you can do a filter after the source address of<br>
the message and do processing needed for the Invite going out if the<br>
source is itself.<br>
<br>
if (!has_totag() && is_method("INVITE") && !(src_ip=="MY_IP" &&<br>
src_port=="MY_PORT")) {<br>
<div> b2b_init_request("top hiding");<br>
exit;<br>
}<br>
</div>....<br>
the rest of the changes needed.<br>
<br>
Anyhow, I should add using the $du as the outbound proxy for the newly<br>
generated request on the features to implement list.<br>
<br>
Regards,<br>
<font color="#888888">Anca<br>
</font><div><div></div><div><br>
<br>
On 10/13/2010 12:19 PM, David Santiago wrote:<br>
> I'll check it later, but the fact is that I have to solve first the<br>
> problem that prevents the INVITEs generated by OpenSIPs to be sent to<br>
> the internal jain slee server.<br>
><br>
> I have confirmed that after the call to ds_select(), the value of $du<br>
> points to such server (which has been obtained from the<br>
> /opt/opensipsnotls/etc/opensips/dispatcher.list file), but the INVITEs<br>
> are not sent there, but to the public IP address of the OpenSIPs<br>
> server. Without the b2bua "setup", the dispatcher has been working<br>
> fine in other tests I've made...<br>
><br>
><br>
> Regards,<br>
> David<br>
><br>
> On Tue, Oct 12, 2010 at 11:22 AM, Anca Vamanu<<a href="mailto:anca@opensips.org" target="_blank">anca@opensips.org</a>> wrote:<br>
><br>
>> Hi David,<br>
>><br>
>> The only thing that won't work as you like is the append_hf - it won't<br>
>> work as you like since the b2bua module won't see that header. You need<br>
>> to do that for the new request generated by the b2bua and put that code<br>
>> in the local_route.<br>
>><br>
>> Regards,<br>
>><br>
>> --<br>
>> Anca Vamanu<br>
>> <a href="http://www.voice-system.ro" target="_blank">www.voice-system.ro</a><br>
>><br>
>><br>
>><br>
>> On 10/11/2010 01:48 PM, David Santiago wrote:<br>
>><br>
>>> Hi all,<br>
>>><br>
>>> After cleaning up the initialization problems in the b2bua related<br>
>>> modules I'm testing a configuration I want to use in order to enable<br>
>>> the "top hiding" scenario, plus using the dispatcher module so I can<br>
>>> configure the internal jain slee server that receives the requests<br>
>>> from the opensips proxy, like this:<br>
>>><br>
>>> VOIP PROVIDER<-------> OPENSIPS<-------> INTERNAL JAIN SLEE SERVER<br>
>>><br>
>>> I will write here the configuration I'm using, taken from the<br>
>>> configuration example available, that results in the INVITEs received<br>
>>> from the VOIP PROVIDER being sent by OPENSIPS to itself (to its public<br>
>>> address, in particular), ad infinitum.<br>
>>><br>
>>> The modparam("dispatcher", "list_file",<br>
>>> "/opt/opensipsnotls/etc/opensips/dispatcher.list") entry points to the<br>
>>> file required by the dispatcher module to determine the ip and port<br>
>>> where the internal jain slee server is running. Furthermore, our<br>
>>> service implementation requires the addition of the<br>
>>> P-Preferred-Service header, which is done with append_hf().<br>
>>><br>
>>> Any hint would be appreciated. Thanks in advance!<br>
>>><br>
>>><br>
>>><br>
>>> # Debugging mode:<br>
>>> debug=9<br>
>>> memlog=6<br>
>>> fork=yes<br>
>>> auto_aliases=no<br>
>>> log_stderror=no<br>
>>><br>
>>> disable_dns_blacklist=yes<br>
>>><br>
>>> listen=<a href="http://10.122.54.163:5060" target="_blank">10.122.54.163:5060</a> # private opensips ip<br>
>>> # alias=OSIPS_REALM<br>
>>> #port=OSIPS_PORT<br>
>>><br>
>>><br>
>>> sip_warning=0<br>
>>> #server_header="SRV_SIGNATURE"<br>
>>> #user_agent_header="PP_USER_AGENT"<br>
>>><br>
>>> #mhomed=yes<br>
>>> #memlog=2<br>
>>> check_via=no<br>
>>> dns=off<br>
>>> rev_dns=off<br>
>>> children=8<br>
>>> disable_tcp=yes<br>
>>> log_facility=LOG_LOCAL0<br>
>>> # for more info: opensips -h<br>
>>><br>
>>> # ------------------ module loading ----------------------------------<br>
>>><br>
>>> mpath="/opt/opensipsnotls/lib/opensips/modules/"<br>
>>><br>
>>> #loadmodule "db_mysql.so"<br>
>>> #loadmodule "xlog.so"<br>
>>> loadmodule "textops.so"<br>
>>> loadmodule "maxfwd.so"<br>
>>> loadmodule "rr.so"<br>
>>> loadmodule "sl.so"<br>
>>> loadmodule "tm.so"<br>
>>> loadmodule "signaling.so"<br>
>>> loadmodule "b2b_entities.so"<br>
>>> loadmodule "b2b_logic.so"<br>
>>> loadmodule "usrloc.so"<br>
>>> loadmodule "registrar.so"<br>
>>> loadmodule "mi_fifo.so"<br>
>>> loadmodule "dispatcher.so"<br>
>>><br>
>>> # ----------------- setting module-specific parameters ---------------<br>
>>> modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")<br>
>>><br>
>>><br>
>>> #modparam("usrloc", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")<br>
>>> #modparam("usrloc", "db_mode", 2)<br>
>>><br>
>>> modparam("tm", "pass_provisional_replies", 1)<br>
>>><br>
>>> modparam("dispatcher", "list_file",<br>
>>> "/opt/opensipsnotls/etc/opensips/dispatcher.list")<br>
>>><br>
>>> modparam("b2b_entities", "server_address",<br>
>>> "sip:MY_OPENSIPS_PUBLIC_IP_GOES_HERE:5060")<br>
>>><br>
>>><br>
>>> #modparam("b2b_logic", "script_scenario",<br>
>>> "/home/anca/work/opensips/modules/b2b_logic/scenario_script.xml")<br>
>>> #modparam("b2b_logic", "extern_scenario",<br>
>>> "/home/anca/work/opensips/modules/b2b_logic/scenario_extern.xml")<br>
>>> modparam("b2b_entities", "script_req_route", "b2b_request")<br>
>>> modparam("b2b_entities", "script_reply_route", "b2b_reply")<br>
>>><br>
>>> route[b2b_request] {<br>
>>> xlog("b2b_request ($ci)\n");<br>
>>> }<br>
>>><br>
>>><br>
>>> route[b2b_reply] {<br>
>>> xlog("b2b_reply ($ci)\n");<br>
>>> }<br>
>>><br>
>>><br>
>>> route {<br>
>>><br>
>>> xlog("mozaa - Here we go...");<br>
>>><br>
>>> if (!mf_process_maxfwd_header("10")) {<br>
>>> sl_send_reply("483","Too Many Hops");<br>
>>> exit;<br>
>>> };<br>
>>><br>
>>> if (msg:len>= 2380 ) {<br>
>>> sl_send_reply("513", "Message too big");<br>
>>> exit;<br>
>>> };<br>
>>><br>
>>> if (!method=="REGISTER")<br>
>>> record_route();<br>
>>><br>
>>> # subsequent messages withing a dialog should take the<br>
>>> # path determined by record-routing<br>
>>> if (loose_route()) {<br>
>>> # mark routing logic in request<br>
>>> append_hf("P-hint: rr-enforced\r\n");<br>
>>> route(1);<br>
>>> };<br>
>>><br>
>>> if(is_method("INVITE")&& /* only for Invite messages from bob*/<br>
>>> !(src_ip == "10.122.54.163"&& src_port ==5060)) /* skip<br>
>>> Invite messages generated by the server*/<br>
>>> {<br>
>>> # DO NOT call t_newtran() on this request -> it will result in the<br>
>>> transaction never being deleted<br>
>>> ##b2b_init_request("prepaid", "<a href="http://sip:320@opensips.org:5070" target="_blank">sip:320@opensips.org:5070</a>",<br>
>>> "<a href="http://sip:321@opensips.org:5070" target="_blank">sip:321@opensips.org:5070</a>");<br>
>>><br>
>>> xlog("mozaa ft - [$ft]");<br>
>>> xlog("mozaa fu - [$fu]");<br>
>>> xlog("mozaa tt - [$tt]");<br>
>>> xlog("mozaa tu - [$tu]");<br>
>>> xlog("mozaa du - [$du]");<br>
>>> xlog("mozaa si - [$si]");<br>
>>><br>
>>> $var(to) = $tu;<br>
>>> $var(to) = $(var(to){s.substr,4,0});<br>
>>> $var(to) = $(var(to){s.select,0,@});<br>
>>> $var(proxy_public_addr) = $(var(to){s.select,1,@});<br>
>>><br>
>>> xlog("mozaa to - [$var(to)]");<br>
>>><br>
>>> xlog("mozaa contact - $hdr(Contact)");<br>
>>><br>
>>> $var(from) = $fu;<br>
>>> $var(from) = $(var(from){s.substr,4,0});<br>
>>><br>
>>> if($var(to)=="THE_NUMBER_REGISTERED_IN_MY_VOIP_PROVIDER_GOES_HERE") {<br>
>>> xlog("mozaa x - SPAIN");<br>
>>> if (<br>
>>> subst('/^From:(.*)sip:[^@]*@[a-zA-Z0-9.]+(.*)$/From:\1sip:34$var(from)\2/ig')<br>
>>> ) {<br>
>>> xlog("mozaa from modified!");<br>
>>> };<br>
>>> append_hf("P-Preferred-Service: OneService\r\n");<br>
>>> } else {<br>
>>> xlog("mozaa x - USA");<br>
>>> append_hf("P-Preferred-Service: AnotherService\r\n");<br>
>>> }<br>
>>><br>
>>> ds_select_dst("1", "0");<br>
>>><br>
>>> xlog("mozaa - Launching top hiding scenario for du = $du");<br>
>>><br>
>>> b2b_init_request("top hiding");<br>
>>> exit;<br>
>>> };<br>
>>><br>
>>> if (!uri==myself) {<br>
>>> # mark routing logic in request<br>
>>> append_hf("P-hint: outbound\r\n");<br>
>>> route(1);<br>
>>> };<br>
>>><br>
>>><br>
>>> if (uri==myself) {<br>
>>><br>
>>> if (method=="REGISTER") {<br>
>>> save("location");<br>
>>> exit;<br>
>>> };<br>
>>><br>
>>> # native SIP destinations are handled using our USRLOC DB<br>
>>> if (!lookup("location")) {<br>
>>> sl_send_reply("404", "Not Found");<br>
>>> exit;<br>
>>> };<br>
>>> append_hf("P-hint: usrloc applied\r\n");<br>
>>> };<br>
>>><br>
>>> route(1);<br>
>>> }<br>
>>><br>
>>><br>
>>> route[1] {<br>
>>> # send it out now; use stateful forwarding as it works reliably<br>
>>> # even for UDP2TCP<br>
>>><br>
>>> if (!t_relay()) {<br>
>>> sl_reply_error();<br>
>>> };<br>
>>> exit;<br>
>>> }<br>
>>><br>
>>> _______________________________________________<br>
>>> Users mailing list<br>
>>> <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
>>> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
>>><br>
>>><br>
>> _______________________________________________<br>
>> Users mailing list<br>
>> <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
>> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
>><br>
>><br>
> _______________________________________________<br>
> Users mailing list<br>
> <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
><br>
><br>
<br>
<br>
</div></div>--<br>
<div>Anca Vamanu<br>
<a href="http://www.voice-system.ro" target="_blank">www.voice-system.ro</a><br>
<br>
<br>
</div><div><div></div><div>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>