Browse code

Extended parser automaton, Record-Route is now parsed.

Jan Janak authored on 28/01/2002 18:45:42
Showing 3 changed files
... ...
@@ -250,6 +250,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
250 250
 		case HDR_CALLID:
251 251
 		case HDR_CONTACT:
252 252
 		case HDR_ROUTE:   /* janakj, HDR_ROUTE was missing here */
253
+	        case HDR_RECORDROUTE:
253 254
 		case HDR_MAXFORWARDS:
254 255
 		case HDR_OTHER:
255 256
 			/* just skip over it */
... ...
@@ -599,7 +600,11 @@ int parse_headers(struct sip_msg* msg, int flags)
599 600
 				if (msg->route==0) msg->route=hf;
600 601
 				msg->parsed_flag|=HDR_ROUTE;
601 602
 				break;
602
-			case HDR_VIA:
603
+		        case HDR_RECORDROUTE:
604
+				if (msg->record_route==0) msg->record_route = hf;
605
+				msg->parsed_flag|=HDR_RECORDROUTE;
606
+				break;
607
+		        case HDR_VIA:
603 608
 				msg->parsed_flag|=HDR_VIA;
604 609
 				DBG("parse_headers: Via1 found, flags=%d\n", flags);
605 610
 				if (msg->via1==0) {
... ...
@@ -27,6 +27,7 @@
27 27
 #define HDR_CONTACT       64
28 28
 #define HDR_MAXFORWARDS  128
29 29
 #define HDR_ROUTE        256
30
+#define HDR_RECORDROUTE  512
30 31
 #define HDR_OTHER       65536 /*unknown header type*/
31 32
 
32 33
 /* maximum length of values appended to Via-branch parameter */
... ...
@@ -159,6 +160,7 @@ struct sip_msg{
159 160
 	struct hdr_field* contact;
160 161
 	struct hdr_field* maxforwards;
161 162
 	struct hdr_field* route;
163
+	struct hdr_field* record_route;
162 164
 	char* eoh; /* pointer to the end of header (if found) or null */
163 165
 
164 166
 	char* unparsed; /* here we stopped parsing*/
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- * $Id�
2
+ * $Id$
3 3
  *
4 4
  * header name parsing automaton:
5 5
 
... ...
@@ -12,6 +12,7 @@
12 12
  * Contact:           m:
13 13
  * Max-Forwards:      n/a
14 14
  * Route:             n/a
15
+ * Record-Route:      n/a
15 16
  */
16 17
 
17 18
 
... ...
@@ -29,9 +30,12 @@ enum { INITIAL=0,
29 30
 		MAXFORWARDS6, MAXFORWARDS7, MAXFORWARDS8, MAXFORWARDS9, MAXFORWARDS10,
30 31
 		MAXFORWARDS11,
31 32
 		ROUTE1, ROUTE2, ROUTE3, ROUTE4,
33
+                RECROUTE1, RECROUTE2, RECROUTE3, RECROUTE4, RECROUTE5, 
34
+                RECROUTE6, RECROUTE7, RECROUTE8, RECROUTE9, RECROUTE10,
35
+       
32 36
 		/* final states*/
33 37
 		F_VIA=1000, F_FROM, F_TO, F_CSEQ, F_CALLID, F_CONTACT, F_MAXFORWARDS,
34
-		F_ROUTE,
38
+                F_ROUTE, F_RECROUTE,
35 39
 		I_START,
36 40
 
37 41
 		UNKNOWN_HEADER=200,
... ...
@@ -142,6 +146,11 @@ char* parse_hname(char* p, char* end, struct hdr_field* hdr)
142 146
 						case MAXFORWARDS9:
143 147
 							state=MAXFORWARDS10;
144 148
 							break;
149
+					        case RECROUTE3:
150
+							state=RECROUTE4;
151
+							break;
152
+					        case RECROUTE6:
153
+							state=RECROUTE7;
145 154
 						case UNKNOWN_HEADER: break;
146 155
 						default:
147 156
 							state=UNKNOWN_HEADER;
... ...
@@ -169,6 +178,12 @@ char* parse_hname(char* p, char* end, struct hdr_field* hdr)
169 178
 						case MAXFORWARDS5:
170 179
 							state=MAXFORWARDS6;
171 180
 							break;
181
+					        case RECROUTE2:
182
+							state=RECROUTE3;
183
+							break;
184
+					        case RECROUTE7:
185
+							state=RECROUTE8;
186
+							break;
172 187
 						case UNKNOWN_HEADER: break;
173 188
 						default:
174 189
 							state=UNKNOWN_HEADER;
... ...
@@ -205,6 +220,9 @@ char* parse_hname(char* p, char* end, struct hdr_field* hdr)
205 220
 							case ROUTE3:
206 221
 								state=ROUTE4;
207 222
 								break;
223
+						        case RECROUTE9:
224
+								state=RECROUTE10;
225
+								break;
208 226
 							case UNKNOWN_HEADER: break;
209 227
 							default:
210 228
 								state=UNKNOWN_HEADER;
... ...
@@ -220,6 +238,9 @@ char* parse_hname(char* p, char* end, struct hdr_field* hdr)
220 238
 							case CONTACT5:
221 239
 								state=CONTACT6;
222 240
 								break;
241
+						        case RECROUTE1:
242
+								state=RECROUTE2;
243
+								break;
223 244
 							case UNKNOWN_HEADER: break;
224 245
 							default:
225 246
 								state=UNKNOWN_HEADER;
... ...
@@ -256,6 +277,12 @@ char* parse_hname(char* p, char* end, struct hdr_field* hdr)
256 277
 							case ROUTE4:
257 278
 								state=F_ROUTE;
258 279
 								break;
280
+						        case ROUTE1:
281
+								state=RECROUTE1;
282
+								break;
283
+						        case RECROUTE10:
284
+								state=F_RECROUTE;
285
+								break;
259 286
 							case UNKNOWN_HEADER: break;
260 287
 							default:
261 288
 								state=UNKNOWN_HEADER;
... ...
@@ -307,6 +334,9 @@ char* parse_hname(char* p, char* end, struct hdr_field* hdr)
307 334
 							case MAXFORWARDS10:
308 335
 								state=MAXFORWARDS11;
309 336
 								break;
337
+						        case RECROUTE4:
338
+								state=RECROUTE5;
339
+								break;
310 340
 							case UNKNOWN_HEADER: break;
311 341
 							default:
312 342
 								state=UNKNOWN_HEADER;
... ...
@@ -354,6 +384,9 @@ char* parse_hname(char* p, char* end, struct hdr_field* hdr)
354 384
 							case MAXFORWARDS3:
355 385
 								state=MAXFORWARDS4;
356 386
 								break;
387
+						        case RECROUTE5:
388
+								state=RECROUTE6;
389
+								break;
357 390
 							case UNKNOWN_HEADER: break;
358 391
 							default:
359 392
 								state=UNKNOWN_HEADER;
... ...
@@ -384,6 +417,9 @@ char* parse_hname(char* p, char* end, struct hdr_field* hdr)
384 417
 							case ROUTE2:
385 418
 								state=ROUTE3;
386 419
 								break;
420
+						        case RECROUTE8:
421
+								state=RECROUTE9;
422
+								break;
387 423
 							case UNKNOWN_HEADER: break;
388 424
 							default:
389 425
 								state=UNKNOWN_HEADER;
... ...
@@ -400,7 +436,8 @@ char* parse_hname(char* p, char* end, struct hdr_field* hdr)
400 436
 							case F_CALLID:
401 437
 							case F_CONTACT:
402 438
 							case F_MAXFORWARDS:
403
-							case F_ROUTE:
439
+						        case F_ROUTE:
440
+						        case F_RECROUTE:
404 441
 								break; /* eat trailing space*/
405 442
 							case VIA1:
406 443
 								/*compact form: v: */
... ...
@@ -474,6 +511,11 @@ char* parse_hname(char* p, char* end, struct hdr_field* hdr)
474 511
 								hdr->name.len=t-hdr->name.s;
475 512
 								hdr->type=HDR_ROUTE;
476 513
 								goto skip;
514
+						        case F_RECROUTE:
515
+								*t=0;
516
+								hdr->name.len=t-hdr->name.s;
517
+								hdr->type=HDR_RECORDROUTE;
518
+								goto skip;
477 519
 							case UNKNOWN_HEADER:
478 520
 								*t=0;
479 521
 								hdr->name.len=t-hdr->name.s;