I am not using a branch routing block at present, I am doing modifications using values I pull from the location table.
So my question may be slightly different but very much branch related.
So I have two contacts;
Contact:: <sip:1009@213.123.211.158:15060;transport=udp;registering_acc=91_208_141_34>;q=;expires=60;flags=0x0;cflags=0x0;state=1;socket=<udp:xx.xx.xx.xx:5060>;methods=0xFFFFFFFF;user_agent=<Contact1>;reg-id=0
Contact:: <sip:1009@213.123.211.158:5061;transport=udp>;q=;expires=3191;flags=0x0;cflags=0xC0;state=1;socket=<udp:xx.xx.xx.xx:5060>;methods=0xFFFFFFFF;received=<sip:213.123.211.158:49827>;user_agent=<Contact2>;+sip.instance=<urn:uuid:00000000-0000-0000-0000-58bfea20a6bd>;reg-id=0
Then using reg_fetch_contacts I get for each registered contact;
xlog("callee=>user_agent: $(ulc(callee=>user_agent)[$var(i)])\n");
xlog("callee=>received: $(ulc(callee=>received)[$var(i)])\n");
xlog("callee=>addr1: $(ulc(callee=>addr)[$var(i)])\n");
And define some variables as a result for each contact;
$var(ua1) = $(ulc(callee=>user_agent)[$var(i)]);
$var(ua1add) = $(ulc(callee=>received)[$var(i)]);
$var(ua1aor) = $(ulc(callee=>addr)[$var(i)]);
I then use these to set $du and $ru in the main routing, I do this for contact2 above, so I send to the recieved port (49827), identifying this by user agent type.
This works fine however branch[0] was sending an INVITE TO 1009@213.123.211.158:5061, contact2 also, and not contact1 (port 15060), so I have added;
$(branch(dst_uri)[0]) = $var(ua1aor);
So I now get parallel forking as follows;
INVITE sip:1009-@213.123.211.158:49827 < This is what I want, for Contact2
INVITE sip:1009-@213.123.211.158:15060 < Again routes to Contact1 after modifiying the branch parameter.
INVITE sip:1009-@213.123.211.158:5061 < Still sends out original branch value.
And can see from debug, my branch [0] is modifed, but branch [1] is also created;
new branch [0] to sip:1009@213.123.211.158:49827
new branch [1] to sip:1009@213.123.211.158:5061
So I now have 3 invites for 2 devices.
Whats the best approach to clean this up or implement in the first place, my main question is probably around branch modification/control.
Thanks, sorry for long question.
Jon