Need Hint for Opensips as UDP/TCP Proxy

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Need Hint for Opensips as UDP/TCP Proxy

Spady#7
Hi all, i am trying to realize a TCP/UDP gateway, using Opensips 1.8.1, to connect a IPPBX to Lync Server 2010.

IPPBX<-------(Trunk SIP)------->OPENSIPS<-------(Trunk SIP)------->LYNC

Ip pbx does not support TCP protocol and Lync does support only TCP and TLS so i need a proxy to do this job.
For now calls can go in both direction but problem comes when from Lync side i try to put on hold the call.
Lync, for putting on hold, send a new INVITE with a=inactive in SDP body. IP Pbx does not support/understand this parameter and call can't go on hold. Ip PBX replies to this INVITE whit a 200 OK with a=sendrecv in SDP.
What I thought is using " if (status== 200) "  then rewrite SDP body from a=sendrecv ( PBX Side ) to a=inactive so that Lync can understand it and call goes on hold.
The problem is when Lync user wants to retrive call. Lync send again another INVITE, with a=sendrecv, IP PBX then reply with 200 OK and a=sendrecv BUT ( here is the problem ) Opensips code ( that i used before ) rewrite again 200 OK message changing a=sendrecv to a=inactive and RTP flow does not start ( as aspected ).
Does anyone have some good idea to solve this problem? Any ideas?
Hope I explained in a clear manner :-)

Thanks to all
Reply | Threaded
Open this post in threaded view
|

Re: Need Hint for Opensips as UDP/TCP Proxy

Binan83
Hi Spady,

You need something like true or false.

Use a dialog flag in this way:

flag idx is set    --->    The call is hold on    <---->    a=Inactive
If (is_dlg_flag_set(idx)) && (status==200)
{
    # Rewrite SDP
}


Dont forget to set the flag idx when receive Invite with a=Inactive.
and reset it when receive a=sendrecv.

// Binan

Från: spady <[hidden email]>
Till: [hidden email]
Skickat: måndag, 8 oktober 2012 19:42
Ämne: [OpenSIPS-Users] Need Hint for Opensips as UDP/TCP Proxy

Hi all, i am trying to realize a TCP/UDP gateway, using Opensips 1.8.1, to
connect a IPPBX to Lync Server 2010.

IPPBX<-------(Trunk SIP)------->OPENSIPS<-------(Trunk SIP)------->LYNC

Ip pbx does not support TCP protocol and Lync does support only TCP and TLS
so i need a proxy to do this job.
For now calls can go in both direction but problem comes when from Lync side
i try to put on hold the call.
Lync, for putting on hold, send a new INVITE with a=inactive in SDP body. IP
Pbx does not support/understand this parameter and call can't go on hold. Ip
PBX replies to this INVITE whit a 200 OK with a=sendrecv in SDP.
What I thought is using " if (status== 200) "  then rewrite SDP body from
a=sendrecv ( PBX Side ) to a=inactive so that Lync can understand it and
call goes on hold.
The problem is when Lync user wants to retrive call. Lync send again another
INVITE, with a=sendrecv, IP PBX then reply with 200 OK and a=sendrecv BUT (
here is the problem ) Opensips code ( that i used before ) rewrite again 200
OK message changing a=sendrecv to a=inactive and RTP flow does not start (
as aspected ).
Does anyone have some good idea to solve this problem? Any ideas?
Hope I explained in a clear manner :-)

Thanks to all



--
View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/Need-Hint-for-Opensips-as-UDP-TCP-Proxy-tp7582137.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users



_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
voipmagazine.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: Need Hint for Opensips as UDP/TCP Proxy

Spady#7
Hi Binan, thanks for reply.
I understood your idea and I am going to try but i don't know how to create a condition. let me explain:

I could do something like:
if (is_method(INVITE)) ...
... set_dlg_flag("3")
..

but how to tell to Opensips to check a=inactive / a=sendrecv ???
if(????(a=inactive))

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Need Hint for Opensips as UDP/TCP Proxy

Spady#7
Any idea?
Reply | Threaded
Open this post in threaded view
|

Re: Need Hint for Opensips as UDP/TCP Proxy

Binan83
Hi spady,

If  is_audio_on_hold() function returned true, this means the received message has an SDP body and at least one audio stream on hold. 

http://www.opensips.org/html/docs/modules/devel/sipmsgops.html#id292843

// Binan

Från: spady <[hidden email]>
Till: [hidden email]
Skickat: tisdag, 9 oktober 2012 22:39
Ämne: Re: [OpenSIPS-Users] Need Hint for Opensips as UDP/TCP Proxy

Any idea?



--
View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/Need-Hint-for-Opensips-as-UDP-TCP-Proxy-tp7582137p7582175.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users



