[SR-Users] riud access from route block

2013-04-30 Thread Juha Heinanen
Juha Heinanen writes:

> there is $branch(name) pv that gives access to other branched, but not
> the "main branch".  is there any way to get access to ruid of the main
> branch when t_relay() fails when called from route block?  for example,
> if there is only one contact (the $ru one), which results in t_relay()
> failure, is there a way to find out the ruid of this contact?

there is $ruid pseudo variable for that purpose.  i got confused by text
in $branch(name) description that gave impression that only $ru and $du
are available for the main branch:

  Using $branch() you can access the additional branches, the main branch
  can be accessed using $ru and $du.

-- juha

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] var vs avp...

2013-04-30 Thread Vitaliy Aleksandrov

On 04/29/2013 03:52 PM, Victor V. Kustov wrote:

В Mon, 29 Apr 2013 14:46:34 +0200
"Olle E. Johansson"  пишет:


All functions of this module load AVPs from SIP-AVP reply items
received from RADIUS upon a successful request. Value of the SIP-AVP
reply item must be a string of form:

• value = SIP_AVP_NAME SIP_AVP_VALUE

• SIP_AVP_NAME = STRING_NAME | '#'ID_NUMBER

• SIP_AVP_VALUE = ':'STRING_VALUE | '#'NUMBER_VALUE



sorry its not clear for me.

$avp('next-hop-ip') is ok in my case? Or i need _special_ radius answer?
Not so "special" .. You need to add SIP-AVP attributes to an 
access-accept reply from radius. As I remember this attribute must be 
declared somewhere in dictionary.openser.





___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] var vs avp...

2013-04-30 Thread Victor V. Kustov
В Tue, 30 Apr 2013 12:38:11 +0300
Vitaliy Aleksandrov  пишет:

> Not so "special" .. You need to add SIP-AVP attributes to an 
> access-accept reply from radius. As I remember this attribute must be 
> declared somewhere in dictionary.openser.

bad news for me. radius already work with other systems and all of them
receive standart response like described.


-- 
 SY,
Victor
  JID: coy...@bks.tv
  JID: coy...@bryansktel.ru
  I use FREE operation system: 3.8.4-calculate GNU/Linux

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] siptrace + flatstore

2013-04-30 Thread Victor V. Kustov
В Mon, 29 Apr 2013 09:46:48 +0200
Daniel-Constantin Mierla  пишет:

Now work.  Just work. 

-- 
 SY,
Victor
  JID: coy...@bks.tv
  JID: coy...@bryansktel.ru
  I use FREE operation system: 3.8.4-calculate GNU/Linux

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] [SR-users] Radius AAA

2013-04-30 Thread Victor V. Kustov
В Tue, 23 Apr 2013 15:35:42 +0300
Vitaliy Aleksandrov  пишет:

> $rd = $avp(s:next-hop);

it not work $avp(s:next-hop) in new misc_radius. 
need SIP-AV attributes if i understand correctly.

-- 
 SY,
Victor
  JID: coy...@bks.tv
  JID: coy...@bryansktel.ru
  I use FREE operation system: 3.8.4-calculate GNU/Linux

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


[SR-Users] [PATCH] Memory corruption using s.substr transformation

2013-04-30 Thread Martin Mikkelsen
Hello,

I have a kamailio 3.3.4 server running on x86-64 Linux, and I have a
script which looks something like this:

  $var(gwruri) = $rU;
  if ($(var(gwruri){s.substr,0,1}) == "+") {
$var(gwruri) = $(var(gwruri){s.substr,1,0});
  }

When this script is run with say $rU = "+009724" (real number
removed).  $var(gwruri) should contain the same but without the +, this
is not the case, $var(gwruri) ends up being "007724".

This smells memory corruption. When run under valgrind, valgrind
generates this error when that code is run:

==1206== Source and destination overlap in strncpy(0x55e3b2a, 0x55e3b2b, 10)
==1206==at 0x4C25ACF: strncpy (mc_replace_strmem.c:339)
==1206==by 0x2A28BB92: set_var_value (pv_svar.c:122)
==1206==by 0x2A2800D1: pv_set_scriptvar (pv_core.c:1683)
==1206==by 0x45E8F8: lval_assign (lvalue.c:353)
==1206==by 0x416A78: do_action (action.c:1524)
==1206==by 0x41E465: run_actions (action.c:1644)
==1206==by 0x4177FD: do_action (action.c:1136)
==1206==by 0x41E465: run_actions (action.c:1644)
==1206==by 0x4177FD: do_action (action.c:1136)
==1206==by 0x41E465: run_actions (action.c:1644)
==1206==by 0x419C67: do_action (action.c:1140)
==1206==by 0x41E465: run_actions (action.c:1644)
==1206==

