Просмотр исходного кода

- Accept header field is now parsed too (needed in pa)

Jan Janak 22 лет назад
Родитель
Сommit
71be0c4a86
6 измененных файлов с 48 добавлено и 104 удалено
  1. 0 1
      parser/hf.c
  2. 3 1
      parser/hf.h
  3. 34 101
      parser/keys.h
  4. 6 0
      parser/msg_parser.c
  5. 1 0
      parser/msg_parser.h
  6. 4 1
      parser/parse_hname2.c

+ 0 - 1
parser/hf.c

@@ -128,4 +128,3 @@ void dump_hdr_field( struct hdr_field* hf )
 		hf->body.len, ZSW(hf->body.s),
 		hf->parsed, hf->next );
 }
-

+ 3 - 1
parser/hf.h

@@ -28,6 +28,7 @@
  * ---------
  * 2003-02-28 scratchpad compatibility abandoned (jiri)
  * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
+ * 2003-05-01 HDR_ACCEPT added (janakj)
  */
 
 
@@ -64,7 +65,8 @@
 #define HDR_UNSUPPORTED   (1 << 19)  /* Unsupported header field */
 #define HDR_ALLOW         (1 << 20)  /* Allow header field */
 #define HDR_EVENT         (1 << 21)  /* Event header field */
-#define HDR_OTHER         (1 << 22)  /* Some other header field */
+#define HDR_ACCEPT        (1 << 22)  /* Accept header field */
+#define HDR_OTHER         (1 << 23)  /* Some other header field */
 
 
 /* 

+ 34 - 101
parser/keys.h

@@ -1,156 +1,89 @@
+/* 
+ * $Id$ 
+ *
+ * Fast 32-bit Header Field Name Parser -- keys
+ *
+ * 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
+ *
+ * History:
+ * --------
+ * 2003-05-01 _acce_ macro added (janakj)
+ */
+
 #ifndef KEYS_H
 #define KEYS_H
 
-
+#define _acce_ 0x65636361   /* "acce" */
 #define _allo_ 0x6f6c6c61   /* "allo" */
-#define _allo_hash ((unsigned char)((_allo_ >> 13) ^ _allo_))
-
 #define _auth_ 0x68747561   /* "auth" */
-#define _auth_hash ((unsigned char)((_auth_ >> 13) ^ _allo_))
-
 #define _oriz_ 0x7a69726f   /* "oriz" */
-#define _oriz_hash ((unsigned char)((_oriz_ >> 13) ^ _oriz_))
-
 #define _atio_ 0x6f697461   /* "atio" */
-#define _atio_hash ((unsigned char)((_atio_ >> 13) ^ _atio_))
-
 #define _call_ 0x6c6c6163   /* "call" */
-#define _call_hash ((unsigned char)((_call_ >> 13) ^ _call_))
-
 #define __id2_ 0x2064692d   /* "-id " */
-#define __id2_hash ((unsigned char)((__id2_ >> 13) ^ __id2_))
-
 #define __id1_ 0x3a64692d   /* "-id:" */
-#define __id1_hash ((unsigned char)((__id1_ >> 13) ^ __id1_))
-
 #define _cont_ 0x746e6f63   /* "cont" */
-#define _cont_hash ((unsigned char)((_cont_ >> 13) ^ _cont_))
-
 #define _act2_ 0x20746361   /* "act " */
-#define _act2_hash ((unsigned char)((_act2_ >> 13) ^ _act2_))
-
 #define _act1_ 0x3a746361   /* "act:" */
-#define _act1_hash ((unsigned char)((_act1_ >> 13) ^ _act1_))
-
 #define _ent__ 0x2d746e65   /* "ent-" */
-#define _ent__hash ((unsigned char)((_ent__ >> 13) ^ _ent__))
-
 #define _leng_ 0x676e656c   /* "leng" */
-#define _leng_hash ((unsigned char)((_leng_ >> 13) ^ _leng_))
-
 #define _th12_ 0x203a6874   /* "th: " */
-#define _th12_hash ((unsigned char)((_th12_ >> 13) ^ _th12_))
-
 #define _type_ 0x65707974   /* "type" */
-#define _type_hash ((unsigned char)((_type_ >> 13) ^ _type_))
-
 #define _cseq_ 0x71657363   /* "cseq" */
