diff --git a/apps/app_dial.c b/apps/app_dial.c index d13dfd9f1e99e0e84614a5ac734693fb4c641c6c..9f0550e3c790b47b3899db74cf1dcdce28bfa5b2 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 03df2dda6bdd43b3111f6b36aae4f5a8b9d283d5..1921a0e6486483d9e77a28ec832e8ac9d5d74a47 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 ac95152384d09d15a3af50c86df6faba5c026ecb..4d47aee7a333ccfb61e28671f4f1ecbd0dd297e4 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)