FreePBX | Register | Issues | Wiki | Portal | Support

SIP Header


#1

FreePBX/Asterisk 14

Hello,

We have an Avaya and Asterisk PBX set. Calls start and end (reaching an endpoint) in Avaya. In between the start and end, calls route out to Asterisk for various treatments (callbacks, IVRs, etc.). When the call begins in Avaya, a unique ID is (UCID) is created for the call. This unique ID is sent via SIP header to Asterisk as the call routes. I am able to pull the Avaya UCID into a variable with:

exten => s,n,Set(UUI=${SIP_HEADER(User-To-User)})

My problem is getting this $UUI back into the SIP header when I get ready to route back to Avaya. I am using this combo to send the call back to Avaya:

exten => s,n,SIPAddHeader(User-To-User: ${UUI})
exten => s,n,Goto(from-internal,${ROUTECBAYES},1)

When the call comes back into Avaya the UUI SIP header is not present, so Avaya creates a new UCID, breaking the continuity of the call. I am thinking this is because I am not inserting the add SIP header line in the correct place.

When I use: exten => s,n,Goto(from-internal, I notice there is a function that gets called: func-apply-sipheaders

    Dial("SIP/xxxxxxxxxxxx", "SIP/xxxxxx/yyyyyyy,300,Tb(func-apply-sipheaders^s^1,(1))") in new stack
      == Using SIP RTP TOS bits 184
      == Using SIP RTP CoS mark 5
        -- SIP/xxxxxxxxxxxx Internal Gosub(func-apply-sipheaders,s,1(1)) start
 Executing [s@func-apply-sipheaders:1] ExecIf("SIP/xxxxxxxxxxxx ", "1?Set(CHANNEL(hangup_handler_push)=crm-hangup,s,1)") in new stack
    -- Executing [s@func-apply-sipheaders:2] NoOp("SIP/xxxxxxxxxxxx ", "Applying SIP Headers to channel SIP/xxxxxxxxxxxx ") in new stack
    -- Executing [s@func-apply-sipheaders:3] Set("SIP/xxxxxxxxxxxx ", "TECH=SIP") in new stack
    -- Executing [s@func-apply-sipheaders:4] Set("SIP/xxxxxxxxxxxx ", "SIPHEADERKEYS=") in new stack
    -- Executing [s@func-apply-sipheaders:5] While("SIP/xxxxxxxxxxxx ", "0") in new stack
    -- Jumping to priority 12
    -- Executing [s@func-apply-sipheaders:13] Return("SIP/xxxxxxxxxxxx ", "") in new stack

Question:

  • Where do I need to insert my SIPAddHeader(User-To-User: ${UUI}) command? Into func-apply-sipheaders?

  • If yes, how do I do it? I know you can rewrite things in the override file and include the original, but it would be nice if there was an example to follow.

  • In the case that I am completely down the wrong path here, what do you recommend for adding a User to User SIP header to the call before dialing?

Thanks in advance for any insights!


#2

I found func-apply-sipheaders in extensions_additional.conf

How could I add my exten => s,n,SIPAddHeader(User-To-User: ${UUI}) line? I don’t think it would hurt to have it applied to every from-internal call?

[func-apply-sipheaders]
include => func-apply-sipheaders-custom
exten => s,1,ExecIf($["${CRM_DIRECTION}"="INBOUND"]?Set(CHANNEL(hangup_handler_push)=crm-hangup,s,1))
exten => s,n,Noop(Applying SIP Headers to channel ${CHANNEL})
exten => s,n,Set(TECH=${CUT(CHANNEL,/,1)})
exten => s,n,Set(SIPHEADERKEYS=${HASHKEYS(SIPHEADERS)})
exten => s,n,While($["${SET(sipkey=${SHIFT(SIPHEADERKEYS)})}" != ""])
exten => s,n,Set(sipheader=${HASH(SIPHEADERS,${sipkey})})
exten => s,n,ExecIf($["${sipheader}" = "unset" & "${TECH}" = "SIP"]?SIPRemoveHeader(${sipkey}:))
exten => s,n,ExecIf($["${sipheader}" = "unset" & "${TECH}" = "PJSIP"]?Set(PJSIP_HEADER(remove,${sipkey})=))
exten => s,n,ExecIf($["${sipkey}" = "Alert-Info" & ${REGEX("^<[^>]*>" ${sipheader})} != 1]?Set(sipheader=<http://127.0.0.1>\;info=${sipheader}))
exten => s,n,ExecIf($["${TECH}" = "SIP"]?SIPAddHeader(${sipkey}:${sipheader}))
exten => s,n,ExecIf($["${TECH}" = "PJSIP"]?Set(PJSIP_HEADER(add,${sipkey})=${sipheader}))
exten => s,n,EndWhile
exten => s,n,Return()

;--== end of [func-apply-sipheaders] ==--;

I know I need to “bring” func-apply-sipheaders to extensions_override.conf, but I am not sure how to blend it so I am not completely overriding what FreePBX is doing (incase the context changes as the software is updated).


(Lorne Gaetz) #3

You add a dialplan hook for outbound calls to the remote system and add a call to the sub there:


#4

As a possible quick fix, try replacing this with

exten => s,n,Gosub(func-set-sipheader,s,1(User-To-User,${UUI}))
exten => s,n,Goto(from-internal,${ROUTECBAYES},1)

If no luck, set up the hook as @lgaetz suggested.


(system) closed #5

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