-#define _cseq_hash ((unsigned char)((_cseq_ >> 13) ^ _cseq_))
-
 #define _expi_ 0x69707865   /* "expi" */
-#define _expi_hash ((unsigned char)((_expi_ >> 13) ^ _expi_))
-
 #define _res2_ 0x20736572   /* "res " */
-#define _res2_hash ((unsigned char)((_res2_ >> 13) ^ _res2_))
-
 #define _res1_ 0x3a736572   /* "res:" */
-#define _res1_hash ((unsigned char)((_res1_ >> 13) ^ _res1_))
-
 #define _from_ 0x6d6f7266   /* "from" */
-#define _from_hash ((unsigned char)((_from_ >> 13) ^ _from_))
-
 #define _max__ 0x2d78616d   /* "max-" */
-#define _max__hash ((unsigned char)((_max__ >> 13) ^ _max__))
-
 #define _forw_ 0x77726f66   /* "forw" */
-#define _forw_hash ((unsigned char)((_forw_ >> 13) ^ _forw_))
-
 #define _ards_ 0x73647261   /* "ards" */
-#define _ards_hash ((unsigned char)((_ards_ >> 13) ^ _ards_))
-
 #define _prox_ 0x786f7270   /* "prox" */
-#define _prox_hash ((unsigned char)((_prox_ >> 13) ^ _prox_))
-
 #define _y_au_ 0x75612d79   /* "y-au" */
-#define _y_au_hash ((unsigned char)((_y_au_ >> 13) ^ _y_au_))
-
 #define _thor_ 0x726f6874   /* "thor" */
-#define _thor_hash ((unsigned char)((_thor_ >> 13) ^ _thor_))
-
 #define _izat_ 0x74617a69   /* "izat" */
-#define _izat_hash ((unsigned char)((_izat_ >> 13) ^ _izat_))
-
 #define _ion2_ 0x206e6f69   /* "ion " */
-#define _ion2_hash ((unsigned char)((_ion2_ >> 13) ^ _ion2_))
-
 #define _ion1_ 0x3a6e6f69   /* "ion:" */
-#define _ion1_hash ((unsigned char)((_ion1_ >> 13) ^ _ion1_))
-
 #define _y_re_ 0x65722d79   /* "y-re" */
-#define _y_re_hash ((unsigned char)((_y_re_ >> 13) ^ _y_re_))
-
 #define _quir_ 0x72697571   /* "quir" */
-#define _quir_hash ((unsigned char)((_quir_ >> 13) ^ _quir_))
-
 #define _reco_ 0x6f636572   /* "reco" */
-#define _reco_hash ((unsigned char)((_reco_ >> 13) ^ _reco_))
-
 #define _rd_r_ 0x722d6472   /* "rd-r" */
-#define _rd_r_hash ((unsigned char)((_rd_r_ >> 13) ^ _rd_r_))
-
 #define _oute_ 0x6574756f   /* "oute" */
-#define _oute_hash ((unsigned char)((_oute_ >> 13) ^ _oute_))
-
 #define _requ_ 0x75716572   /* "requ" */
-#define _requ_hash ((unsigned char)((_requ_ >> 13) ^ _requ_))
-
 #define _ire2_ 0x20657269   /* "ire " */
-#define _ire2_hash ((unsigned char)((_ire2_ >> 13) ^ _ire2_))
-
 #define _ire1_ 0x3a657269   /* "ire:" */
-#define _ire1_hash ((unsigned char)((_ire1_ >> 13) ^ _ire1_))
-
 #define _rout_ 0x74756f72   /* "rout" */
-#define _rout_hash ((unsigned char)((_rout_ >> 13) ^ _rout_))
-
 #define _supp_ 0x70707573   /* "supp" */
-#define _supp_hash ((unsigned char)((_supp_ >> 13) ^ _supp_))
-
 #define _orte_ 0x6574726f   /* "orte" */
-#define _orte_hash ((unsigned char)((_orte_ >> 13) ^ _orte_))
-
 #define _to12_ 0x203a6f74   /* "to: " */
-#define _to12_hash ((unsigned char)((_to12_ >> 13) ^ _to12_))
-
 #define _unsu_ 0x75736e75   /* "unsu" */
