aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormartinp <martinp@f38db490-d61c-443f-a65b-d21fe96a405b>2003-10-01 16:05:40 +0000
committermartinp <martinp@f38db490-d61c-443f-a65b-d21fe96a405b>2003-10-01 16:05:40 +0000
commit143f06cec4526c4f8f9dadb3d3533b9c77ac250c (patch)
treefb29cc6d88c7be55350958128b2304f13d96df62
parentcfa5d5657f6986b9a231c2bd016ab60e52186f52 (diff)
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() git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1596 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xapps/app_dial.c3
-rwxr-xr-xchannels/chan_sip.c16
-rwxr-xr-xchannels/chan_zap.c20
3 files changed, 36 insertions, 3 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c
index d13dfd9f1..9f0550e3c 100755
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -229,6 +229,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
case AST_CONTROL_BUSY:
if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "%s is busy\n", o->chan->name);
+ in->hangupcause = o->chan->hangupcause;
ast_hangup(o->chan);
o->chan = NULL;
o->stillgoing = 0;
@@ -239,6 +240,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
case AST_CONTROL_CONGESTION:
if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "%s is circuit-busy\n", o->chan->name);
+ in->hangupcause = o->chan->hangupcause;
ast_hangup(o->chan);
o->chan = NULL;
o->stillgoing = 0;
@@ -282,6 +284,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
}
ast_frfree(f);
} else {
+ in->hangupcause = o->chan->hangupcause;
ast_hangup(o->chan);
o->chan = NULL;
o->stillgoing = 0;
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 03df2dda6..1921a0e64 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -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 @@ static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req)
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 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
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);
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index ac9515238..4d47aee7a 100755
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -503,16 +503,15 @@ static int cidrings[] = {
#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 @@ static int hangup_pri2cause(int cause)
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 @@ static int zt_hangup(struct ast_channel *ast)
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)