I am not very familiar with the kamailio source code, but as far as I
can tell this happens because the strncpy() in set_var_value() in
pv_svar.c copies the string directly within the same overlapping memory
area. The same memory area is used because the tr_eval_string() function
and the TR_S_SUBSTR-code in pv_trans.c reuses the input buffer and just
increments the pointer and since the source pvar is the same as the
destination pvar the strncpy() ends up copying between overlapping
memory area.

I am not sure what the best fix would be for that, but I have attached a
patch which copies the string in the TR_S_SUBST code to _tr_buffer and
returns that buffer instead like a lot of the other transformations in
that function does.

If this fix is correct some other transformation functions probably
needs to be corrected as well.

-- 
Martin Mikkelsen, Zisson AS

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] [PATCH] Memory corruption using s.substr transformation

2013-04-30 Thread Martin Mikkelsen
On Tue, Apr 30, 2013 at 01:29:21PM +0200, Martin Mikkelsen wrote:
> I am not sure what the best fix would be for that, but I have attached a
> patch which copies the string in the TR_S_SUBST code to _tr_buffer and
> returns that buffer instead like a lot of the other transformations in
> that function does.
> 
> If this fix is correct some other transformation functions probably
> needs to be corrected as well.

Forgot to attach the patch. Sorry.

-- 
Martin Mikkelsen, Zisson AS
diff -ruN kamailio-3.3.4.orig/modules_k/pv/pv_trans.c kamailio-3.3.4/modules_k/pv/pv_trans.c
--- kamailio-3.3.4.orig/modules_k/pv/pv_trans.c	2013-02-25 18:20:37.0 +0100
+++ kamailio-3.3.4/modules_k/pv/pv_trans.c	2013-04-30 12:38:23.0 +0200
@@ -309,8 +309,12 @@
 LM_ERR("substr negative offset\n");
 return -1;
 			}
+ 			memcpy(_tr_buffer, val->rs.s, val->rs.len);
+ 			st.s = _tr_buffer;
+ 			st.len = val->rs.len;
 			val->flags = PV_VAL_STR;
 			val->ri = 0;
+ 			val->rs = st;
 			if(i>=0)
 			{
 if(i>=val->rs.len)
___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Kamailio 3.x and Asterisk Realtime Integration plus Dispatcher module

2013-04-30 Thread Barry Flanagan
On 29 April 2013 14:51, Aldo Antignano  wrote:

> I have read and applied the excellent guide found on:
> http://kb.asipto.com/asterisk:realtime:kamailio-3.3.x-asterisk-10.7.0-astdb
>
> Now I have added to Kamailio the HA/Load Balancer support, with the
> "dispatcher" module.
> This way I have 1 Kamailio and 2 Asterisk machines.
>
> How can I change the routing logic of the sections route[REGFWD] |
> route[FROMASTERISK] route[TOASTERISK] to use the dispatcher module? (in the
> guide above the asterisk binded ip address is cabled in the kamailio config
> code)
>

I have done that. Relevant route entries below.

# Forward REGISTER to Asterisk
route[REGFWD] {
if(!is_method("REGISTER"))
 {
return;
}

# for each Asterisk server in setid=2 (External) we send a registration on
behalf of the user.
 sql_xquery("ca", "SELECT SUBSTRING_INDEX(destination,':',-1) AS port,
SUBSTRING_INDEX(SUBSTRING(destination,5),':',1) AS address
 FROM dispatcher WHERE setid = 2", "ra");
$var(i) = 0;
while($xavp(ra[$var(i)]) != $null)
{
$var(rip) = $xavp(ra[$var(i)]=>address);
$uac_req(method)="REGISTER";
$uac_req(ruri)="sip:" + $var(rip) + ":" + $xavp(ra[$var(i)]=>port);
 $uac_req(furi)="sip:" + $au + "@" + $var(rip);
$uac_req(turi)="sip:" + $au + "@" + $var(rip);
 $uac_req(hdrs)="Contact: \r\n";
if($sel(contact.expires) != $null)
 $uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $sel(contact.expires) +
"\r\n";
else
 $uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $hdr(Expires) + "\r\n";
uac_req_send();
$var(i) = $var(i) + 1;
}
 sql_result_free("ra");

}

# Test if coming from Asterisk. We check the dispatcher "ds_is_from_list()"
function to see if this is one of our Asterisk IPs
route[FROMASTERISK] {
if(ds_is_from_list())
{
return 1;
 } else {
return -1;
}
}

# Send to Asterisk
route[TOASTERISK] {

# If call comes in to the .75 iface, we need to send it to the .75 iface of
Asterisk as well.
 # otherwise we send to the .76 iface. We do this by calling different
dispatcher sets. This is
# because Asterisk needs to use NAT on the .76. (public) interface but not
on the .75.
 if($td=~"10.5.75.")
{
$var(setid) = 4;
 xlog("SCRIPT: Call to 10.5.75. ip - using set $var(setid) \n");
} else {
$var(setid) = 2;
 xlog("SCRIPT: Call from $fn to 10.5.76. ip - using set $var(setid) \n");
}
# round robin dispatching on set determined above
if(!ds_select_dst($var(setid), "4"))
{
send_reply("404", "No destination");
exit;
}
t_on_failure("RTF_DISPATCH");
route(RELAY);
  exit;
}




Hope this helps.

-Barry Flanagan
___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] [PATCH] Memory corruption using s.substr transformation

2013-04-30 Thread Andreas Granig

Hi,

We've seen this behaviour as well and worked around it using avp_subst 
with regex, as we didn't have the time yet to investigate further.


But basically I can confirm this issue.

Andreas

On 04/30/2013 01:31 PM, Martin Mikkelsen wrote:

On Tue, Apr 30, 2013 at 01:29:21PM +0200, Martin Mikkelsen wrote:

I am not sure what the best fix would be for that, but I have attached a
patch which copies the string in the TR_S_SUBST code to _tr_buffer and
returns that buffer instead like a lot of the other transformations in
that function does.

If this fix is correct some other transformation functions probably
needs to be corrected as well.


Forgot to attach the patch. Sorry.



___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


[SR-Users] gruu and dead-lock in registrar module

2013-04-30 Thread Andreas Granig

Hi,

We're hitting an issue in a deployment where all udp receivers are 
sitting in FUTEX_WAIT caused by save() -> lock_udomain() and seem to 
have deadlocked themselves every couple of days.


Looking at the code, enable_gruu in registrar is active by default, and 
in lookup there is a code path


/* temp-gruu lookup */
res = ul.get_urecord_by_ruid(_d, ahash, &inst, &r, &ptr);

but no lock_udomain is obtained. However, when the execution falls 
through to the "done:" marker, it does


ul.unlock_udomain(_d, &aor);

without having called ul.lock_udomain first.

1.) Could someone please review this part? Looks a bit suspicious, 
although I don't know what implicitly happens in this case. If it were a 
semaphore and you decrease it to -1 by decrementing it without prior 
increment, it's essentially causing a dead-lock, but the current locking 
implementation might work completely different.


