[Asterisk-Dev] Proposed MWI support for Endpoints on Different Softswitch

Jay Ray jonty_11 at yahoo.com
Thu Apr 14 14:27:48 MST 2005


Hi Chris,
 
   In case of a Static ENDPOINT  which has multiple VM boxes defined in sip.conf, it will send a NOTIFY for each mailbox defined, which I think might not be a problem.
 
  However, if a Softswitch is registering with the Asterisk, then this wont work. Asterisk is desingned to aggregate all NEW and OLD msgs for a registering Endpoint/Softswitch and send them in on NOTIFY msg.
 
  The idea to put in an extra RemoteMailbox in sip.conf looks good. Going through the Asterisk Code and how if retireves Data from Files, i was a little confused as to how it actually gets info from the files like sip.conf.
 
    Here is how I would have to implement the remotemailbox thing....
 

       Add it to the sip_peer structure
       make sure the FILE i/o operation reads that new variable (remotemailbox) from sip.conf.....(This I am not sure how to implement - Any pointers would help)
   Use the remotemailbox  in all the places that I am using mailbox currently in my new Functions..
Regarding your point of create MWI 's on the fly..can you explain what teh purpose for such a Feature would be.. I guess I missed your point....
 
Thx,
J

"Chris A. Icide" <chris at netgeeks.net> wrote:
This looks like a great idea.  However I've got some questions.

You indicate you are making some decision based upon whether or not an endpoint is registered or static.  What happens if a static endpoint is really just a SIP UA EP?  What happens if a softswitch you are serving as voicemail media for is registering with you instead of being static?

Would it work better if you added a special argument to the sip.conf?

instead of 

mailbox=12895551001 at suppc5cm1,12895551002 at suppc5cm1,12455551000 at suppc5cm1

how about:

remotemailbox=12895551001 at suppc5cm1,12895551002 at suppc5cm1,12455551000 at suppc5cm1

That way you leave the decision of whether or not the host statement is static or dynamic to remain a functional decision versus a policy argument.  (I could just be misunderstanding your detailed description as well)

On similar another note, I've been thinking about something I think would be valuable.



How difficult would it be to create a dialplan command that could assign, un-assign, etc. MWI pointers on the fly?  How would this fit in with your changes here?

For example:

exten => s,1,MWISet(SIP/1234,1001 at office)  ;set MWI for SIP/1234 to 1001 at office  

exten => s,1,MWIClear(SIP/1234)  ;remove all MWI setting for SIP/1234

exten => s,1,MWISet(SIP/1234,2222 at softswitch,r)  ; same as above except r options indicates this is a remote softswitch.


-Chris


On 12:45 PM 4/14/2005, Jay Ray wrote:

Here is relevant portion of sip.conf. for those peer softswitches....I have tested with 2 Clarent Softswitches one with 3 and other with just one mailbox..worked fine. I will go to bugs.digium.com..and submit a case....Thx
 
I followed the NOTIFY mechanism for sending MWI as per RFC 3842....
 
 
---------------------------------------------------------------sip.conf---------------------------------------
[10.1.1.1:5080]         //This sofswitch uses port 5080 for VoiceMail...we do have to 
                                 explicitly mention the port here so that Asterisk does not loose it while 
                                 sending NOTIFY to Softswitches..I found out that Asterisk does loose 
                                  this port.
type=friend
username=c5cm
context=clarentcm
dtmfmode=rfc2833
host=10.1.1.1
mailbox=12895551001 at suppc5cm1,12895551002 at suppc5cm1,12455551000 at suppc5cm1
allow=ulaw
port=5080
[10.1.1.2:5080]
type=friend
context=JerryC5_84
dtmfmode=rfc2833
host=10.1.1.2
mailbox=15142550001 at jerryc5vm
allow=ulaw
port=5080
--------------------------------------------------------------------------------------------------------------------------------------------


