I am working on extending $hfl and $hflc to support some more headers.
During some experimentation, I stumbled into some weird behavior regarding $(hfl(Route)[-1]) and negative indexing of $hfl pseudo-variable (also for Via, Contact).
Per the docs : -1 index should print the last header found and so on (as stated by $hdr $hfl).
Right now, -1 produces null, and from -2 and onwards it prints correctly from the last one to the first one.
#kamailio.cfg
...
request_route {
xlog("L_INFO", "Route headers hdr: $hdr(Route)\n");
xlog("L_INFO", "Route headers hfl: $hfl(Route)\n");
xlog("L_INFO", "Route headers count: $hflc(Route)\n");
xlog("L_INFO", "Route headers 0: $(hfl(Route)[0])\n");
xlog("L_INFO", "Route headers 1: $(hfl(Route)[1])\n");
xlog("L_INFO", "Route headers 4: $(hfl(Route)[4])\n");
xlog("L_INFO", "Route headers -1: $(hfl(Route)[-1])\n");
xlog("L_INFO", "Route headers -2: $(hfl(Route)[-2])\n");
xlog("L_INFO", "Route headers -3: $(hfl(Route)[-3])\n");
...
}
Seng a SIP message containing Route (but also applicable for VIA, Contact headers):
OPTIONS_MSG_2CONTACTS="OPTIONS sip:example.com SIP/2.0
Via: SIP/2.0/UDP 192.168.1.100:5060;branch=z9hG4bK123456789
Max-Forwards: 70
From: <sip:bob@example.com>;tag=123456789
To: <sip:alice@example.com>
Call-ID: 987654321@192.168.1.100
CSeq: 1 OPTIONS
Contact: <sip:bob@example.com>;expires=3600,<sip:bob2@example.com>;expires=3600,<sip:bob3@example.com>;expires=3600
Route: <sip:server1.example.com;lr;ftag=1234>, <sip:server2.example.com;lr;ftag=5678>, <sip:server3.example.com;lr;ftag=9012>
Route: <sip:server4.example.com;lr;ftag=1234>, <sip:server5.example.com;lr;ftag=5678>
Content-Length: 0
"
echo -e "$OPTIONS_MSG_2CONTACTS" | nc -u localhost 5060
See logs for logging details.
INFO: {1 1 OPTIONS 987654321@192.168.1.100} <script>: Route headers hdr: <sip:server1.example.com;lr;ftag=1234>, <sip:server2.example.com;lr;ftag=5678>, <sip:server3.example.com;lr;ftag=9012>
INFO: {1 1 OPTIONS 987654321@192.168.1.100} <script>: Route headers hfl: <sip:server1.example.com;lr;ftag=1234>
INFO: {1 1 OPTIONS 987654321@192.168.1.100} <script>: Route headers count: 5
INFO: {1 1 OPTIONS 987654321@192.168.1.100} <script>: Route headers 0: <sip:server1.example.com;lr;ftag=1234>
INFO: {1 1 OPTIONS 987654321@192.168.1.100} <script>: Route headers 1: <sip:server2.example.com;lr;ftag=5678>
INFO: {1 1 OPTIONS 987654321@192.168.1.100} <script>: Route headers 4: <sip:server5.example.com;lr;ftag=5678>
INFO: {1 1 OPTIONS 987654321@192.168.1.100} <script>: Route headers -1: <null>
INFO: {1 1 OPTIONS 987654321@192.168.1.100} <script>: Route headers -2: <sip:server5.example.com;lr;ftag=5678>
INFO: {1 1 OPTIONS 987654321@192.168.1.100} <script>: Route headers -3: <sip:server4.example.com;lr;ftag=1234>
In https://github.com/kamailio/kamailio/blob/e59c4415707f0995a0d5315b5601ae518b4f1ed5/src/modules/pv/pv_core.c#L2145C2-L2163, the count should start at 0 ie.
n=0; // not n=1;
kamailio -v
(paste your output here)
(paste your output here)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.