Browse code

- added NO_DEBUG & NO_LOG - fixed socket listen

Andrei Pelinescu-Onciul authored on 08/11/2001 05:16:56
Showing 4 changed files
... ...
@@ -21,9 +21,9 @@ NAME=ser
21 21
 # MACROEATER replaces frequently called parser helper functions
22 22
 # with macros
23 23
 # recommanded: on (speed-up)
24
-# STATS allows to print out number of packets processed on CTRL-C; implementation
25
-#  still nasty and reports per-process
26
-DEFS=-DNOCR -DMACROEATER -DSTATS
24
+# STATS allows to print out number of packets processed on CTRL-C; 
25
+# implementation still nasty and reports per-process
26
+DEFS=-DNOCR -DMACROEATER -DSTATS #-DNO_DEBUG #-DNO_LOG
27 27
 
28 28
 # platform dependent settings
29 29
 
... ...
@@ -32,7 +32,7 @@ ARCH = $(shell uname -s)
32 32
 #common
33 33
 CC=gcc
34 34
 LD=gcc
35
-CFLAGS=-O2 -Wcast-align #-Wmissing-prototypes 
35
+CFLAGS=-O3 -Wcast-align #-Wmissing-prototypes 
36 36
 LDFLAGS=-Wl,-O2 -Wl,-E
37 37
 LEX=flex
38 38
 YACC=bison
... ...
@@ -46,9 +46,15 @@ void dprint (char* format, ...);
46 46
 
47 47
 #endif
48 48
 
49
+#ifndef NO_DEBUG
50
+	#undef NO_LOG
51
+#endif
49 52
 
53
+#ifdef NO_LOG
54
+	#define LOG(lev, fmt, args...)
55
+#else
50 56
 
51
-#define LOG(lev, fmt, args...) \
57
+	#define LOG(lev, fmt, args...) \
52 58
 			do { \
53 59
 				if (debug>=(lev)){ \
54 60
 					if (log_stderr) dprint (fmt, ## args); \
... ...
@@ -79,7 +85,13 @@ void dprint (char* format, ...);
79 85
 					} \
80 86
 				} \
81 87
 			}while(0)
88
+#endif
89
+
82 90
 
83
-#define DBG(fmt, args...) LOG(L_DBG, fmt, ## args)
91
+#ifdef NO_DEBUG
92
+	#define DBG(fmt, args...)
93
+#else
94
+	#define DBG(fmt, args...) LOG(L_DBG, fmt, ## args)
95
+#endif
84 96
 
85 97
 #endif /* ifndef dprint_h */
... ...
@@ -34,7 +34,7 @@
34 34
 
35 35
 
36 36
 static char id[]="@(#) $Id$";
37
-static char version[]="ser 0.8.3";
37
+static char version[]="ser 0.8.3.1";
38 38
 static char flags[]="NOCR:"
39 39
 #ifdef NOCR
40 40
 "On"
... ...
@@ -169,12 +169,10 @@ int daemonize(char*  name)
169 169
 	}
170 170
 	
171 171
 	/* close any open file descriptors */
172
-	
173 172
 	for (r=0;r<MAX_FD; r++){
174 173
 		if ((r==3) && log_stderr)  continue;
175 174
 		close(r);
176 175
 	}
177
-	
178 176
 	return  0;
179 177
 
180 178
 error:
... ...
@@ -191,6 +189,7 @@ int main_loop()
191 189
 
192 190
 	/* one "main" process and n children handling i/o */
193 191
 
192
+
194 193
 	if (dont_fork){
195 194
 		/* only one address */
196 195
 		if (udp_init(addresses[0],port_no)==-1) goto error;
... ...
@@ -198,6 +197,8 @@ int main_loop()
198 197
 		udp_rcv_loop();
199 198
 	}else{
200 199
 		for(r=0;r<addresses_no;r++){
200
+			/* create the listening socket (for each address)*/
201
+			if (udp_init(addresses[r], port_no)==-1) goto error;
201 202
 			for(i=0;i<children_no;i++){
202 203
 				if ((pid=fork())<0){
203 204
 					LOG(L_CRIT,  "main_loop: Cannot fork\n");
... ...
@@ -205,16 +206,17 @@ int main_loop()
205 206
 				}
206 207
 				if (pid==0){
207 208
 					/* child */
208
-					if (udp_init(addresses[r], port_no)==-1) goto error;
209 209
 					return udp_rcv_loop();
210 210
 				}
211 211
 			}
212
+			close(udp_sock); /*parent*/
212 213
 		}
213 214
 	}
