[Asterisk-cvs] asterisk/channels chan_sip.c,1.187,1.188 chan_zap.c,1.107,1.108

martinp at lists.digium.com martinp at lists.digium.com
Wed Oct 1 11:04:29 CDT 2003


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv19006/channels

Modified Files:
	chan_sip.c chan_zap.c 
Log Message:
Add 486 message (SIP) to 17 cause (PRI) translation when you call Dial app and then Hangup:
exten => _X.,1,Dial(SIP/user)
exten => _X.,2,Hangup()



Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.187
retrieving revision 1.188
diff -u -d -r1.187 -r1.188
--- chan_sip.c	1 Oct 2003 04:53:53 -0000	1.187
+++ chan_sip.c	1 Oct 2003 16:05:40 -0000	1.188
@@ -38,6 +38,7 @@
 #include <asterisk/acl.h>
 #include <asterisk/srv.h>
 #include <asterisk/astdb.h>
+#include <asterisk/causes.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <net/if.h>
@@ -4426,6 +4427,19 @@
 		strncpy(p->owner->call_forward, s, sizeof(p->owner->call_forward) - 1);
 }
 
+static int hangup_sip2cause(int cause)
+{
+	switch(cause)
+	{
+		case 486:
+			return AST_CAUSE_BUSY;
+		default:
+			return AST_CAUSE_NORMAL;
+	}
+	/* Never reached */
+	return 0;
+}
+
 static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_request *req)
 {
 	char *to;
@@ -4442,6 +4456,8 @@
 	msg = strchr(c, ' ');
 	if (!msg) msg = ""; else msg++;
 	owner = p->owner;
+	if (owner) 
+		owner->hangupcause = hangup_sip2cause(resp);
 	/* Acknowledge whatever it is destined for */
 	if ((resp >= 100) && (resp <= 199))
 		__sip_semi_ack(p, seqno, 0);

Index: chan_zap.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -d -r1.107 -r1.108
--- chan_zap.c	1 Oct 2003 15:59:26 -0000	1.107
+++ chan_zap.c	1 Oct 2003 16:05:40 -0000	1.108
@@ -503,16 +503,15 @@
 #define CANBUSYDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_SF)) /* || (p->sig & __ZT_SIG_FXO) */)
 #define CANPROGRESSDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_SF)) /* || (p->sig & __ZT_SIG_FXO) */)
 
+#ifdef ZAPATA_PRI
 /* translate between PRI causes and asterisk's */
 static int hangup_pri2cause(int cause)
 {
 	switch(cause) {
-#ifdef ZAPATA_PRI
 		case PRI_CAUSE_USER_BUSY:
 			return AST_CAUSE_BUSY;
 		case PRI_CAUSE_NORMAL_CLEARING:
 			return AST_CAUSE_NORMAL;
-#endif
 		default:
 			return AST_CAUSE_FAILURE;
 	}
@@ -520,6 +519,21 @@
 	return 0;
 }
 
+/* translate between ast cause and PRI */
+static int hangup_cause2pri(int cause)
+{
+	switch(cause) {
+		case AST_CAUSE_BUSY:
+			return PRI_CAUSE_USER_BUSY;
+		case AST_CAUSE_NORMAL:
+		default:
+			return PRI_CAUSE_NORMAL_CLEARING;
+	}
+	/* never reached */
+	return 0;
+}
+#endif
+
 static int zt_get_index(struct ast_channel *ast, struct zt_pvt *p, int nullok)
 {
 	int res;
@@ -1753,7 +1767,7 @@
 						p->call = NULL;
 					} else {
 						p->alreadyhungup = 1;
-						pri_hangup(p->pri->pri, p->call, -1);
+						pri_hangup(p->pri->pri, p->call, ast->hangupcause ? hangup_cause2pri(ast->hangupcause) : -1);
 					}
 #endif
 					if (res < 0) 




More information about the svn-commits mailing list