浏览代码

Kamailio compatibility: Privacy header field name parser

This patch adds support for the Privacy header field name parser.
Jan Janak 16 年之前
父节点
当前提交
87d8497867
共有 7 个文件被更改,包括 67 次插入2 次删除
  1. 51 0
      parser/case_priv.h
  2. 1 0
      parser/hf.c
  3. 2 0
      parser/hf.h
  4. 4 0
      parser/keys.h
  5. 5 0
      parser/msg_parser.c
  6. 1 0
      parser/msg_parser.h
  7. 3 2
      parser/parse_hname2.c

+ 51 - 0
parser/case_priv.h

@@ -0,0 +1,51 @@
+/* 
+ * $Id$ 
+ *
+ * Call-ID Header Name Parsing Macros
+ *
+ * Copyright (C) 2001-2003 FhG FOKUS
+ *
+ * This file is part of ser, a free SIP server.
+ *
+ * ser is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * ser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _CASE_PRIV_H
+#define _CASE_PRIV_H
+
+
+#define ACY_CASE					  \
+	switch(LOWER_DWORD(val)) {		  \
+	case _acy1_:					  \
+		hdr->type = HDR_PRIVACY_T;	  \
+		hdr->name.len = 7;			  \
+		return (p + 4);				  \
+									  \
+	case _acy2_:					  \
+		hdr->type = HDR_PRIVACY_T;	  \
+		p += 4;						  \
+		goto dc_end;				  \
+	}
+
+
+#define priv_CASE	   \
+	p += 4;			   \
+	val = READ(p);	   \
+	ACY_CASE;		   \
+	goto other;
+
+
+
+#endif /* _CASE_PRIV_H */

+ 1 - 0
parser/hf.c

@@ -214,6 +214,7 @@ void clean_hdr_field(struct hdr_field* hf)
 		case HDR_WWW_AUTHENTICATE_T:
 		case HDR_PROXY_AUTHENTICATE_T:
 		case HDR_PATH_T:
+		case HDR_PRIVACY_T:
 			break;
 		default:
 			LOG(L_CRIT, "BUG: clean_hdr_field: unknown header type %d\n",

+ 2 - 0
parser/hf.h

@@ -110,6 +110,7 @@ enum _hdr_types_t {
 	HDR_PPI_T                          /**< P-Preferred-Identity header field */,
 	HDR_PAI_T                          /**< P-Asserted-Identity header field */,
 	HDR_PATH_T                         /**< Path header field */,
+	HDR_PRIVACY_T				       /**< Privacy header field */,
 	HDR_EOH_T					       /* End of message header */
 };
 
@@ -180,6 +181,7 @@ typedef unsigned long long hdr_flags_t;
 #define HDR_PPI_F                   HDR_F_DEF(PPI)
 #define HDR_PAI_F                   HDR_F_DEF(PAI)
 #define HDR_PATH_F                  HDR_F_DEF(PATH)
+#define HDR_PRIVACY_F               HDR_F_DEF(PRIVACY)
 
 #define HDR_OTHER_F					HDR_F_DEF(OTHER)
 

+ 4 - 0
parser/keys.h

@@ -181,4 +181,8 @@
 #define _ter1_ 0x3a726574   /* "ter:" */
 #define _ter2_ 0x20726574   /* "ter " */
 
+#define _priv_ 0x76697270   /* "priv" */
+#define _acy2_ 0x20796361   /* "acy " */
+#define _acy1_ 0x3a796361   /* "acy:" */
+
 #endif /* KEYS_H */

+ 5 - 0
parser/msg_parser.c

@@ -242,6 +242,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 		case HDR_WWW_AUTHENTICATE_T:
 		case HDR_PROXY_AUTHENTICATE_T:
 	    case HDR_PATH_T:
+	    case HDR_PRIVACY_T:
 		case HDR_OTHER_T:
 			/* just skip over it */
 			hdr->body.s=tmp;
@@ -521,6 +522,10 @@ int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next)
 				if (msg->path==0) msg->path=hf;
 				msg->parsed_flag|=HDR_PATH_F;
 				break;
+		    case HDR_PRIVACY_T:
+				if (msg->privacy==0) msg->privacy=hf;
+				msg->parsed_flag|=HDR_PRIVACY_F;
+				break;
 			default:
 				LOG(L_CRIT, "BUG: parse_headers: unknown header type %d\n",
 							hf->type);

+ 1 - 0
parser/msg_parser.h

@@ -278,6 +278,7 @@ typedef struct sip_msg {
 	struct hdr_field* pai;
 	struct hdr_field* ppi;
 	struct hdr_field* path;
+	struct hdr_field* privacy;
 
 	struct msg_body* body;
 

+ 3 - 2
parser/parse_hname2.c

@@ -99,6 +99,7 @@ static inline char* skip_ws(char* p, unsigned int size)
 #include "case_iden.h"     /* Identity, Identity-info */
 #include "case_retr.h"     /* Retry-After */
 #include "case_path.h"     /* Path */
+#include "case_priv.h"
 
 
 #define READ(val) \
@@ -144,8 +145,8 @@ static inline char* skip_ws(char* p, unsigned int size)
 	case _date_: date_CASE; \
 	case _iden_: iden_CASE; \
 	case _retr_: retr_CASE; \
-    case _path_: path_CASE;
-
+    case _path_: path_CASE; \
+	case _priv_: priv_CASE;
 
 
 #define PARSE_COMPACT(id)          \