Adding some generic handling of error codes sent to us in replys to requests.
authorOlle Johansson <oej@edvina.net>
Wed, 27 May 2009 20:14:00 +0000 (20:14 +0000)
committerOlle Johansson <oej@edvina.net>
Wed, 27 May 2009 20:14:00 +0000 (20:14 +0000)
Previously they always set hangupcause 0, which is generally wrong. With this
change, we're setting some generic hangup causes. For 5xx errors, which indicate
some sort of problem with the remote server, we're now setting CONGESTION.

EDVX002

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@197266 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 20e47a4..07b2330 100644 (file)
@@ -5698,6 +5698,16 @@ static int hangup_sip2cause(int cause)
                case 606:       /* Not acceptable */
                        return AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
                default:
+                       if (cause < 500 && cause >= 400) {
+                               /* 4xx class error that is unknown - someting wrong with our request */
+                               return AST_CAUSE_INTERWORKING;
+                       } else if (cause < 600 && cause >= 500) {
+                               /* 5xx class error - problem in the remote end */
+                               return AST_CAUSE_CONGESTION;
+                       } else if (cause < 700 && cause >= 600) {
+                               /* 6xx - global errors in the 4xx class */
+                               return AST_CAUSE_INTERWORKING;
+                       }
                        return AST_CAUSE_NORMAL;
        }
        /* Never reached */