-#define _unsu_hash ((unsigned char)((_unsu_ >> 13) ^ _unsu_))
-
 #define _ppor_ 0x726f7070   /* "ppor" */
-#define _ppor_hash ((unsigned char)((_ppor_ >> 13) ^ _ppor_))
-
 #define _ted2_ 0x20646574   /* "ted " */
-#define _ted2_hash ((unsigned char)((_ted2_ >> 13) ^ _ted2_))
-
 #define _ted1_ 0x3a646574   /* "ted:" */
-#define _ted1_hash ((unsigned char)((_ted1_ >> 13) ^ _ted1_))
-
 #define _via2_ 0x20616976   /* "via " */
-#define _via2_hash ((unsigned char)((_via2_ >> 13) ^ _via2_))
-
 #define _via1_ 0x3a616976   /* "via:" */
-#define _via1_hash ((unsigned char)((_via1_ >> 13) ^ _via1_))
-
 #define _www__ 0x2d777777   /* "www-" */
-#define _www__hash ((unsigned char)((_www__ >> 13) ^ _www__))
-
 #define _enti_ 0x69746e65   /* "enti" */
-#define _enti_hash ((unsigned char)((_enti_ >> 13) ^ _enti_))
-
 #define _cate_ 0x65746163   /* "cate" */
-#define _cate_hash ((unsigned char)((_cate_ >> 13) ^ _cate_))
-
 #define _even_ 0x6e657665   /* "even" */
-#define _even_hash ((unsigned char)((_even_ >> 13) ^ _even_))
 
 #endif /* KEYS_H */
-

+ 6 - 0
parser/msg_parser.c

@@ -34,6 +34,7 @@
  *  2003-01-27  next baby-step to removing ZT - PRESERVE_ZT (jiri)
  *  2003-03-31  removed msg->repl_add_rm (andrei)
  *  2003-04-26 ZSW (jiri)
+ *  2003-05-01  parser extended to support Accept header field (janakj)
  */
 
 
@@ -195,6 +196,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 		case HDR_UNSUPPORTED:
 		case HDR_ALLOW:
 		case HDR_EVENT:
+	        case HDR_ACCEPT:
 		case HDR_OTHER:
 			/* just skip over it */
 			hdr->body.s=tmp;
@@ -366,6 +368,10 @@ int parse_headers(struct sip_msg* msg, int flags, int next)
 				if (msg->allow==0) msg->event = hf;
 				msg->parsed_flag|=HDR_EVENT;
 				break;
+		        case HDR_ACCEPT:
+				if (msg->accept==0) msg->accept = hf;
+				msg->parsed_flag|=HDR_ACCEPT;
+				break;
 			case HDR_VIA:
 				msg->parsed_flag|=HDR_VIA;
 				DBG("parse_headers: Via found, flags=%d\n", flags);

+ 1 - 0
parser/msg_parser.h

@@ -176,6 +176,7 @@ struct sip_msg {
 	struct hdr_field* unsupported;
 	struct hdr_field* allow;
 	struct hdr_field* event;
+	struct hdr_field* accept;
 
 	char* eoh;        /* pointer to the end of header (if found) or null */
 	char* unparsed;   /* here we stopped parsing*/

+ 4 - 1
parser/parse_hname2.c

@@ -30,6 +30,7 @@
  * --------
  * 2003-02-28 scratchpad compatibility abandoned (jiri)
  * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
+ * 2003-05-01 added support for Accept HF (janakj)
  */
 
 
@@ -77,6 +78,7 @@ static inline char* skip_ws(char* p, unsigned int size)
 #include "case_supp.h"     /* Supported */
 #include "case_www.h"      /* WWW-Authenticate */
 #include "case_even.h"     /* Event */
+#include "case_acce.h"     /* Accept */
 
 
 #define READ(val) \
@@ -102,7 +104,8 @@ static inline char* skip_ws(char* p, unsigned int size)
 	case _requ_: requ_CASE; \
 	case _supp_: supp_CASE; \
         case _www__: www_CASE;  \
-        case _even_: even_CASE;
+        case _even_: even_CASE; \
+        case _acce_: acce_CASE;
 
 
 #define PARSE_COMPACT(id)          \