2.) Since I have no clue how gruu is supposed to work in detail, and 
since in our config we don't explicitly handle gruu (no lookup in 
loose-route, but gruu is enabled by default in registrar and we don't 
explicitly turned it off), I'm not even sure if we ever hit this code 
path. I only see that the ruid column in the location table is filled, 
but in order to get to this part, the ";gr" flag needs to be set in the 
R-URI for a lookup(), which I don't know whether that happened somehow 
in some call flows (we only log $ru, which I don't think logs these 
parameters, right?).


Some input is highly appreciated!

Andreas

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] [PATCH] Memory corruption using s.substr transformation

2013-04-30 Thread Martin Mikkelsen
On Tue, Apr 30, 2013 at 02:42:22PM +0200, Andreas Granig wrote:
> Hi,
> 
> We've seen this behaviour as well and worked around it using
> avp_subst with regex, as we didn't have the time yet to investigate
> further.

I was also able to work around it with:

  $var(tmp) = $(var(x){s.substr,1,0});
  $var(x) = $(var(tmp));

> But basically I can confirm this issue.

It seems that at least the s.substr, s.select, s.strip, s.striptail,
line.at and line.sw transformations are vulnerable to this issue since
they reuse the input buffer. I think that the URI-parsing
transformations are also vulnerable since they also reuse the existing
input as far as I can see.

I can probably write a patch to change the 6 string transformations to
use _tr_buffer, but I dont know if that is the best solution. It may be
better to fix the variable assignment functions to make a copy of the
rvalue if it overlaps the lvalue before the assignment, maybe someone
who is more knowledgable with the kamailio source code can take a look
at this.

-- 
Martin Mikkelsen, Zisson AS

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] gruu and dead-lock in registrar module

2013-04-30 Thread Daniel-Constantin Mierla

Hello,

what version are you playing with? To look in the right branch when 
troubleshooting first time, then look at the others that might be 
affected...


Cheers,
Daniel

On 4/30/13 5:07 PM, Andreas Granig wrote:

Hi,

We're hitting an issue in a deployment where all udp receivers are 
sitting in FUTEX_WAIT caused by save() -> lock_udomain() and seem to 
have deadlocked themselves every couple of days.


Looking at the code, enable_gruu in registrar is active by default, 
and in lookup there is a code path


/* temp-gruu lookup */
res = ul.get_urecord_by_ruid(_d, ahash, &inst, &r, &ptr);

