So looking at the generated dial plan…
include => func-apply-sipheaders-custom
exten => s,1,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}" = "PJSIP"]?Set(PJSIP_HEADER(remove,${sipkey})=))
exten => s,n,ExecIf($["${sipheader}" != "unset" & "${sipkey}" = "Alert-Info" & ${REGEX("^<[^>]*>" ${sipheader})} != 1 & ${REGEX("\;info=" ${sipheader})} != 1]?Set(sipheader=<http://127.0.0.1>\;info=${sipheader}))
exten => s,n,ExecIf($["${sipheader}" != "unset" & "${sipkey}" = "Alert-Info" & ${REGEX("^<[^>]*>" ${sipheader})} != 1]?Set(sipheader=<http://127.0.0.1>${sipheader}))
exten => s,n,ExecIf($["${TECH}" = "PJSIP" & "${sipheader}" != "unset"]?Set(PJSIP_HEADER(add,${sipkey})=${sipheader}))
exten => s,n,EndWhile
exten => s,n,Return()
;--== end of [func-apply-sipheaders] ==--;
This bit
exten => s,n,Set(sipheader=${HASH(SIPHEADERS,${sipkey})})
is returning "unset"
So I copied this routine to /etc/asterisk/extensions_override_freepbx.conf
and dropped a couple NoOp’s in there for detail, it seems that “Alert-Info” always exists.
exten => s,n,NoOp(Alert-Info is currently set to: ${PJSIP_HEADER(read,Alert-Info)})
No matter where I had those (at one point after every line), it always returned empty.
[jbusch@pbx ~]$ tail -f /var/log/asterisk/full | grep "NoOp\|Noop\|ERROR"
[2021-02-18 14:09:04] VERBOSE[18600][C-000004db] pbx.c: Executing [s@macro-hangupcall:5] NoOp("PJSIP/103-000009e1", "PJSIP/Skyetel-000009e2 montior file= ") in new stack
[2021-02-18 14:10:19] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@macro-user-callerid:20] NoOp("PJSIP/103-000009e3", "[TRACE](3) Current Concurrency Count for 103: 0, User Limit: 3") in new stack
[2021-02-18 14:10:19] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@macro-user-callerid:24] NoOp("PJSIP/103-000009e3", "Macro Depth is 1") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@macro-user-callerid:51] NoOp("PJSIP/103-000009e3", "[TRACE](3) Using CallerID "Jared Busch" <103>") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@sub-record-check:10] NoOp("PJSIP/103-000009e3", "Recordings initialized") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [out@sub-record-check:1] NoOp("PJSIP/103-000009e3", "Outbound Recording Check from 103 to 314NXXXXXX") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [recordcheck@sub-record-check:1] NoOp("PJSIP/103-000009e3", "Starting recording check against dontcare") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [314NXXXXXX@from-internal:3] NoOp("PJSIP/103-000009e3", "[TRACE](1) Calling Out Route: Normal_Out") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@macro-outbound-callerid:1] NoOp("PJSIP/103-000009e3", "103") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@macro-outbound-callerid:2] NoOp("PJSIP/103-000009e3", "") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@macro-outbound-callerid:3] NoOp("PJSIP/103-000009e3", "off") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@macro-dialout-trunk-predial-hook:1] NoOp("PJSIP/103-000009e3", "Entering user defined context [macro-dialout-trunk-predial-hook] in extensions_custom.conf") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@macro-dialout-trunk-predial-hook:10] NoOp("PJSIP/103-000009e3", "Trunk Name: @Skyetel") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@macro-dialout-trunk-predial-hook:12] NoOp("PJSIP/103-000009e3", "We are heading for the Skyetel Trunk, determine the X-Tenant based on outbound route") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@macro-dialout-trunk-predial-hook:17] NoOp("PJSIP/103-000009e3", "Based on the outbound route name of Normal_Out, the X-Tenant is being set to bundy.") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-set-sipheader:1] NoOp("PJSIP/103-000009e3", "Sip Add Header function called. Adding X-Tenant = bundy") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:1] NoOp("PJSIP/Skyetel-000009e4", "Applying SIP Headers to channel PJSIP/Skyetel-000009e4") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:2] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:4] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:6] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:7] NoOp("PJSIP/Skyetel-000009e4", "Before Current Alert-Info = ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:8] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:10] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:12] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:13] NoOp("PJSIP/Skyetel-000009e4", "Current sipkey = Alert-Info and sipheader = unset") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:14] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:16] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] ERROR[23828] res_pjsip_header_funcs.c: No headers had been previously added to this session.
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:18] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:20] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:22] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:24] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:26] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:10] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:12] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:13] NoOp("PJSIP/Skyetel-000009e4", "Current sipkey = X-Tenant and sipheader = bundy") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:14] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:16] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:18] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:20] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:22] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:24] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:26] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:20] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@func-apply-sipheaders:28] NoOp("PJSIP/Skyetel-000009e4", "Alert-Info is currently set to: ") in new stack
[2021-02-18 14:10:24] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@sub-send-obroute-email:2] NoOp("PJSIP/Skyetel-000009e4", "email notifications disabled..exiting.") in new stack
[2021-02-18 14:10:28] VERBOSE[18894][C-000004dc] pbx.c: Executing [s@macro-hangupcall:5] NoOp("PJSIP/103-000009e3", "PJSIP/Skyetel-000009e4 montior file= ") in new stack
I could 100% break my outbound calling by setting Alert-Info manually to “Testing” after the while loop.
exten => s,n,Set(PJSIP_HEADER(add,Alert-Info)=Testing)
Manually setting it to a similar form as the generated context kept calls flowing.
exten => s,n,Set(PJSIP_HEADER(add,Alert-Info)=<http://127.0.0.1>\;info=Testing)
So should the dial plan logic be smarter, or should Asterisk be updated to more gracefully handle a remove when nothing has been previously set?