How opensis can manage different ports.

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

How opensis can manage different ports.

stefanoIT
  Hi all,
I return on an argument proposed a couple of weeks ago.
I have an installation of opensips binding on two ports (5060 and 5061).
Some client registers itself on 5060, others on 5061.
My wish is that opensips uses as from port the same port used by client
for registration.
Is it possible that?
At the moment opensips uses always 5060.

regards,
stefano

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

Re: How opensis can manage different ports.

Iñaki Baz Castillo
2010/9/15 Stefano <[hidden email]>:
> My wish is that opensips uses as from port the same port used by client
> for registration.
> Is it possible that?

Two points:

1) This doesn't amke sense. The client sends the REGISTER from some
port to some port of OpenSIPS. How would OpenSIPS change its receiving
port??

2) Why do you want something like that?

--
Iñaki Baz Castillo
<[hidden email]>

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

Re: How opensis can manage different ports.

Stefano Pisani
In reply to this post by stefanoIT
  I tried to use "mhomed = 1" but it doesn't work for me.
When a call arrives to opensips for a client registered on port 5061, he
forwards the call
using 5060 as from port and not 5061, so che call does not pass the
firewall.

regards,
stefano

Il 15/09/2010 14:05, Stefano ha scritto:

>    Hi all,
> I return on an argument proposed a couple of weeks ago.
> I have an installation of opensips binding on two ports (5060 and 5061).
> Some client registers itself on 5060, others on 5061.
> My wish is that opensips uses as from port the same port used by client
> for registration.
> Is it possible that?
> At the moment opensips uses always 5060.
>
> regards,
> stefano
>
> _______________________________________________
> 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
Reply | Threaded
Open this post in threaded view
|

Re: How opensis can manage different ports.

Stefano Pisani
In reply to this post by Iñaki Baz Castillo
  No I don't.
I want that opensis uses same port of registration for INVITE.
i.e. the client is register on port 5061, opensips uses from port 5061
for INVITE

regards,
s

Il 17/09/2010 01:33, Iñaki Baz Castillo ha scritto:
> 2010/9/15 Stefano<[hidden email]>:>  My wish is that opensips uses as from port the same port used by client>  for registration.>  Is it possible that?
> Two points:
> 1) This doesn't amke sense. The client sends the REGISTER from someport to some port of OpenSIPS. How would OpenSIPS change its receivingport??
> 2) Why do you want something like that?
> -- Iñaki Baz Castillo<[hidden email]>
> _______________________________________________Users mailing [hidden email]://lists.opensips.org/cgi-bin/mailman/listinfo/users
>

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

Re: How opensis can manage different ports.

mayamatakeshi

On Sat, Sep 18, 2010 at 7:57 AM, Stefano Pisani <[hidden email]> wrote:
 No I don't.
I want that opensis uses same port of registration for INVITE.
i.e. the client is register on port 5061, opensips uses from port 5061
for INVITE

If you are dealing with more than 2 ports, this might get complicated.
But in case of just 2 ports, you could check the ReceivedPort and set a bflag during handling of the REGISTER request:

if($Rp == 5060) {
  setbflag(BFLAG_RECEIVED_ON_PORT_5060);
}

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:

if (lookup("location")) {
  t_on_branch("USER_BRANCH");
  if (!t_relay()) {
    sl_reply_error();
    exit;
  }
}

branch_route [USER_BRANCH] {
  if (isbflagset(BFLAG_RECEIVED_ON_PORT_5060)) {
    force_send_socket(MY_IP_ADDRESS:5060);
   } else {
    force_send_socket(MY_IP_ADDRESS:5061);
  }
}

