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 391
 		case HDR_REQUESTDISPOSITION_T:
391 392
 		case HDR_WWW_AUTHENTICATE_T:
392 393
 		case HDR_PROXY_AUTHENTICATE_T:
394
+		case HDR_DATE_T:
395
+		case HDR_IDENTITY_T:
396
+		case HDR_IDENTITY_INFO_T:
393 397
 			/* we ignore them for now even if they have something parsed*/
394 398
 			break;
395 399
 		}/*switch*/
... ...
@@ -530,6 +534,9 @@ do { \
530 534
 		case HDR_REQUESTDISPOSITION_T:
531 535
 		case HDR_WWW_AUTHENTICATE_T:
532 536
 		case HDR_PROXY_AUTHENTICATE_T:
537
+		case HDR_DATE_T:
538
+		case HDR_IDENTITY_T:
539
+		case HDR_IDENTITY_INFO_T:
533 540
 			break;
534 541
 
535 542
 		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 37
 #include "parse_via.h"
37 38
 #include "parse_to.h"
38 39
 #include "parse_cseq.h"
40
+#include "parse_date.h"
39 41
 #include "../dprint.h"
40 42
 #include "../mem/mem.h"
41 43
 #include "parse_def.h"
... ...
@@ -57,7 +59,7 @@
57 59
 void clean_hdr_field(struct hdr_field* hf)
58 60
 {
59 61
 	void** h_parsed;
60
-	
62
+
61 63
 	if (hf->parsed){
62 64
 		h_parsed=&hf->parsed; /*strict aliasing warnings workarround */
63 65
 		switch(hf->type){
... ...
@@ -122,7 +124,7 @@ void clean_hdr_field(struct hdr_field* hf)
122 124
 
123 125
 		case HDR_REQUIRE_T:
124 126
 			break;
125
-			
127
+
126 128
 		case HDR_PROXYREQUIRE_T:
127 129
 			break;
128 130
 
... ...
@@ -173,11 +175,23 @@ void clean_hdr_field(struct hdr_field* hf)
173 175
 		case HDR_REFER_TO_T:
174 176
 			free_to(hf->parsed);
175 177
 			break;
176
-		
178
+
177 179
 		case HDR_SUBSCRIPTION_STATE_T:
178 180
 			free_subscription_state((subscription_state_t**)h_parsed);
179 181
 			break;
180 182
 
183
+		case HDR_DATE_T:
184
+			free_date(hf->parsed);
185
+			break;
186
+
187
+		case HDR_IDENTITY_INFO_T:
188
+			free_identityinfo(hf->parsed);
189
+			break;
190
+
191
+		case HDR_IDENTITY_T:
192
+			free_identity(hf->parsed);
193
+			break;
194
+
181 195
 		case HDR_SESSIONEXPIRES_T:
182 196
 		case HDR_MIN_SE_T:
183 197
 		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 101
 	HDR_REQUESTDISPOSITION_T	       /* Request-Disposition header */,
101 102
 	HDR_WWW_AUTHENTICATE_T		       /* WWW-Authenticate header field */,
102 103
 	HDR_PROXY_AUTHENTICATE_T	       /* Proxy-Authenticate header field */,
104
+	HDR_DATE_T			       /* Date header field */,
105
+	HDR_IDENTITY_T			       /* Identity header field */,
106
+	HDR_IDENTITY_INFO_T		       /* Identity-info header field */,
103 107
 
104 108
 	HDR_EOH_T					       /* End of message header */
105 109
 };
... ...
@@ -163,6 +167,9 @@ typedef unsigned long long hdr_flags_t;
163 167
 #define HDR_REQUESTDISPOSITION_F	HDR_F_DEF(REQUESTDISPOSITION)
164 168
 #define HDR_WWW_AUTHENTICATE_F		HDR_F_DEF(WWW_AUTHENTICATE)
165 169
 #define HDR_PROXY_AUTHENTICATE_F	HDR_F_DEF(PROXY_AUTHENTICATE)
170
+#define HDR_DATE_F			HDR_F_DEF(DATE)
171
+#define HDR_IDENTITY_F			HDR_F_DEF(IDENTITY)
172
+#define HDR_IDENTITY_INFO_F		HDR_F_DEF(IDENTITY_INFO)
166 173
 
167 174
 #define HDR_OTHER_F					HDR_F_DEF(OTHER)
168 175
 
... ...
@@ -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 104
 #define _sip_  0x2d706973   /* "sip-" */
104 105
 #define _ifm_  0x6d2d6669   /* "if-m" */
105 106
 #define _atch_ 0x68637461   /* "atch" */
107
+#define _date_ 0x65746164   /* "date" */
108
+#define _iden_ 0x6e656469   /* "iden" */
109
+#define _tity_ 0x79746974   /* "tity" */
110
+#define _info_ 0x6f666e69   /* "info" */
106 111
 
107 112
 #define _pt_l_ 0x6c2d7470   /* "pt-l" */
108 113
 #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 79
 	struct via_body *vb;
78 80
 	struct cseq_body* cseq_b;
79 81
 	struct to_body* to_b;
82
+	struct date_body* date_b;
83
+	struct identity_body* identity_b;
84
+	struct identityinfo_body* identityinfo_b;
80 85
 	int integer;
81 86
 
82 87
 	if ((*buf)=='\n' || (*buf)=='\r'){
... ...
@@ -181,6 +186,57 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
181 186
 			DBG("DEBUG: get_hdr_body : content_length=%d\n",
182 187
 					(int)(long)hdr->parsed);
183 188
 			break;
189
+		case HDR_DATE_T:
190
+			date_b=pkg_malloc(sizeof(*date_b));
191
+			if (date_b==0){
192
+				LOG(L_ERR, "get_hdr_field: out of memory\n");
193
+				goto error;
194
+			}
195
+			memset(date_b, 0, sizeof(*date_b));
196
+			hdr->body.s=tmp;
197
+			tmp=parse_date(tmp,end,date_b);
198
+			if (date_b->error==PARSE_ERROR){
199
+				LOG(L_ERR, "ERROR:get_hdr_field: bad date header\n");
200
+				free_date(date_b);
201
+				goto error;
202
+			}
203
+			hdr->parsed=(void*)date_b;
204
+			hdr->body.len=tmp-hdr->body.s;
205
+			break;
206
+		case HDR_IDENTITY_INFO_T:
207
+			identityinfo_b=pkg_malloc(sizeof(*identityinfo_b));
208
+			if (identityinfo_b==0){
209
+				LOG(L_ERR, "get_hdr_field: out of memory\n");
210
+				goto error;
211
+			}
212
+			memset(identityinfo_b, 0, sizeof(*identityinfo_b));
213
+			hdr->body.s=tmp;
214
+			tmp=parse_identityinfo(tmp,end,identityinfo_b);
215
+			if (identityinfo_b->error==PARSE_ERROR || !tmp){
216
+				LOG(L_ERR, "ERROR: get_hdr_field: bad identityinfo header\n");
217
+				free_identityinfo(identityinfo_b);
218
+				goto error;
219
+			}
220
+			hdr->parsed=(void*)identityinfo_b;
221
+			hdr->body.len=tmp-hdr->body.s;
222
+			break;
223
+		case HDR_IDENTITY_T:
224
+			identity_b=pkg_malloc(sizeof(*identity_b));
225
+			if (identity_b==0){
226
+				LOG(L_ERR, "get_hdr_field: out of memory\n");
227
+				goto error;
228
+			}
229
+			memset(identity_b, 0, sizeof(*identity_b));
230
+			hdr->body.s=tmp;
231
+			tmp=parse_identity(tmp,end,identity_b);
232
+			if (identity_b->error==PARSE_ERROR || !tmp){
233
+				LOG(L_ERR, "ERROR: get_hdr_field: bad identity header\n");
234
+				free_identity(identity_b);
235
+				goto error;
236
+			}
237
+			hdr->parsed=(void*)identity_b;
238
+			hdr->body.len=tmp-hdr->body.s;
239
+			break;
184 240
 		case HDR_SUPPORTED_T:
185 241
 		case HDR_REQUIRE_T:
186 242
 		case HDR_CONTENTTYPE_T:
... ...
@@ -477,6 +533,18 @@ int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next)
477 533
 					DBG("parse_headers: this is the second via\n");
478 534
 				}
479 535
 				break;
536
+			case HDR_DATE_T:
537
+				if (msg->date==0) msg->date=hf;
538
+				msg->parsed_flag|=HDR_DATE_F;
539
+				break;
540
+			case HDR_IDENTITY_T:
541
+				if (msg->identity==0) msg->identity=hf;
542
+				msg->parsed_flag|=HDR_IDENTITY_F;
543
+				break;
544
+			case HDR_IDENTITY_INFO_T:
545
+				if (msg->identity_info==0) msg->identity_info=hf;
546
+				msg->parsed_flag|=HDR_IDENTITY_INFO_F;
547
+				break;
480 548
 			default:
481 549
 				LOG(L_CRIT, "BUG: parse_headers: unknown header type %d\n",
482 550
 							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 58
 #include "../config.h"
57 59
 #include "parse_def.h"
58 60
 #include "parse_cseq.h"
61
+#include "parse_date.h"
62
+#include "parse_identity.h"
63
+#include "parse_identityinfo.h"
59 64
 #include "parse_to.h"
60 65
 #include "parse_via.h"
61 66
 #include "parse_fline.h"
... ...
@@ -232,6 +237,9 @@ struct sip_msg {
232 237
 	struct hdr_field* min_se;
233 238
 	struct hdr_field* sipifmatch;
234 239
 	struct hdr_field* subscription_state;
240
+	struct hdr_field* date;
241
+	struct hdr_field* identity;
242
+	struct hdr_field* identity_info;
235 243
 
236 244
 	char* eoh;        /* pointer to the end of header (if found) or null */
237 245
 	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 93
 #include "case_subs.h"     /* Subscription-State */
93 94
 #include "case_requ.h"     /* Require */
94 95
 #include "case_www.h"      /* WWW-Authenticate */
96
+#include "case_date.h"     /* Date */
97
+#include "case_iden.h"     /* Identity, Identity-info */
95 98
 
96 99
 
97 100
 #define READ(val) \
... ...
@@ -133,6 +136,8 @@ static inline char* skip_ws(char* p, unsigned int size)
133 136
 	case _min__: min_CASE;  \
134 137
 	case _requ_: requ_CASE;  \
135 138
 	case _www__: www_CASE; \
139
+	case _date_: date_CASE; \
140
+	case _iden_: iden_CASE; \
136 141
 
137 142
 
138 143
 
... ...
@@ -202,6 +207,8 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
202 207
 		case 'd': PARSE_COMPACT(HDR_REQUESTDISPOSITION_T); break;
203 208
 		case 's': PARSE_COMPACT(HDR_SUBJECT_T);       break;
204 209
 		case 'r': PARSE_COMPACT(HDR_REFER_TO_T);      break;
210
+		case 'y': PARSE_COMPACT(HDR_IDENTITY_T);      break;
211
+		case 'n': PARSE_COMPACT(HDR_IDENTITY_INFO_T); break;
205 212
 		}
206 213
 		goto other;
207 214
         }
... ...
@@ -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 1185
 SELECT_plain_header(session_expires, session_expires, HDR_SESSIONEXPIRES_F)
1185 1186
 SELECT_plain_header(min_se, min_se, HDR_MIN_SE_F)
1186 1187
 SELECT_plain_header(sip_if_match, sipifmatch, HDR_SIPIFMATCH_F)
1188
+SELECT_plain_header(date, date, HDR_DATE_F)
1189
+SELECT_plain_header(identity, identity, HDR_IDENTITY_F)
1190
+SELECT_plain_header(identity_info, identity_info, HDR_IDENTITY_INFO_F)
1187 1191
 
1188 1192
 int select_msg_request(str* res, select_t* s, struct sip_msg* msg)
1189 1193
 {
... ...
@@ -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 204
 SELECT_F(select_branch_uriq)
204 205
 SELECT_F(select_branch_q)
205 206
 
207
+SELECT_F(select_date)
208
+SELECT_F(select_identity)
209
+SELECT_F(select_identity_info)
210
+
206 211
 static select_row_t select_core[] = {
207 212
 	{ 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 213
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("request_uri"), select_ruri, 0},
... ...
@@ -386,6 +391,10 @@ static select_row_t select_core[] = {
386 391
 	{ select_branch_uriq, SEL_PARAM_STR, STR_NULL, select_any_nameaddr, NESTED},
387 392
 	{ select_branch, SEL_PARAM_STR, STR_STATIC_INIT("q"), select_branch_q, OPTIONAL | CONSUME_NEXT_INT | DIVERSION | SEL_BRANCH_Q},
388 393
 
394
+	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("date"), select_date, 0},
395
+	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("identity"), select_identity, 0},
396
+	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("identity_info"), select_identity_info, 0},
397
+
389 398
 	{ NULL, SEL_PARAM_INT, STR_NULL, NULL, 0}
390 399
 };
391 400