Browse code

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

Jan Janak authored on 02/05/2003 08:36:15
Showing 6 changed files
... ...
@@ -128,4 +128,3 @@ void dump_hdr_field( struct hdr_field* hf )
128 128
 		hf->body.len, ZSW(hf->body.s),
129 129
 		hf->parsed, hf->next );
130 130
 }
131
-
... ...
@@ -28,6 +28,7 @@
28 28
  * ---------
29 29
  * 2003-02-28 scratchpad compatibility abandoned (jiri)
30 30
  * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
31
+ * 2003-05-01 HDR_ACCEPT added (janakj)
31 32
  */
32 33
 
33 34
 
... ...
@@ -64,7 +65,8 @@
64 64
 #define HDR_UNSUPPORTED   (1 << 19)  /* Unsupported header field */
65 65
 #define HDR_ALLOW         (1 << 20)  /* Allow header field */
66 66
 #define HDR_EVENT         (1 << 21)  /* Event header field */
67
-#define HDR_OTHER         (1 << 22)  /* Some other header field */
67
+#define HDR_ACCEPT        (1 << 22)  /* Accept header field */
68
+#define HDR_OTHER         (1 << 23)  /* Some other header field */
68 69
 
69 70
 
70 71
 /* 
... ...
@@ -1,156 +1,89 @@
1
+/* 
2
+ * $Id$ 
3
+ *
4
+ * Fast 32-bit Header Field Name Parser -- keys
5
+ *
6
+ * Copyright (C) 2001-2003 Fhg Fokus
7
+ *
8
+ * This file is part of ser, a free SIP server.
9
+ *
10
+ * ser is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version
14
+ *
15
+ * For a license to use the ser software under conditions
16
+ * other than those described here, or to purchase support for this
17
+ * software, please contact iptel.org by e-mail at the following addresses:
18
+ *    info@iptel.org
19
+ *
20
+ * ser is distributed in the hope that it will be useful,
21
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
+ * GNU General Public License for more details.
24
+ *
25
+ * You should have received a copy of the GNU General Public License 
26
+ * along with this program; if not, write to the Free Software 
27
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
+ *
29
+ * History:
30
+ * --------
31
+ * 2003-05-01 _acce_ macro added (janakj)
32
+ */
33
+
1 34
 #ifndef KEYS_H
2 35
 #define KEYS_H
3 36
 
4
-
37
+#define _acce_ 0x65636361   /* "acce" */
5 38
 #define _allo_ 0x6f6c6c61   /* "allo" */
6
-#define _allo_hash ((unsigned char)((_allo_ >> 13) ^ _allo_))
7
-
8 39
 #define _auth_ 0x68747561   /* "auth" */
9
-#define _auth_hash ((unsigned char)((_auth_ >> 13) ^ _allo_))
10
-
11 40
 #define _oriz_ 0x7a69726f   /* "oriz" */
12
-#define _oriz_hash ((unsigned char)((_oriz_ >> 13) ^ _oriz_))
13
-
14 41
 #define _atio_ 0x6f697461   /* "atio" */
15
-#define _atio_hash ((unsigned char)((_atio_ >> 13) ^ _atio_))
16
-
17 42
 #define _call_ 0x6c6c6163   /* "call" */
18
-#define _call_hash ((unsigned char)((_call_ >> 13) ^ _call_))
19
-
20 43
 #define __id2_ 0x2064692d   /* "-id " */
21
-#define __id2_hash ((unsigned char)((__id2_ >> 13) ^ __id2_))
22
-
23 44
 #define __id1_ 0x3a64692d   /* "-id:" */
24
-#define __id1_hash ((unsigned char)((__id1_ >> 13) ^ __id1_))
25
-
26 45
 #define _cont_ 0x746e6f63   /* "cont" */
27
-#define _cont_hash ((unsigned char)((_cont_ >> 13) ^ _cont_))
28
-
29 46
 #define _act2_ 0x20746361   /* "act " */
30
-#define _act2_hash ((unsigned char)((_act2_ >> 13) ^ _act2_))
31
-
32 47
 #define _act1_ 0x3a746361   /* "act:" */
33
-#define _act1_hash ((unsigned char)((_act1_ >> 13) ^ _act1_))
34
-
35 48
 #define _ent__ 0x2d746e65   /* "ent-" */
36
-#define _ent__hash ((unsigned char)((_ent__ >> 13) ^ _ent__))
37
-
38 49
 #define _leng_ 0x676e656c   /* "leng" */
39
-#define _leng_hash ((unsigned char)((_leng_ >> 13) ^ _leng_))
40
-
41 50
 #define _th12_ 0x203a6874   /* "th: " */
42
-#define _th12_hash ((unsigned char)((_th12_ >> 13) ^ _th12_))
43
-
44 51
 #define _type_ 0x65707974   /* "type" */
