فهرست منبع

- adjusted compact headers. There were missing compact equivalents for
Subject, Refer-To and completely missing Session-Expires, Accept-Contact, etc. support.
Currently I've implemented both compact header and case switches
to assign enumeration type. No next parsing is processed, but
probably will be done, good candidate e.g. Session-Expires.

Now e.g. textops hf_value correctly recognizes "Session-Expires" and "x" as equal headers.

Tomas Mandys 19 سال پیش
والد
کامیت
6738661913
12فایلهای تغییر یافته به همراه439 افزوده شده و 104 حذف شده
  1. 31 7
      parser/case_acce.h
  2. 27 6
      parser/case_allo.h
  3. 19 6
      parser/case_cont.h
  4. 29 9
      parser/case_refe.h
  5. 69 0
      parser/case_reje.h
  6. 42 5
      parser/case_requ.h
  7. 72 0
      parser/case_sess.h
  8. 17 9
      parser/hf.c
  9. 16 0
      parser/hf.h
  10. 32 5
      parser/keys.h
  11. 46 32
      parser/msg_parser.c
  12. 39 25
      parser/parse_hname2.c

+ 31 - 7
parser/case_acce.h

@@ -1,7 +1,7 @@
-/* 
- * $Id$ 
+/*
+ * $Id$
  *
- * Accept and Accept-Language Header Field Name Parsing Macros
+ * Accept, Accept-Language, Accept-Contact, Accept-Disposition Header Field Name Parsing Macros
  *
  * Copyright (C) 2001-2003 FhG Fokus
  *
@@ -22,8 +22,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -85,8 +85,27 @@
                 goto other;        \
         }
 
+#define accept_contact_ct_CASE                             \
+        if (LOWER_BYTE(*p) == 'c') {                       \
+                p++;                                       \
+                if (LOWER_BYTE(*p) == 't') {               \
+                        hdr->type = HDR_ACCEPTCONTACT_T;   \
+                        p++;                               \
+                        goto dc_end;                       \
+                }                                          \
+        }
 
-#define ptld_CASE                  \
+#define accept_c_onta_CASE         \
+        switch(LOWER_DWORD(val)) { \
+        case _onta_:               \
+                p += 4;            \
+                val = READ(p);     \
+                accept_contact_ct_CASE;  \
+                goto other;        \
+        }
+
+
+#define ptldc_CASE                 \
         switch(LOWER_DWORD(val)) { \
         case _pt_l_:               \
 		p += 4;            \
@@ -99,13 +118,18 @@
                 val = READ(p);     \
                 ispo_CASE;         \
                 goto other;        \
+        case _pt_c_:               \
+                p += 4;            \
+                val = READ(p);     \
+                accept_c_onta_CASE;\
+                goto other;        \
 	}
 
 
 #define acce_CASE                           \
     p += 4;                                 \
     val = READ(p);                          \
-    ptld_CASE;                              \
+    ptldc_CASE;                             \
                                             \
     if (LOWER_BYTE(*p) == 'p') {            \
             p++;                            \

+ 27 - 6
parser/case_allo.h

@@ -1,7 +1,7 @@
-/* 
- * $Id$ 
+/*
+ * $Id$
  *
- * Allow Header Field Name Parsing Macros
+ * Allow, Allow-Events Header Field Name Parsing Macros
  *
  * Copyright (C) 2001-2003 FhG Fokus
  *
@@ -22,21 +22,42 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #ifndef CASE_ALLO_H
 #define CASE_ALLO_H
 
+#define allow_ev_ents_CASE         \
+	switch(LOWER_DWORD(val)) { \
+	case _ents_:               \
+		p += 4;            \
+		hdr->type = HDR_ALLOWEVENTS_T; \
+		goto dc_end;       \
+	}
+
+
+
+#define allo_w_ev_CASE             \
+        switch(LOWER_DWORD(val)) { \
+        case _w_ev_:               \
+                p += 4;            \
+                val = READ(p);     \
+                allow_ev_ents_CASE;\
+                goto other;        \
+        }
+
 
 #define allo_CASE                  \
     p += 4;                        \
+    val = READ(p);                 \
+    allo_w_ev_CASE;                \
     if (LOWER_BYTE(*p) == 'w') {   \
             hdr->type = HDR_ALLOW_T; \
             p++;                   \
-	    goto dc_end;           \
+            goto dc_end;           \
     }                              \
     goto other;
 

+ 19 - 6
parser/case_cont.h

@@ -1,7 +1,7 @@
-/* 
- * $Id$ 
+/*
+ * $Id$
  *
- * Contact, Content-Type, Content-Length, Content-Disposition
+ * Contact, Content-Type, Content-Length, Content-Disposition, Content-Encoding
  * Header Field Name Parsing Macros
  *
  * Copyright (C) 2001-2003 FhG Fokus
@@ -23,8 +23,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * History:
@@ -81,6 +81,14 @@
 	}
 
 
+#define ENCODING_CASE              \
+	switch(LOWER_DWORD(val)) { \
+	case _ding_:               \
+		p += 4;            \
+		hdr->type = HDR_CONTENTENCODING_T; \
+		goto dc_end;       \
+	}
+
 #define CONTENT_CASE                         \
         switch(LOWER_DWORD(val)) {           \
         case _leng_:                         \
@@ -99,6 +107,11 @@
 		val = READ(p);               \
 		DISPOSITION_CASE;            \
                 goto other;                  \
+        case _enco_:                         \
+                p += 4;                      \
+		val = READ(p);               \
+		ENCODING_CASE;               \
+                goto other;                  \
         }
 
 
@@ -119,7 +132,7 @@
                 val = READ(p);           \
                 CONTENT_CASE;            \
                 goto other;              \
-        }                         
+        }
 
 #define cont_CASE      \
      p += 4;           \

+ 29 - 9
parser/case_refe.h

@@ -1,6 +1,8 @@
-/* 
+/*
  * Refer-To Header Field Name Parsing Macros
  *
+ * Refer-To, Referred-By Header Field Name Parsing Macros
+ *
  * Copyright (C) 2005 Juha Heinanen
  *
  * This file is part of ser, a free SIP server.
@@ -20,26 +22,44 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #ifndef CASE_REFE_H
 #define CASE_REFE_H
 
-#define r_to_CASE                          \
-        if (LOWER_DWORD(val) == _r_to_) {  \
+#define REFERRED_BY_CASE                 \
+        switch(LOWER_DWORD(val)) {       \
+        case __by1_:                     \
+	        hdr->type = HDR_REFERREDBY_T; \
+	        hdr->name.len = 11;      \
+	        return (p + 4);          \
+        case __by2_:                      \
+	        hdr->type = HDR_REFERREDBY_T; \
+	        p += 4;                  \
+	        goto dc_end;             \
+	}
+
+#define r_to_CASE                        \
+        switch(LOWER_DWORD(val)) {       \
+        case _r_to_:  \
                 hdr->type = HDR_REFER_TO_T;  \
-                p += 4;                    \
-                goto dc_end;               \
+                p += 4;                  \
+                goto dc_end;             \
+        \
+        case _rred_:                     \
+                p += 4;                  \
+                val = READ(p);           \
+                REFERRED_BY_CASE;        \
+                goto other;              \
         }
 
-
 #define refe_CASE      \
      p += 4;           \
      val = READ(p);    \
-     r_to_CASE;         \
+     r_to_CASE;        \
      goto other;
 
 

+ 69 - 0
parser/case_reje.h

@@ -0,0 +1,69 @@
+/*
+ * $Id$
+ *
+ * Reject-Contact Header Field Name Parsing Macros
+ *
+ * Copyright (C) 2001-2003 FhG Fokus
+ *
+ * This file is part of ser, a free SIP server.
+ *
+ * ser is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * For a license to use the ser software under conditions
+ * other than those described here, or to purchase support for this
+ * software, please contact iptel.org by e-mail at the following addresses:
+ *    [email protected]
+ *
+ * ser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef CASE_REJE_H
+#define CASE_REJE_H
+
+
+#define reject_conta_ct_CASE                            \
+        if (LOWER_BYTE(*p) == 'c') {                    \
+                p++;                                    \
+                if (LOWER_BYTE(*p) == 't') {            \
+                        hdr->type = HDR_REJECTCONTACT_T;\
+                        p++;                            \
+                        goto dc_end;                    \
+                }                                       \
+        }
+
+#define reject_c_onta_CASE                \
+        if (LOWER_DWORD(val) == _onta_) { \
+	        p += 4;                   \
+                val = READ(p);            \
+                reject_conta_ct_CASE;     \
+		goto other;               \
+	}
+
+
+#define reje_ct_c_CASE                 \
+        if (LOWER_DWORD(val) == _ct_c_) {  \
+                p += 4;                     \
+	        val = READ(p);              \
+	        reject_c_onta_CASE;         \
+                goto other;                 \
+        }
+
+
+#define reje_CASE      \
+     p += 4;           \
+     val = READ(p);    \
+     reje_ct_c_CASE;        \
+     goto other;
+
+
+#endif /* CASE_REJE_H */