_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
voipmagazine.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: Need Hint for Opensips as UDP/TCP Proxy

Spady#7
Hi Binan, seems your idea does not work. I post ngrep traces. Look at last 200OK from IP 172.16.55.100 (opensips) to IP 10.9.101.163 (lync). SDP still have "a=inactive".

Snippet of code:

branch_route[2] {
        if (is_method("INVITE") && is_audio_on_hold()) {
              xlog( "L_ERR", "########LOG: Setto la flag \n" );
          set_dlg_flag("7");
   }
   
          if (is_dlg_flag_set("7") && (status=="200")) {
                xlog( "L_ERR", "########LOG: SDP-ON-HOLD Sostituzione del parametro INACTIVE\n" );
    replace_body("a=sendrecv.", "a=inactive");
          }  

        xlog("new branch at $ru\n");
}



T 2012/10/10 11:45:56.587382 10.9.101.163:61892 -> 172.16.55.100:5060 [AP]
INVITE sip:172.16.52.51 SIP/2.0.
FROM: <sip:3707@172.16.55.100;user=phone>;epid=D430E933C4;tag=198e999071.
TO: <sip:172.16.52.51>;tag=8b30fc41e5be9ba91c2d8e1b152a7e9a.
CSEQ: 2 INVITE.
CALL-ID: 8fc28eebc1aa2e142dd34dd6d9f4713d@172.16.52.51.
MAX-FORWARDS: 70.
VIA: SIP/2.0/TCP 10.9.101.163:61892;branch=z9hG4bKa8eef17.
ROUTE: <sip:172.16.55.100;transport=tcp;r2=on;lr>,<sip:172.16.55.100;r2=on;lr>.
CONTACT: <sip:LYNC.lwtec.eu:5068;transport=Tcp;maddr=10.9.101.163;ms-opaque=dcf7ba7515f99f91>.
CONTENT-LENGTH: 255.
SUPPORTED: timer.
SUPPORTED: 100rel.
USER-AGENT: RTCC/4.0.0.0 MediationServer.
CONTENT-TYPE: application/sdp.
Session-Expires: 1800.
Min-SE: 90.
.
v=0.
o=- 115 3 IN IP4 10.9.101.163.
s=session.
c=IN IP4 10.9.101.163.
b=CT:1000.
t=0 0.
m=audio 56346 RTP/AVP 8 106.
c=IN IP4 10.9.101.163.
a=rtcp:56347.
a=label:Audio.
a=sendrecv.
a=rtpmap:8 PCMA/8000.
a=rtpmap:106 telephone-event/8000.
a=fmtp:106 0-16.


T 2012/10/10 11:45:56.591138 172.16.55.100:5060 -> 10.9.101.163:61892 [AP]
SIP/2.0 100 Giving a try.
FROM: <sip:3707@172.16.55.100;user=phone>;epid=D430E933C4;tag=198e999071.
TO: <sip:172.16.52.51>;tag=8b30fc41e5be9ba91c2d8e1b152a7e9a.
CSEQ: 2 INVITE.
CALL-ID: 8fc28eebc1aa2e142dd34dd6d9f4713d@172.16.52.51.
VIA: SIP/2.0/TCP 10.9.101.163:61892;branch=z9hG4bKa8eef17.
Server: OpenSIPS-Longwave.
Content-Length: 0.
.


U 2012/10/10 11:45:56.591494 172.16.55.100:5060 -> 172.16.52.51:5060
INVITE sip:172.16.52.51 SIP/2.0.
Record-Route: <sip:172.16.55.100;r2=on;lr>.
Record-Route: <sip:172.16.55.100;transport=tcp;r2=on;lr>.
FROM: <sip:3707@172.16.55.100;user=phone>;epid=D430E933C4;tag=198e999071.
TO: <sip:172.16.52.51>;tag=8b30fc41e5be9ba91c2d8e1b152a7e9a.
CSEQ: 2 INVITE.
CALL-ID: 8fc28eebc1aa2e142dd34dd6d9f4713d@172.16.52.51.
MAX-FORWARDS: 69.
Via: SIP/2.0/UDP 172.16.55.100;branch=z9hG4bKf65f.5b426246.0;i=5.
VIA: SIP/2.0/TCP 10.9.101.163:61892;branch=z9hG4bKa8eef17.
CONTACT: <sip:LYNC.lwtec.eu:5068;transport=Tcp;maddr=10.9.101.163;ms-opaque=dcf7ba7515f99f91>.
CONTENT-LENGTH: 255.
SUPPORTED: timer.
SUPPORTED: 100rel.
USER-AGENT: RTCC/4.0.0.0 MediationServer.
CONTENT-TYPE: application/sdp.
Session-Expires: 1800.
Min-SE: 90.
.
v=0.
o=- 115 3 IN IP4 10.9.101.163.
s=session.
c=IN IP4 10.9.101.163.
b=CT:1000.
t=0 0.
m=audio 56346 RTP/AVP 8 106.
c=IN IP4 10.9.101.163.
a=rtcp:56347.
a=label:Audio.
a=sendrecv.
a=rtpmap:8 PCMA/8000.
a=rtpmap:106 telephone-event/8000.
a=fmtp:106 0-16.


