Hello,
Hello,
I have remote users registering/ routing calls through my server. When calls do pass through the server, the server updates the from name, to uri and from uri via updating the pseudovariables $fn, $tu, and $fu respectively. While this is has been working, I do occasionally see calls failing to process as the remote gateway fails the call with a "400 Bad From header". Inspecting the A-leg INVITE and the B-leg INVITE after updating the pseudovariables, I see the following:
A-leg INVITE:INVITE sip:15551112222@example.com SIP/2.0Via: SIP/2.0/UDP 79..xx.xx.xx:61379;rport;branch=z9hG4bKPj2b8935f4460447538d0176dcfb5c74a1Max-Forwards: 70From: sip:12223334444@example.com;tag=dff3c585a6154f23898e1121918f1752Call-ID: d793331e066f47bdafc0ad957cb506ccCSeq: 30770 INVITEAllow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONSSupported: replaces, 100rel, timer, norefersubSession-Expires: 1800Min-SE: 90Proxy-Authorization: Digest username="12223334444", realm="example.com", nonce="ZhUw02YVL6cdi51KMymTxGpzCZCZhd8G", uri="sip:15551112222@example.com", response="3a25b4ea0b1154e31caee1184a92f12b"Content-Type: application/sdpContent-Length: 627
v=0o=- 3921660487 3921660487 IN IP4 79..xx.xx.xxs=pjmediab=AS:84t=0 0a=X-nat:0m=audio 4006 RTP/AVP 96 97 98 99 3 0 8 9 120 121 122c=IN IP4 79..xx.xx.xxb=TIAS:64000a=rtcp:4007 IN IP4 79..xx.xx.xxa=sendrecva=rtpmap:96 speex/16000a=rtpmap:97 speex/8000a=rtpmap:98 speex/32000a=rtpmap:99 iLBC/8000a=fmtp:99 mode=30a=rtpmap:3 GSM/8000a=rtpmap:0 PCMU/8000a=rtpmap:8 PCMA/8000a=rtpmap:9 G722/8000a=rtpmap:120 telephone-event/16000a=fmtp:120 0-16a=rtpmap:121 telephone-event/8000a=fmtp:121 0-16a=rtpmap:122 telephone-event/32000a=fmtp:122 0-16a=ssrc:63772004 cname:3ff849bd611036a7
----------------------------------B-leg INVITE:INVITE sip:15551112222@togateway.com SIP/2.0Record-Route: <sip:10.64.54.207;lr;ftag=dff3c585a6154f23898e1121918f1752;did=e21.65c1>Via: SIP/2.0/UDP 10.64.54.207:5060;branch=z9hG4bK919d.5ca83e030c0879093169546cd80591a6.0Via: SIP/2.0/UDP 79..xx.xx.xx:61379;received=79..xx.xx.xx;rport=61379;branch=z9hG4bKPj2b8935f4460447538d0176dcfb5c74a1Max-Forwards: 15From: sip:12125557777@example.com"Updated Name" ;tag=dff3c585a6154f23898e1121918f1752Call-ID: d793331e066f47bdafc0ad957cb506ccCSeq: 30770 INVITEAllow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONSSupported: replaces, 100rel, timer, norefersubSession-Expires: 1800Min-SE: 90Content-Type: application/sdpContent-Length: 609
v=0o=- 3921660487 3921660487 IN IP4 10.64.54.207s=pjmediab=AS:84t=0 0a=X-nat:0m=audio 18400 RTP/AVP 96 97 98 99 3 0 8 9 120 121 122c=IN IP4 10.64.54.207b=TIAS:64000a=ssrc:63772004 cname:3ff849bd611036a7a=rtpmap:96 speex/16000a=rtpmap:97 speex/8000a=rtpmap:98 speex/32000a=rtpmap:99 iLBC/8000a=fmtp:99 mode=30a=rtpmap:3 GSM/8000a=rtpmap:0 PCMU/8000a=rtpmap:8 PCMA/8000a=rtpmap:9 G722/8000a=rtpmap:120 telephone-event/16000a=fmtp:120 0-16a=rtpmap:121 telephone-event/8000a=fmtp:121 0-16a=rtpmap:122 telephone-event/32000a=fmtp:122 0-16a=sendrecva=rtcp:18401
Note that I've updated the following on the B-leg:
$fn = "Updated Name" // originally nothing$fu = sip:12125557777@example.com // originally sip:12223334444@example.com$tu = sip:15551112222@togateway.com // originally sip:15551112222@example.com
While the from uri, and to uri do get updated, the from name is injected in the wrong place of the from header. This only seems to happen when the A-leg is missing the "<" and ">" characters enclosing the from headers.
Should I not be updating the pseudo variables in this manner to update the from name, to uri and from uri; is there another way to update these attributes of the header without malforming it?
looks like a bug, you can open an issue on the tracker.
On the other hand, updating directly with variables the To/From attributes is somehow unsafe overall, the option to do it so was made more for testing or particular use cases. It is recommended to use the uac module and its functions uac_replace_from()/_to() for this purpose.
Cheers,
Daniel
-- Daniel-Constantin Mierla (@ asipto.com) twitter.com/miconda -- linkedin.com/in/miconda Kamailio Consultancy, Training and Development Services -- asipto.com Kamailio World Conference, April 18-19, 2024, Berlin -- kamailioworld.com