214 215
 		
215 216
 	for(;;){
216
-		/* debug:  instead of select */
217
-		sleep(1);
217
+		/* debug:  instead of doing something usefull */
218
+		/* (placeholder for timers, etc.) */
219
+		sleep(10);
218 220
 	}
219 221
 	
220 222
 	return 0;
... ...
@@ -26,7 +26,8 @@ enum{	         F_HOST,    P_HOST,
26 26
 				 F_IP6HOST, P_IP6HOST,
27 27
 				 F_CRLF,
28 28
 				 F_LF,
29
-				 F_CR
29
+				 F_CR,
30
+				 END_OF_HEADER
30 31
 	};
31 32
 
32 33
 /* first via part state */
... ...
@@ -37,13 +38,690 @@ enum{	         F_SIP=100,
37 38
 		L_PROTO, F_PROTO, P_PROTO
38 39
 	};
39 40
 
41
+/* param realated states */
42
+enum{	L_VALUE=200,   F_VALUE, P_VALUE, P_STRING,
43
+		HIDDEN1,   HIDDEN2,   HIDDEN3,   HIDDEN4,   HIDDEN5,
44
+		TTL1,      TTL2,
45
+		BRANCH1,   BRANCH2,   BRANCH3,   BRANCH4,   BRANCH5,
46
+		MADDR1,    MADDR2,    MADDR3,    MADDR4,
47
+		RECEIVED1, RECEIVED2, RECEIVED3, RECEIVED4, RECEIVED5, RECEIVED6,
48
+		RECEIVED7,
49
+		/* fin states (227-...)*/
50
+		FIN_HIDDEN, FIN_TTL, FIN_BRANCH, FIN_MADDR, FIN_RECEIVED,
51
+		GEN_PARAM
52
+	};
53
+
40 54
 #define LOG(lev, fmt, args...) fprintf(stderr, fmt, ## args)
41 55
 
