Hi
https://www.kamailio.org/wiki/cookbooks/devel/pseudovariables#branch_name_-_...
"Assigning $null to uri attribute will drop the branch, for the rest of attributes will just set the value to null."
Where do I need to assing $null to the brach URI to get it dropped? And what happens to the index, is there a gap, or do the subsequent branches get re-indexed so they don't match with the ulc indexes anymore?
Actual example, I have multiple contacts I would like to add to branches.
Two of the contacts are from the location database + an additional contact.
# Basic Branch: $ru = $(ulc(aor=>addr)[0]); $du = $(ulc(aor=>received)[0]); $fs = $(ulc(aor=>socket)[0]);
# Additional Branch: append_branch($(ulc(aor=>addr)[1])); $(branch(dst_uri)[-1]) = $(ulc(aor=>received)[1]); $(branch(send_socket)[-1]) = $(ulc(aor=>socket)[1]);
and so on, actually a loop over all ulc contacts.
# Lasst Additional Branch, point to other registrar, not to a usrloc location. append_branch($ru); $(branch(dst_uri)[-1]) = "sip:other-registrar:5060;transport=udp"; $fsn = "LocalUDPv4"; $(branch(send_socket)[-1]) = $fs;
t_on_branch("BR_T");
branch_route[BR_T] { $var(socket) = $(ulc(aor=>socket)[$T_branch_idx]); if ($var(socket) == 0) { xlog("L_INFO", "$cfg(route): DROPPING BRANCH: $T_branch_idx No local socket on this registrar\n"); $(branch(uri)[$T_branch_idx]) = $null; } }
I don't get this right! Call is still sent to that contact.
Ok I re-worked this.
I'm not adding branches I don't want anymore.
But I still need to access:
$(ulc(aor=>user_agent)[INDEX]) from within the branch route to tweak some headers for specific user agents.
The ulc INDEX does not match the Branch INDEX.
How can I pass an information into a branch route which is specific to a branch route like the user_agent associated with the registration to which the call is sent?
I finally worked it out.
$var(c) = 0; Branch Count
looping through the ul:
append_branch($(ulc(aor=>addr)[$var(i)])); $(branch(dst_uri)[-1]) = $(ulc(aor=>received)[$var(i)]); $(branch(send_socket)[-1]) = $(ulc(aor=>socket)[$var(i)]); $avp(ua) = $(ulc(aor=>user_agent)[$var(i)]); $var(c) = $var(c) + 1;
branch_route[BR_T] { $var(uax) = $var(c) - $T_branch_idx - 1; xlog("L_INFO", "$cfg(route): BR_idx: $T_branch_idx UAX: $var(uax) User Agent: $(avp(ua)[$var(uax)]) \n"); route(FILTER_USERAGENT); # Do user_agent specific stuff. }
I hope append_branch works by adding at the end of the index and never inserting a branch in between.