[asterisk-dev] SIP Channel fails to parse refer_to_domain

Jan Gaida jan.gaida at grupoamper.com
Fri Nov 29 05:48:09 CST 2013


The scenario is an attended transfer to a remote domain.

The short description:
When Asterisk receives a REFER message with a refer-to header that contains
"?replaces=" query, in chan_sip's function "get_refer_info" the domain is
extracted with the query-part. That leads to an error (no such host) when
trying to send the INVITE to this domain.

The solution is to remove the query part ('?') in the get_refer_info
function (see attached diff file).


The following is a description of the events like a SIP trace; with A being
transferor, B transferee (Asterisk) and C the transfer-target.

Two calls are established: call1 between B and A, and call2 between A and C.
When starting the transfer, the transferor A sends a REFER to Asterisk (B):
A -> REFER (Refer-to: <sip:C at domain?replaces=call2>) -> B
B -> 202 Accepted -> A
B -> Notify sipfrag 200 ok -> A
A -> 200 ok -> B

Now, there should be an outgoing INIVTE with Replaces header:
B -> INVITE (Replaces: call2) > C
But this INVITE never is send.

In Asterisk's traces you see the following:
  chan_sip.c: Attended transfer: Will use Replace-Call-ID : call2 (No check
of from/to tags)
  chan_sip.c: SIP transfer to extension C at internal by A at domain
  chan_sip.c: This SIP transfer is to a remote SIP extension (remote domain

Here you can see the error ^^^^. The remote domain still contains the query
part (?Replaces) of the uri.

The traces then continue:
chan_sip.c: SIP attended transfer: Still not our call - generating INVITE
with replaces

Then it enters the dialplan where it is redirected with a Dial command:
logger.c:     -- Executing [s at callreferred:4] Dial("SIP/domain-09a40b60",
"SIP/C at domain?Replaces=call2|60|") in new stack

And finally the error:
WARNING[32395] chan_sip.c: No such host: domain?Replaces=call2
DEBUG[32395] chan_sip.c: Cant create SIP call - target device not registered


With the attached patch, Asterisk behaves as expected.  Should I open an
issue on the tracker?


    *Jan **Gaida*
Ingeniero Desarrollo Software     C/ Marconi 3 (PTM)
28760 Tres Cantos
jan.gaida at grupoamper.com | www.grupoamper.com


This message and any attachments are intended only for the use of the 
individual to whom they are addressed and it may contain information that 
is privileged or confidential. If you have received this communication by 
mistake, please notify us immediately by e-mail or telephone.The storage, 
recording, use or disclosure of this e-mail and its attachments by anyone 
other than the intended recipient is strictly prohibited. This message has 
been verified using antivirus software; however, the sender is not 
responsible for any damage to hardware or software resulting from the 
presence of any virus.

Este mensaje y cualquier anexo son exclusivamente para la persona a quien 
van dirigidos y pueden contener información privilegiada o confidencial. Si 
usted ha recibido esta comunicación por error, le agradecemos notificarlo 
de inmediato por esta misma vía o por teléfono. Está prohibida su 
retención, grabación, utilización o divulgación con cualquier propósito. 
Este mensaje ha sido verificado con software antivirus; sin embargo, el 
remitente no se hace responsable en caso de que en éste o en los archivos 
adjuntos haya presencia de algún virus que pueda generar daños en los 
equipos o programas del destinatario.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20131129/e299dcc7/attachment.html>
-------------- next part --------------
--- chan_sip.c  2013-10-18 18:38:45.000000000 +0200
+++ ../../asterisk11/channels/chan_sip.c        2013-11-29 11:37:09.000000000 +0100
@@ -17788,6 +17793,10 @@

+               /* Remove ?query */
+               if ((ptr = strchr(domain, '?')))
+                       *ptr = '\0';

More information about the asterisk-dev mailing list