Browse code

Date, Identity, Identity-info HF support added

Gergely Kovacs authored on 08/03/2007 14:56:10
Showing 9 changed files
... ...
@@ -48,6 +48,7 @@
48 48
  *  2004-03-31  alias shortcuts are also translated (andrei)
49 49
  *  2006-04-20  via->comp is also translated (andrei)
50 50
  *  2006-10-16  HDR_{PROXY,WWW}_AUTHENTICATE_T cloned (andrei)
51
+ *  2007-01-26  HDR_DATE_T, HDR_IDENTITY_T, HDR_IDENTITY_INFO_T added (gergo)
51 52
  */
52 53
 
53 54
 #include "defs.h"
... ...
@@ -390,6 +391,9 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len )
390 390
 		case HDR_REQUESTDISPOSITION_T:
391 391
 		case HDR_WWW_AUTHENTICATE_T:
392 392
 		case HDR_PROXY_AUTHENTICATE_T:
393
+		case HDR_DATE_T:
394
+		case HDR_IDENTITY_T:
395
+		case HDR_IDENTITY_INFO_T:
393 396
 			/* we ignore them for now even if they have something parsed*/
394 397
 			break;
395 398
 		}/*switch*/
... ...
@@ -530,6 +534,9 @@ do { \
530 530
 		case HDR_REQUESTDISPOSITION_T:
531 531
 		case HDR_WWW_AUTHENTICATE_T:
532 532
 		case HDR_PROXY_AUTHENTICATE_T:
533
+		case HDR_DATE_T:
534
+		case HDR_IDENTITY_T:
535
+		case HDR_IDENTITY_INFO_T:
533 536
 			break;
534 537
 
535 538
 		case HDR_VIA_T:
... ...
@@ -29,6 +29,7 @@
29 29
  * 2003-03-26 Frees also hdr->parsed for Route & Record-Route (janakj)
30 30
  * 2003-04-26 ZSW (jiri)
31 31
  * 2003-08-05 free the parsed part of Accept header (bogdan)
32
+ * 2007-01-26 HDR_DATE_T, HDR_IDENTITY_T, HDR_IDENTITY_INFO_T added (gergo)
32 33
  */
33 34
 
34 35
 
... ...
@@ -36,6 +37,7 @@
36 36
 #include "parse_via.h"
37 37
 #include "parse_to.h"
38 38
 #include "parse_cseq.h"
39
+#include "parse_date.h"
39 40
 #include "../dprint.h"
40 41
 #include "../mem/mem.h"
41 42
 #include "parse_def.h"
... ...
@@ -57,7 +59,7 @@
57 57
 void clean_hdr_field(struct hdr_field* hf)
58 58
 {
59 59
 	void** h_parsed;
60
-	
60
+
61 61
 	if (hf->parsed){
62 62
 		h_parsed=&hf->parsed; /*strict aliasing warnings workarround */
63 63
 		switch(hf->type){
... ...
@@ -122,7 +124,7 @@ void clean_hdr_field(struct hdr_field* hf)
122 122
 
123 123
 		case HDR_REQUIRE_T:
124 124
 			break;
125
-			
125
+
126 126
 		case HDR_PROXYREQUIRE_T:
127 127
 			break;
128 128
 
... ...
@@ -173,11 +175,23 @@ void clean_hdr_field(struct hdr_field* hf)
173 173
 		case HDR_REFER_TO_T:
174 174
 			free_to(hf->parsed);
175 175
 			break;
176
-		
176
+
177 177
 		case HDR_SUBSCRIPTION_STATE_T:
178 178
 			free_subscription_state((subscription_state_t**)h_parsed);
179 179
 			break;
180 180
 
181
+		case HDR_DATE_T:
182
+			free_date(hf->parsed);
183
+			break;
184
+
185
+		case HDR_IDENTITY_INFO_T:
186
+			free_identityinfo(hf->parsed);
187
+			break;
188
+
189
+		case HDR_IDENTITY_T:
190
+			free_identity(hf->parsed);
191
+			break;
192
+
181 193
 		case HDR_SESSIONEXPIRES_T:
182 194
 		case HDR_MIN_SE_T:
183 195
 		case HDR_ACCEPTCONTACT_T:
... ...
@@ -31,6 +31,7 @@
31 31
  * 2003-05-01 HDR_ACCEPT added (janakj)
32 32
  * 2005-02-14 hdr_flags_t && hdr_flags_f defined, split HDR_xxx into
33 33
  *             HDR_xxx_F & HDR_xxx_T [WARNING: don't mix them!] (andrei)
34
+ * 2007-01-26 HDR_DATE_T, HDR_IDENTITY_T, HDR_IDENTITY_INFO_T added (gergo)
34 35
  */
35 36
 
36 37
 
... ...
@@ -100,6 +101,9 @@ enum _hdr_types_t {
100 100
 	HDR_REQUESTDISPOSITION_T	       /* Request-Disposition header */,
101 101
 	HDR_WWW_AUTHENTICATE_T		       /* WWW-Authenticate header field */,
102 102
 	HDR_PROXY_AUTHENTICATE_T	       /* Proxy-Authenticate header field */,
103
+	HDR_DATE_T			       /* Date header field */,
104
+	HDR_IDENTITY_T			       /* Identity header field */,
105
+	HDR_IDENTITY_INFO_T		       /* Identity-info header field */,
103 106
 
104 107
 	HDR_EOH_T					       /* End of message header */
105 108
 };
... ...
@@ -163,6 +167,9 @@ typedef unsigned long long hdr_flags_t;
163 163
 #define HDR_REQUESTDISPOSITION_F	HDR_F_DEF(REQUESTDISPOSITION)
164 164
 #define HDR_WWW_AUTHENTICATE_F		HDR_F_DEF(WWW_AUTHENTICATE)
165 165
 #define HDR_PROXY_AUTHENTICATE_F	HDR_F_DEF(PROXY_AUTHENTICATE)
166
+#define HDR_DATE_F			HDR_F_DEF(DATE)
167
+#define HDR_IDENTITY_F			HDR_F_DEF(IDENTITY)
168
+#define HDR_IDENTITY_INFO_F		HDR_F_DEF(IDENTITY_INFO)
166 169
 
167 170
 #define HDR_OTHER_F					HDR_F_DEF(OTHER)
168 171
 
... ...
@@ -31,6 +31,7 @@
31 31
  * 2003-05-01 _acce_ macro added (janakj)
32 32
  * 2003-05-01 Macros for Accept-Disposition added (janakj)
33 33
  * 2003-11-02 Macros for Diversion added (jh)
34
+ * 2007-01-26 Macros for Identity, Identity-info, Date added (gergo)
34 35
  */
35 36
 
36 37
 #ifndef KEYS_H
... ...
@@ -103,6 +104,10 @@
103 103
 #define _sip_  0x2d706973   /* "sip-" */
104 104
 #define _ifm_  0x6d2d6669   /* "if-m" */
105 105
 #define _atch_ 0x68637461   /* "atch" */
106
+#define _date_ 0x65746164   /* "date" */
107
+#define _iden_ 0x6e656469   /* "iden" */
108
+#define _tity_ 0x79746974   /* "tity" */
109
+#define _info_ 0x6f666e69   /* "info" */
106 110
 
107 111
 #define _pt_l_ 0x6c2d7470   /* "pt-l" */
108 112
 #define _angu_ 0x75676e61   /* "angu" */
... ...
@@ -37,6 +37,8 @@
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 
41
+ *		header fields (gergo)
40 42
  */
41 43
 
42 44
 
... ...
@@ -77,6 +79,9 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
77 77
 	struct via_body *vb;
78 78
 	struct cseq_body* cseq_b;
79 79
 	struct to_body* to_b;
80
+	struct date_body* date_b;
81
+	struct identity_body* identity_b;
82
+	struct identityinfo_body* identityinfo_b;
80 83
 	int integer;
81 84
 
82 85
 	if ((*buf)=='\n' || (*buf)=='\r'){
... ...
@@ -181,6 +186,57 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
181 181
 			DBG("DEBUG: get_hdr_body : content_length=%d\n",
182 182
 					(int)(long)hdr->parsed);
183 183
 			break;
184
+		case HDR_DATE_T:
185
+			date_b=pkg_malloc(sizeof(*date_b));
186
+			if (date_b==0){
187
+				LOG(L_ERR, "get_hdr_field: out of memory\n");
188
+				goto error;
189
+			}
190
+			memset(date_b, 0, sizeof(*date_b));
191
+			hdr->body.s=tmp;
192
+			tmp=parse_date(tmp,end,date_b);
193
+			if (date_b->error==PARSE_ERROR){
194
+				LOG(L_ERR, "ERROR:get_hdr_field: bad date header\n");
195
+				free_date(date_b);
196
+				goto error;
197
+			}
198
+			hdr->parsed=(void*)date_b;
199
+			hdr->body.len=tmp-hdr->body.s;
200
+			break;
201
+		case HDR_IDENTITY_INFO_T:
202
+			identityinfo_b=pkg_malloc(sizeof(*identityinfo_b));
203
+			if (identityinfo_b==0){
204
+				LOG(L_ERR, "get_hdr_field: out of memory\n");
205
+				goto error;
206
+			}
207
+			memset(identityinfo_b, 0, sizeof(*identityinfo_b));
208
+			hdr->body.s=tmp;
209
+			tmp=parse_identityinfo(tmp,end,identityinfo_b);
210
+			if (identityinfo_b->error==PARSE_ERROR || !tmp){
211
+				LOG(L_ERR, "ERROR: get_hdr_field: bad identityinfo header\n");
212
+				free_identityinfo(identityinfo_b);
213
+				goto error;
214
+			}
215
+			hdr->parsed=(void*)identityinfo_b;
216
+			hdr->body.len=tmp-hdr->body.s;
217
+			break;
218
+		case HDR_IDENTITY_T:
219
+			identity_b=pkg_malloc(sizeof(*identity_b));
220
+			if (identity_b==0){
221
+				LOG(L_ERR, "get_hdr_field: out of memory\n");
222
+				goto error;
223
+			}
224
+			memset(identity_b, 0, sizeof(*identity_b));
225
+			hdr->body.s=tmp;
226
+			tmp=parse_identity(tmp,end,identity_b);
227
+			if (identity_b->error==PARSE_ERROR || !tmp){
228
+				LOG(L_ERR, "ERROR: get_hdr_field: bad identity header\n");
229
+				free_identity(identity_b);
230
+				goto error;
231
+			}
232
+			hdr->parsed=(void*)identity_b;
233
+			hdr->body.len=tmp-hdr->body.s;
234
+			break;
184 235
 		case HDR_SUPPORTED_T:
185 236
 		case HDR_REQUIRE_T:
186 237
 		case HDR_CONTENTTYPE_T:
... ...
@@ -477,6 +533,18 @@ int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next)
477 477
 					DBG("parse_headers: this is the second via\n");
478 478
 				}
479 479
 				break;
480
+			case HDR_DATE_T:
481
+				if (msg->date==0) msg->date=hf;
482
+				msg->parsed_flag|=HDR_DATE_F;
483
+				break;
484
+			case HDR_IDENTITY_T:
485
+				if (msg->identity==0) msg->identity=hf;
486
+				msg->parsed_flag|=HDR_IDENTITY_F;
487
+				break;
488
+			case HDR_IDENTITY_INFO_T:
489
+				if (msg->identity_info==0) msg->identity_info=hf;
490
+				msg->parsed_flag|=HDR_IDENTITY_INFO_F;
491
+				break;
480 492
 			default:
481 493
 				LOG(L_CRIT, "BUG: parse_headers: unknown header type %d\n",
482 494
 							hf->type);
... ...
@@ -40,6 +40,8 @@
40 40
  *  2005-02-25  uri types added (sip, sips & tel)  (andrei)
41 41
  *  2006-04-20  uri comp member (only if USE_COMP is defined) (andrei)
42 42
  *  2006-11-10  check_transaction_quadruple inlined (andrei)
43
+ *  2007-01-26  added date, identity, identity_info header fields
44
+ *		to sip_msg (gergo)
43 45
  */
44 46
 
45 47
 
... ...
@@ -56,6 +58,9 @@
56 56
 #include "../config.h"
57 57
 #include "parse_def.h"
58 58
 #include "parse_cseq.h"
59
+#include "parse_date.h"
60
+#include "parse_identity.h"
61
+#include "parse_identityinfo.h"
59 62
 #include "parse_to.h"
60 63
 #include "parse_via.h"
61 64
 #include "parse_fline.h"
... ...
@@ -232,6 +237,9 @@ struct sip_msg {
232 232
 	struct hdr_field* min_se;
233 233
 	struct hdr_field* sipifmatch;
234 234
 	struct hdr_field* subscription_state;
235
+	struct hdr_field* date;
236
+	struct hdr_field* identity;
237
+	struct hdr_field* identity_info;
235 238
 
236 239
 	char* eoh;        /* pointer to the end of header (if found) or null */
237 240
 	char* unparsed;   /* here we stopped parsing*/
... ...
@@ -31,6 +31,7 @@
31 31
  * 2003-02-28 scratchpad compatibility abandoned (jiri)
32 32
  * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
33 33
  * 2003-05-01 added support for Accept HF (janakj)
34
+ * 2007-01-26 Date, Identity, Identity_info HF support added (gergo)
34 35
  */
35 36
 
36 37
 
... ...
@@ -92,6 +93,8 @@ static inline char* skip_ws(char* p, unsigned int size)
92 92
 #include "case_subs.h"     /* Subscription-State */
93 93
 #include "case_requ.h"     /* Require */
94 94
 #include "case_www.h"      /* WWW-Authenticate */
95
+#include "case_date.h"     /* Date */
96
+#include "case_iden.h"     /* Identity, Identity-info */
95 97
 
96 98
 
97 99
 #define READ(val) \
... ...
@@ -133,6 +136,8 @@ static inline char* skip_ws(char* p, unsigned int size)
133 133
 	case _min__: min_CASE;  \
134 134
 	case _requ_: requ_CASE;  \
135 135
 	case _www__: www_CASE; \
136
+	case _date_: date_CASE; \
137
+	case _iden_: iden_CASE; \
136 138
 
137 139
 
138 140
 
... ...
@@ -202,6 +207,8 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
202 202
 		case 'd': PARSE_COMPACT(HDR_REQUESTDISPOSITION_T); break;
203 203
 		case 's': PARSE_COMPACT(HDR_SUBJECT_T);       break;
204 204
 		case 'r': PARSE_COMPACT(HDR_REFER_TO_T);      break;
205
+		case 'y': PARSE_COMPACT(HDR_IDENTITY_T);      break;
206
+		case 'n': PARSE_COMPACT(HDR_IDENTITY_INFO_T); break;
205 207
 		}
206 208
 		goto other;
207 209
         }
... ...
@@ -29,6 +29,7 @@
29 29
  *  2005-12-19  select framework, basic core functions (mma)
30 30
  *  2006-01-19  multiple nested calls, IS_ALIAS -> NESTED flag renamed (mma)
31 31
  *  2006-02-17  fixup call for select_anyhdr (mma)
32
+ *  2007-01-26  date, identity, identity_info support added (gergo)
32 33
  */
33 34
 
34 35
 #include <stdlib.h> 
... ...
@@ -1184,6 +1185,9 @@ SELECT_plain_header(priority, priority, HDR_PRIORITY_F)
1184 1184
 SELECT_plain_header(session_expires, session_expires, HDR_SESSIONEXPIRES_F)
1185 1185
 SELECT_plain_header(min_se, min_se, HDR_MIN_SE_F)
1186 1186
 SELECT_plain_header(sip_if_match, sipifmatch, HDR_SIPIFMATCH_F)
1187
+SELECT_plain_header(date, date, HDR_DATE_F)
1188
+SELECT_plain_header(identity, identity, HDR_IDENTITY_F)
1189
+SELECT_plain_header(identity_info, identity_info, HDR_IDENTITY_INFO_F)
1187 1190
 
1188 1191
 int select_msg_request(str* res, select_t* s, struct sip_msg* msg)
1189 1192
 {
... ...
@@ -28,6 +28,7 @@
28 28
  * --------
29 29
  *  2005-12-19  select framework, basic core functions (mma)
30 30
  *  2006-01-19  multiple nested calls, IS_ALIAS -> NESTED flag renamed (mma)
31
+ *  2007-01-26  date, identity, identity_info support added (gergo)
31 32
  */
32 33
 
33 34
  
... ...
@@ -203,6 +204,10 @@ SELECT_F(select_branch_dst_uri)
203 203
 SELECT_F(select_branch_uriq)
204 204
 SELECT_F(select_branch_q)
205 205
 
206
+SELECT_F(select_date)
207
+SELECT_F(select_identity)
208
+SELECT_F(select_identity_info)
209
+
206 210
 static select_row_t select_core[] = {
207 211
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("ruri"), select_ruri, 0}, /* not the same as request.uri because it is involved by new_uri */
208 212
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("request_uri"), select_ruri, 0},
... ...
@@ -386,6 +391,10 @@ static select_row_t select_core[] = {
386 386
 	{ select_branch_uriq, SEL_PARAM_STR, STR_NULL, select_any_nameaddr, NESTED},
387 387
 	{ select_branch, SEL_PARAM_STR, STR_STATIC_INIT("q"), select_branch_q, OPTIONAL | CONSUME_NEXT_INT | DIVERSION | SEL_BRANCH_Q},
388 388
 
389
+	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("date"), select_date, 0},
390
+	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("identity"), select_identity, 0},
391
+	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("identity_info"), select_identity_info, 0},
392
+
389 393
 	{ NULL, SEL_PARAM_INT, STR_NULL, NULL, 0}
390 394
 };
391 395