Bläddra i källkod

Date, Identity, Identity-info HF support added

Gergely Kovacs 18 år sedan
förälder
incheckning
e7317b87df
9 ändrade filer med 132 tillägg och 3 borttagningar
  1. 7 0
      modules/tm/sip_msg.c
  2. 17 3
      parser/hf.c
  3. 7 0
      parser/hf.h
  4. 5 0
      parser/keys.h
  5. 68 0
      parser/msg_parser.c
  6. 8 0
      parser/msg_parser.h
  7. 7 0
      parser/parse_hname2.c
  8. 4 0
      select_core.c
  9. 9 0
      select_core.h

+ 7 - 0
modules/tm/sip_msg.c

@@ -48,6 +48,7 @@
  *  2004-03-31  alias shortcuts are also translated (andrei)
  *  2006-04-20  via->comp is also translated (andrei)
  *  2006-10-16  HDR_{PROXY,WWW}_AUTHENTICATE_T cloned (andrei)
+ *  2007-01-26  HDR_DATE_T, HDR_IDENTITY_T, HDR_IDENTITY_INFO_T added (gergo)
  */
 
 #include "defs.h"
@@ -390,6 +391,9 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len )
 		case HDR_REQUESTDISPOSITION_T:
 		case HDR_WWW_AUTHENTICATE_T:
 		case HDR_PROXY_AUTHENTICATE_T:
+		case HDR_DATE_T:
+		case HDR_IDENTITY_T:
+		case HDR_IDENTITY_INFO_T:
 			/* we ignore them for now even if they have something parsed*/
 			break;
 		}/*switch*/
