فهرست منبع

- 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 20 سال پیش
والد
کامیت
5c28a534d5
56فایلهای تغییر یافته به همراه517 افزوده شده و 389 حذف شده
  1. 1 1
      Makefile.defs
  2. 26 0
      doc/parse_headers.txt
  3. 1 1
      forward.c
  4. 7 7
      modules/tm/dlg.c
  5. 1 1
      modules/tm/fix_lumps.h
  6. 61 59
      modules/tm/sip_msg.c
  7. 5 5
      modules/tm/t_fifo.c
  8. 2 2
      modules/tm/t_funcs.c
  9. 7 7
      modules/tm/t_lookup.c
  10. 3 3
      modules/tm/t_msgbuilder.c
  11. 3 3
      modules/tm/t_reply.c
  12. 5 5
      modules/tm/uac_fifo.c
  13. 5 5
      modules/tm/uac_unixsock.c
  14. 40 31
      msg_translator.c
  15. 4 4
      parser/case_acce.h
  16. 1 1
      parser/case_allo.h
  17. 1 1
      parser/case_auth.h
  18. 2 2
      parser/case_call.h
  19. 7 7
      parser/case_cont.h
  20. 1 1
      parser/case_cseq.h
  21. 1 1
      parser/case_dive.h
  22. 1 1
      parser/case_even.h
  23. 2 2
      parser/case_expi.h
  24. 1 1
      parser/case_from.h
  25. 1 1
      parser/case_max.h
  26. 1 1
      parser/case_orga.h
  27. 1 1
      parser/case_prio.h
  28. 3 3
      parser/case_prox.h
  29. 1 1
      parser/case_reco.h
  30. 1 1
      parser/case_refe.h
  31. 2 2
      parser/case_remo.h
  32. 2 2
      parser/case_requ.h
  33. 1 1
      parser/case_rout.h
  34. 1 1
      parser/case_serv.h
  35. 1 1
      parser/case_sip.h
  36. 2 2
      parser/case_subj.h
  37. 1 1
      parser/case_supp.h
  38. 1 1
      parser/case_to.h
  39. 2 2
      parser/case_unsu.h
  40. 1 1
      parser/case_user.h
  41. 2 2
      parser/case_via.h
  42. 1 1
      parser/case_www.h
  43. 4 4
      parser/contact/parse_contact.c
  44. 2 2
      parser/digest/digest.c
  45. 30 30
      parser/hf.c
  46. 122 42
      parser/hf.h
  47. 115 110
      parser/msg_parser.c
  48. 3 3
      parser/msg_parser.h
  49. 2 2
      parser/parse_content.c
  50. 1 1
      parser/parse_disposition.c
  51. 2 1
      parser/parse_diversion.c
  52. 1 1
      parser/parse_from.c
  53. 13 13
      parser/parse_hname2.c
  54. 1 1
      parser/parse_refer_to.c
  55. 1 1
      parser/parse_rpid.c
  56. 7 2
      route.c

+ 1 - 1
Makefile.defs

@@ -53,7 +53,7 @@ MAIN_NAME=ser
 VERSION = 0
 PATCHLEVEL = 10
 SUBLEVEL =   99
-EXTRAVERSION = -dev0
+EXTRAVERSION = -dev1
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")

+ 26 - 0
doc/parse_headers.txt

@@ -0,0 +1,26 @@
+# $Id$
+#
+# parse headers api changes
+#
+# 2004.02.23  created (andrei)
+
+
+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.
+
+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).
+
+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.
+
+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).
+
+WARNING: don't use a header type (HDR_xxx_T) where a header flag (HDR_xxx_F) is expected or viceversa!
+
+Examples:
+
+An old call to parse_headers(msg, HDR_FOO, 0) will become parse_header(msg, HDR_FOO_F, 0).
+
+An old loop searching for a header field:
+	while(hdr && (hdr->type!=HDR_FOO)) hdr=hdr->next;
+will become:
+	while (hdr && (hdr->type!=HDR_FOO_T)) hdr=hdr->next;
+.

+ 1 - 1
forward.c

@@ -463,7 +463,7 @@ int forward_reply(struct sip_msg* msg)
 	}
 
 	/* we have to forward the reply stateless, so we need second via -bogdan*/
