在 Dialplan 解析 SIP Header 資訊裡的 Diversion 欄位內容
Dialplan:
[my-sip-header-filter] exten => s,1,NoOp( Incoming calls from internet ) exten => s,n,NoOp(SIP_HEADER From field: ${SIP_HEADER(From,1)}) exten => s,n,NoOp(SIP_HEADER To field: ${SIP_HEADER(To,1)}) ; for debuf only exten => s,n,GotoIf($[${LEN(${SIP_HEADER(Diversion,1)})} > 0]?next:next) ;exten => s,n,GotoIf($[${LEN(${SIP_HEADER(Diversion,1)})} > 0]?next) exten => s,n,NoOp(SIP_HEADER Diversion field: <Data Not Found>) exten => s,n,Hangup exten => s,n(next),NoOp(SIP_HEADER Diversion field: ${SIP_HEADER(Diversion,1)}) ; for debug only exten => s,n,Set(STR=<sip:358505735791@voxbone.com>\;counter=1\;reason=unknown) ;exten => s,n,Set(STR=${SIP_HEADER(Diversion,1)}) exten => s,n,NoOp(STR: ${STR}) exten => s,n,Set(REGEX=^.+?:\+(.+?)@.*$) exten => s,n,NoOp(Regular Expression: ${REGEX}) exten => s,n,Set(DIVERTER=$["${STR}" : "${REGEX}"]) exten => s,n,NoOp(Diverter: ${DIVERTER}) exten => s,n,Hangup
Note:
這個 dialplan 只適用在 Asterisk 1.6.2.13;若執行在 1.8.8 版本,會有以下問題:
- 這行 Set(STR=<sip:358505.........),不接受分號;字元。
- 這行 Set(DIVERTER=$["${STR}" : "${REGEX}"]),正規表示式無法正常被套用。
Images 0 | ||
---|---|---|
No images to display in the gallery. |