@@ -530,6 +534,9 @@ do { \
 		case HDR_REQUESTDISPOSITION_T:
 		case HDR_WWW_AUTHENTICATE_T:
 		case HDR_PROXY_AUTHENTICATE_T:
+		case HDR_DATE_T:
+		case HDR_IDENTITY_T:
+		case HDR_IDENTITY_INFO_T:
 			break;
 
 		case HDR_VIA_T:

+ 17 - 3
parser/hf.c

@@ -29,6 +29,7 @@
  * 2003-03-26 Frees also hdr->parsed for Route & Record-Route (janakj)
  * 2003-04-26 ZSW (jiri)
  * 2003-08-05 free the parsed part of Accept header (bogdan)
+ * 2007-01-26 HDR_DATE_T, HDR_IDENTITY_T, HDR_IDENTITY_INFO_T added (gergo)
  */
 
 
@@ -36,6 +37,7 @@
 #include "parse_via.h"
 #include "parse_to.h"
 #include "parse_cseq.h"
+#include "parse_date.h"
 #include "../dprint.h"
 #include "../mem/mem.h"
 #include "parse_def.h"
@@ -57,7 +59,7 @@
 void clean_hdr_field(struct hdr_field* hf)
 {
 	void** h_parsed;
-	
+
 	if (hf->parsed){
 		h_parsed=&hf->parsed; /*strict aliasing warnings workarround */
 		switch(hf->type){
@@ -122,7 +124,7 @@ void clean_hdr_field(struct hdr_field* hf)
 
 		case HDR_REQUIRE_T:
 			break;
-			
+
 		case HDR_PROXYREQUIRE_T:
 			break;
 
@@ -173,11 +175,23 @@ void clean_hdr_field(struct hdr_field* hf)
 		case HDR_REFER_TO_T:
 			free_to(hf->parsed);
 			break;
-		
+
 		case HDR_SUBSCRIPTION_STATE_T:
 			free_subscription_state((subscription_state_t**)h_parsed);
 			break;
 
+		case HDR_DATE_T:
+			free_date(hf->parsed);
+			break;
+
+		case HDR_IDENTITY_INFO_T:
+			free_identityinfo(hf->parsed);
+			break;
+
+		case HDR_IDENTITY_T:
+			free_identity(hf->parsed);
+			break;
+
 		case HDR_SESSIONEXPIRES_T:
 		case HDR_MIN_SE_T:
 		case HDR_ACCEPTCONTACT_T:

+ 7 - 0
parser/hf.h

@@ -31,6 +31,7 @@
  * 2003-05-01 HDR_ACCEPT added (janakj)
  * 2005-02-14 hdr_flags_t && hdr_flags_f defined, split HDR_xxx into
  *             HDR_xxx_F & HDR_xxx_T [WARNING: don't mix them!] (andrei)
+ * 2007-01-26 HDR_DATE_T, HDR_IDENTITY_T, HDR_IDENTITY_INFO_T added (gergo)
  */
 
 
@@ -100,6 +101,9 @@ enum _hdr_types_t {
 	HDR_REQUESTDISPOSITION_T	       /* Request-Disposition header */,
 	HDR_WWW_AUTHENTICATE_T		       /* WWW-Authenticate header field */,
 	HDR_PROXY_AUTHENTICATE_T	       /* Proxy-Authenticate header field */,
+	HDR_DATE_T			       /* Date header field */,
+	HDR_IDENTITY_T			       /* Identity header field */,
+	HDR_IDENTITY_INFO_T		       /* Identity-info header field */,
 
 	HDR_EOH_T					       /* End of message header */
 };
@@ -163,6 +167,9 @@ typedef unsigned long long hdr_flags_t;
 #define HDR_REQUESTDISPOSITION_F	HDR_F_DEF(REQUESTDISPOSITION)
 #define HDR_WWW_AUTHENTICATE_F		HDR_F_DEF(WWW_AUTHENTICATE)
 #define HDR_PROXY_AUTHENTICATE_F	HDR_F_DEF(PROXY_AUTHENTICATE)
+#define HDR_DATE_F			HDR_F_DEF(DATE)
+#define HDR_IDENTITY_F			HDR_F_DEF(IDENTITY)
+#define HDR_IDENTITY_INFO_F		HDR_F_DEF(IDENTITY_INFO)
 
 #define HDR_OTHER_F					HDR_F_DEF(OTHER)
 

+ 5 - 0
parser/keys.h

@@ -31,6 +31,7 @@
  * 2003-05-01 _acce_ macro added (janakj)
  * 2003-05-01 Macros for Accept-Disposition added (janakj)
  * 2003-11-02 Macros for Diversion added (jh)
+ * 2007-01-26 Macros for Identity, Identity-info, Date added (gergo)
  */
 
 #ifndef KEYS_H
@@ -103,6 +104,10 @@
 #define _sip_  0x2d706973   /* "sip-" */
 #define _ifm_  0x6d2d6669   /* "if-m" */
 #define _atch_ 0x68637461   /* "atch" */
+#define _date_ 0x65746164   /* "date" */
+#define _iden_ 0x6e656469   /* "iden" */
+#define _tity_ 0x79746974   /* "tity" */
+#define _info_ 0x6f666e69   /* "info" */
 
 #define _pt_l_ 0x6c2d7470   /* "pt-l" */
 #define _angu_ 0x75676e61   /* "angu" */

+ 68 - 0
parser/msg_parser.c

@@ -37,6 +37,8 @@
  *  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 
+ *		header fields (gergo)
  */
 
 
@@ -77,6 +79,9 @@ 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;
 
 	if ((*buf)=='\n' || (*buf)=='\r'){
@@ -181,6 +186,57 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 			DBG("DEBUG: get_hdr_body : content_length=%d\n",
 					(int)(long)hdr->parsed);
 			break;
+		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:
@@ -477,6 +533,18 @@ int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next)
 					DBG("parse_headers: this is the second via\n");
 				}
 				break;
+			case HDR_DATE_T:
+				if (msg->date==0) msg->date=hf;
+				msg->parsed_flag|=HDR_DATE_F;
+				break;
+			case HDR_IDENTITY_T:
+				if (msg->identity==0) msg->identity=hf;
+				msg->parsed_flag|=HDR_IDENTITY_F;
+				break;
+			case HDR_IDENTITY_INFO_T:
+				if (msg->identity_info==0) msg->identity_info=hf;
+				msg->parsed_flag|=HDR_IDENTITY_INFO_F;
+				break;
 			default:
 				LOG(L_CRIT, "BUG: parse_headers: unknown header type %d\n",
 							hf->type);

+ 8 - 0
parser/msg_parser.h

@@ -40,6 +40,8 @@
  *  2005-02-25  uri types added (sip, sips & tel)  (andrei)
  *  2006-04-20  uri comp member (only if USE_COMP is defined) (andrei)
  *  2006-11-10  check_transaction_quadruple inlined (andrei)
+ *  2007-01-26  added date, identity, identity_info header fields
+ *		to sip_msg (gergo)
  */
 
 
@@ -56,6 +58,9 @@
 #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"
@@ -232,6 +237,9 @@ struct sip_msg {
 	struct hdr_field* min_se;
 	struct hdr_field* sipifmatch;
 	struct hdr_field* subscription_state;
+	struct hdr_field* date;
+	struct hdr_field* identity;
+	struct hdr_field* identity_info;
 
 	char* eoh;        /* pointer to the end of header (if found) or null */
 	char* unparsed;   /* here we stopped parsing*/

+ 7 - 0
parser/parse_hname2.c

@@ -31,6 +31,7 @@
  * 2003-02-28 scratchpad compatibility abandoned (jiri)
  * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
  * 2003-05-01 added support for Accept HF (janakj)
+ * 2007-01-26 Date, Identity, Identity_info HF support added (gergo)
  */
 
 
@@ -92,6 +93,8 @@ static inline char* skip_ws(char* p, unsigned int size)
 #include "case_subs.h"     /* Subscription-State */
 #include "case_requ.h"     /* Require */
 #include "case_www.h"      /* WWW-Authenticate */
+#include "case_date.h"     /* Date */
+#include "case_iden.h"     /* Identity, Identity-info */
 
 
 #define READ(val) \
@@ -133,6 +136,8 @@ static inline char* skip_ws(char* p, unsigned int size)
 	case _min__: min_CASE;  \
 	case _requ_: requ_CASE;  \
 	case _www__: www_CASE; \
+	case _date_: date_CASE; \
+	case _iden_: iden_CASE; \
 
 
 
@@ -202,6 +207,8 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
 		case 'd': PARSE_COMPACT(HDR_REQUESTDISPOSITION_T); break;
 		case 's': PARSE_COMPACT(HDR_SUBJECT_T);       break;
 		case 'r': PARSE_COMPACT(HDR_REFER_TO_T);      break;
+		case 'y': PARSE_COMPACT(HDR_IDENTITY_T);      break;
+		case 'n': PARSE_COMPACT(HDR_IDENTITY_INFO_T); break;
 		}
 		goto other;
         }

+ 4 - 0
select_core.c

@@ -29,6 +29,7 @@
  *  2005-12-19  select framework, basic core functions (mma)
  *  2006-01-19  multiple nested calls, IS_ALIAS -> NESTED flag renamed (mma)
  *  2006-02-17  fixup call for select_anyhdr (mma)
+ *  2007-01-26  date, identity, identity_info support added (gergo)
  */
 
 #include <stdlib.h> 
@@ -1184,6 +1185,9 @@ SELECT_plain_header(priority, priority, HDR_PRIORITY_F)
 SELECT_plain_header(session_expires, session_expires, HDR_SESSIONEXPIRES_F)
 SELECT_plain_header(min_se, min_se, HDR_MIN_SE_F)
 SELECT_plain_header(sip_if_match, sipifmatch, HDR_SIPIFMATCH_F)
+SELECT_plain_header(date, date, HDR_DATE_F)
+SELECT_plain_header(identity, identity, HDR_IDENTITY_F)
+SELECT_plain_header(identity_info, identity_info, HDR_IDENTITY_INFO_F)
 
 int select_msg_request(str* res, select_t* s, struct sip_msg* msg)
 {

+ 9 - 0
select_core.h

@@ -28,6 +28,7 @@
  * --------
  *  2005-12-19  select framework, basic core functions (mma)
  *  2006-01-19  multiple nested calls, IS_ALIAS -> NESTED flag renamed (mma)
+ *  2007-01-26  date, identity, identity_info support added (gergo)
  */
 
  
@@ -203,6 +204,10 @@ SELECT_F(select_branch_dst_uri)
 SELECT_F(select_branch_uriq)
 SELECT_F(select_branch_q)
 
+SELECT_F(select_date)
+SELECT_F(select_identity)
+SELECT_F(select_identity_info)
+
 static select_row_t select_core[] = {
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("ruri"), select_ruri, 0}, /* not the same as request.uri because it is involved by new_uri */
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("request_uri"), select_ruri, 0},
@@ -386,6 +391,10 @@ static select_row_t select_core[] = {
 	{ select_branch_uriq, SEL_PARAM_STR, STR_NULL, select_any_nameaddr, NESTED},
 	{ select_branch, SEL_PARAM_STR, STR_STATIC_INIT("q"), select_branch_q, OPTIONAL | CONSUME_NEXT_INT | DIVERSION | SEL_BRANCH_Q},
 
+	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("date"), select_date, 0},
+	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("identity"), select_identity, 0},
+	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("identity_info"), select_identity_info, 0},
+
 	{ NULL, SEL_PARAM_INT, STR_NULL, NULL, 0}
 };