]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
error -> error name.
authorMichael Jerris <mike@jerris.com>
Thu, 24 May 2007 17:19:03 +0000 (17:19 +0000)
committerMichael Jerris <mike@jerris.com>
Thu, 24 May 2007 17:19:03 +0000 (17:19 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@143 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/openzap/src/isdn/Q931.c
libs/openzap/src/isdn/include/Q931.h
libs/openzap/src/zap_isdn.c

index d7bf935ff097506c614de21a8f043f001b9954e4..cc5ff4f00b4c7d50770c137a67ca46d90c2ce02c 100644 (file)
@@ -664,3 +664,61 @@ L3BOOL Q931IsEventLegal(L3UCHAR iD, L3INT iState, L3INT iMes, L3UCHAR cDir)
        }
        return L3FALSE; 
 }
+
+/*****************************************************************************
+  Function:            q931_error_to_name()
+
+  Description: Check state table for matching criteria to indicate if this
+                               Message is legal in this state or not.
+
+  Note:                        Someone write a bsearch or invent something smart here
+                               please - sequensial is ok for now.
+*****************************************************************************/
+static const char *q931_error_names[] = {
+       "Q931E_NO_ERROR",                               /* 0 */
+
+       "Q931E_UNKNOWN_MESSAGE",                /* -3001 */
+       "Q931E_ILLEGAL_IE",                             /* -3002 */
+       "Q931E_UNKNOWN_IE",                             /* -3003 */
+       "Q931E_BEARERCAP",                              /* -3004 */
+       "Q931E_HLCOMP",                                 /* -3005 */
+       "Q931E_LLCOMP",                                 /* -3006 */
+       "Q931E_INTERNAL",                               /* -3007 */
+       "Q931E_MISSING_CB",                             /* -3008 */
+       "Q931E_UNEXPECTED_MESSAGE",             /* -3009 */
+       "Q931E_ILLEGAL_MESSAGE",                /* -3010 */
+       "Q931E_TOMANYCALLS",                    /* -3011 */
+       "Q931E_INVALID_CRV",                    /* -3012 */
+       "Q931E_CALLID",                                 /* -3013 */
+       "Q931E_CALLSTATE",                              /* -3014 */
+       "Q931E_CALLEDSUB",                              /* -3015 */
+       "Q931E_CALLEDNUM",                              /* -3016 */
+       "Q931E_CALLINGNUM",                             /* -3017 */
+       "Q931E_CALLINGSUB",                             /* -3018 */
+       "Q931E_CAUSE",                                  /* -3019 */
+       "Q931E_CHANID",                                 /* -3020 */
+       "Q931E_DATETIME",                               /* -3021 */
+       "Q931E_DISPLAY",                                /* -3022 */
+       "Q931E_KEYPADFAC",                              /* -3023 */
+       "Q931E_NETFAC",                                 /* -3024 */
+       "Q931E_NOTIFIND",                               /* -3025 */
+       "Q931E_PROGIND",                                /* -3026 */
+       "Q931E_RESTARTIND",                             /* -3027 */
+       "Q931E_SEGMENT",                                /* -3028 */
+       "Q931E_SIGNAL",                                 /* -3029 */
+
+};
+
+#define Q931_MAX_ERROR 29
+
+const char *q931_error_to_name(q931_error_t error)
+{
+       int index = 0;
+       if ((int)error < 0) {
+               index = (((int)error * -1) -3000);
+       }
+       if (index < 0 || index > Q931_MAX_ERROR) {
+               return "";
+       }
+       return q931_error_names[index];
+}
\ No newline at end of file
index a8682527e5937494761eb0e1f781457f6e18fa03..29f7fa7373ae6f032fa85999d4088c15fd5ceeca 100644 (file)
   Error Codes
 
 *****************************************************************************/
