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

Jay Ray jonty_11 at yahoo.com
Thu Apr 14 12:45:07 MST 2005


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 on 
>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", 
>newmsgs ? "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)) {
>< /* 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);
>< ; 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20050414/a80bd78a/attachment.htm


More information about the asterisk-dev mailing list