Browse code

Add support for Server header field, since it is necessary in one place (mediaproxy module) already and will also be used in another new module.

Submitted by: Valentin Nechaev <netch@portaone.com>

Maxim Sobolev authored on 20/12/2004 18:52:54
Showing 7 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,45 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ * Subject Header Field Name Parsing Macros
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
+
30
+
31
+#ifndef CASE_SERV_H
32
+#define CASE_SERV_H
33
+
34
+
35
+#define serv_CASE                   \
36
+    p += 4;                         \
37
+    if (LOWER_BYTE(*p) == 'e' && LOWER_BYTE(p[1]) == 'r') {   \
38
+            hdr->type = HDR_SERVER; \
39
+            p+= 2;                  \
40
+	    goto dc_end;            \
41
+    }                               \
42
+    goto other;
43
+
44
+
45
+#endif /* CASE_SERV_H */
... ...
@@ -130,10 +130,10 @@ void clean_hdr_field(struct hdr_field* hf)
130 130
 
131 131
 		case HDR_ACCEPTLANGUAGE:
132 132
 			break;
133
-			
133
+
134 134
 		case HDR_ORGANIZATION:
135 135
 			break;
136
-			
136
+
137 137
 		case HDR_PRIORITY:
138 138
 			break;
139 139
 
... ...
@@ -158,6 +158,9 @@ void clean_hdr_field(struct hdr_field* hf)
158 158
 			free_to(hf->parsed);
159 159
 			break;
160 160
 
161
+		case HDR_SERVER:
162
+			break;
163
+
161 164
 		default:
162 165
 			LOG(L_CRIT, "BUG: clean_hdr_field: unknown header type %d\n",
163 166
 			    hf->type);
... ...
@@ -73,7 +73,8 @@
73 73
 #define HDR_CONTENTDISPOSITION (1 << 27)  /* Content-Disposition hdr field */
74 74
 #define HDR_DIVERSION          (1 << 28)  /* Diversion header field */
75 75
 #define HDR_RPID               (1 << 29)  /* Remote-Party-ID header field */
76
-#define HDR_OTHER              (1 << 30)  /* Some other header field */
76
+#define HDR_SERVER             (1 << 30)  /* Server header field */
77
+#define HDR_OTHER              (1 << 31)  /* Some other header field */
77 78
 
78 79
 
79 80
 /* returns true if the header links allocated memory on parse field */
... ...
@@ -116,6 +116,8 @@
116 116
 #define _ispo_ 0x6f707369   /* "ispo" */
117 117
 #define _siti_ 0x69746973   /* "siti" */
118 118
 
119
+#define _serv_ 0x76726573   /* "serv" */
120
+
119 121
 #define _dive_ 0x65766964   /* "dive" */
120 122
 #define _rsio_ 0x6f697372   /* "rsio" */
121 123
 
... ...
@@ -204,6 +204,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
204 204
 	        case HDR_ACCEPTDISPOSITION:
205 205
 	        case HDR_DIVERSION:
206 206
 	        case HDR_RPID:
207
+	        case HDR_SERVER:
207 208
 		case HDR_OTHER:
208 209
 			/* just skip over it */
209 210
 			hdr->body.s=tmp;
... ...
@@ -407,6 +408,10 @@ int parse_headers(struct sip_msg* msg, int flags, int next)
407 408
 				if (msg->rpid==0) msg->rpid = hf;
408 409
 				msg->parsed_flag|=HDR_RPID;
409 410
 				break;
411
+		        case HDR_SERVER:
412
+				if (msg->server==0) msg->server = hf;
413
+				msg->parsed_flag|=HDR_SERVER;
414
+				break;
410 415
 			case HDR_VIA:
411 416
 				msg->parsed_flag|=HDR_VIA;
412 417
 				DBG("parse_headers: Via found, flags=%d\n", flags);
... ...
@@ -193,6 +193,7 @@ struct sip_msg {
193 193
 	struct hdr_field* accept_disposition;
194 194
 	struct hdr_field* diversion;
195 195
 	struct hdr_field* rpid;
196
+	struct hdr_field* server;
196 197
 
197 198
 	char* eoh;        /* pointer to the end of header (if found) or null */
198 199
 	char* unparsed;   /* here we stopped parsing*/
... ...
@@ -84,6 +84,7 @@ static inline char* skip_ws(char* p, unsigned int size)
84 84
 #include "case_supp.h"     /* Supported */
85 85
 #include "case_dive.h"     /* Diversion */
86 86
 #include "case_remo.h"     /* Remote-Party-ID */
87
+#include "case_serv.h"     /* Server */
87 88
 
88 89
 
89 90
 #define READ(val) \
... ...
@@ -114,7 +115,8 @@ static inline char* skip_ws(char* p, unsigned int size)
114 115
         case _subj_: subj_CASE; \
115 116
         case _user_: user_CASE; \
116 117
         case _dive_: dive_CASE; \
117
-        case _remo_: remo_CASE;
118
+        case _remo_: remo_CASE; \
119
+        case _serv_: serv_CASE;
118 120
 
119 121
 
120 122
 #define PARSE_COMPACT(id)          \