[Asterisk-Dev] Re: Patches for libpri and chan_zap to handle Q931_SENDING_COMPLETE

Otmar Lendl lendl at nic.at
Thu Jul 24 08:07:02 MST 2003


[resent, this thime with correct From:, To: and a second patch.]

On 2003/07/01 15:07, Otmar Lendl <lendl at nic.at> wrote:
> 
> The choice of "immediate=yes/no" on PRI interfaces is not
> sufficient to get the typical behaviour of an Austrian PBX.

There was a bug in my patches which caused it to fail if 
the "Sending Complete" was included in the initial Call Setup
in front of the RING message. I encountered this when calling
from a GSM mobile, giving me the following pri debugging output:

-- Processing Q.931 Call Setup
-- Processing IE 33 (Sending Complete)
-- Processing IE 4 (Bearer Capability)
-- Processing IE 24 (Channel Identification)
-- Processing IE 108 (Calling Party Number)

The attached patch fixes this by tidying up the libpri routines for
multiple IEs in one message, and (in chan_zap.c) moving the "sending
complete" handling *after* the called-party-id handling, making Direct
Dial In (DDI) calls to extensions possible.

Mark, consider this to be disclaimed and please apply to CVS.

/ol
-- 
< Otmar Lendl (lendl at nic.at) | nic.at Systems Engineer >
-------------- next part --------------
--- tmp/libpri/q931.c	Tue Jul  8 01:37:18 2003
+++ libpri/q931.c	Thu Jul 24 13:01:33 2003
@@ -1648,7 +1645,6 @@
 	c->slotmap = -1;
 	c->ds1no = -1;
 	c->nonisdn = nonisdn;
-	c->complete = 0; 
 		
 	if (exclusive) 
 		c->chanflags = FLAG_EXCLUSIVE;
@@ -1777,6 +1773,7 @@
                 c->useruserprotocoldisc = -1; 
 		strcpy(c->useruserinfo, "");
 		c->ourcallstate = Q931_CALL_STATE_CALL_INITIATED;
+		c->complete = 0;
 		break;
 	case Q931_CONNECT:
 		c->ourcallstate = Q931_CALL_STATE_ACTIVE;
@@ -1878,7 +1875,7 @@
 		pri->ev.ring.cref = c->cr;
 		pri->ev.ring.call = c;
 		pri->ev.ring.layer1 = c->userl1;
-		pri->ev.ring.complete = 0; 
+		pri->ev.ring.complete = c->complete; 
 		if (c->transmoderate != TRANS_MODE_64_CIRCUIT) {
 			q931_release(pri, c, PRI_CAUSE_BEARERCAPABILITY_NOTIMPL);
 			break;
-------------- next part --------------
--- tmp/asterisk/channels/chan_zap.c	Wed Jul  2 23:56:03 2003
+++ asterisk/channels/chan_zap.c	Thu Jul 24 16:20:37 2003
@@ -5608,10 +5607,10 @@
 							strcpy(pri->pvt[chan]->callerid, "");
 						strncpy(pri->pvt[chan]->rdnis, e->ring.redirectingnum, sizeof(pri->pvt[chan]->rdnis));
 					}
-					/* If immediate=yes or call complete go to s|1 */
-					if (pri->pvt[chan]->immediate || e->ring.complete) {
+					/* If immediate=yes go to s|1 */
+					if (pri->pvt[chan]->immediate) {
 						if (option_verbose > 2)
-							ast_verbose(VERBOSE_PREFIX_3 "Going to extension s|1 because of immediate=yes or Complete received\n");
+							ast_verbose(VERBOSE_PREFIX_3 "Going to extension s|1 because of immediate=yes\n");
 						strcpy(pri->pvt[chan]->exten, "s");
 					}
 					/* Get called number */
@@ -5630,6 +5629,14 @@
 #endif
 					else
 						strcpy(pri->pvt[chan]->exten, "");
+
+					/* No number yet, but received "sending complete"? */
+					if (e->ring.complete && (!strlen(e->ring.callednum))) {
+						if (option_verbose > 2)
+							ast_verbose(VERBOSE_PREFIX_3 "Going to extension s|1 because of Complete received\n");
+						strcpy(pri->pvt[chan]->exten, "s");
+					}
+
 					/* queue DTMF frame if the PBX for this call was already started (we're forwarding INFORMATION further on */
 					if (pri->overlapdial && pri->pvt[chan]->call==e->ring.call && pri->pvt[chan]->owner) {
 						/* how to do that */


More information about the asterisk-dev mailing list