Fix and improve the new pri hangup routines
authorMartin Pycko <martinp@digium.com>
Tue, 5 Aug 2003 01:25:43 +0000 (01:25 +0000)
committerMartin Pycko <martinp@digium.com>
Tue, 5 Aug 2003 01:25:43 +0000 (01:25 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1262 65c4cc65-6c06-0410-ace0-fbb531ad65f3

Makefile
channels/chan_zap.c

index c515dd6..0c53598 100755 (executable)
--- a/Makefile
+++ b/Makefile
@@ -13,6 +13,9 @@
 
 .EXPORT_ALL_VARIABLES:
 
+# Create OPTIONS variable
+OPTIONS=
+
 OSARCH=$(shell uname -s)
 
 ifeq (${OSARCH},Linux)
@@ -41,6 +44,11 @@ OPTIMIZE=-O6
 #Include debug symbols in the executables (-g) and profiling info (-pg)
 DEBUG=-g #-pg
 
+# New hangup routines for chan_zap.c
+# If this flag is uncommented then you need to have new libpri code in your system
+# You can still use the old libpri if you do "cvs update -D "08/03/03" in libpri source code
+OPTIONS += -DNEW_PRI_HANGUP
+
 # Optional debugging parameters
 DEBUG_THREADS = #-DDO_CRASH -DDEBUG_THREADS
 
@@ -117,6 +125,7 @@ CFLAGS+= $(DEBUG_THREADS)
 CFLAGS+= $(TRACE_FRAMES)
 CFLAGS+= $(MALLOC_DEBUG)
 CFLAGS+= $(BUSYDETECT)
+CFLAGS+= $(OPTIONS)
 CFLAGS+=# -fomit-frame-pointer 
 SUBDIRS=res channels pbx apps codecs formats agi cdr astman
 ifeq (${OSARCH},Linux)
index 0d46dbb..1be12cc 100755 (executable)
@@ -1614,6 +1614,7 @@ static int zt_hangup(struct ast_channel *ast)
                if (p->sig == SIG_PRI) {
                        if (p->call) {
                                if (!pri_grab(p, p->pri)) {
+#ifndef NEW_PRI_HANGUP
                                        if (!p->alreadyhungup) {
                                                res = pri_disconnect(p->pri->pri, p->call, PRI_CAUSE_NORMAL_CLEARING);
                                        } else {
@@ -1621,6 +1622,12 @@ static int zt_hangup(struct ast_channel *ast)
                                                p->call = NULL;
                                                p->alreadyhungup = 0;
                                        }
+#else
+#ifndef PRI_HANGUP
+#error Please update libpri. The new hangup routines were implemented. You can debug then using "pri debug span <span_no>". If you dont want to update libpri code simply comment out OPTIONS += -DNEW_PRI_HANGUP in asterisk/Makefile
+#endif
+                                       pri_hangup(p->pri->pri, p->call, -1);
+#endif
                                        if (res < 0) 
                                                ast_log(LOG_WARNING, "pri_disconnect failed\n");
                                        pri_rel(p->pri);                        
@@ -5685,7 +5692,11 @@ static void *pri_dchannel(void *vpri)
                                                        zt_enable_ec(pri->pvt[chan]);
                                                } else {
                                                        ast_log(LOG_WARNING, "Unable to start PBX on channel %d, span %d\n", chan, pri->span);
+#if NEW_PRI_HANGUP
+                                                       pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_SWITCH_CONGESTION);
+#else
                                                        pri_release(pri->pri, e->ring.call, PRI_CAUSE_SWITCH_CONGESTION);
+#endif
                                                        pri->pvt[chan]->call = 0;
                                                }
                                        } else {
@@ -5696,11 +5707,19 @@ static void *pri_dchannel(void *vpri)
                                                } else {
                                                        if (option_verbose > 2)
                                                                ast_verbose(VERBOSE_PREFIX_3 "Extension '%s' in context '%s' from '%s' does not exist.  Rejecting call on channel %d, span %d\n",pri->pvt[chan]->exten, pri->pvt[chan]->context, pri->pvt[chan]->callerid, chan, pri->span);
+#ifdef NEW_PRI_HANGUP
+                                                       pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_UNALLOCATED);
+#else
                                                        pri_release(pri->pri, e->ring.call, PRI_CAUSE_UNALLOCATED);
+#endif
                                                }
                                        }
                                } else 
+#ifdef NEW_PRI_HANGUP
+                                       pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_REQUESTED_CHAN_UNAVAIL);
+#else
                                        pri_release(pri->pri, e->ring.call, PRI_CAUSE_REQUESTED_CHAN_UNAVAIL);
+#endif
                                break;
                        case PRI_EVENT_RINGING:
                                chan = e->ringing.channel;