Browse code

core - test: reorganized the old files in test folder

- moved to subfolders in test/misc
- keep content of the test folder cleaner for travis and unit tests

Daniel-Constantin Mierla authored on 26/11/2015 22:30:51
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,1583 +0,0 @@
1
-
2
-/* test program -> via parse */
3
-/*
4
- * Copyright (C) 2001-2003 FhG Fokus
5
- *
6
- * This file is part of Kamailio, a free SIP server.
7
- *
8
- * Kamailio is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version
12
- *
13
- * Kamailio is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License 
19
- * along with this program; if not, write to the Free Software 
20
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21
- */
22
-
23
-
24
-
25
-/* parsing:           compact form:
26
- */
27
-
28
-/* 
29
- * still TODO/test:
30
- *  - parse next via
31
- *  - return a list of header structs
32
- *  - '[' ']' ipv6 parsing!
33
- *  - return list of params
34
- *  - test ^\s...'
35
- *  - add support for parsing via front (SIP/2.0/UDP)
36
- */
37
-
38
-#include <stdio.h>
39
-
40
-/* main via states (uri:port ...) */
41
-enum{	         F_HOST,    P_HOST,
42
-		L_PORT,  F_PORT,    P_PORT,
43
-		L_PARAM, F_PARAM,   P_PARAM,
44
-		L_VIA,   F_VIA,
45
-		         F_COMMENT, P_COMMENT,
46
-				 F_IP6HOST, P_IP6HOST,
47
-				 F_CRLF,
48
-				 F_LF,
49
-				 F_CR,
50
-				 END_OF_HEADER
51
-	};
52
-
53
-/* first via part state */
54
-enum{	         F_SIP=100,
55
-		SIP1, SIP2, FIN_SIP,
56
-		L_VER, F_VER,
57
-		VER1, VER2, FIN_VER,
58
-		L_PROTO, F_PROTO, P_PROTO
59
-	};
60
-
61
-/* param related states */
62
-enum{	L_VALUE=200,   F_VALUE, P_VALUE, P_STRING,
63
-		HIDDEN1,   HIDDEN2,   HIDDEN3,   HIDDEN4,   HIDDEN5,
64
-		TTL1,      TTL2,
65
-		BRANCH1,   BRANCH2,   BRANCH3,   BRANCH4,   BRANCH5,
66
-		MADDR1,    MADDR2,    MADDR3,    MADDR4,
67
-		RECEIVED1, RECEIVED2, RECEIVED3, RECEIVED4, RECEIVED5, RECEIVED6,
68
-		RECEIVED7,
69
-		/* fin states (227-...)*/
70
-		FIN_HIDDEN, FIN_TTL, FIN_BRANCH, FIN_MADDR, FIN_RECEIVED,
71
-		GEN_PARAM
72
-	};
73
-
74
-#define LOG(lev, fmt, args...) fprintf(stderr, fmt, ## args)
75
-
76
-
77
-/* entry state must be F_PARAM, or saved_state=F_PARAM and 
78
- * state=F_{LF,CR,CRLF}!
79
- * output state = L_PARAM or F_PARAM or END_OF_HEADER 
80
- * (and saved_state= last state); everything else => error */
81
-__inline char* parse_via_param(char* p, int* pstate, int* psaved_state)
82
-{
83
-	char* tmp;
84
-	register int state;
85
-	int saved_state;
86
-	int param_type;
87
-	char* param_name;
88
-	char* param_value;
89
-	
90
-	state=*pstate;
91
-	saved_state=*psaved_state;
92
-	param_name=param_value=0;
93
-	param_type=0;
94
-	
95
-	for (tmp=p;*tmp;tmp++){
96
-		switch(*tmp){
97
-			case ' ':
98
-			case '\t':
99
-				switch(state){
100
-					case FIN_HIDDEN:
101
-						*tmp=0;
102
-						param_type=state;
103
-						state=L_PARAM;
104
-						goto endofparam;
105
-					case FIN_BRANCH:
106
-					case FIN_TTL:
107
-					case FIN_MADDR:
108
-					case FIN_RECEIVED:
109
-						*tmp=0;
110
-						param_type=state;
111
-						state=L_VALUE;
112
-						goto find_value;
113
-					case F_PARAM:
114
-						break;
115
-					case F_LF:
116
-					case F_CR:
117
-					case F_CRLF:
118
-						state=saved_state;
119
-						break;
120
-					case GEN_PARAM:
121
-					default:
122
-						*tmp=0;
123
-						param_type=GEN_PARAM;
124
-						state=L_VALUE;
125
-						goto find_value;
126
-				}
127
-				break;
128
-			/* \n and \r*/
129
-			case '\n':
130
-				switch(state){
131
-					case FIN_HIDDEN:
132
-						*tmp=0;
133
-						param_type=state;
134
-						saved_state=L_PARAM;
135
-						state=F_LF;
136
-						goto endofparam;
137
-					case FIN_BRANCH:
138
-					case FIN_TTL:
139
-					case FIN_MADDR:
140
-					case FIN_RECEIVED:
141
-						*tmp=0;
142
-						param_type=state;
143
-						saved_state=L_VALUE;
144
-						state=F_LF;
145
-						goto find_value;
146
-					case F_PARAM:
147
-						saved_state=state;
148
-						state=F_LF;
149
-						break;
150
-					case F_LF:
151
-					case F_CRLF:
152
-						state=END_OF_HEADER;
153
-						goto end;
154
-					case F_CR:
155
-						state=F_CRLF;
156
-						break;
157
-					case GEN_PARAM:
158
-					default:
159
-						*tmp=0;
160
-						param_type=GEN_PARAM;
161
-						saved_state=L_VALUE;
162
-						state=F_LF;
163
-						goto find_value;
164
-				}
165
-				break;
166
-			case '\r':
167
-				switch(state){
168
-					case FIN_HIDDEN:
169
-						*tmp=0;
170
-						param_type=state;
171
-						saved_state=L_PARAM;
172
-						state=F_CR;
173
-						goto endofparam;
174
-					case FIN_BRANCH:
175
-					case FIN_TTL:
176
-					case FIN_MADDR:
177
-					case FIN_RECEIVED:
178
-						*tmp=0;
179
-						param_type=state;
180
-						saved_state=L_VALUE;
181
-						state=F_CR;
182
-						goto find_value;
183
-					case F_PARAM:
184
-						saved_state=state;
185
-						state=F_CR;
186
-						break;
187
-					case F_CR:
188
-					case F_CRLF:
189
-						state=END_OF_HEADER;
190
-						goto end;
191
-					case GEN_PARAM:
192
-					default:
193
-						*tmp=0;
194
-						param_type=GEN_PARAM;
195
-						saved_state=L_VALUE;
196
-						state=F_CR;
197
-						goto find_value;
198
-				}
199
-				break;
200
-
201
-			case '=':
202
-				switch(state){
203
-					case FIN_BRANCH:
204
-					case FIN_TTL:
205
-					case FIN_MADDR:
206
-					case FIN_RECEIVED:
207
-						*tmp=0;
208
-						param_type=state;
209
-						state=F_VALUE;
210
-						goto find_value;
211
-					case F_PARAM:
212
-					case FIN_HIDDEN:
213
-						LOG(L_ERR, "ERROR: parse_via: invalid char <%c> in"
214
-								" state %d\n");
215
-						goto error;
216
-					case F_CR:
217
-					case F_LF:
218
-					case F_CRLF:
219
-						state=END_OF_HEADER;
220
-						goto end;
221
-					case GEN_PARAM:
222
-					default:
223
-						*tmp=0;
224
-						param_type=GEN_PARAM;
225
-						state=F_VALUE;
226
-						goto find_value;
227
-				}
228
-				break;
229
-			case ';':
230
-				switch(state){
231
-					case FIN_HIDDEN:
232
-						*tmp=0;
233
-						param_type=state;
234
-						state=F_PARAM;
235
-						goto endofparam;
236
-					case FIN_BRANCH:
237
-					case FIN_MADDR:
238
-					case FIN_TTL:
239
-					case FIN_RECEIVED:
240
-						LOG(L_ERR, "ERROR: parse_via: invalid char <%c> in"
241
-								" state %d\n");
242
-						goto error;
243
-					case F_CR:
244
-					case F_LF:
245
-					case F_CRLF:
246
-						state=END_OF_HEADER;
247
-						goto end;
248
-					case GEN_PARAM:
249
-					default:
250
-						*tmp=0;
251
-						param_type=GEN_PARAM;
252
-						state=F_PARAM;
253
-						goto endofparam;
254
-				}
255
-				break;
256
-				
257
-				/* param names */
258
-			case 'h':
259
-			case 'H':
260
-				switch(state){
261
-					case F_PARAM:
262
-						state=HIDDEN1;
263
-						param_name=tmp;
264
-						break;
265
-					case GEN_PARAM:
266
-						break;
267
-					case F_CR:
268
-					case F_LF:
269
-					case F_CRLF:
270
-						state=END_OF_HEADER;
271
-						goto end;
272
-					default:
273
-						state=GEN_PARAM;
274
-				}
275
-				break;
276
-			case 'i':
277
-			case 'I':
278
-				switch(state){
279
-					case HIDDEN1:
280
-						state=HIDDEN2;
281
-						break;
282
-					case RECEIVED4:
283
-						state=RECEIVED5;
284
-						break;
285
-					case GEN_PARAM:
286
-						break;
287
-					case F_CR:
288
-					case F_LF:
289
-					case F_CRLF:
290
-						state=END_OF_HEADER;
291
-						goto end;
292
-					default:
293
-						state=GEN_PARAM;
294
-				}
295
-				break;
296
-			case 'd':
297
-			case 'D':
298
-				switch(state){
299
-					case HIDDEN2:
300
-						state=HIDDEN3;
301
-						break;
302
-					case HIDDEN3:
303
-						state=HIDDEN4;
304
-						break;
305
-					case MADDR2:
306
-						state=MADDR3;
307
-						break;
308
-					case MADDR3:
309
-						state=MADDR4;
310
-						break;
311
-					case RECEIVED7:
312
-						state=FIN_RECEIVED;
313
-						break;
314
-					case GEN_PARAM:
315
-						break;
316
-					case F_CR:
317
-					case F_LF:
318
-					case F_CRLF:
319
-						state=END_OF_HEADER;
320
-						goto end;
321
-					default:
322
-						state=GEN_PARAM;
323
-				}
324
-				break;
325
-			case 'e':
326
-			case 'E':
327
-				switch(state){
328
-					case HIDDEN4:
329
-						state=HIDDEN5;
330
-						break;
331
-					case RECEIVED1:
332
-						state=RECEIVED2;
333
-						break;
334
-					case RECEIVED3:
335
-						state=RECEIVED4;
336
-						break;
337
-					case RECEIVED6:
338
-						state=RECEIVED7;
339
-						break;
340
-					case GEN_PARAM:
341
-						break;
342
-					case F_CR:
343
-					case F_LF:
344
-					case F_CRLF:
345
-						state=END_OF_HEADER;
346
-						goto end;
347
-					default:
348
-						state=GEN_PARAM;
349
-				}
350
-				break;
351
-			case 'n':
352
-			case 'N':
353
-				switch(state){
354
-					case HIDDEN5:
355
-						state=FIN_HIDDEN;
356
-						break;
357
-					case BRANCH3:
358
-						state=BRANCH4;
359
-						break;
360
-					case GEN_PARAM:
361
-						break;
362
-					case F_CR:
363
-					case F_LF:
364
-					case F_CRLF:
365
-						state=END_OF_HEADER;
366
-						goto end;
367
-					default:
368
-						state=GEN_PARAM;
369
-				}
370
-				break;
371
-			case 't':
372
-			case 'T':
373
-				switch(state){
374
-					case F_PARAM:
375
-						state=TTL1;
376
-						param_name=tmp;
377
-						break;
378
-					case TTL1:
379
-						state=TTL2;
380
-						break;
381
-					case GEN_PARAM:
382
-						break;
383
-					case F_CR:
384
-					case F_LF:
385
-					case F_CRLF:
386
-						state=END_OF_HEADER;
387
-						goto end;
388
-					default:
389
-						state=GEN_PARAM;
390
-				}
391
-				break;
392
-			case 'l':
393
-			case 'L':
394
-				switch(state){
395
-					case TTL2:
396
-						state=FIN_TTL;
397
-						break;
398
-					case GEN_PARAM:
399
-						break;
400
-					case F_CR:
401
-					case F_LF:
402
-					case F_CRLF:
403
-						state=END_OF_HEADER;
404
-						goto end;
405
-					default:
406
-						state=GEN_PARAM;
407
-				}
408
-				break;
409
-			case 'm':
410
-			case 'M':
411
-				switch(state){
412
-					case F_PARAM:
413
-						state=MADDR1;
414
-						param_name=tmp;
415
-						break;
416
-					case GEN_PARAM:
417
-						break;
418
-					case F_CR:
419
-					case F_LF:
420
-					case F_CRLF:
421
-						state=END_OF_HEADER;
422
-						goto end;
423
-					default:
424
-						state=GEN_PARAM;
425
-				}
426
-				break;
427
-			case 'a':
428
-			case 'A':
429
-				switch(state){
430
-					case MADDR1:
431
-						state=MADDR2;
432
-						break;
433
-					case BRANCH2:
434
-						state=BRANCH3;
435
-						break;
436
-					case GEN_PARAM:
437
-						break;
438
-					case F_CR:
439
-					case F_LF:
440
-					case F_CRLF:
441
-						state=END_OF_HEADER;
442
-						goto end;
443
-					default:
444
-						state=GEN_PARAM;
445
-				}
446
-				break;
447
-			case 'r':
448
-			case 'R':
449
-				switch(state){
450
-					case MADDR4:
451
-						state=FIN_MADDR;
452
-						break;
453
-					case F_PARAM:
454
-						state=RECEIVED1;
455
-						param_name=tmp;
456
-						break;
457
-					case BRANCH1:
458
-						state=BRANCH2;
459
-						break;
460
-					case GEN_PARAM:
461
-						break;
462
-					case F_CR:
463
-					case F_LF:
464
-					case F_CRLF:
465
-						state=END_OF_HEADER;
466
-						goto end;
467
-					default:
468
-						state=GEN_PARAM;
469
-				}
470
-				break;
471
-			case 'c':
472
-			case 'C':
473
-				switch(state){
474
-					case RECEIVED2:
475
-						state=RECEIVED3;
476
-						break;
477
-					case BRANCH4:
478
-						state=BRANCH5;
479
-						break;
480
-					case GEN_PARAM:
481
-						break;
482
-					case F_CR:
483
-					case F_LF:
484
-					case F_CRLF:
485
-						state=END_OF_HEADER;
486
-						goto end;
487
-					default:
488
-						state=GEN_PARAM;
489
-				}
490
-				break;
491
-			case 'v':
492
-			case 'V':
493
-				switch(state){
494
-					case RECEIVED5:
495
-						state=RECEIVED6;
496
-						break;
497
-					case GEN_PARAM:
498
-						break;
499
-					case F_CR:
500
-					case F_LF:
501
-					case F_CRLF:
502
-						state=END_OF_HEADER;
503
-						goto end;
504
-					default:
505
-						state=GEN_PARAM;
506
-				}
507
-				break;
508
-			case 'b':
509
-			case 'B':
510
-				switch(state){
511
-					case F_PARAM:
512
-						state=BRANCH1;
513
-						param_name=tmp;
514
-						break;
515
-					case GEN_PARAM:
516
-						break;
517
-					case F_CR:
518
-					case F_LF:
519
-					case F_CRLF:
520
-						state=END_OF_HEADER;
521
-						goto end;
522
-					default:
523
-						state=GEN_PARAM;
524
-				}
525
-				break;
526
-
527
-			default:
528
-				switch(state){
529
-					case F_PARAM:
530
-						state=GEN_PARAM;
531
-						param_name=tmp;
532
-						break;
533
-					case  GEN_PARAM:
534
-						break;
535
-					case F_CR:
536
-					case F_LF:
537
-					case F_CRLF:
538
-						state=END_OF_HEADER;
539
-						goto end;
540
-					default:
541
-						state=GEN_PARAM;
542
-				}
543
-		}
544
-	}/* for tmp*/
545
-
546
-/* end of packet?*/
547
-saved_state=state;
548
-param_type=state;
549
-state=END_OF_HEADER;
550
-goto end;
551
-
552
-find_value:
553
-	tmp++;
554
-	for(tmp;*tmp;tmp++){
555
-		switch(*tmp){
556
-			case ' ':
557
-			case '\t':
558
-				switch(state){
559
-					case L_VALUE:
560
-					case F_VALUE: /*eat space*/
561
-						break; 
562
-					case P_VALUE:
563
-						*tmp=0;
564
-						state=L_PARAM;
565
-						goto endofvalue;
566
-					case P_STRING:
567
-						break;
568
-					case F_CR:
569
-					case F_LF:
570
-					case F_CRLF:
571
-						state=saved_state;
572
-						break;
573
-					default:
574
-						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
575
-								" in state %d\n", state);
576
-						goto error;
577
-				}
578
-				break;
579
-			case '\n':
580
-				switch(state){
581
-					case L_VALUE:
582
-					case F_VALUE: /*eat space*/
583
-					case P_STRING:
584
-						saved_state=state;
585
-						state=F_LF;
586
-						break; 
587
-					case P_VALUE:
588
-						*tmp=0;
589
-						saved_state=L_PARAM;
590
-						state=F_LF;
591
-						goto endofvalue;
592
-					case F_LF:
593
-					case F_CRLF:
594
-						state=END_OF_HEADER;
595
-						goto end;
596
-					case F_CR:
597
-						state=F_CRLF;
598
-						break;
599
-					default:
600
-						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
601
-								" in state %d\n", state);
602
-						goto error;
603
-				}
604
-				break;
605
-			case '\r':
606
-				switch(state){
607
-					case L_VALUE:
608
-					case F_VALUE: /*eat space*/
609
-					case P_STRING:
610
-						saved_state=state;
611
-						state=F_CR;
612
-						break; 
613
-					case P_VALUE:
614
-						*tmp=0;
615
-						saved_state=L_PARAM;
616
-						state=F_CR;
617
-						goto endofvalue;
618
-					case F_LF:
619
-					case F_CR:
620
-					case F_CRLF:
621
-						state=END_OF_HEADER;
622
-						goto end;
623
-					default:
624
-						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
625
-								" in state %d\n", state);
626
-						goto error;
627
-				}
628
-				break;
629
-
630
-			case '=':
631
-				switch(state){
632
-					case L_VALUE:
633
-						state=F_VALUE;
634
-						break;
635
-					case P_STRING:
636
-						break;
637
-					case F_LF:
638
-					case F_CR:
639
-					case F_CRLF:
640
-						state=END_OF_HEADER;
641
-						goto end;
642
-					default:
643
-						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
644
-								" in state %d\n", state);
645
-						goto error;
646
-				}
647
-				break;
648
-			case ';':
649
-				switch(state){
650
-					case P_VALUE:
651
-						*tmp=0;
652
-						state=F_PARAM;
653
-						goto endofvalue;
654
-					case P_STRING:
655
-						break; /* what to do? */
656
-					case F_LF:
657
-					case F_CR:
658
-					case F_CRLF:
659
-						state=END_OF_HEADER;
660
-						goto end;
661
-					default:
662
-						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
663
-								" in state %d\n", state);
664
-						goto error;
665
-				}
666
-				break;
667
-			
668
-			case '"':
669
-				switch(state){
670
-					case F_VALUE:
671
-						state=P_STRING;
672
-						param_value=tmp+1;
673
-						break;
674
-					case P_STRING:
675
-						*tmp=0;
676
-						state=L_PARAM;
677
-						goto endofvalue;
678
-					case F_LF:
679
-					case F_CR:
680
-					case F_CRLF:
681
-						state=END_OF_HEADER;
682
-						goto end;
683
-					default:
684
-						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
685
-								" in state %d\n", state);
686
-						goto error;
687
-				}
688
-				break;
689
-			default:
690
-				switch(state){
691
-					case F_VALUE:
692
-						state=P_VALUE;
693
-						param_value=tmp;
694
-						break;
695
-					case P_VALUE:
696
-					case P_STRING:
697
-						break;
698
-					case F_LF:
699
-					case F_CR:
700
-					case F_CRLF:
701
-						state=END_OF_HEADER;
702
-						goto end;
703
-					default:
704
-						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
705
-								" in state %d\n", state);
706
-						goto error;
707
-				}
708
-		}
709
-	} /* for2 tmp*/
710
-
711
-	/* if generic_param => it can have no value */
712
-	if ((state==L_VALUE)&&(param_type==GEN_PARAM)) state=L_PARAM;
713
-	saved_state=state;
714
-	state=END_OF_HEADER;
715
-	goto end;
716
-
717
-endofparam:
718
-endofvalue:
719
-	printf("end, tmp=%x, <%c>\n", tmp, *tmp);
720
-	//tmp++;
721
-end:
722
-	*pstate=state;
723
-	*psaved_state=saved_state;
724
-	printf("Found param type %d, <%s> = <%s>\n", param_type, param_name,
725
-			param_value);
726
-	return tmp;
727
-
728
-error:
729
-	fprintf(stderr,"error: via_parse_param\n");
730
-	*pstate=state;
731
-	*psaved_state=saved_state;
732
-	return tmp;
733
-}
734
-
735
-
736
-
737
-
738
-
739
-
740
-int main(int argc, char** argv)
741
-{
742
-
743
-	char* tmp;
744
-	int state;
745
-	int saved_state;
746
-	int c_nest;
747
-	int i;
748
-	int port;
749
-	char* host;
750
-	char* port_str;
751
-	char* param;
752
-	char* comment;
753
-	char* next_via;
754
-	char *proto; /* in fact transport*/
755
-
756
-	host=port_str=param=comment=next_via=proto=0;
757
-
758
-	printf(" %s (%d)\n", argv[0], argc);
759
-	if (argc<2){
760
-			fprintf(stderr, " no parameters\n");
761
-			exit(-1);
762
-	}
763
-	
764
-	/* parse start of via ( SIP/2.0/UDP    )*/
765
-	state=F_SIP;
766
-	for(tmp=argv[1];*tmp;tmp++){
767
-		switch(*tmp){
768
-			case ' ':
769
-			case'\t':
770
-				switch(state){
771
-					case L_VER: /* eat space */
772
-					case L_PROTO:
773
-					case F_SIP:
774
-					case F_VER:
775
-					case F_PROTO:
776
-						break;
777
-					case P_PROTO:
778
-						*tmp=0;  /* finished proto parsing */
779
-						state=F_HOST; /* start looking for host*/
780
-						goto main_via;
781
-					case FIN_SIP:
782
-						*tmp=0;
783
-						state=L_VER;
784
-						break;
785
-					case FIN_VER:
786
-						*tmp=0;
787
-						state=L_PROTO;
788
-						break;
789
-					case F_LF:
790
-					case F_CRLF:
791
-					case F_CR: /* header continues on this line */
792
-						state=saved_state;
793
-						break;
794
-					default:
795
-						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
796
-								" state %d\n", *tmp, state);
797
-						goto error;
798
-				}
799
-				break;
800
-			case '\n':
801
-				switch(state){
802
-					case L_VER:
803
-					case F_SIP:
804
-					case F_VER:
805
-					case F_PROTO:
806
-					case L_PROTO:
807
-						saved_state=state;
808
-						state=F_LF;
809
-						break;
810
-					case P_PROTO:
811
-						*tmp=0;
812
-						state=F_LF;
813
-						saved_state=F_HOST; /* start looking for host*/
814
-						goto main_via;
815
-					case FIN_SIP:
816
-						*tmp=0;
817
-						state=F_LF;
818
-						saved_state=L_VER;
819
-						break;
820
-					case FIN_VER:
821
-						*tmp=0;
822
-						state=F_LF;
823
-						saved_state=L_PROTO;
824
-						break;
825
-					case F_CR:
826
-						state=F_CRLF;
827
-						break;
828
-					case F_LF:
829
-					case F_CRLF:
830
-						state=saved_state;
831
-						goto endofheader;
832
-					default:
833
-						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
834
-								" state %d\n", *tmp, state);
835
-						goto error;
836
-				}
837
-				break;
838
-			case '\r':
839
-				switch(state){
840
-					case L_VER:
841
-					case F_SIP:
842
-					case F_VER:
843
-					case F_PROTO:
844
-					case L_PROTO:
845
-						saved_state=state;
846
-						state=F_CR;
847
-						break;
848
-					case P_PROTO:
849
-						*tmp=0;
850
-						state=F_CR;
851
-						saved_state=F_HOST;
852
-						goto main_via;
853
-					case FIN_SIP:
854
-						*tmp=0;
855
-						state=F_CR;
856
-						saved_state=L_VER;
857
-						break;
858
-					case FIN_VER:
859
-						*tmp=0;
860
-						state=F_CR;
861
-						saved_state=L_PROTO;
862
-						break;
863
-					case F_LF: /*end of line ?next header?*/
864
-					case F_CR:
865
-					case F_CRLF:
866
-						state=saved_state;
867
-						goto endofheader;
868
-					default:
869
-						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
870
-								" state %d\n", *tmp, state);
871
-						goto error;
872
-				}
873
-				break;
874
-			
875
-			case '/':
876
-				switch(state){
877
-					case FIN_SIP:
878
-						*tmp=0;
879
-						state=F_VER;
880
-						break;
881
-					case FIN_VER:
882
-						*tmp=0;
883
-						state=F_PROTO;
884
-						break;
885
-					case L_VER:
886
-						state=F_VER;
887
-						break;
888
-					case L_PROTO:
889
-						state=F_PROTO;
890
-						break;
891
-					default:
892
-						LOG(L_ERR, "ERROR: parse_via: bad char <%c> on"
893
-								" state %d\n", *tmp, state);
894
-						goto error;
895
-				}
896
-				break;
897
-				/* match SIP*/
898
-			case 'S':
899
-			case 's':
900
-				switch(state){
901
-					case F_SIP:
902
-						state=SIP1;
903
-						break;
904
-					/* allow S in PROTO */
905
-					case F_PROTO:
906
-						proto=tmp;
907
-						state=P_PROTO;
908
-						break;
909
-					case P_PROTO:
910
-						break;
911