[Asterisk-Dev] [RFC] Remote MWI using IAX2

Gil Kloepfer astr-dev at kloepfer.org
Fri Apr 29 21:59:58 MST 2005


I e-mailed with Kenny Shumard regarding the following idea and
made mention of it in a previous message to asterisk-dev:

The patch (below) is a proof-of-concept to allow phones on
one Asterisk server to get voicemail notification (message waiting
indication or MWI) from another Asterisk server (where a centralized
voicemail server would be).  While this patch works, it has some
significant problems noted below, which are mainly due to my own
ignorance of how everything works internally.

My proposed enhancement would work as follows:

1. The "mailbox=" configuration option in the .conf files is
extended to allow the following syntax (in addition to the
normal extension at context):

       IAX2/{iax2-conn-spec}/extension at context

As with the original usage, the @context is optional, and the
{iax2-conn-spec} is either a user:pass at host or a reference to
a peer in iax.conf.

So, for example, in sip.conf, you could have:

      mailbox=IAX2/voicemail-server/199

would track the mailbox status for box #199  on [voicemail-server].

2. the IAX command frame subtype IAX_COMMAND_MWI (that is defined
but currently has no formal definition) would be used as follows:

         Voicemail server:  serverA
         "other" server:    serverB  (where a phone is)

     serverB sends to serverA an IAX command frame of type
     IAX_COMMAND_MWI with an IE of type IAX_IE_CALLED_NUMBER
     containing the extension at context that serverB wishes to query.

     serverA receives the frame and uses the IAX_IE_CALLED_NUMBER
     data and calls its local ast_app_messagecount to get the count
     of new and old messages for the mailbox being queried.

     serverA responds to serverB with an IAX command frame of
     type IAX_COMMAND_MWI with an IE of type IAX_IE_MSGCOUNT
     containing the message count.

3. The voicemail ast_app_messagecount and ast_app_has_voicemail is
modified to recognize the IAX2/{iax2-conn-spec}/extension at context
syntax and will dispatch a remote query via IAX if specified.


Limitations/problems with my proof-of-concept patch:

1.  This patch is against the 29-April-2005 CVS v1-0 (not the
CVS development) build.  There are changes in the way that the
voicemail message count/status routines are called in the development
version of Asterisk, but my method below could be adapted to work
with those changes.

2.  I am not handling the call creation properly and so it only
appears to connect to the remote host via a "default" IAX connection.
I am using a function used by the IAX dialplan cache that isn't
exactly doing what I probably want it to do (I didn't want to
reinvent the wheel for a proof-of-concept).

3.  There is no security so anyone who can attach via IAX can query
the status of anyone's mailbox.  A configuration option in iax.conf
should be added so that only specified trusted servers can do the
remote mailbox queries.

4.  I have no idea whether or not there was some other intended use
for IAX_COMMAND_MWI that hasn't been made public.

5.  There may be scalability issues with many phones doing remote MWI
queries as, in the case of Zap/ channels, the MWI checking is done
once a second.

6.  The thread that services MWI for Zap/ channels is also responsible
for starting the simple switch, so if for some reason there is a delay
in the IAX response (such as server down or network problems) it will
delay dialtone on all the Zap/ channels on the querying server.

This is probably indicative of a larger problem of doing on-demand
MWI checks directly to the voicemail files rather than having a
separate thread that could maintain an in-memory cache of MWI status.

7.  This code makes no effort to support any other remote message
querying other than via IAX2...and it may not even be appropriate
for any other protocols to be supported.  However, it may be nice
to have a further modularized MWI status routine tree, rather
than a single level as in the development CVS version of Asterisk.


Patch:
AGAIN, this is against the 29-April-2005 CVS v1-0 Asterisk.  Also,
pardon some of the poorly handled prototypes (there will be an error
when this is compiled).

The patch is available at:

    http://www.kloepfer.org/gc2/rmwipatch2a.txt

to help keep this e-mail a little shorter...

Please feel free to contact me directly at astrepl at kloepfer.org or
discuss this in the list.  I would be very open to suggestions on how
to make this more efficient or more correct.  It's my first real
attempt at low-level Asterisk coding, and I'm sure I made some mistakes.

Thanks in advance for constructive comments and suggestions.

---
Gil Kloepfer
astrepl at kloepfer.org



More information about the asterisk-dev mailing list