Re: [OpenSIPS-Users] MySQL Type: FIELD_TYPE_NEWDECIMAL (246) uses DB_INT result type but should use float

2020-03-08 Thread Brett Nemeroff
Hello Calvin,
Looks like your coerecing a float into an integer field. I think it's your
delay field. What do you expect to happen here? I mean that seriously. If
the delay field is an integer, you can't put anything but an integer in it
if you have no access to change the database type.

Alternatively, you could try to use transformations to manipulate the
numeric into something that looks like an integer (for example, multiple
those values by 1 and store that.

Let us know if that helps or if you need some more help.
-Brett


On Mon, Mar 9, 2020 at 12:51 AM Calvin Ellison 
wrote:

> It appears that OpenSIPS is assuming an incorrect integer data type on a
> field that is a floating-point value. I have no access to change the field
> type in the database. What can be done?
>
> Server version: 10.2.31-MariaDB MariaDB Server
>
> Query and response attached
>
> async(avp_db_query("call lrn.fulldataz('$var(number)',curdate())",
> "$avp(number); $avp(lrn); $avp(portType); $avp(state); $avp(network);
> $avp(ocn); $avp(ratecenter); $avp(class); $avp(lata); $avp(country);
> $avp(reachable); $avp(reason); $avp(dnc); $avp(good)", "2"), resume_dnc);
>
> ERROR:core:db_str2int: Unexpected characters: [.0011]
>
> # opensips -V
> version: opensips 2.4.7 (x86_64/linux)
> flags: STATS: On, DISABLE_NAGLE, USE_MCAST, SHM_MMAP, PKG_MALLOC,
> F_MALLOC, FAST_LOCK-ADAPTIVE_WAIT
> ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16,
> MAX_URI_SIZE 1024, BUF_SIZE 65535
> poll method support: poll, epoll, sigio_rt, select.
> main.c compiled on  with gcc 7
>
>
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: 15 columns returned from the query
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:core:db_allocate_columns: allocate 420 bytes for result columns at
> 0x7f4bed66fa20
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fa98)[0]=[number]
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66faa8)[1]=[lrn]
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fab8)[2]=[port type]
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: use DB_INT result type
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fac8)[3]=[state]
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fad8)[4]=[network]
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fae8)[5]=[ocn]
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66faf8)[6]=[ratecenter]
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fb08)[7]=[class]
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fb18)[8]=[lata]
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fb28)[9]=[country]
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fb38)[10]=[reachable]
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: use DB_BIGINT result type
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fb48)[11]=[reason]
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
> Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
> DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fb58)[12]=[dnc]
> Mar  8 22:28:11 localhost /usr/sbin/ope

[OpenSIPS-Users] MySQL Type: FIELD_TYPE_NEWDECIMAL (246) uses DB_INT result type but should use float

2020-03-08 Thread Calvin Ellison
It appears that OpenSIPS is assuming an incorrect integer data type on a
field that is a floating-point value. I have no access to change the field
type in the database. What can be done?

Server version: 10.2.31-MariaDB MariaDB Server

Query and response attached

