[Asterisk-Users] Call Waiting on SIP phones

Walker Haddock whaddock at datacrest.com
Tue Oct 21 12:50:22 MST 2003


On Tue, Oct 21, 2003 at 09:32:44AM +1000, Paul Liew wrote:
> Sorry, to repost - but I left a "/*" comment - here it is again
> 
> Paul
> 
> --- chan_sip.c.save     2003-10-20 21:51:52.000000000 +1000
> +++ chan_sip.c  2003-10-21 09:26:41.000000000 +1000
> @@ -959,7 +959,9 @@
>                 return 0;
>         }
>         switch(event) {
> +               /* Incoming and outging affects the inUse counter */
>                 case DEC_IN_USE:
> +               case DEC_OUT_USE:
>                         if ( u->inUse > 0 ) {
>                                 u->inUse--;
>                         } else {
> @@ -967,6 +969,7 @@
>                         }
>                         break;
>                 case INC_IN_USE:
> +               case INC_OUT_USE:
>                         if (u->incominglimit > 0 ) {
>                                 if (u->inUse >= u->incominglimit) {
>                                         ast_log(LOG_ERROR, "Call from user '%s'
> rejected due to usage limit of %d\n", u->name, u->incominglimit);
> @@ -977,6 +980,8 @@
>                         u->inUse++;
>                         ast_log(LOG_DEBUG, "Call from user '%s' is %d out of %d\
> n", u->name, u->inUse, u->incominglimit);
>                         break;
> +               /* Commented out - don't want to limit outgoing */
> +               /*
>                 case DEC_OUT_USE:
>                         if ( u->outUse > 0 ) {
>                                 u->outUse--;
> @@ -994,6 +999,7 @@
>                         }
>                         u->outUse++;
>                         break;
> +                       */
>                 default:
>                         ast_log(LOG_ERROR, "find_user(%s,%d) called with no even
> t!\n",u->name,event);
>         }
> @@ -1086,6 +1092,12 @@
>                                    INVITE, but do set an autodestruct just in ca
> se. */
>                                 needdestroy = 0;
>                                 sip_scheddestroy(p, 15000);
> +                               /* channel still up - reverse dec of inuse count
> er */
> +                               if ( p->outgoing ) {
> +                                       find_user(p, INC_OUT_USE);
> +                               } else {
> +                                       find_user(p, INC_IN_USE);
> +                               }
>                         } else {
>                                 char *res;
>                                 if (ast->hangupcause && ((res = hangup_cause2sip
> (ast->hangupcause)))) {
Paul, I'm getting a patch error when I diff to the chan_sip.c that I just got from CVS this morning.  It looks like this morning's version hasn't changed from the version I had from 9/24/03.  Here's the .rej file output:

***************
*** 1071,1076 ****
                                   INVITE, but do set an autodestruct just in case. */
                                needdestroy = 0;
                                sip_scheddestroy(p, 15000);
                        } else {
                                char *res;
                                if (ast->hangupcause && ((res = hangup_cause2sip(ast->hangupcause)))) {
--- 1080,1091 ----
                                   INVITE, but do set an autodestruct just in case. */
                                needdestroy = 0;
                                sip_scheddestroy(p, 15000);
+                               /* channel still up - reverse dec of inuse counter */
+                               if ( p->outgoing ) {
+                                       find_user(p, INC_OUT_USE);
+                               } else {
+                                       find_user(p, INC_IN_USE);
+                               }
                        } else {
                                char *res;
                                if (ast->hangupcause && ((res = hangup_cause2sip(ast->hangupcause)))) {
--------
Here's what I find in the source around those lines:

        needdestroy = 1;
        /* Start the process if it's not already started */
        if (!p->alreadygone && strlen(p->initreq.data)) {
                if (needcancel) {
                        if (p->outgoing) {
                                transmit_request_with_auth(p, "CANCEL", p->ocseq, 1);
                                /* Actually don't destroy us yet, wait for the 487 on our original
                                   INVITE, but do set an autodestruct just in case. */
                                needdestroy = 0;
                                sip_scheddestroy(p, 15000);
                        } else
                                transmit_response_reliable(p, "403 Forbidden", &p->initreq);
                } else {
                        if (!p->pendinginvite) {
                                /* Send a hangup */
                                transmit_request_with_auth(p, "BYE", 0, 1);
                        } else {
                                /* Note we will need a BYE when this all settles out
                                   but we can't send one while we have "INVITE" outstanding. */
                                p->pendingbye = 1;
                        }
                }
        }
--------

Walker
> @@ -4708,6 +4720,14 @@
>                                         if (p->owner)
>                                                 ast_queue_control(p->owner, AST_
> CONTROL_BUSY, 0);
>                                         break;
> +                               case 487:
> +                                       /* channel now destroyed - dec the inuse
>  counter */
> +                                       if ( p->outgoing ) {
> +                                               find_user(p, DEC_OUT_USE);
> +                                       } else {
> +                                               find_user(p, DEC_IN_USE);
> +                                       }
> +                                       break;
>                                 case 486: /* Busy here */
>                                 case 600: /* Busy everywhere */
>                                         if (p->owner)

-- 
********   DataCrest, Inc. -- Technically Superior   ******************
Walker Haddock                       http://www.datacrest.com
DataCrest, Inc.                    e-mail:  wh at datacrest.com
1634A Montgomery Hwy.    phone:  1-888-941-3282, 1-205-335-8589
Birmingham, AL 35216                  fax:  1-205-823-7838
***********************************************************************



More information about the asterisk-users mailing list