John Todd <jtodd at loligo.com> wrote:


   This looks interesting. Can you provide a bit more detail and some 

   other updates?


   1) Can you supply a diff on the sip.conf file that shows an example 

   of your new method (comment the section out, and use several lines of 

   comments to explain what the example does)


   2) On what softswitches is this known to work? I assume you've 

   tested with SER, as a baseline?


   3) Have you signed a disclaimer with Digium?


   4) Can you submit this as an addition to bugs.digium.com so that it 

   will be included in future Asterisk releases if it meets approval and 

   functionality criteria (as nebulous as both of those are...)?


   JT



   At 11:05 AM -0700 on 4/14/05, Jay Ray wrote:

   >Hi All,

   >

   > I had proposed the changes to be able to support Asterisk 

   >VoiceMail for 3rd Party Softswitches. Here is what I have changed o n 

   >Asterisk in chan_sip.c

   >

   >While in function sip_send_mwi_to_peer() . in case peer->tohost has 

   >a value which means that its not a registered EP - but a static 

   >peer, I call another function called sip_send_mwi_to_softswitch() 

   >.....in which I separate the comma separated mailboxes defined in 

   >sip.conf for that peer. and send NOTIFY in a for loop for each of 

   >the Mailboxes....by calling another new function 

   > transmit_notify_to_softswitch_with_mwi()

   >

   >In transmit_notify_to_softswitch_with_mwi() , I populate the 

   >sip_pvt->username with the mailbox number (minus the mailbox 

   >context, if any)...so that the mailbox number gets added to the "TO" 

   >header in the NOTIFY going out to that Softswitch...for the 

   >Softswitch to pass on the NOTIFY to the appropriate Endpoint....

   >

   >The DIFF is below, comments appreciated.......

   >

   >

   >

   >

   >[root at jerrylinux channels]# diff chan_sip.c.wrking1 chan_sip.c.orig

   >489,490d488

   >< int *lastmsgsent_switch; /* maintaining last message 

   >sent for EPS on a Third Party Softswitch */

   ><

   >1207c1205

   ><

   >---

   >>

   >1209d1206

   ><

   >1212d1208

   ><

   >3930,3932d3925

   ><

   ><

   ><

   >4217,4271d4209

   >< /*--- transmit_notify_to_softswitch_with_mwi: Notify Softswitch user of

   >< messages waiting in voicemail ---*/

   >< /* Notification works for Softswitch peers with mailbox= definitions

   >< * in sip.conf

   >< * We use the SIP Event package message-summary

   >< * MIME type defaults to "application/simple-message-summary";

   >< */

   >< static int transmit_notify_to_softswitch_with_mwi(struct sip_pvt 

   >*p, char *mbox, int newmsgs, int oldmsgs)

   >< {

   >< struct sip_request req;

   >< char tmp[256];

   >< char tmp2[256];

   >< char *tmp_mbox;

   >< char clen[20];

   ><

   >< /* I will put the Mailbox Number - the part before the @

   >< * in p->username, and then call initreqprep as initreqprep

   >< * looks for a p->username and puts it in TO Header

   >< */

   ><

   >< tmp_mbox = (char*) calloc(strlen(mbox), sizeof(char));

   ><

   >< strncpy(tmp_mbox, mbox, strlen(mbox));

   ><

   >< tmp_mbox = strsep(&tmp_mbox, "@");

   ><

   >< strncpy(p->username, tmp_mbox, strlen(tmp_mbox));

   ><

   ><

   ><

   >< initreqprep(&req, p, "NOTIFY", NULL);

   ><

   >< add_header(&req, "Event", "message-summary");

   >< add_header(&req, "Content-Type", default_notifymime);

   ><

   >< snprintf(tmp, sizeof(tmp), "Messages-Waiting: %s\r\n", 

   >ne wmsgs ? "yes" : "no");

   >< snprintf(tmp2, sizeof(tmp2), "Voice-Message: %d/%d\r \n", 

   >newmsgs, oldmsgs);

   >< snprintf(clen, sizeof(clen), "%d", (int)(strlen(tmp) + 

   >strlen(tmp2)));

   >< add_header(&req, "Content-Length", clen);

   >< add_line(&req, tmp);

   >< add_line(&req, tmp2);

   ><

   >< if (!p->initreq.headers) {

   >< /* Use this as the basis */

   >< copy_request(&p->initreq, &req);

   >< parse(&p->initreq);

   >< if (sip_debug_test_pvt(p))

   >< ast_verbose("%d headers, %d lines\n", 

   >p->initreq.headers, p->initreq.lines);

   >< determine_firstline_parts(&p->initreq);

   >< }

   ><

   >< return send_request(p, &req, 1, p->ocseq);

   >< }

   ><

   ><

   >8628,8734d8565

   >< //Ujju - sip_send_mwi_to_softswitch : Sending MWI to another Softswitch.

   >< static int sip_send_mwi_to_softswitch(struct sip_peer *peer)

   >< {

   >< /* Checking for all the m alboxes configured for a softswitch

   >< and sending NOTIFY w/MWI for all */

   >< struct sip_pvt *p;

   >< char name[256] = "";

   >< int newmsgs, oldmsgs;

   ><

   >< if(peer->mailbox==NULL){

   >< ast_log(LOG_WARNING, "No Mailboxes defined in sip.conf and 

   >voicemail.conf for this softswitch");

   >< return 0;

   >< }

   ><

   >< int i;

   >< int mbox_count=0;

   >< char *mbox[500]; /*Pointer to individual malboxes*/

   >< char *tmp=NULL; /*Temp Pointer to individual mailboxes*/

   >< char *mailboxes;/* storing full comma separated mailbox 

   >string here */

   ><

   >< mailboxes=(char *)calloc(strlen(peer->mailbox),sizeof(char));

   ><

   >< strcpy(mailboxes,peer->mailbox);

   ><

   ><

   >< tmp=strchr(mailboxes,',');

   >< //**mbox=(char **)malloc(sizeof(char *)*256);

   >< //This copies first Mailbox in mbox[0]

   >< mbox[mbox_count]=mailboxes;

   >< mbox[mbox_count]=strsep(&mbox[mbox_count], ",");

   ><

   >< //This copies rest of the mailboxes in mbox[1, 2, 3......]

   >< while(tmp!=NULL)

   >< {

   >< mbox_count++;

   >< tmp+=1;

   >< mbox[mbox_count]=(char*) calloc(strlen(tmp), sizeof(char));

   >< strncpy(mbox[mbox_count],tmp, strlen(tmp));

   >< mbox[mbox_count]=strsep(&mbox[mbox_count], ",");

   >< tmp=strchr(tmp,',');

   >< }

   ><

   ><

   >< /* Allocating memory for PTR to last msg for each mailbox 

   >for EPs on Softswitch */

   >< if (peer->lastmsgsent_switch == NULL) {

   >< peer->lastmsgsent_switch = (int *) 

   >calloc(mbox_count,sizeof(int));

   >< for (i=0;i<=mbox_count;i++)

   >< peer->lastmsgsent_switch[i]=-1;

   >< }

   ><

   ><

   >< //Now looping through all the Mailboxes to send individual Notify's

   >< for(i=0;i<=mbox_count;i++) {

   ><

   ><

   >< ast_app_messagecount(mbox[i], &newmsgs, &oldmsgs);

   ><

   >< time(&peer->lastmsgcheck);

   ><

   >< /* Retur n now if it's the same thing we told them 

   >last time */

   >< if (((newmsgs << 8) | (oldmsgs)) == 

   >peer->lastmsgsent_switch[i]) {

   >< if (i==mbox_count)

   >< return 0;

   >< else

   >< continue;

   >< }

   ><

   >< p = sip_alloc(NULL, NULL, 0);

   >< if (!p) {

   >< ast_log(LOG_WARNING, "Unable to build sip 

   >pvt data for MWI\n");

   >< return -1;

   >< }

   >< strncpy(name, peer->name, sizeof(name) - 1);

   >< peer->lastmsgsent_switch[i] = ((newmsgs << 8) | (oldmsgs));

   >< if (create_addr(p, name)) {

   >&lt

   ; /* Maybe they're not registered, etc. */

   >< sip_destroy(p);

   >< return 0;

   >< }

   >< /* Recalculate our side, and recalculate Call ID */

   >< if (ast_sip_ouraddrfor(&p->sa.sin_addr,&p->ourip))

   >< memcpy(&p->ourip, &__ourip, sizeof(p->ourip));

   >< build_via(p, p->via, sizeof(p->via));

   >< build_callid(p->callid, sizeof(p->callid), p->ourip, 

   >p->fromdomain);

   >< /* Here I call another Function to Build Proper to header */

   >< /* Sen d MWI */

   >< ast_set_flag(p, SIP_OUTGOING);

   ><

   >< //Ujju Set the p->peername pointer to char to NULL 

   >if its length is 0

   ><

   >< if (!strlen(p->peername)){

   >< strncpy(p->peername, peer->name, sizeof(p->peername));

   >< }

   ><

   ><

   >< transmit_notify_to_softswitch_with_mwi(p, mbox[i], 

   >newmsgs, oldmsgs);

   >&l

   t; ; sip_scheddestroy(p, 15000);

   >< }

   ><

   ><

   ><

   >< return 0;

   ><

   >< }

   ><

   ><

   ><

   >8743,8750c8574

   >< /* Ujju Here we call function to separate all the mailboxes 

   >if tohost ne NULL and

   >< then call the below func - sip_send_mwi_to_softswitch - 

   >for each of those mailboxes */

   ><

   >< if (strlen(peer->tohost) != 0){

   >< sip_send_mwi_to_softswitch(peer);

   >< return 0;

   >< }

   ><

   >---

   >> /* Check for messages */

   >

   >

   >

   >Do you Yahoo!?

   >Yahoo! Small Business - 

   >Try 

   >our new resources site!

   >

   >_______________________________________________

   >Asterisk-Dev mailing list

   >Asterisk-Dev at lists.digium.com

   >http://lists.digium.com/mailman/listinfo/asterisk-dev

   >To UNSUBSCRIBE or update options visit:

   > http://lists.digium.com/mailman/listinfo/asterisk-dev




Do you Yahoo!?
Yahoo! Mail - 250MB free storage. Do more. Manage less. 
_______________________________________________
Asterisk-Dev mailing list
Asterisk-Dev at lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-dev
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev _______________________________________________
Asterisk-Dev mailing list
Asterisk-Dev at lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-dev
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-dev


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20050414/f3372e09/attachment.htm


More information about the asterisk-dev mailing list