async(avp_db_query("call lrn.fulldataz('$var(number)',curdate())",
"$avp(number); $avp(lrn); $avp(portType); $avp(state); $avp(network);
$avp(ocn); $avp(ratecenter); $avp(class); $avp(lata); $avp(country);
$avp(reachable); $avp(reason); $avp(dnc); $avp(good)", "2"), resume_dnc);

ERROR:core:db_str2int: Unexpected characters: [.0011]

# opensips -V
version: opensips 2.4.7 (x86_64/linux)
flags: STATS: On, DISABLE_NAGLE, USE_MCAST, SHM_MMAP, PKG_MALLOC, F_MALLOC,
FAST_LOCK-ADAPTIVE_WAIT
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16,
MAX_URI_SIZE 1024, BUF_SIZE 65535
poll method support: poll, epoll, sigio_rt, select.
main.c compiled on  with gcc 7


Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: 15 columns returned from the query
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:core:db_allocate_columns: allocate 420 bytes for result columns at
0x7f4bed66fa20
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fa98)[0]=[number]
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66faa8)[1]=[lrn]
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fab8)[2]=[port type]
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: use DB_INT result type
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fac8)[3]=[state]
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fad8)[4]=[network]
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fae8)[5]=[ocn]
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66faf8)[6]=[ratecenter]
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fb08)[7]=[class]
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fb18)[8]=[lata]
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fb28)[9]=[country]
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fb38)[10]=[reachable]
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: use DB_BIGINT result type
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fb48)[11]=[reason]
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: use DB_STRING result type
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fb58)[12]=[dnc]
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: use DB_INT result type
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fb68)[13]=[good]
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: use DB_BIGINT result type
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: RES_NAMES(0x7f4bed66fb78)[14]=[delay]
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:db_mysql:db_mysql_get_columns: use DB_INT result type
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:core:db_allocate_rows: allocate 496 bytes for result rows and values at
0x7f4bed66e878
Mar  8 22:28:11 localhost /usr/sbin/opensips[32124]:
DBG:

Re: [OpenSIPS-Users] Public IP in REGISTER

2020-03-08 Thread Jehanzaib Younis
i do
if(isflagset(8))
{
setbflag(3);
setbflag(NAT);
setbflag(7);
}
   save("location");
   exit;
I have modparam("usrloc", "nat_bflag", "NAT")  & modparam("nathelper",
"sipping_bflag", 7)

On Mon, Mar 9, 2020 at 12:56 PM David Villasmil <
david.villasmil.w...@gmail.com> wrote:

> Have you tried setting the bflag right before save()’ing during the
> REGISTER?
>
> On Sun, 8 Mar 2020 at 23:34, Jehanzaib Younis 
> wrote:
>
>> Hi David,
>>
>> I have one contact in the Usrloc
>> Do you think it could be a timeout issue? or i should use
>> remove_on_timeout_bflag option?
>>
>> On Mon, Mar 9, 2020 at 12:31 PM David Villasmil <
>> david.villasmil.w...@gmail.com> wrote:
>>
>>> Make sure you don’t have 2 contacts
>>>
>>> On Sun, 8 Mar 2020 at 23:22, Jehanzaib Younis 
>>> wrote:
>>>
 but i have strange issue.
 nathelper keep on sending the OPTION to old IP:PORT. As soon as the new
 REGISTER comes in, it should only send the option to the latest one.
 For example, I see OPTION going to xx.xxx.xx.xx:25001 and opensips keep
 on sending to this after every 120 seconds (which is my setting)
 The new register comes in and the  xx.xxx.xx.xx:25004 letsay and now
 opensips sends to 25001 as well as 25004. Obviously my cpe only replies to
 the latest one.

 Anyone have faced this issue ?

 Thank you

 On Fri, Mar 6, 2020 at 2:54 PM Jehanzaib Younis <
 jehanzaib.ki...@gmail.com> wrote:

