Browse code

- changed parse_headers api, HDR_xxx split into HDR_xxx_F (hdr_flags_t) and HDR_xxx_T (hdr_types_t), for more info read doc/parse_headers.txt. The header flags were extended top 64 bits. Be carefull not to mix types with flags, they won't work!

Andrei Pelinescu-Onciul authored on 23/02/2005 17:16:01
Showing 56 changed files
... ...
@@ -53,7 +53,7 @@ MAIN_NAME=ser
53 53
 VERSION = 0
54 54
 PATCHLEVEL = 10
55 55
 SUBLEVEL =   99
56
-EXTRAVERSION = -dev0
56
+EXTRAVERSION = -dev1
57 57
 
58 58
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
59 59
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
60 60
new file mode 100644
... ...
@@ -0,0 +1,26 @@
0
+# $Id$
1
+#
2
+# parse headers api changes
3
+#
4
+# 2004.02.23  created (andrei)
5
+
6
+
7
+Starting with the ser version 0.10.99-dev1, the parse headers api has been slighlty changed. The reason for this change was performance improvement (now gcc can optimze much better all the switches involving header types) and dramatically reducing the memory impact of switching to 64 bits flags.
8
+
9
+The header flags (HDR_xxx) have been split into header types (hdr_types_t) and header flags (hdr_flags_t). Instead of the old HDR_xxx use now HDR_xxx_T when the header type is required and HDR_xxx_F or HDR_T2F(HDR_xxx_T) when the corresponding header flag is needed (e.g. in the parse_headers() call).
10
+
11
+The hdr_field structure and the parse_headers() function have also been changed. struct hdr_field's type member is now a hdr_types_t instead of an int and the flags parameter of parse_headers is now a hdr_flags_t.
12
+
13
+The change affects also the lump types for header operations. For example instead of del_lump( msg, via_offset, via_len, HDR_VIA) use del_lump( msg, via_offset, via_len, HDR_VIA_T).
14
+
15
+WARNING: don't use a header type (HDR_xxx_T) where a header flag (HDR_xxx_F) is expected or viceversa!
16
+
17
+Examples:
18
+
19
+An old call to parse_headers(msg, HDR_FOO, 0) will become parse_header(msg, HDR_FOO_F, 0).
20
+
21
+An old loop searching for a header field:
22
+	while(hdr && (hdr->type!=HDR_FOO)) hdr=hdr->next;
23
+will become:
24
+	while (hdr && (hdr->type!=HDR_FOO_T)) hdr=hdr->next;
25
+.
... ...
@@ -463,7 +463,7 @@ int forward_reply(struct sip_msg* msg)
463 463
 	}
464 464
 
465 465
 	/* we have to forward the reply stateless, so we need second via -bogdan*/