but no lock_udomain is obtained. However, when the execution falls 
through to the "done:" marker, it does


ul.unlock_udomain(_d, &aor);

without having called ul.lock_udomain first.

1.) Could someone please review this part? Looks a bit suspicious, 
although I don't know what implicitly happens in this case. If it were 
a semaphore and you decrease it to -1 by decrementing it without prior 
increment, it's essentially causing a dead-lock, but the current 
locking implementation might work completely different.


2.) Since I have no clue how gruu is supposed to work in detail, and 
since in our config we don't explicitly handle gruu (no lookup in 
loose-route, but gruu is enabled by default in registrar and we don't 
explicitly turned it off), I'm not even sure if we ever hit this code 
path. I only see that the ruid column in the location table is filled, 
but in order to get to this part, the ";gr" flag needs to be set in 
the R-URI for a lookup(), which I don't know whether that happened 
somehow in some call flows (we only log $ru, which I don't think logs 
these parameters, right?).


Some input is highly appreciated!

Andreas

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


--
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio Advanced Training, San Francisco, USA - June 24-27, 2013
  * http://asipto.com/u/katu *


___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] [PATCH] Memory corruption using s.substr transformation

2013-04-30 Thread Daniel-Constantin Mierla

Hello,

On 4/30/13 5:31 PM, Martin Mikkelsen wrote:

On Tue, Apr 30, 2013 at 02:42:22PM +0200, Andreas Granig wrote:

Hi,

We've seen this behaviour as well and worked around it using
avp_subst with regex, as we didn't have the time yet to investigate
further.

I was also able to work around it with:

   $var(tmp) = $(var(x){s.substr,1,0});
   $var(x) = $(var(tmp));


But basically I can confirm this issue.

It seems that at least the s.substr, s.select, s.strip, s.striptail,
line.at and line.sw transformations are vulnerable to this issue since
they reuse the input buffer. I think that the URI-parsing
transformations are also vulnerable since they also reuse the existing
input as far as I can see.

I can probably write a patch to change the 6 string transformations to
use _tr_buffer, but I dont know if that is the best solution. It may be
better to fix the variable assignment functions to make a copy of the
rvalue if it overlaps the lvalue before the assignment, maybe someone
who is more knowledgable with the kamailio source code can take a look
at this.

please do the patch to store the new value in _tr_buffer and attach it 
to mailing list or bug tracker. I haven't looked at code yet, but sounds 
like there is indeed an issue. I will review the patch and apply it.


Cheers,
Daniel

--
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio Advanced Training, San Francisco, USA - June 24-27, 2013
  * http://asipto.com/u/katu *


___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] gruu and dead-lock in registrar module

2013-04-30 Thread Andreas Granig

Hi Daniel,

On 04/30/2013 05:34 PM, Daniel-Constantin Mierla wrote:

what version are you playing with? To look in the right branch when
troubleshooting first time, then look at the others that might be
affected...


The affected version is latest 3.3 branch, but the same code is there in 
4.0 as well.


Andreas

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


[SR-Users] dlg_end_dlg

2013-04-30 Thread Dragos Oancea
Hi everyone,

I believe I've run into a problem when using dlg_end_dlg (with mi_datagram ) 
called from an external perl script with perl_exec() .

Kamailio just locks after a while (few seconds) after disconnecting a call.
Some parts of my debug log can be found here:
http://pastebin.com/ANaTEifC

The problem was observed while performing a stress test.
Is it a good idea to call dlg_end_dlg() like that or I can kill an established 
dialog from the routing script in some other way ? 

Regards,
Dragos
___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Kamailio 3.x and Asterisk Realtime Integration plus

2013-04-30 Thread Aldo Antignano
Thank you very much for your reply Barry.
Can you explain us yours ip 10.5.75. and 10.5.76. ?
Seems your asterisks have two interfaces, one private and one public?

In my infrastructure I have:
SIP client -> Kamailio  ---> Asterisk 01 
---> Asterisk 02
...
---> Asterisk N  

Only Kamailio has a public IP address.

In the REGFWD route you send all the registrations to ALL the Asterisks? 
If so, why?

I'm trying to achieve something like:

SIP clientA ---> REG ---> Kamailio  Is Asterisk01 alive?Yes --> REG 
---> Asterisk 01 

NO  --> Choose next one

---> Asterisk 02

...

---> Asterisk N  


---> Asterisk 01
SIP clientB ---> REG ---> Kamailio  Is Asterisl02 alive?Yes --> REG 
---> Asterisk 02 

NO  --> Choose next one

---> Asterisk 03

...

---> Asterisk N  
and so on, with a round robin algorithm.