45
-#define _type_hash ((unsigned char)((_type_ >> 13) ^ _type_))
46
-
47 52
 #define _cseq_ 0x71657363   /* "cseq" */
48
-#define _cseq_hash ((unsigned char)((_cseq_ >> 13) ^ _cseq_))
49
-
50 53
 #define _expi_ 0x69707865   /* "expi" */
51
-#define _expi_hash ((unsigned char)((_expi_ >> 13) ^ _expi_))
52
-
53 54
 #define _res2_ 0x20736572   /* "res " */
54
-#define _res2_hash ((unsigned char)((_res2_ >> 13) ^ _res2_))
55
-
56 55
 #define _res1_ 0x3a736572   /* "res:" */
57
-#define _res1_hash ((unsigned char)((_res1_ >> 13) ^ _res1_))
58
-
59 56
 #define _from_ 0x6d6f7266   /* "from" */
60
-#define _from_hash ((unsigned char)((_from_ >> 13) ^ _from_))
61
-
62 57
 #define _max__ 0x2d78616d   /* "max-" */
63
-#define _max__hash ((unsigned char)((_max__ >> 13) ^ _max__))
64
-
65 58
 #define _forw_ 0x77726f66   /* "forw" */
66
-#define _forw_hash ((unsigned char)((_forw_ >> 13) ^ _forw_))
67
-
68 59
 #define _ards_ 0x73647261   /* "ards" */
69
-#define _ards_hash ((unsigned char)((_ards_ >> 13) ^ _ards_))
70
-
71 60
 #define _prox_ 0x786f7270   /* "prox" */
72
-#define _prox_hash ((unsigned char)((_prox_ >> 13) ^ _prox_))
73
-
74 61
 #define _y_au_ 0x75612d79   /* "y-au" */
75
-#define _y_au_hash ((unsigned char)((_y_au_ >> 13) ^ _y_au_))
76
-
77 62
 #define _thor_ 0x726f6874   /* "thor" */
78
-#define _thor_hash ((unsigned char)((_thor_ >> 13) ^ _thor_))
79
-
80 63
 #define _izat_ 0x74617a69   /* "izat" */
81
-#define _izat_hash ((unsigned char)((_izat_ >> 13) ^ _izat_))
82
-
83 64
 #define _ion2_ 0x206e6f69   /* "ion " */
84
-#define _ion2_hash ((unsigned char)((_ion2_ >> 13) ^ _ion2_))
85
-
86 65
 #define _ion1_ 0x3a6e6f69   /* "ion:" */
87
-#define _ion1_hash ((unsigned char)((_ion1_ >> 13) ^ _ion1_))
88
-
89 66
 #define _y_re_ 0x65722d79   /* "y-re" */
90
-#define _y_re_hash ((unsigned char)((_y_re_ >> 13) ^ _y_re_))
91
-
92 67
 #define _quir_ 0x72697571   /* "quir" */
93
-#define _quir_hash ((unsigned char)((_quir_ >> 13) ^ _quir_))
94
-
95 68
 #define _reco_ 0x6f636572   /* "reco" */
96
-#define _reco_hash ((unsigned char)((_reco_ >> 13) ^ _reco_))
97
-
98 69
 #define _rd_r_ 0x722d6472   /* "rd-r" */
99
-#define _rd_r_hash ((unsigned char)((_rd_r_ >> 13) ^ _rd_r_))
100
-
101 70
 #define _oute_ 0x6574756f   /* "oute" */
102
-#define _oute_hash ((unsigned char)((_oute_ >> 13) ^ _oute_))
103
-
104 71
 #define _requ_ 0x75716572   /* "requ" */
105
-#define _requ_hash ((unsigned char)((_requ_ >> 13) ^ _requ_))
106
-
107 72
 #define _ire2_ 0x20657269   /* "ire " */
108
-#define _ire2_hash ((unsigned char)((_ire2_ >> 13) ^ _ire2_))
109
-
110 73
 #define _ire1_ 0x3a657269   /* "ire:" */
111
-#define _ire1_hash ((unsigned char)((_ire1_ >> 13) ^ _ire1_))
112
-
113 74
 #define _rout_ 0x74756f72   /* "rout" */
114
-#define _rout_hash ((unsigned char)((_rout_ >> 13) ^ _rout_))
115
-
116 75
 #define _supp_ 0x70707573   /* "supp" */
117
-#define _supp_hash ((unsigned char)((_supp_ >> 13) ^ _supp_))
118
-
119 76
 #define _orte_ 0x6574726f   /* "orte" */
120
-#define _orte_hash ((unsigned char)((_orte_ >> 13) ^ _orte_))
121
-
122 77
 #define _to12_ 0x203a6f74   /* "to: " */
123
-#define _to12_hash ((unsigned char)((_to12_ >> 13) ^ _to12_))
124
-
125 78
 #define _unsu_ 0x75736e75   /* "unsu" */