+ 42 - 5
parser/case_requ.h

@@ -1,7 +1,7 @@
-/* 
- * $Id$ 
+/*
+ * $Id$
  *
- * Require Header Field Name Parsing Macros
+ * Require, Request-Disposition Header Field Name Parsing Macros
  *
  * Copyright (C) 2001-2003 FhG Fokus
  *
@@ -22,8 +22,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * History:
@@ -38,6 +38,38 @@
 
 #include "../comp_defs.h"
 
+#define REQUESTDISPOSIT_ion_CASE                    \
+        switch(LOWER_DWORD(val)) {                  \
+        case _ion1_:                                \
+	        hdr->type = HDR_REQUESTDISPOSITION_T; \
+	        hdr->name.len = 19;                 \
+	        return (p + 4);                     \
+                                                    \
+        case _ion2_:                                \
+                hdr->type = HDR_REQUESTDISPOSITION_T; \
+                p += 4;                             \
+	        goto dc_end;                        \
+        }
+
+
+#define REQUESTDISP_OSITION_CASE   \
+        switch(LOWER_DWORD(val)) { \
+        case _osit_:               \
+		p += 4;            \
+		val = READ(p);     \
+		REQUESTDISPOSIT_ion_CASE;  \
+		goto other;        \
+	}
+
+#define REQUEST_DISPOSITION_CASE             \
+        switch(LOWER_DWORD(val)) {           \
+        case _disp_:                         \
+                p += 4;                      \
+		val = READ(p);               \
+		REQUESTDISP_OSITION_CASE;    \
+                goto other;                  \
+        }
+
 
 #define IRE_CASE                         \
         switch(LOWER_DWORD(val)) {       \
@@ -50,6 +82,11 @@
                 hdr->type = HDR_REQUIRE_T; \
                 p += 4;                  \
                 goto dc_end;             \
+        case _est__:                     \
+                p += 4;                  \
+                val = READ(p);           \
+                REQUEST_DISPOSITION_CASE;\
+                goto other;              \
         }
 
 

+ 72 - 0
parser/case_sess.h

@@ -0,0 +1,72 @@
+/*
+ * $Id$
+ *
+ * Session-Expires Header Field Name Parsing Macros
+ *
+ * Copyright (C) 2001-2003 FhG Fokus
+ *
+ * This file is part of ser, a free SIP server.
+ *
+ * ser is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * For a license to use the ser software under conditions
+ * other than those described here, or to purchase support for this
+ * software, please contact iptel.org by e-mail at the following addresses:
+ *    [email protected]
+ *
+ * ser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef CASE_SESS_H
+#define CASE_SESS_H
+
+
+#define sessionexpi_res_CASE                         \
+	switch(LOWER_DWORD(val)) {       \
+	case _res1_:                     \
+		hdr->type = HDR_SESSIONEXPIRES_T;    \
+		hdr->name.len = 15;      \
+		return (p + 4);          \
+						\
+	case _res2_:                     \
+		hdr->type = HDR_SESSIONEXPIRES_T;    \
+		p += 4;                  \
+		goto dc_end;             \
+	}
+
+#define session_expi_CASE                         \
+        if (LOWER_DWORD(val) == _expi_) { \
+	        p += 4;                   \
+                val = READ(p);            \
+                sessionexpi_res_CASE;                 \
+		goto other;               \
+	}
+
+
+#define sess_ion__CASE                          \
+        if (LOWER_DWORD(val) == _ion__) {  \
+                p += 4;                    \
+	        val = READ(p);             \
+	        session_expi_CASE;                 \
+                goto other;                \
+        }
+
+
+#define sess_CASE      \
+     p += 4;           \
+     val = READ(p);    \
+     sess_ion__CASE;        \
+     goto other;
+
+
+#endif /* CASE_SESS_H */