When Sip ClientA want to call Sip ClientB, it asks Kamailio, that know that SIP 
Client B is
registered on Asterisk 02 and so send the invite to it.


I'm going to work over this in the next few days and let you know the result, 
if positive I'll write a new complete guide on this topic with your valuable 
suggestions.

Any suggestion is welcome

BR,
Anty


--
>> I have read and applied the excellent guide found on:
>> http://kb.asipto.com/asterisk:realtime:kamailio-3.3.x-asterisk-10.7.0-astdb
>>
>> Now I have added to Kamailio the HA/Load Balancer support, with the
>> "dispatcher" module.
>> This way I have 1 Kamailio and 2 Asterisk machines.
>>
>> How can I change the routing logic of the sections route[REGFWD] |
>> route[FROMASTERISK] route[TOASTERISK] to use the dispatcher module? (in the
>> guide above the asterisk binded ip address is cabled in the kamailio config
>> code)

I have done that. Relevant route entries below.

# Forward REGISTER to Asterisk
route[REGFWD] {
if(!is_method("REGISTER"))
 {
return;
}

# for each Asterisk server in setid=2 (External) we send a registration on
behalf of the user.
 sql_xquery("ca", "SELECT SUBSTRING_INDEX(destination,':',-1) AS port,
SUBSTRING_INDEX(SUBSTRING(destination,5),':',1) AS address
 FROM dispatcher WHERE setid = 2", "ra");
$var(i) = 0;
while($xavp(ra[$var(i)]) != $null)
{
$var(rip) = $xavp(ra[$var(i)]=>address);
$uac_req(method)="REGISTER";
$uac_req(ruri)="sip:" + $var(rip) + ":" + $xavp(ra[$var(i)]=>port);
 $uac_req(furi)="sip:" + $au + "@" + $var(rip);
$uac_req(turi)="sip:" + $au + "@" + $var(rip);
 $uac_req(hdrs)="Contact: \r\n";
if($sel(contact.expires) != $null)
 $uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $sel(contact.expires) +
"\r\n";
else
 $uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $hdr(Expires) + "\r\n";
uac_req_send();
$var(i) = $var(i) + 1;
}
 sql_result_free("ra");

}

# Test if coming from Asterisk. We check the dispatcher "ds_is_from_list()"
function to see if this is one of our Asterisk IPs
route[FROMASTERISK] {
if(ds_is_from_list())
{
return 1;
 } else {
return -1;
}
}

# Send to Asterisk
route[TOASTERISK] {

# If call comes in to the .75 iface, we need to send it to the .75 iface of
Asterisk as well.
 # otherwise we send to the .76 iface. We do this by calling different
dispatcher sets. This is
# because Asterisk needs to use NAT on the .76. (public) interface but not
on the .75.
 if($td=~"10.5.75.")
{
$var(setid) = 4;
 xlog("SCRIPT: Call to 10.5.75. ip - using set $var(setid) \n");
} else {
$var(setid) = 2;
 xlog("SCRIPT: Call from $fn to 10.5.76. ip - using set $var(setid) \n");
}
# round robin dispatching on set determined above
if(!ds_select_dst($var(setid), "4"))
{
send_reply("404", "No destination");
exit;
}
t_on_failure("RTF_DISPATCH");
route(RELAY);
  exit;
}


Hope this helps.

-Barry Flanagan



___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/

Re: [SR-Users] dlg_end_dlg

2013-04-30 Thread Daniel-Constantin Mierla

Hello,

does it block for few seconds and then goes on, or it locks after few 
seconds and stays locked?


If the second, attach with gdb to the pid of the locked process and get 
the backtrace.


Cheers,
Daniel

On 4/30/13 6:19 PM, Dragos Oancea wrote:

Hi everyone,

I believe I've run into a problem when using dlg_end_dlg (with 
mi_datagram ) called from an external perl script with perl_exec() .
Kamailio just locks after a while (few seconds) after disconnecting a 
call.

Some parts of my debug log can be found here:
http://pastebin.com/ANaTEifC

The problem was observed while performing a stress test.
Is it a good idea to call dlg_end_dlg() like that or I can kill an 
established dialog from the routing script in some other way ?


Regards,
Dragos



___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


--
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio Advanced Training, San Francisco, USA - June 24-27, 2013
  * http://asipto.com/u/katu *

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] dlg_end_dlg

2013-04-30 Thread Dragos Oancea
Hi Daniel,

It locks and stays locked. It is interesting that for a while ( 1-2 minutes 
while I am sending some traffic ) it can reply to REGISTER with a 200 OK ,  but 
it does not reply `100 Trying` to INVITE . Then nothing, no reply. 
 
gdb output here:
http://pastebin.com/Kg3hwzZT


Regards, 
Dragos




 From: Daniel-Constantin Mierla 
