Module: sems
Branch: master
Commit: eb465723e73baa0b92e818ba880d096b01e6ca25
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=eb465723e73baa0b92e818ba880d096b01e6ca25

Author: Raphael Coeffic <[email protected]>
Committer: Raphael Coeffic <[email protected]>
Date:   Thu Mar 29 15:03:04 2012 +0200

sip version should be parsed case-insensitively.

---

 core/sip/sip_parser.cpp |   51 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/core/sip/sip_parser.cpp b/core/sip/sip_parser.cpp
index d4ab201..3201e6e 100644
--- a/core/sip/sip_parser.cpp
+++ b/core/sip/sip_parser.cpp
@@ -262,19 +262,27 @@ static int parse_first_line(sip_msg* msg, char** c)
 
        switch(st){
 
-#define case_SIPVER(ch,st1,st2,else_st) \
-       case st1:\
-           if(**c == (ch)){\
-               st = st2;\
-           }\
-           else {\
-               st = else_st;\
-           }\
-           break
-            
-       case_SIPVER('S',FL_SIPVER1,FL_SIPVER2,FL_METH;(*c)--);
-       case_SIPVER('I',FL_SIPVER2,FL_SIPVER3,FL_METH;(*c)--);
-       case_SIPVER('P',FL_SIPVER3,FL_SIPVER4,FL_METH;(*c)--);
+#define case_SIPVER(ch1,ch2,st1,st2)           \
+           case st1:                           \
+               switch(**c){                    \
+               case ch1:                       \
+               case ch2:                       \
+                   st = st2;                   \
+                   break;                      \
+               default:                        \
+                   if(!is_request){            \
+                       st = FL_METH;           \
+                       (*c)--;                 \
+                   }                           \
+                   else {                      \
+                       st = FL_ERR;            \
+                   }                           \
+               }                               \
+               break
+
+       case_SIPVER('S','s',FL_SIPVER1,FL_SIPVER2);
+       case_SIPVER('I','i',FL_SIPVER2,FL_SIPVER3);
+       case_SIPVER('P','p',FL_SIPVER3,FL_SIPVER4);
 
        case FL_SIPVER4:     // '/'
            if(**c == '/'){
@@ -289,10 +297,21 @@ static int parse_first_line(sip_msg* msg, char** c)
            }
            break;
 
-       case_SIPVER('2',FL_SIPVER_DIG1,FL_SIPVER_SEP,FL_ERR);
-       case_SIPVER('.',FL_SIPVER_SEP,FL_SIPVER_DIG2,FL_ERR);
-
 #undef case_SIPVER
+#define case_SIPVER(ch1,st1,st2)               \
+           case st1:                           \
+               switch(**c){                    \
+               case ch1:                       \
+                   st = st2;                   \
+                   break;                      \
+               default:                        \
+                   st = FL_ERR;                \
+                   break;                      \
+               }                               \
+               break
+
+       case_SIPVER('2',FL_SIPVER_DIG1,FL_SIPVER_SEP);
+       case_SIPVER('.',FL_SIPVER_SEP,FL_SIPVER_DIG2);
 
        case FL_SIPVER_DIG2:
            if(**c == '0'){

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to