+ 17 - 9
parser/hf.c

@@ -1,5 +1,5 @@
-/* 
- * $Id$ 
+/*
+ * $Id$
  *
  * Copyright (C) 2001-2003 FhG Fokus
  *
@@ -20,8 +20,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * History:
@@ -49,7 +49,7 @@
 #include "../ut.h"
 
 
-/* 
+/*
  * Frees a hdr_field structure,
  * WARNING: it frees only parsed (and not name.s, body.s)
  */
@@ -135,10 +135,10 @@ void clean_hdr_field(struct hdr_field* hf)
 
 		case HDR_ACCEPTLANGUAGE_T:
 			break;
-			
+
 		case HDR_ORGANIZATION_T:
 			break;
-			
+
 		case HDR_PRIORITY_T:
 			break;
 
@@ -167,6 +167,14 @@ void clean_hdr_field(struct hdr_field* hf)
 			free_to(hf->parsed);
 			break;
 
+		case HDR_SESSIONEXPIRES_T:
+		case HDR_ACCEPTCONTACT_T:
+		case HDR_ALLOWEVENTS_T:
+		case HDR_CONTENTENCODING_T:
+		case HDR_REFERREDBY_T:
+		case HDR_REJECTCONTACT_T:
+		case HDR_REQUESTDISPOSITION_T:
+			break;
 		default:
 			LOG(L_CRIT, "BUG: clean_hdr_field: unknown header type %d\n",
 			    hf->type);