To: Dragos Oancea ; Kamailio (SER) - Users Mailing List 
 
Sent: Tuesday, April 30, 2013 6:26 PM
Subject: Re: [SR-Users] dlg_end_dlg
 


Hello,

does it block for few seconds and then goes on, or it locks after
few seconds and stays locked?

If the second, attach with gdb to the pid of the locked process and
get the backtrace.

Cheers,
Daniel


On 4/30/13 6:19 PM, Dragos Oancea wrote:

Hi everyone,
>
>
>I believe I've run into a problem when using dlg_end_dlg (with mi_datagram ) 
>called from an external perl script with perl_exec() .
>
>Kamailio just locks after a while (few seconds) after disconnecting a call.
>Some parts of my debug log can be found here:
>http://pastebin.com/ANaTEifC
>
>
>The problem was observed while performing a stress test.
>Is it a good idea to call dlg_end_dlg() like that or I can kill an established 
>dialog from the routing script in some other way ? 
>
>
>Regards,
>Dragos
>
>
>
>
>___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list 
sr-users@lists.sip-router.org 
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users 

-- 
Daniel-Constantin Mierla - http://www.asipto.com http://twitter.com/#!/miconda 
- http://www.linkedin.com/in/miconda Kamailio Advanced Training, San Francisco, 
USA - June 24-27, 2013 * http://asipto.com/u/katu *___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] dlg_end_dlg

2013-04-30 Thread Daniel-Constantin Mierla

Hello,

the backtrace is from the MI process, not a SIP worker. That process 
does not handle sip traffic.


Before you start testing you can do 'kamctl ps' and see which are the 
sip workers and get the backtrace from those pids.


Cheers,
Daniel

On 4/30/13 8:04 PM, Dragos Oancea wrote:

Hi Daniel,

It locks and stays locked. It is interesting that for a while ( 1-2 
minutes while I am sending some traffic ) it can reply to REGISTER 
with a 200 OK ,  but it does not reply `100 Trying` to INVITE . Then 
nothing, no reply.

gdb output here:
http://pastebin.com/Kg3hwzZT


Regards,
Dragos



*From:* Daniel-Constantin Mierla 
*To:* Dragos Oancea ; Kamailio (SER) - Users 
Mailing List 

*Sent:* Tuesday, April 30, 2013 6:26 PM
*Subject:* Re: [SR-Users] dlg_end_dlg

Hello,

does it block for few seconds and then goes on, or it locks after few 
seconds and stays locked?


If the second, attach with gdb to the pid of the locked process and 
get the backtrace.


Cheers,
Daniel

On 4/30/13 6:19 PM, Dragos Oancea wrote:

Hi everyone,

I believe I've run into a problem when using dlg_end_dlg (with 
mi_datagram ) called from an external perl script with perl_exec() .
Kamailio just locks after a while (few seconds) after disconnecting a 
call.

Some parts of my debug log can be found here:
http://pastebin.com/ANaTEifC

The problem was observed while performing a stress test.
Is it a good idea to call dlg_end_dlg() like that or I can kill an 
established dialog from the routing script in some other way ?


Regards,
Dragos



___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org  
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


--
Daniel-Constantin Mierla -http://www.asipto.com  
http://twitter.com/#!/miconda    
-http://www.linkedin.com/in/miconda
Kamailio Advanced Training, San Francisco, USA - June 24-27, 2013
   *http://asipto.com/u/katu  *




--
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio Advanced Training, San Francisco, USA - June 24-27, 2013
  * http://asipto.com/u/katu *

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] dlg_end_dlg

2013-04-30 Thread Dragos Oancea
Hi 

Yes, Daniel , you are right.

Here is a backtrace from a SIP worker: 
http://pastebin.com/t6XPQ6dx


Regards,
Dragos



 From: Daniel-Constantin Mierla 
To: Dragos Oancea ; Kamailio (SER) - Users Mailing List 
 
Sent: Tuesday, April 30, 2013 8:28 PM
Subject: Re: [SR-Users] dlg_end_dlg
 


Hello,

the backtrace is from the MI process, not a SIP worker. That process
does not handle sip traffic.

Before you start testing you can do 'kamctl ps' and see which are
the sip workers and get the backtrace from those pids.

Cheers,
Daniel


On 4/30/13 8:04 PM, Dragos Oancea wrote:

Hi Daniel,
>
>
>It locks and stays locked. It is interesting that for a while ( 1-2 minutes 
>while I am sending some traffic ) it can reply to REGISTER with a 200 OK ,  
>but it does not reply `100 Trying` to INVITE . Then nothing, no reply. 
> 
>gdb output here:
>http://pastebin.com/Kg3hwzZT
>
>
>
>
>Regards, 
>Dragos
>
>
>
>
>
>
> From: Daniel-Constantin Mierla 
>To: Dragos Oancea ; Kamailio (SER) - Users Mailing List 
> 
>Sent: Tuesday, April 30, 2013 6:26 PM
>Subject: Re: [SR-Users] dlg_end_dlg
> 
>
>
>Hello,
>
>does it block for few seconds and then goes on, or it
  locks after few seconds and stays locked?
>
>If the second, attach with gdb to the pid of the
  locked process and get the backtrace.
>
>Cheers,
>Daniel
>
>
>On 4/30/13 6:19 PM, Dragos Oancea wrote:
>
>Hi everyone,
>>
>>
>>I believe I've run into a problem when using dlg_end_dlg (with mi_datagram ) 
>>called from an external perl script with perl_exec() .
>>
>>Kamailio just locks after a while (few seconds) after disconnecting a call.
>>Some parts of my debug log can be found here:
>>http://pastebin.com/ANaTEifC
>>
>>
>>The problem was observed while performing a stress test.
>>Is it a good idea to call dlg_end_dlg() like that or I can kill an 
>>established dialog from the routing script in some other way ? 
>>
>>
>>Regards,
>>Dragos
>>
>>
>>
>>
>>___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list 
sr-users@lists.sip-router.org 
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users 
>
>-- 
Daniel-Constantin Mierla - http://www.asipto.com http://twitter.com/#!/miconda 
- http://www.linkedin.com/in/miconda Kamailio Advanced Training, San Francisco, 
USA - June 24-27, 2013 * http://asipto.com/u/katu *
>
>

-- 
Daniel-Constantin Mierla - http://www.asipto.com http://twitter.com/#!/miconda 
- http://www.linkedin.com/in/miconda Kamailio Advanced Training, San Francisco, 
USA - June 24-27, 2013 * http://asipto.com/u/katu *___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


[SR-Users] extra_id_pv parameter

2013-04-30 Thread Bruno Bresciani
Hi All,

I need forking a call to multiple destinations in paralel on different
network segments, requiring different rtpproxy parameters. Reading the
rtpproxy module documentation I discovered that is possible by setting the
"b" parameter on rtpproxy_manage(), rtpproxy_offer(), rtpproxy_answer() and
rtpproxy_destroy() functions, but I'm with some doubts...

I can't understanding how set the extra_id_pv parameter correctly to use
when the "b" parameter is used.

The "b" parameter is supported on rtpproxy version 1.2.1?

Best Regards
___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Kamailio 3.x and Asterisk Realtime Integration plus

2013-04-30 Thread Barry Flanagan
On 30 April 2013 17:23, Aldo Antignano  wrote:

> Thank you very much for your reply Barry.
> Can you explain us yours ip 10.5.75. and 10.5.76. ?
> Seems your asterisks have two interfaces, one private and one public?
>
>
Sorry, yeah. you should probably ignore that part :-) The same dispatcher
deals with client connections from the "public" network as well as inbound
calls from a pstn gateway which is on a "private" network. Asterisk is
behind NAT for the public clients (Openstack cloud) so by sending the
request on the .76 network Asterisk uses its externhost setting as the IP
address for the RTP. Unless you are running this on a virtualized
environment it is probably not relevant.


> In my infrastructure I have:
> SIP client -> Kamailio  ---> Asterisk 01
> ---> Asterisk 02
> ...
> ---> Asterisk N
>
> Only Kamailio has a public IP address.
>
> In the REGFWD route you send all the registrations to ALL the Asterisks?
> If so, why?
>
>
By sending the registration to all the available Asterisk servers then they
all know  where each SIP client can be located. If a call comes in from the
PSTN or from a SIP client Kamailio can just be sent it to any of the *
servers and it will find the registered client. This will work even with
multiple load balancers/dispatchers using DNS SRV.

In this scenario Kamailio is mainly acting as a load balancer, topology
hider and security/anti-flood front-end to create a scalable and redundant
Asterisk PBX system. Really depends what you are after. For this particular
implementation I was not overly concerned with having too many
registrations for it to be a problem for Asterisk, so sending them to all
servers was not an issue

Regards,

-Barry Flanagan