U 2012/10/10 11:45:56.604032 172.16.52.51:5060 -> 172.16.55.100:5060
SIP/2.0 100 Trying.
To: <sip:172.16.52.51>;tag=8b30fc41e5be9ba91c2d8e1b152a7e9a.
From: <sip:3707@172.16.55.100;user=phone>;tag=198e999071;epid=D430E933C4.
Call-ID: 8fc28eebc1aa2e142dd34dd6d9f4713d@172.16.52.51.
CSeq: 2 INVITE.
Via: SIP/2.0/UDP 172.16.55.100;branch=z9hG4bKf65f.5b426246.0;i=5.
Via: SIP/2.0/TCP 10.9.101.163:61892;branch=z9hG4bKa8eef17.
Content-Length: 0.
.


U 2012/10/10 11:45:56.626543 172.16.52.51:5060 -> 172.16.55.100:5060
SIP/2.0 200 OK.
Record-Route: <sip:172.16.55.100;r2=on;lr>.
Record-Route: <sip:172.16.55.100;transport=tcp;r2=on;lr>.
Content-Type: application/sdp.
Allow: INVITE, ACK, CANCEL, BYE, OPTIONS, PRACK, REFER, NOTIFY, UPDATE.
Contact: "Pippo" <sip:172.16.52.51>.
Require: timer.
Supported: 100rel,timer,from-change.
User-Agent: OXO_GW_820/044.001.
Session-Expires: 1800;refresher=uac.
P-Asserted-Identity: "Pippo" <sip:172.16.52.51>.
To: <sip:172.16.52.51>;tag=8b30fc41e5be9ba91c2d8e1b152a7e9a.
From: <sip:3707@172.16.55.100;user=phone>;tag=198e999071;epid=D430E933C4.
Call-ID: 8fc28eebc1aa2e142dd34dd6d9f4713d@172.16.52.51.
CSeq: 2 INVITE.
Via: SIP/2.0/UDP 172.16.55.100;branch=z9hG4bKf65f.5b426246.0;i=5.
Via: SIP/2.0/TCP 10.9.101.163:61892;branch=z9hG4bKa8eef17.
Content-Length: 219.
.
v=0.
o=default 1349862354 1349862356 IN IP4 172.16.52.51.
s=session.
c=IN IP4 172.16.52.51.
t=0 0.
m=audio 32000 RTP/AVP 8 106.
a=sendrecv.
a=rtpmap:106 telephone-event/8000.
a=fmtp:106 0-15.
a=ptime:30.
a=maxptime:90.


T 2012/10/10 11:45:56.627802 172.16.55.100:5060 -> 10.9.101.163:61892 [AP]
SIP/2.0 200 OK.
Record-Route: <sip:172.16.55.100;r2=on;lr>.
Record-Route: <sip:172.16.55.100;transport=tcp;r2=on;lr>.
Content-Type: application/sdp.
Allow: INVITE, ACK, CANCEL, BYE, OPTIONS, PRACK, REFER, NOTIFY, UPDATE.
Contact: "Pippo" <sip:172.16.52.51>.
Require: timer.
Supported: 100rel,timer,from-change.
User-Agent: OXO_GW_820/044.001.
Session-Expires: 1800;refresher=uac.
P-Asserted-Identity: "Pippo" <sip:172.16.52.51>.
To: <sip:172.16.52.51>;tag=8b30fc41e5be9ba91c2d8e1b152a7e9a.
From: <sip:3707@172.16.55.100;user=phone>;tag=198e999071;epid=D430E933C4.
Call-ID: 8fc28eebc1aa2e142dd34dd6d9f4713d@172.16.52.51.
CSeq: 2 INVITE.
Via: SIP/2.0/TCP 10.9.101.163:61892;branch=z9hG4bKa8eef17.
Content-Length: 218.
.
v=0.
o=default 1349862354 1349862356 IN IP4 172.16.52.51.
s=session.
c=IN IP4 172.16.52.51.
t=0 0.
m=audio 32000 RTP/AVP 8 106.
a=inactive
a=rtpmap:106 telephone-event/8000.
a=fmtp:106 0-15.
a=ptime:30.
a=maxptime:90.

Reply | Threaded
Open this post in threaded view
|

Re: Need Hint for Opensips as UDP/TCP Proxy

