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 @@
0
+/*
1
+ * $Id$
2
+ *
3
+ * Subject Header Field Name Parsing Macros
4
+ *
5
+ * Copyright (C) 2001-2003 Fhg Fokus
6
+ *
7
+ * This file is part of ser, a free SIP server.
8
+ *
9
+ * ser is free software; you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation; either version 2 of the License, or
12
+ * (at your option) any later version
13
+ *
14
+ * For a license to use the ser software under conditions
15
+ * other than those described here, or to purchase support for this
16
+ * software, please contact iptel.org by e-mail at the following addresses:
17
+ *    info@iptel.org
18
+ *
19
+ * ser is distributed in the hope that it will be useful,
20
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
+ * GNU General Public License for more details.
23
+ *
24
+ * You should have received a copy of the GNU General Public License
25
+ * along with this program; if not, write to the Free Software
26
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
+ */
28
+
29
+
30
+#ifndef CASE_SERV_H
31
+#define CASE_SERV_H
32
+
33
+
34
+#define serv_CASE                   \
35
+    p += 4;                         \
36
+    if (LOWER_BYTE(*p) == 'e' && LOWER_BYTE(p[1]) == 'r') {   \
37
+            hdr->type = HDR_SERVER; \
38
+            p+= 2;                  \
39
+	    goto dc_end;            \
40
+    }                               \
41
+    goto other;
42
+
43
+
44
+#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 407
 				if (msg->rpid==0) msg->rpid = hf;
408 408
 				msg->parsed_flag|=HDR_RPID;
409 409
 				break;
410
+		        case HDR_SERVER:
411
+				if (msg->server==0) msg->server = hf;
412
+				msg->parsed_flag|=HDR_SERVER;
413
+				break;
410 414
 			case HDR_VIA:
411 415
 				msg->parsed_flag|=HDR_VIA;
412 416
 				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 114
         case _subj_: subj_CASE; \
115 115
         case _user_: user_CASE; \
116 116
         case _dive_: dive_CASE; \
117
-        case _remo_: remo_CASE;
117
+        case _remo_: remo_CASE; \
118
+        case _serv_: serv_CASE;
118 119
 
119 120
 
120 121
 #define PARSE_COMPACT(id)          \