I'm trying to achieve something like:
>
> SIP clientA ---> REG ---> Kamailio  Is Asterisk01 alive?Yes -->
> REG ---> Asterisk 01
>
>   NO  --> Choose next one
>
>   ---> Asterisk 02
>
>   ...
>
>   ---> Asterisk N
>
>
>   ---> Asterisk 01
> SIP clientB ---> REG ---> Kamailio  Is Asterisl02 alive?Yes -->
> REG ---> Asterisk 02
>
>   NO  --> Choose next one
>
>   ---> Asterisk 03
>
>   ...
>
>   ---> Asterisk N
> and so on, with a round robin algorithm.
>
> When Sip ClientA want to call Sip ClientB, it asks Kamailio, that know
> that SIP Client B is
> registered on Asterisk 02 and so send the invite to it.
>
>
> I'm going to work over this in the next few days and let you know the
> result,
> if positive I'll write a new complete guide on this topic with your
> valuable suggestions.
>
> Any suggestion is welcome
>
> BR,
> Anty
>
>
>
> --
> >> I have read and applied the excellent guide found on:
> >>
> http://kb.asipto.com/asterisk:realtime:kamailio-3.3.x-asterisk-10.7.0-astdb
> >>
> >> Now I have added to Kamailio the HA/Load Balancer support, with the
> >> "dispatcher" module.
> >> This way I have 1 Kamailio and 2 Asterisk machines.
> >>
> >> How can I change the routing logic of the sections route[REGFWD] |
> >> route[FROMASTERISK] route[TOASTERISK] to use the dispatcher module? (in
> the
> >> guide above the asterisk binded ip address is cabled in the kamailio
> config
> >> code)
>
> I have done that. Relevant route entries below.
>
> # Forward REGISTER to Asterisk
> route[REGFWD] {
> if(!is_method("REGISTER"))
>  {
> return;
> }
>
> # for each Asterisk server in setid=2 (External) we send a registration on
> behalf of the user.
>  sql_xquery("ca", "SELECT SUBSTRING_INDEX(destination,':',-1) AS port,
> SUBSTRING_INDEX(SUBSTRING(destination,5),':',1) AS address
>  FROM dispatcher WHERE setid = 2", "ra");
> $var(i) = 0;
> while($xavp(ra[$var(i)]) != $null)
> {
> $var(rip) = $xavp(ra[$var(i)]=>address);
> $uac_req(method)="REGISTER";
> $uac_req(ruri)="sip:" + $var(rip) + ":" + $xavp(ra[$var(i)]=>port);
>  $uac_req(furi)="sip:" + $au + "@" + $var(rip);
> $uac_req(turi)="sip:" + $au + "@" + $var(rip);
>  $uac_req(hdrs)="Contact:  + $sel(cfg_get.kamailio.bindip)
>  + ":" + $sel(cfg_get.kamailio.bindport) + ">\r\n";
> if($sel(contact.expires) != $null)
>  $uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $sel(contact.expires) +
> "\r\n";
> else
>  $uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $hdr(Expires) + "\r\n";
> uac_req_send();
> $var(i) = $var(i) + 1;
> }
>  sql_result_free("ra");
>
> }
>
> # Test if coming from Asterisk. We check the dispatcher "ds_is_from_list()"
> function to see if this is one of our Asterisk IPs
> route[FROMASTERISK] {
> if(ds_is_from_list())
> {
> return 1;
>  } else {
> return -1;
> }
> }
>
> # Send to Asterisk
> route[TOASTERISK] {
>
> # If call comes in to the .75 iface, we 

Re: [SR-Users] Kamailio 3.x and Asterisk Realtime Integration plus dispatcher

2013-04-30 Thread Aldo Antignano
> Sorry, yeah. you should probably ignore that part :-) The same dispatcher
>deals with client connections from the "public" network as well as inbound

Ok thanks, it's clear now. :)

>> In the REGFWD route you send all the registrations to ALL the Asterisks?
>> If so, why?

> By sending the registration to all the available Asterisk servers then they
> all know  where each SIP client can be located. If a call comes in from the
> PSTN or from a SIP client Kamailio can just be sent it to any of the *
> servers and it will find the registered client. This will work even with
> multiple load balancers/dispatchers using DNS SRV.

In this way should be an option to keep registration in Kamailio only,
let Asterisk do its specific job, and configure Asterisk to accept all calls 
coming from Kamailio as authorized calls by its IP?

> In this scenario Kamailio is mainly acting as a load balancer, topology
> hider and security/anti-flood front-end to create a scalable and redundant
> Asterisk PBX system. Really depends what you are after. 

These are exactly my goals and was trying to understand which is the best way 
to achieve this.
Any suggestion is welcome, thanks.

Anty




--

Message: 3
Date: Tue, 30 Apr 2013 23:02:20 +0100
From: Barry Flanagan 
To: "Kamailio (SER) - Users Mailing List"

Subject: Re: [SR-Users] Kamailio 3.x and Asterisk Realtime Integration
plus
Message-ID:

Content-Type: text/plain; charset="utf-8"




> ___
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users@lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.sip-router.org/pipermail/sr-users/attachments/20130430/95b9dbb4/attachment.html>

--

___
sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


End of sr-users Digest, Vol 96, Issue 1
***



___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users