Hi List
I'm trying to inspect the content of the $xavp(tm_contacts) to figure out how t_load_contacts exactly behaves when called multiple times.
$var(k) = 0; while ($xavp(tm_contacts[$var(k)]) != $null) { $var(out) = "nothing"; xavp_params_implode("tm_contacts[$var(k)]", "$var(out)"); xlog("L_INFO", "$cfg(route): tm_contacts idx: $var(k) => $var(out)\n"); $var(k) = $var(k) + 1; }
My stack contains multiple entries.
Unfortunately I struggle to access the lower entries.
xavp_params_implode("tm_contacts[$var(k)]", "$var(out)");
does nothing when $var(k) > 0
What is the best way to dump a complete xavp stack?
I suspect t_load_contacts does flush the complete stack. Is there a way to stack an xavp on top of another one?
Something like:
xavp_rm("contact_stack"); # Initialize Stack
lookup("location", "sip:alice@example.com"); t_load_contacts(0);
$xavp(contact_stack) = $xavp(tm_contacts);
lookup("location", "sip:bob@example.com"); t_load_contacts(0);
$xavp(contact_stack) = $xavp(tm_contacts); # contact_stack now contains alice + bob
lookup("location", "sip:carlie@example.com"); t_load_contacts(0);
# $xavp(tm_contacts) now contains only charlie.
$xavp(tm_contacts) = $xavp(contact_stack);
# $xavp(tm_contacts) now contains only alice, bob + charlie.
t_next_contacts(); # Push contacts to destination list creating branches. t_relay(); # Invite all contacts
Mit freundlichen Grüssen
-Benoît Panizzon-
Hi,
You can use $cnt(pv) to count the number of xvps…
https://www.kamailio.org/wikidocs/cookbooks/5.8.x/pseudovariables/#cntpv-cou...
And then do a while ($xavp(tm_contacts[$var(k)]) < the count.
Regards,
Fred Posner
On Dec 10, 2024, at 5:47 AM, Benoit Panizzon via sr-users sr-users@lists.kamailio.org wrote:
Hi List
I'm trying to inspect the content of the $xavp(tm_contacts) to figure out how t_load_contacts exactly behaves when called multiple times.
$var(k) = 0; while ($xavp(tm_contacts[$var(k)]) != $null) { $var(out) = "nothing"; xavp_params_implode("tm_contacts[$var(k)]", "$var(out)"); xlog("L_INFO", "$cfg(route): tm_contacts idx: $var(k) => $var(out)\n"); $var(k) = $var(k) + 1; }
My stack contains multiple entries.
Unfortunately I struggle to access the lower entries.
xavp_params_implode("tm_contacts[$var(k)]", "$var(out)");
does nothing when $var(k) > 0
What is the best way to dump a complete xavp stack?
I suspect t_load_contacts does flush the complete stack. Is there a way to stack an xavp on top of another one?
Something like:
xavp_rm("contact_stack"); # Initialize Stack
lookup("location", "sip:alice@example.com"); t_load_contacts(0);
$xavp(contact_stack) = $xavp(tm_contacts);
lookup("location", "sip:bob@example.com"); t_load_contacts(0);
$xavp(contact_stack) = $xavp(tm_contacts); # contact_stack now contains alice + bob
lookup("location", "sip:carlie@example.com"); t_load_contacts(0);
# $xavp(tm_contacts) now contains only charlie.
$xavp(tm_contacts) = $xavp(contact_stack);
# $xavp(tm_contacts) now contains only alice, bob + charlie.
t_next_contacts(); # Push contacts to destination list creating branches. t_relay(); # Invite all contacts
Mit freundlichen Grüssen
-Benoît Panizzon-
I m p r o W a r e A G - Leiter Commerce Kunden ______________________________________________________
Zurlindenstrasse 29 Tel +41 61 826 93 00 CH-4133 Pratteln Fax +41 61 826 93 01 Schweiz Web http://www.imp.ch ______________________________________________________ __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
Hi Fred
And then do a while ($xavp(tm_contacts[$var(k)]) < the count.
while ($xavp(tm_contacts[$var(k)]) != $null) { $var(out) = "nothing"; xavp_params_implode("tm_contacts[$var(k)]", "$var(out)");
I guess this is allmost the same but my issue is with the last line when I try to implode a specific element of the stack into $var(out) If it's not element 0 I get 'nothing' and I am sure there is content.
Mit freundlichen Grüssen
-Benoît Panizzon-
Hi,
$cnt is useful -- didn't know about it!
But I wonder, can you not just combine these operations into one loop?
while($xavp(tm_contacts[$var(k)]) ne $null)
or
while(defined $xavp(tm_contacts[$var(k)]))
-- Alex
On Dec 10, 2024, at 8:32 am, Fred Posner via sr-users sr-users@lists.kamailio.org wrote:
Hi,
You can use $cnt(pv) to count the number of xvps…
https://www.kamailio.org/wikidocs/cookbooks/5.8.x/pseudovariables/#cntpv-cou...
And then do a while ($xavp(tm_contacts[$var(k)]) < the count.
Regards,
Fred Posner
On Dec 10, 2024, at 5:47 AM, Benoit Panizzon via sr-users sr-users@lists.kamailio.org wrote:
Hi List
I'm trying to inspect the content of the $xavp(tm_contacts) to figure out how t_load_contacts exactly behaves when called multiple times.
$var(k) = 0; while ($xavp(tm_contacts[$var(k)]) != $null) { $var(out) = "nothing"; xavp_params_implode("tm_contacts[$var(k)]", "$var(out)"); xlog("L_INFO", "$cfg(route): tm_contacts idx: $var(k) => $var(out)\n"); $var(k) = $var(k) + 1; }
My stack contains multiple entries.
Unfortunately I struggle to access the lower entries.
xavp_params_implode("tm_contacts[$var(k)]", "$var(out)");
does nothing when $var(k) > 0
What is the best way to dump a complete xavp stack?
I suspect t_load_contacts does flush the complete stack. Is there a way to stack an xavp on top of another one?
Something like:
xavp_rm("contact_stack"); # Initialize Stack
lookup("location", "sip:alice@example.com"); t_load_contacts(0);
$xavp(contact_stack) = $xavp(tm_contacts);
lookup("location", "sip:bob@example.com"); t_load_contacts(0);
$xavp(contact_stack) = $xavp(tm_contacts); # contact_stack now contains alice + bob
lookup("location", "sip:carlie@example.com"); t_load_contacts(0);
# $xavp(tm_contacts) now contains only charlie.
$xavp(tm_contacts) = $xavp(contact_stack);
# $xavp(tm_contacts) now contains only alice, bob + charlie.
t_next_contacts(); # Push contacts to destination list creating branches. t_relay(); # Invite all contacts
Mit freundlichen Grüssen
-Benoît Panizzon-
I m p r o W a r e A G - Leiter Commerce Kunden ______________________________________________________
Zurlindenstrasse 29 Tel +41 61 826 93 00 CH-4133 Pratteln Fax +41 61 826 93 01 Schweiz Web http://www.imp.ch ______________________________________________________ __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
Hi
But I wonder, can you not just combine these operations into one loop?
My issue is not the loop, that works fine.
My issue is accessing / dumping the content of the xavp element 'k' in this loop.
And then the next challenge is, how to concatenate two xavp stacks.
All with the goal to be able to parallel branch a call to multiple destinations gathered from locations contact of multiple AoR (in case I am trying to overcomplicate this, please tell me the obvious solution I'm missing :-) )
Mit freundlichen Grüssen
-Benoît Panizzon-
Would `xavp_params_implode()` work for you? https://kamailio.org/docs/modules/5.6.x/modules/pv.html#pv.f.xavp_params_imp...
Regards, Kaufman
________________________________ From: Benoit Panizzon via sr-users sr-users@lists.kamailio.org Sent: Tuesday, December 10, 2024 8:23 AM To: Alex Balashov via sr-users sr-users@lists.kamailio.org Cc: Benoit Panizzon benoit.panizzon@imp.ch Subject: [SR-Users] Re: How to inspect/dump a stacked xavp? / How to stack two xavp on each other?
CAUTION: This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
Hi
But I wonder, can you not just combine these operations into one loop?
My issue is not the loop, that works fine.
My issue is accessing / dumping the content of the xavp element 'k' in this loop.
And then the next challenge is, how to concatenate two xavp stacks.
All with the goal to be able to parallel branch a call to multiple destinations gathered from locations contact of multiple AoR (in case I am trying to overcomplicate this, please tell me the obvious solution I'm missing :-) )
Mit freundlichen Grüssen
-Benoît Panizzon- -- I m p r o W a r e A G - Leiter Commerce Kunden ______________________________________________________
Zurlindenstrasse 29 Tel +41 61 826 93 00 CH-4133 Pratteln Fax +41 61 826 93 01 Schweiz Web https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.imp.ch%...http://www.imp.ch/ ______________________________________________________ __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
Hi Ben
Would `xavp_params_implode()` work for you? https://kamailio.org/docs/modules/5.6.x/modules/pv.html#pv.f.xavp_params_imp...
That is exactly what I try to do:
$var(k) = 0; while ($xavp(tm_contacts[$var(k)]) != $null) { $var(out) = "nothing"; xavp_params_implode("tm_contacts[$var(k)]", "$var(out)"); xlog("L_INFO", "$cfg(route): tm_contacts idx: $var(k) => $var(out)\n"); $var(k) = $var(k) + 1; }
I know there are 4 elements on the stack as the while looks runs for k from 0 to 3.
But $var(out) only contains data when k is 0 so I am unable to dump the other elements on the stack.
Mit freundlichen Grüssen
-Benoît Panizzon-
On Dec 10, 2024, at 9:23 am, Benoit Panizzon benoit.panizzon@imp.ch wrote:
All with the goal to be able to parallel branch a call to multiple destinations gathered from locations contact of multiple AoR (in case I am trying to overcomplicate this, please tell me the obvious solution I'm missing :-) )
You might be overcomplicating this, as parallel forking is out-of-the-box behaviour for lookup(), provided that `append_branches` is set to 1:
https://kamailio.org/docs/modules/5.8.x/modules/registrar.html#idm175
It's the serial forking across contacts that takes extra work. With the parallel forking, you don't need to mess with t_load_contacts() / t_next_contacts() at all.
-- Alex
Hi Alex
You might be overcomplicating this, as parallel forking is out-of-the-box behaviour for lookup(), provided that `append_branches` is set to 1:
https://kamailio.org/docs/modules/5.8.x/modules/registrar.html#idm175
It's the serial forking across contacts that takes extra work. With the parallel forking, you don't need to mess with t_load_contacts() / t_next_contacts() at all.
This is, why I first try to get parallel forking to work, but somehow I don't.
Again what I want to do in this, I assume, simple and common scenario:
I have AoR alice registered with 4 contacts all with q=0.5 I have AoR bob registered with 1 contact with q=0.5
I try to get those total of 5 contacts in my destination set and parallel fork a call to those 5 contacts.
I got this working the 'very hard' way by making use of reg_fetch_contacts and append_branch and setting 'most' branch values from the $ulc() variables, but this need manual tweaking each time I add some functionality like NAT or PATH support.
=> There must be an easier way, right?
What am I missing with the lookup() function to make this work 'out-of-the-box'?
Mit freundlichen Grüssen
-Benoît Panizzon-
Hello,
just using lookup() should do the job. It should create additional branches at the execution of t_relay(). If its not working maybe the module is configured in a non-standard way.
Cheers,
Henning
-----Original Message----- From: Benoit Panizzon via sr-users sr-users@lists.kamailio.org Sent: Tuesday, December 10, 2024 4:22 PM To: Alex Balashov via sr-users sr-users@lists.kamailio.org Cc: Benoit Panizzon benoit.panizzon@imp.ch Subject: [SR-Users] Re: How to inspect/dump a stacked xavp? / How to stack two xavp on each other?
Hi Alex
You might be overcomplicating this, as parallel forking is out-of-the-box behaviour for lookup(), provided that `append_branches` is set to 1:
https://kamailio.org/docs/modules/5.8.x/modules/registrar.html#idm175
It's the serial forking across contacts that takes extra work. With the parallel forking, you don't need to mess with t_load_contacts() / t_next_contacts() at all.
This is, why I first try to get parallel forking to work, but somehow I don't.
Again what I want to do in this, I assume, simple and common scenario:
I have AoR alice registered with 4 contacts all with q=0.5 I have AoR bob registered with 1 contact with q=0.5
I try to get those total of 5 contacts in my destination set and parallel fork a call to those 5 contacts.
I got this working the 'very hard' way by making use of reg_fetch_contacts and append_branch and setting 'most' branch values from the $ulc() variables, but this need manual tweaking each time I add some functionality like NAT or PATH support.
=> There must be an easier way, right?
What am I missing with the lookup() function to make this work 'out-of-the-box'?
Mit freundlichen Grüssen
-Benoît Panizzon-
Hello,
maybe printing all xavps and analyzing the output is a simpler way to try:
- https://www.kamailio.org/docs/modules/stable/modules/pv.html#pv.f.pv_xavp_pr...
Cheers, Daniel
On 10.12.24 11:47, Benoit Panizzon via sr-users wrote:
Hi List
I'm trying to inspect the content of the $xavp(tm_contacts) to figure out how t_load_contacts exactly behaves when called multiple times.
$var(k) = 0; while ($xavp(tm_contacts[$var(k)]) != $null) { $var(out) = "nothing"; xavp_params_implode("tm_contacts[$var(k)]", "$var(out)"); xlog("L_INFO", "$cfg(route): tm_contacts idx: $var(k) => $var(out)\n"); $var(k) = $var(k) + 1; }
My stack contains multiple entries.
Unfortunately I struggle to access the lower entries.
xavp_params_implode("tm_contacts[$var(k)]", "$var(out)");
does nothing when $var(k) > 0
What is the best way to dump a complete xavp stack?
I suspect t_load_contacts does flush the complete stack. Is there a way to stack an xavp on top of another one?
Something like:
xavp_rm("contact_stack"); # Initialize Stack
lookup("location", "sip:alice@example.com"); t_load_contacts(0);
$xavp(contact_stack) = $xavp(tm_contacts);
lookup("location", "sip:bob@example.com"); t_load_contacts(0);
$xavp(contact_stack) = $xavp(tm_contacts); # contact_stack now contains alice + bob
lookup("location", "sip:carlie@example.com"); t_load_contacts(0);
# $xavp(tm_contacts) now contains only charlie.
$xavp(tm_contacts) = $xavp(contact_stack);
# $xavp(tm_contacts) now contains only alice, bob + charlie.
t_next_contacts(); # Push contacts to destination list creating branches. t_relay(); # Invite all contacts
Mit freundlichen Grüssen
-Benoît Panizzon-
I m p r o W a r e A G - Leiter Commerce Kunden ______________________________________________________
Zurlindenstrasse 29 Tel +41 61 826 93 00 CH-4133 Pratteln Fax +41 61 826 93 01 Schweiz Web http://www.imp.ch ______________________________________________________ __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!