> Thank you for your suggestions Diptesh,
>
> Actually adding modparam("nathelper", "received_avp", "$avp(s:rcv)") &
> modparam("registrar", "received_avp", "$avp(s:rcv)") did the trick.
>
>
>
> On Thu, Mar 5, 2020 at 7:25 PM Dipteshkumar Patel <
> diptesh.pa...@ecosmob.com> wrote:
>
>> Hello Jehan,
>>
>> OpenSIPS handle NAT different way for INVITE and REGISTER packets. If
>> we use fix_nated_contact(), it will get the actual source ip from network
>> and create a lump for that and replace the headers(like Contact, Received
>> in Via and c parameter in SDP packet) just before sent out or relay the
>> packet.
>>
>> In your case, You need to manage the REGISTER and we are using
>> OpenSIPS as a Registrar so we are not relay the packet so
>> fix_nated_contact() will not help you. and your location table will have
>> the private ip not public. So Let me guide how NAT can be managed in
>> Registration.
>>
>> There are three modules are responsible for the registration with NAT
>> handling.
>> 1. registrar module
>> 2. usrloc module
>> 3. nathelper module
>>
>> nathelper module can check the packet source is behind nat or nat and
>> get the public ip from source ip.
>>
>> We need to define a module parameter for netheper module with an
>> avp variable so the module will store the received IP in that avp. and
>> similar avp should be in registrar module so registrar module can read 
>> the
>> avp and store it into location as received parameter.
>>
>> modparam("nathelper", "received_avp", "$avp(received)")
>>
>> modparam("registrar", "received_avp", "$avp(received)")
>>
>>
>> Refer the following snippet.
>>
>> /*Other registrar Parameters*/
>> modparam("registrar", "received_avp", "$avp(received)")
>>
>> /*Other nethelper Parameters*/
>> modparam("nathelper", "received_avp", "$avp(received)") #keep in mind
>> that this avp should be same in registrar module.
>>
>> /*Other usrloc Parameters*/
>> modparam("usrloc", "nat_bflag", "NAT_FLAG")
>>
>> route(NAT_MANAGE);
>> ---
>> /*Some Authentication Stuff*/
>> ---
>> if(!save("location")) {
>> sl_reply_error();
>> }
>>
>> route[NAT_MANAGE] {
>> if(nat_uac_test("19")){
>> xlog("L_INFO","--- [NAT_MANAGE] UAC IS BEHIND NAT ---");
>> if(is_method("REGISTER")){
>> fix_nated_register();
>> setbflag(NAT_FLAG);
>> } else {
>> fix_nated_contact();
>> setflag(NAT_FLAG);
>> if (has_body("application/sdp")){
>> fix_nated_sdp("3");
>> }
>> }
>> }
>> }
>>
>> Output of opensipsctl ul show
>> ---
>>
>> AOR:: 1...@world.provider.in
>> Contact:: sip:100@[ACTUAL CONTACT IP]:5060 Q=
>> ContactID:: 2522655082190201667
>> Expires:: 2219
>> Callid:: 18480129104911-28121824031899@192.168.30.238
>> Cseq:: 6
>> User-agent:: Phone Ver2.2
>> Received:: sip:[RECEIVED IP]:5060 /*This IP will be used
>> as requ

Re: [OpenSIPS-Users] Public IP in REGISTER

2020-03-08 Thread David Villasmil
Have you tried setting the bflag right before save()’ing during the
REGISTER?

On Sun, 8 Mar 2020 at 23:34, Jehanzaib Younis 
wrote:

> Hi David,
>
> I have one contact in the Usrloc
> Do you think it could be a timeout issue? or i should use
> remove_on_timeout_bflag option?
>
> On Mon, Mar 9, 2020 at 12:31 PM David Villasmil <
> david.villasmil.w...@gmail.com> wrote:
>
>> Make sure you don’t have 2 contacts
>>
>> On Sun, 8 Mar 2020 at 23:22, Jehanzaib Younis 
>> wrote:
>>
>>> but i have strange issue.
>>> nathelper keep on sending the OPTION to old IP:PORT. As soon as the new
>>> REGISTER comes in, it should only send the option to the latest one.
>>> For example, I see OPTION going to xx.xxx.xx.xx:25001 and opensips keep
>>> on sending to this after every 120 seconds (which is my setting)
>>> The new register comes in and the  xx.xxx.xx.xx:25004 letsay and now
>>> opensips sends to 25001 as well as 25004. Obviously my cpe only replies to
>>> the latest one.
>>>
>>> Anyone have faced this issue ?
>>>
>>> Thank you
>>>
>>> On Fri, Mar 6, 2020 at 2:54 PM Jehanzaib Younis <
>>> jehanzaib.ki...@gmail.com> wrote:
>>>
 Thank you for your suggestions Diptesh,

 Actually adding modparam("nathelper", "received_avp", "$avp(s:rcv)") &
 modparam("registrar", "received_avp", "$avp(s:rcv)") did the trick.



 On Thu, Mar 5, 2020 at 7:25 PM Dipteshkumar Patel <
 diptesh.pa...@ecosmob.com> wrote:

> Hello Jehan,
>
> OpenSIPS handle NAT different way for INVITE and REGISTER packets. If
> we use fix_nated_contact(), it will get the actual source ip from network
> and create a lump for that and replace the headers(like Contact, Received
> in Via and c parameter in SDP packet) just before sent out or relay the
> packet.
>
> In your case, You need to manage the REGISTER and we are using
> OpenSIPS as a Registrar so we are not relay the packet so
> fix_nated_contact() will not help you. and your location table will have
> the private ip not public. So Let me guide how NAT can be managed in
> Registration.
>
> There are three modules are responsible for the registration with NAT
> handling.
> 1. registrar module
> 2. usrloc module
> 3. nathelper module
>
> nathelper module can check the packet source is behind nat or nat and
> get the public ip from source ip.
>
> We need to define a module parameter for netheper module with an
> avp variable so the module will store the received IP in that avp. and
> similar avp should be in registrar module so registrar module can read the
> avp and store it into location as received parameter.
>
> modparam("nathelper", "received_avp", "$avp(received)")
>
> modparam("registrar", "received_avp", "$avp(received)")
>
>
> Refer the following snippet.
>
> /*Other registrar Parameters*/
> modparam("registrar", "received_avp", "$avp(received)")
>
> /*Other nethelper Parameters*/
> modparam("nathelper", "received_avp", "$avp(received)") #keep in mind
> that this avp should be same in registrar module.
>
> /*Other usrloc Parameters*/
> modparam("usrloc", "nat_bflag", "NAT_FLAG")
>
> route(NAT_MANAGE);
> ---
> /*Some Authentication Stuff*/
> ---
> if(!save("location")) {
> sl_reply_error();
> }
>
> route[NAT_MANAGE] {
> if(nat_uac_test("19")){
> xlog("L_INFO","--- [NAT_MANAGE] UAC IS BEHIND NAT ---");
> if(is_method("REGISTER")){
> fix_nated_register();
> setbflag(NAT_FLAG);
> } else {
> fix_nated_contact();
> setflag(NAT_FLAG);
> if (has_body("application/sdp")){
> fix_nated_sdp("3");
> }
> }
> }
> }
>
> Output of opensipsctl ul show
> ---
>
> AOR:: 1...@world.provider.in
> Contact:: sip:100@[ACTUAL CONTACT IP]:5060 Q=
> ContactID:: 2522655082190201667
> Expires:: 2219
> Callid:: 18480129104911-28121824031899@192.168.30.238
> Cseq:: 6
> User-agent:: Phone Ver2.2
> Received:: sip:[RECEIVED IP]:5060 /*This IP will be used
> as request domain on relay the packet*/
> State:: CS_SYNC
> Flags:: 0
> Cflags:: SIPPING_RTO SIPPING_ENABLE NAT_FLAG
> Socket:: udp:[OPENSIPS LISTEN SOCKET]:5070
> Methods:: 7551
>
> I hope this will solve your problem.
>
> Thanks & Regards
> *Diptesh Patel*
> Software Developer
> Ecosmob Technologies Ltd,
> Ahmedabad
> Mo:*+919898962659*
>
>
> On Thu, Mar 5, 2020 at 4:35 AM Jehanzaib Younis <
> jehanzaib.ki...@gmail.com> wrote:

Re: [OpenSIPS-Users] Public IP in REGISTER

2020-03-08 Thread Jehanzaib Younis
Hi David,

I have one contact in the Usrloc
Do you think it could be a timeout issue? or i should use
remove_on_timeout_bflag option?

On Mon, Mar 9, 2020 at 12:31 PM David Villasmil <
david.villasmil.w...@gmail.com> wrote:

> Make sure you don’t have 2 contacts
>
> On Sun, 8 Mar 2020 at 23:22, Jehanzaib Younis 
> wrote:
>
>> but i have strange issue.
>> nathelper keep on sending the OPTION to old IP:PORT. As soon as the new
>> REGISTER comes in, it should only send the option to the latest one.
>> For example, I see OPTION going to xx.xxx.xx.xx:25001 and opensips keep
>> on sending to this after every 120 seconds (which is my setting)
>> The new register comes in and the  xx.xxx.xx.xx:25004 letsay and now
>> opensips sends to 25001 as well as 25004. Obviously my cpe only replies to
>> the latest one.
>>
>> Anyone have faced this issue ?
>>
>> Thank you
>>
>> On Fri, Mar 6, 2020 at 2:54 PM Jehanzaib Younis <
>> jehanzaib.ki...@gmail.com> wrote:
>>
>>> Thank you for your suggestions Diptesh,
>>>
>>> Actually adding modparam("nathelper", "received_avp", "$avp(s:rcv)") &
>>> modparam("registrar", "received_avp", "$avp(s:rcv)") did the trick.
>>>
>>>
>>>
>>> On Thu, Mar 5, 2020 at 7:25 PM Dipteshkumar Patel <
>>> diptesh.pa...@ecosmob.com> wrote:
>>>
 Hello Jehan,

 OpenSIPS handle NAT different way for INVITE and REGISTER packets. If
 we use fix_nated_contact(), it will get the actual source ip from network
 and create a lump for that and replace the headers(like Contact, Received
 in Via and c parameter in SDP packet) just before sent out or relay the
 packet.

 In your case, You need to manage the REGISTER and we are using OpenSIPS
 as a Registrar so we are not relay the packet so fix_nated_contact() will
 not help you. and your location table will have the private ip not public.
 So Let me guide how NAT can be managed in Registration.

 There are three modules are responsible for the registration with NAT
 handling.
 1. registrar module
 2. usrloc module
 3. nathelper module

 nathelper module can check the packet source is behind nat or nat and
 get the public ip from source ip.

 We need to define a module parameter for netheper module with an
 avp variable so the module will store the received IP in that avp. and
 similar avp should be in registrar module so registrar module can read the
 avp and store it into location as received parameter.

 modparam("nathelper", "received_avp", "$avp(received)")

 modparam("registrar", "received_avp", "$avp(received)")


 Refer the following snippet.

 /*Other registrar Parameters*/
 modparam("registrar", "received_avp", "$avp(received)")

 /*Other nethelper Parameters*/
 modparam("nathelper", "received_avp", "$avp(received)") #keep in mind
 that this avp should be same in registrar module.

 /*Other usrloc Parameters*/
 modparam("usrloc", "nat_bflag", "NAT_FLAG")

 route(NAT_MANAGE);
 ---
 /*Some Authentication Stuff*/
 ---
 if(!save("location")) {
 sl_reply_error();
 }

 route[NAT_MANAGE] {
 if(nat_uac_test("19")){
 xlog("L_INFO","--- [NAT_MANAGE] UAC IS BEHIND NAT ---");
 if(is_method("REGISTER")){
 fix_nated_register();
 setbflag(NAT_FLAG);
 } else {
 fix_nated_contact();
 setflag(NAT_FLAG);
 if (has_body("application/sdp")){
 fix_nated_sdp("3");
 }
 }
 }
 }

 Output of opensipsctl ul show
 ---

 AOR:: 1...@world.provider.in
 Contact:: sip:100@[ACTUAL CONTACT IP]:5060 Q=
 ContactID:: 2522655082190201667
 Expires:: 2219
 Callid:: 18480129104911-28121824031899@192.168.30.238
 Cseq:: 6
 User-agent:: Phone Ver2.2
 Received:: sip:[RECEIVED IP]:5060 /*This IP will be used as
 request domain on relay the packet*/
 State:: CS_SYNC
 Flags:: 0
 Cflags:: SIPPING_RTO SIPPING_ENABLE NAT_FLAG
 Socket:: udp:[OPENSIPS LISTEN SOCKET]:5070
 Methods:: 7551

 I hope this will solve your problem.

 Thanks & Regards
 *Diptesh Patel*
 Software Developer
 Ecosmob Technologies Ltd,
 Ahmedabad
 Mo:*+919898962659*


 On Thu, Mar 5, 2020 at 4:35 AM Jehanzaib Younis <
 jehanzaib.ki...@gmail.com> wrote:

> Thank you for your email Callum,
> I can not see the public IP in the command line that is strange. but
> OPTION is working fine. i can see 200 OK in the OPTION.
> I have already tried what you have suggested i.e fixed_nated_contact
> on INVITE it is still send

Re: [OpenSIPS-Users] Public IP in REGISTER

2020-03-08 Thread David Villasmil
Make sure you don’t have 2 contacts

On Sun, 8 Mar 2020 at 23:22, Jehanzaib Younis 
wrote:

> but i have strange issue.
> nathelper keep on sending the OPTION to old IP:PORT. As soon as the new
> REGISTER comes in, it should only send the option to the latest one.
> For example, I see OPTION going to xx.xxx.xx.xx:25001 and opensips keep on
> sending to this after every 120 seconds (which is my setting)
> The new register comes in and the  xx.xxx.xx.xx:25004 letsay and now
> opensips sends to 25001 as well as 25004. Obviously my cpe only replies to
> the latest one.
>
> Anyone have faced this issue ?
>
> Thank you
>
> On Fri, Mar 6, 2020 at 2:54 PM Jehanzaib Younis 
> wrote:
>
>> Thank you for your suggestions Diptesh,
>>
>> Actually adding modparam("nathelper", "received_avp", "$avp(s:rcv)") &
>> modparam("registrar", "received_avp", "$avp(s:rcv)") did the trick.
>>
>>
>>
>> On Thu, Mar 5, 2020 at 7:25 PM Dipteshkumar Patel <
>> diptesh.pa...@ecosmob.com> wrote:
>>
>>> Hello Jehan,
>>>
>>> OpenSIPS handle NAT different way for INVITE and REGISTER packets. If we
>>> use fix_nated_contact(), it will get the actual source ip from network and
>>> create a lump for that and replace the headers(like Contact, Received in
>>> Via and c parameter in SDP packet) just before sent out or relay the packet.
>>>
>>> In your case, You need to manage the REGISTER and we are using OpenSIPS
>>> as a Registrar so we are not relay the packet so fix_nated_contact() will
>>> not help you. and your location table will have the private ip not public.
>>> So Let me guide how NAT can be managed in Registration.
>>>
>>> There are three modules are responsible for the registration with NAT
>>> handling.
>>> 1. registrar module
>>> 2. usrloc module
>>> 3. nathelper module
>>>
>>> nathelper module can check the packet source is behind nat or nat and
>>> get the public ip from source ip.
>>>
>>> We need to define a module parameter for netheper module with an
>>> avp variable so the module will store the received IP in that avp. and
>>> similar avp should be in registrar module so registrar module can read the
>>> avp and store it into location as received parameter.
>>>
>>> modparam("nathelper", "received_avp", "$avp(received)")
>>>
>>> modparam("registrar", "received_avp", "$avp(received)")
>>>
>>>
>>> Refer the following snippet.
>>>
>>> /*Other registrar Parameters*/
>>> modparam("registrar", "received_avp", "$avp(received)")
>>>
>>> /*Other nethelper Parameters*/
>>> modparam("nathelper", "received_avp", "$avp(received)") #keep in mind
>>> that this avp should be same in registrar module.
>>>
>>> /*Other usrloc Parameters*/
>>> modparam("usrloc", "nat_bflag", "NAT_FLAG")
>>>
>>> route(NAT_MANAGE);
>>> ---
>>> /*Some Authentication Stuff*/
>>> ---
>>> if(!save("location")) {
>>> sl_reply_error();
>>> }
>>>
>>> route[NAT_MANAGE] {
>>> if(nat_uac_test("19")){
>>> xlog("L_INFO","--- [NAT_MANAGE] UAC IS BEHIND NAT ---");
>>> if(is_method("REGISTER")){
>>> fix_nated_register();
>>> setbflag(NAT_FLAG);
>>> } else {
>>> fix_nated_contact();
>>> setflag(NAT_FLAG);
>>> if (has_body("application/sdp")){
>>> fix_nated_sdp("3");
>>> }
>>> }
>>> }
>>> }
>>>
>>> Output of opensipsctl ul show
>>> ---
>>>
>>> AOR:: 1...@world.provider.in
>>> Contact:: sip:100@[ACTUAL CONTACT IP]:5060 Q=
>>> ContactID:: 2522655082190201667
>>> Expires:: 2219
>>> Callid:: 18480129104911-28121824031899@192.168.30.238
>>> Cseq:: 6
>>> User-agent:: Phone Ver2.2
>>> Received:: sip:[RECEIVED IP]:5060 /*This IP will be used as
>>> request domain on relay the packet*/
>>> State:: CS_SYNC
>>> Flags:: 0
>>> Cflags:: SIPPING_RTO SIPPING_ENABLE NAT_FLAG
>>> Socket:: udp:[OPENSIPS LISTEN SOCKET]:5070
>>> Methods:: 7551
>>>
>>> I hope this will solve your problem.
>>>
>>> Thanks & Regards
>>> *Diptesh Patel*
>>> Software Developer
>>> Ecosmob Technologies Ltd,
>>> Ahmedabad
>>> Mo:*+919898962659*
>>>
>>>
>>> On Thu, Mar 5, 2020 at 4:35 AM Jehanzaib Younis <
>>> jehanzaib.ki...@gmail.com> wrote:
>>>
 Thank you for your email Callum,
 I can not see the public IP in the command line that is strange. but
 OPTION is working fine. i can see 200 OK in the OPTION.
 I have already tried what you have suggested i.e fixed_nated_contact on
 INVITE it is still sending to my 10.xx.xx.xx ip.

 Here is my URL location
 AOR:: xx
 Contact:: sip:x...@10.202.128.xx:5060;transport=udp Q=
 Expires:: 2914
 Callid:: n883832msp1lm0nl3cmjks88jkpin...@10.202.128.xx
 Cseq:: 12
 User-agent:: HUAWEI-EchoLife HG8240H/V3R013C10S108
 State:: CS_N