126
-#define _unsu_hash ((unsigned char)((_unsu_ >> 13) ^ _unsu_))
127
-
128 79
 #define _ppor_ 0x726f7070   /* "ppor" */
129
-#define _ppor_hash ((unsigned char)((_ppor_ >> 13) ^ _ppor_))
130
-
131 80
 #define _ted2_ 0x20646574   /* "ted " */
132
-#define _ted2_hash ((unsigned char)((_ted2_ >> 13) ^ _ted2_))
133
-
134 81
 #define _ted1_ 0x3a646574   /* "ted:" */
135
-#define _ted1_hash ((unsigned char)((_ted1_ >> 13) ^ _ted1_))
136
-
137 82
 #define _via2_ 0x20616976   /* "via " */
138
-#define _via2_hash ((unsigned char)((_via2_ >> 13) ^ _via2_))
139
-
140 83
 #define _via1_ 0x3a616976   /* "via:" */
141
-#define _via1_hash ((unsigned char)((_via1_ >> 13) ^ _via1_))
142
-
143 84
 #define _www__ 0x2d777777   /* "www-" */
144
-#define _www__hash ((unsigned char)((_www__ >> 13) ^ _www__))
145
-
146 85
 #define _enti_ 0x69746e65   /* "enti" */
147
-#define _enti_hash ((unsigned char)((_enti_ >> 13) ^ _enti_))
148
-
149 86
 #define _cate_ 0x65746163   /* "cate" */
150
-#define _cate_hash ((unsigned char)((_cate_ >> 13) ^ _cate_))
151
-
152 87
 #define _even_ 0x6e657665   /* "even" */
153
-#define _even_hash ((unsigned char)((_even_ >> 13) ^ _even_))
154 88
 
155 89
 #endif /* KEYS_H */
156
-
... ...
@@ -34,6 +34,7 @@
34 34
  *  2003-01-27  next baby-step to removing ZT - PRESERVE_ZT (jiri)
35 35
  *  2003-03-31  removed msg->repl_add_rm (andrei)
36 36
  *  2003-04-26 ZSW (jiri)
37
+ *  2003-05-01  parser extended to support Accept header field (janakj)
37 38
  */
38 39
 
39 40
 
... ...
@@ -195,6 +196,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
195 195
 		case HDR_UNSUPPORTED:
196 196
 		case HDR_ALLOW:
197 197
 		case HDR_EVENT:
198
+	        case HDR_ACCEPT:
198 199
 		case HDR_OTHER:
199 200
 			/* just skip over it */
200 201
 			hdr->body.s=tmp;
... ...
@@ -366,6 +368,10 @@ int parse_headers(struct sip_msg* msg, int flags, int next)
366 366
 				if (msg->allow==0) msg->event = hf;
367 367
 				msg->parsed_flag|=HDR_EVENT;
368 368
 				break;
369
+		        case HDR_ACCEPT:
370
+				if (msg->accept==0) msg->accept = hf;
371
+				msg->parsed_flag|=HDR_ACCEPT;
372
+				break;
369 373
 			case HDR_VIA:
370 374
 				msg->parsed_flag|=HDR_VIA;
371 375
 				DBG("parse_headers: Via found, flags=%d\n", flags);
... ...
@@ -176,6 +176,7 @@ struct sip_msg {
176 176
 	struct hdr_field* unsupported;
177 177
 	struct hdr_field* allow;
178 178
 	struct hdr_field* event;
179
+	struct hdr_field* accept;
179 180
 
180 181
 	char* eoh;        /* pointer to the end of header (if found) or null */
181 182
 	char* unparsed;   /* here we stopped parsing*/
... ...
@@ -30,6 +30,7 @@
30 30
  * --------
31 31
  * 2003-02-28 scratchpad compatibility abandoned (jiri)
32 32
  * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
33
+ * 2003-05-01 added support for Accept HF (janakj)
33 34
  */
34 35
 
35 36
 
... ...
@@ -77,6 +78,7 @@ static inline char* skip_ws(char* p, unsigned int size)
77 77
 #include "case_supp.h"     /* Supported */
78 78
 #include "case_www.h"      /* WWW-Authenticate */
79 79
 #include "case_even.h"     /* Event */
80
+#include "case_acce.h"     /* Accept */
80 81
 
81 82
 
82 83
 #define READ(val) \
... ...
@@ -102,7 +104,8 @@ static inline char* skip_ws(char* p, unsigned int size)
102 102
 	case _requ_: requ_CASE; \
103 103
 	case _supp_: supp_CASE; \
104 104
         case _www__: www_CASE;  \
105
-        case _even_: even_CASE;
105
+        case _even_: even_CASE; \
106
+        case _acce_: acce_CASE;
106 107
 
107 108
 
108 109
 #define PARSE_COMPACT(id)          \