[OpenSIPS-Users] OCS-Asterisk Gateway tcp-to-udp

Steffen Görlach Steffen.Goerlach at connextis.de
Sun Nov 9 23:46:02 CET 2008


Hello Newsgroup,

I still got some issues with my OCS server. 
Ips:
x.x.116.2 Mediation Port:5060
x.x.116.15 Asterisk P:5060
x.x.116.16 Opensips P:5061

If I send from my Asterisk the SIP/UDP message destinated to Opensips IP, the opensips relays this packet to SIP/TCP to the OCS-Mediation Server,
So long so good.
But the SIP Information is still addressed to the Opensips, so the OCS won't accept this SIP-Message.
Log:
192.168.116.16 -> 192.168.116.2 SIP/SDP Request: INVITE sip:192.168.116.16:5061, with session description
Error: 
192.168.116.2 -> 192.168.116.16 SIP Status: 400 Get Request/To Sip Uri error.

Is there a way, to tell opensips, he should also change the SIP-Addresses to the point he relays it?
.

My actual opensips.cfg:

# main request routing logic

route{

                xlog( "L_ERR", "LOG: ROU time=[$Tf] contact header=[$ct] from uri=[$fu] request's method=[$rm] request's uri=[$ru] to uri=[$tu] sip message id=[$mi] ip source=[$src_ip]\n" );

	if (!mf_process_maxfwd_header("10")) {
		sl_send_reply("483","Too Many Hops");
		exit;
	}

	if (src_ip == 192.168.116.2) {
		#remove misleading CONTACT header line
		remove_hf("Contact");
		#remove UTF-8 information, as * is not able to process it properly
	        subst("/^(CONTENT-TYPE:.*);[ ]*charset=utf-8(.*)/\1\2/");
		#relay request to *
       		if (!t_relay("udp:192.168.116.15:5060")) {
			xlog("LOG: Goto asterisk  \n");
			sl_reply_error();
	       	}
        	xlog( "L_ERR", "LOG: AST time=[$Tf] contact header=[$ct] from uri=[$fu] request's method=[$rm] request's uri=[$ru] to uri=[$tu] sip message id=[$mi] ip source=[$src_ip]\n" );
	}
	else {
		#relay request to OCS	
		if (!t_relay("tcp:192.168.116.2:5060")  ) {
			xlog("LOG: Return to OCS \n");
			sl_reply_error();
	       	}
                xlog( "L_ERR", "LOG: OCS time=[$Tf] contact header=[$ct] from uri=[$fu] request's method=[$rm] request's uri=[$ru] to uri=[$tu] sip message id=[$mi] ip source=[$src_ip]\n" );	
	}

}

onreply_route {
	
                xlog( "L_ERR", "LOG: Orr time=[$Tf] contact header=[$ct] from uri=[$fu] request's method=[$rm] request's uri=[$ru] to uri=[$tu] sip message id=[$mi] ip source=[$src_ip]\n" );
	
exit;
}

branch_route[1] {
	xlog("LOG:new branch at $ru\n");
}

failure_route[1] {
	if (t_was_cancelled()) {
		exit;
	}
}
-----Ursprüngliche Nachricht-----
Von: users-bounces at lists.opensips.org [mailto:users-bounces at lists.opensips.org] Im Auftrag von Steffen Görlach
Gesendet: Freitag, 24. Oktober 2008 15:57
An: Bogdan-Andrei Iancu
Cc: users at lists.opensips.org
Betreff: Re: [OpenSIPS-Users] OCS-Asterisk Gateway tcp-to-udp

Hello Bogdan,

thanks for your quick response.
I commented out the route[1] and now, everything works.
Thx for your help.

Regards,
Steffen

-----Ursprüngliche Nachricht-----
Von: Bogdan-Andrei Iancu [mailto:bogdan at voice-system.ro] 
Gesendet: Freitag, 24. Oktober 2008 14:34
An: Steffen Görlach
Cc: users at lists.opensips.org
Betreff: Re: [OpenSIPS-Users] OCS-Asterisk Gateway tcp-to-udp

Hi Steffen,

Do you get the CANCEL on your opensips ? if so, do you see the xlog 
messages for the CANCEL?

Also looking at your script, I see a duplicate block - you do the 
routing in the main route and again in route[1] - you should remove the 
route[1] from your script.

Regards,
Bogdan

