Kamailio sends INVITE by tm.t_uac_wait RPC command:
INVITE sip:test-0x55e7f1f78e70@192.168.187.215:5022 SIP/2.0
Via: SIP/2.0/UDP 192.168.187.215;branch=z9hG4bK6cf1.f1d087d6000000000000000000000000.0
To: <sip:test@test.tutpro.com>
From:
<sip:click2dial@test.tutpro.com>;tag=2dd3d4389fe3d66c5cb97dc370ab7d7b-9c5a2a58
CSeq: 1 INVITE
Call-ID: 6649e78355ac2(a)test.tutpro.com
Content-Length: 131
User-Agent: OpenSIPg SIP Proxy (5.9.0-0b01 (x86_64/linux))
Max-Forwards: 10
Contact: <sip:click2dial@192.168.187.215:5060>
Content-Type: application/sdp
.. sdp omitted
UAS accepts the INVITE:
SIP/2.0 200 Answering
Via: SIP/2.0/UDP 192.168.187.215;branch=z9hG4bK6cf1.f1d087d6000000000000000000000000.0
To: <sip:test@test.tutpro.com>;tag=a3302e2a0898de3e
From:
<sip:click2dial@test.tutpro.com>;tag=2dd3d4389fe3d66c5cb97dc370ab7d7b-9c5a2a58
CSeq: 1 INVITE
Call-ID: 6649e78355ac2(a)test.tutpro.com
Server: baresip v3.12.0 (x86_64/Linux)
Contact: <sip:test-0x55e7f1f78e70@192.168.187.215:5022>
Allow: INVITE,ACK,BYE,CANCEL,OPTIONS,NOTIFY,SUBSCRIBE,INFO,MESSAGE,UPDATE,REFER
Supported: gruu,replaces,norefersub
Content-Type: application/sdp
Content-Length: 239
.. sdp omitted
After receiving the response, Kamailio automatically sends ACK:
ACK sip:test-0x55e7f1f78e70@192.168.187.215:5022 SIP/2.0
Via: SIP/2.0/UDP 192.168.187.215;branch=z9hG4bK6cf1.f1d087d6000000000000000000000000.0
From:
<sip:click2dial@test.tutpro.com>;tag=2dd3d4389fe3d66c5cb97dc370ab7d7b-9c5a2a58
Call-ID: 6649e78355ac2(a)test.tutpro.com
To: <sip:test@test.tutpro.com>;tag=a3302e2a0898de3e
CSeq: 1 ACK
User-Agent: OpenSIPg SIP Proxy (5.9.0-0b01 (x86_64/linux))
Content-Length: 0
The problem is that Max-Forwards header is missing from the ACK.
Should I have something in config file to add it or is this a bug?
-- Juha
Show replies by date
t_msgbuilder.c build_uac_req() has:
if(headers == NULL || headers->len < 15
|| _strnstr(headers->s, "Max-Forwards:", headers->len) == NULL) {
maxfwd_len = MAXFWD_HEADER_LEN;
} else {
maxfwd_len = 0;
}
It should add Max-Forwards if it missing, but for some reason it does not
happen with ACK.
-- Juha
I added some debug to t_msgbuilder.c and found out that
function build_uac_req() where missing Max-Forwards is added, is not
executed when request is ACK. It is executed when request is INVITE or
BYE.
So where should Max-Forwards check for ACK be done?
-- Juha
OK, this is the fix:
diff --git a/src/modules/tm/t_msgbuilder.c b/src/modules/tm/t_msgbuilder.c
index 362ff6c5eb..187be7871d 100644
--- a/src/modules/tm/t_msgbuilder.c
+++ b/src/modules/tm/t_msgbuilder.c
@@ -1246,7 +1246,8 @@ char *build_dlg_ack(struct sip_msg *rpl, struct cell *Trans,
/* headers */
*len += Trans->from_hdr.len + Trans->callid_hdr.len + to->len
- + Trans->cseq_hdr_n.len + 1 + ACK_LEN + CRLF_LEN;
+ + Trans->cseq_hdr_n.len + 1 + ACK_LEN +
+ + MAXFWD_HEADER_LEN + CRLF_LEN;
/* copy'n'paste Route headers */
@@ -1291,6 +1292,8 @@ char *build_dlg_ack(struct sip_msg *rpl, struct cell *Trans,
append_str(p, Trans->callid_hdr.s, Trans->callid_hdr.len);
append_str(p, to->s, to->len);
+ append_str(p, MAXFWD_HEADER, MAXFWD_HEADER_LEN);
+
append_str(p, Trans->cseq_hdr_n.s, Trans->cseq_hdr_n.len);
append_str(p, " ", 1);
append_str(p, ACK, ACK_LEN);
Can I push it to master and 5.8?
-- Juha