56
+
57
+/* entry state must be F_PARAM, or saved_state=F_PARAM and 
58
+ * state=F_{LF,CR,CRLF}!
59
+ * output state = L_PARAM or F_PARAM or END_OF_HEADER 
60
+ * (and saved_state= last state); everything else => error */
61
+__inline char* parse_via_param(char* p, int* pstate, int* psaved_state)
62
+{
63
+	char* tmp;
64
+	register int state;
65
+	int saved_state;
66
+	int param_type;
67
+	char* param_name;
68
+	char* param_value;
69
+	
70
+	state=*pstate;
71
+	saved_state=*psaved_state;
72
+	param_name=param_value=0;
73
+	param_type=0;
74
+	
75
+	for (tmp=p;*tmp;tmp++){
76
+		switch(*tmp){
77
+			case ' ':
78
+			case '\t':
79
+				switch(state){
80
+					case FIN_HIDDEN:
81
+						*tmp=0;
82
+						param_type=state;
83
+						state=L_PARAM;
84
+						goto endofparam;
85
+					case FIN_BRANCH:
86
+					case FIN_TTL:
87
+					case FIN_MADDR:
88
+					case FIN_RECEIVED:
89
+						*tmp=0;
90
+						param_type=state;
91
+						state=L_VALUE;
92
+						goto find_value;
93
+					case F_PARAM:
94
+						break;
95
+					case F_LF:
96
+					case F_CR:
97
+					case F_CRLF:
98
+						state=saved_state;
99
+						break;
100
+					case GEN_PARAM:
101
+					default:
102
+						*tmp=0;
103
+						param_type=GEN_PARAM;
104
+						state=L_VALUE;
105
+						goto find_value;
106
+				}
107
+				break;
108
+			/* \n and \r*/
109
+			case '\n':
110
+				switch(state){
111
+					case FIN_HIDDEN:
112
+						*tmp=0;
113
+						param_type=state;
114
+						saved_state=L_PARAM;
115
+						state=F_LF;
116
+						goto endofparam;
117
+					case FIN_BRANCH:
118
+					case FIN_TTL:
119
+					case FIN_MADDR:
120
+					case FIN_RECEIVED:
121
+						*tmp=0;
122
+						param_type=state;
123
+						saved_state=L_VALUE;
124
+						state=F_LF;
125
+						goto find_value;
126
+					case F_PARAM:
127
+						saved_state=state;
128
+						state=F_LF;
129
+						break;
130
+					case F_LF:
131
+					case F_CRLF:
132
+						state=END_OF_HEADER;
133
+						goto end;
134
+					case F_CR:
135
+						state=F_CRLF;
136
+						break;
137
+					case GEN_PARAM:
138
+					default:
139
+						*tmp=0;
140
+						param_type=GEN_PARAM;
141
+						saved_state=L_VALUE;
142
+						state=F_LF;
143
+						goto find_value;
144
+				}
145
+				break;
146
+			case '\r':
147
+				switch(state){
148
+					case FIN_HIDDEN:
149
+						*tmp=0;
150
+						param_type=state;
151
+						saved_state=L_PARAM;
152
+						state=F_CR;
153
+						goto endofparam;
154
+					case FIN_BRANCH:
155
+					case FIN_TTL:
156
+					case FIN_MADDR:
157
+					case FIN_RECEIVED:
158
+						*tmp=0;
159
+						param_type=state;
160
+						saved_state=L_VALUE;
161
+						state=F_CR;
162
+						goto find_value;
163
+					case F_PARAM:
164
+						saved_state=state;
165
+						state=F_CR;
166
+						break;
167
+					case F_CR:
168
+					case F_CRLF:
169
+						state=END_OF_HEADER;
170
+						goto end;
171
+					case GEN_PARAM:
172
+					default:
173
+						*tmp=0;
174
+						param_type=GEN_PARAM;
175
+						saved_state=L_VALUE;
176
+						state=F_CR;
177
+						goto find_value;
178
+				}
179
+				break;
180
+
181
+			case '=':
182
+				switch(state){
183
+					case FIN_BRANCH:
184
+					case FIN_TTL:
185
+					case FIN_MADDR:
186
+					case FIN_RECEIVED:
187
+						*tmp=0;
188
+						param_type=state;
189
+						state=F_VALUE;
190
+						goto find_value;
191
+					case F_PARAM:
192
+					case FIN_HIDDEN:
193
+						LOG(L_ERR, "ERROR: parse_via: invalid char <%c> in"
194
+								" state %d\n");
195
+						goto error;
196
+					case F_CR:
197
+					case F_LF:
198
+					case F_CRLF:
199
+						state=END_OF_HEADER;
200
+						goto end;
201
+					case GEN_PARAM:
202
+					default:
203
+						*tmp=0;
204
+						param_type=GEN_PARAM;
205
+						state=F_VALUE;
206
+						goto find_value;
207
+				}
208
+				break;
209
+			case ';':
210
+				switch(state){
211
+					case FIN_HIDDEN:
212
+						*tmp=0;
213
+						param_type=state;
214
+						state=F_PARAM;
215
+						goto endofparam;
216
+					case FIN_BRANCH:
217
+					case FIN_MADDR:
218
+					case FIN_TTL:
219
+					case FIN_RECEIVED:
220
+						LOG(L_ERR, "ERROR: parse_via: invalid char <%c> in"
221
+								" state %d\n");
222
+						goto error;
223
+					case F_CR:
224
+					case F_LF:
225
+					case F_CRLF:
226
+						state=END_OF_HEADER;
227
+						goto end;
228
+					case GEN_PARAM:
229
+					default:
230
+						*tmp=0;
231
+						param_type=GEN_PARAM;
232
+						state=F_PARAM;
233
+						goto endofparam;
234
+				}
235
+				break;
236
+				
237
+				/* param names */
238
+			case 'h':
239
+			case 'H':
240
+				switch(state){
241
+					case F_PARAM:
242
+						state=HIDDEN1;
243
+						param_name=tmp;
244
+						break;
245
+					case GEN_PARAM:
246
+						break;
247
+					case F_CR:
248
+					case F_LF:
249
+					case F_CRLF:
250
+						state=END_OF_HEADER;
251
+						goto end;
252
+					default:
253
+						state=GEN_PARAM;
254
+				}
255
+				break;
256
+			case 'i':
257
+			case 'I':
258
+				switch(state){
259
+					case HIDDEN1:
260
+						state=HIDDEN2;
261
+						break;
262
+					case RECEIVED4:
263
+						state=RECEIVED5;
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 'd':
277
+			case 'D':
278
+				switch(state){
279
+					case HIDDEN2:
280
+						state=HIDDEN3;
281
+						break;
282
+					case HIDDEN3:
283
+						state=HIDDEN4;
284
+						break;
285
+					case MADDR2:
286
+						state=MADDR3;
287
+						break;
288
+					case MADDR3:
289
+						state=MADDR4;
290
+						break;
291
+					case RECEIVED7:
292
+						state=FIN_RECEIVED;
293
+						break;
294
+					case GEN_PARAM:
295
+						break;
296
+					case F_CR:
297
+					case F_LF:
298
+					case F_CRLF:
299
+						state=END_OF_HEADER;
300
+						goto end;
301
+					default:
302
+						state=GEN_PARAM;
303
+				}
304
+				break;
305
+			case 'e':
306
+			case 'E':
307
+				switch(state){
308
+					case HIDDEN4:
309
+						state=HIDDEN5;
310
+						break;
311
+					case RECEIVED1:
312
+						state=RECEIVED2;
313
+						break;
314
+					case RECEIVED3:
315
+						state=RECEIVED4;
316
+						break;
317
+					case RECEIVED6:
318
+						state=RECEIVED7;
319
+						break;
320
+					case GEN_PARAM:
321
+						break;
322
+					case F_CR:
323
+					case F_LF:
324
+					case F_CRLF:
325
+						state=END_OF_HEADER;
326
+						goto end;
327
+					default:
328
+						state=GEN_PARAM;
329
+				}
330
+				break;
331
+			case 'n':
332
+			case 'N':
333
+				switch(state){
334
+					case HIDDEN5:
335
+						state=FIN_HIDDEN;
336
+						break;
337
+					case BRANCH3:
338
+						state=BRANCH4;
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 't':
352
+			case 'T':
353
+				switch(state){
354
+					case F_PARAM:
355
+						state=TTL1;
356
+						param_name=tmp;
357
+						break;
358
+					case TTL1:
359
+						state=TTL2;
360
+						break;
361
+					case GEN_PARAM:
362
+						break;
363
+					case F_CR:
364
+					case F_LF:
365
+					case F_CRLF:
366
+						state=END_OF_HEADER;
367
+						goto end;
368
+					default:
369
+						state=GEN_PARAM;
370
+				}
371
+				break;
372
+			case 'l':
373
+			case 'L':
374
+				switch(state){
375
+					case TTL2:
376
+						state=FIN_TTL;
377
+						break;
378
+					case GEN_PARAM:
379
+						break;
380
+					case F_CR:
381
+					case F_LF:
382
+					case F_CRLF:
383
+						state=END_OF_HEADER;
384
+						goto end;
385
+					default:
386
+						state=GEN_PARAM;
387
+				}
388
+				break;
389
+			case 'm':
390
+			case 'M':
391
+				switch(state){
392
+					case F_PARAM:
393
+						state=MADDR1;
394
+						param_name=tmp;
395
+						break;
396
+					case GEN_PARAM:
397
+						break;
398
+					case F_CR:
399
+					case F_LF:
400
+					case F_CRLF:
401
+						state=END_OF_HEADER;
402
+						goto end;
403
+					default:
404
+						state=GEN_PARAM;
405
+				}
406
+				break;
407
+			case 'a':
408
+			case 'A':
409
+				switch(state){
410
+					case MADDR1:
411
+						state=MADDR2;
412
+						break;
413
+					case BRANCH2:
414
+						state=BRANCH3;
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 'r':
428
+			case 'R':
429
+				switch(state){
430
+					case MADDR4:
431
+						state=FIN_MADDR;
432
+						break;
433
+					case F_PARAM:
434
+						state=RECEIVED1;
435
+						param_name=tmp;
436
+						break;
437
+					case BRANCH1:
438
+						state=BRANCH2;
439
+						break;
440
+					case GEN_PARAM:
441
+						break;
442
+					case F_CR:
443
+					case F_LF:
444
+					case F_CRLF:
445
+						state=END_OF_HEADER;
446
+						goto end;
447
+					default:
448
+						state=GEN_PARAM;
449
+				}
450
+				break;
451
+			case 'c':
452
+			case 'C':
453
+				switch(state){
454
+					case RECEIVED2:
455
+						state=RECEIVED3;
456
+						break;
457
+					case BRANCH4:
458
+						state=BRANCH5;
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 'v':
472
+			case 'V':
473
+				switch(state){
474
+					case RECEIVED5:
475
+						state=RECEIVED6;
476
+						break;
477
+					case GEN_PARAM:
478
+						break;
479
+					case F_CR:
480
+					case F_LF:
481
+					case F_CRLF:
482
+						state=END_OF_HEADER;
483
+						goto end;
484
+					default:
485
+						state=GEN_PARAM;
486
+				}
487
+				break;
488
+			case 'b':
489
+			case 'B':
490
+				switch(state){
491
+					case F_PARAM:
492
+						state=BRANCH1;
493
+						param_name=tmp;
494
+						break;
495
+					case GEN_PARAM:
496
+						break;
497
+					case F_CR:
498
+					case F_LF:
499
+					case F_CRLF:
500
+						state=END_OF_HEADER;
501
+						goto end;
502
+					default:
503
+						state=GEN_PARAM;
504
+				}
505
+				break;
506
+
507
+			default:
508
+				switch(state){
509
+					case F_PARAM:
510
+						state=GEN_PARAM;
511
+						param_name=tmp;
512
+						break;
513
+					case  GEN_PARAM:
514
+						break;
515
+					case F_CR:
516
+					case F_LF:
517
+					case F_CRLF:
518
+						state=END_OF_HEADER;
519
+						goto end;
520
+					default:
521
+						state=GEN_PARAM;
522
+				}
523
+		}
524
+	}/* for tmp*/
525
+
526
+/* end of packet?*/
527
+saved_state=state;
528
+param_type=state;
529
+state=END_OF_HEADER;
530
+goto end;
531
+
532
+find_value:
533
+	tmp++;
534
+	for(tmp;*tmp;tmp++){
535
+		switch(*tmp){
536
+			case ' ':
537
+			case '\t':
538
+				switch(state){
539
+					case L_VALUE:
540
+					case F_VALUE: /*eat space*/
541
+						break; 
542
+					case P_VALUE:
543
+						*tmp=0;
544
+						state=L_PARAM;
545
+						goto endofvalue;
546
+					case P_STRING:
547
+						break;
548
+					case F_CR:
549
+					case F_LF:
550
+					case F_CRLF:
551
+						state=saved_state;
552
+						break;
553
+					default:
554
+						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
555
+								" in state %d\n", state);
556
+						goto error;
557
+				}
558
+				break;
559
+			case '\n':
560
+				switch(state){
561
+					case L_VALUE:
562
+					case F_VALUE: /*eat space*/
563
+					case P_STRING:
564
+						saved_state=state;
565
+						state=F_LF;
566
+						break; 
567
+					case P_VALUE:
568
+						*tmp=0;
569
+						saved_state=L_PARAM;
570
+						state=F_LF;
571
+						goto endofvalue;
572
+					case F_LF:
573
+					case F_CRLF:
574
+						state=END_OF_HEADER;
575
+						goto end;
576
+					case F_CR:
577
+						state=F_CRLF;
578
+						break;
579
+					default:
580
+						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
581
+								" in state %d\n", state);
582
+						goto error;
583
+				}
584
+				break;
585
+			case '\r':
586
+				switch(state){
587
+					case L_VALUE:
588
+					case F_VALUE: /*eat space*/
589
+					case P_STRING:
590
+						saved_state=state;
591
+						state=F_CR;
592
+						break; 
593
+					case P_VALUE:
594
+						*tmp=0;
595
+						saved_state=L_PARAM;
596
+						state=F_CR;
597
+						goto endofvalue;
598
+					case F_LF:
599
+					case F_CR:
600
+					case F_CRLF:
601
+						state=END_OF_HEADER;
602
+						goto end;
603
+					default:
604
+						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
605
+								" in state %d\n", state);
606
+						goto error;
607
+				}
608
+				break;
609
+
610
+			case '=':
611
+				switch(state){
612
+					case L_VALUE:
613
+						state=F_VALUE;
614
+						break;
615
+					case P_STRING:
616
+						break;
617
+					case F_LF:
618
+					case F_CR:
619
+					case F_CRLF:
620
+						state=END_OF_HEADER;
621
+						goto end;
622
+					default:
623
+						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
624
+								" in state %d\n", state);
625
+						goto error;
626
+				}
627
+				break;
628
+			case ';':
629
+				switch(state){
630
+					case P_VALUE:
631
+						*tmp=0;
632
+						state=F_PARAM;
633
+						goto endofvalue;
634
+					case P_STRING:
635
+						break; /* what to do? */
636
+					case F_LF:
637
+					case F_CR:
638
+					case F_CRLF:
639
+						state=END_OF_HEADER;
640
+						goto end;
641
+					default:
642
+						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
643
+								" in state %d\n", state);
644
+						goto error;
645
+				}
646
+				break;
647
+			
648
+			case '"':
649
+				switch(state){
650
+					case F_VALUE:
651
+						state=P_STRING;
652
+						param_value=tmp+1;
653
+						break;
654
+					case P_STRING:
655
+						*tmp=0;
656
+						state=L_PARAM;
657
+						goto endofvalue;
658
+					case F_LF:
659
+					case F_CR:
660
+					case F_CRLF:
661
+						state=END_OF_HEADER;
662
+						goto end;
663
+					default:
664
+						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
665
+								" in state %d\n", state);
666
+						goto error;
667
+				}
668
+				break;
669
+			default:
670
+				switch(state){
671
+					case F_VALUE:
672
+						state=P_VALUE;
673
+						param_value=tmp;
674
+						break;
675
+					case P_VALUE:
676
+					case P_STRING:
677
+						break;
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
+		}
689
+	} /* for2 tmp*/
690
+
691
+	/* if generic_param => it can have no value */
692
+	if ((state==L_VALUE)&&(param_type==GEN_PARAM)) state=L_PARAM;
693
+	saved_state=state;
694
+	state=END_OF_HEADER;
695
+	goto end;
696
+
697
+endofparam:
698
+endofvalue:
699
+	printf("end, tmp=%x, <%c>\n", tmp, *tmp);
700
+	//tmp++;
701
+end:
702
+	*pstate=state;
703
+	*psaved_state=saved_state;
704
+	printf("Found param type %d, <%s> = <%s>\n", param_type, param_name,
705
+			param_value);
706
+	return tmp;
707
+
708
+error:
709
+	fprintf(stderr,"error: via_parse_param\n");
710
+	*pstate=state;
711
+	*psaved_state=saved_state;
712
+	return tmp;
713
+}
714
+
715
+
716
+
717
+
718
+
719
+
42 720
 int main(int argc, char** argv)
