Browse Source

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

Gergely Kovacs 18 năm trước cách đây
mục cha
commit
5255318827
6 tập tin đã thay đổi với 16 bổ sung64 xóa
  1. 2 0
      parser/hf.c
  2. 2 53
      parser/msg_parser.c
  3. 0 3
      parser/msg_parser.h
  4. 4 3
      parser/parse_date.h
  5. 4 2
      parser/parse_identity.h
  6. 4 3
      parser/parse_identityinfo.h

+ 2 - 0
parser/hf.c

@@ -39,6 +39,8 @@
 #include "parse_to.h"
 #include "parse_cseq.h"
 #include "parse_date.h"
+#include "parse_identity.h"
+#include "parse_identityinfo.h"
 #include "../dprint.h"
 #include "../mem/mem.h"
 #include "parse_def.h"

+ 2 - 53
parser/msg_parser.c

@@ -37,7 +37,7 @@
  *  2003-05-01  parser extended to support Accept header field (janakj)
  *  2005-02-23  parse_headers uses hdr_flags_t now (andrei)
  *  2005-03-02  free_via_list(vb) on via parse error (andrei)
- *  2007-01-26  parser extended to support Identity, Identity-info and Date 
+ *  2007-01-26  parser extended to support Identity, Identity-info and Date
  *		header fields (gergo)
  */
 
@@ -80,9 +80,6 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 	struct via_body *vb;
 	struct cseq_body* cseq_b;
 	struct to_body* to_b;
-	struct date_body* date_b;
-	struct identity_body* identity_b;
-	struct identityinfo_body* identityinfo_b;
 	int integer, err;
 	unsigned uval;
 
@@ -200,57 +197,9 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 			DBG("DEBUG: get_hdr_body : retry_after=%d\n",
 					(unsigned)(long)hdr->parsed);
 			break;
+		case HDR_IDENTITY_T:
 		case HDR_DATE_T:
-			date_b=pkg_malloc(sizeof(*date_b));
-			if (date_b==0){
-				LOG(L_ERR, "get_hdr_field: out of memory\n");
-				goto error;
-			}
-			memset(date_b, 0, sizeof(*date_b));
-			hdr->body.s=tmp;
-			tmp=parse_date(tmp,end,date_b);
-			if (date_b->error==PARSE_ERROR){
-				LOG(L_ERR, "ERROR:get_hdr_field: bad date header\n");
-				free_date(date_b);
-				goto error;
-			}
-			hdr->parsed=(void*)date_b;
-			hdr->body.len=tmp-hdr->body.s;
-			break;
 		case HDR_IDENTITY_INFO_T:
-			identityinfo_b=pkg_malloc(sizeof(*identityinfo_b));
-			if (identityinfo_b==0){
-				LOG(L_ERR, "get_hdr_field: out of memory\n");
-				goto error;
-			}
-			memset(identityinfo_b, 0, sizeof(*identityinfo_b));
-			hdr->body.s=tmp;
-			tmp=parse_identityinfo(tmp,end,identityinfo_b);
-			if (identityinfo_b->error==PARSE_ERROR || !tmp){
-				LOG(L_ERR, "ERROR: get_hdr_field: bad identityinfo header\n");
-				free_identityinfo(identityinfo_b);
-				goto error;
-			}
-			hdr->parsed=(void*)identityinfo_b;
-			hdr->body.len=tmp-hdr->body.s;
-			break;
-		case HDR_IDENTITY_T:
-			identity_b=pkg_malloc(sizeof(*identity_b));
-			if (identity_b==0){
-				LOG(L_ERR, "get_hdr_field: out of memory\n");
-				goto error;
-			}
-			memset(identity_b, 0, sizeof(*identity_b));
-			hdr->body.s=tmp;
-			tmp=parse_identity(tmp,end,identity_b);
-			if (identity_b->error==PARSE_ERROR || !tmp){
-				LOG(L_ERR, "ERROR: get_hdr_field: bad identity header\n");
-				free_identity(identity_b);
-				goto error;
-			}
-			hdr->parsed=(void*)identity_b;
-			hdr->body.len=tmp-hdr->body.s;
-			break;
 		case HDR_SUPPORTED_T:
 		case HDR_REQUIRE_T:
 		case HDR_CONTENTTYPE_T:

+ 0 - 3
parser/msg_parser.h

@@ -59,9 +59,6 @@
 #include "../config.h"
 #include "parse_def.h"
 #include "parse_cseq.h"
-#include "parse_date.h"
-#include "parse_identity.h"
-#include "parse_identityinfo.h"
 #include "parse_to.h"
 #include "parse_via.h"
 #include "parse_fline.h"

+ 4 - 3
parser/parse_date.h

@@ -1,5 +1,5 @@
 /*
- * $Id$ 
+ * $Id$
  *
  * Copyright (c) 2007 iptelorg GmbH
  *
@@ -30,6 +30,7 @@
 #define PARSE_DATE
 
 #include <time.h>
+#include "msg_parser.h"
 
 #define RFC1123DATELENGTH	29
 
@@ -46,8 +47,8 @@ struct date_body{
 /*
  * Parse Date header field
  */
-char* parse_date(char *buf, char *end, struct date_body *db);
-
+void parse_date(char *buf, char *end, struct date_body *db);
+int parse_date_header(struct sip_msg *msg);
 
 /*
  * Free all associated memory

+ 4 - 2
parser/parse_identity.h

@@ -1,5 +1,5 @@
 /*
- * $Id$ 
+ * $Id$
  *
  * Copyright (c) 2007 iptelorg GmbH
  *
@@ -30,6 +30,7 @@
 #define PARSE_IDENTITY
 
 #include "../str.h"
+#include "msg_parser.h"
 
 struct identity_body{
 	int error;  		/* Error code */
@@ -45,7 +46,8 @@ struct identity_body{
 /*
  * Parse Identity header field
  */
-char* parse_identity(char *buf, char *end, struct identity_body *ib);
+void parse_identity(char *buf, char *end, struct identity_body *ib);
+int parse_identity_header(struct sip_msg *msg);
 
 
 /*

+ 4 - 3
parser/parse_identityinfo.h

@@ -1,5 +1,5 @@
 /*
- * $Id$ 
+ * $Id$
  *
  * Copyright (c) 2007 iptelorg GmbH
  *
@@ -30,6 +30,7 @@
 #define PARSE_IDENTITYNFO
 
 #include "../str.h"
+#include "msg_parser.h"
 
 enum {
 	II_START,
@@ -77,8 +78,8 @@ struct identityinfo_body {
 /*
  * Parse Identity-Info header field
  */
-char* parse_identityinfo(char *buffer, char* end, struct identityinfo_body *ii_b);
-
+void parse_identityinfo(char *buffer, char* end, struct identityinfo_body *ii_b);
+int parse_identityinfo_header(struct sip_msg *msg);
 
 /*
  * Free all associated memory