Manipulate Contact Header

Hi,

In Asterisk i am using Transfer Command and i added Diversion Header.
In 302 request I see the Diversion Header successfully,
While in the Contact section I can see before the information there was added “Transfer” prefix the sip details of the contact.

Is there a way to remove the “Transfer”? if so can any one advise how?
Currently displayed: Contact: Transfer sip:003B0123456789
Desired: Contact: sip:003B0123456789

The Code part: (You comment see different tries which i have done by changing it to Dial \ Remove and Adding Headers)

exten => 797406001,1,Verbose(STAR 0123456789 ******0987654321 ************************:${CALLERID(num)} ---- ${EXTEN} —0${EXTEN:3})
same => n,Verbose(addDiversionHeader:${EXTEN})
same => n,SET(REDIRECTING(from-num,i)=${EXTEN})
same => n,SET(REDIRECTING(reason,i)=cfu)
;same => n,SIPRemoveHeader(Contact)
;same => n,SIPAddHeader(Contact: 003B0123456789})
same => n,Transfer(SIP/003B0123456789)
;same => n,Dial(SIP/003B0123456789)
same => n,Hangup()

Asterisk version is 16

Contact is a header that only Asterisk itself can manage. You can’t delete it and add your own.

Also, please mark up logs and configurations as pre-formatted text, when posting the the forum, as your posting is missing some critical angle brackets which I think were in the original.

Transfer is the name of the destination, the Display Name, in the formal grammar:

Contact        =  ("Contact" / "m" ) HCOLON
                  ( STAR / (contact-param *(COMMA contact-param)))
contact-param  =  (name-addr / addr-spec) *(SEMI contact-params)
name-addr      =  [ display-name ] LAQUOT addr-spec RAQUOT
addr-spec      =  SIP-URI / SIPS-URI / absoluteURI
display-name   =  *(token LWS)/ quoted-string

There is no valid reason for that field not to be present, although there may be cases where you might want to change it to, say, “John Smith”, although I’m not sure that is supported.

Ungarbling what I think you meant to post, Contact: <sip:003B0123456789> would be a syntax violation, as it could only be parsed as a one component domain name, but, the final component of a domain name components must begin with an alphabetic character:

hostname         =  *( domainlabel "." ) toplabel [ "." ]
domainlabel      =  alphanum
                    / alphanum *( alphanum / "-" ) alphanum
toplabel         =  ALPHA / ALPHA *( alphanum / "-" ) alphanum

Actually I thought that Transfer added the local domain name if you only provided a user.

Also, you appear to be using chan_sip, but that is no longer supported. For chan_sip, at least, the “Transfer” part is hard coded:

	ast_string_field_build(p, our_contact, "Transfer <sip:%s@%s>", extension, domain);
	transmit_response_reliable(p, "302 Moved Temporarily", &p->initreq);

Also, note that the @ is hard coded, so it couldn’t have produced the contact header you claim it produced. If there is no @ in the Transfer application parameter, it tries to use the domain part of the incoming To header.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.