Re: [OpenSIPS-Users] Public IP in REGISTER

2020-03-08 Thread Jehanzaib Younis
but i have strange issue.
nathelper keep on sending the OPTION to old IP:PORT. As soon as the new
REGISTER comes in, it should only send the option to the latest one.
For example, I see OPTION going to xx.xxx.xx.xx:25001 and opensips keep on
sending to this after every 120 seconds (which is my setting)
The new register comes in and the  xx.xxx.xx.xx:25004 letsay and now
opensips sends to 25001 as well as 25004. Obviously my cpe only replies to
the latest one.

Anyone have faced this issue ?

Thank you

On Fri, Mar 6, 2020 at 2:54 PM Jehanzaib Younis 
wrote:

> Thank you for your suggestions Diptesh,
>
> Actually adding modparam("nathelper", "received_avp", "$avp(s:rcv)") &
> modparam("registrar", "received_avp", "$avp(s:rcv)") did the trick.
>
>
>
> On Thu, Mar 5, 2020 at 7:25 PM Dipteshkumar Patel <
> diptesh.pa...@ecosmob.com> wrote:
>
>> Hello Jehan,
>>
>> OpenSIPS handle NAT different way for INVITE and REGISTER packets. If we
>> use fix_nated_contact(), it will get the actual source ip from network and
>> create a lump for that and replace the headers(like Contact, Received in
>> Via and c parameter in SDP packet) just before sent out or relay the packet.
>>
>> In your case, You need to manage the REGISTER and we are using OpenSIPS
>> as a Registrar so we are not relay the packet so fix_nated_contact() will
>> not help you. and your location table will have the private ip not public.
>> So Let me guide how NAT can be managed in Registration.
>>
>> There are three modules are responsible for the registration with NAT
>> handling.
>> 1. registrar module
>> 2. usrloc module
>> 3. nathelper module
>>
>> nathelper module can check the packet source is behind nat or nat and get
>> the public ip from source ip.
>>
>> We need to define a module parameter for netheper module with an
>> avp variable so the module will store the received IP in that avp. and
>> similar avp should be in registrar module so registrar module can read the
>> avp and store it into location as received parameter.
>>
>> modparam("nathelper", "received_avp", "$avp(received)")
>>
>> modparam("registrar", "received_avp", "$avp(received)")
>>
>>
>> Refer the following snippet.
>>
>> /*Other registrar Parameters*/
>> modparam("registrar", "received_avp", "$avp(received)")
>>
>> /*Other nethelper Parameters*/
>> modparam("nathelper", "received_avp", "$avp(received)") #keep in mind
>> that this avp should be same in registrar module.
>>
>> /*Other usrloc Parameters*/
>> modparam("usrloc", "nat_bflag", "NAT_FLAG")
>>
>> route(NAT_MANAGE);
>> ---
>> /*Some Authentication Stuff*/
>> ---
>> if(!save("location")) {
>> sl_reply_error();
>> }
>>
>> route[NAT_MANAGE] {
>> if(nat_uac_test("19")){
>> xlog("L_INFO","--- [NAT_MANAGE] UAC IS BEHIND NAT ---");
>> if(is_method("REGISTER")){
>> fix_nated_register();
>> setbflag(NAT_FLAG);
>> } else {
>> fix_nated_contact();
>> setflag(NAT_FLAG);
>> if (has_body("application/sdp")){
>> fix_nated_sdp("3");
>> }
>> }
>> }
>> }
>>
>> Output of opensipsctl ul show
>> ---
>>
>> AOR:: 1...@world.provider.in
>> Contact:: sip:100@[ACTUAL CONTACT IP]:5060 Q=
>> ContactID:: 2522655082190201667
>> Expires:: 2219
>> Callid:: 18480129104911-28121824031899@192.168.30.238
>> Cseq:: 6
>> User-agent:: Phone Ver2.2
>> Received:: sip:[RECEIVED IP]:5060 /*This IP will be used as
>> request domain on relay the packet*/
>> State:: CS_SYNC
>> Flags:: 0
>> Cflags:: SIPPING_RTO SIPPING_ENABLE NAT_FLAG
>> Socket:: udp:[OPENSIPS LISTEN SOCKET]:5070
>> Methods:: 7551
>>
>> I hope this will solve your problem.
>>
>> Thanks & Regards
>> *Diptesh Patel*
>> Software Developer
>> Ecosmob Technologies Ltd,
>> Ahmedabad
>> Mo:*+919898962659*
>>
>>
>> On Thu, Mar 5, 2020 at 4:35 AM Jehanzaib Younis <
>> jehanzaib.ki...@gmail.com> wrote:
>>
>>> Thank you for your email Callum,
>>> I can not see the public IP in the command line that is strange. but
>>> OPTION is working fine. i can see 200 OK in the OPTION.
>>> I have already tried what you have suggested i.e fixed_nated_contact on
>>> INVITE it is still sending to my 10.xx.xx.xx ip.
>>>
>>> Here is my URL location
>>> AOR:: xx
>>> Contact:: sip:x...@10.202.128.xx:5060;transport=udp Q=
>>> Expires:: 2914
>>> Callid:: n883832msp1lm0nl3cmjks88jkpin...@10.202.128.xx
>>> Cseq:: 12
>>> User-agent:: HUAWEI-EchoLife HG8240H/V3R013C10S108
>>> State:: CS_NEW
>>> Flags:: 0
>>> Cflags:: 3
>>> Socket:: udp:mysipserverip:5060
>>> Methods:: 8191
>>>
>>> here is my url and nat module parameters
>>>
>>> loadmodule "usrloc.so"
>>> modpara