Make Asterisk cause codes match those of Q.931 (bug #1999)
authorMark Spencer <markster@digium.com>
Thu, 12 Aug 2004 22:09:18 +0000 (22:09 +0000)
committerMark Spencer <markster@digium.com>
Thu, 12 Aug 2004 22:09:18 +0000 (22:09 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3603 65c4cc65-6c06-0410-ace0-fbb531ad65f3

CHANGES
channels/chan_zap.c
include/asterisk/causes.h

diff --git a/CHANGES b/CHANGES
index c439131..9509c94 100755 (executable)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+ -- Use Q.931 standard cause codes for asterisk cause codes
+ -- Bug fixes from the bug tracker
 Asterisk 1.0-RC2 
  -- Additional CDR backends
  -- Allow muted to reconnect
index 8a3b453..b06ec1d 100755 (executable)
@@ -604,50 +604,6 @@ static int cidrings[NUM_CADENCE_MAX] = {
 #define CANBUSYDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __ZT_SIG_FXO) */)
 #define CANPROGRESSDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | 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) {
-               case PRI_CAUSE_USER_BUSY:
-                       return AST_CAUSE_BUSY;
-               case PRI_CAUSE_NORMAL_CLEARING:
-                       return AST_CAUSE_NORMAL;
-               case PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION:
-               case PRI_CAUSE_REQUESTED_CHAN_UNAVAIL:
-                       return AST_CAUSE_CONGESTION;
-               case PRI_CAUSE_UNALLOCATED:
-               case PRI_CAUSE_NUMBER_CHANGED:
-                       return AST_CAUSE_UNALLOCATED;
-               case PRI_CAUSE_NO_USER_RESPONSE:
-               case PRI_CAUSE_NO_ANSWER:
-                       return AST_CAUSE_NOANSWER;
-               default:
-                       return AST_CAUSE_FAILURE;
-       }
-       /* never reached */
-       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_UNALLOCATED:
-                       return PRI_CAUSE_UNALLOCATED;
-               case AST_CAUSE_CONGESTION:
-                       return PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION;
-               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;
@@ -2106,7 +2062,7 @@ static int zt_hangup(struct ast_channel *ast)
                                                        p->bearer->call = NULL;
                                        } else {
                                                char *cause = pbx_builtin_getvar_helper(ast,"PRI_CAUSE");
-                                               int icause = ast->hangupcause ? hangup_cause2pri(ast->hangupcause) : -1;
+                                               int icause = ast->hangupcause ? ast->hangupcause : -1;
                                                ast_log(LOG_DEBUG, "Not yet hungup...  Calling hangup once with icause, and clearing call\n");
                                                p->alreadyhungup = 1;
                                                if (p->bearer)
@@ -7510,7 +7466,7 @@ static void *pri_dchannel(void *vpri)
                                                                pri_hangup_all(pri->pvts[chanpos]->master);
                                                        else if (pri->pvts[chanpos]->owner) {
                                                                /* Queue a BUSY instead of a hangup if our cause is appropriate */
-                                                               pri->pvts[chanpos]->owner->hangupcause = hangup_pri2cause(e->hangup.cause);
+                                                               pri->pvts[chanpos]->owner->hangupcause = e->hangup.cause;
                                                                switch(e->hangup.cause) {
                                                                case PRI_CAUSE_USER_BUSY:
                                                                        pri->pvts[chanpos]->subs[SUB_REAL].needbusy =1;
@@ -7565,7 +7521,7 @@ static void *pri_dchannel(void *vpri)
                                                if (pri->pvts[chanpos]->master) 
                                                        pri_hangup_all(pri->pvts[chanpos]->master);
                                                else if (pri->pvts[chanpos]->owner) {
-                                                       pri->pvts[chanpos]->owner->hangupcause = hangup_pri2cause(e->hangup.cause);
+                                                       pri->pvts[chanpos]->owner->hangupcause = e->hangup.cause;
                                                        switch(e->hangup.cause) {
                                                        case PRI_CAUSE_USER_BUSY:
                                                                pri->pvts[chanpos]->subs[SUB_REAL].needbusy =1;
index c77905d..6a6c5dc 100755 (executable)
 #ifndef _ASTERISK_CAUSES_H
 #define _ASTERISK_CAUSES_H
 
-#define AST_CAUSE_NOTDEFINED   0
-#define AST_CAUSE_NORMAL       1
-#define AST_CAUSE_BUSY         2
-#define AST_CAUSE_FAILURE      3
-#define AST_CAUSE_CONGESTION   4
-#define AST_CAUSE_UNALLOCATED  5
-#define AST_CAUSE_NOANSWER             6
+/* Causes for disconnection (from Q.931) */
+#define AST_CAUSE_UNALLOCATED                                  1
+#define AST_CAUSE_NO_ROUTE_TRANSIT_NET                 2
+#define AST_CAUSE_NO_ROUTE_DESTINATION                 3
+#define AST_CAUSE_CHANNEL_UNACCEPTABLE                 6
+#define AST_CAUSE_CALL_AWARDED_DELIVERED               7
+#define AST_CAUSE_NORMAL_CLEARING                              16
+#define AST_CAUSE_USER_BUSY                                            17
+#define AST_CAUSE_NO_USER_RESPONSE                             18
+#define AST_CAUSE_NO_ANSWER                                            19
+#define AST_CAUSE_CALL_REJECTED                                        21
+#define AST_CAUSE_NUMBER_CHANGED                               22
+#define AST_CAUSE_DESTINATION_OUT_OF_ORDER             27
+#define AST_CAUSE_INVALID_NUMBER_FORMAT                        28
+#define AST_CAUSE_FACILITY_REJECTED                            29
+#define AST_CAUSE_RESPONSE_TO_STATUS_ENQUIRY   30
+#define AST_CAUSE_NORMAL_UNSPECIFIED                   31
+#define AST_CAUSE_NORMAL_CIRCUIT_CONGESTION            34
+#define AST_CAUSE_NETWORK_OUT_OF_ORDER                 38
+#define AST_CAUSE_NORMAL_TEMPORARY_FAILURE             41
+#define AST_CAUSE_SWITCH_CONGESTION                            42
+#define AST_CAUSE_ACCESS_INFO_DISCARDED                        43
+#define AST_CAUSE_REQUESTED_CHAN_UNAVAIL               44
+#define AST_CAUSE_PRE_EMPTED                                   45
+#define AST_CAUSE_FACILITY_NOT_SUBSCRIBED              50
+#define AST_CAUSE_OUTGOING_CALL_BARRED                 52
+#define AST_CAUSE_INCOMING_CALL_BARRED                 54
+#define AST_CAUSE_BEARERCAPABILITY_NOTAUTH             57
+#define AST_CAUSE_BEARERCAPABILITY_NOTAVAIL     58
+#define AST_CAUSE_BEARERCAPABILITY_NOTIMPL             65
+#define AST_CAUSE_CHAN_NOT_IMPLEMENTED                 66
+#define AST_CAUSE_FACILITY_NOT_IMPLEMENTED      69
+#define AST_CAUSE_INVALID_CALL_REFERENCE               81
+#define AST_CAUSE_INCOMPATIBLE_DESTINATION             88
+#define AST_CAUSE_INVALID_MSG_UNSPECIFIED              95
+#define AST_CAUSE_MANDATORY_IE_MISSING                 96
+#define AST_CAUSE_MESSAGE_TYPE_NONEXIST                        97
+#define AST_CAUSE_WRONG_MESSAGE                                        98
+#define AST_CAUSE_IE_NONEXIST                                  99
+#define AST_CAUSE_INVALID_IE_CONTENTS                  100
+#define AST_CAUSE_WRONG_CALL_STATE                             101
+#define AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE             102
+#define AST_CAUSE_MANDATORY_IE_LENGTH_ERROR            103
+#define AST_CAUSE_PROTOCOL_ERROR                               111
+#define AST_CAUSE_INTERWORKING                                 127
+
+/* Special Asterisk aliases */
+#define AST_CAUSE_BUSY                                                         AST_CAUSE_USER_BUSY
+#define AST_CAUSE_FAILURE                                              AST_CAUSE_NETWORK_OUT_OF_ORDER
+#define AST_CAUSE_NORMAL                                               AST_CAUSE_NORMAL_CLEARING
+#define AST_CAUSE_NOANSWER                                             AST_CAUSE_NO_ANSWER
+#define AST_CAUSE_CONGESTION                                   AST_CAUSE_NORMAL_CIRCUIT_CONGESTION
+#define AST_CAUSE_NOTDEFINED                                   0
 
 #endif