Summary:ASTERISK-12289: [patch] Change the "sip notify" CLI to allow for adding message body to the SIP NOTIFY message (Patch submission)
Reporter:Ashutosh Apte (asteriskrocks)Labels:
Date Opened:2008-06-30 17:27:01Date Closed:2011-06-07 14:03:15
Versions:Frequency of
Environment:Attachments:( 0) chan_sip_cli_notify.patch
Description:The existing CLI for sending NOTIFY requests to SIP peers does not allow for adding message body. It allows for adding various SIP headers only. The "sip notify" CLI can be used for sending MWI messages using unsolicited SIP NOTIFY requests. This feature will allow legacy third party telephony switches and / or voicemail systems to dial feature codes and have the Asterisk set or clear MWI lamps on its extensions.

This change introduces a special tag in the "sip_notify.conf". By making use of "Notify-Body" tag, Asterisk can be programmed to add one or more lines in the outgoing NOTIFY message body.


The following example demostrates the usage of the new tag. It shows how Asterisk can handle incoming SIP calls with feature codes and react to them by setting or clearing MWI lamps on SIP phones registered to it.

This snippet from the extensions.conf shows that on receving a call with a dial-string that starts with *4998*, Asterisk will answer the call, invoke the CLI utility "sip notify" with "mwi-set" and at the most 6 digits after *4998* from the dial-string.

;   MWI set and clear - direct SIP notify method
;   Depends on modifications to chan_sip.c to add the ability to
;   create a message body in sip_notity.conf

exten => _*4998*.,1,Answer
exten => _*4998*.,2,System(/usr/sbin/asterisk -rx "sip notify mwi-set ${EXTEN:6}")
exten => _*4998*.,3,Hangup

exten => _*4999*.,1,Answer
exten => _*4999*.,2,System(/usr/sbin/asterisk -rx "sip notify mwi-clear ${EXTEN:6}")
exten => _*4998*.,3,Hangup

The following snippet from sip_notify.conf shows the use of this special tag. Sections [mwi-set] and [mwi-clear] generate unsolicted NOTIFY requests that contain "Event" and "Content-Type" as SIP headers and all lines starting with "Notify-Body" as the SIP message body. The lines are added to the message body in the order they appear in the section. The Asterisk code will automatically calculate the final body length and add "Content-Length" header in the outgoing NOTIFY request.

Notify-Body=>Messages-Waiting: yes
Notify-Body=>Voice-Message: 1/0 (0/0)

Notify-Body=>Messages-Waiting: no
Notify-Body=>Voice-Message: 0/0 (0/0)

This feature has been tested with CounterPath eveBeam soft phone (version: build 30937) and Polycom SoundPoint IP320 SIP. Note that this feature does not require active subscription from SIP phones to work. It should work with all SIP phones that support unsolicited NOTIFY requests for "message-summary" event package.

It has also been verified that this feature does not interfere with an existing
active subscription from the phone.
Comments:By: Olle Johansson (oej) 2008-07-01 01:30:55

A suggestion: can we move this CLI to a AMI command? This is hardly used by operators, like the others are uset for resetting phones. We don't want to implement CLI commands for third party application integration, we prefer manager commands.

By: Ashutosh Apte (asteriskrocks) 2008-07-08 15:30:00

I'm not familiar with AMI but a brief look at the AMI interface suggests that it is not SIP driven. This patch allows an administrator to program the Asterisk to react to the incoming SIP INVITE message that correspond to a "star code" or a "Feature Access code". Also, this patch is an attempt to fit Asterisk in a huge deployment where Asterisk is NOT the main telephony or voice mail service provider. As an example, please consider the following environment:

A huge corporation has a non Asterisk PBX with thousands of phones at its corporate headquarters. This PBX also hosts a centralized voice mail. This corporation has numerous small locations spread across a vast geographical area. Each of the remote locations is locally serviced by an Asterisk PBX which, in turn, is connected to the central PBX through SIP trunks. This allows users at a remote local location stay connected and reachable to users at the central (and other remote) location. Since the voice mail service is also located at the central location, it should have an ability to set / clear MWI lamps on phones located at remote locations that are reachable only through the Asterisk PBX. The central voice mail service can perform MWI over SIP using two different methods, a) sending unsolicited SIP NOTIFY requests or b) sending SIP INVITE requests containing a predefined "star code". This patch adds support to the second option where a command line option can be used to generate a SIP NOTIFY message with an appropriate message body to support "message summary" event package.

I hope this scenario helps justify the need for this patch to allow the Asterisk PBX fit into complex telephony networks.

P.S. I'm in the process of submitting another patch to add support for unsolicited NOTIFY requests for "message-summary" event package.

By: snuffy (snuffy) 2008-07-08 16:24:27

just putting in my own 2cents..

Wouldn't it be better to have a dialplan function to send 'sip notifies' since you seem to be doing this all from the DP rather than an external force.

By: Olle Johansson (oej) 2008-07-09 04:10:47

As SNUFFY says, this calls for something different than a CLI command. THanks for informing us about the application.

By: Tilghman Lesher (tilghman) 2008-08-06 16:21:07

1) This is a plain patch, instead of a unified patch, as is required by the bugtracker guidelines.  As it stands, I cannot adapt this patch at all, since it lacks the required information.

2) As Snuffy suggested, this needs to be something other than a CLI command.  In this case, it should probably be a dialplan application, since it "does" something to the channel, rather than simply inquiring information.

At the very least, I need this patch updated, so I can adapt it into the necessary form, or, if you prefer, you can update this patch.  In either case, I need a reply back within the next 7 days as to your intent, or this issue will be closed.

By: Tilghman Lesher (tilghman) 2008-09-11 17:34:39

No response from reporter in over 2 months.