Hello,
I am currently working on a scenario where I need to use Kamailio in the failure_route to
process SIP responses, specifically handling negative SIP replies (e.g., 486 Busy Here)
that Kamailio may receive.
Here is the topology:
##B2BUA (acts as a UAC with the Kamailio, because it sends the INVITE) -> Kamailio
-> Callee##
In my setup, Kamailio needs to extract all Via headers from the received SIP response in
the failure_route, focusing particularly on the bottom Via header (from the B2BUA' UAC
part). However, I am encountering difficulties in achieving this. Here is what I have
tried so far:
1. To extract the Via headers, I used the following line of code in the failure_route:
```$var(viaHeaderValues) = $T_rpl($hdr(Via));```
However, this only returns the topmost Via header.
2. I attempted to get the first and last Via headers values with:
```$var(viaHeaderValueFirst) = $T_rpl($hdr(Via)[0]);
$var(viaHeaderValueLast) = $T_rpl($hdr(Via)[1]);```
Unfortunately, this also only returns the topmost Via header, which contains the
address of Kamailio.
My goal is to make sure that when Kamailio sends the SIP reply to the UAC with send_reply
method on the failure_route, it uses the extracted *Via header* of the incoming SIP
response (only the bottom one). Here is an example scenario:
- Received SIP Response in kamailio:
```
SIP/2.0 486 Busy Here
Via: SIP/2.0/UDP
200.200.200.4;branch=z9hG4bK9157.090080a91105c0ec6279bb56882d1dc8.0
Via: SIP/2.0/UDP
200.200.200.3;received=200.200.200.3;rport=5060;branch=z9hG4bKF1aaZ7ea7yc2m
From: <sip:caller@200.200.200.3>;tag=222222
To: <sip:callee@200.200.200.4:5060>;tag=4545454
Call-ID: 65695DSQ(a)200.200.200.3
CSeq: 1 INVITE
Content-Length: 0
```
- Desired SIP Response from kamailio:
```
SIP/2.0 486 Busy Here
Via: SIP/2.0/UDP
200.200.200.3;received=200.200.200.3;rport=5060;branch=z9hG4bKF1aaZ7ea7yc2m
From: <sip:caller@200.200.200.3>;tag=222222
To: <sip:callee@200.200.200.4:5060>;tag=4545454
Call-ID: 65695DSQ(a)200.200.200.3
CSeq: 1 INVITE
Content-Length: 0
```
The current issue is that Kamailio modifies the Via header when sending the reply with
send_reply method, resulting in:
```
SIP/2.0 486 Busy Here
Via: SIP/2.0/UDP
200.200.200.3;rport=5060;branch=z9hG4bKF1aaZ7ea7yc2m;received=200.200.200.3
From: <sip:caller@200.200.200.3>;tag=222222
To: <sip:callee@200.200.200.4:5060>;tag=4545454
Call-ID: 65695DSQ(a)200.200.200.3
CSeq: 1 INVITE
Content-Length: 0
```
Due to this change, the UAC does not correctly react to or understand the SIP response
"SIP Reply follows the RFC standards, but my current UAC waits for a Via that looks
like Via of the previous SIP messages in the structure of parameters.". It is crucial
for the Via header to maintain the same important order such as the branch, received, and
rport values as the previous exchanged SIP messages.
Could you please provide guidance on how to force Kamailio to send the SIP reply using
send_reply method with the extracted bottom Via header from the incoming SIP response? Any
advice or examples on handling this situation would be greatly appreciated.
Thank you for your time and assistance.
Show replies by date