-#define Q931E_NO_ERROR                                 0
-#define Q931E_UNKNOWN_MESSAGE                  -3001
-#define Q931E_ILLEGAL_IE                               -3002
-#define Q931E_UNKNOWN_IE                               -3003
-#define Q931E_BEARERCAP                                        -3004
-#define Q931E_HLCOMP                                   -3005
-#define Q931E_LLCOMP                                   -3006
-#define Q931E_INTERNAL                  -3007
-#define Q931E_MISSING_CB                -3008
-#define Q931E_UNEXPECTED_MESSAGE        -3009
-#define Q931E_ILLEGAL_MESSAGE                  -3010
-#define Q931E_TOMANYCALLS               -3011
-#define Q931E_INVALID_CRV               -3012
-#define Q931E_CALLID                    -3013
-#define Q931E_CALLSTATE                 -3014
-#define Q931E_CALLEDSUB                 -3015
-#define Q931E_CALLEDNUM                 -3016
-#define Q931E_CALLINGNUM                -3017
-#define Q931E_CALLINGSUB                -3018
-#define Q931E_CAUSE                     -3019
-#define Q931E_CHANID                    -3020
-#define Q931E_DATETIME                  -3021
-#define Q931E_DISPLAY                   -3022
-#define Q931E_KEYPADFAC                 -3023
-#define Q931E_NETFAC                    -3024
-#define Q931E_NOTIFIND                  -3025
-#define Q931E_PROGIND                   -3026
-#define Q931E_RESTARTIND                -3027
-#define Q931E_SEGMENT                   -3028
-#define Q931E_SIGNAL                    -3029
+typedef enum {
+
+       Q931E_NO_ERROR                          =       0,
+
+       Q931E_UNKNOWN_MESSAGE           =       -3001,
+       Q931E_ILLEGAL_IE                        =       -3002,
+       Q931E_UNKNOWN_IE                        =       -3003,
+       Q931E_BEARERCAP                         =       -3004,
+       Q931E_HLCOMP                            =       -3005,
+       Q931E_LLCOMP                            =       -3006,
+       Q931E_INTERNAL              =   -3007,
+       Q931E_MISSING_CB            =   -3008,
+       Q931E_UNEXPECTED_MESSAGE    =   -3009,
+       Q931E_ILLEGAL_MESSAGE           =       -3010,
+       Q931E_TOMANYCALLS           =   -3011,
+       Q931E_INVALID_CRV           =   -3012,
+       Q931E_CALLID                =   -3013,
+       Q931E_CALLSTATE             =   -3014,
+       Q931E_CALLEDSUB             =   -3015,
+       Q931E_CALLEDNUM             =   -3016,
+       Q931E_CALLINGNUM            =   -3017,
+       Q931E_CALLINGSUB            =   -3018,
+       Q931E_CAUSE                 =   -3019,
+       Q931E_CHANID                =   -3020,
+       Q931E_DATETIME              =   -3021,
+       Q931E_DISPLAY               =   -3022,
+       Q931E_KEYPADFAC             =   -3023,
+       Q931E_NETFAC                =   -3024,
+       Q931E_NOTIFIND              =   -3025,
+       Q931E_PROGIND               =   -3026,
+       Q931E_RESTARTIND            =   -3027,
+       Q931E_SEGMENT               =   -3028,
+       Q931E_SIGNAL                =   -3029
+
+} q931_error_t;
+
+/* The q931_error_t enum should be kept in sync with the q931_error_names array in Q931.c */ 
+
+const char *q931_error_to_name(q931_error_t error);
 
 /*****************************************************************************
 
index f88f1202311b0c94e21a8439a7c0fa1aeaa99589..2076419ba830373839007cee40905bfe7b8333e0 100644 (file)
@@ -57,7 +57,7 @@ static L2ULONG zap_time_now()
 
 static L3INT zap_isdn_931_err(void *pvt, L3INT id, L3INT p1, L3INT p2)
 {
-       zap_log(ZAP_LOG_ERROR, "ERROR: %d %d %d", id, p1, p2);
+       zap_log(ZAP_LOG_ERROR, "ERROR: [%s] [%d] [%d]\n", q931_error_to_name(id), p1, p2);
        return 0;
 }
 
@@ -82,7 +82,7 @@ static int zap_isdn_921_23(void *pvt, L2UCHAR *msg, L2INT mlen)
 {
        int ret = Q931Rx23(pvt, msg, mlen);
        if (ret != 0)
-               zap_log(ZAP_LOG_DEBUG, "931 parse error [%d] \n", ret);
+               zap_log(ZAP_LOG_DEBUG, "931 parse error [%d] [%s]\n", ret, q931_error_to_name(ret));
        return ((ret >= 0) ? 1 : 0);
 }