466
-	if (parse_headers( msg, HDR_VIA2, 0 )==-1 
466
+	if (parse_headers( msg, HDR_VIA2_F, 0 )==-1 
467 467
 		|| (msg->via2==0) || (msg->via2->error!=PARSE_OK))
468 468
 	{
469 469
 		/* no second via => error */
... ...
@@ -313,7 +313,7 @@ static inline int get_route_set(struct sip_msg* _m, rr_t** _rs, unsigned char _o
313 313
 
314 314
 	ptr = _m->record_route;
315 315
 	while(ptr) {
316
-		if (ptr->type == HDR_RECORDROUTE) {
316
+		if (ptr->type == HDR_RECORDROUTE_T) {
317 317
 			if (parse_rr(ptr) < 0) {
318 318
 				LOG(L_ERR, "get_route_set(): Error while parsing Record-Route body\n");
319 319
 				goto error;
... ...
@@ -358,7 +358,7 @@ static inline int response2dlg(struct sip_msg* _m, dlg_t* _d)
358 358
 	str contact, rtag;
359 359
 
360 360
 	     /* Parse the whole message, we will need all Record-Route headers */
361
-	if (parse_headers(_m, HDR_EOH, 0) == -1) {
361
+	if (parse_headers(_m, HDR_EOH_F, 0) == -1) {
362 362
 		LOG(L_ERR, "response2dlg(): Error while parsing headers\n");
363 363
 		return -1;
364 364
 	}
... ...
@@ -478,7 +478,7 @@ static inline int dlg_early_resp_uac(dlg_t* _d, struct sip_msg* _m)
478 478
  */
479 479
 static inline int get_cseq_method(struct sip_msg* _m, str* _method)
480 480
 {
481
-	if (!_m->cseq && ((parse_headers(_m, HDR_CSEQ, 0) == -1) || !_m->cseq)) {
481
+	if (!_m->cseq && ((parse_headers(_m, HDR_CSEQ_F, 0) == -1) || !_m->cseq)) {
482 482
 		LOG(L_ERR, "get_cseq_method(): Error while parsing CSeq\n");
483 483
 		return -1;
484 484
 	}
... ...
@@ -526,7 +526,7 @@ static inline int dlg_confirmed_resp_uac(dlg_t* _d, struct sip_msg* _m)
526 526
 	if (get_cseq_method(_m, &method) < 0) return -1;
527 527
 	if ((method.len == 6) && !memcmp("INVITE", method.s, 6)) {
528 528
 		     /* Get contact if any and update remote target */
529
-		if (parse_headers(_m, HDR_CONTACT, 0) == -1) {
529
+		if (parse_headers(_m, HDR_CONTACT_F, 0) == -1) {
530 530
 			LOG(L_ERR, "dlg_confirmed_resp_uac(): Error while parsing headers\n");
531 531
 			return -2;
532 532
 		}
... ...
@@ -674,7 +674,7 @@ static inline int request2dlg(struct sip_msg* _m, dlg_t* _d)
674 674
 {
675 675
 	str contact, rtag, callid;
676 676
 
677
-	if (parse_headers(_m, HDR_EOH, 0) == -1) {
677
+	if (parse_headers(_m, HDR_EOH_F, 0) == -1) {
678 678
 		LOG(L_ERR, "request2dlg(): Error while parsing headers");
679 679
 		return -1;
680 680
 	}
... ...
@@ -789,7 +789,7 @@ int dlg_request_uas(dlg_t* _d, struct sip_msg* _m)
789 789
 	     /* We must check if the request is not out of order or retransmission
790 790
 	      * first, if so then we will not update anything
791 791
 	      */
792
-	if (parse_headers(_m, HDR_CSEQ, 0) == -1) {
792
+	if (parse_headers(_m, HDR_CSEQ_F, 0) == -1) {
793 793
 		LOG(L_ERR, "dlg_request_uas(): Error while parsing headers\n");
794 794
 		return -2;
795 795
 	}
... ...
@@ -805,7 +805,7 @@ int dlg_request_uas(dlg_t* _d, struct sip_msg* _m)
805 805
 	      */
806 806
 	if (_m->first_line.u.request.method_value == METHOD_INVITE) {
807 807
 		     /* target refresher */
808
-		if (parse_headers(_m, HDR_CONTACT, 0) == -1) {
808
+		if (parse_headers(_m, HDR_CONTACT_F, 0) == -1) {
809 809
 			LOG(L_ERR, "dlg_request_uas(): Error while parsing headers\n");
810 810
 			return -4;
811 811
 		}
... ...
@@ -66,7 +66,7 @@ inline static void free_via_clen_lump( struct lump **list )
66 66
 	prev_lump=0;
67 67
 	for(lump=*list;lump;lump=next) {
68 68
 		next=lump->next;
69
-		if (lump->type==HDR_VIA||lump->type==HDR_CONTENTLENGTH) {
69
+		if (lump->type==HDR_VIA_T||lump->type==HDR_CONTENTLENGTH_T) {
70 70
 			a=lump->before;
71 71
 			while(a) {
72 72
 				foo=a; a=a->before;
... ...
@@ -293,7 +293,7 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len )
293 293
 		len += ROUND4(sizeof( struct hdr_field));
294 294
 		switch (hdr->type)
295 295
 		{
296
-			case HDR_VIA:
296
+			case HDR_VIA_T:
297 297
 				for (via=(struct via_body*)hdr->parsed;via;via=via->next)
298 298
 				{
299 299
 					len+=ROUND4(sizeof(struct via_body));
... ...
@@ -303,8 +303,8 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len )
303 303
 				}
304 304
 				break;
305 305
 
306
-			case HDR_TO:
307
-			case HDR_FROM:
306
+			case HDR_TO_T:
307
+			case HDR_FROM_T:
308 308
 				/* From header might be unparsed */
309 309
 				if (hdr->parsed) {
310 310
 					len+=ROUND4(sizeof(struct to_body));
... ...
@@ -315,43 +315,42 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len )
315 315
 				}
316 316
 				break;
317 317
 
318
-			case HDR_CSEQ:
318
+			case HDR_CSEQ_T:
319 319
 				len+=ROUND4(sizeof(struct cseq_body));
320 320
 				break;
321 321
 
322 322
 
323
-			case HDR_AUTHORIZATION:
324
-			case HDR_PROXYAUTH:
323
+			case HDR_AUTHORIZATION_T:
324
+			case HDR_PROXYAUTH_T:
325 325
 				if (hdr->parsed) {
326 326
 					len += ROUND4(AUTH_BODY_SIZE);
327 327
 				}
328 328
 				break;
329 329
 
330
-			case HDR_CALLID:
331
-			case HDR_CONTACT:
332
-			case HDR_MAXFORWARDS:
333
-			case HDR_ROUTE:
334
-			case HDR_RECORDROUTE:
335
-			case HDR_CONTENTTYPE:
336
-			case HDR_CONTENTLENGTH:
337
-			case HDR_EXPIRES:
338
-			case HDR_SUPPORTED:
339
-			case HDR_PROXYREQUIRE:
340
-			case HDR_UNSUPPORTED:
341
-			case HDR_ALLOW:
342
-			case HDR_EVENT:
343
-			case HDR_ACCEPT:
344
-			case HDR_ACCEPTLANGUAGE:
345
-			case HDR_ORGANIZATION:
346
-			case HDR_PRIORITY:
347
-			case HDR_SUBJECT:
348
-			case HDR_USERAGENT:
349
-			case HDR_ACCEPTDISPOSITION:
350
-			case HDR_CONTENTDISPOSITION:
351
-		        case HDR_DIVERSION:
352
-		        case HDR_RPID:
353
-		        case HDR_REFER_TO:
354
-
330
+			case HDR_CALLID_T:
331
+			case HDR_CONTACT_T:
332
+			case HDR_MAXFORWARDS_T:
333
+			case HDR_ROUTE_T:
334
+			case HDR_RECORDROUTE_T:
335
+			case HDR_CONTENTTYPE_T:
336
+			case HDR_CONTENTLENGTH_T:
337
+			case HDR_EXPIRES_T:
338
+			case HDR_SUPPORTED_T:
339
+			case HDR_PROXYREQUIRE_T:
340
+			case HDR_UNSUPPORTED_T:
341
+			case HDR_ALLOW_T:
342
+			case HDR_EVENT_T:
343
+			case HDR_ACCEPT_T:
344
+			case HDR_ACCEPTLANGUAGE_T:
345
+			case HDR_ORGANIZATION_T:
346
+			case HDR_PRIORITY_T:
347
+			case HDR_SUBJECT_T:
348
+			case HDR_USERAGENT_T:
349
+			case HDR_ACCEPTDISPOSITION_T:
350
+			case HDR_CONTENTDISPOSITION_T:
351
+			case HDR_DIVERSION_T:
352
+			case HDR_RPID_T:
353
+			case HDR_REFER_TO_T:
355 354
 				/* we ignore them for now even if they have something parsed*/
356 355
 				break;
357 356
 
... ...
@@ -477,7 +476,7 @@ do { \
477 477
 
478 478
 		switch (hdr->type)
479 479
 		{
480
-			case HDR_VIA:
480
+			case HDR_VIA_T:
481 481
 				/*fprintf(stderr,"prepare to clone via |%.*s|\n",
482 482
 					via_len((struct via_body*)hdr->parsed),
483 483
 					via_s((struct via_body*)hdr->parsed,org_msg));*/
... ...
@@ -511,7 +510,7 @@ do { \
511 511
 						(struct via_body*)hdr->parsed , &p);
512 512
 				}
513 513
 				break;
514
-			case HDR_CSEQ:
514
+			case HDR_CSEQ_T:
515 515
 				new_hdr->parsed = p;
516 516
 				p +=ROUND4(sizeof(struct cseq_body));
517 517
 				memcpy(new_hdr->parsed, hdr->parsed, sizeof(struct cseq_body));
... ...
@@ -523,9 +522,9 @@ do { \
523 523
 					((struct cseq_body*)hdr->parsed)->method.s );
524 524
 				new_msg->cseq = new_hdr;
525 525
 				break;
526
-			case HDR_TO:
527
-			case HDR_FROM:
528
-				if (hdr->type == HDR_TO) {
526
+			case HDR_TO_T:
527
+			case HDR_FROM_T:
528
+				if (hdr->type == HDR_TO_T) {
529 529
 					new_msg->to = new_hdr;
530 530
 				} else {
531 531
 					new_msg->from = new_hdr;
... ...
@@ -570,85 +569,88 @@ do { \
570 570
 						= new_to_prm;
571 571
 				}
572 572
 				break;
573
-			case HDR_CALLID:
573
+			case HDR_CALLID_T:
574 574
 				new_msg->callid = new_hdr;
575 575
 				break;
576
-			case HDR_CONTACT:
576
+			case HDR_CONTACT_T:
577 577
 				new_msg->contact = new_hdr;
578 578
 				break;
579
-			case HDR_MAXFORWARDS :
579
+			case HDR_MAXFORWARDS_T:
580 580
 				new_msg->maxforwards = new_hdr;
581 581
 				break;
582
-			case HDR_ROUTE :
582
+			case HDR_ROUTE_T:
583 583
 				new_msg->route = new_hdr;
584 584
 				break;
585
-			case HDR_RECORDROUTE :
585
+			case HDR_RECORDROUTE_T:
586 586
 				new_msg->record_route = new_hdr;
587 587
 				break;
588
-			case HDR_CONTENTTYPE :
588
+			case HDR_CONTENTTYPE_T:
589 589
 				new_msg->content_type = new_hdr;
590 590
 				new_msg->content_type->parsed = hdr->parsed;
591 591
 				break;
592
-			case HDR_CONTENTLENGTH :
592
+			case HDR_CONTENTLENGTH_T:
593 593
 				new_msg->content_length = new_hdr;
594 594
 				new_msg->content_length->parsed = hdr->parsed;
595 595
 				break;
596
-			case HDR_AUTHORIZATION :
596
+			case HDR_AUTHORIZATION_T:
597 597
 				new_msg->authorization = new_hdr;
598 598
 				if (hdr->parsed) {
599 599
 					new_hdr->parsed = auth_body_cloner(new_msg->buf ,
600 600
 						org_msg->buf , (struct auth_body*)hdr->parsed , &p);
601 601
 				}
602 602
 				break;
603
-			case HDR_EXPIRES :
603
+			case HDR_EXPIRES_T:
604 604
 				new_msg->expires = new_hdr;
605 605
 				break;
606
-			case HDR_PROXYAUTH :
606
+			case HDR_PROXYAUTH_T:
607 607
 				new_msg->proxy_auth = new_hdr;
608 608
 				if (hdr->parsed) {
609 609
 					new_hdr->parsed = auth_body_cloner(new_msg->buf ,
610 610
 						org_msg->buf , (struct auth_body*)hdr->parsed , &p);
611 611
 				}
612 612
 				break;
613
-			case HDR_SUPPORTED :
613
+			case HDR_SUPPORTED_T:
614 614
 				new_msg->supported = new_hdr;
615 615
 				break;
616
-			case HDR_PROXYREQUIRE :
616
+			case HDR_PROXYREQUIRE_T:
617 617
 				new_msg->proxy_require = new_hdr;
618 618
 				break;
619
-			case HDR_UNSUPPORTED :
619
+			case HDR_UNSUPPORTED_T:
620 620
 				new_msg->unsupported = new_hdr;
621 621
 				break;
622
-			case HDR_ALLOW :
622
+			case HDR_ALLOW_T:
623 623
 				new_msg->allow = new_hdr;	
624 624
 				break;
625
-			case HDR_EVENT:
625
+			case HDR_EVENT_T:
626 626
 				new_msg->event = new_hdr;
627 627
 				break;
628
-			case HDR_ACCEPT:
628
+			case HDR_ACCEPT_T:
629 629
 				new_msg->accept = new_hdr;
630 630
 				break;
631
-			case HDR_ACCEPTLANGUAGE:
631
+			case HDR_ACCEPTLANGUAGE_T:
632 632
 				new_msg->accept_language = new_hdr;
633 633
 				break;
634
-			case HDR_ORGANIZATION:
634
+			case HDR_ORGANIZATION_T:
635 635
 				new_msg->organization = new_hdr;
636 636
 				break;
637
-			case HDR_PRIORITY:
637
+			case HDR_PRIORITY_T:
638 638
 				new_msg->priority = new_hdr;
639 639
 				break;
640
-			case HDR_SUBJECT:
640
+			case HDR_SUBJECT_T:
641 641
 				new_msg->subject = new_hdr;
642 642
 				break;
643
-			case HDR_USERAGENT:
643
+			case HDR_USERAGENT_T:
644 644
 				new_msg->user_agent = new_hdr;
645 645
 				break;
646
-			case HDR_ACCEPTDISPOSITION:
646
+			case HDR_ACCEPTDISPOSITION_T:
647 647
 				new_msg->accept_disposition = new_hdr;
648 648
 				break;
649
-			case HDR_CONTENTDISPOSITION:
649
+			case HDR_CONTENTDISPOSITION_T:
650 650
 				new_msg->content_disposition = new_hdr;
651 651
 				break;
652
+			default:
653
+				/* ignore the rest*/
654
+				;
652 655
 		}/*switch*/
653 656
 
654 657
 		if ( last_hdr )
... ...
@@ -354,7 +354,7 @@ int parse_tw_append( modparam_t type, void* val)
354 354
 			}
355 355
 			foo.s[foo.len] = bar;
356 356
 			ha->ival = hdr.type;
357
-			if (hdr.type==HDR_OTHER || ha->title.s==0) {
357
+			if (hdr.type==HDR_OTHER_T || ha->title.s==0) {
358 358
 				/* duplicate hdr name */
359 359
 				ha->sval.s = (char*)pkg_malloc(foo.len+1);
360 360
 				if (ha->sval.s==0) {
... ...
@@ -615,14 +615,14 @@ static inline char* append2buf( char *buf, int len, struct sip_msg *req,
615 615
 		} else if (ha->type==ELEM_IS_HDR) {
616 616
 			/* parse the HDRs */
617 617
 			if (!msg_parsed) {
618
-				if (parse_headers( req, HDR_EOH, 0)!=0) {
618
+				if (parse_headers( req, HDR_EOH_F, 0)!=0) {
619 619
 					LOG(L_ERR,"ERROR:tm:append2buf: parsing hdrs failed\n");
620 620
 					goto error;
621 621
 				}
622 622
 				msg_parsed = 1;
623 623
 			}
624 624
 			/* search the HDR */
625
-			if (ha->ival==HDR_OTHER) {
625
+			if (ha->ival==HDR_OTHER_T) {
626 626
 				for(hdr=req->headers;hdr;hdr=hdr->next)
627 627
 					if (ha->sval.len==hdr->name.len &&
628 628
 					strncasecmp( ha->sval.s, hdr->name.s, hdr->name.len)==0)
... ...
@@ -680,7 +680,7 @@ static int assemble_msg(struct sip_msg* msg, struct tw_info *twi)
680 680
 	}
681 681
 
682 682
 	/* parse all -- we will need every header field for a UAS */
683
-	if ( parse_headers(msg, HDR_EOH, 0)==-1) {
683
+	if ( parse_headers(msg, HDR_EOH_F, 0)==-1) {
684 684
 		LOG(L_ERR,"assemble_msg: parse_headers failed\n");
685 685
 		goto error;
686 686
 	}
... ...
@@ -770,7 +770,7 @@ static int assemble_msg(struct sip_msg* msg, struct tw_info *twi)
770 770
 		}
771 771
 		for(p_hdr = p_hdr->next;p_hdr;p_hdr = p_hdr->next) {
772 772
 			/* filter out non-RR hdr and empty hdrs */
773
-			if( (p_hdr->type!=HDR_RECORDROUTE) || p_hdr->body.len==0)
773
+			if( (p_hdr->type!=HDR_RECORDROUTE_T) || p_hdr->body.len==0)
774 774
 				continue;
775 775
 
776 776
 			if(p_hdr->parsed==0 && parse_rr(p_hdr)!=0 ){
... ...
@@ -63,10 +63,10 @@
63 63
 
64 64
 /* fr_timer AVP specs */
65 65
 static int     fr_timer_avp_type = 0;
66
-static int_str fr_timer_avp = (int_str)0;
66
+static int_str fr_timer_avp = {0};
67 67
 static str     fr_timer_str;
68 68
 static int     fr_inv_timer_avp_type = 0;
69
-static int_str fr_inv_timer_avp = (int_str)0;
69
+static int_str fr_inv_timer_avp = {0};
70 70
 static str     fr_inv_timer_str;
71 71
 
72 72
 
... ...
@@ -163,7 +163,7 @@ void init_t() {global_msg_id=0; set_t(T_UNDEFINED);}
163 163
 
164 164
 static inline int parse_dlg( struct sip_msg *msg )
165 165
 {
166
-	if (parse_headers(msg, HDR_FROM | HDR_CSEQ | HDR_TO, 0)==-1) {
166
+	if (parse_headers(msg, HDR_FROM_F | HDR_CSEQ_F | HDR_TO_F, 0)==-1) {
167 167
 		LOG(L_ERR, "ERROR: parse_dlg: From or Cseq or To invalid\n");
168 168
 		return 0;
169 169
 	}
... ...
@@ -800,7 +800,7 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch )
800 800
 				has_tran_tmcbs(p_cell,TMCB_RESPONSE_OUT|TMCB_E2EACK_IN) )
801 801
 			|| (is_local(p_cell)&&has_tran_tmcbs(p_cell,TMCB_LOCAL_COMPLETED))
802 802
 		)) {
803
-			if (parse_headers(p_msg, HDR_TO, 0)==-1) {
803
+			if (parse_headers(p_msg, HDR_TO_F, 0)==-1) {
804 804
 				LOG(L_ERR, "ERROR: t_reply_matching: to parsing failed\n");
805 805
 			}
806 806
 		}
... ...
@@ -845,7 +845,7 @@ int t_check( struct sip_msg* p_msg , int *param_branch )
845 845
 		/* transaction lookup */
846 846
 		if ( p_msg->first_line.type==SIP_REQUEST ) {
847 847
 			/* force parsing all the needed headers*/
848
-			if (parse_headers(p_msg, HDR_EOH, 0 )==-1) {
848
+			if (parse_headers(p_msg, HDR_EOH_F, 0 )==-1) {
849 849
 				LOG(L_ERR, "ERROR: t_check: parsing error\n");
850 850
 				return -1;
851 851
 			}
... ...
@@ -864,7 +864,7 @@ int t_check( struct sip_msg* p_msg , int *param_branch )
864 864
 			/* we need Via for branch and Cseq method to distinguish
865 865
 			   replies with the same branch/cseqNr (CANCEL)
866 866
 			*/
867
-			if ( parse_headers(p_msg, HDR_VIA1|HDR_CSEQ, 0 )==-1
867
+			if ( parse_headers(p_msg, HDR_VIA1_F|HDR_CSEQ_F, 0 )==-1
868 868
 			|| !p_msg->via1 || !p_msg->cseq ) {
869 869
 				LOG(L_ERR, "ERROR: reply cannot be parsed\n");
870 870
 				return -1;
... ...
@@ -875,7 +875,7 @@ int t_check( struct sip_msg* p_msg , int *param_branch )
875 875
 			*/
876 876
             if ( get_cseq(p_msg)->method.len==INVITE_LEN 
877 877
 				&& memcmp( get_cseq(p_msg)->method.s, INVITE, INVITE_LEN )==0 ) {
878
-					if (parse_headers(p_msg, HDR_TO, 0)==-1
878
+					if (parse_headers(p_msg, HDR_TO_F, 0)==-1
879 879
 						|| !p_msg->to)  {
880 880
 						LOG(L_ERR, "ERROR: INVITE reply cannot be parsed\n");
881 881
 						return -1;
... ...
@@ -1038,11 +1038,11 @@ int t_newtran( struct sip_msg* p_msg )
1038 1038
 	   shmem with pkg_mem
1039 1039
 	*/
1040 1040
 	
1041
-	if (parse_headers(p_msg, HDR_EOH, 0 )) {
1041
+	if (parse_headers(p_msg, HDR_EOH_F, 0 )) {
1042 1042
 		LOG(L_ERR, "ERROR: t_newtran: parse_headers failed\n");
1043 1043
 		return E_BAD_REQ;
1044 1044
 	}
1045
-	if ((p_msg->parsed_flag & HDR_EOH)!=HDR_EOH) {
1045
+	if ((p_msg->parsed_flag & HDR_EOH_F)!=HDR_EOH_F) {
1046 1046
 			LOG(L_ERR, "ERROR: t_newtran: EoH not parsed\n");
1047 1047
 			return E_OUT_OF_MEM;
1048 1048
 	}
... ...
@@ -126,7 +126,7 @@ char *build_local(struct cell *Trans,unsigned int branch,
126 126
 	/* copy'n'paste Route headers */
127 127
 	if (!is_local(Trans)) {
128 128
 		for ( hdr=Trans->uas.request->headers ; hdr ; hdr=hdr->next )
129
-			 if (hdr->type==HDR_ROUTE)
129
+			 if (hdr->type==HDR_ROUTE_T)
130 130
 				*len+=hdr->len;
131 131
 	}
132 132
 
... ...
@@ -165,7 +165,7 @@ char *build_local(struct cell *Trans,unsigned int branch,
165 165
 
166 166
 	if (!is_local(Trans))  {
167 167
 		for ( hdr=Trans->uas.request->headers ; hdr ; hdr=hdr->next )
168
-			if(hdr->type==HDR_ROUTE) {
168
+			if(hdr->type==HDR_ROUTE_T) {
169 169
 				append_mem_block(p, hdr->name.s, hdr->len );
170 170
 			}
171 171
 	}
... ...
@@ -216,7 +216,7 @@ static inline int process_routeset(struct sip_msg* msg, str* contact, struct rte
216 216
 	ptr = msg->record_route;
217 217
 	head = 0;
218 218
 	while(ptr) {
219
-		if (ptr->type == HDR_RECORDROUTE) {
219
+		if (ptr->type == HDR_RECORDROUTE_T) {
220 220
 			if (parse_rr(ptr) < 0) {
221 221
 				LOG(L_ERR, "process_routeset: Error while parsing Record-Route header\n");
222 222
 				return -1;
... ...
@@ -179,7 +179,7 @@ int unmatched_totag(struct cell *t, struct sip_msg *ack)
179 179
 	struct totag_elem *i;
180 180
 	str *tag;
181 181
 
182
-	if (parse_headers(ack, HDR_TO,0)==-1 || 
182
+	if (parse_headers(ack, HDR_TO_F,0)==-1 || 
183 183
 				!ack->to ) {
184 184
 		LOG(L_ERR, "ERROR: unmatched_totag: To invalid\n");
185 185
 		return 1;
... ...
@@ -273,7 +273,7 @@ static char *build_ack(struct sip_msg* rpl,struct cell *trans,int branch,
273 273
 {
274 274
 	str to;
275 275
 
276
-    if (parse_headers(rpl,HDR_TO, 0)==-1 || !rpl->to ) {
276
+    if (parse_headers(rpl,HDR_TO_F, 0)==-1 || !rpl->to ) {
277 277
         LOG(L_ERR, "ERROR: build_ack: "
278 278
             "cannot generate a HBH ACK if key HFs in reply missing\n");
279 279
         return NULL;
... ...
@@ -294,7 +294,7 @@ static char *build_local_ack(struct sip_msg* rpl, struct cell *trans, int branch
294 294
 			     unsigned int *ret_len, str* next_hop)
295 295
 {
296 296
 	str to;
297
-	if (parse_headers(rpl, HDR_EOH, 0) == -1 || !rpl->to) {
297
+	if (parse_headers(rpl, HDR_EOH_F, 0) == -1 || !rpl->to) {
298 298
 		LOG(L_ERR, "ERROR: build_local_ack: Error while parsing headers\n");
299 299
 		return 0;
300 300
 	}
... ...
@@ -65,10 +65,10 @@ struct str_list {
65 65
 
66 66
 
67 67
 #define skip_hf(_hf) (             \
68
-    ((_hf)->type == HDR_FROM)   || \
69
-    ((_hf)->type == HDR_TO)     || \
70
-    ((_hf)->type == HDR_CALLID) || \
71
-    ((_hf)->type == HDR_CSEQ)      \
68
+    ((_hf)->type == HDR_FROM_T)   || \
69
+    ((_hf)->type == HDR_TO_T)     || \
70
+    ((_hf)->type == HDR_CALLID_T) || \
71
+    ((_hf)->type == HDR_CSEQ_T)      \
72 72
 )
73 73
 
74 74
 
... ...
@@ -595,7 +595,7 @@ int fifo_uac(FILE *stream, char *response_file)
595 595
 	memset(&faked_msg, 0, sizeof(struct sip_msg));
596 596
 	faked_msg.len = headers.len; 
597 597
 	faked_msg.buf = faked_msg.unparsed = headers.s;
598
-	if (parse_headers(&faked_msg, HDR_EOH, 0) == -1 ) {
598
+	if (parse_headers(&faked_msg, HDR_EOH_F, 0) == -1 ) {
599 599
 		DBG("DEBUG: fifo_uac: parse_headers failed\n");
600 600
 		fifo_uac_error(response_file, 400, "HFs unparseable");
601 601
 		goto error;
... ...
@@ -52,10 +52,10 @@ struct str_list {
52 52
 
53 53
 
54 54
 #define skip_hf(_hf) (             \
55
-    ((_hf)->type == HDR_FROM)   || \
56
-    ((_hf)->type == HDR_TO)     || \
57
-    ((_hf)->type == HDR_CALLID) || \
58
-    ((_hf)->type == HDR_CSEQ)      \
55
+    ((_hf)->type == HDR_FROM_T)   || \
56
+    ((_hf)->type == HDR_TO_T)     || \
57
+    ((_hf)->type == HDR_CALLID_T) || \
58
+    ((_hf)->type == HDR_CSEQ_T)      \
59 59
 )
60 60
 
61 61
 
... ...
@@ -504,7 +504,7 @@ int unixsock_uac(str* msg)
504 504
 	memset(&faked_msg, 0, sizeof(struct sip_msg));
505 505
 	faked_msg.len = headers.len; 
506 506
 	faked_msg.buf = faked_msg.unparsed = headers.s;
507
-	if (parse_headers(&faked_msg, HDR_EOH, 0) == -1 ) {
507
+	if (parse_headers(&faked_msg, HDR_EOH_F, 0) == -1 ) {
508 508
 		unixsock_reply_asciiz("400 HFs unparsable\n");
509 509
 		unixsock_reply_send();
510 510
 		goto error;
... ...
@@ -288,7 +288,8 @@ static char * warning_builder( struct sip_msg *msg, unsigned int *returned_len)
288 288
 	str_pair_print(" in_uri=", msg->first_line.u.request.uri.s,
289 289
 								msg->first_line.u.request.uri.len);
290 290
 	str_pair_print(" out_uri=", foo->s, foo->len);
291
-	str_pair_print(" via_cnt", msg->parsed_flag & HDR_EOH ? "=" : ">", 1);
291
+	str_pair_print(" via_cnt",
292
+					(msg->parsed_flag & HDR_EOH_F)==HDR_EOH_F ? "=" : ">", 1);
292 293
 	str_int_print("=", via_cnt);
293 294
 	if (clen<MAX_WARNING_LEN){ buf[clen]='"'; clen++; }
294 295
 	else goto error_overflow;
... ...
@@ -1208,7 +1209,7 @@ static inline int adjust_clen(struct sip_msg* msg, int body_delta, int proto)
1208 1208
 	    || proto == PROTO_TLS
1209 1209
 #endif
1210 1210
 	    ) {
1211
-		if (parse_headers(msg, HDR_CONTENTLENGTH, 0)==-1){
1211
+		if (parse_headers(msg, HDR_CONTENTLENGTH_F, 0)==-1){
1212 1212
 			LOG(L_ERR, "adjust_clen: error parsing content-length\n");
1213 1213
 			goto error;
1214 1214
 		}
... ...
@@ -1218,7 +1219,7 @@ static inline int adjust_clen(struct sip_msg* msg, int body_delta, int proto)
1218 1218
 			 * - whole message was parsed by the above parse_headers
1219 1219
 			 *   which did not find content-length */
1220 1220
 			anchor=anchor_lump(msg, msg->unparsed-msg->buf, 0,
1221
-												HDR_CONTENTLENGTH);
1221
+												HDR_CONTENTLENGTH_T);
1222 1222
 			if (anchor==0){
1223 1223
 				LOG(L_ERR, "adjust_clen: cannot set clen anchor\n");
1224 1224
 				goto error;
... ...
@@ -1229,7 +1230,7 @@ static inline int adjust_clen(struct sip_msg* msg, int body_delta, int proto)
1229 1229
 	
1230 1230
 	
1231 1231
 	if ((anchor==0) && body_delta){
1232
-		if (parse_headers(msg, HDR_CONTENTLENGTH, 0) == -1) {
1232
+		if (parse_headers(msg, HDR_CONTENTLENGTH_F, 0) == -1) {
1233 1233
 			LOG(L_ERR, "adjust_clen: Error parsing Content-Length\n");
1234 1234
 			goto error;
1235 1235
 		}
... ...
@@ -1246,7 +1247,7 @@ static inline int adjust_clen(struct sip_msg* msg, int body_delta, int proto)
1246 1246
 			 *   which did not find content-length */
1247 1247
 			if (proto!=PROTO_UDP){
1248 1248
 				anchor=anchor_lump(msg, msg->unparsed-msg->buf, 0,
1249
-													HDR_CONTENTLENGTH);
1249
+													HDR_CONTENTLENGTH_T);
1250 1250
 				if (anchor==0){
1251 1251
 					LOG(L_ERR, "adjust_clen: cannot set clen anchor\n");
1252 1252
 					goto error;
... ...
@@ -1257,7 +1258,7 @@ static inline int adjust_clen(struct sip_msg* msg, int body_delta, int proto)
1257 1257
 		}else{
1258 1258
 			/* Content-Length has been found, remove it */
1259 1259
 			anchor = del_lump(	msg, msg->content_length->name.s - msg->buf,
1260
-								msg->content_length->len, HDR_CONTENTLENGTH);
1260
+								msg->content_length->len, HDR_CONTENTLENGTH_T);
1261 1261
 			if (anchor==0) {
1262 1262
 				LOG(L_ERR, "adjust_clen: Can't remove original"
1263 1263
 							" Content-Length\n");
... ...
@@ -1270,7 +1271,7 @@ static inline int adjust_clen(struct sip_msg* msg, int body_delta, int proto)
1270 1270
 		clen_buf = clen_builder(msg, &clen_len, body_delta);
1271 1271
 		if (!clen_buf) goto error;
1272 1272
 		if (insert_new_lump_after(anchor, clen_buf, clen_len,
1273
-					HDR_CONTENTLENGTH) == 0)
1273
+					HDR_CONTENTLENGTH_T) == 0)
1274 1274
 			goto error;
1275 1275
 	}
1276 1276
 
... ...
@@ -1384,9 +1385,9 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
1384 1384
 	/* add via header to the list */
1385 1385
 	/* try to add it before msg. 1st via */
1386 1386
 	/* add first via, as an anchor for second via*/
1387
-	anchor=anchor_lump(msg, msg->via1->hdr.s-buf, 0, HDR_VIA);
1387
+	anchor=anchor_lump(msg, msg->via1->hdr.s-buf, 0, HDR_VIA_T);
1388 1388
 	if (anchor==0) goto error01;
1389
-	if (insert_new_lump_before(anchor, line_buf, via_len, HDR_VIA)==0)
1389
+	if (insert_new_lump_before(anchor, line_buf, via_len, HDR_VIA_T)==0)
1390 1390
 		goto error01;
1391 1391
 	/* find out where the offset of the first parameter that should be added
1392 1392
 	 * (after host:port), needed by add receive & maybe rport */
... ...
@@ -1412,29 +1413,29 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
1412 1412
 		if (msg->via1->received){ /* received already present => overwrite it*/
1413 1413
 			via_insert_param=del_lump(msg,
1414 1414
 								msg->via1->received->start-buf-1, /*;*/
1415
-								msg->via1->received->size+1, /*;*/ HDR_VIA);
1415
+								msg->via1->received->size+1, /*;*/ HDR_VIA_T);
1416 1416
 		}else if (via_insert_param==0){ /* receive not present, ok */
1417
-			via_insert_param=anchor_lump(msg,
1418
-										msg->via1->hdr.s-buf+size,0, HDR_VIA);
1417
+			via_insert_param=anchor_lump(msg, msg->via1->hdr.s-buf+size, 0,
1418
+											HDR_VIA_T);
1419 1419
 		}
1420 1420
 		if (via_insert_param==0) goto error02; /* free received_buf */
1421 1421
 		if (insert_new_lump_after(via_insert_param, received_buf, received_len,
1422
-					HDR_VIA) ==0 ) goto error02; /* free received_buf */
1422
+					HDR_VIA_T) ==0 ) goto error02; /* free received_buf */
1423 1423
 	}
1424 1424
 	/* if rport needs to be updated, delete it if present and add it's value */
1425 1425
 	if (rport_len){
1426 1426
 		if (msg->via1->rport){ /* rport already present */
1427 1427
 			via_insert_param=del_lump(msg,
1428 1428
 								msg->via1->rport->start-buf-1, /*';'*/
1429
-								msg->via1->rport->size+1 /* ; */, HDR_VIA);
1429
+								msg->via1->rport->size+1 /* ; */, HDR_VIA_T);
1430 1430
 		}else if (via_insert_param==0){ /*force rport, no rport present */
1431 1431
 			/* no rport, add it */
1432
-			via_insert_param=anchor_lump(msg,
1433
-										msg->via1->hdr.s-buf+size,0, HDR_VIA);
1432
+			via_insert_param=anchor_lump(msg, msg->via1->hdr.s-buf+size, 0,
1433
+											HDR_VIA_T);
1434 1434
 		}
1435 1435
 		if (via_insert_param==0) goto error03; /* free rport_buf */
1436 1436
 		if (insert_new_lump_after(via_insert_param, rport_buf, rport_len,
1437
-									HDR_VIA) ==0 )
1437
+									HDR_VIA_T) ==0 )
1438 1438
 			goto error03; /* free rport_buf */
1439 1439
 			
1440 1440
 	}
... ...
@@ -1540,7 +1541,7 @@ char * build_res_buf_from_sip_res( struct sip_msg* msg,
1540 1540
 	}
1541 1541
 
1542 1542
 	/* remove the first via*/
1543
-	if (del_lump( msg, via_offset, via_len, HDR_VIA)==0){
1543
+	if (del_lump( msg, via_offset, via_len, HDR_VIA_T)==0){
1544 1544
 		LOG(L_ERR, "build_res_buf_from_sip_res: error trying to remove first"
1545 1545
 					"via\n");
1546 1546
 		goto error;
... ...
@@ -1610,7 +1611,7 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1610 1610
 	Via's in the reply and they may be scattered down to the
1611 1611
 	end of header (non-block Vias are a really poor property
1612 1612
 	of SIP :( ) */
1613
-	if (parse_headers( msg, HDR_EOH, 0 )==-1) {
1613
+	if (parse_headers( msg, HDR_EOH_F, 0 )==-1) {
1614 1614
 		LOG(L_ERR, "ERROR: build_res_buf_from_sip_req: "
1615 1615
 			"alas, parse_headers failed\n");
1616 1616
 		goto error00;
... ...
@@ -1645,7 +1646,7 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1645 1645
 	/*headers that will be copied (TO, FROM, CSEQ,CALLID,VIA)*/
1646 1646
 	for ( hdr=msg->headers ; hdr ; hdr=hdr->next ) {
1647 1647
 		switch (hdr->type) {
1648
-			case HDR_TO:
1648
+			case HDR_TO_T:
1649 1649
 				if (new_tag && new_tag->len) {
1650 1650
 					to_tag=get_to(msg)->tag_value;
1651 1651
 					if (to_tag.len )
... ...
@@ -1655,20 +1656,24 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1655 1655
 				}
1656 1656
 				len += hdr->len;
1657 1657
 				break;
1658
-			case HDR_VIA:
1658
+			case HDR_VIA_T:
1659 1659
 				/* we always add CRLF to via*/
1660 1660
 				len+=(hdr->body.s+hdr->body.len)-hdr->name.s+CRLF_LEN;
1661 1661
 				if (hdr==msg->h_via1) len += received_len+rport_len;
1662 1662
 				break;
1663
-			case HDR_RECORDROUTE:
1663
+			case HDR_RECORDROUTE_T:
1664 1664
 				/* RR only for 1xx and 2xx replies */
1665 1665
 				if (code<180 || code>=300)
1666 1666
 					break;
1667
-			case HDR_FROM:
1668
-			case HDR_CALLID:
1669
-			case HDR_CSEQ:
1667
+			case HDR_FROM_T:
1668
+			case HDR_CALLID_T:
1669
+			case HDR_CSEQ_T:
1670 1670
 				/* we keep the original termination for these headers*/
1671 1671
 				len += hdr->len;
1672
+				break;
1673
+			default:
1674
+				/* do nothing, we are interested only in the above headers */
1675
+				;
1672 1676
 		}
1673 1677
 	}
1674 1678
 	/* lumps length */
... ...
@@ -1724,7 +1729,7 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1724 1724
 	for ( hdr=msg->headers ; hdr ; hdr=hdr->next ) {
1725 1725
 		switch (hdr->type)
1726 1726
 		{
1727
-			case HDR_VIA:
1727
+			case HDR_VIA_T:
1728 1728
 				if (hdr==msg->h_via1){
1729 1729
 					if (rport_buf){
1730 1730
 						if (msg->via1->rport){ /* delete the old one */
... ...
@@ -1759,12 +1764,12 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1759 1759
 				}
1760 1760
 				append_str( p, CRLF,CRLF_LEN);
1761 1761
 				break;
1762
-			case HDR_RECORDROUTE:
1762
+			case HDR_RECORDROUTE_T:
1763 1763
 				/* RR only for 1xx and 2xx replies */
1764 1764
 				if (code<180 || code>=300) break;
1765 1765
 				append_str(p, hdr->name.s, hdr->len);
1766 1766
 				break;
1767
-			case HDR_TO:
1767
+			case HDR_TO_T:
1768 1768
 				if (new_tag && new_tag->len){
1769 1769
 					if (to_tag.s ) { /* replacement */
1770 1770
 						/* before to-tag */
... ...
@@ -1794,10 +1799,14 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
1794 1794
 					bmark->to_tag_val.len=
1795 1795
 							((struct to_body*)(hdr->parsed))->tag_value.len;
1796 1796
 				};
1797
-			case HDR_FROM:
1798
-			case HDR_CALLID:
1799
-			case HDR_CSEQ:
1797
+			case HDR_FROM_T:
1798
+			case HDR_CALLID_T:
1799
+			case HDR_CSEQ_T:
1800 1800
 					append_str(p, hdr->name.s, hdr->len);
1801
+					break;
1802
+			default:
1803
+				/* do nothing, we are interested only in the above headers */
1804
+				;
1801 1805
 		} /* end switch */
1802 1806
 	} /* end for */
1803 1807
 	/* lumps */
... ...
@@ -34,12 +34,12 @@
34 34
 #define age_CASE                                \
35 35
         switch(LOWER_DWORD(val)) {              \
36 36
         case _age1_:                            \
37
-	        hdr->type = HDR_ACCEPTLANGUAGE; \
37
+	        hdr->type = HDR_ACCEPTLANGUAGE_T; \
38 38
 	        hdr->name.len = 15;             \
39 39
 	        return (p + 4);                 \
40 40
                                                 \
41 41
         case _age2_:                            \
42
-                hdr->type = HDR_ACCEPTLANGUAGE; \
42
+                hdr->type = HDR_ACCEPTLANGUAGE_T; \
43 43
                 p += 4;                         \
44 44
 	        goto dc_end;                    \
45 45
         }
... ...
@@ -59,7 +59,7 @@
59 59
         if (LOWER_BYTE(*p) == 'o') {                       \
60 60
                 p++;                                       \
61 61
                 if (LOWER_BYTE(*p) == 'n') {               \
62
-                        hdr->type = HDR_ACCEPTDISPOSITION; \
62
+                        hdr->type = HDR_ACCEPTDISPOSITION_T; \
63 63
                         p++;                               \
64 64
                         goto dc_end;                       \
65 65
                 }                                          \
... ...
@@ -110,7 +110,7 @@
110 110
     if (LOWER_BYTE(*p) == 'p') {            \
111 111
             p++;                            \
112 112
             if (LOWER_BYTE(*p) == 't') {    \
113
-                    hdr->type = HDR_ACCEPT; \
113
+                    hdr->type = HDR_ACCEPT_T; \
114 114
                     p++;                    \
115 115
                     goto dc_end;            \
116 116
             }                               \
... ...
@@ -34,7 +34,7 @@
34 34
 #define allo_CASE                  \
35 35
     p += 4;                        \
36 36
     if (LOWER_BYTE(*p) == 'w') {   \
37
-            hdr->type = HDR_ALLOW; \
37
+            hdr->type = HDR_ALLOW_T; \
38 38
             p++;                   \
39 39
 	    goto dc_end;           \
40 40
     }                              \
... ...
@@ -36,7 +36,7 @@
36 36
 	        p += 4;                                \
37 37
 		switch(LOWER_BYTE(*p)) {               \
38 38
 		case 'n':                              \
39
-		        hdr->type = HDR_AUTHORIZATION; \
39
+		        hdr->type = HDR_AUTHORIZATION_T; \
40 40
 			p++;                           \
41 41
 			goto dc_end;                   \
42 42
                                                        \
... ...
@@ -41,12 +41,12 @@
41 41
 #define ID_CASE                      \
42 42
      switch(LOWER_DWORD(val)) {      \
43 43
      case __id1_:                    \
44
-	     hdr->type = HDR_CALLID; \
44
+	     hdr->type = HDR_CALLID_T; \
45 45
 	     hdr->name.len = 7;      \
46 46
 	     return (p + 4);         \
47 47
 	                             \
48 48
      case __id2_:                    \
49
-	     hdr->type = HDR_CALLID; \
49
+	     hdr->type = HDR_CALLID_T; \
50 50
 	     p += 4;                 \
51 51
 	     goto dc_end;            \
52 52
      }
... ...
@@ -42,7 +42,7 @@
42 42
 #define TH_CASE                                        \
43 43
         switch(LOWER_DWORD(val)) {                     \
44 44
         case _th12_:                                   \
45
-                hdr->type = HDR_CONTENTLENGTH;         \
45
+                hdr->type = HDR_CONTENTLENGTH_T;       \
46 46
                 hdr->name.len = 14;                    \
47 47
                 return (p + 4);                        \
48 48
         }                                              \
... ...
@@ -50,7 +50,7 @@
50 50
         if (LOWER_BYTE(*p) == 't') {                   \
51 51
                 p++;                                   \
52 52
                 if (LOWER_BYTE(*p) == 'h') {           \
53
-                        hdr->type = HDR_CONTENTLENGTH; \
53
+                        hdr->type = HDR_CONTENTLENGTH_T;\
54 54
                         p++;                           \
55 55
                         goto dc_end;                   \
56 56
                 }                                      \
... ...
@@ -60,12 +60,12 @@
60 60
 #define ion_CASE                                    \
61 61
         switch(LOWER_DWORD(val)) {                  \
62 62
         case _ion1_:                                \
63
-	        hdr->type = HDR_CONTENTDISPOSITION; \
63
+	        hdr->type = HDR_CONTENTDISPOSITION_T; \
64 64
 	        hdr->name.len = 19;                 \
65 65
 	        return (p + 4);                     \
66 66
                                                     \
67 67
         case _ion2_:                                \
68
-                hdr->type = HDR_CONTENTDISPOSITION; \
68
+                hdr->type = HDR_CONTENTDISPOSITION_T; \
69 69
                 p += 4;                             \
70 70
 	        goto dc_end;                        \
71 71
         }
... ...
@@ -90,7 +90,7 @@
90 90
                 goto other;                  \
91 91
                                              \
92 92
         case _type_:                         \
93
-                hdr->type = HDR_CONTENTTYPE; \
93
+                hdr->type = HDR_CONTENTTYPE_T; \
94 94
                 p += 4;                      \
95 95
                 goto dc_end;                 \
96 96
                                              \
... ...
@@ -105,12 +105,12 @@
105 105
 #define ACT_ENT_CASE                     \
106 106
         switch(LOWER_DWORD(val)) {       \
107 107
         case _act1_:                     \
108
-	        hdr->type = HDR_CONTACT; \
108
+	        hdr->type = HDR_CONTACT_T; \
109 109
 	        hdr->name.len = 7;       \
110 110
 	        return (p + 4);          \
111 111
 	                                 \
112 112
         case _act2_:                     \
113
-	        hdr->type = HDR_CONTACT; \
113
+	        hdr->type = HDR_CONTACT_T; \
114 114
 	        p += 4;                  \
115 115
 	        goto dc_end;             \
116 116
                                          \
... ...
@@ -33,7 +33,7 @@
33 33
 
34 34
 
35 35
 #define cseq_CASE          \
36
-     hdr->type = HDR_CSEQ; \
36
+     hdr->type = HDR_CSEQ_T; \
37 37
      p += 4;               \
38 38
      goto dc_end
39 39
 
... ...
@@ -37,7 +37,7 @@
37 37
         case _rsio_:                               \
38 38
 	        p += 4;                            \
39 39
 	        if (LOWER_BYTE(*p) == 'n') {       \
40
-		        hdr->type = HDR_DIVERSION; \
40
+		        hdr->type = HDR_DIVERSION_T; \
41 41
                         p++;                       \
42 42
                         goto dc_end;               \
43 43
                 }                                  \
... ...
@@ -35,7 +35,7 @@
35 35
 #define even_CASE                     \
36 36
     p += 4;                           \
37 37
     if (LOWER_BYTE(*p) == 't') {      \
38
-            hdr->type = HDR_EVENT;    \
38
+            hdr->type = HDR_EVENT_T;    \
39 39
             p++;                      \
40 40
 	    goto dc_end;              \
41 41
     }                                 \
... ...
@@ -41,12 +41,12 @@
41 41
 #define EXPI_RES_CASE                    \
42 42
         switch(LOWER_DWORD(val)) {       \
43 43
         case _res1_:                     \
44
-		hdr->type = HDR_EXPIRES; \
44
+		hdr->type = HDR_EXPIRES_T; \
45 45
 		hdr->name.len = 7;       \
46 46
 		return (p + 4);          \
47 47
                                          \
48 48
         case _res2_:                     \
49
-		hdr->type = HDR_EXPIRES; \
49
+		hdr->type = HDR_EXPIRES_T; \
50 50
 		p += 4;                  \
51 51
 		goto dc_end;             \
52 52
         }
... ...
@@ -33,7 +33,7 @@
33 33
 
34 34
 
35 35
 #define from_CASE             \
36
-        hdr->type = HDR_FROM; \
36
+        hdr->type = HDR_FROM_T; \
37 37
         p += 4;               \
38 38
         goto dc_end
39 39
 
... ...
@@ -34,7 +34,7 @@
34 34
 
35 35
 #define ARDS_CASE                            \
36 36
         if (LOWER_DWORD(val) == _ards_) {    \
37
-	        hdr->type = HDR_MAXFORWARDS; \
37
+	        hdr->type = HDR_MAXFORWARDS_T; \
38 38
 	        p += 4;                      \
39 39
 		goto dc_end;                 \
40 40
 	}
... ...
@@ -34,7 +34,7 @@
34 34
 
35 35
 #define tion_CASE                             \
36 36
         if (LOWER_DWORD(val) == _tion_) {     \
37
-	        hdr->type = HDR_ORGANIZATION; \
37
+	        hdr->type = HDR_ORGANIZATION_T; \
38 38
 		p += 4;                       \
39 39
 		goto dc_end;                  \
40 40
 	}                                     \
... ...
@@ -34,7 +34,7 @@
34 34
 
35 35
 #define rity_CASE                             \
36 36
         if (LOWER_DWORD(val) == _rity_) {     \
37
-	        hdr->type = HDR_PRIORITY;     \
37
+	        hdr->type = HDR_PRIORITY_T;     \
38 38
 		p += 4;                       \
39 39
 		goto dc_end;                  \
40 40
 	}                                     \
... ...
@@ -41,12 +41,12 @@
41 41
 #define ION_CASE                           \
42 42
         switch(LOWER_DWORD(val)) {         \
43 43
         case _ion1_:                       \
44
-	        hdr->type = HDR_PROXYAUTH; \
44
+	        hdr->type = HDR_PROXYAUTH_T; \
45 45
 	        hdr->name.len = 19;        \
46 46
 	        return (p + 4);            \
47 47
                                            \
48 48
         case _ion2_:                       \
49
-                hdr->type = HDR_PROXYAUTH; \
49
+                hdr->type = HDR_PROXYAUTH_T; \
50 50
                 p += 4;                    \
51 51
 	        goto dc_end;               \
52 52
         }
... ...
@@ -78,7 +78,7 @@
78 78
 	        p += 4;                               \
79 79
                 switch(LOWER_BYTE(*p)) {              \
80 80
                 case 'e':                             \
81
-                        hdr->type = HDR_PROXYREQUIRE; \
81
+                        hdr->type = HDR_PROXYREQUIRE_T; \
82 82
 	                p++;                          \
83 83
                         goto dc_end;                  \
84 84
                 }                                     \
... ...
@@ -34,7 +34,7 @@
34 34
 
35 35
 #define OUTE_CASE                            \
36 36
         if (LOWER_DWORD(val) == _oute_) {    \
37
-	        hdr->type = HDR_RECORDROUTE; \
37
+	        hdr->type = HDR_RECORDROUTE_T; \
38 38
 		p += 4;                      \
39 39
 		goto dc_end;                 \
40 40
 	}                                    \
... ...
@@ -30,7 +30,7 @@
30 30
 
31 31
 #define r_to_CASE                          \
32 32
         if (LOWER_DWORD(val) == _r_to_) {  \
33
-                hdr->type = HDR_REFER_TO;  \
33
+                hdr->type = HDR_REFER_TO_T;  \
34 34
                 p += 4;                    \
35 35
                 goto dc_end;               \
36 36
         }
... ...
@@ -34,12 +34,12 @@
34 34
 #define _ID_CASE                         \
35 35
         switch(LOWER_DWORD(val)) {       \
36 36
         case __id1_:                     \
37
-	        hdr->type = HDR_RPID;    \
37
+	        hdr->type = HDR_RPID_T;    \
38 38
 	        hdr->name.len = 15;      \
39 39
 	        return (p + 4);          \
40 40
                                          \
41 41
         case __id2_:                     \
42
-                hdr->type = HDR_RPID;    \
42
+                hdr->type = HDR_RPID_T;    \
43 43
                 p += 4;                  \
44 44
 	        goto dc_end;             \
45 45
         }
... ...
@@ -42,12 +42,12 @@
42 42
 #define IRE_CASE                         \
43 43
         switch(LOWER_DWORD(val)) {       \
44 44
         case _ire1_:                     \
45
-                hdr->type = HDR_REQUIRE; \
45
+                hdr->type = HDR_REQUIRE_T; \
46 46
                 hdr->name.len = 7;       \
47 47
                 return (p + 4);          \
48 48
                                          \
49 49
         case _ire2_:                     \
50
-                hdr->type = HDR_REQUIRE; \
50
+                hdr->type = HDR_REQUIRE_T; \
51 51
                 p += 4;                  \
52 52
                 goto dc_end;             \
53 53
         }
... ...
@@ -36,7 +36,7 @@
36 36
      p += 4;                        \
37 37
      switch(LOWER_BYTE(*p)) {       \
38 38
      case 'e':                      \
39
-	     hdr->type = HDR_ROUTE; \
39
+	     hdr->type = HDR_ROUTE_T; \
40 40
 	     p++;                   \
41 41
 	     goto dc_end;           \
42 42
                                     \
... ...
@@ -35,7 +35,7 @@
35 35
 #define serv_CASE                   \
36 36
     p += 4;                         \
37 37
     if (LOWER_BYTE(*p) == 'e' && LOWER_BYTE(p[1]) == 'r') {   \
38
-            hdr->type = HDR_SERVER; \
38
+            hdr->type = HDR_SERVER_T; \
39 39
             p+= 2;                  \
40 40
 	    goto dc_end;            \
41 41
     }                               \
... ...
@@ -5,7 +5,7 @@
5 5
         switch(LOWER_DWORD(val)) {          \
6 6
         case _atch_:                        \
7 7
 		DBG("end of SIP-If-Match\n"); \
8
-                hdr->type = HDR_SIPIFMATCH; \
8
+                hdr->type = HDR_SIPIFMATCH_T; \
9 9
                 p += 4;                     \
10 10
                 goto dc_end;                \
11 11
         }
... ...
@@ -35,12 +35,12 @@
35 35
 #define ect_CASE                         \
36 36
         switch(LOWER_DWORD(val)) {       \
37 37
         case _ect1_:                     \
38
-	        hdr->type = HDR_SUBJECT; \
38
+	        hdr->type = HDR_SUBJECT_T; \
39 39
 	        hdr->name.len = 7;       \
40 40
 	        return (p + 4);          \
41 41
                                          \
42 42
         case _ect2_:                     \
43
-                hdr->type = HDR_SUBJECT; \
43
+                hdr->type = HDR_SUBJECT_T; \
44 44
                 p += 4;                  \
45 45
 	        goto dc_end;             \
46 46
         }
... ...
@@ -37,7 +37,7 @@
37 37
         case _orte_:                               \
38 38
 	        p += 4;                            \
39 39
 	        if (LOWER_BYTE(*p) == 'd') {       \
40
-		        hdr->type = HDR_SUPPORTED; \
40
+		        hdr->type = HDR_SUPPORTED_T; \
41 41
                         p++;                       \
42 42
                         goto dc_end;               \
43 43
                 }                                  \
... ...
@@ -39,7 +39,7 @@
39 39
 #include "../comp_defs.h"
40 40
 
41 41
 #define to12_CASE           \
42
-        hdr->type = HDR_TO; \
42
+        hdr->type = HDR_TO_T; \
43 43
         hdr->name.len = 2;  \
44 44
         return (p + 4);
45 45
 
... ...
@@ -41,12 +41,12 @@
41 41
 #define TED_CASE                             \
42 42
         switch(LOWER_DWORD(val)) {           \
43 43
         case _ted1_:                         \
44
-                hdr->type = HDR_UNSUPPORTED; \
44
+                hdr->type = HDR_UNSUPPORTED_T; \
45 45
                 hdr->name.len = 11;          \
46 46
 	        return (p + 4);              \
47 47
                                              \
48 48
         case _ted2_:                         \
49
-                hdr->type = HDR_UNSUPPORTED; \
49
+                hdr->type = HDR_UNSUPPORTED_T; \
50 50
                 p += 4;                      \
51 51
 	        goto dc_end;                 \
52 52
         }
... ...
@@ -35,7 +35,7 @@
35 35
     if (LOWER_BYTE(*p) == 'n') {               \
36 36
             p++;                               \
37 37
             if (LOWER_BYTE(*p) == 't') {       \
38
-                    hdr->type = HDR_USERAGENT; \
38
+                    hdr->type = HDR_USERAGENT_T; \
39 39
                     p++;                       \
40 40
                     goto dc_end;               \
41 41
             }                                  \
... ...
@@ -38,12 +38,12 @@
38 38
 #include "../comp_defs.h"
39 39
 
40 40
 #define via1_CASE            \
41
-        hdr->type = HDR_VIA; \
41
+        hdr->type = HDR_VIA_T; \
42 42
         hdr->name.len = 3;   \
43 43
         return (p + 4)        
44 44
 
45 45
 #define via2_CASE            \
46
-        hdr->type = HDR_VIA; \
46
+        hdr->type = HDR_VIA_T; \
47 47
         p += 4;              \
48 48
         goto dc_end
49 49
 
... ...
@@ -35,7 +35,7 @@
35 35
 #define CATE_CASE                        \
36 36
         switch(LOWER_DWORD(val)) {       \
37 37
         case _cate_:                     \
38
-                hdr->type = HDR_WWWAUTH; \
38
+                hdr->type = HDR_WWWAUTH_T; \
39 39
                 p += 4;                  \
40 40
 	        goto dc_end;             \
41 41
         }
... ...
@@ -145,7 +145,7 @@ int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t* prev)
145 145
 		      */
146 146
 		hdr = msg->contact;
147 147
 		if (!hdr) {
148
-			if (parse_headers(msg, HDR_CONTACT, 0) == -1) {
148
+			if (parse_headers(msg, HDR_CONTACT_F, 0) == -1) {
149 149
 				LOG(L_ERR, "contact_iterator: Error while parsing headers\n");
150 150
 				return -1;
151 151
 			}
... ...
@@ -184,7 +184,7 @@ int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t* prev)
184 184
 		     /* Search another already parsed Contact
185 185
 		      * header field
186 186
 		      */
187
-		while(hdr && hdr->type != HDR_CONTACT) {
187
+		while(hdr && hdr->type != HDR_CONTACT_T) {
188 188
 			hdr = hdr->next;
189 189
 		}
190 190
 
... ...
@@ -192,7 +192,7 @@ int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t* prev)
192 192
 			     /* Look for another Contact HF in unparsed
193 193
 			      * part of the message header
194 194
 			      */
195
-			if (parse_headers(msg, HDR_CONTACT, 1) == -1) {
195
+			if (parse_headers(msg, HDR_CONTACT_F, 1) == -1) {
196 196
 				LOG(L_ERR, "contact_iterator: Error while parsing message header\n");
197 197
 				return -1;
198 198
 			}
... ...
@@ -202,7 +202,7 @@ int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t* prev)
202 202
 			      * previous Contact HF (that indicates that the previous 
203 203
 			      * one was the last header field in the header)
204 204
 			      */
205
-			if ((msg->last_header->type == HDR_CONTACT) &&
205
+			if ((msg->last_header->type == HDR_CONTACT_T) &&
206 206
 			    (msg->last_header != last)) {
207 207
 				hdr = msg->last_header;
208 208
 			} else {
... ...
@@ -197,8 +197,8 @@ int mark_authorized_cred(struct sip_msg* _m, struct hdr_field* _h)
197 197
 	struct hdr_field* f;
198 198
 	
199 199
 	switch(_h->type) {
200
-	case HDR_AUTHORIZATION: f = _m->authorization; break;
201
-	case HDR_PROXYAUTH:     f = _m->proxy_auth;    break;
200
+	case HDR_AUTHORIZATION_T: f = _m->authorization; break;
201
+	case HDR_PROXYAUTH_T:     f = _m->proxy_auth;    break;
202 202
 	default:
203 203
 		LOG(L_ERR, "mark_authorized_cred(): Invalid header field type\n");
204 204
 		return -1;
... ...
@@ -56,109 +56,109 @@ void clean_hdr_field(struct hdr_field* hf)
56 56
 {
57 57
 	if (hf->parsed){
58 58
 		switch(hf->type){
59
-		case HDR_VIA:
59
+		case HDR_VIA_T:
60 60
 			free_via_list(hf->parsed);
61 61
 			break;
62 62
 
63
-		case HDR_TO:
63
+		case HDR_TO_T:
64 64
 			free_to(hf->parsed);
65 65
 			break;
66 66
 
67
-		case HDR_FROM:
67
+		case HDR_FROM_T:
68 68
 			free_to(hf->parsed);
69 69
 			break;
70 70
 
71
-		case HDR_CSEQ:
71
+		case HDR_CSEQ_T:
72 72
 			free_cseq(hf->parsed);
73 73
 			break;
74 74
 
75
-		case HDR_CALLID:
75
+		case HDR_CALLID_T:
76 76
 			break;
77 77
 
78
-		case HDR_CONTACT:
78
+		case HDR_CONTACT_T:
79 79
 			free_contact((contact_body_t**)(&(hf->parsed)));
80 80
 			break;
81 81
 
82
-		case HDR_MAXFORWARDS:
82
+		case HDR_MAXFORWARDS_T:
83 83
 			break;
84 84
 
85
-		case HDR_ROUTE:
85
+		case HDR_ROUTE_T:
86 86
 			free_rr((rr_t**)(&hf->parsed));
87 87
 			break;
88 88
 
89
-		case HDR_RECORDROUTE:
89
+		case HDR_RECORDROUTE_T:
90 90
 			free_rr((rr_t**)(&hf->parsed));
91 91
 			break;
92 92
 
93
-		case HDR_CONTENTTYPE:
93
+		case HDR_CONTENTTYPE_T:
94 94
 			break;
95 95
 
96
-		case HDR_CONTENTLENGTH:
96
+		case HDR_CONTENTLENGTH_T:
97 97
 			break;
98 98
 
99
-		case HDR_AUTHORIZATION:
99
+		case HDR_AUTHORIZATION_T:
100 100
 			free_credentials((auth_body_t**)(&(hf->parsed)));
101 101
 			break;
102 102
 
103
-		case HDR_EXPIRES:
103
+		case HDR_EXPIRES_T:
104 104
 			free_expires((exp_body_t**)(&(hf->parsed)));
105 105
 			break;
106 106
 
107
-		case HDR_PROXYAUTH:
107
+		case HDR_PROXYAUTH_T:
108 108
 			free_credentials((auth_body_t**)(&(hf->parsed)));
109 109
 			break;
110 110
 
111
-		case HDR_SUPPORTED:
111
+		case HDR_SUPPORTED_T:
112 112
 			break;
113 113
 
114
-		case HDR_PROXYREQUIRE:
114
+		case HDR_PROXYREQUIRE_T:
115 115
 			break;
116 116
 
117
-		case HDR_UNSUPPORTED:
117
+		case HDR_UNSUPPORTED_T:
118 118
 			break;
119 119
 
120
-		case HDR_ALLOW:
120
+		case HDR_ALLOW_T:
121 121
 			break;
122 122
 
123
-		case HDR_EVENT:
123
+		case HDR_EVENT_T:
124 124
 			free_event((event_t**)(&(hf->parsed)));
125 125
 			break;
126 126
 
127
-		case HDR_ACCEPT:
127
+		case HDR_ACCEPT_T:
128 128
 			pkg_free(hf->parsed);
129 129
 			break;
130 130
 
131
-		case HDR_ACCEPTLANGUAGE:
131
+		case HDR_ACCEPTLANGUAGE_T:
132 132
 			break;
133 133
 			
134
-		case HDR_ORGANIZATION:
134
+		case HDR_ORGANIZATION_T:
135 135
 			break;
136 136
 			
137
-		case HDR_PRIORITY:
137
+		case HDR_PRIORITY_T:
138 138
 			break;
139 139
 
140
-		case HDR_SUBJECT:
140
+		case HDR_SUBJECT_T:
141 141
 			break;
142 142
 
143
-		case HDR_USERAGENT:
143
+		case HDR_USERAGENT_T:
144 144
 			break;
145 145
 
146
-		case HDR_ACCEPTDISPOSITION:
146
+		case HDR_ACCEPTDISPOSITION_T:
147 147
 			break;
148 148
 
149
-		case HDR_CONTENTDISPOSITION:
149
+		case HDR_CONTENTDISPOSITION_T:
150 150
 			free_disposition( ((struct disposition**)(&hf->parsed)) );
151 151
 			break;
152 152
 
153
-		case HDR_DIVERSION:
153
+		case HDR_DIVERSION_T:
154 154
 			free_to(hf->parsed);
155 155
 			break;
156 156
 
157
-		case HDR_RPID:
157
+		case HDR_RPID_T:
158 158
 			free_to(hf->parsed);
159 159
 			break;
160 160
 
161
-		case HDR_REFER_TO:
161
+		case HDR_REFER_TO_T:
162 162
 			free_to(hf->parsed);
163 163
 			break;
164 164
 
... ...
@@ -29,6 +29,8 @@
29 29
  * 2003-02-28 scratchpad compatibility abandoned (jiri)
30 30
  * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
31 31
  * 2003-05-01 HDR_ACCEPT added (janakj)
32
+ * 2005-02-14 hdr_flags_t && hdr_flags_f defined, split HDR_xxx into
33
+ *             HDR_xxx_F & HDR_xxx_T [WARNING: don't mix them!] (andrei)
32 34
  */
33 35
 
34 36
 
... ...
@@ -39,57 +41,109 @@
39 39
 #include "../comp_defs.h"
40 40
 
41 41
 
42
-/* Header types and flags */
43
-#define HDR_EOH         	     -1   /* End of header found */
44
-#define HDR_ERROR                     0   /* Error while parsing */
45
-#define HDR_VIA                       1   /* Via header field */
46
-#define HDR_VIA1                      1   /* First Via header field */
47
-#define HDR_VIA2               (1 <<  1)  /* only used as flag*/
48
-#define HDR_TO                 (1 <<  2)  /* To header field */
49
-#define HDR_FROM               (1 <<  3)  /* From header field */
50
-#define HDR_CSEQ               (1 <<  4)  /* CSeq header field */
51
-#define HDR_CALLID             (1 <<  5)  /* Call-Id header field */
52
-#define HDR_CONTACT            (1 <<  6)  /* Contact header field */
53
-#define HDR_MAXFORWARDS        (1 <<  7)  /* MaxForwards header field */
54
-#define HDR_ROUTE              (1 <<  8)  /* Route header field */
55
-#define HDR_RECORDROUTE        (1 <<  9)  /* Record-Route header field */
56
-#define HDR_CONTENTTYPE        (1 << 10)  /* Content-Type header field */
57
-#define HDR_CONTENTLENGTH      (1 << 11)  /* Content-Length header field */
58
-#define HDR_AUTHORIZATION      (1 << 12)  /* Authorization header field */
59
-#define HDR_EXPIRES            (1 << 13)  /* Expires header field */
60
-#define HDR_PROXYAUTH          (1 << 14)  /* Proxy-Authorization hdr field */
61
-#define HDR_SUPPORTED          (1 << 15)  /* Supported  header field */
62
-#define HDR_PROXYREQUIRE       (1 << 16)  /* Proxy-Require header field */
63
-#define HDR_UNSUPPORTED        (1 << 17)  /* Unsupported header field */
64
-#define HDR_ALLOW              (1 << 18)  /* Allow header field */
65
-#define HDR_EVENT              (1 << 19)  /* Event header field */
66
-#define HDR_ACCEPT             (1 << 20)  /* Accept header field */
67
-#define HDR_ACCEPTLANGUAGE     (1 << 21)  /* Accept-Language header field */
68
-#define HDR_ORGANIZATION       (1 << 22)  /* Organization header field */
69
-#define HDR_PRIORITY           (1 << 23)  /* Priority header field */
70
-#define HDR_SUBJECT            (1 << 24)  /* Subject header field */
71
-#define HDR_USERAGENT          (1 << 25)  /* User-Agent header field */
72
-#define HDR_ACCEPTDISPOSITION  (1 << 26)  /* Accept-Disposition hdr field */
73
-#define HDR_CONTENTDISPOSITION (1 << 27)  /* Content-Disposition hdr field */
74
-#define HDR_DIVERSION          (1 << 28)  /* Diversion header field */
75
-#define HDR_RPID               (1 << 29)  /* Remote-Party-ID header field */
76
-#define HDR_REFER_TO           (1 << 30)  /* Remote-Party-ID header field */
77
-#define HDR_OTHER              (1 << 31)  /* Some other header field */
78