From a4f7b18361d81d7d8fb07ca2f20c9ab4fe5e935d Mon Sep 17 00:00:00 2001 From: MelwareDE Date: Thu, 22 Jul 2010 05:31:51 +0000 Subject: [PATCH] Added variable DISCONNECT_IND_REASON when DISCONNECT_IND is received. --- CHANGES | 1 + README | 7 +++++++ chan_capi.c | 20 +++++++++++++------- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index e2c3ede..966383a 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,7 @@ HEAD - Fixed memory leak in chat_play if using with 's' option - Add 'econtransitconn' configurations parameter. Allows to preserve EC for transit connections +- added variable DISCONNECT_IND_REASON to get real reason code from CAPI chan_capi-1.1.5 ------------------ diff --git a/README b/README index 80181fa..ca872a2 100644 --- a/README +++ b/README @@ -530,6 +530,13 @@ CONNECTEDNUMBER Can be set before answering and if set, the content is used for IE 'Connected Number' on answering. +DISCONNECT_IND_REASON + When CAPI reports DISCONNECT_IND, some CAPI reason codes are not set + in HANGUPCAUSE, because they are not valid cause codes. To also + get those CAPI reason codes, you can check this variable on hangup. + This is e.g. useful for reason 0x3301, which tells that the ISDN + connection is physically broken (cable). + FAXEXTEN If chan_capi sends the call to extensions 'fax', the original extension number is saved in this variable. diff --git a/chan_capi.c b/chan_capi.c index 1f9eac5..d8ad27b 100644 --- a/chan_capi.c +++ b/chan_capi.c @@ -4698,6 +4698,7 @@ static void capidev_handle_disconnect_indication(_cmsg *CMSG, unsigned int PLCI, { struct ast_frame fr = { AST_FRAME_CONTROL, }; int state; + char buffer[CAPI_MAX_STRING]; FRAME_SUBCLASS_INTEGER(fr.subclass) = AST_CONTROL_HANGUP; @@ -4717,13 +4718,18 @@ static void capidev_handle_disconnect_indication(_cmsg *CMSG, unsigned int PLCI, i->reason = DISCONNECT_IND_REASON(CMSG); - if ((i->owner) && (i->owner->hangupcause == 0)) { - /* set hangupcause, in case there is no - * "cause" information element: - */ - i->owner->hangupcause = - ((i->reason & 0xFF00) == 0x3400) ? - i->reason & 0x7F : AST_CAUSE_NORMAL_CLEARING; + if (i->owner) { + if (i->owner->hangupcause == 0) { + /* set hangupcause, in case there is no + * "cause" information element: + */ + i->owner->hangupcause = + ((i->reason & 0xFF00) == 0x3400) ? + i->reason & 0x7F : AST_CAUSE_NORMAL_CLEARING; + } + /* the real reason could be != 0x34xx, so provide this value in variable */ + sprintf(buffer, "%d", i->reason); + pbx_builtin_setvar_helper(i->owner, "DISCONNECT_IND_REASON", buffer); } if (i->FaxState & CAPI_FAX_STATE_ACTIVE) {