@@ -176,13 +184,13 @@ void clean_hdr_field(struct hdr_field* hf)
 }
 
 
-/* 
+/*
  * Frees a hdr_field list,
  * WARNING: frees only ->parsed and ->next*/
 void free_hdr_field_lst(struct hdr_field* hf)
 {
 	struct hdr_field* foo;
-	
+
 	while(hf) {
 		foo=hf;
 		hf=hf->next;

+ 16 - 0
parser/hf.h

@@ -87,6 +87,14 @@ enum _hdr_types_t {
 	HDR_RPID_T					       /* Remote-Party-ID header field */,
 	HDR_REFER_TO_T				       /* Refer-To header fiels */,
 	HDR_SIPIFMATCH_T                   /* SIP-If-Match header field */,
+	HDR_SESSIONEXPIRES_T                           /* Session-Expires header */,
+	HDR_ACCEPTCONTACT_T                            /* Accept-Contact header */,
+	HDR_ALLOWEVENTS_T                              /* Allow-Events header */,
+	HDR_CONTENTENCODING_T                          /* Content-Encoding header */,
+	HDR_REFERREDBY_T                               /* Referred-By header */,
+	HDR_REJECTCONTACT_T                            /* Reject-Contact header */,
+	HDR_REQUESTDISPOSITION_T                       /* Request-Disposition header */,
+
 	HDR_EOH_T				       /* End of message header */
 };
 
@@ -137,6 +145,14 @@ typedef unsigned long long hdr_flags_t;
 #define HDR_RPID_F					HDR_F_DEF(RPID)
 #define HDR_REFER_TO_F				HDR_F_DEF(REFER_TO)
 #define HDR_SIPIFMATCH_F			HDR_F_DEF(SIPIFMATCH)
+#define HDR_SESSIONEXPIRES_F			HDR_F_DEF(SESSIONEXPIRES)
+#define HDR_ACCEPTCONTACT_F			HDR_F_DEF(HDR_ACCEPTCONTACT_T)
+#define HDR_ALLOWEVENTS_F			HDR_F_DEF(HDR_ALLOWEVENTS_T)
+#define HDR_CONTENTENCODING_F			HDR_F_DEF(HDR_CONTENTENCODING_T)
+#define HDR_REFERREDBY_F			HDR_F_DEF(HDR_REFERREDBY_T)
+#define HDR_REJECTCONTACT_F			HDR_F_DEF(HDR_REJECTCONTACT_T)
+#define HDR_REQUESTDISPOSITION_F		HDR_F_DEF(HDR_REQUESTDISPOSITION_T)
+
 #define HDR_OTHER_F					HDR_F_DEF(OTHER)
 
 typedef enum _hdr_types_t hdr_types_t;

+ 32 - 5
parser/keys.h

@@ -1,5 +1,5 @@
-/* 
- * $Id$ 
+/*
+ * $Id$
  *
  * Fast 32-bit Header Field Name Parser -- keys
  *
@@ -22,8 +22,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * History:
@@ -39,6 +39,10 @@
 /*
  * a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z  :  ' ' -
  * 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 3a 20  2d
+ *
+ * Test manually/visually if dword is intended string using:
+ * awk '/^#define/ {printf("%s \"%x%x%x%x\" ... %s \n",  $3,strtonum("0x" substr($3,9,2)),strtonum("0x" substr($3,7,2)),strtonum("0x" substr($3,5,2)),strtonum("0x" substr($3,3,2)),$5)}' keys.h
+ *
  */
 
 #define _acce_ 0x65636361   /* "acce" */
@@ -115,7 +119,7 @@
 #define _ion2_ 0x206e6f69   /* "ion " */
 #define _ion1_ 0x3a6e6f69   /* "ion:" */
 
-#define _pt_d_ 0x64617470   /* "pt-d" */
+#define _pt_d_ 0x642d7470   /* "pt-d" */
 #define _ispo_ 0x6f707369   /* "ispo" */
 #define _siti_ 0x69746973   /* "siti" */
 
@@ -131,4 +135,27 @@
 #define _refe_ 0x65666572   /* "refe" */
 #define _r_to_ 0x6f742d72   /* "r-to" */
 
+#define _pt_c_ 0x632d7470   /* "pt-c" */
+#define _onta_ 0x61746e6f   /* "onta" */
+
+#define _sess_ 0x73736573   /* "sess" */
+#define _ion__ 0x2d6e6f69   /* "ion-" */
+#define _res2_ 0x20736572   /* "res " */
+#define _res1_ 0x3a736572   /* "res:" */
+
+#define _w_ev_ 0x76652d77   /* "w-ev" */
+#define _ents_ 0x73746e65   /* "ents" */
+
+#define _enco_ 0x6f636e65   /* "enco" */
+#define _ding_ 0x676e6964   /* "ding" */
+
+#define _rred_ 0x64657272   /* "rred" */
+#define __by2_ 0x2079622d   /* "-by " */
+#define __by1_ 0x3a79622d   /* "-by:" */
+
+#define _reje_ 0x656a6572   /* "reje" */
+#define _ct_c_ 0x632d7463   /* "ct-c" */
+
+#define _est__ 0x2d747365   /* "est-" */
+
 #endif /* KEYS_H */

+ 46 - 32
parser/msg_parser.c

@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * sip msg. header proxy parser 
+ * sip msg. header proxy parser
  *
  *
  * Copyright (C) 2001-2003 FhG Fokus
@@ -23,8 +23,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * History:
@@ -93,7 +93,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 	}
 
 	/* eliminate leading whitespace */
-	tmp=eat_lws_end(tmp, end); 
+	tmp=eat_lws_end(tmp, end);
 	if (tmp>=end) {
 		LOG(L_ERR, "ERROR: get_hdr_field: HF empty\n");
 		goto error;
@@ -143,8 +143,8 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 			hdr->parsed=cseq_b;
 			hdr->body.len=tmp-hdr->body.s;
 			DBG("get_hdr_field: cseq <%.*s>: <%.*s> <%.*s>\n",
-					hdr->name.len, ZSW(hdr->name.s), 
-					cseq_b->number.len, ZSW(cseq_b->number.s), 
+					hdr->name.len, ZSW(hdr->name.s),
+					cseq_b->number.len, ZSW(cseq_b->number.s),
 					cseq_b->method.len, cseq_b->method.s);
 			break;
 		case HDR_TO_T:
@@ -164,7 +164,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 			hdr->parsed=to_b;
 			hdr->body.len=tmp-hdr->body.s;
 			DBG("DEBUG: get_hdr_field: <%.*s> [%d]; uri=[%.*s] \n",
-				hdr->name.len, ZSW(hdr->name.s), 
+				hdr->name.len, ZSW(hdr->name.s),
 				hdr->body.len, to_b->uri.len,ZSW(to_b->uri.s));
 			DBG("DEBUG: to body [%.*s]\n",to_b->body.len,
 				ZSW(to_b->body.s));
@@ -208,6 +208,13 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 		case HDR_RPID_T:
 		case HDR_SIPIFMATCH_T:
 		case HDR_REFER_TO_T:
+		case HDR_SESSIONEXPIRES_T:
+		case HDR_ACCEPTCONTACT_T:
+		case HDR_ALLOWEVENTS_T:
+		case HDR_CONTENTENCODING_T:
+		case HDR_REFERREDBY_T:
+		case HDR_REJECTCONTACT_T:
+		case HDR_REQUESTDISPOSITION_T:
 		case HDR_OTHER_T:
 			/* just skip over it */
 			hdr->body.s=tmp;
@@ -273,13 +280,13 @@ int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next)
 
 	end=msg->buf+msg->len;
 	tmp=msg->unparsed;
-	
+
 	if (next) {
 		orig_flag = msg->parsed_flag;
 		msg->parsed_flag &= ~flags;
 	}else
-		orig_flag=0; 
-	
+		orig_flag=0;
+
 	DBG("parse_headers: flags=%llx\n", (unsigned long long)flags);
 	while( tmp<end && (flags & msg->parsed_flag) != flags){
 		hf=pkg_malloc(sizeof(struct hdr_field));
@@ -300,6 +307,13 @@ int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next)
 				msg->parsed_flag|=HDR_EOH_F;
 				pkg_free(hf);
 				goto skip;
+			case HDR_SESSIONEXPIRES_T:
+			case HDR_ACCEPTCONTACT_T:
+			case HDR_ALLOWEVENTS_T:
+			case HDR_CONTENTENCODING_T:
+			case HDR_REFERREDBY_T:
+			case HDR_REJECTCONTACT_T:
+			case HDR_REQUESTDISPOSITION_T:
 			case HDR_OTHER_T: /*do nothing*/
 				break;
 			case HDR_CALLID_T:
@@ -456,8 +470,8 @@ int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next)
 		}
 #ifdef EXTRA_DEBUG
 		DBG("header field type %d, name=<%.*s>, body=<%.*s>\n",
-			hf->type, 
-			hf->name.len, ZSW(hf->name.s), 
+			hf->type,
+			hf->name.len, ZSW(hf->name.s),
 			hf->body.len, ZSW(hf->body.s));
 #endif
 		tmp=rest;