Steffen Görlach wrote:
>
> Hello to all,
>
> I`m trying to setup opensips as a gateway from Office Communication 
> Server (tcp) to Asterisk (udp). I followed this guide: 
> http://confluence.terena.org:8080/display/IPTelCB/3.2.7.+Tying+MS+OCS+with+Asterisk+through+OpenSER
>
> My Setup is:
>
> Trixbox with 2 IPs:
>
> 192.168.67.4 -> Asterisk (Port 5060)
>
> 192.168.67.5 -> Opensips (Port 5060)
>
> Office Communication Server 2007
>
> 192.168.67.83 -> OCS-Mediation-Server (Port 5060)
>
> This Setup can establish phone calls , but I got problems with the 
> SIP-Status messages. If I call from OCS-Phone to Asterisk Extension 
> and I cancel the Call, the Asterisk Phone don’t get this Cancel-Message.
>
> *How can I route all of the SIP-messages to the Asterisk and the other 
> way?*
>
> * *
>
> My log posts this ERROR (I don`t if this matters for my Problem):
>
> ERROR:core:forward_reply: no 2nd via found in reply
>
> * *
>
> Here is my opensips.cfg:
>
> #
>
> # $Id: opensips.cfg 4423 2008-06-27 10:25:01Z henningw $
>
> #
>
> # OpenSIPS basic configuration script
>
> # by Anca Vamanu <anca at voice-system.ro>
>
> #
>
> # Please refer to the Core CookBook at 
> http://www.opensips.org/dokuwiki/doku.php
>
> # for a explanation of possible statements, functions and parameters.
>
> #
>
> ####### Global Parameters #########
>
> debug=3
>
> log_stderror=no
>
> log_facility=LOG_LOCAL0
>
> fork=yes
>
> children=4
>
> /* uncomment the following lines to enable debugging */
>
> #debug=6
>
> #fork=no
>
> #log_stderror=yes
>
> /* uncomment the next line to disable TCP (default on) */
>
> disable_tcp=no
>
> /* uncomment the next line to enable the auto temporary blacklisting of
>
> not available destinations (default disabled) */
>
> #disable_dns_blacklist=no
>
> /* uncomment the next line to enable IPv6 lookup after IPv4 dns
>
> lookup failures (default disabled) */
>
> #dns_try_ipv6=yes
>
> /* uncomment the next line to disable the auto discovery of local aliases
>
> based on revers DNS on IPs (default on) */
>
> auto_aliases=no
>
> /* uncomment the following lines to enable TLS support (default off) */
>
> #disable_tls = no
>
> #listen = tls:your_IP:5061
>
> #tls_verify_server = 1
>
> #tls_verify_client = 1
>
> #tls_require_client_certificate = 0
>
> #tls_method = TLSv1
>
> #tls_certificate = "//etc/opensips/tls/user/user-cert.pem"
>
> #tls_private_key = "//etc/opensips/tls/user/user-privkey.pem"
>
> #tls_ca_list = "//etc/opensips/tls/user/user-calist.pem"
>
> #port=5061
>
> /* uncomment and configure the following line if you want opensips to
>
> bind on a specific interface/port/proto (default bind on all available) */
>
> listen=udp:192.168.67.5:5060
>
> listen=tcp:192.168.67.5:5060
>
> ####### Modules Section ########
>
> #set module path
>
> mpath="//lib/opensips/modules/"
>
> /* uncomment next line for MySQL DB support */
>
> #loadmodule "db_mysql.so"
>
> loadmodule "sl.so"
>
> loadmodule "tm.so"
>
> loadmodule "rr.so"
>
> loadmodule "maxfwd.so"
>
> loadmodule "usrloc.so"
>
> loadmodule "registrar.so"
>
> loadmodule "textops.so"
>
> loadmodule "mi_fifo.so"
>
> loadmodule "uri_db.so"
>
> loadmodule "uri.so"
>
> loadmodule "xlog.so"
>
> loadmodule "acc.so"
>
> /* uncomment next lines for MySQL based authentication support
>
> NOTE: a DB (like db_mysql) module must be also loaded */
>
> #loadmodule "auth.so"
>
> #loadmodule "auth_db.so"
>
> /* uncomment next line for aliases support
>
> NOTE: a DB (like db_mysql) module must be also loaded */
>
> #loadmodule "alias_db.so"
>
> /* uncomment next line for multi-domain support
>
> NOTE: a DB (like db_mysql) module must be also loaded
>
> NOTE: be sure and enable multi-domain support in all used modules
>
> (see "multi-module params" section ) */
>
> #loadmodule "domain.so"
>
> /* uncomment the next two lines for presence server support
>
> NOTE: a DB (like db_mysql) module must be also loaded */
>
> #loadmodule "presence.so"
>
> #loadmodule "presence_xml.so"
>
> # ----------------- setting module-specific parameters ---------------
>
> # ----- mi_fifo params -----
>
> modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
>
> # ----- rr params -----
>
> # add value to ;lr param to cope with most of the UAs
>
> modparam("rr", "enable_full_lr", 1)
>
> # do not append from tag to the RR (no need for this script)
>
> modparam("rr", "append_fromtag", 0)
>
> # ----- rr params -----
>
> modparam("registrar", "method_filtering", 1)
>
> /* uncomment the next line to disable parallel forking via location */
>
> # modparam("registrar", "append_branches", 0)
>
> /* uncomment the next line not to allow more than 10 contacts per AOR */
>
> #modparam("registrar", "max_contacts", 10)
>
> # ----- uri_db params -----
>
> /* by default we disable the DB support in the module as we do not need it
>
> in this configuration */
>
> modparam("uri_db", "use_uri_table", 0)
>
> modparam("uri_db", "db_url", "")
>
> # ----- acc params -----
>
> /* what sepcial events should be accounted ? */
>
> modparam("acc", "early_media", 1)
>
> modparam("acc", "report_ack", 1)
>
> modparam("acc", "report_cancels", 1)
>
> /* by default ww do not adjust the direct of the sequential requests.
>
> if you enable this parameter, be sure the enable "append_fromtag"
>
> in "rr" module */
>
> modparam("acc", "detect_direction", 0)
>
> /* account triggers (flags) */
>
> modparam("acc", "failed_transaction_flag", 3)
>
> modparam("acc", "log_flag", 1)
>
> modparam("acc", "log_missed_flag", 2)
>
> /* uncomment the following lines to enable DB accounting also */
>
> modparam("acc", "db_flag", 1)
>
> modparam("acc", "db_missed_flag", 2)
>
> ####### Routing Logic ########
>
> # main request routing logic
>
> route{
>
> if (!mf_process_maxfwd_header("10")) {
>
> sl_send_reply("483","Too Many Hops");
>
> exit;
>
> }
>
> if (loose_route()) {
>
> xlog("LOG: loose_route \n");
>
> append_hf("P-hint: rr-enforced\r\n");
>
> route(1);
>
> };
>
> if (!uri==myself)
>
> {
>
> append_hf("P-hint: outbound\r\n");
>
> route(1);
>
> }
>
> if (src_ip == 192.168.67.83) {
>
> #remove misleading CONTACT header line
>
> remove_hf("Contact");
>
> #remove UTF-8 information, as * is not able to process it properly
>
> subst("/^(CONTENT-TYPE:.*);[ ]*charset=utf-8(.*)/\1\2/");
>
> #relay request to *
>
> if (!t_relay("udp:192.168.67.4:5060")) {
>
> xlog("LOG:Goto asterisk \n");
>
> sl_reply_error();
>
> }
>
> }
>
> else {
>
> #relay request to OCS
>
> if (!t_relay("tcp:192.168.67.83:5060") ) {
>
> xlog("LOG:Return to OCS \n");
>
> sl_reply_error();
>
> }
>
> }
>
> route(1);
>
> }
>
> route[1] {
>
> xlog("LOG: Route 1 $src_ip \n");
>
> # If coming from OCS
>
> if (src_ip== 192.168.67.83)
>
> {
>
> if (method=="INVITE|BYE") {
>
> xlog("L_INFO", "*** invite from OCS M=$rm RURI=$ru F=$fu T=$tu IP=$si 
> ID=$ci\n");
>
> }
>
> xlog("LOG: t_relay Asterisk \n $src_ip \n");
>
> t_relay("udp:192.168.67.4:5060");
>
> }
>
> # else coming from Asterisk
>
> else {
>
> xlog("LOG: t_relay OCS \n $src_ip \n");
>
> t_relay("tcp:192.168.67.83:5060");
>
> };
>
> exit;
>
> }
>
> onreply_route {
>
> xlog("LOG: incoming reply \n $src_ip \n $tu \n");
>
> if (src_ip == 192.168.67.83) {
>
> #remove misleading CONTACT header line
>
> remove_hf("Contact");
>
> #remove UTF-8 information, as * is not able to process it properly
>
> subst("/^(CONTENT-TYPE:.*);[ ]*charset=utf-8(.*)/\1\2/");
>
> }
>
> exit;
>
> }
>
> branch_route[1] {
>
> xlog("LOG:new branch at $ru\n");
>
> }
>
> failure_route[1] {
>
> if (t_was_cancelled()) {
>
> exit;
>
> }
>
> }
>

_______________________________________________
Users mailing list
Users at lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


More information about the Users mailing list