(obs: I actually, never tested this. I'm writing from my recollections of similar problems I had to deal with).


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

Re: How opensis can manage different ports.

mayamatakeshi


On Sat, Sep 18, 2010 at 11:49 AM, mayamatakeshi <[hidden email]> wrote:

On Sat, Sep 18, 2010 at 7:57 AM, Stefano Pisani <[hidden email]> wrote:
 No I don't.
I want that opensis uses same port of registration for INVITE.
i.e. the client is register on port 5061, opensips uses from port 5061
for INVITE

If you are dealing with more than 2 ports, this might get complicated.
But in case of just 2 ports, you could check the ReceivedPort and set a bflag during handling of the REGISTER request:

if($Rp == 5060) {
  setbflag(BFLAG_RECEIVED_ON_PORT_5060);
}

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:

if (lookup("location")) {
  t_on_branch("USER_BRANCH");
  if (!t_relay()) {
    sl_reply_error();
    exit;
  }
}

branch_route [USER_BRANCH] {
  if (isbflagset(BFLAG_RECEIVED_ON_PORT_5060)) {
    force_send_socket(MY_IP_ADDRESS:5060);
   } else {
    force_send_socket(MY_IP_ADDRESS:5061);
  }
}

(obs: I actually, never tested this. I'm writing from my recollections of similar problems I had to deal with).


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)):

http://www.opensips.org/Resources/DocsCoreVar16#toc16

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.
So maybe you can use just $(branch(socket)) in the call to force_send_socket:

force_send_socket($(branch(socket)));