@@ -541,55 +555,55 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
 	/* dump parsed data */
 	if (msg->via1){
 		DBG(" first  via: <%.*s/%.*s/%.*s> <%.*s:%.*s(%d)>",
-			msg->via1->name.len, 
-			ZSW(msg->via1->name.s), 
+			msg->via1->name.len,
+			ZSW(msg->via1->name.s),
 			msg->via1->version.len,
 			ZSW(msg->via1->version.s),
 			msg->via1->transport.len,
-			ZSW(msg->via1->transport.s), 
+			ZSW(msg->via1->transport.s),
 			msg->via1->host.len,
 			ZSW(msg->via1->host.s),
-			msg->via1->port_str.len, 
-			ZSW(msg->via1->port_str.s), 
+			msg->via1->port_str.len,
+			ZSW(msg->via1->port_str.s),
 			msg->via1->port);
-		if (msg->via1->params.s)  DBG(";<%.*s>", 
+		if (msg->via1->params.s)  DBG(";<%.*s>",
 				msg->via1->params.len, ZSW(msg->via1->params.s));
-		if (msg->via1->comment.s) 
-				DBG(" <%.*s>", 
+		if (msg->via1->comment.s)
+				DBG(" <%.*s>",
 					msg->via1->comment.len, ZSW(msg->via1->comment.s));
 		DBG ("\n");
 	}
 	if (msg->via2){
 		DBG(" first  via: <%.*s/%.*s/%.*s> <%.*s:%.*s(%d)>",
-			msg->via2->name.len, 
-			ZSW(msg->via2->name.s), 
+			msg->via2->name.len,
+			ZSW(msg->via2->name.s),
 			msg->via2->version.len,
 			ZSW(msg->via2->version.s),
-			msg->via2->transport.len, 
-			ZSW(msg->via2->transport.s), 
+			msg->via2->transport.len,
+			ZSW(msg->via2->transport.s),
 			msg->via2->host.len,
 			ZSW(msg->via2->host.s),
-			msg->via2->port_str.len, 
-			ZSW(msg->via2->port_str.s), 
+			msg->via2->port_str.len,
+			ZSW(msg->via2->port_str.s),
 			msg->via2->port);
-		if (msg->via2->params.s)  DBG(";<%.*s>", 
+		if (msg->via2->params.s)  DBG(";<%.*s>",
 				msg->via2->params.len, ZSW(msg->via2->params.s));
-		if (msg->via2->comment.s) DBG(" <%.*s>", 
+		if (msg->via2->comment.s) DBG(" <%.*s>",
 				msg->via2->comment.len, ZSW(msg->via2->comment.s));
 		DBG ("\n");
 	}
 #endif
-	
+
 
 #ifdef EXTRA_DEBUG
 	DBG("exiting parse_msg\n");
 #endif
 
 	return 0;
-	
+
 error:
 	/* more debugging, msg->orig is/should be null terminated*/
-	LOG(L_ERR, "ERROR: parse_msg: message=<%.*s>\n", 
+	LOG(L_ERR, "ERROR: parse_msg: message=<%.*s>\n",
 			(int)msg->len, ZSW(msg->buf));
 	return -1;
 }
@@ -619,7 +633,7 @@ void free_sip_msg(struct sip_msg* msg)
 	if (msg->reply_lump)   free_reply_lump(msg->reply_lump);
 	/* don't free anymore -- now a pointer to a static buffer */
 #	ifdef DYN_BUF
-	pkg_free(msg->buf); 
+	pkg_free(msg->buf);
 #	endif
 }
 

+ 39 - 25
parser/parse_hname2.c

@@ -1,5 +1,5 @@
-/* 
- * $Id$ 
+/*
+ * $Id$
  *
  * Fast 32-bit Header Field Name Parser
  *
@@ -22,8 +22,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * History:
@@ -49,14 +49,14 @@
 static inline char* skip_ws(char* p, unsigned int size)
 {
 	char* end;
-	
+
 	end = p + size;
 	for(; p < end; p++) {
 		if ((*p != ' ') && (*p != '\t')) return p;
 	}
 	return p;
 }
-	
+
 /*
  * Parser macros
  */
@@ -65,7 +65,7 @@ static inline char* skip_ws(char* p, unsigned int size)
 #include "case_to.h"       /* To */
 #include "case_cseq.h"     /* CSeq */
 #include "case_call.h"     /* Call-ID */
-#include "case_cont.h"     /* Contact, Content-Type, Content-Length, Content-Purpose, 
+#include "case_cont.h"     /* Contact, Content-Type, Content-Length, Content-Purpose,
 			    * Content-Action, Content-Disposition */
 #include "case_rout.h"     /* Route */
 #include "case_max.h"      /* Max-Forwards */
@@ -86,6 +86,8 @@ static inline char* skip_ws(char* p, unsigned int size)
 #include "case_dive.h"     /* Diversion */
 #include "case_remo.h"     /* Remote-Party-ID */
 #include "case_refe.h"     /* Refer-To */
+#include "case_sess.h"     /* Session-Expires */
+#include "case_reje.h"     /* Reject-Contact */
 
 
 #define READ(val) \
@@ -110,7 +112,7 @@ static inline char* skip_ws(char* p, unsigned int size)
 	case _allo_: allo_CASE; \
 	case _unsu_: unsu_CASE; \
         case _even_: even_CASE; \
-        case _sip_: sip_CASE; \
+        case _sip_ : sip_CASE;  \
         case _acce_: acce_CASE; \
         case _orga_: orga_CASE; \
         case _prio_: prio_CASE; \
@@ -118,7 +120,10 @@ static inline char* skip_ws(char* p, unsigned int size)
         case _user_: user_CASE; \
         case _dive_: dive_CASE; \
         case _remo_: remo_CASE; \
-        case _refe_: refe_CASE;
+        case _refe_: refe_CASE; \
+	case _sess_: sess_CASE; \
+	case _reje_: reje_CASE; \
+
 
 
 #define PARSE_COMPACT(id)          \
@@ -132,7 +137,7 @@ static inline char* skip_ws(char* p, unsigned int size)
 	        hdr->type = id;    \
 	        hdr->name.len = 1; \
 	        return (p + 2);    \
-        }                            
+        }
 
 
 char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
@@ -155,19 +160,19 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
 
 	default:
 		switch(LOWER_BYTE(*p)) {
-		case 't':                           
-			switch(LOWER_BYTE(*(p + 1))) {          
-			case 'o':                   
-			case ' ':                   
-				hdr->type = HDR_TO_T; 
-				p += 2;             
-				goto dc_end;        
-				
-			case ':':                   
-				hdr->type = HDR_TO_T; 
-				hdr->name.len = 1;  
-				return (p + 2);     
-			}                           
+		case 't':
+			switch(LOWER_BYTE(*(p + 1))) {
+			case 'o':
+			case ' ':
+				hdr->type = HDR_TO_T;
+				p += 2;
+				goto dc_end;
+
+			case ':':
+				hdr->type = HDR_TO_T;
+				hdr->name.len = 1;
+				return (p + 2);
+			}
 			break;
 
 		case 'v': PARSE_COMPACT(HDR_VIA_T);           break;
@@ -178,6 +183,15 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
 		case 'k': PARSE_COMPACT(HDR_SUPPORTED_T);     break;
 		case 'c': PARSE_COMPACT(HDR_CONTENTTYPE_T);   break;
 		case 'o': PARSE_COMPACT(HDR_EVENT_T);         break;
+		case 'x': PARSE_COMPACT(HDR_SESSIONEXPIRES_T);break;
+		case 'a': PARSE_COMPACT(HDR_ACCEPTCONTACT_T); break;
+		case 'u': PARSE_COMPACT(HDR_ALLOWEVENTS_T);   break;
+		case 'e': PARSE_COMPACT(HDR_CONTENTENCODING_T); break;
+		case 'b': PARSE_COMPACT(HDR_REFERREDBY_T);    break;
+		case 'j': PARSE_COMPACT(HDR_REJECTCONTACT_T); break;
+		case 'd': PARSE_COMPACT(HDR_REQUESTDISPOSITION_T); break;
+		case 's': PARSE_COMPACT(HDR_SUBJECT_T);       break;
+		case 'r': PARSE_COMPACT(HDR_REFER_TO_T);      break;
 		}
 		goto other;
         }
@@ -185,7 +199,7 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
 	     /* Double colon hasn't been found yet */
  dc_end:
        	p = skip_ws(p, end - p);
-	if (*p != ':') {   
+	if (*p != ':') {
 	        goto other;
 	} else {
 		hdr->name.len = p - hdr->name.s;
@@ -193,7 +207,7 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
 	}
 
 	     /* Unknown header type */
- other:    
+ other:
 	p = q_memchr(p, ':', end - p);
 	if (!p) {        /* No double colon found, error.. */
 		hdr->type = HDR_ERROR_T;