Add P-Preferred-Identity and Remote-Party-ID header

Some providers require sending an additional SIP header when initiating an outgoing call. In this article we will describe a way to install it.

  1. To solve the problem, additional contexts should be described through the System File Customization menu.

System File Customization menu
  1. We will edit the extensions.conf file.

Extensions.conf file
  1. Add the following text to the end of the file:

[SIP-1611151795-outgoing-custom]
exten => _X!,1,Dial(PJSIP/${number}@SIP-${CUT(CONTEXT,-,2)},600,${DOPTIONS}TKU(dial_answer)b(dial_create_chan_${CUT(CONTEXT,-,2)}_custom,s,1))
    same => n,ExecIf($["${DIALSTATUS}" = "ANSWER"]?Hangup())
    same => n,ExecIf($["${DIALSTATUS}" = "BUSY"]?Busy(2))
    same => n,return
    
[dial_create_chan_1611151795_custom] 
exten => s,1,Gosub(lua_${ISTRANSFER}dial_create_chan,${EXTEN},1)
    same => n,Set(pt1c_is_dst=1) 
    same => n,Set(OUTGOING_CID=32672293042)
    same => n,ExecIf($["${OUTGOING_CID}x" != "x"]?Set(PJSIP_HEADER(add,P-Preferred-Identit)=<sip:${OUTGOING_CID}@127.0.0.1>))
    same => n,ExecIf($["${OUTGOING_CID}x" != "x"]?Set(PJSIP_HEADER(add,Remote-Party-ID)=<sip:${OUTGOING_CID}@127.0.0.1>))
    same => n,Set(__PT1C_SIP_HEADER=${UNDEFINED}) 
    same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1) 
    same => n,return
Code for extrensions.conf

When using the "User Groups" module:

[SIP-1611151795-outgoing-ug-custom]
exten => _X!,1,Dial(PJSIP/${number}@SIP-${CUT(CONTEXT,-,2)},600,${DOPTIONS}TKU(dial_answer)b(dial_create_chan_custom,s,1))
	same => n,ExecIf($["${DIALSTATUS}" = "ANSWER"]?Hangup())
	same => n,ExecIf($["${DIALSTATUS}" = "BUSY"]?Busy(2))
    same => n,return
    
[dial_create_chan_custom] 
exten => s,1,Gosub(lua_${ISTRANSFER}dial_create_chan,${EXTEN},1)
    same => n,Set(pt1c_is_dst=1) 
    same => n,Set(GR_VARS=${DB(UsersGroups/${FROM_PEER})}) 
    same => n,Set(tmpName=${CUT(GR_VARS,\,,2)})
    same => n,Set(tmpName=${CUT(tmpName,\_,3)})
	same => n,ExecIf($["${GR_VARS}x" != "x"]?Exec(Set(${GR_VARS}))) 
	same => n,ExecIf($["${GR_PERM_ENABLE}" == "1" && "${GR_ID_${tmpName}}" != "1"]?return) 
	same => n,ExecIf($["${GR_PERM_ENABLE}" == "1" && "${GR_CID_${tmpName}}x" != "x"]?MSet(GR_OLD_CALLERID=${CALLERID(num)},OUTGOING_CID=${GR_CID_${tmpName}}))
	same => n,ExecIf($["${OUTGOING_CID}x" != "x"]?Set(PJSIP_HEADER(add,P-Preferred-Identit)=<sip:${OUTGOING_CID}@127.0.0.1>))
	same => n,ExecIf($["${OUTGOING_CID}x" != "x"]?Set(PJSIP_HEADER(add,Remote-Party-ID)=<sip:${OUTGOING_CID}@127.0.0.1>))
    same => n,Set(__PT1C_SIP_HEADER=${UNDEFINED}) 
    same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1) 
    same => n,return

Last updated

Was this helpful?