(I don't know if it is necessary to remove the "sip:" prefix from the socket info).


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

Re: How opensis can manage different ports.

Andrew Pogrebennyk-3
In reply to this post by mayamatakeshi
On 18.09.2010 07:36, mayamatakeshi wrote:
> If you are dealing with more than 2 ports, this might get complicated.
> But in case of just 2 ports, you could check the ReceivedPort and set
> a bflag during handling of the REGISTER request:
>
> if($Rp == 5060) {
>   setbflag(BFLAG_RECEIVED_ON_PORT_5060);
> }

That's correct. It will also work with more than 2 ports, but you need
to enumerate each socket with a flag.

--
Sincerely,
Andrew Pogrebennyk

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

Re: How opensis can manage different ports.

Stefano Pisani
  Hi,
I solved it using field socket in location table and using $fs = this
socket before t_relay()
just in case of local lookup

Il 18/09/2010 06:43, Andrew Pogrebennyk ha scritto:

> On 18.09.2010 07:36, mayamatakeshi wrote:
>> If you are dealing with more than 2 ports, this might get complicated.
>> But in case of just 2 ports, you could check the ReceivedPort and set
>> a bflag during handling of the REGISTER request:
>>
>> if($Rp == 5060) {
>>    setbflag(BFLAG_RECEIVED_ON_PORT_5060);
>> }
> That's correct. It will also work with more than 2 ports, but you need
> to enumerate each socket with a flag.
>

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

Re: How opensis can manage different ports.

Kennard White

Hi Guys,

I don't understand why you need to do any of this (bflags,setting $fs). We listen on both port 5060 and 5062 of our public interface, and the registrar module handles all this internally. Specifically, we can receive an REGISTER on either port, and when an INVITE comes in for that user and it goes thru lookup(), then the outgoing INVITE will be sent on the same socket on which the REGISTER was received.

In registrar module, the save() function stores the received socket into the usrloc module, and the lookup() function retrieves it and stores that into the force_send_sock. The only thing I can see that would mess this up is if you use the 's' flag to save(), which will then try extracting the received sock from a header rather than using the actual received socket.

The relevant code registrar/save.c:240 and registrar/lookup.c:288.

Could you help me understand what it is you are attempting to do that the registrar module doesn't handle internally?

Thanks,
Kennard



Inactive hide details for Stefano Pisani ---09/18/2010 02:52:37 AM---  Hi, I solved it using field socket in location table andStefano Pisani ---09/18/2010 02:52:37 AM--- Hi, I solved it using field socket in location table and using $fs = this

From: Stefano Pisani <[hidden email]>
To: OpenSIPS users mailling list <[hidden email]>
Date: 09/18/2010 02:52 AM
Subject: Re: [OpenSIPS-Users] How opensis can manage different ports.
Sent by: [hidden email]





  Hi,
I solved it using field socket in location table and using $fs = this
socket before t_relay()
just in case of local lookup

Il 18/09/2010 06:43, Andrew Pogrebennyk ha scritto:
> On 18.09.2010 07:36, mayamatakeshi wrote:
>> If you are dealing with more than 2 ports, this might get complicated.
>> But in case of just 2 ports, you could check the ReceivedPort and set
>> a bflag during handling of the REGISTER request:
>>
>> if($Rp == 5060) {
>>    setbflag(BFLAG_RECEIVED_ON_PORT_5060);
>> }
> That's correct. It will also work with more than 2 ports, but you need
> to enumerate each socket with a flag.
>

_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: How opensis can manage different ports.

Bogdan-Andrei Iancu
In reply to this post by Andrew Pogrebennyk-3
Hi guys,

you do not have to do anything at all (for multiple ports) - the
save(location) function saves the socket the register was received on
(in the "socket" column in db). The lookup(location) function will force
this socket whenever a request needs to be sent to the end-point....

automagically, it works !

Regards,
Bogdan

Andrew Pogrebennyk wrote:

> On 18.09.2010 07:36, mayamatakeshi wrote:
>  
>> If you are dealing with more than 2 ports, this might get complicated.
>> But in case of just 2 ports, you could check the ReceivedPort and set
>> a bflag during handling of the REGISTER request:
>>
>> if($Rp == 5060) {
>>   setbflag(BFLAG_RECEIVED_ON_PORT_5060);
>> }
>>    
>
> That's correct. It will also work with more than 2 ports, but you need
> to enumerate each socket with a flag.
>
>  


--
Bogdan-Andrei Iancu
OpenSIPS Bootcamp
15 - 19 November 2010, Edison, New Jersey, USA
www.voice-system.ro


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

Re: How opensis can manage different ports.

Bogdan-Andrei Iancu
In reply to this post by Stefano Pisani
Hi Stefano

Stefano Pisani wrote:
>   I tried to use "mhomed = 1" but it doesn't work for me.
>  
this is for interface selection, not ports.
> When a call arrives to opensips for a client registered on port 5061, he
> forwards the call
> using 5060 as from port and not 5061, so che call does not pass the
> firewall.
>  
do you route your calls (INVITEs) based on lookup() information ?

Regards,
Bogdan

> regards,
> stefano
>
> Il 15/09/2010 14:05, Stefano ha scritto:
>  
>>    Hi all,
>> I return on an argument proposed a couple of weeks ago.
>> I have an installation of opensips binding on two ports (5060 and 5061).
>> Some client registers itself on 5060, others on 5061.
>> My wish is that opensips uses as from port the same port used by client
>> for registration.
>> Is it possible that?
>> At the moment opensips uses always 5060.
>>
>> regards,
>> stefano
>>
>> _______________________________________________
>> 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
>
>  


--
Bogdan-Andrei Iancu
OpenSIPS Bootcamp
15 - 19 November 2010, Edison, New Jersey, USA
www.voice-system.ro


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

Re: How opensis can manage different ports.

Stefano Pisani
  Thank you for your reply.
I solved my problem.
I rewrite lookup() to extend it and I forgot to assign right local
interface using $fs.
Now I fixed the problem.
Thanks for your support.

stefano

Il 21/09/2010 12:58, Bogdan-Andrei Iancu ha scritto:

> Hi Stefano
>
> Stefano Pisani wrote:
>>    I tried to use "mhomed = 1" but it doesn't work for me.
>>
> this is for interface selection, not ports.
>> When a call arrives to opensips for a client registered on port 5061, he
>> forwards the call
>> using 5060 as from port and not 5061, so che call does not pass the
>> firewall.
>>
> do you route your calls (INVITEs) based on lookup() information ?
>
> Regards,
> Bogdan
>> regards,
>> stefano
>>
>> Il 15/09/2010 14:05, Stefano ha scritto:
>>
>>>     Hi all,
>>> I return on an argument proposed a couple of weeks ago.
>>> I have an installation of opensips binding on two ports (5060 and 5061).
>>> Some client registers itself on 5060, others on 5061.
>>> My wish is that opensips uses as from port the same port used by client
>>> for registration.
>>> Is it possible that?
>>> At the moment opensips uses always 5060.
>>>
>>> regards,
>>> stefano
>>>
>>> _______________________________________________
>>> 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
>>
>>
>

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