-	if (parse_headers( msg, HDR_VIA2, 0 )==-1 
+	if (parse_headers( msg, HDR_VIA2_F, 0 )==-1 
 		|| (msg->via2==0) || (msg->via2->error!=PARSE_OK))
 	{
 		/* no second via => error */

+ 7 - 7
modules/tm/dlg.c

@@ -313,7 +313,7 @@ static inline int get_route_set(struct sip_msg* _m, rr_t** _rs, unsigned char _o
 
 	ptr = _m->record_route;
 	while(ptr) {
-		if (ptr->type == HDR_RECORDROUTE) {
+		if (ptr->type == HDR_RECORDROUTE_T) {
 			if (parse_rr(ptr) < 0) {
 				LOG(L_ERR, "get_route_set(): Error while parsing Record-Route body\n");
 				goto error;
@@ -358,7 +358,7 @@ static inline int response2dlg(struct sip_msg* _m, dlg_t* _d)
 	str contact, rtag;
 
 	     /* Parse the whole message, we will need all Record-Route headers */
-	if (parse_headers(_m, HDR_EOH, 0) == -1) {
+	if (parse_headers(_m, HDR_EOH_F, 0) == -1) {
 		LOG(L_ERR, "response2dlg(): Error while parsing headers\n");
 		return -1;
 	}
@@ -478,7 +478,7 @@ static inline int dlg_early_resp_uac(dlg_t* _d, struct sip_msg* _m)
  */
 static inline int get_cseq_method(struct sip_msg* _m, str* _method)
 {
-	if (!_m->cseq && ((parse_headers(_m, HDR_CSEQ, 0) == -1) || !_m->cseq)) {
+	if (!_m->cseq && ((parse_headers(_m, HDR_CSEQ_F, 0) == -1) || !_m->cseq)) {
 		LOG(L_ERR, "get_cseq_method(): Error while parsing CSeq\n");
 		return -1;
 	}
@@ -526,7 +526,7 @@ static inline int dlg_confirmed_resp_uac(dlg_t* _d, struct sip_msg* _m)
 	if (get_cseq_method(_m, &method) < 0) return -1;
 	if ((method.len == 6) && !memcmp("INVITE", method.s, 6)) {
 		     /* Get contact if any and update remote target */
-		if (parse_headers(_m, HDR_CONTACT, 0) == -1) {
+		if (parse_headers(_m, HDR_CONTACT_F, 0) == -1) {
 			LOG(L_ERR, "dlg_confirmed_resp_uac(): Error while parsing headers\n");
 			return -2;
 		}
@@ -674,7 +674,7 @@ static inline int request2dlg(struct sip_msg* _m, dlg_t* _d)
 {
 	str contact, rtag, callid;
 
-	if (parse_headers(_m, HDR_EOH, 0) == -1) {
+	if (parse_headers(_m, HDR_EOH_F, 0) == -1) {
 		LOG(L_ERR, "request2dlg(): Error while parsing headers");
 		return -1;
 	}
@@ -789,7 +789,7 @@ int dlg_request_uas(dlg_t* _d, struct sip_msg* _m)
 	     /* We must check if the request is not out of order or retransmission
 	      * first, if so then we will not update anything
 	      */
-	if (parse_headers(_m, HDR_CSEQ, 0) == -1) {
+	if (parse_headers(_m, HDR_CSEQ_F, 0) == -1) {
 		LOG(L_ERR, "dlg_request_uas(): Error while parsing headers\n");
 		return -2;
 	}
@@ -805,7 +805,7 @@ int dlg_request_uas(dlg_t* _d, struct sip_msg* _m)
 	      */
 	if (_m->first_line.u.request.method_value == METHOD_INVITE) {
 		     /* target refresher */
-		if (parse_headers(_m, HDR_CONTACT, 0) == -1) {
+		if (parse_headers(_m, HDR_CONTACT_F, 0) == -1) {
 			LOG(L_ERR, "dlg_request_uas(): Error while parsing headers\n");
 			return -4;
 		}

+ 1 - 1
modules/tm/fix_lumps.h

@@ -66,7 +66,7 @@ inline static void free_via_clen_lump( struct lump **list )
 	prev_lump=0;
 	for(lump=*list;lump;lump=next) {
 		next=lump->next;
-		if (lump->type==HDR_VIA||lump->type==HDR_CONTENTLENGTH) {
+		if (lump->type==HDR_VIA_T||lump->type==HDR_CONTENTLENGTH_T) {
 			a=lump->before;
 			while(a) {
 				foo=a; a=a->before;

+ 61 - 59
modules/tm/sip_msg.c

@@ -293,7 +293,7 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len )
 		len += ROUND4(sizeof( struct hdr_field));
 		switch (hdr->type)
 		{
-			case HDR_VIA:
+			case HDR_VIA_T:
 				for (via=(struct via_body*)hdr->parsed;via;via=via->next)
 				{
 					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 )
 				}
 				break;
 
-			case HDR_TO:
-			case HDR_FROM:
+			case HDR_TO_T:
+			case HDR_FROM_T:
 				/* From header might be unparsed */
 				if (hdr->parsed) {
 					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 )
 				}
 				break;
 
-			case HDR_CSEQ:
+			case HDR_CSEQ_T:
 				len+=ROUND4(sizeof(struct cseq_body));
 				break;
 
 
-			case HDR_AUTHORIZATION:
-			case HDR_PROXYAUTH:
+			case HDR_AUTHORIZATION_T:
+			case HDR_PROXYAUTH_T:
 				if (hdr->parsed) {
 					len += ROUND4(AUTH_BODY_SIZE);
 				}
 				break;
 
-			case HDR_CALLID:
-			case HDR_CONTACT:
-			case HDR_MAXFORWARDS:
-			case HDR_ROUTE:
-			case HDR_RECORDROUTE:
-			case HDR_CONTENTTYPE:
-			case HDR_CONTENTLENGTH:
-			case HDR_EXPIRES:
-			case HDR_SUPPORTED:
-			case HDR_PROXYREQUIRE:
-			case HDR_UNSUPPORTED:
-			case HDR_ALLOW:
-			case HDR_EVENT:
-			case HDR_ACCEPT:
-			case HDR_ACCEPTLANGUAGE:
-			case HDR_ORGANIZATION:
-			case HDR_PRIORITY:
-			case HDR_SUBJECT:
-			case HDR_USERAGENT:
-			case HDR_ACCEPTDISPOSITION:
-			case HDR_CONTENTDISPOSITION:
-		        case HDR_DIVERSION:
-		        case HDR_RPID:
-		        case HDR_REFER_TO:
-
+			case HDR_CALLID_T:
+			case HDR_CONTACT_T:
+			case HDR_MAXFORWARDS_T:
+			case HDR_ROUTE_T:
+			case HDR_RECORDROUTE_T:
+			case HDR_CONTENTTYPE_T:
+			case HDR_CONTENTLENGTH_T:
+			case HDR_EXPIRES_T:
+			case HDR_SUPPORTED_T:
+			case HDR_PROXYREQUIRE_T:
+			case HDR_UNSUPPORTED_T:
+			case HDR_ALLOW_T:
+			case HDR_EVENT_T:
+			case HDR_ACCEPT_T:
+			case HDR_ACCEPTLANGUAGE_T:
+			case HDR_ORGANIZATION_T:
+			case HDR_PRIORITY_T:
+			case HDR_SUBJECT_T:
+			case HDR_USERAGENT_T:
+			case HDR_ACCEPTDISPOSITION_T:
+			case HDR_CONTENTDISPOSITION_T:
+			case HDR_DIVERSION_T:
+			case HDR_RPID_T:
+			case HDR_REFER_TO_T:
 				/* we ignore them for now even if they have something parsed*/
 				break;
 
@@ -477,7 +476,7 @@ do { \
 
 		switch (hdr->type)
 		{
-			case HDR_VIA:
+			case HDR_VIA_T:
 				/*fprintf(stderr,"prepare to clone via |%.*s|\n",
 					via_len((struct via_body*)hdr->parsed),
 					via_s((struct via_body*)hdr->parsed,org_msg));*/
@@ -511,7 +510,7 @@ do { \
 						(struct via_body*)hdr->parsed , &p);
 				}
 				break;
-			case HDR_CSEQ:
+			case HDR_CSEQ_T:
 				new_hdr->parsed = p;
 				p +=ROUND4(sizeof(struct cseq_body));
 				memcpy(new_hdr->parsed, hdr->parsed, sizeof(struct cseq_body));
@@ -523,9 +522,9 @@ do { \
 					((struct cseq_body*)hdr->parsed)->method.s );
 				new_msg->cseq = new_hdr;
 				break;
-			case HDR_TO:
-			case HDR_FROM:
-				if (hdr->type == HDR_TO) {
+			case HDR_TO_T:
+			case HDR_FROM_T:
+				if (hdr->type == HDR_TO_T) {
 					new_msg->to = new_hdr;
 				} else {
 					new_msg->from = new_hdr;
@@ -570,85 +569,88 @@ do { \
 						= new_to_prm;
 				}
 				break;
-			case HDR_CALLID:
+			case HDR_CALLID_T:
 				new_msg->callid = new_hdr;
 				break;
-			case HDR_CONTACT:
+			case HDR_CONTACT_T:
 				new_msg->contact = new_hdr;
 				break;
-			case HDR_MAXFORWARDS :
+			case HDR_MAXFORWARDS_T:
 				new_msg->maxforwards = new_hdr;
 				break;
-			case HDR_ROUTE :
+			case HDR_ROUTE_T:
 				new_msg->route = new_hdr;
 				break;
-			case HDR_RECORDROUTE :
+			case HDR_RECORDROUTE_T:
 				new_msg->record_route = new_hdr;
 				break;
-			case HDR_CONTENTTYPE :
+			case HDR_CONTENTTYPE_T:
 				new_msg->content_type = new_hdr;
 				new_msg->content_type->parsed = hdr->parsed;
 				break;
-			case HDR_CONTENTLENGTH :
+			case HDR_CONTENTLENGTH_T:
 				new_msg->content_length = new_hdr;
 				new_msg->content_length->parsed = hdr->parsed;
 				break;
-			case HDR_AUTHORIZATION :
+			case HDR_AUTHORIZATION_T:
 				new_msg->authorization = new_hdr;
 				if (hdr->parsed) {
 					new_hdr->parsed = auth_body_cloner(new_msg->buf ,
 						org_msg->buf , (struct auth_body*)hdr->parsed , &p);
 				}
 				break;
-			case HDR_EXPIRES :
+			case HDR_EXPIRES_T:
 				new_msg->expires = new_hdr;
 				break;
-			case HDR_PROXYAUTH :
+			case HDR_PROXYAUTH_T:
 				new_msg->proxy_auth = new_hdr;
 				if (hdr->parsed) {
 					new_hdr->parsed = auth_body_cloner(new_msg->buf ,
 						org_msg->buf , (struct auth_body*)hdr->parsed , &p);
 				}
 				break;
-			case HDR_SUPPORTED :
+			case HDR_SUPPORTED_T:
 				new_msg->supported = new_hdr;
 				break;
-			case HDR_PROXYREQUIRE :
+			case HDR_PROXYREQUIRE_T:
 				new_msg->proxy_require = new_hdr;
 				break;
-			case HDR_UNSUPPORTED :
+			case HDR_UNSUPPORTED_T:
 				new_msg->unsupported = new_hdr;
 				break;
-			case HDR_ALLOW :
+			case HDR_ALLOW_T:
 				new_msg->allow = new_hdr;	
 				break;
-			case HDR_EVENT:
+			case HDR_EVENT_T:
 				new_msg->event = new_hdr;
 				break;
-			case HDR_ACCEPT:
+			case HDR_ACCEPT_T:
 				new_msg->accept = new_hdr;
 				break;
-			case HDR_ACCEPTLANGUAGE:
+			case HDR_ACCEPTLANGUAGE_T:
 				new_msg->accept_language = new_hdr;
 				break;
-			case HDR_ORGANIZATION:
+			case HDR_ORGANIZATION_T:
 				new_msg->organization = new_hdr;
 				break;
-			case HDR_PRIORITY:
+			case HDR_PRIORITY_T:
 				new_msg->priority = new_hdr;
 				break;
-			case HDR_SUBJECT:
+			case HDR_SUBJECT_T:
 				new_msg->subject = new_hdr;
 				break;
-			case HDR_USERAGENT:
+			case HDR_USERAGENT_T:
 				new_msg->user_agent = new_hdr;
 				break;
-			case HDR_ACCEPTDISPOSITION:
+			case HDR_ACCEPTDISPOSITION_T:
 				new_msg->accept_disposition = new_hdr;
 				break;
-			case HDR_CONTENTDISPOSITION:
+			case HDR_CONTENTDISPOSITION_T:
 				new_msg->content_disposition = new_hdr;
 				break;
+			default:
+				/* ignore the rest*/
+				;
 		}/*switch*/
 
 		if ( last_hdr )

+ 5 - 5
modules/tm/t_fifo.c

@@ -354,7 +354,7 @@ int parse_tw_append( modparam_t type, void* val)
 			}
 			foo.s[foo.len] = bar;
 			ha->ival = hdr.type;
-			if (hdr.type==HDR_OTHER || ha->title.s==0) {
+			if (hdr.type==HDR_OTHER_T || ha->title.s==0) {
 				/* duplicate hdr name */
 				ha->sval.s = (char*)pkg_malloc(foo.len+1);
 				if (ha->sval.s==0) {
@@ -615,14 +615,14 @@ static inline char* append2buf( char *buf, int len, struct sip_msg *req,
 		} else if (ha->type==ELEM_IS_HDR) {
 			/* parse the HDRs */
 			if (!msg_parsed) {
-				if (parse_headers( req, HDR_EOH, 0)!=0) {
+				if (parse_headers( req, HDR_EOH_F, 0)!=0) {
 					LOG(L_ERR,"ERROR:tm:append2buf: parsing hdrs failed\n");
 					goto error;
 				}
 				msg_parsed = 1;
 			}
 			/* search the HDR */
-			if (ha->ival==HDR_OTHER) {
+			if (ha->ival==HDR_OTHER_T) {
 				for(hdr=req->headers;hdr;hdr=hdr->next)
 					if (ha->sval.len==hdr->name.len &&
 					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)
 	}
 
 	/* parse all -- we will need every header field for a UAS */
-	if ( parse_headers(msg, HDR_EOH, 0)==-1) {
+	if ( parse_headers(msg, HDR_EOH_F, 0)==-1) {
 		LOG(L_ERR,"assemble_msg: parse_headers failed\n");
 		goto error;
 	}
@@ -770,7 +770,7 @@ static int assemble_msg(struct sip_msg* msg, struct tw_info *twi)
 		}
 		for(p_hdr = p_hdr->next;p_hdr;p_hdr = p_hdr->next) {
 			/* filter out non-RR hdr and empty hdrs */
-			if( (p_hdr->type!=HDR_RECORDROUTE) || p_hdr->body.len==0)
+			if( (p_hdr->type!=HDR_RECORDROUTE_T) || p_hdr->body.len==0)
 				continue;
 
 			if(p_hdr->parsed==0 && parse_rr(p_hdr)!=0 ){

+ 2 - 2
modules/tm/t_funcs.c

@@ -63,10 +63,10 @@
 
 /* fr_timer AVP specs */
 static int     fr_timer_avp_type = 0;
-static int_str fr_timer_avp = (int_str)0;
+static int_str fr_timer_avp = {0};
 static str     fr_timer_str;
 static int     fr_inv_timer_avp_type = 0;
-static int_str fr_inv_timer_avp = (int_str)0;
+static int_str fr_inv_timer_avp = {0};
 static str     fr_inv_timer_str;
 
 

+ 7 - 7
modules/tm/t_lookup.c

@@ -163,7 +163,7 @@ void init_t() {global_msg_id=0; set_t(T_UNDEFINED);}
 
 static inline int parse_dlg( struct sip_msg *msg )
 {
-	if (parse_headers(msg, HDR_FROM | HDR_CSEQ | HDR_TO, 0)==-1) {
+	if (parse_headers(msg, HDR_FROM_F | HDR_CSEQ_F | HDR_TO_F, 0)==-1) {
 		LOG(L_ERR, "ERROR: parse_dlg: From or Cseq or To invalid\n");
 		return 0;
 	}
@@ -800,7 +800,7 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch )
 				has_tran_tmcbs(p_cell,TMCB_RESPONSE_OUT|TMCB_E2EACK_IN) )
 			|| (is_local(p_cell)&&has_tran_tmcbs(p_cell,TMCB_LOCAL_COMPLETED))
 		)) {
-			if (parse_headers(p_msg, HDR_TO, 0)==-1) {
+			if (parse_headers(p_msg, HDR_TO_F, 0)==-1) {
 				LOG(L_ERR, "ERROR: t_reply_matching: to parsing failed\n");
 			}
 		}
@@ -845,7 +845,7 @@ int t_check( struct sip_msg* p_msg , int *param_branch )
 		/* transaction lookup */
 		if ( p_msg->first_line.type==SIP_REQUEST ) {
 			/* force parsing all the needed headers*/
-			if (parse_headers(p_msg, HDR_EOH, 0 )==-1) {
+			if (parse_headers(p_msg, HDR_EOH_F, 0 )==-1) {
 				LOG(L_ERR, "ERROR: t_check: parsing error\n");
 				return -1;
 			}
@@ -864,7 +864,7 @@ int t_check( struct sip_msg* p_msg , int *param_branch )
 			/* we need Via for branch and Cseq method to distinguish
 			   replies with the same branch/cseqNr (CANCEL)
 			*/
-			if ( parse_headers(p_msg, HDR_VIA1|HDR_CSEQ, 0 )==-1
+			if ( parse_headers(p_msg, HDR_VIA1_F|HDR_CSEQ_F, 0 )==-1
 			|| !p_msg->via1 || !p_msg->cseq ) {
 				LOG(L_ERR, "ERROR: reply cannot be parsed\n");
 				return -1;
@@ -875,7 +875,7 @@ int t_check( struct sip_msg* p_msg , int *param_branch )
 			*/
             if ( get_cseq(p_msg)->method.len==INVITE_LEN 
 				&& memcmp( get_cseq(p_msg)->method.s, INVITE, INVITE_LEN )==0 ) {
-					if (parse_headers(p_msg, HDR_TO, 0)==-1
+					if (parse_headers(p_msg, HDR_TO_F, 0)==-1
 						|| !p_msg->to)  {
 						LOG(L_ERR, "ERROR: INVITE reply cannot be parsed\n");
 						return -1;
@@ -1038,11 +1038,11 @@ int t_newtran( struct sip_msg* p_msg )
 	   shmem with pkg_mem
 	*/
 	
-	if (parse_headers(p_msg, HDR_EOH, 0 )) {
+	if (parse_headers(p_msg, HDR_EOH_F, 0 )) {
 		LOG(L_ERR, "ERROR: t_newtran: parse_headers failed\n");
 		return E_BAD_REQ;
 	}
-	if ((p_msg->parsed_flag & HDR_EOH)!=HDR_EOH) {
+	if ((p_msg->parsed_flag & HDR_EOH_F)!=HDR_EOH_F) {
 			LOG(L_ERR, "ERROR: t_newtran: EoH not parsed\n");
 			return E_OUT_OF_MEM;
 	}

+ 3 - 3
modules/tm/t_msgbuilder.c

@@ -126,7 +126,7 @@ char *build_local(struct cell *Trans,unsigned int branch,
 	/* copy'n'paste Route headers */
 	if (!is_local(Trans)) {
 		for ( hdr=Trans->uas.request->headers ; hdr ; hdr=hdr->next )
-			 if (hdr->type==HDR_ROUTE)
+			 if (hdr->type==HDR_ROUTE_T)
 				*len+=hdr->len;
 	}
 
@@ -165,7 +165,7 @@ char *build_local(struct cell *Trans,unsigned int branch,
 
 	if (!is_local(Trans))  {
 		for ( hdr=Trans->uas.request->headers ; hdr ; hdr=hdr->next )
-			if(hdr->type==HDR_ROUTE) {
+			if(hdr->type==HDR_ROUTE_T) {
 				append_mem_block(p, hdr->name.s, hdr->len );
 			}
 	}
@@ -216,7 +216,7 @@ static inline int process_routeset(struct sip_msg* msg, str* contact, struct rte
 	ptr = msg->record_route;
 	head = 0;
 	while(ptr) {
-		if (ptr->type == HDR_RECORDROUTE) {
+		if (ptr->type == HDR_RECORDROUTE_T) {
 			if (parse_rr(ptr) < 0) {
 				LOG(L_ERR, "process_routeset: Error while parsing Record-Route header\n");
 				return -1;

+ 3 - 3
modules/tm/t_reply.c

@@ -179,7 +179,7 @@ int unmatched_totag(struct cell *t, struct sip_msg *ack)
 	struct totag_elem *i;
 	str *tag;
 
-	if (parse_headers(ack, HDR_TO,0)==-1 || 
+	if (parse_headers(ack, HDR_TO_F,0)==-1 || 
 				!ack->to ) {
 		LOG(L_ERR, "ERROR: unmatched_totag: To invalid\n");
 		return 1;
@@ -273,7 +273,7 @@ static char *build_ack(struct sip_msg* rpl,struct cell *trans,int branch,
 {
 	str to;
 
-    if (parse_headers(rpl,HDR_TO, 0)==-1 || !rpl->to ) {
+    if (parse_headers(rpl,HDR_TO_F, 0)==-1 || !rpl->to ) {
         LOG(L_ERR, "ERROR: build_ack: "
             "cannot generate a HBH ACK if key HFs in reply missing\n");
         return NULL;
@@ -294,7 +294,7 @@ static char *build_local_ack(struct sip_msg* rpl, struct cell *trans, int branch
 			     unsigned int *ret_len, str* next_hop)
 {
 	str to;
-	if (parse_headers(rpl, HDR_EOH, 0) == -1 || !rpl->to) {
+	if (parse_headers(rpl, HDR_EOH_F, 0) == -1 || !rpl->to) {
 		LOG(L_ERR, "ERROR: build_local_ack: Error while parsing headers\n");
 		return 0;
 	}

+ 5 - 5
modules/tm/uac_fifo.c

@@ -65,10 +65,10 @@ struct str_list {
 
 
 #define skip_hf(_hf) (             \
-    ((_hf)->type == HDR_FROM)   || \
-    ((_hf)->type == HDR_TO)     || \
-    ((_hf)->type == HDR_CALLID) || \
-    ((_hf)->type == HDR_CSEQ)      \
+    ((_hf)->type == HDR_FROM_T)   || \
+    ((_hf)->type == HDR_TO_T)     || \
+    ((_hf)->type == HDR_CALLID_T) || \
+    ((_hf)->type == HDR_CSEQ_T)      \
 )
 
 
@@ -595,7 +595,7 @@ int fifo_uac(FILE *stream, char *response_file)
 	memset(&faked_msg, 0, sizeof(struct sip_msg));
 	faked_msg.len = headers.len; 
 	faked_msg.buf = faked_msg.unparsed = headers.s;
-	if (parse_headers(&faked_msg, HDR_EOH, 0) == -1 ) {
+	if (parse_headers(&faked_msg, HDR_EOH_F, 0) == -1 ) {
 		DBG("DEBUG: fifo_uac: parse_headers failed\n");
 		fifo_uac_error(response_file, 400, "HFs unparseable");
 		goto error;

+ 5 - 5
modules/tm/uac_unixsock.c

@@ -52,10 +52,10 @@ struct str_list {
 
 
 #define skip_hf(_hf) (             \
-    ((_hf)->type == HDR_FROM)   || \
-    ((_hf)->type == HDR_TO)     || \
-    ((_hf)->type == HDR_CALLID) || \
-    ((_hf)->type == HDR_CSEQ)      \
+    ((_hf)->type == HDR_FROM_T)   || \
+    ((_hf)->type == HDR_TO_T)     || \
+    ((_hf)->type == HDR_CALLID_T) || \
+    ((_hf)->type == HDR_CSEQ_T)      \
 )
 
 
@@ -504,7 +504,7 @@ int unixsock_uac(str* msg)
 	memset(&faked_msg, 0, sizeof(struct sip_msg));
 	faked_msg.len = headers.len; 
 	faked_msg.buf = faked_msg.unparsed = headers.s;
-	if (parse_headers(&faked_msg, HDR_EOH, 0) == -1 ) {
+	if (parse_headers(&faked_msg, HDR_EOH_F, 0) == -1 ) {
 		unixsock_reply_asciiz("400 HFs unparsable\n");
 		unixsock_reply_send();
 		goto error;

+ 40 - 31
msg_translator.c

@@ -288,7 +288,8 @@ static char * warning_builder( struct sip_msg *msg, unsigned int *returned_len)
 	str_pair_print(" in_uri=", msg->first_line.u.request.uri.s,
 								msg->first_line.u.request.uri.len);
 	str_pair_print(" out_uri=", foo->s, foo->len);
-	str_pair_print(" via_cnt", msg->parsed_flag & HDR_EOH ? "=" : ">", 1);
+	str_pair_print(" via_cnt",
+					(msg->parsed_flag & HDR_EOH_F)==HDR_EOH_F ? "=" : ">", 1);
 	str_int_print("=", via_cnt);
 	if (clen<MAX_WARNING_LEN){ buf[clen]='"'; clen++; }
 	else goto error_overflow;
@@ -1208,7 +1209,7 @@ static inline int adjust_clen(struct sip_msg* msg, int body_delta, int proto)
 	    || proto == PROTO_TLS
 #endif
 	    ) {
-		if (parse_headers(msg, HDR_CONTENTLENGTH, 0)==-1){
+		if (parse_headers(msg, HDR_CONTENTLENGTH_F, 0)==-1){
 			LOG(L_ERR, "adjust_clen: error parsing content-length\n");
 			goto error;
 		}
@@ -1218,7 +1219,7 @@ static inline int adjust_clen(struct sip_msg* msg, int body_delta, int proto)
 			 * - whole message was parsed by the above parse_headers
 			 *   which did not find content-length */
 			anchor=anchor_lump(msg, msg->unparsed-msg->buf, 0,
-												HDR_CONTENTLENGTH);
+												HDR_CONTENTLENGTH_T);
 			if (anchor==0){
 				LOG(L_ERR, "adjust_clen: cannot set clen anchor\n");
 				goto error;
@@ -1229,7 +1230,7 @@ static inline int adjust_clen(struct sip_msg* msg, int body_delta, int proto)
 	
 	
 	if ((anchor==0) && body_delta){
-		if (parse_headers(msg, HDR_CONTENTLENGTH, 0) == -1) {
+		if (parse_headers(msg, HDR_CONTENTLENGTH_F, 0) == -1) {
 			LOG(L_ERR, "adjust_clen: Error parsing Content-Length\n");
 			goto error;
 		}
@@ -1246,7 +1247,7 @@ static inline int adjust_clen(struct sip_msg* msg, int body_delta, int proto)
 			 *   which did not find content-length */
 			if (proto!=PROTO_UDP){
 				anchor=anchor_lump(msg, msg->unparsed-msg->buf, 0,
-													HDR_CONTENTLENGTH);
+													HDR_CONTENTLENGTH_T);
 				if (anchor==0){
 					LOG(L_ERR, "adjust_clen: cannot set clen anchor\n");
 					goto error;
@@ -1257,7 +1258,7 @@ static inline int adjust_clen(struct sip_msg* msg, int body_delta, int proto)
 		}else{
 			/* Content-Length has been found, remove it */
 			anchor = del_lump(	msg, msg->content_length->name.s - msg->buf,
-								msg->content_length->len, HDR_CONTENTLENGTH);
+								msg->content_length->len, HDR_CONTENTLENGTH_T);
 			if (anchor==0) {
 				LOG(L_ERR, "adjust_clen: Can't remove original"
 							" Content-Length\n");
@@ -1270,7 +1271,7 @@ static inline int adjust_clen(struct sip_msg* msg, int body_delta, int proto)
 		clen_buf = clen_builder(msg, &clen_len, body_delta);
 		if (!clen_buf) goto error;
 		if (insert_new_lump_after(anchor, clen_buf, clen_len,
-					HDR_CONTENTLENGTH) == 0)
+					HDR_CONTENTLENGTH_T) == 0)
 			goto error;
 	}
 
@@ -1384,9 +1385,9 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
 	/* add via header to the list */
 	/* try to add it before msg. 1st via */
 	/* add first via, as an anchor for second via*/
-	anchor=anchor_lump(msg, msg->via1->hdr.s-buf, 0, HDR_VIA);
+	anchor=anchor_lump(msg, msg->via1->hdr.s-buf, 0, HDR_VIA_T);
 	if (anchor==0) goto error01;
-	if (insert_new_lump_before(anchor, line_buf, via_len, HDR_VIA)==0)
+	if (insert_new_lump_before(anchor, line_buf, via_len, HDR_VIA_T)==0)
 		goto error01;
 	/* find out where the offset of the first parameter that should be added
 	 * (after host:port), needed by add receive & maybe rport */
@@ -1412,29 +1413,29 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
 		if (msg->via1->received){ /* received already present => overwrite it*/
 			via_insert_param=del_lump(msg,
 								msg->via1->received->start-buf-1, /*;*/
-								msg->via1->received->size+1, /*;*/ HDR_VIA);
+								msg->via1->received->size+1, /*;*/ HDR_VIA_T);
 		}else if (via_insert_param==0){ /* receive not present, ok */
-			via_insert_param=anchor_lump(msg,
-										msg->via1->hdr.s-buf+size,0, HDR_VIA);
+			via_insert_param=anchor_lump(msg, msg->via1->hdr.s-buf+size, 0,
+											HDR_VIA_T);
 		}
 		if (via_insert_param==0) goto error02; /* free received_buf */
 		if (insert_new_lump_after(via_insert_param, received_buf, received_len,
-					HDR_VIA) ==0 ) goto error02; /* free received_buf */
+					HDR_VIA_T) ==0 ) goto error02; /* free received_buf */
 	}
 	/* if rport needs to be updated, delete it if present and add it's value */
 	if (rport_len){
 		if (msg->via1->rport){ /* rport already present */
 			via_insert_param=del_lump(msg,
 								msg->via1->rport->start-buf-1, /*';'*/
-								msg->via1->rport->size+1 /* ; */, HDR_VIA);
+								msg->via1->rport->size+1 /* ; */, HDR_VIA_T);
 		}else if (via_insert_param==0){ /*force rport, no rport present */
 			/* no rport, add it */
-			via_insert_param=anchor_lump(msg,
-										msg->via1->hdr.s-buf+size,0, HDR_VIA);
+			via_insert_param=anchor_lump(msg, msg->via1->hdr.s-buf+size, 0,
+											HDR_VIA_T);
 		}
 		if (via_insert_param==0) goto error03; /* free rport_buf */
 		if (insert_new_lump_after(via_insert_param, rport_buf, rport_len,
-									HDR_VIA) ==0 )
+									HDR_VIA_T) ==0 )
 			goto error03; /* free rport_buf */
 			
 	}
@@ -1540,7 +1541,7 @@ char * build_res_buf_from_sip_res( struct sip_msg* msg,
 	}
 
 	/* remove the first via*/
-	if (del_lump( msg, via_offset, via_len, HDR_VIA)==0){
+	if (del_lump( msg, via_offset, via_len, HDR_VIA_T)==0){
 		LOG(L_ERR, "build_res_buf_from_sip_res: error trying to remove first"
 					"via\n");
 		goto error;
@@ -1610,7 +1611,7 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
 	Via's in the reply and they may be scattered down to the
 	end of header (non-block Vias are a really poor property
 	of SIP :( ) */
-	if (parse_headers( msg, HDR_EOH, 0 )==-1) {
+	if (parse_headers( msg, HDR_EOH_F, 0 )==-1) {
 		LOG(L_ERR, "ERROR: build_res_buf_from_sip_req: "
 			"alas, parse_headers failed\n");
 		goto error00;
@@ -1645,7 +1646,7 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
 	/*headers that will be copied (TO, FROM, CSEQ,CALLID,VIA)*/
 	for ( hdr=msg->headers ; hdr ; hdr=hdr->next ) {
 		switch (hdr->type) {
-			case HDR_TO:
+			case HDR_TO_T:
 				if (new_tag && new_tag->len) {
 					to_tag=get_to(msg)->tag_value;
 					if (to_tag.len )
@@ -1655,20 +1656,24 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
 				}
 				len += hdr->len;
 				break;
-			case HDR_VIA:
+			case HDR_VIA_T:
 				/* we always add CRLF to via*/
 				len+=(hdr->body.s+hdr->body.len)-hdr->name.s+CRLF_LEN;
 				if (hdr==msg->h_via1) len += received_len+rport_len;
 				break;
-			case HDR_RECORDROUTE:
+			case HDR_RECORDROUTE_T:
 				/* RR only for 1xx and 2xx replies */
 				if (code<180 || code>=300)
 					break;
-			case HDR_FROM:
-			case HDR_CALLID:
-			case HDR_CSEQ:
+			case HDR_FROM_T:
+			case HDR_CALLID_T:
+			case HDR_CSEQ_T:
 				/* we keep the original termination for these headers*/
 				len += hdr->len;
+				break;
+			default:
+				/* do nothing, we are interested only in the above headers */
+				;
 		}
 	}
 	/* lumps length */
@@ -1724,7 +1729,7 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
 	for ( hdr=msg->headers ; hdr ; hdr=hdr->next ) {
 		switch (hdr->type)
 		{
-			case HDR_VIA:
+			case HDR_VIA_T:
 				if (hdr==msg->h_via1){
 					if (rport_buf){
 						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,
 				}
 				append_str( p, CRLF,CRLF_LEN);
 				break;
-			case HDR_RECORDROUTE:
+			case HDR_RECORDROUTE_T:
 				/* RR only for 1xx and 2xx replies */
 				if (code<180 || code>=300) break;
 				append_str(p, hdr->name.s, hdr->len);
 				break;
-			case HDR_TO:
+			case HDR_TO_T:
 				if (new_tag && new_tag->len){
 					if (to_tag.s ) { /* replacement */
 						/* before to-tag */
@@ -1794,10 +1799,14 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text ,str *new_tag,
 					bmark->to_tag_val.len=
 							((struct to_body*)(hdr->parsed))->tag_value.len;
 				};
-			case HDR_FROM:
-			case HDR_CALLID:
-			case HDR_CSEQ:
+			case HDR_FROM_T:
+			case HDR_CALLID_T:
+			case HDR_CSEQ_T:
 					append_str(p, hdr->name.s, hdr->len);
+					break;
+			default:
+				/* do nothing, we are interested only in the above headers */
+				;
 		} /* end switch */
 	} /* end for */
 	/* lumps */

+ 4 - 4
parser/case_acce.h

@@ -34,12 +34,12 @@
 #define age_CASE                                \
         switch(LOWER_DWORD(val)) {              \
         case _age1_:                            \
-	        hdr->type = HDR_ACCEPTLANGUAGE; \
+	        hdr->type = HDR_ACCEPTLANGUAGE_T; \
 	        hdr->name.len = 15;             \
 	        return (p + 4);                 \
                                                 \
         case _age2_:                            \
-                hdr->type = HDR_ACCEPTLANGUAGE; \
+                hdr->type = HDR_ACCEPTLANGUAGE_T; \
                 p += 4;                         \
 	        goto dc_end;                    \
         }
@@ -59,7 +59,7 @@
         if (LOWER_BYTE(*p) == 'o') {                       \
                 p++;                                       \
                 if (LOWER_BYTE(*p) == 'n') {               \
-                        hdr->type = HDR_ACCEPTDISPOSITION; \
+                        hdr->type = HDR_ACCEPTDISPOSITION_T; \
                         p++;                               \
                         goto dc_end;                       \
                 }                                          \
@@ -110,7 +110,7 @@
     if (LOWER_BYTE(*p) == 'p') {            \
             p++;                            \
             if (LOWER_BYTE(*p) == 't') {    \
-                    hdr->type = HDR_ACCEPT; \
+                    hdr->type = HDR_ACCEPT_T; \
                     p++;                    \
                     goto dc_end;            \
             }                               \

+ 1 - 1
parser/case_allo.h

@@ -34,7 +34,7 @@
 #define allo_CASE                  \
     p += 4;                        \
     if (LOWER_BYTE(*p) == 'w') {   \
-            hdr->type = HDR_ALLOW; \
+            hdr->type = HDR_ALLOW_T; \
             p++;                   \
 	    goto dc_end;           \
     }                              \

+ 1 - 1
parser/case_auth.h

@@ -36,7 +36,7 @@
 	        p += 4;                                \
 		switch(LOWER_BYTE(*p)) {               \
 		case 'n':                              \
-		        hdr->type = HDR_AUTHORIZATION; \
+		        hdr->type = HDR_AUTHORIZATION_T; \
 			p++;                           \
 			goto dc_end;                   \
                                                        \

+ 2 - 2
parser/case_call.h

@@ -41,12 +41,12 @@
 #define ID_CASE                      \
      switch(LOWER_DWORD(val)) {      \
      case __id1_:                    \
-	     hdr->type = HDR_CALLID; \
+	     hdr->type = HDR_CALLID_T; \
 	     hdr->name.len = 7;      \
 	     return (p + 4);         \
 	                             \
      case __id2_:                    \
-	     hdr->type = HDR_CALLID; \
+	     hdr->type = HDR_CALLID_T; \
 	     p += 4;                 \
 	     goto dc_end;            \
      }

+ 7 - 7
parser/case_cont.h

@@ -42,7 +42,7 @@
 #define TH_CASE                                        \
         switch(LOWER_DWORD(val)) {                     \
         case _th12_:                                   \
-                hdr->type = HDR_CONTENTLENGTH;         \
+                hdr->type = HDR_CONTENTLENGTH_T;       \
                 hdr->name.len = 14;                    \
                 return (p + 4);                        \
         }                                              \
@@ -50,7 +50,7 @@
         if (LOWER_BYTE(*p) == 't') {                   \
                 p++;                                   \
                 if (LOWER_BYTE(*p) == 'h') {           \
-                        hdr->type = HDR_CONTENTLENGTH; \
+                        hdr->type = HDR_CONTENTLENGTH_T;\
                         p++;                           \
                         goto dc_end;                   \
                 }                                      \
@@ -60,12 +60,12 @@
 #define ion_CASE                                    \
         switch(LOWER_DWORD(val)) {                  \
         case _ion1_:                                \
-	        hdr->type = HDR_CONTENTDISPOSITION; \
+	        hdr->type = HDR_CONTENTDISPOSITION_T; \
 	        hdr->name.len = 19;                 \
 	        return (p + 4);                     \
                                                     \
         case _ion2_:                                \
-                hdr->type = HDR_CONTENTDISPOSITION; \
+                hdr->type = HDR_CONTENTDISPOSITION_T; \
                 p += 4;                             \
 	        goto dc_end;                        \
         }
@@ -90,7 +90,7 @@
                 goto other;                  \
                                              \
         case _type_:                         \
-                hdr->type = HDR_CONTENTTYPE; \
+                hdr->type = HDR_CONTENTTYPE_T; \
                 p += 4;                      \
                 goto dc_end;                 \
                                              \
@@ -105,12 +105,12 @@
 #define ACT_ENT_CASE                     \
         switch(LOWER_DWORD(val)) {       \
         case _act1_:                     \
-	        hdr->type = HDR_CONTACT; \
+	        hdr->type = HDR_CONTACT_T; \
 	        hdr->name.len = 7;       \
 	        return (p + 4);          \
 	                                 \
         case _act2_:                     \
-	        hdr->type = HDR_CONTACT; \
+	        hdr->type = HDR_CONTACT_T; \
 	        p += 4;                  \
 	        goto dc_end;             \
                                          \

+ 1 - 1
parser/case_cseq.h

@@ -33,7 +33,7 @@
 
 
 #define cseq_CASE          \
-     hdr->type = HDR_CSEQ; \
+     hdr->type = HDR_CSEQ_T; \
      p += 4;               \
      goto dc_end
 

+ 1 - 1
parser/case_dive.h

@@ -37,7 +37,7 @@
         case _rsio_:                               \
 	        p += 4;                            \
 	        if (LOWER_BYTE(*p) == 'n') {       \
-		        hdr->type = HDR_DIVERSION; \
+		        hdr->type = HDR_DIVERSION_T; \
                         p++;                       \
                         goto dc_end;               \
                 }                                  \

+ 1 - 1
parser/case_even.h

@@ -35,7 +35,7 @@
 #define even_CASE                     \
     p += 4;                           \
     if (LOWER_BYTE(*p) == 't') {      \
-            hdr->type = HDR_EVENT;    \
+            hdr->type = HDR_EVENT_T;    \
             p++;                      \
 	    goto dc_end;              \
     }                                 \

+ 2 - 2
parser/case_expi.h

@@ -41,12 +41,12 @@
 #define EXPI_RES_CASE                    \
         switch(LOWER_DWORD(val)) {       \
         case _res1_:                     \
-		hdr->type = HDR_EXPIRES; \
+		hdr->type = HDR_EXPIRES_T; \
 		hdr->name.len = 7;       \
 		return (p + 4);          \
                                          \
         case _res2_:                     \
-		hdr->type = HDR_EXPIRES; \
+		hdr->type = HDR_EXPIRES_T; \
 		p += 4;                  \
 		goto dc_end;             \
         }

+ 1 - 1
parser/case_from.h

@@ -33,7 +33,7 @@
 
 
 #define from_CASE             \
-        hdr->type = HDR_FROM; \
+        hdr->type = HDR_FROM_T; \
         p += 4;               \
         goto dc_end
 

+ 1 - 1
parser/case_max.h

@@ -34,7 +34,7 @@
 
 #define ARDS_CASE                            \
         if (LOWER_DWORD(val) == _ards_) {    \
-	        hdr->type = HDR_MAXFORWARDS; \
+	        hdr->type = HDR_MAXFORWARDS_T; \
 	        p += 4;                      \
 		goto dc_end;                 \
 	}

+ 1 - 1
parser/case_orga.h

@@ -34,7 +34,7 @@
 
 #define tion_CASE                             \
         if (LOWER_DWORD(val) == _tion_) {     \
-	        hdr->type = HDR_ORGANIZATION; \
+	        hdr->type = HDR_ORGANIZATION_T; \
 		p += 4;                       \
 		goto dc_end;                  \
 	}                                     \

+ 1 - 1
parser/case_prio.h

@@ -34,7 +34,7 @@
 
 #define rity_CASE                             \
         if (LOWER_DWORD(val) == _rity_) {     \
-	        hdr->type = HDR_PRIORITY;     \
+	        hdr->type = HDR_PRIORITY_T;     \
 		p += 4;                       \
 		goto dc_end;                  \
 	}                                     \

+ 3 - 3
parser/case_prox.h

@@ -41,12 +41,12 @@
 #define ION_CASE                           \
         switch(LOWER_DWORD(val)) {         \
         case _ion1_:                       \
-	        hdr->type = HDR_PROXYAUTH; \
+	        hdr->type = HDR_PROXYAUTH_T; \
 	        hdr->name.len = 19;        \
 	        return (p + 4);            \
                                            \
         case _ion2_:                       \
-                hdr->type = HDR_PROXYAUTH; \
+                hdr->type = HDR_PROXYAUTH_T; \
                 p += 4;                    \
 	        goto dc_end;               \
         }
@@ -78,7 +78,7 @@
 	        p += 4;                               \
                 switch(LOWER_BYTE(*p)) {              \
                 case 'e':                             \
-                        hdr->type = HDR_PROXYREQUIRE; \
+                        hdr->type = HDR_PROXYREQUIRE_T; \
 	                p++;                          \
                         goto dc_end;                  \
                 }                                     \

+ 1 - 1
parser/case_reco.h

@@ -34,7 +34,7 @@
 
 #define OUTE_CASE                            \
         if (LOWER_DWORD(val) == _oute_) {    \
-	        hdr->type = HDR_RECORDROUTE; \
+	        hdr->type = HDR_RECORDROUTE_T; \
 		p += 4;                      \
 		goto dc_end;                 \
 	}                                    \

+ 1 - 1
parser/case_refe.h

@@ -30,7 +30,7 @@
 
 #define r_to_CASE                          \
         if (LOWER_DWORD(val) == _r_to_) {  \
-                hdr->type = HDR_REFER_TO;  \
+                hdr->type = HDR_REFER_TO_T;  \
                 p += 4;                    \
                 goto dc_end;               \
         }

+ 2 - 2
parser/case_remo.h

@@ -34,12 +34,12 @@
 #define _ID_CASE                         \
         switch(LOWER_DWORD(val)) {       \
         case __id1_:                     \
-	        hdr->type = HDR_RPID;    \
+	        hdr->type = HDR_RPID_T;    \
 	        hdr->name.len = 15;      \
 	        return (p + 4);          \
                                          \
         case __id2_:                     \
-                hdr->type = HDR_RPID;    \
+                hdr->type = HDR_RPID_T;    \
                 p += 4;                  \
 	        goto dc_end;             \
         }

+ 2 - 2
parser/case_requ.h

@@ -42,12 +42,12 @@
 #define IRE_CASE                         \
         switch(LOWER_DWORD(val)) {       \
         case _ire1_:                     \
-                hdr->type = HDR_REQUIRE; \
+                hdr->type = HDR_REQUIRE_T; \
                 hdr->name.len = 7;       \
                 return (p + 4);          \
                                          \
         case _ire2_:                     \
-                hdr->type = HDR_REQUIRE; \
+                hdr->type = HDR_REQUIRE_T; \
                 p += 4;                  \
                 goto dc_end;             \
         }

+ 1 - 1
parser/case_rout.h

@@ -36,7 +36,7 @@
      p += 4;                        \
      switch(LOWER_BYTE(*p)) {       \
      case 'e':                      \
-	     hdr->type = HDR_ROUTE; \
+	     hdr->type = HDR_ROUTE_T; \
 	     p++;                   \
 	     goto dc_end;           \
                                     \

+ 1 - 1
parser/case_serv.h

@@ -35,7 +35,7 @@
 #define serv_CASE                   \
     p += 4;                         \
     if (LOWER_BYTE(*p) == 'e' && LOWER_BYTE(p[1]) == 'r') {   \
-            hdr->type = HDR_SERVER; \
+            hdr->type = HDR_SERVER_T; \
             p+= 2;                  \
 	    goto dc_end;            \
     }                               \

+ 1 - 1
parser/case_sip.h

@@ -5,7 +5,7 @@
         switch(LOWER_DWORD(val)) {          \
         case _atch_:                        \
 		DBG("end of SIP-If-Match\n"); \
-                hdr->type = HDR_SIPIFMATCH; \
+                hdr->type = HDR_SIPIFMATCH_T; \
                 p += 4;                     \
                 goto dc_end;                \
         }

+ 2 - 2
parser/case_subj.h

@@ -35,12 +35,12 @@
 #define ect_CASE                         \
         switch(LOWER_DWORD(val)) {       \
         case _ect1_:                     \
-	        hdr->type = HDR_SUBJECT; \
+	        hdr->type = HDR_SUBJECT_T; \
 	        hdr->name.len = 7;       \
 	        return (p + 4);          \
                                          \
         case _ect2_:                     \
-                hdr->type = HDR_SUBJECT; \
+                hdr->type = HDR_SUBJECT_T; \
                 p += 4;                  \
 	        goto dc_end;             \
         }

+ 1 - 1
parser/case_supp.h

@@ -37,7 +37,7 @@
         case _orte_:                               \
 	        p += 4;                            \
 	        if (LOWER_BYTE(*p) == 'd') {       \
-		        hdr->type = HDR_SUPPORTED; \
+		        hdr->type = HDR_SUPPORTED_T; \
                         p++;                       \
                         goto dc_end;               \
                 }                                  \

+ 1 - 1
parser/case_to.h

@@ -39,7 +39,7 @@
 #include "../comp_defs.h"
 
 #define to12_CASE           \
-        hdr->type = HDR_TO; \
+        hdr->type = HDR_TO_T; \
         hdr->name.len = 2;  \
         return (p + 4);
 

+ 2 - 2
parser/case_unsu.h

@@ -41,12 +41,12 @@
 #define TED_CASE                             \
         switch(LOWER_DWORD(val)) {           \
         case _ted1_:                         \
-                hdr->type = HDR_UNSUPPORTED; \
+                hdr->type = HDR_UNSUPPORTED_T; \
                 hdr->name.len = 11;          \
 	        return (p + 4);              \
                                              \
         case _ted2_:                         \
-                hdr->type = HDR_UNSUPPORTED; \
+                hdr->type = HDR_UNSUPPORTED_T; \
                 p += 4;                      \
 	        goto dc_end;                 \
         }

+ 1 - 1
parser/case_user.h

@@ -35,7 +35,7 @@
     if (LOWER_BYTE(*p) == 'n') {               \
             p++;                               \
             if (LOWER_BYTE(*p) == 't') {       \
-                    hdr->type = HDR_USERAGENT; \
+                    hdr->type = HDR_USERAGENT_T; \
                     p++;                       \
                     goto dc_end;               \
             }                                  \

+ 2 - 2
parser/case_via.h

@@ -38,12 +38,12 @@
 #include "../comp_defs.h"
 
 #define via1_CASE            \
-        hdr->type = HDR_VIA; \
+        hdr->type = HDR_VIA_T; \
         hdr->name.len = 3;   \
         return (p + 4)        
 
 #define via2_CASE            \
-        hdr->type = HDR_VIA; \
+        hdr->type = HDR_VIA_T; \
         p += 4;              \
         goto dc_end
 

+ 1 - 1
parser/case_www.h

@@ -35,7 +35,7 @@
 #define CATE_CASE                        \
         switch(LOWER_DWORD(val)) {       \
         case _cate_:                     \
-                hdr->type = HDR_WWWAUTH; \
+                hdr->type = HDR_WWWAUTH_T; \
                 p += 4;                  \
 	        goto dc_end;             \
         }

+ 4 - 4
parser/contact/parse_contact.c

@@ -145,7 +145,7 @@ int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t* prev)
 		      */
 		hdr = msg->contact;
 		if (!hdr) {
-			if (parse_headers(msg, HDR_CONTACT, 0) == -1) {
+			if (parse_headers(msg, HDR_CONTACT_F, 0) == -1) {
 				LOG(L_ERR, "contact_iterator: Error while parsing headers\n");
 				return -1;
 			}
@@ -184,7 +184,7 @@ int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t* prev)
 		     /* Search another already parsed Contact
 		      * header field
 		      */
-		while(hdr && hdr->type != HDR_CONTACT) {
+		while(hdr && hdr->type != HDR_CONTACT_T) {
 			hdr = hdr->next;
 		}
 
@@ -192,7 +192,7 @@ int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t* prev)
 			     /* Look for another Contact HF in unparsed
 			      * part of the message header
 			      */
-			if (parse_headers(msg, HDR_CONTACT, 1) == -1) {
+			if (parse_headers(msg, HDR_CONTACT_F, 1) == -1) {
 				LOG(L_ERR, "contact_iterator: Error while parsing message header\n");
 				return -1;
 			}
@@ -202,7 +202,7 @@ int contact_iterator(contact_t** c, struct sip_msg* msg, contact_t* prev)
 			      * previous Contact HF (that indicates that the previous 
 			      * one was the last header field in the header)
 			      */
-			if ((msg->last_header->type == HDR_CONTACT) &&
+			if ((msg->last_header->type == HDR_CONTACT_T) &&
 			    (msg->last_header != last)) {
 				hdr = msg->last_header;
 			} else {

+ 2 - 2
parser/digest/digest.c

@@ -197,8 +197,8 @@ int mark_authorized_cred(struct sip_msg* _m, struct hdr_field* _h)
 	struct hdr_field* f;
 	
 	switch(_h->type) {
-	case HDR_AUTHORIZATION: f = _m->authorization; break;
-	case HDR_PROXYAUTH:     f = _m->proxy_auth;    break;
+	case HDR_AUTHORIZATION_T: f = _m->authorization; break;
+	case HDR_PROXYAUTH_T:     f = _m->proxy_auth;    break;
 	default:
 		LOG(L_ERR, "mark_authorized_cred(): Invalid header field type\n");
 		return -1;

+ 30 - 30
parser/hf.c

@@ -56,109 +56,109 @@ void clean_hdr_field(struct hdr_field* hf)
 {
 	if (hf->parsed){
 		switch(hf->type){
-		case HDR_VIA:
+		case HDR_VIA_T:
 			free_via_list(hf->parsed);
 			break;
 
-		case HDR_TO:
+		case HDR_TO_T:
 			free_to(hf->parsed);
 			break;
 
-		case HDR_FROM:
+		case HDR_FROM_T:
 			free_to(hf->parsed);
 			break;
 
-		case HDR_CSEQ:
+		case HDR_CSEQ_T:
 			free_cseq(hf->parsed);
 			break;
 
-		case HDR_CALLID:
+		case HDR_CALLID_T:
 			break;
 
-		case HDR_CONTACT:
+		case HDR_CONTACT_T:
 			free_contact((contact_body_t**)(&(hf->parsed)));
 			break;
 
-		case HDR_MAXFORWARDS:
+		case HDR_MAXFORWARDS_T:
 			break;
 
-		case HDR_ROUTE:
+		case HDR_ROUTE_T:
 			free_rr((rr_t**)(&hf->parsed));
 			break;
 
-		case HDR_RECORDROUTE:
+		case HDR_RECORDROUTE_T:
 			free_rr((rr_t**)(&hf->parsed));
 			break;
 
-		case HDR_CONTENTTYPE:
+		case HDR_CONTENTTYPE_T:
 			break;
 
-		case HDR_CONTENTLENGTH:
+		case HDR_CONTENTLENGTH_T:
 			break;
 
-		case HDR_AUTHORIZATION:
+		case HDR_AUTHORIZATION_T:
 			free_credentials((auth_body_t**)(&(hf->parsed)));
 			break;
 
-		case HDR_EXPIRES:
+		case HDR_EXPIRES_T:
 			free_expires((exp_body_t**)(&(hf->parsed)));
 			break;
 
-		case HDR_PROXYAUTH:
+		case HDR_PROXYAUTH_T:
 			free_credentials((auth_body_t**)(&(hf->parsed)));
 			break;
 
-		case HDR_SUPPORTED:
+		case HDR_SUPPORTED_T:
 			break;
 
-		case HDR_PROXYREQUIRE:
+		case HDR_PROXYREQUIRE_T:
 			break;
 
-		case HDR_UNSUPPORTED:
+		case HDR_UNSUPPORTED_T:
 			break;
 
-		case HDR_ALLOW:
+		case HDR_ALLOW_T:
 			break;
 
-		case HDR_EVENT:
+		case HDR_EVENT_T:
 			free_event((event_t**)(&(hf->parsed)));
 			break;
 
-		case HDR_ACCEPT:
+		case HDR_ACCEPT_T:
 			pkg_free(hf->parsed);
 			break;
 
-		case HDR_ACCEPTLANGUAGE:
+		case HDR_ACCEPTLANGUAGE_T:
 			break;
 			
-		case HDR_ORGANIZATION:
+		case HDR_ORGANIZATION_T:
 			break;
 			
-		case HDR_PRIORITY:
+		case HDR_PRIORITY_T:
 			break;
 
-		case HDR_SUBJECT:
+		case HDR_SUBJECT_T:
 			break;
 
-		case HDR_USERAGENT:
+		case HDR_USERAGENT_T:
 			break;
 
-		case HDR_ACCEPTDISPOSITION:
+		case HDR_ACCEPTDISPOSITION_T:
 			break;
 
-		case HDR_CONTENTDISPOSITION:
+		case HDR_CONTENTDISPOSITION_T:
 			free_disposition( ((struct disposition**)(&hf->parsed)) );
 			break;
 
-		case HDR_DIVERSION:
+		case HDR_DIVERSION_T:
 			free_to(hf->parsed);
 			break;
 
-		case HDR_RPID:
+		case HDR_RPID_T:
 			free_to(hf->parsed);
 			break;
 
-		case HDR_REFER_TO:
+		case HDR_REFER_TO_T:
 			free_to(hf->parsed);
 			break;
 

+ 122 - 42
parser/hf.h

@@ -29,6 +29,8 @@
  * 2003-02-28 scratchpad compatibility abandoned (jiri)
  * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
  * 2003-05-01 HDR_ACCEPT added (janakj)
+ * 2005-02-14 hdr_flags_t && hdr_flags_f defined, split HDR_xxx into
+ *             HDR_xxx_F & HDR_xxx_T [WARNING: don't mix them!] (andrei)
  */
 
 
@@ -39,57 +41,109 @@
 #include "../comp_defs.h"
 
 
-/* Header types and flags */
-#define HDR_EOH         	     -1   /* End of header found */
-#define HDR_ERROR                     0   /* Error while parsing */
-#define HDR_VIA                       1   /* Via header field */
-#define HDR_VIA1                      1   /* First Via header field */
-#define HDR_VIA2               (1 <<  1)  /* only used as flag*/
-#define HDR_TO                 (1 <<  2)  /* To header field */
-#define HDR_FROM               (1 <<  3)  /* From header field */
-#define HDR_CSEQ               (1 <<  4)  /* CSeq header field */
-#define HDR_CALLID             (1 <<  5)  /* Call-Id header field */
-#define HDR_CONTACT            (1 <<  6)  /* Contact header field */
-#define HDR_MAXFORWARDS        (1 <<  7)  /* MaxForwards header field */
-#define HDR_ROUTE              (1 <<  8)  /* Route header field */
-#define HDR_RECORDROUTE        (1 <<  9)  /* Record-Route header field */
-#define HDR_CONTENTTYPE        (1 << 10)  /* Content-Type header field */
-#define HDR_CONTENTLENGTH      (1 << 11)  /* Content-Length header field */
-#define HDR_AUTHORIZATION      (1 << 12)  /* Authorization header field */
-#define HDR_EXPIRES            (1 << 13)  /* Expires header field */
-#define HDR_PROXYAUTH          (1 << 14)  /* Proxy-Authorization hdr field */
-#define HDR_SUPPORTED          (1 << 15)  /* Supported  header field */
-#define HDR_PROXYREQUIRE       (1 << 16)  /* Proxy-Require header field */
-#define HDR_UNSUPPORTED        (1 << 17)  /* Unsupported header field */
-#define HDR_ALLOW              (1 << 18)  /* Allow header field */
-#define HDR_EVENT              (1 << 19)  /* Event header field */
-#define HDR_ACCEPT             (1 << 20)  /* Accept header field */
-#define HDR_ACCEPTLANGUAGE     (1 << 21)  /* Accept-Language header field */
-#define HDR_ORGANIZATION       (1 << 22)  /* Organization header field */
-#define HDR_PRIORITY           (1 << 23)  /* Priority header field */
-#define HDR_SUBJECT            (1 << 24)  /* Subject header field */
-#define HDR_USERAGENT          (1 << 25)  /* User-Agent header field */
-#define HDR_ACCEPTDISPOSITION  (1 << 26)  /* Accept-Disposition hdr field */
-#define HDR_CONTENTDISPOSITION (1 << 27)  /* Content-Disposition hdr field */
-#define HDR_DIVERSION          (1 << 28)  /* Diversion header field */
-#define HDR_RPID               (1 << 29)  /* Remote-Party-ID header field */
-#define HDR_REFER_TO           (1 << 30)  /* Remote-Party-ID header field */
-#define HDR_OTHER              (1 << 31)  /* Some other header field */
 
+/* header type enum
+ * if you add a new type:
+ *  - make sure it's not greater than 63
+ *  - make sure you add the corresponding flag to the hdr_flags_t defs below
+ *  - update clean_hdr_field (in hf.c)
+ *  - update sip_msg_cloner (modules/tm/sip_msg.c)
+ *  - update parse_headers (msg_parser.c)
+ */
 
-/* returns true if the header links allocated memory on parse field */
-#define hdr_allocs_parse( _hdr ) \
-	(((_hdr)->type)&(HDR_VIA|HDR_TO|HDR_FROM|HDR_CONTACT|HDR_ROUTE|\
-		HDR_RECORDROUTE|HDR_AUTHORIZATION|HDR_EXPIRES|HDR_PROXYAUTH|\
-		HDR_EVENT|HDR_ACCEPT|HDR_CONTENTDISPOSITION|HDR_DIVERSION|HDR_RPID|HDR_REFER_TO))
+enum _hdr_types_t {
+	HDR_ERROR_T					= -1   /* Error while parsing */,
+	HDR_VIA_T					=  0   /* Via header field */,
+	HDR_VIA1_T					=  0   /* First Via header field */,
+	HDR_VIA2_T					=  1   /* only used as flag */,
+	HDR_TO_T					       /* To header field */,
+	HDR_FROM_T					       /* From header field */,
+	HDR_CSEQ_T					       /* CSeq header field */,
+	HDR_CALLID_T				       /* Call-Id header field */,
+	HDR_CONTACT_T				       /* Contact header field */,
+	HDR_MAXFORWARDS_T			       /* MaxForwards header field */,
+	HDR_ROUTE_T					       /* Route header field */,
+	HDR_RECORDROUTE_T			       /* Record-Route header field */,
+	HDR_CONTENTTYPE_T			       /* Content-Type header field */,
+	HDR_CONTENTLENGTH_T			       /* Content-Length header field */,
+	HDR_AUTHORIZATION_T			       /* Authorization header field */,
+	HDR_EXPIRES_T				       /* Expires header field */,
+	HDR_PROXYAUTH_T				       /* Proxy-Authorization hdr field */,
+	HDR_SUPPORTED_T				       /* Supported  header field */,
+	HDR_PROXYREQUIRE_T			       /* Proxy-Require header field */,
+	HDR_UNSUPPORTED_T			       /* Unsupported header field */,
+	HDR_ALLOW_T					       /* Allow header field */,
+	HDR_EVENT_T					       /* Event header field */,
+	HDR_ACCEPT_T				       /* Accept header field */,
+	HDR_ACCEPTLANGUAGE_T		       /* Accept-Language header field */,
+	HDR_ORGANIZATION_T			       /* Organization header field */,
+	HDR_PRIORITY_T				       /* Priority header field */,
+	HDR_SUBJECT_T				       /* Subject header field */,
+	HDR_USERAGENT_T				       /* User-Agent header field */,
+	HDR_ACCEPTDISPOSITION_T		       /* Accept-Disposition hdr field */,
+	HDR_CONTENTDISPOSITION_T	       /* Content-Disposition hdr field */,
+	HDR_DIVERSION_T				       /* Diversion header field */,
+	HDR_RPID_T					       /* Remote-Party-ID header field */,
+	HDR_REFER_TO_T				       /* Refer-To header fiels */,
+	HDR_OTHER_T					       /* Some other header field */,
+	HDR_EOH_T					       /* end of headers */
+};
 
 
+typedef unsigned long long hdr_flags_t;
+
+/* type to flag conversion
+ * WARNING: HDR_ERROR_T has no corresponding FLAG ! */
+#define HDR_T2F(type)	\
+		(((type)!=HDR_EOH_T)?((hdr_flags_t)1<<(type)):(~(hdr_flags_t)0))
+
+/* helper macro for easy defining and keeping in sync. the flags enum */
+#define HDR_F_DEF(name)		HDR_T2F(HDR_##name##_T)
+
+/* flags definitions
+ * (enum won't work with all the compiler (e.g. icc) due to the 64bit size) */
+#define HDR_EOH_F					HDR_F_DEF(EOH)
+#define HDR_VIA_F					HDR_F_DEF(VIA)
+#define HDR_VIA1_F					HDR_F_DEF(VIA1)
+#define HDR_VIA2_F					HDR_F_DEF(VIA2)
+#define HDR_TO_F					HDR_F_DEF(TO)
+#define HDR_FROM_F					HDR_F_DEF(FROM)
+#define HDR_CSEQ_F					HDR_F_DEF(CSEQ)
+#define HDR_CALLID_F				HDR_F_DEF(CALLID)
+#define HDR_CONTACT_F				HDR_F_DEF(CONTACT)
+#define HDR_MAXFORWARDS_F			HDR_F_DEF(MAXFORWARDS)
+#define HDR_ROUTE_F					HDR_F_DEF(ROUTE)
+#define HDR_RECORDROUTE_F			HDR_F_DEF(RECORDROUTE)
+#define HDR_CONTENTTYPE_F			HDR_F_DEF(CONTENTTYPE)
+#define HDR_CONTENTLENGTH_F			HDR_F_DEF(CONTENTLENGTH)
+#define HDR_AUTHORIZATION_F			HDR_F_DEF(AUTHORIZATION)
+#define HDR_EXPIRES_F				HDR_F_DEF(EXPIRES)
+#define HDR_PROXYAUTH_F				HDR_F_DEF(PROXYAUTH)
+#define HDR_SUPPORTED_F				HDR_F_DEF(SUPPORTED)
+#define HDR_PROXYREQUIRE_F			HDR_F_DEF(PROXYREQUIRE)
+#define HDR_UNSUPPORTED_F			HDR_F_DEF(UNSUPPORTED)
+#define HDR_ALLOW_F					HDR_F_DEF(ALLOW)
+#define HDR_EVENT_F					HDR_F_DEF(EVENT)
+#define HDR_ACCEPT_F				HDR_F_DEF(ACCEPT)
+#define HDR_ACCEPTLANGUAGE_F		HDR_F_DEF(ACCEPTLANGUAGE)
+#define HDR_ORGANIZATION_F			HDR_F_DEF(ORGANIZATION)
+#define HDR_PRIORITY_F				HDR_F_DEF(PRIORITY)
+#define HDR_SUBJECT_F				HDR_F_DEF(SUBJECT)
+#define HDR_USERAGENT_F				HDR_F_DEF(USERAGENT)
+#define HDR_ACCEPTDISPOSITION_F		HDR_F_DEF(ACCEPTDISPOSITION)
+#define HDR_CONTENTDISPOSITION_F	HDR_F_DEF(CONTENTDISPOSITION)
+#define HDR_DIVERSION_F				HDR_F_DEF(DIVERSION)
+#define HDR_RPID_F					HDR_F_DEF(RPID)
+#define HDR_REFER_TO_F				HDR_F_DEF(REFER_TO)
+#define HDR_OTHER_F					HDR_F_DEF(OTHER)
+
+typedef enum _hdr_types_t hdr_types_t;
 
 /* 
  * Format: name':' body 
  */
 struct hdr_field {   
-	int type;               /* Header field type */
+	hdr_types_t type;       /* Header field type */
 	str name;               /* Header field name */
 	str body;               /* Header field body (may not include CRLF) */
 	int len;		/* length from hdr start until EoHF (incl.CRLF) */
@@ -98,6 +152,32 @@ struct hdr_field {
 };
 
 
+
+/* returns true if the header links allocated memory on parse field */
+static inline int hdr_allocs_parse(struct hdr_field* hdr)
+{
+	switch(hdr->type){
+		case HDR_VIA_T:
+		case HDR_TO_T:
+		case HDR_FROM_T:
+		case HDR_CONTACT_T:
+		case HDR_ROUTE_T:
+		case HDR_RECORDROUTE_T:
+		case HDR_AUTHORIZATION_T:
+		case HDR_EXPIRES_T:
+		case HDR_PROXYAUTH_T:
+		case HDR_EVENT_T:
+		case HDR_ACCEPT_T:
+		case HDR_CONTENTDISPOSITION_T:
+		case HDR_DIVERSION_T:
+		case HDR_RPID_T:
+		case HDR_REFER_TO_T:
+			return 1;
+		default:
+			return 0;
+	}
+}
+
 /* frees a hdr_field structure,
  * WARNING: it frees only parsed (and not name.s, body.s)
  */

+ 115 - 110
parser/msg_parser.c

@@ -35,6 +35,7 @@
  *  2003-03-31  removed msg->repl_add_rm (andrei)
  *  2003-04-26 ZSW (jiri)
  *  2003-05-01  parser extended to support Accept header field (janakj)
+ *  2005-02-23  parse_headers uses hdr_flags_t now (andrei)
  */
 
 
@@ -80,12 +81,12 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 	if ((*buf)=='\n' || (*buf)=='\r'){
 		/* double crlf or lflf or crcr */
 		DBG("found end of header\n");
-		hdr->type=HDR_EOH;
+		hdr->type=HDR_EOH_T;
 		return buf;
 	}
 
 	tmp=parse_hname(buf, end, hdr);
-	if (hdr->type==HDR_ERROR){
+	if (hdr->type==HDR_ERROR_T){
 		LOG(L_ERR, "ERROR: get_hdr_field: bad header\n");
 		goto error;
 	}
@@ -102,7 +103,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 	 * next header field
 	 */
 	switch(hdr->type){
-		case HDR_VIA:
+		case HDR_VIA_T:
 			/* keep number of vias parsed -- we want to report it in
 			   replies for diagnostic purposes */
 			via_cnt++;
@@ -124,7 +125,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 			vb->hdr.len=hdr->name.len;
 			hdr->body.len=tmp-hdr->body.s;
 			break;
-		case HDR_CSEQ:
+		case HDR_CSEQ_T:
 			cseq_b=pkg_malloc(sizeof(struct cseq_body));
 			if (cseq_b==0){
 				LOG(L_ERR, "get_hdr_field: out of memory\n");
@@ -145,7 +146,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 					cseq_b->number.len, ZSW(cseq_b->number.s), 
 					cseq_b->method.len, cseq_b->method.s);
 			break;
-		case HDR_TO:
+		case HDR_TO_T:
 			to_b=pkg_malloc(sizeof(struct to_body));
 			if (to_b==0){
 				LOG(L_ERR, "get_hdr_field: out of memory\n");
@@ -167,7 +168,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 			DBG("DEBUG: to body [%.*s]\n",to_b->body.len,
 				ZSW(to_b->body.s));
 			break;
-		case HDR_CONTENTLENGTH:
+		case HDR_CONTENTLENGTH_T:
 			hdr->body.s=tmp;
 			tmp=parse_content_length(tmp,end, &integer);
 			if (tmp==0){
@@ -179,33 +180,33 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 			DBG("DEBUG: get_hdr_body : content_length=%d\n",
 					(int)(long)hdr->parsed);
 			break;
-		case HDR_SUPPORTED:
-		case HDR_CONTENTTYPE:
-		case HDR_FROM:
-		case HDR_CALLID:
-		case HDR_CONTACT:
-		case HDR_ROUTE:
-		case HDR_RECORDROUTE:
-		case HDR_MAXFORWARDS:
-		case HDR_AUTHORIZATION:
-		case HDR_EXPIRES:
-		case HDR_PROXYAUTH:
-		case HDR_PROXYREQUIRE:
-		case HDR_UNSUPPORTED:
-		case HDR_ALLOW:
-		case HDR_EVENT:
-	        case HDR_ACCEPT:
-	        case HDR_ACCEPTLANGUAGE:
-	        case HDR_ORGANIZATION:
-	        case HDR_PRIORITY:
-	        case HDR_SUBJECT:
-	        case HDR_USERAGENT:
-	        case HDR_CONTENTDISPOSITION:
-	        case HDR_ACCEPTDISPOSITION:
-	        case HDR_DIVERSION:
-	        case HDR_RPID:
-	        case HDR_REFER_TO:
-		case HDR_OTHER:
+		case HDR_SUPPORTED_T:
+		case HDR_CONTENTTYPE_T:
+		case HDR_FROM_T:
+		case HDR_CALLID_T:
+		case HDR_CONTACT_T:
+		case HDR_ROUTE_T:
+		case HDR_RECORDROUTE_T:
+		case HDR_MAXFORWARDS_T:
+		case HDR_AUTHORIZATION_T:
+		case HDR_EXPIRES_T:
+		case HDR_PROXYAUTH_T:
+		case HDR_PROXYREQUIRE_T:
+		case HDR_UNSUPPORTED_T:
+		case HDR_ALLOW_T:
+		case HDR_EVENT_T:
+		case HDR_ACCEPT_T:
+		case HDR_ACCEPTLANGUAGE_T:
+		case HDR_ORGANIZATION_T:
+		case HDR_PRIORITY_T:
+		case HDR_SUBJECT_T:
+		case HDR_USERAGENT_T:
+		case HDR_CONTENTDISPOSITION_T:
+		case HDR_ACCEPTDISPOSITION_T:
+		case HDR_DIVERSION_T:
+		case HDR_RPID_T:
+		case HDR_REFER_TO_T:
+		case HDR_OTHER_T:
 			/* just skip over it */
 			hdr->body.s=tmp;
 			/* find end of header */
@@ -238,7 +239,7 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 	return tmp;
 error:
 	DBG("get_hdr_field: error exit\n");
-	hdr->type=HDR_ERROR;
+	hdr->type=HDR_ERROR_T;
 	hdr->len=tmp-hdr->name.s;
 	return tmp;
 }
@@ -247,7 +248,10 @@ error:
 
 /* parse the headers and adds them to msg->headers and msg->to, from etc.
  * It stops when all the headers requested in flags were parsed, on error
- * (bad header) or end of headers */
+ * (bad header) or end of headers
+ * WARNING: parse_headers was changed to use hdr_flags_t (the flags are now
+ *          different from the header types). Don't call it with a header type
+ *          (HDR_xxx_T), only with header flags (HDR_xxx_F)!*/
 /* note: it continues where it previously stopped and goes ahead until
    end is encountered or desired HFs are found; if you call it twice
    for the same HF which is present only once, it will fail the second
@@ -257,13 +261,13 @@ error:
    give you the first occurrence of a header you are interested in,
    look at check_transaction_quadruple
 */
-int parse_headers(struct sip_msg* msg, int flags, int next)
+int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next)
 {
 	struct hdr_field* hf;
 	char* tmp;
 	char* rest;
 	char* end;
-	int orig_flag;
+	hdr_flags_t orig_flag;
 
 	end=msg->buf+msg->len;
 	tmp=msg->unparsed;
@@ -274,7 +278,7 @@ int parse_headers(struct sip_msg* msg, int flags, int next)
 	}else
 		orig_flag=0; 
 	
-	DBG("parse_headers: flags=%d\n", flags);
+	DBG("parse_headers: flags=%llx\n", (unsigned long long)flags);
 	while( tmp<end && (flags & msg->parsed_flag) != flags){
 		hf=pkg_malloc(sizeof(struct hdr_field));
 		if (hf==0){
@@ -283,150 +287,151 @@ int parse_headers(struct sip_msg* msg, int flags, int next)
 			goto error;
 		}
 		memset(hf,0, sizeof(struct hdr_field));
-		hf->type=HDR_ERROR;
+		hf->type=HDR_ERROR_T;
 		rest=get_hdr_field(tmp, msg->buf+msg->len, hf);
 		switch (hf->type){
-			case HDR_ERROR:
+			case HDR_ERROR_T:
 				LOG(L_INFO,"ERROR: bad header  field\n");
 				goto  error;
-			case HDR_EOH:
+			case HDR_EOH_T:
 				msg->eoh=tmp; /* or rest?*/
-				msg->parsed_flag|=HDR_EOH;
+				msg->parsed_flag|=HDR_EOH_F;
 				pkg_free(hf);
 				goto skip;
-			case HDR_OTHER: /*do nothing*/
+			case HDR_OTHER_T: /*do nothing*/
 				break;
-			case HDR_CALLID:
+			case HDR_CALLID_T:
 				if (msg->callid==0) msg->callid=hf;
-				msg->parsed_flag|=HDR_CALLID;
+				msg->parsed_flag|=HDR_CALLID_F;
 				break;
-			case HDR_TO:
+			case HDR_TO_T:
 				if (msg->to==0) msg->to=hf;
-				msg->parsed_flag|=HDR_TO;
+				msg->parsed_flag|=HDR_TO_F;
 				break;
-			case HDR_CSEQ:
+			case HDR_CSEQ_T:
 				if (msg->cseq==0) msg->cseq=hf;
-				msg->parsed_flag|=HDR_CSEQ;
+				msg->parsed_flag|=HDR_CSEQ_F;
 				break;
-			case HDR_FROM:
+			case HDR_FROM_T:
 				if (msg->from==0) msg->from=hf;
-				msg->parsed_flag|=HDR_FROM;
+				msg->parsed_flag|=HDR_FROM_F;
 				break;
-			case HDR_CONTACT:
+			case HDR_CONTACT_T:
 				if (msg->contact==0) msg->contact=hf;
-				msg->parsed_flag|=HDR_CONTACT;
+				msg->parsed_flag|=HDR_CONTACT_F;
 				break;
-			case HDR_MAXFORWARDS:
+			case HDR_MAXFORWARDS_T:
 				if(msg->maxforwards==0) msg->maxforwards=hf;
-				msg->parsed_flag|=HDR_MAXFORWARDS;
+				msg->parsed_flag|=HDR_MAXFORWARDS_F;
 				break;
-			case HDR_ROUTE:
+			case HDR_ROUTE_T:
 				if (msg->route==0) msg->route=hf;
-				msg->parsed_flag|=HDR_ROUTE;
+				msg->parsed_flag|=HDR_ROUTE_F;
 				break;
-			case HDR_RECORDROUTE:
+			case HDR_RECORDROUTE_T:
 				if (msg->record_route==0) msg->record_route = hf;
-				msg->parsed_flag|=HDR_RECORDROUTE;
+				msg->parsed_flag|=HDR_RECORDROUTE_F;
 				break;
-			case HDR_CONTENTTYPE:
+			case HDR_CONTENTTYPE_T:
 				if (msg->content_type==0) msg->content_type = hf;
-				msg->parsed_flag|=HDR_CONTENTTYPE;
+				msg->parsed_flag|=HDR_CONTENTTYPE_F;
 				break;
-			case HDR_CONTENTLENGTH:
+			case HDR_CONTENTLENGTH_T:
 				if (msg->content_length==0) msg->content_length = hf;
-				msg->parsed_flag|=HDR_CONTENTLENGTH;
+				msg->parsed_flag|=HDR_CONTENTLENGTH_F;
 				break;
-			case HDR_AUTHORIZATION:
+			case HDR_AUTHORIZATION_T:
 				if (msg->authorization==0) msg->authorization = hf;
-				msg->parsed_flag|=HDR_AUTHORIZATION;
+				msg->parsed_flag|=HDR_AUTHORIZATION_F;
 				break;
-			case HDR_EXPIRES:
+			case HDR_EXPIRES_T:
 				if (msg->expires==0) msg->expires = hf;
-				msg->parsed_flag|=HDR_EXPIRES;
+				msg->parsed_flag|=HDR_EXPIRES_F;
 				break;
-			case HDR_PROXYAUTH:
+			case HDR_PROXYAUTH_T:
 				if (msg->proxy_auth==0) msg->proxy_auth = hf;
-				msg->parsed_flag|=HDR_PROXYAUTH;
+				msg->parsed_flag|=HDR_PROXYAUTH_F;
 				break;
-		        case HDR_PROXYREQUIRE:
+			case HDR_PROXYREQUIRE_T:
 				if (msg->proxy_require==0) msg->proxy_require = hf;
-				msg->parsed_flag|=HDR_PROXYREQUIRE;
+				msg->parsed_flag|=HDR_PROXYREQUIRE_F;
 				break;
-	                case HDR_SUPPORTED:
+			case HDR_SUPPORTED_T:
 				if (msg->supported==0) msg->supported=hf;
-				msg->parsed_flag|=HDR_SUPPORTED;
+				msg->parsed_flag|=HDR_SUPPORTED_F;
 				break;
-			case HDR_UNSUPPORTED:
+			case HDR_UNSUPPORTED_T:
 				if (msg->unsupported==0) msg->unsupported=hf;
-				msg->parsed_flag|=HDR_UNSUPPORTED;
+				msg->parsed_flag|=HDR_UNSUPPORTED_F;
 				break;
-			case HDR_ALLOW:
+			case HDR_ALLOW_T:
 				if (msg->allow==0) msg->allow = hf;
-				msg->parsed_flag|=HDR_ALLOW;
+				msg->parsed_flag|=HDR_ALLOW_F;
 				break;
-			case HDR_EVENT:
+			case HDR_EVENT_T:
 				if (msg->event==0) msg->event = hf;
-				msg->parsed_flag|=HDR_EVENT;
+				msg->parsed_flag|=HDR_EVENT_F;
 				break;
-		        case HDR_ACCEPT:
+			case HDR_ACCEPT_T:
 				if (msg->accept==0) msg->accept = hf;
-				msg->parsed_flag|=HDR_ACCEPT;
+				msg->parsed_flag|=HDR_ACCEPT_F;
 				break;
-		        case HDR_ACCEPTLANGUAGE:
+			case HDR_ACCEPTLANGUAGE_T:
 				if (msg->accept_language==0) msg->accept_language = hf;
-				msg->parsed_flag|=HDR_ACCEPTLANGUAGE;
+				msg->parsed_flag|=HDR_ACCEPTLANGUAGE_F;
 				break;
-		        case HDR_ORGANIZATION:
+			case HDR_ORGANIZATION_T:
 				if (msg->organization==0) msg->organization = hf;
-				msg->parsed_flag|=HDR_ORGANIZATION;
+				msg->parsed_flag|=HDR_ORGANIZATION_F;
 				break;
-		        case HDR_PRIORITY:
+			case HDR_PRIORITY_T:
 				if (msg->priority==0) msg->priority = hf;
-				msg->parsed_flag|=HDR_PRIORITY;
+				msg->parsed_flag|=HDR_PRIORITY_F;
 				break;
-		        case HDR_SUBJECT:
+			case HDR_SUBJECT_T:
 				if (msg->subject==0) msg->subject = hf;
-				msg->parsed_flag|=HDR_SUBJECT;
+				msg->parsed_flag|=HDR_SUBJECT_F;
 				break;
-		        case HDR_USERAGENT:
+			case HDR_USERAGENT_T:
 				if (msg->user_agent==0) msg->user_agent = hf;
-				msg->parsed_flag|=HDR_USERAGENT;
+				msg->parsed_flag|=HDR_USERAGENT_F;
 				break;
-		        case HDR_CONTENTDISPOSITION:
+			case HDR_CONTENTDISPOSITION_T:
 				if (msg->content_disposition==0) msg->content_disposition = hf;
-				msg->parsed_flag|=HDR_CONTENTDISPOSITION;
+				msg->parsed_flag|=HDR_CONTENTDISPOSITION_F;
 				break;
-		        case HDR_ACCEPTDISPOSITION:
+			case HDR_ACCEPTDISPOSITION_T:
 				if (msg->accept_disposition==0) msg->accept_disposition = hf;
-				msg->parsed_flag|=HDR_ACCEPTDISPOSITION;
+				msg->parsed_flag|=HDR_ACCEPTDISPOSITION_F;
 				break;
-		        case HDR_DIVERSION:
+			case HDR_DIVERSION_T:
 				if (msg->diversion==0) msg->diversion = hf;
-				msg->parsed_flag|=HDR_DIVERSION;
+				msg->parsed_flag|=HDR_DIVERSION_F;
 				break;
-		        case HDR_RPID:
+			case HDR_RPID_T:
 				if (msg->rpid==0) msg->rpid = hf;
-				msg->parsed_flag|=HDR_RPID;
+				msg->parsed_flag|=HDR_RPID_F;
 				break;
-		        case HDR_REFER_TO:
+			case HDR_REFER_TO_T:
 				if (msg->refer_to==0) msg->refer_to = hf;
-				msg->parsed_flag|=HDR_REFER_TO;
+				msg->parsed_flag|=HDR_REFER_TO_F;
 				break;
-			case HDR_VIA:
-				msg->parsed_flag|=HDR_VIA;
-				DBG("parse_headers: Via found, flags=%d\n", flags);
+			case HDR_VIA_T:
+				msg->parsed_flag|=HDR_VIA_F;
+				DBG("parse_headers: Via found, flags=%llx\n",
+						(unsigned long long)flags);
 				if (msg->via1==0) {
 					DBG("parse_headers: this is the first via\n");
 					msg->h_via1=hf;
 					msg->via1=hf->parsed;
 					if (msg->via1->next){
 						msg->via2=msg->via1->next;
-						msg->parsed_flag|=HDR_VIA2;
+						msg->parsed_flag|=HDR_VIA2_F;
 					}
 				}else if (msg->via2==0){
 					msg->h_via2=hf;
 					msg->via2=hf->parsed;
-					msg->parsed_flag|=HDR_VIA2;
+					msg->parsed_flag|=HDR_VIA2_F;
 					DBG("parse_headers: this is the second via\n");
 				}
 				break;
@@ -476,7 +481,7 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
 	char* second_via;
 	struct msg_start *fl;
 	int offset;
-	int flags;
+	hdr_flags_t flags;
 
 	/* eat crlf from the beginning */
 	for (tmp=buf; (*tmp=='\n' || *tmp=='\r')&&
@@ -502,7 +507,7 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
 				ZSW(fl->u.request.uri.s));
 			DBG(" version: <%.*s>\n",fl->u.request.version.len,
 				ZSW(fl->u.request.version.s));
-			flags=HDR_VIA;
+			flags=HDR_VIA_F;
 			break;
 		case SIP_REPLY:
 			DBG("SIP Reply  (status):\n");
@@ -514,7 +519,7 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
 					ZSW(fl->u.reply.reason.s));
 			/* flags=HDR_VIA | HDR_VIA2; */
 			/* we don't try to parse VIA2 for local messages; -Jiri */
-			flags=HDR_VIA;
+			flags=HDR_VIA_F;
 			break;
 		default:
 			DBG("unknown type %d\n",fl->type);
@@ -619,7 +624,7 @@ void free_sip_msg(struct sip_msg* msg)
 
 int check_transaction_quadruple( struct sip_msg* msg )
 {
-	if ( parse_headers(msg, HDR_FROM|HDR_TO|HDR_CALLID|HDR_CSEQ,0)!=-1
+	if ( parse_headers(msg, HDR_FROM_F|HDR_TO_F|HDR_CALLID_F|HDR_CSEQ_F,0)!=-1
 		&& msg->from && msg->to && msg->callid && msg->cseq ) {
 		return 1;
 	} else {

+ 3 - 3
parser/msg_parser.h

@@ -157,7 +157,7 @@ struct sip_msg {
 	struct via_body* via2;         /* The second via */
 	struct hdr_field* headers;     /* All the parsed headers*/
 	struct hdr_field* last_header; /* Pointer to the last parsed header*/
-	int parsed_flag;               /* Already parsed header field types */
+	hdr_flags_t parsed_flag;    /* Already parsed header field types */
 
 	     /* Via, To, CSeq, Call-Id, From, end of header*/
 	     /* pointers to the first occurrences of these headers;
@@ -254,7 +254,7 @@ extern int via_cnt;
 
 int parse_msg(char* buf, unsigned int len, struct sip_msg* msg);
 
-int parse_headers(struct sip_msg* msg, int flags, int next);
+int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next);
 
 char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr);
 
@@ -307,7 +307,7 @@ inline static char* get_body(struct sip_msg *msg)
 	int offset;
 	int len;
 
-	if ( parse_headers(msg,HDR_EOH, 0)==-1 )
+	if ( parse_headers(msg, HDR_EOH_F, 0)==-1 )
 		return 0;
 
 	if (msg->unparsed){

+ 2 - 2
parser/parse_content.c

@@ -348,7 +348,7 @@ int parse_content_type_hdr( struct sip_msg *msg )
 	/* is the header already found? */
 	if ( msg->content_type==0 ) {
 		/* if not, found it */
-		if ( parse_headers(msg,HDR_CONTENTTYPE,0)==-1)
+		if ( parse_headers(msg, HDR_CONTENTTYPE_F, 0)==-1)
 			goto error;
 		if ( msg->content_type==0 ) {
 			DBG("DEBUG:parse_content_type_hdr: missing Content-Type"
@@ -400,7 +400,7 @@ int parse_accept_hdr( struct sip_msg *msg )
 	/* is the header already found? */
 	if ( msg->accept==0 ) {
 		/* if not, found it */
-		if ( parse_headers(msg,HDR_ACCEPT,0)==-1)
+		if ( parse_headers(msg, HDR_ACCEPT_F, 0)==-1)
 			goto error;
 		if ( msg->accept==0 ) {
 			DBG("DEBUG:parse_accept_hdr: missing Accept header\n");

+ 1 - 1
parser/parse_disposition.c

@@ -376,7 +376,7 @@ int parse_content_disposition( struct sip_msg *msg )
 
 	/* look for Content-Disposition header */
 	if (msg->content_disposition==0) {
-		if (parse_headers(msg,HDR_CONTENTDISPOSITION,0)==-1)
+		if (parse_headers(msg, HDR_CONTENTDISPOSITION_F, 0)==-1)
 			goto error;
 		if (msg->content_disposition==0) {
 			DBG("DEBUG:parse_content_disposition: hdr not found\n");

+ 2 - 1
parser/parse_diversion.c

@@ -45,7 +45,8 @@ int parse_diversion_header(struct sip_msg *msg)
 {
  	struct to_body* diversion_b;
 	
- 	if (!msg->diversion && (parse_headers(msg, HDR_DIVERSION, 0) == -1 || !msg->diversion)) {
+ 	if (!msg->diversion && (parse_headers(msg, HDR_DIVERSION_F, 0) == -1 ||
+				!msg->diversion)) {
  		goto error;
  	}
  

+ 1 - 1
parser/parse_from.c

@@ -48,7 +48,7 @@ int parse_from_header( struct sip_msg *msg)
 {
 	struct to_body* from_b;
 
-	if ( !msg->from && ( parse_headers(msg,HDR_FROM,0)==-1 || !msg->from)) {
+	if ( !msg->from && ( parse_headers(msg,HDR_FROM_F,0)==-1 || !msg->from)) {
 		LOG(L_ERR,"ERROR:parse_from_header: bad msg or missing FROM header\n");
 		goto error;
 	}

+ 13 - 13
parser/parse_hname2.c

@@ -139,7 +139,7 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
 	register unsigned int val;
 
 	if ((end - begin) < 4) {
-		hdr->type = HDR_ERROR;
+		hdr->type = HDR_ERROR_T;
 		return begin;
 	}
 
@@ -157,25 +157,25 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
 			switch(LOWER_BYTE(*(p + 1))) {          
 			case 'o':                   
 			case ' ':                   
-				hdr->type = HDR_TO; 
+				hdr->type = HDR_TO_T; 
 				p += 2;             
 				goto dc_end;        
 				
 			case ':':                   
-				hdr->type = HDR_TO; 
+				hdr->type = HDR_TO_T; 
 				hdr->name.len = 1;  
 				return (p + 2);     
 			}                           
 			break;
 
-		case 'v': PARSE_COMPACT(HDR_VIA);           break;
-		case 'f': PARSE_COMPACT(HDR_FROM);          break;
-		case 'i': PARSE_COMPACT(HDR_CALLID);        break;
-		case 'm': PARSE_COMPACT(HDR_CONTACT);       break;
-		case 'l': PARSE_COMPACT(HDR_CONTENTLENGTH); break;
-		case 'k': PARSE_COMPACT(HDR_SUPPORTED);     break;
-		case 'c': PARSE_COMPACT(HDR_CONTENTTYPE);   break;
-		case 'o': PARSE_COMPACT(HDR_EVENT);         break;
+		case 'v': PARSE_COMPACT(HDR_VIA_T);           break;
+		case 'f': PARSE_COMPACT(HDR_FROM_T);          break;
+		case 'i': PARSE_COMPACT(HDR_CALLID_T);        break;
+		case 'm': PARSE_COMPACT(HDR_CONTACT_T);       break;
+		case 'l': PARSE_COMPACT(HDR_CONTENTLENGTH_T); break;
+		case 'k': PARSE_COMPACT(HDR_SUPPORTED_T);     break;
+		case 'c': PARSE_COMPACT(HDR_CONTENTTYPE_T);   break;
+		case 'o': PARSE_COMPACT(HDR_EVENT_T);         break;
 		}
 		goto other;
         }
@@ -194,12 +194,12 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
  other:    
 	p = q_memchr(p, ':', end - p);
 	if (!p) {        /* No double colon found, error.. */
-		hdr->type = HDR_ERROR;
+		hdr->type = HDR_ERROR_T;
 		hdr->name.s = 0;
 		hdr->name.len = 0;
 		return 0;
 	} else {
-		hdr->type = HDR_OTHER;
+		hdr->type = HDR_OTHER_T;
 		hdr->name.len = p - hdr->name.s;
 		return (p + 1);
 	}

+ 1 - 1
parser/parse_refer_to.c

@@ -45,7 +45,7 @@ int parse_refer_to_header( struct sip_msg *msg )
 	struct to_body* refer_to_b;
 	
  	if ( !msg->refer_to &&
-	     (parse_headers(msg, HDR_REFER_TO,0)==-1 || !msg->refer_to)) {
+	     (parse_headers(msg, HDR_REFER_TO_F,0)==-1 || !msg->refer_to)) {
  		goto error;
  	}
  

+ 1 - 1
parser/parse_rpid.c

@@ -44,7 +44,7 @@ int parse_rpid_header( struct sip_msg *msg )
 {
 	struct to_body* rpid_b;
 	
- 	if ( !msg->rpid && (parse_headers(msg,HDR_RPID,0)==-1 || !msg->rpid)) {
+ 	if ( !msg->rpid && (parse_headers(msg, HDR_RPID_F, 0)==-1 || !msg->rpid)) {
  		goto error;
  	}
  

+ 7 - 2
route.c

@@ -255,7 +255,12 @@ static int fix_actions(struct action* a)
 					return E_BUG;
 				}
 				he=resolvehost(((struct socket_id*)t->p1.data)->name);
-				if (he==0) return E_BAD_ADDRESS;
+				if (he==0){
+					LOG(L_ERR, "ERROR: fix_actions: force_send_socket:"
+								" could not resolve %s\n",
+							((struct socket_id*)t->p1.data)->name);
+					return E_BAD_ADDRESS;
+				}
 				hostent2ip_addr(&ip, he, 0);
 				si=find_si(&ip, ((struct socket_id*)t->p1.data)->port,
 								((struct socket_id*)t->p1.data)->proto);
@@ -567,7 +572,7 @@ static int eval_elem(struct expr* e, struct sip_msg* msg)
 				}
 				break;
 		case TO_URI_O:
-				if ((msg->to==0) && ((parse_headers(msg, HDR_TO, 0)==-1) ||
+				if ((msg->to==0) && ((parse_headers(msg, HDR_TO_F, 0)==-1) ||
 							(msg->to==0))){
 					LOG(L_ERR, "ERROR: eval_elem: bad or missing"
 								" To: header\n");