Browse code

Identity, Identity-info, Date headers would be parsed only if they were required

Gergely Kovacs authored on 15/10/2007 14:21:01
Showing 6 changed files
... ...
@@ -39,6 +39,8 @@
39 39
 #include "parse_to.h"
40 40
 #include "parse_cseq.h"
41 41
 #include "parse_date.h"
42
+#include "parse_identity.h"
43
+#include "parse_identityinfo.h"
42 44
 #include "../dprint.h"
43 45
 #include "../mem/mem.h"
44 46
 #include "parse_def.h"
... ...
@@ -37,7 +37,7 @@
37 37
  *  2003-05-01  parser extended to support Accept header field (janakj)
38 38
  *  2005-02-23  parse_headers uses hdr_flags_t now (andrei)
39 39
  *  2005-03-02  free_via_list(vb) on via parse error (andrei)
40
- *  2007-01-26  parser extended to support Identity, Identity-info and Date 
40
+ *  2007-01-26  parser extended to support Identity, Identity-info and Date
41 41
  *		header fields (gergo)
42 42
  */
43 43
 
... ...
@@ -80,9 +80,6 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
80 80
 	struct via_body *vb;
81 81
 	struct cseq_body* cseq_b;
82 82
 	struct to_body* to_b;
83
-	struct date_body* date_b;
84
-	struct identity_body* identity_b;
85
-	struct identityinfo_body* identityinfo_b;
86 83
 	int integer, err;
87 84
 	unsigned uval;
88 85
 
... ...
@@ -200,57 +197,9 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
200 197
 			DBG("DEBUG: get_hdr_body : retry_after=%d\n",
201 198
 					(unsigned)(long)hdr->parsed);
202 199
 			break;
200
+		case HDR_IDENTITY_T:
203 201
 		case HDR_DATE_T:
204
-			date_b=pkg_malloc(sizeof(*date_b));
205
-			if (date_b==0){
206
-				LOG(L_ERR, "get_hdr_field: out of memory\n");
207
-				goto error;
208
-			}
209
-			memset(date_b, 0, sizeof(*date_b));
210
-			hdr->body.s=tmp;
211
-			tmp=parse_date(tmp,end,date_b);
212
-			if (date_b->error==PARSE_ERROR){
213
-				LOG(L_ERR, "ERROR:get_hdr_field: bad date header\n");
214
-				free_date(date_b);
215
-				goto error;
216
-			}
217
-			hdr->parsed=(void*)date_b;
218
-			hdr->body.len=tmp-hdr->body.s;
219
-			break;
220 202
 		case HDR_IDENTITY_INFO_T:
221
-			identityinfo_b=pkg_malloc(sizeof(*identityinfo_b));
222
-			if (identityinfo_b==0){
223
-				LOG(L_ERR, "get_hdr_field: out of memory\n");
224
-				goto error;
225
-			}
226
-			memset(identityinfo_b, 0, sizeof(*identityinfo_b));
227
-			hdr->body.s=tmp;
228
-			tmp=parse_identityinfo(tmp,end,identityinfo_b);
229
-			if (identityinfo_b->error==PARSE_ERROR || !tmp){
230
-				LOG(L_ERR, "ERROR: get_hdr_field: bad identityinfo header\n");
231
-				free_identityinfo(identityinfo_b);
232
-				goto error;
233
-			}
234
-			hdr->parsed=(void*)identityinfo_b;
235
-			hdr->body.len=tmp-hdr->body.s;
236
-			break;
237
-		case HDR_IDENTITY_T:
238
-			identity_b=pkg_malloc(sizeof(*identity_b));
239
-			if (identity_b==0){
240
-				LOG(L_ERR, "get_hdr_field: out of memory\n");
241
-				goto error;
242
-			}
243
-			memset(identity_b, 0, sizeof(*identity_b));
244
-			hdr->body.s=tmp;
245
-			tmp=parse_identity(tmp,end,identity_b);
246
-			if (identity_b->error==PARSE_ERROR || !tmp){
247
-				LOG(L_ERR, "ERROR: get_hdr_field: bad identity header\n");
248
-				free_identity(identity_b);
249
-				goto error;
250
-			}
251
-			hdr->parsed=(void*)identity_b;
252
-			hdr->body.len=tmp-hdr->body.s;
253
-			break;
254 203
 		case HDR_SUPPORTED_T:
255 204
 		case HDR_REQUIRE_T:
256 205
 		case HDR_CONTENTTYPE_T:
... ...
@@ -59,9 +59,6 @@
59 59
 #include "../config.h"
60 60
 #include "parse_def.h"
61 61
 #include "parse_cseq.h"
62
-#include "parse_date.h"
63
-#include "parse_identity.h"
64
-#include "parse_identityinfo.h"
65 62
 #include "parse_to.h"
66 63
 #include "parse_via.h"
67 64
 #include "parse_fline.h"
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- * $Id$ 
2
+ * $Id$
3 3
  *
4 4
  * Copyright (c) 2007 iptelorg GmbH
5 5
  *
... ...
@@ -30,6 +30,7 @@
30 30
 #define PARSE_DATE
31 31
 
32 32
 #include <time.h>
33
+#include "msg_parser.h"
33 34
 
34 35
 #define RFC1123DATELENGTH	29
35 36
 
... ...
@@ -46,8 +47,8 @@ struct date_body{
46 47
 /*
47 48
  * Parse Date header field
48 49
  */
49
-char* parse_date(char *buf, char *end, struct date_body *db);
50
-
50
+void parse_date(char *buf, char *end, struct date_body *db);
51
+int parse_date_header(struct sip_msg *msg);
51 52
 
52 53
 /*
53 54
  * Free all associated memory
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- * $Id$ 
2
+ * $Id$
3 3
  *
4 4
  * Copyright (c) 2007 iptelorg GmbH
5 5
  *
... ...
@@ -30,6 +30,7 @@
30 30
 #define PARSE_IDENTITY
31 31
 
32 32
 #include "../str.h"
33
+#include "msg_parser.h"
33 34
 
34 35
 struct identity_body{
35 36
 	int error;  		/* Error code */
... ...
@@ -45,7 +46,8 @@ struct identity_body{
45 46
 /*
46 47
  * Parse Identity header field
47 48
  */
48
-char* parse_identity(char *buf, char *end, struct identity_body *ib);
49
+void parse_identity(char *buf, char *end, struct identity_body *ib);
50
+int parse_identity_header(struct sip_msg *msg);
49 51
 
50 52
 
51 53
 /*
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- * $Id$ 
2
+ * $Id$
3 3
  *
4 4
  * Copyright (c) 2007 iptelorg GmbH
5 5
  *
... ...
@@ -30,6 +30,7 @@
30 30
 #define PARSE_IDENTITYNFO
31 31
 
32 32
 #include "../str.h"
33
+#include "msg_parser.h"
33 34
 
34 35
 enum {
35 36
 	II_START,
... ...
@@ -77,8 +78,8 @@ struct identityinfo_body {
77 78
 /*
78 79
  * Parse Identity-Info header field
79 80
  */
80
-char* parse_identityinfo(char *buffer, char* end, struct identityinfo_body *ii_b);
81
-
81
+void parse_identityinfo(char *buffer, char* end, struct identityinfo_body *ii_b);
82
+int parse_identityinfo_header(struct sip_msg *msg);
82 83
 
83 84
 /*
84 85
  * Free all associated memory