res_pjsip_notify: add dialplan application

Add dialplan application PJSIPNOTIFY to send either pre-configured
NOTIFY messages from pjsip_notify.conf or with headers defined in
dialplan.

Also adds the ability to send pre-configured NOTIFY commands to a
channel via the CLI.

Resolves: #799

UserNote: A new dialplan application PJSIPNotify is now available
which can send SIP NOTIFY requests from the dialplan.

The pjsip send notify CLI command has also been enhanced to allow
sending NOTIFY messages to a specific channel. Syntax:

pjsip send notify <option> channel <channel>

(cherry picked from commit e94c5f0d3b)
This commit is contained in:
Mike Bradeen
2024-07-09 16:11:36 -06:00
committed by Asterisk Development Team
parent 3f670e6358
commit 40d7ce1084
5 changed files with 281 additions and 24 deletions

View File

@@ -861,3 +861,53 @@ exten => _X.,40000(ani),NoOp(ANI: ${EXTEN})
; "core show functions" will list all dialplan functions
; "core show function <COMMAND>" will show you more information about
; one function. Remember that function names are UPPER CASE.
; Examples using PJSIPNotify application.
;[generate-notify]
;
; Send a NOTIFY with the following headers inside the SIP dialog for the current channel:
;
; Event: Test
; X-Data: Fun
;
;exten => 6880,1,noOp()
; same => n,Answer()
; same => n,PJSIPNotify(,&Event=Test&X-Data=Fun)
; same => n,Wait(1)
; same => n,Hangup()
;
; Send a NOTIFY with the following headers to bob's custom uri. This requries a
; default outbound endpoint to be configured in pjsip.conf.
;
; Event: Test
; X-Data: Over
;
;exten => 6881,1,noOp()
; same => n,Answer()
; same => n,PJSIPNotify(<sip:bob@127.0.0.1:5260>,&Event=Test&X-Data=Over)
; same => n,Wait(1)
; same => n,Hangup()
;
; Send a NOTIFY with the the custom headers defined in pjsip_notify.conf under
; 'custom-notify-1' inside the SIP dialog for the current channel.
;
;exten => 6882,1,noOp()
; same => n,Answer()
; same => n,PJSIPNotify(,custom-notify-1)
; same => n,Wait(1)
; same => n,Hangup()
; Send a NOTIFY with the following headers and body to bob's custom uri. This
; requries a default outbound endpoint to be configured in pjsip.conf.
;
; Event: Custom
;
; Content-Type: application/voicemail
; Content-Length: 14
;
; check-messages
;
;exten => 6882,1,noOp()
; same => n,Answer()
; same => n,PJSIPNotify(,&Event=Custom&Content-type=application/voicemail&Content=check-messages&Content=)
; same => n,Wait(1)
; same => n,Hangup()

View File

@@ -432,6 +432,16 @@
;type=aor
;max_contacts=2
;===============DEFAULT ENDPOINT FOR OUTBOUND REQUESTS TO URI===================
;
; This is an example default outbound endpoint. The global setting:
; default_outbound_endpoint needs to be set to such an endpoint in order to be
; able to send an outbound request to a URI without a specified endpoint.
;
;[default_outbound_endpoint]
;type=endpoint
;context=none-invalid
;============EXAMPLE ACL CONFIGURATION==========================================
;

View File

@@ -55,3 +55,17 @@ Event=>check-sync\;reboot=true
[cisco-check-cfg]
Event=>check-sync
; custom examples to use for PJSIPNotify application
; tell an endpoint to check messages
[custom-notify-1]
Event=>custom
Content-type=>application/voicemail
Content=>check-messages
Content=>
; tell an endpoint to force a remote hangup via custom header
[custom-notify-2]
Event=>custom
X-Data=>force-hangup