Spady#7
SOLVED!!
i was not reseted flag!!! :-(

This is the right code:

branch_route[2] {
        if (is_method("INVITE") && is_audio_on_hold()) {
             
          set_dlg_flag("7");
   } else {
          if (is_method("INVITE")){
        reset_dlg_flag("7");
           }
          }
          if (is_dlg_flag_set("7") && (status=="200")) {
               
    replace_body("a=sendrecv.", "a=inactive");
          }  

        xlog("new branch at $ru\n");
  }
Reply | Threaded
Open this post in threaded view
|

Re: Need Hint for Opensips as UDP/TCP Proxy

Binan83
great.


Från: spady <[hidden email]>
Till: [hidden email]
Skickat: onsdag, 10 oktober 2012 12:09
Ämne: Re: [OpenSIPS-Users] Need Hint for Opensips as UDP/TCP Proxy

SOLVED!!
i was not reseted flag!!! :-(

This is the right code:

branch_route[2] {
    if (is_method("INVITE") && is_audio_on_hold()) {
       
            set_dlg_flag("7");
      } else {
                if (is_method("INVITE")){
                  reset_dlg_flag("7");
              }
            }
        if (is_dlg_flag_set("7") && (status=="200")) {
       
      replace_body("a=sendrecv.", "a=inactive");
      } 

    xlog("new branch at $ru\n");
  }




--
View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/Need-Hint-for-Opensips-as-UDP-TCP-Proxy-tp7582137p7582187.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users



_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
voipmagazine.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: Need Hint for Opensips as UDP/TCP Proxy

Spady#7
This post was updated on .
I talked to early !! :-(
It's happening  a very strange thing.
Seems that this part of code is no more taken into account:

if (is_method("INVITE") || is_audio_on_hold()){
          set_dlg_flag("7");
         
   } else {
          if (is_method("INVITE")){
        reset_dlg_flag("7");
           }


I mean the part relating to "is_audio_on_hold()" infact, flag is no more reseted.
What can be changed? I can't understand!!
What is the condition for "is_audio_on_hold()" to work? I mean, the function "is_audio_on_hold()" which part of incoming SIP msg it looks for??
I tried to change also from " && " to " || " but it doesn't change anything

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Need Hint for Opensips as UDP/TCP Proxy

Binan83
You have changed && to  ||

//Binan


Från: spady <[hidden email]>
Till: [hidden email]
Skickat: onsdag, 10 oktober 2012 16:20
Ämne: Re: [OpenSIPS-Users] Need Hint for Opensips as UDP/TCP Proxy

I talked to early !! :-(
It's happening  a very strange thing.
Seems that this part of code is no more taken into account:

*if (is_method("INVITE") || is_audio_on_hold()){
            set_dlg_flag("7");
           
      } else {
                if (is_method("INVITE")){
                  reset_dlg_flag("7");
              }
*

I mean the part relating to "is_audio_on_hold()" infact, flag is no more
reseted.
What can be changed? I can't understand!!
What is the condition for "is_audio_on_hold()" to work? I mean, the function
"is_audio_on_hold()" which part of incoming SIP msg it looks for??

Thanks



--
View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/Need-Hint-for-Opensips-as-UDP-TCP-Proxy-tp7582137p7582196.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users



_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
voipmagazine.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: Need Hint for Opensips as UDP/TCP Proxy

Spady#7
Hi Binan,
as I said, i tried both methods but seems nothing is changing.
How can I test if seted flag is really seted? How can i show it on logs??
Reply | Threaded
Open this post in threaded view
|

Re: Need Hint for Opensips as UDP/TCP Proxy

Spady#7
SOLVED!!
It was because i have an error on dialog behaviour. For now I solved in this way, hope could be interesting for someone else:

branch_route[2] {
        if (is_method("INVITE") && is_audio_on_hold()){
                        if ( search_body("a=sendonly")){
          set_dlg_flag("7");
            } else {
              if ( search_body("a=inactive.")){
                 set_dlg_flag("8");
                   }
                 }    
          if (is_dlg_flag_set("7") && (status=="200")){
          replace_body("a=sendrecv.","a=recvonly");
              } else {
              if (is_dlg_flag_set("8") && (status=="200")){
          replace_body("a=sendrecv.","a=inactive");
          }
          }
    } else {
          if (is_method("INVITE")){
        reset_dlg_flag("7");
        reset_dlg_flag("8");
           }
         }
     }    

onreply_route[2] {
          if (is_dlg_flag_set("7") && (status=="200")){
         replace_body("a=sendrecv.","a=recvonly");
              } else {
              if (is_dlg_flag_set("8") && (status=="200")){
          replace_body("a=sendrecv.","a=inactive");
          }
          }  
        }