43 721
 {
44 722
 
45 723
 	char* tmp;
46
-	register int state;
724
+	int state;
47 725
 	int saved_state;
48 726
 	int c_nest;
49 727
 	int i;
... ...
@@ -779,8 +1457,25 @@ main_via:
779 1457
 						/*check if number?*/
780 1458
 						break;
781 1459
 					case F_PARAM:
782
-						state=P_PARAM;
1460
+						/*state=P_PARAM*/;
783 1461
 						param=tmp;
1462
+						tmp=parse_via_param(tmp, &state, &saved_state);
1463
+						switch(state){
1464
+							case L_PARAM:
1465
+							case F_PARAM:
1466
+							case F_LF:
1467
+							case F_CR:
1468
+								break;
1469
+							case END_OF_HEADER:
1470
+								state=saved_state;
1471
+								goto endofheader;
1472
+							default:
1473
+								LOG(L_ERR, "ERROR: parse_via after"
1474
+										" parse_via_param: invalid"
1475
+										" char <%c> on state %d\n",
1476
+										*tmp, state);
1477
+								goto error;
1478
+						}
784 1479
 						break;
785 1480
 					case P_PARAM:
786 1481
 						break;
... ...
@@ -839,6 +1534,9 @@ endofpacket:
839 1534
 		case P_PORT:
840 1535
 		case L_PARAM:
841 1536
 		case P_PARAM:
1537
+		case P_VALUE:
1538
+		case GEN_PARAM:
1539
+		case FIN_HIDDEN:
842 1540
 		case L_VIA:
843 1541
 			break;
844 1542
 		default:
... ...
@@ -848,7 +1546,7 @@ endofpacket:
848 1546
 	}
849 1547
 		
850 1548
 nextvia:
851
-	if (proto) printf("<SIP/2.0/%s<\n", proto);
1549
+	if (proto) printf("<SIP/2.0/%s>\n", proto);
852 1550
 	if (host) printf("host= <%s>\n", host);
853 1551
 	if (port_str) printf("port= <%s>\n", port_str);
854 1552
 	if (param) printf("params= <%s>\n", param);