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 44 changed files
... ...
@@ -410,7 +410,7 @@ static inline void acc_preparse_req(struct sip_msg *rq)
410 410
 	 * don't be worried about parsing outcome -- if it failed, 
411 411
 	 * we will report N/A
412 412
 	 */
413
-	parse_headers(rq, HDR_CALLID| HDR_FROM| HDR_TO, 0 );
413
+	parse_headers(rq, HDR_CALLID_F| HDR_FROM_F| HDR_TO_F, 0 );
414 414
 	parse_from_header(rq);
415 415
 
416 416
 	if (strchr(log_fmt, 'p') || strchr(log_fmt, 'D')) {
... ...
@@ -491,7 +491,7 @@ static inline void acc_onreply_in(struct cell *t, struct sip_msg *reply,
491 491
 	if (((is_invite(t) && code>=300 && is_mc_on(t->uas.request))
492 492
 					|| should_acc_reply(t,code)) 
493 493
 				&& (reply && reply!=FAKED_REPLY)) {
494
-		parse_headers(reply, HDR_TO, 0 );
494
+		parse_headers(reply, HDR_TO_F, 0 );
495 495
 	}
496 496
 }
497 497
 
... ...
@@ -299,7 +299,7 @@ int get_uri(struct sip_msg* m, str** uri)
299 299
 	if ((REQ_LINE(m).method.len == 8) && 
300 300
 					(memcmp(REQ_LINE(m).method.s, "REGISTER", 8) == 0)) 
301 301
 	{/* REGISTER */
302
-		if (!m->to && ((parse_headers(m, HDR_TO, 0) == -1) || !m->to )) 
302
+		if (!m->to && ((parse_headers(m, HDR_TO_F, 0) == -1) || !m->to )) 
303 303
 		{
304 304
 			LOG(L_ERR, M_NAME": To header field not found or malformed\n");
305 305
 			return -1;
... ...
@@ -61,9 +61,11 @@ void strip_realm(str* _realm)
61 61
 /*
62 62
  * Find credentials with given realm in a SIP message header
63 63
  */
64
-static inline int find_credentials(struct sip_msg* _m, str* _realm, int _hftype, struct hdr_field** _h)
64
+static inline int find_credentials(struct sip_msg* _m, str* _realm,
65
+									hdr_types_t _hftype, struct hdr_field** _h)
65 66
 {
66 67
 	struct hdr_field** hook, *ptr, *prev;
68
+	hdr_flags_t hdr_flags;
67 69
 	int res;
68 70
 	str* r;
69 71
 
... ...
@@ -73,9 +75,18 @@ static inline int find_credentials(struct sip_msg* _m, str* _realm, int _hftype,
73 75
 	      * is set in www_authorize and proxy_authorize
74 76
 	      */
75 77
 	switch(_hftype) {
76
-	case HDR_AUTHORIZATION: hook = &(_m->authorization); break;
77
-	case HDR_PROXYAUTH:     hook = &(_m->proxy_auth);    break;
78
-	default:                hook = &(_m->authorization); break;
78
+	case HDR_AUTHORIZATION_T: 
79
+							hook = &(_m->authorization);
80
+							hdr_flags=HDR_AUTHORIZATION_F;
81
+							break;
82
+	case HDR_PROXYAUTH_T:
83
+							hook = &(_m->proxy_auth);
84
+							hdr_flags=HDR_PROXYAUTH_F;
85
+							break;
86
+	default:				
87
+							hook = &(_m->authorization);
88
+							hdr_flags=HDR_T2F(_hftype);
89
+							break;
79 90
 	}
80 91
 
81 92
 	     /*
... ...
@@ -83,7 +94,7 @@ static inline int find_credentials(struct sip_msg* _m, str* _realm, int _hftype,
83 94
 	      */
84 95
 	if (*hook == 0) {
85 96
 		     /* No credentials parsed yet */
86
-		if (parse_headers(_m, _hftype, 0) == -1) {
97
+		if (parse_headers(_m, hdr_flags, 0) == -1) {
87 98
 			LOG(L_ERR, "find_credentials(): Error while parsing headers\n");
88 99
 			return -1;
89 100
 		}
... ...
@@ -112,7 +123,7 @@ static inline int find_credentials(struct sip_msg* _m, str* _realm, int _hftype,
112 123
 		}
113 124
 
114 125
 		prev = ptr;
115
-		if (parse_headers(_m, _hftype, 1) == -1) {
126
+		if (parse_headers(_m, hdr_flags, 1) == -1) {
116 127
 			LOG(L_ERR, "find_credentials(): Error while parsing headers\n");
117 128
 			return -4;
118 129
 		} else {
... ...
@@ -136,7 +147,8 @@ static inline int find_credentials(struct sip_msg* _m, str* _realm, int _hftype,
136 147
  * we should really authenticate (there must be no authentication for
137 148
  * ACK and CANCEL
138 149
  */
139
-auth_result_t pre_auth(struct sip_msg* _m, str* _realm, int _hftype, struct hdr_field** _h)
150
+auth_result_t pre_auth(struct sip_msg* _m, str* _realm, hdr_types_t _hftype,
151
+						struct hdr_field** _h)
140 152
 {
141 153
 	int ret;
142 154
 	auth_body_t* c;
... ...
@@ -50,8 +50,10 @@ typedef enum auth_result {
50 50
  * we should really authenticate (there must be no authentication for
51 51
  * ACK and CANCEL
52 52
  */
53
-typedef auth_result_t (*pre_auth_t)(struct sip_msg* _m, str* _realm, int _hftype, struct hdr_field** _h);
54
-auth_result_t pre_auth(struct sip_msg* _m, str* _realm, int _hftype, struct hdr_field** _h);
53
+typedef auth_result_t (*pre_auth_t)(struct sip_msg* _m, str* _realm,
54
+								hdr_types_t _hftype, struct hdr_field** _h);
55
+auth_result_t pre_auth(struct sip_msg* _m, str* _realm, hdr_types_t _hftype,
56
+						struct hdr_field** _h);
55 57
 
56 58
 
57 59
 /*
... ...
@@ -135,17 +135,18 @@ static inline int challenge(struct sip_msg* _msg, str* _realm, int _qop,
135 135
 	struct hdr_field* h;
136 136
 	auth_body_t* cred = 0;
137 137
 	char *auth_hf;
138
-	int ret, hftype = 0; /* Makes gcc happy */
138
+	int ret;
139
+	hdr_types_t hftype = 0; /* Makes gcc happy */
139 140
 	struct sip_uri uri;
140 141
 
141 142
 	switch(_code) {
142 143
 	case 401: 
143 144
 		get_authorized_cred(_msg->authorization, &h); 
144
-		hftype = HDR_AUTHORIZATION;
145
+		hftype = HDR_AUTHORIZATION_T;
145 146
 		break;
146 147
 	case 407: 
147 148
 		get_authorized_cred(_msg->proxy_auth, &h);
148
-		hftype = HDR_PROXYAUTH;
149
+		hftype = HDR_PROXYAUTH_T;
149 150
 		break;
150 151
 	}
151 152
 
... ...
@@ -47,15 +47,15 @@
47 47
 /* 
48 48
  * Return parsed To or From, host part of the parsed uri is realm
49 49
  */
50
-int get_realm(struct sip_msg* _m, int _hftype, struct sip_uri* _u)
50
+int get_realm(struct sip_msg* _m, hdr_types_t _hftype, struct sip_uri* _u)
51 51
 {
52 52
 	str uri;
53 53
 
54 54
 	if ((REQ_LINE(_m).method.len == 8) 
55 55
 	    && !memcmp(REQ_LINE(_m).method.s, "REGISTER", 8) 
56
-	    && (_hftype == HDR_AUTHORIZATION)
56
+	    && (_hftype == HDR_AUTHORIZATION_T)
57 57
 	   ) {
58
-		if (!_m->to && ((parse_headers(_m, HDR_TO, 0) == -1) || (!_m->to))) {
58
+		if (!_m->to && ((parse_headers(_m, HDR_TO_F, 0) == -1) || (!_m->to))) {
59 59
 			LOG(L_ERR, "get_realm(): Error while parsing headers\n");
60 60
 			return -1;
61 61
 		}
... ...
@@ -77,7 +77,7 @@ static inline int append_rpid_helper(struct sip_msg* _m, str *_s)
77 77
 {
78 78
 	struct lump* anchor;
79 79
 	
80
-	if (parse_headers(_m, HDR_EOH, 0) == -1) {
80
+	if (parse_headers(_m, HDR_EOH_F, 0) == -1) {
81 81
 		LOG(L_ERR, "append_rpid(): Error while parsing message\n");
82 82
 		return -1;
83 83
 	}
... ...
@@ -203,7 +203,8 @@ static int generate_avps(db_res_t* result)
203 203
 /*
204 204
  * Authorize digest credentials
205 205
  */
206
-static inline int authorize(struct sip_msg* _m, str* _realm, char* _table, int _hftype)
206
+static inline int authorize(struct sip_msg* _m, str* _realm, char* _table,
207
+								hdr_types_t _hftype)
207 208
 {
208 209
 	char ha1[256];
209 210
 	int res;
... ...
@@ -273,7 +274,7 @@ static inline int authorize(struct sip_msg* _m, str* _realm, char* _table, int _
273 274
 int proxy_authorize(struct sip_msg* _m, char* _realm, char* _table)
274 275
 {
275 276
 	     /* realm parameter is converted to str* in str_fixup */
276
-	return authorize(_m, (str*)_realm, _table, HDR_PROXYAUTH);
277
+	return authorize(_m, (str*)_realm, _table, HDR_PROXYAUTH_T);
277 278
 }
278 279
 
279 280
 
... ...
@@ -282,5 +283,5 @@ int proxy_authorize(struct sip_msg* _m, char* _realm, char* _table)
282 283
  */
283 284
 int www_authorize(struct sip_msg* _m, char* _realm, char* _table)
284 285
 {
285
-	return authorize(_m, (str*)_realm, _table, HDR_AUTHORIZATION);
286
+	return authorize(_m, (str*)_realm, _table, HDR_AUTHORIZATION_T);
286 287
 }
... ...
@@ -198,7 +198,7 @@ static int str_fixup(void** param, int param_no)
198 198
 int diameter_proxy_authorize(struct sip_msg* _msg, char* _realm, char* _s2)
199 199
 {
200 200
 	/* realm parameter is converted to str* in str_fixup */
201
-	return authorize(_msg, (str*)_realm, HDR_PROXYAUTH);
201
+	return authorize(_msg, (str*)_realm, HDR_PROXYAUTH_T);
202 202
 
203 203
 }
204 204
 
... ...
@@ -208,7 +208,7 @@ int diameter_proxy_authorize(struct sip_msg* _msg, char* _realm, char* _s2)
208 208
  */
209 209
 int diameter_www_authorize(struct sip_msg* _msg, char* _realm, char* _s2)
210 210
 {
211
-	return authorize(_msg, (str*)_realm, HDR_AUTHORIZATION);
211
+	return authorize(_msg, (str*)_realm, HDR_AUTHORIZATION_T);
212 212
 }
213 213
 
214 214
 static int group_fixup(void** param, int param_no)
... ...
@@ -74,7 +74,7 @@ int get_uri(struct sip_msg* m, str** uri)
74 74
 					(memcmp(REQ_LINE(m).method.s, "REGISTER", 8) == 0)) 
75 75
 	{	
76 76
 		/* REGISTER */
77
-		if (!m->to && ((parse_headers(m, HDR_TO, 0) == -1)|| (!m->to))) 
77
+		if (!m->to && ((parse_headers(m, HDR_TO_F, 0) == -1)|| (!m->to))) 
78 78
 		{
79 79
 			LOG(L_ERR, M_NAME":get_uri(): To header field not found or "
80 80
 				"malformed\n");
... ...
@@ -102,17 +102,17 @@ int get_uri(struct sip_msg* m, str** uri)
102 102
 
103 103
 
104 104
 /* Return parsed To or From host part of the parsed uri (that is realm) */
105
-int get_realm(struct sip_msg* m, int hftype, struct sip_uri* u)
105
+int get_realm(struct sip_msg* m, hdr_types_t hftype, struct sip_uri* u)
106 106
 {
107 107
 	str uri;
108 108
 
109 109
 	/* extracting the uri */
110 110
 	if ((REQ_LINE(m).method.len==8)
111 111
 					&& !memcmp(REQ_LINE(m).method.s, "REGISTER", 8) 
112
-					&& (hftype == HDR_AUTHORIZATION) ) 
112
+					&& (hftype == HDR_AUTHORIZATION_T) ) 
113 113
 	{ 
114 114
 		/* REGISTER */
115
-		if (!m->to && ((parse_headers(m, HDR_TO, 0) == -1) || (!m->to))) 
115
+		if (!m->to && ((parse_headers(m, HDR_TO_F, 0) == -1) || (!m->to))) 
116 116
 		{
117 117
 			LOG(L_ERR, M_NAME":get_realm(): Error while parsing TO header\n");
118 118
 			/* signal the error */
... ...
@@ -146,24 +146,34 @@ int get_realm(struct sip_msg* m, int hftype, struct sip_uri* u)
146 146
 }
147 147
 
148 148
 /* Find credentials with given realm in a SIP message header */
149
-int find_credentials(struct sip_msg* _m, str* _realm, int _hftype, 
149
+int find_credentials(struct sip_msg* _m, str* _realm, hdr_types_t _hftype, 
150 150
 				struct hdr_field** _h)
151 151
 {
152 152
 	struct hdr_field** hook, *ptr, *prev;
153 153
 	int res;
154
+	hdr_flags_t hdr_flags;
154 155
 	str* r;
155 156
       
156 157
 	switch(_hftype) 
157 158
 	{
158
-		case HDR_AUTHORIZATION: hook = &(_m->authorization); break;
159
-		case HDR_PROXYAUTH:     hook = &(_m->proxy_auth);    break;
160
-		default:                hook = &(_m->authorization); break;
159
+		case HDR_AUTHORIZATION_T:
160
+			hook = &(_m->authorization);
161
+			hdr_flags=HDR_AUTHORIZATION_F;
162
+			break;
163
+		case HDR_PROXYAUTH_T:
164
+			hook = &(_m->proxy_auth);
165
+			hdr_flags=HDR_PROXYAUTH_F;
166
+			break;
167
+		default:
168
+			hook = &(_m->authorization);
169
+			hdr_flags=HDR_T2F(_hftype);
170
+			break;
161 171
 	}
162 172
 
163 173
 	     
164 174
      /* If the credentials haven't been parsed yet, do it now */
165 175
 	if (*hook == 0) 
166
-		if (parse_headers(_m, _hftype, 0) == -1) 
176
+		if (parse_headers(_m, hdr_flags, 0) == -1) 
167 177
 		{
168 178
 			LOG(L_ERR, M_NAME":find_credentials(): Error while parsing headers\n");
169 179
 			return -1;
... ...
@@ -199,7 +209,7 @@ int find_credentials(struct sip_msg* _m, str* _realm, int _hftype,
199 209
 			}
200 210
 			
201 211
 			prev = ptr;
202
-			if (parse_headers(_m, _hftype, 1) == -1) 
212
+			if (parse_headers(_m, hdr_flags, 1) == -1) 
203 213
 			{
204 214
 				LOG(L_ERR, M_NAME":find_credentials(): Error while parsing"
205 215
 					" headers\n");
... ...
@@ -221,7 +231,8 @@ int find_credentials(struct sip_msg* _m, str* _realm, int _hftype,
221 231
 }
222 232
 
223 233
 
224
-auth_result_t pre_auth(struct sip_msg* _m, str* _realm, int _hftype, struct hdr_field** _h)
234
+auth_result_t pre_auth(struct sip_msg* _m, str* _realm, hdr_types_t _hftype,
235
+						struct hdr_field** _h)
225 236
 {
226 237
 	int ret;
227 238
 	struct sip_uri uri;
... ...
@@ -270,7 +281,7 @@ auth_result_t pre_auth(struct sip_msg* _m, str* _realm, int _hftype, struct hdr_
270 281
 
271 282
 
272 283
 /* Authorize digest credentials */
273
-int authorize(struct sip_msg* msg, str* realm, int hftype)
284
+int authorize(struct sip_msg* msg, str* realm, hdr_types_t hftype)
274 285
 {
275 286
 	auth_result_t ret;
276 287
 	struct hdr_field* h;
... ...
@@ -663,7 +674,7 @@ error:
663 674
 }
664 675
 
665 676
 /* give the appropriate response to the SER client */
666
-int srv_response(struct sip_msg* msg, rd_buf_t * rb, int hftype)
677
+int srv_response(struct sip_msg* msg, rd_buf_t * rb, hdr_types_t hftype)
667 678
 {
668 679
 	int auth_hf_len=0, ret=0;
669 680
 	char* auth_hf;
... ...
@@ -682,7 +693,7 @@ int srv_response(struct sip_msg* msg, rd_buf_t * rb, int hftype)
682 693
 			return -1;
683 694
 				
684 695
 		case AAA_CHALENGE:
685
-		 	if(hftype==HDR_AUTHORIZATION) /* SIP server */
696
+		 	if(hftype==HDR_AUTHORIZATION_T) /* SIP server */
686 697
 			{
687 698
 				auth_hf_len = WWW_AUTH_CHALLENGE_LEN+rb->chall_len;
688 699
 				auth_hf = (char*)ad_malloc(auth_hf_len*(sizeof(char)));
... ...
@@ -85,7 +85,7 @@ static inline int get_request_uri(struct sip_msg* m, str* u)
85 85
 static inline int get_to_uri(struct sip_msg* m, str* u)
86 86
 {
87 87
      // check that the header field is there and is parsed
88
-	if (!m->to && ((parse_headers(m, HDR_TO, 0) == -1)|| (!m->to))) 
88
+	if (!m->to && ((parse_headers(m, HDR_TO_F, 0) == -1)|| (!m->to))) 
89 89
 	{
90 90
 		LOG(L_ERR, "get_to_uri(): Can't get To header field\n");
91 91
 		return -1;
... ...
@@ -55,7 +55,7 @@
55 55
 static inline int get_uri(struct sip_msg* _m, str** _uri)
56 56
 {
57 57
 	if ((REQ_LINE(_m).method.len == 8) && (memcmp(REQ_LINE(_m).method.s, "REGISTER", 8) == 0)) {
58
-		if (!_m->to && ((parse_headers(_m, HDR_TO, 0) == -1) || !_m->to)) {
58
+		if (!_m->to && ((parse_headers(_m, HDR_TO_F, 0) == -1) || !_m->to)) {
59 59
 			LOG(L_ERR, "get_uri(): To header field not found or malformed\n");
60 60
 			return -1;
61 61
 		}
... ...
@@ -74,7 +74,8 @@ static inline int get_uri(struct sip_msg* _m, str** _uri)
74 74
 /*
75 75
  * Authorize digest credentials
76 76
  */
77
-static inline int authorize(struct sip_msg* _msg, str* _realm, int _hftype)
77
+static inline int authorize(struct sip_msg* _msg, str* _realm,
78
+							hdr_types_t _hftype)
78 79
 {
79 80
 	int res;
80 81
 	auth_result_t ret;
... ...
@@ -136,7 +137,7 @@ static inline int authorize(struct sip_msg* _msg, str* _realm, int _hftype)
136 137
 int radius_proxy_authorize(struct sip_msg* _msg, char* _realm, char* _s2)
137 138
 {
138 139
 	/* realm parameter is converted to str* in str_fixup */
139
-	return authorize(_msg, (str*)_realm, HDR_PROXYAUTH);
140
+	return authorize(_msg, (str*)_realm, HDR_PROXYAUTH_T);
140 141
 }
141 142
 
142 143
 
... ...
@@ -145,6 +146,6 @@ int radius_proxy_authorize(struct sip_msg* _msg, char* _realm, char* _s2)
145 146
  */
146 147
 int radius_www_authorize(struct sip_msg* _msg, char* _realm, char* _s2)
147 148
 {
148
-	return authorize(_msg, (str*)_realm, HDR_AUTHORIZATION);
149
+	return authorize(_msg, (str*)_realm, HDR_AUTHORIZATION_T);
149 150
 }
150 151
 
... ...
@@ -105,7 +105,7 @@ static int add_cisco_vsa(VALUE_PAIR** send, struct sip_msg* msg)
105 105
 {
106 106
 	str callid;
107 107
 
108
-	if (!msg->callid && parse_headers(msg, HDR_CALLID, 0) == -1) {
108
+	if (!msg->callid && parse_headers(msg, HDR_CALLID_F, 0) == -1) {
109 109
 		LOG(L_ERR, "add_cisco_vsa: Cannot parse Call-ID header field\n");
110 110
 		return -1;
111 111
 	}
... ...
@@ -215,7 +215,7 @@ inline static str* get_source_uri(struct sip_msg* msg,int source)
215 215
 		return &(get_from(msg)->uri);
216 216
 	} else if (source&AVPOPS_USE_TO)
217 217
 	{  /* to */
218
-		if (parse_headers( msg, HDR_TO, 0)<0)
218
+		if (parse_headers( msg, HDR_TO_F, 0)<0)
219 219
 		{
220 220
 			LOG(L_ERR,"ERROR:avpops:get_source_uri: failed "
221 221
 				"to parse to\n");
... ...
@@ -809,7 +809,7 @@ int ops_pushto_avp ( struct sip_msg* msg, struct fis_param* dst,
809 809
 			}
810 810
 		} else {
811 811
 			/* set a header for request */
812
-			if (parse_headers(msg, HDR_EOH, 0)==-1)
812
+			if (parse_headers(msg, HDR_EOH_F, 0)==-1)
813 813
 			{
814 814
 				LOG(L_ERR, "ERROR:avpops:pushto_avp: message parse failed\n");
815 815
 				goto error;
... ...
@@ -549,9 +549,10 @@ static inline int get_dest_user(struct sip_msg *msg, str *uh, int flg)
549 549
 		msg->first_line.u.request.uri.len ,&uri)==-1 || !uri.user.len )
550 550
 		{
551 551
 			DBG("DEBUG:cpl-c:get_dest_user: trying to get user from To\n");
552
-			if ( (!msg->to&&( (parse_headers(msg,HDR_TO,0)==-1) || !msg->to))||
553
-			parse_uri( get_to(msg)->uri.s, get_to(msg)->uri.len, &uri)==-1
554
-			|| !uri.user.len)
552
+			if ( (!msg->to&&( (parse_headers(msg,HDR_TO_F,0)==-1) ||
553
+					!msg->to)) ||
554
+				parse_uri( get_to(msg)->uri.s, get_to(msg)->uri.len, &uri)==-1
555
+				|| !uri.user.len)
555 556
 			{
556 557
 				LOG(L_ERR,"ERROR:cpl-c:get_dest_user: unable to extract user"
557 558
 					" name from RURI or To header!\n");
... ...
@@ -709,8 +710,10 @@ static inline int do_script_action(struct sip_msg *msg, int action)
709 710
 	str  log  = {0,0};
710 711
 
711 712
 	/* content-length (if present) */
712
-	if ( !msg->content_length && ((parse_headers(msg,HDR_CONTENTLENGTH,0)==-1)
713
-	|| !msg->content_length) ) {
713
+	if ( !msg->content_length && 
714
+			((parse_headers(msg, HDR_CONTENTLENGTH_F, 0)==-1)
715
+			 || !msg->content_length) )
716
+	{
714 717
 		LOG(L_ERR,"ERROR:cpl-c:do_script_action: no Content-Length "
715 718
 			"hdr found!\n");
716 719
 		goto error;
... ...
@@ -49,7 +49,7 @@
49 49
 		if (!(_intr_)->_field_) {\
50 50
 			if (!(_intr_)->msg->_field_) { \
51 51
 				if (parse_headers((_intr_)->msg,_name_,0)==-1) {\
52
-					LOG(L_ERR,"ERROR:run_proxy: bad %u hdr\n",_name_);\
52
+					LOG(L_ERR,"ERROR:run_proxy: bad %llx hdr\n",_name_);\
53 53
 					goto runtime_error;\
54 54
 				} else if ( !(_intr_)->msg->_field_) {\
55 55
 					(_intr_)->_field_ = STR_NOT_FOUND;\
... ...
@@ -103,7 +103,7 @@ static inline int add_contacts_to_loc_set(struct sip_msg* msg,
103 103
 	/* we need to have the contact header */
104 104
 	if (msg->contact==0) {
105 105
 		/* find and parse the Contact header */
106
-		if ((parse_headers(msg, HDR_CONTACT, 0)==-1) || (msg->contact==0) ) {
106
+		if ((parse_headers(msg, HDR_CONTACT_F, 0)==-1) || (msg->contact==0) ) {
107 107
 			LOG(L_ERR,"ERROR:cpl-c:add_contacts_to_loc_set: error parsing or "
108 108
 				"no Contact hdr found!\n");
109 109
 			goto error;
... ...
@@ -410,7 +410,7 @@ static inline char *run_proxy( struct cpl_interpreter *intr )
410 410
 		/* TO header - mandatory in SIP msg (cannot be STR_NOT_FOUND) */
411 411
 		if (!intr->to) {
412 412
 			if (!intr->msg->to &&
413
-			(parse_headers(intr->msg,HDR_TO,0)==-1 || !intr->msg->to)) {
413
+			(parse_headers(intr->msg,HDR_TO_F,0)==-1 || !intr->msg->to)) {
414 414
 				LOG(L_ERR,"ERROR:run_proxy: bad msg or missing TO header\n");
415 415
 				goto runtime_error;
416 416
 			}
... ...
@@ -432,19 +432,19 @@ static inline char *run_proxy( struct cpl_interpreter *intr )
432 432
 		intr->flags |= CPL_FROM_DUPLICATED;
433 433
 		/* SUBJECT header - optional in SIP msg (can be STR_NOT_FOUND) */
434 434
 		if (intr->subject!=STR_NOT_FOUND) {
435
-			search_and_duplicate_hdr(intr,subject,HDR_SUBJECT,s);
435
+			search_and_duplicate_hdr(intr,subject,HDR_SUBJECT_F,s);
436 436
 			if (intr->subject!=STR_NOT_FOUND)
437 437
 				intr->flags |= CPL_SUBJECT_DUPLICATED;
438 438
 		}
439 439
 		/* ORGANIZATION header - optional in SIP msg (can be STR_NOT_FOUND) */
440 440
 		if ( intr->organization!=STR_NOT_FOUND) {
441
-			search_and_duplicate_hdr(intr,organization,HDR_ORGANIZATION,s);
441
+			search_and_duplicate_hdr(intr,organization,HDR_ORGANIZATION_F,s);
442 442
 			if ( intr->organization!=STR_NOT_FOUND)
443 443
 				intr->flags |= CPL_ORGANIZATION_DUPLICATED;
444 444
 		}
445 445
 		/* USER_AGENT header - optional in SIP msg (can be STR_NOT_FOUND) */
446 446
 		if (intr->user_agent!=STR_NOT_FOUND) {
447
-			search_and_duplicate_hdr(intr,user_agent,HDR_USERAGENT,s);
447
+			search_and_duplicate_hdr(intr,user_agent,HDR_USERAGENT_F,s);
448 448
 			if (intr->user_agent!=STR_NOT_FOUND)
449 449
 				intr->flags |= CPL_USERAGENT_DUPLICATED;
450 450
 		}
... ...
@@ -452,13 +452,13 @@ static inline char *run_proxy( struct cpl_interpreter *intr )
452 452
 		 * (can be STR_NOT_FOUND) */
453 453
 		if (intr->accept_language!=STR_NOT_FOUND) {
454 454
 			search_and_duplicate_hdr(intr,accept_language,
455
-				HDR_ACCEPTLANGUAGE,s);
455
+				HDR_ACCEPTLANGUAGE_F,s);
456 456
 			if (intr->accept_language!=STR_NOT_FOUND)
457 457
 				intr->flags |= CPL_ACCEPTLANG_DUPLICATED;
458 458
 		}
459 459
 		/* PRIORITY header - optional in SIP msg (can be STR_NOT_FOUND) */
460 460
 		if (intr->priority!=STR_NOT_FOUND) {
461
-			search_and_duplicate_hdr(intr,priority,HDR_PRIORITY,s);
461
+			search_and_duplicate_hdr(intr,priority,HDR_PRIORITY_F,s);
462 462
 			if (intr->priority!=STR_NOT_FOUND)
463 463
 				intr->flags |= CPL_PRIORITY_DUPLICATED;
464 464
 		}
... ...
@@ -147,7 +147,7 @@ static inline char *run_address_switch( struct cpl_interpreter *intr )
147 147
 							if (!intr->to) {
148 148
 								/* get and parse the header */
149 149
 								if (!intr->msg->to &&
150
-								(parse_headers(intr->msg,HDR_TO,0)==-1 ||
150
+								(parse_headers(intr->msg,HDR_TO_F,0)==-1 ||
151 151
 								!intr->msg->to)) {
152 152
 									LOG(L_ERR,"ERROR:run_address_switch: bad "
153 153
 										"msg or missing TO header\n");
... ...
@@ -354,7 +354,7 @@ static inline char *run_string_switch( struct cpl_interpreter *intr )
354 354
 								/* get the subject header */
355 355
 								if (!intr->msg->subject) {
356 356
 									if (parse_headers(intr->msg,
357
-									HDR_SUBJECT,0)==-1) {
357
+									HDR_SUBJECT_F,0)==-1) {
358 358
 										LOG(L_ERR,"ERROR:run_string_switch: "
359 359
 										"bad SUBJECT header\n");
360 360
 										goto runtime_error;
... ...
@@ -377,7 +377,7 @@ static inline char *run_string_switch( struct cpl_interpreter *intr )
377 377
 								/* get the organization header */
378 378
 								if (!intr->msg->organization) {
379 379
 									if (parse_headers(intr->msg,
380
-									HDR_ORGANIZATION,0)==-1) {
380
+									HDR_ORGANIZATION_F,0)==-1) {
381 381
 										LOG(L_ERR,"ERROR:run_string_switch: "
382 382
 										"bad ORGANIZATION hdr\n");
383 383
 										goto runtime_error;
... ...
@@ -400,7 +400,7 @@ static inline char *run_string_switch( struct cpl_interpreter *intr )
400 400
 								/* get the  header */
401 401
 								if (!intr->msg->user_agent) {
402 402
 									if (parse_headers(intr->msg,
403
-									HDR_USERAGENT,0)==-1) {
403
+									HDR_USERAGENT_F,0)==-1) {
404 404
 										LOG(L_ERR,"ERROR:run_string_switch: "
405 405
 										"bad USERAGENT hdr\n");
406 406
 										goto runtime_error;
... ...
@@ -558,7 +558,7 @@ static inline char *run_priority_switch( struct cpl_interpreter *intr )
558 558
 					if (!intr->priority) {
559 559
 						/* get the PRIORITY header from message */
560 560
 						if (!intr->msg->priority) {
561
-							if (parse_headers(intr->msg,HDR_PRIORITY,0)==-1) {
561
+							if (parse_headers(intr->msg,HDR_PRIORITY_F,0)==-1){
562 562
 								LOG(L_ERR,"ERROR:run_priority_switch: bad "
563 563
 									"sip msg or PRIORITY header !\n");
564 564
 								goto runtime_error;
... ...
@@ -1050,7 +1050,7 @@ static inline char *run_language_switch( struct cpl_interpreter *intr )
1050 1050
 						/* get the accept_language header */
1051 1051
 						if (!intr->msg->accept_language) {
1052 1052
 							if (parse_headers(intr->msg,
1053
-							HDR_ACCEPTLANGUAGE,0)==-1) {
1053
+							HDR_ACCEPTLANGUAGE_F,0)==-1) {
1054 1054
 								LOG(L_ERR,"ERROR:run_language_switch: "
1055 1055
 									"bad ACCEPT_LANGUAGE header\n");
1056 1056
 								goto runtime_error;
... ...
@@ -451,7 +451,7 @@ int ds_hash_callid(struct sip_msg *msg, unsigned int *hash)
451 451
 		return -1;
452 452
 	}
453 453
 	
454
-	if(msg->callid==NULL && ((parse_headers(msg, HDR_CALLID, 0)==-1) ||
454
+	if(msg->callid==NULL && ((parse_headers(msg, HDR_CALLID_F, 0)==-1) ||
455 455
 				(msg->callid==NULL)) )
456 456
 	{
457 457
 		LOG(L_ERR, "DISPATCHER:ds_hash_callid:ERROR cannot parse Call-Id\n");
... ...
@@ -137,7 +137,7 @@ static inline int add_diversion_helper(struct sip_msg* msg, str* s)
137 137
 		anchor = 0;
138 138
 	}
139 139
 	
140
-	if (!msg->diversion && parse_headers(msg, HDR_DIVERSION, 0) == -1) {
140
+	if (!msg->diversion && parse_headers(msg, HDR_DIVERSION_F, 0) == -1) {
141 141
 		LOG(L_ERR, "add_diversion_helper: Header parsing failed\n");
142 142
 		return -1;
143 143
 	}
... ...
@@ -81,7 +81,7 @@ static int insert_hf( struct hf_wrapper **list, struct hdr_field *hf )
81 81
 	for(i=*list; i; i=i->next_other) {
82 82
 		if (i->var_type==W_HF && i->u.hf->type==hf->type) {
83 83
 			/* if it is OTHER, check name too */
84
-			if (hf->type==HDR_OTHER && (hf->name.len!=i->u.hf->name.len
84
+			if (hf->type==HDR_OTHER_T && (hf->name.len!=i->u.hf->name.len
85 85
 					|| strncasecmp(i->u.hf->name.s, hf->name.s, 
86 86
 					   hf->name.len)!=0))
87 87
 				continue;
... ...
@@ -122,44 +122,44 @@ static void release_hf_struct( struct hf_wrapper *list )
122 122
 /* if that is some of well-known header fields which have compact
123 123
  * form, return canonical form ... returns 1 and sets params;
124 124
  * 0 is returned otherwise */
125
-static int compacthdr_type2str(int type, char **hname, int *hlen )
125
+static int compacthdr_type2str(hdr_types_t type, char **hname, int *hlen )
126 126
 {
127 127
 	switch(type) {
128 128
 		/* HDR_CONTENT_ENCODING: 'e' -- unsupported by parser */
129 129
 		/* HDR_SUBJECT: 's' -- unsupported by parser */
130
-		case HDR_VIA /* v */ : 
130
+		case HDR_VIA_T /* v */ : 
131 131
 			*hname=VAR_VIA;
132 132
 			*hlen=VAR_VIA_LEN;
133 133
 			break;
134
-		case HDR_CONTENTTYPE /* c */ : 
134
+		case HDR_CONTENTTYPE_T /* c */ : 
135 135
 			*hname=VAR_CTYPE;
136 136
 			*hlen=VAR_CTYPE_LEN;
137 137
 			break;
138
-		case HDR_FROM /* f */: 
138
+		case HDR_FROM_T /* f */: 
139 139
 			*hname=VAR_FROM;
140 140
 			*hlen=VAR_FROM_LEN;
141 141
 			break;
142
-		case HDR_CALLID /* i */: 
142
+		case HDR_CALLID_T /* i */: 
143 143
 			*hname=VAR_CALLID;
144 144
 			*hlen=VAR_CALLID_LEN;
145 145
 			break;
146
-		case HDR_SUPPORTED /* k */: 
146
+		case HDR_SUPPORTED_T /* k */: 
147 147
 			*hname=VAR_SUPPORTED;
148 148
 			*hlen=VAR_SUPPORTED_LEN;
149 149
 			break;
150
-		case HDR_CONTENTLENGTH /* l */: 
150
+		case HDR_CONTENTLENGTH_T /* l */: 
151 151
 			*hname=VAR_CLEN;
152 152
 			*hlen=VAR_CLEN_LEN;
153 153
 			break;
154
-		case HDR_CONTACT /* m */: 
154
+		case HDR_CONTACT_T /* m */: 
155 155
 			*hname=VAR_CONTACT;
156 156
 			*hlen=VAR_CONTACT_LEN;
157 157
 			break;
158
-		case HDR_TO /* t */: 
158
+		case HDR_TO_T /* t */: 
159 159
 			*hname=VAR_TO;
160 160
 			*hlen=VAR_TO_LEN;
161 161
 			break;
162
-		case HDR_EVENT /* o */: 
162
+		case HDR_EVENT_T /* o */: 
163 163
 			*hname=VAR_EVENT;
164 164
 			*hlen=VAR_EVENT_LEN;
165 165
 			break;
... ...
@@ -518,7 +518,7 @@ environment_t *set_env(struct sip_msg *msg)
518 518
 	environment_t *backup_env;
519 519
 
520 520
 	/* parse all so that we can pass all header fields to script */
521
-	if (parse_headers(msg, HDR_EOH, 0)==-1) {
521
+	if (parse_headers(msg, HDR_EOH_F, 0)==-1) {
522 522
 		LOG(L_ERR, "ERROR: set_env: parsing failed\n");
523 523
 		return 0;
524 524
 	}
... ...
@@ -73,7 +73,7 @@ static inline int get_request_uri(struct sip_msg* _m, str* _u)
73 73
  */
74 74
 static inline int get_to_uri(struct sip_msg* _m, str* _u)
75 75
 {
76
-	if (!_m->to && ((parse_headers(_m, HDR_TO, 0) == -1) || (!_m->to))) {
76
+	if (!_m->to && ((parse_headers(_m, HDR_TO_F, 0) == -1) || (!_m->to))) {
77 77
 		LOG(L_ERR, "get_to_uri(): Can't get To header field\n");
78 78
 		return -1;
79 79
 	}
... ...
@@ -74,7 +74,7 @@ static inline int get_to_uri(struct sip_msg* _m, str* _u)
74 74
 	     /* Double check that the header field is there
75 75
 	      * and is parsed
76 76
 	      */
77
-	if (!_m->to && ((parse_headers(_m, HDR_TO, 0) == -1) || !_m->to)) {
77
+	if (!_m->to && ((parse_headers(_m, HDR_TO_F, 0) == -1) || !_m->to)) {
78 78
 		LOG(L_ERR, "get_to_uri(): Can't get To header field\n");
79 79
 		return -1;
80 80
 	}
... ...
@@ -470,7 +470,8 @@ int xjab_manage_sipmsg(struct sip_msg *msg, int type)
470 470
 	}
471 471
 	
472 472
 	// check for TO and FROM headers - if is not SIP MESSAGE 
473
-	if(parse_headers( msg, HDR_TO|HDR_FROM, 0)==-1 || !msg->to || !msg->from)
473
+	if(parse_headers( msg, HDR_TO_F|HDR_FROM_F, 0)==-1 || !msg->to 
474
+			|| !msg->from)
474 475
 	{
475 476
 		LOG(L_ERR,"XJAB:xjab_manage_sipmsg: cannot find TO or FROM HEADERS!\n");
476 477
 		goto error;
... ...
@@ -73,7 +73,7 @@ encode_contact (struct sip_msg *msg, char *encoding_prefix,char *public_ip)
73 73
         fprintf (stdout,"%.*s\n",50,msg->buf);
74 74
 #endif
75 75
 	
76
-	if ((msg->contact == NULL)&&((parse_headers(msg,HDR_CONTACT,0) == -1) ||
76
+	if ((msg->contact == NULL)&&((parse_headers(msg,HDR_CONTACT_F,0) == -1) ||
77 77
 				(msg->contact == NULL) ))
78 78
 		{
79 79
 		LOG(L_ERR,"ERROR: encode_contact: no Contact header present\n");
... ...
@@ -240,7 +240,7 @@ decode_contact_header (struct sip_msg *msg,char *unused1,char *unused2)
240 240
 	fprintf (stdout,"---START--------DECODE CONTACT HEADER-----------------\n");
241 241
 #endif
242 242
 
243
-	if ((msg->contact == NULL)&&((parse_headers(msg,HDR_CONTACT,0) == -1) || 
243
+	if ((msg->contact == NULL)&&((parse_headers(msg,HDR_CONTACT_F,0) == -1) || 
244 244
 				(msg->contact== NULL) ))
245 245
 		{
246 246
 		LOG(L_ERR,"ERROR: decode_contact_header: no Contact header present\n");
... ...
@@ -76,7 +76,7 @@ sdp_mangle_port (struct sip_msg *msg, char *offset, char *unused)
76 76
 		}
77 77
                 
78 78
 	if ((msg->content_length==0) &&
79
-			((parse_headers(msg,HDR_CONTENTLENGTH,0)==-1) ||
79
+			((parse_headers(msg,HDR_CONTENTLENGTH_F,0)==-1) ||
80 80
 			 (msg->content_length==0) )){
81 81
 		LOG(L_ERR,"ERROR: sdp_mangle_port: bad or missing "
82 82
 				"Content-Length \n");
... ...
@@ -314,7 +314,7 @@ sdp_mangle_ip (struct sip_msg *msg, char *oldip, char *newip)
314 314
 		return -1;
315 315
 		}
316 316
 	if ((msg->content_length==0) &&
317
-				((parse_headers(msg,HDR_CONTENTLENGTH,0)==-1) ||
317
+				((parse_headers(msg,HDR_CONTENTLENGTH_F,0)==-1) ||
318 318
 				 (msg->content_length==0) )){
319 319
 			LOG(L_ERR,"ERROR: sdp_mangle_port: bad or missing "
320 320
 					"Content-Length \n");
... ...
@@ -83,7 +83,7 @@ patch_content_length (struct sip_msg *msg, unsigned int newValue)
83 83
 	contentLength = msg->content_length;
84 84
 	if (contentLength == NULL)	/* maybe not yet parsed */
85 85
 	{
86
-		if (parse_headers (msg, HDR_CONTENTLENGTH, 0) == -1)
86
+		if (parse_headers (msg, HDR_CONTENTLENGTH_F, 0) == -1)
87 87
 		{
88 88
 			LOG (L_ERR,"ERROR: patch_content_length: parse headers on Content-Length failed\n");
89 89
 			return -1;
... ...
@@ -54,7 +54,7 @@ int is_maxfwd_present( struct sip_msg* msg , str *foo)
54 54
 
55 55
 	/* lookup into the message for MAX FORWARDS header*/
56 56
 	if ( !msg->maxforwards ) {
57
-		if  ( parse_headers( msg , HDR_MAXFORWARDS, 0 )==-1 ){
57
+		if  ( parse_headers( msg , HDR_MAXFORWARDS_F, 0 )==-1 ){
58 58
 			LOG( L_ERR , "ERROR:maxfwd:is_maxfwd_present :"
59 59
 				" parsing MAX_FORWARD header failed!\n");
60 60
 			return -2;
... ...
@@ -152,7 +152,7 @@ FixContact(struct sip_msg* msg, char* str1, char* str2)
152 152
     }
153 153
 
154 154
     offset = contact->uri.s - msg->buf;
155
-    anchor = del_lump(msg, offset, contact->uri.len, HDR_CONTACT);
155
+    anchor = del_lump(msg, offset, contact->uri.len, HDR_CONTACT_T);
156 156
 
157 157
     if (!anchor) {
158 158
         pkg_free(buf);
... ...
@@ -170,7 +170,7 @@ FixContact(struct sip_msg* msg, char* str1, char* str2)
170 170
                       newip, msg->rcv.src_port, after.len, after.s);
171 171
     }
172 172
 
173
-    if (insert_new_lump_after(anchor, buf, len, HDR_CONTACT) == 0) {
173
+    if (insert_new_lump_after(anchor, buf, len, HDR_CONTACT_T) == 0) {
174 174
         pkg_free(buf);
175 175
         return -1;
176 176
     }
... ...
@@ -442,7 +442,7 @@ static Bool
442 442
 getCallId(struct sip_msg* msg, str *cid)
443 443
 {
444 444
     if (msg->callid == NULL) {
445
-        if (parse_headers(msg, HDR_CALLID, 0) == -1) {
445
+        if (parse_headers(msg, HDR_CALLID_F, 0) == -1) {
446 446
             return False;
447 447
         }
448 448
         if (msg->callid == NULL) {
... ...
@@ -643,7 +643,7 @@ getUserAgent(struct sip_msg* msg)
643 643
     str block, server;
644 644
     char *ptr;
645 645
 
646
-    if ((parse_headers(msg, HDR_USERAGENT, 0)!=-1) && msg->user_agent &&
646
+    if ((parse_headers(msg, HDR_USERAGENT_F, 0)!=-1) && msg->user_agent &&
647 647
         msg->user_agent->body.len>0) {
648 648
         return msg->user_agent->body;
649 649
     }
... ...
@@ -676,7 +676,7 @@ static Bool
676 676
 getContactURI(struct sip_msg* msg, struct sip_uri *uri, contact_t** _c)
677 677
 {
678 678
 
679
-    if ((parse_headers(msg, HDR_CONTACT, 0) == -1) || !msg->contact)
679
+    if ((parse_headers(msg, HDR_CONTACT_F, 0) == -1) || !msg->contact)
680 680
         return False;
681 681
 
682 682
     if (!msg->contact->parsed && parse_contact(msg->contact) < 0) {
... ...
@@ -677,7 +677,7 @@ static int m_dump(struct sip_msg* msg, char* str1, char* str2)
677 677
 	body_str.len=1024;
678 678
 	
679 679
 	/* check for TO header */
680
-	if(msg->to==NULL && (parse_headers(msg, HDR_TO, 0)==-1
680
+	if(msg->to==NULL && (parse_headers(msg, HDR_TO_F, 0)==-1
681 681
 				|| msg->to==NULL || msg->to->body.s==NULL))
682 682
 	{
683 683
 		LOG(L_ERR,"MSILO:m_dump: ERROR cannot find TO HEADER!\n");
... ...
@@ -707,7 +707,7 @@ static int m_dump(struct sip_msg* msg, char* str1, char* str2)
707 707
 	/**
708 708
 	 * check if has expires=0 (REGISTER)
709 709
 	 */
710
-	if(parse_headers(msg, HDR_EXPIRES, 0) >= 0)
710
+	if(parse_headers(msg, HDR_EXPIRES_F, 0) >= 0)
711 711
 	{
712 712
 		/* check 'expires' > 0 */
713 713
 		if(msg->expires && msg->expires->body.len > 0)
... ...
@@ -499,7 +499,7 @@ static inline int
499 499
 get_callid(struct sip_msg* _m, str* _cid)
500 500
 {
501 501
 
502
-	if ((parse_headers(_m, HDR_CALLID, 0) == -1)) {
502
+	if ((parse_headers(_m, HDR_CALLID_F, 0) == -1)) {
503 503
 		LOG(L_ERR, "get_callid(): parse_headers() failed\n");
504 504
 		return -1;
505 505
 	}
... ...
@@ -522,7 +522,7 @@ static inline int
522 522
 get_contact_uri(struct sip_msg* _m, struct sip_uri *uri, contact_t** _c)
523 523
 {
524 524
 
525
-	if ((parse_headers(_m, HDR_CONTACT, 0) == -1) || !_m->contact)
525
+	if ((parse_headers(_m, HDR_CONTACT_F, 0) == -1) || !_m->contact)
526 526
 		return -1;
527 527
 	if (!_m->contact->parsed && parse_contact(_m->contact) < 0) {
528 528
 		LOG(L_ERR, "get_contact_uri: Error while parsing Contact body\n");
... ...
@@ -565,7 +565,7 @@ fix_nated_contact_f(struct sip_msg* msg, char* str1, char* str2)
565 565
 	}
566 566
 
567 567
 	offset = c->uri.s - msg->buf;
568
-	anchor = del_lump(msg, offset, c->uri.len, HDR_CONTACT);
568
+	anchor = del_lump(msg, offset, c->uri.len, HDR_CONTACT_T);
569 569
 	if (anchor == 0)
570 570
 		return -1;
571 571
 
... ...
@@ -589,7 +589,7 @@ fix_nated_contact_f(struct sip_msg* msg, char* str1, char* str2)
589 589
 		len = len1;
590 590
 	hostport.s[0] = temp[0];
591 591
 	c->uri.s[c->uri.len] = temp[1];
592
-	if (insert_new_lump_after(anchor, buf, len, HDR_CONTACT) == 0) {
592
+	if (insert_new_lump_after(anchor, buf, len, HDR_CONTACT_T) == 0) {
593 593
 		pkg_free(buf);
594 594
 		return -1;
595 595
 	}
... ...
@@ -65,7 +65,8 @@ extern str str_strdup(str string);
65 65
  */
66 66
 static int parse_hfs(struct sip_msg* _m)
67 67
 {
68
-	if (parse_headers(_m, HDR_FROM | HDR_EVENT | HDR_EXPIRES | HDR_ACCEPT, 0) == -1) {
68
+	if (parse_headers(_m, HDR_FROM_F | HDR_EVENT_F | HDR_EXPIRES_F |
69
+							HDR_ACCEPT_F, 0) == -1) {
69 70
 		paerrno = PA_PARSE_ERR;
70 71
 		LOG(L_ERR, "parse_hfs(): Error while parsing headers\n");
71 72
 		return -1;
... ...
@@ -238,8 +238,9 @@ int parse_accept(struct hdr_field* _h, doctype_t* _a)
238 238
  */
239 239
 static int parse_hfs(struct sip_msg* _m, int accept_header_required)
240 240
 {
241
-	if ( (parse_headers(_m, HDR_FROM | HDR_EVENT | HDR_EXPIRES | HDR_ACCEPT, 0)
242
-				== -1) || (_m->from==0)||(_m->event==0)||(_m->expires==0) ||
241
+	if ( (parse_headers(_m, HDR_FROM_F | HDR_EVENT_F | HDR_EXPIRES_F |
242
+							HDR_ACCEPT_F, 0) == -1) ||
243
+			(_m->from==0)||(_m->event==0)||(_m->expires==0) ||
243 244
 			(_m->accept==0) ) {
244 245
 		paerrno = PA_PARSE_ERR;
245 246
 		LOG(L_ERR, "parse_hfs(): Error while parsing headers\n");
... ...
@@ -572,7 +573,7 @@ int pa_handle_registration(struct sip_msg* _m, char* _domain, char* _s2)
572 573
 	       if (_m->contact) {
573 574
 		    struct hdr_field* ptr = _m->contact;
574 575
 		    while (ptr) {
575
-			 if (ptr->type == HDR_CONTACT) {
576
+			 if (ptr->type == HDR_CONTACT_T) {
576 577
 			      if (!ptr->parsed && (parse_contact(ptr) < 0)) {
577 578
 				   goto next;
578 579
 			      }
... ...
@@ -271,7 +271,7 @@ static int check_routing(struct sip_msg* msg, int idx)
271 271
 	}
272 272
 	
273 273
 	/* looking for FROM HF */
274
-        if ((!msg->from) && (parse_headers(msg, HDR_FROM, 0) == -1)) {
274
+        if ((!msg->from) && (parse_headers(msg, HDR_FROM_F, 0) == -1)) {
275 275
                 LOG(L_ERR, "check_routing(): Error while parsing message\n");
276 276
                 return -1;
277 277
         }
... ...
@@ -546,7 +546,7 @@ static int check_register(struct sip_msg* msg, int idx)
546 546
 	      * of them causes reject then we don't look at others, this could improve performance
547 547
 	      * a little bit in some situations
548 548
 	      */
549
-	if (parse_headers(msg, HDR_TO | HDR_CONTACT, 0) == -1) {
549
+	if (parse_headers(msg, HDR_TO_F | HDR_CONTACT_F, 0) == -1) {
550 550
 		LOG(L_ERR, "check_register(): Error while parsing headers\n");
551 551
 		return -1;
552 552
 	}
... ...
@@ -653,7 +653,7 @@ static int check_refer_to(struct sip_msg* msg, int idx)
653 653
 	}
654 654
 	
655 655
 	/* looking for FROM HF */
656
-        if ((!msg->from) && (parse_headers(msg, HDR_FROM, 0) == -1)) {
656
+        if ((!msg->from) && (parse_headers(msg, HDR_FROM_F, 0) == -1)) {
657 657
                 LOG(L_ERR, "check_refer_to(): Error while parsing message\n");
658 658
                 return -1;
659 659
         }
... ...
@@ -679,7 +679,7 @@ static int check_refer_to(struct sip_msg* msg, int idx)
679 679
 	from_str[len] = '\0';
680 680
 	
681 681
 	/* looking for REFER-TO HF */
682
-        if ((!msg->refer_to) && (parse_headers(msg, HDR_REFER_TO, 0) == -1)) {
682
+        if ((!msg->refer_to) && (parse_headers(msg, HDR_REFER_TO_F, 0) == -1)){
683 683
                 LOG(L_ERR, "check_refer_to(): Error while parsing message\n");
684 684
                 return -1;
685 685
         }
... ...
@@ -79,7 +79,7 @@ int pike_check_req(struct sip_msg *msg, char *foo, char *bar)
79 79
 
80 80
 #ifdef _test
81 81
 	/* get the ip address from second via */
82
-	if (parse_headers(msg, HDR_VIA1, 0)!=0 )
82
+	if (parse_headers(msg, HDR_VIA1_F, 0)!=0 )
83 83
 		return -1;
84 84
 	if (msg->via1==0 )
85 85
 		return -1;
... ...
@@ -495,7 +495,7 @@ static inline int save_real(struct sip_msg* _m, udomain_t* _t, char* _s, int dor
495 495
 	}
496 496
 
497 497
 	ua.len = 0;
498
-	if (parse_headers(_m, HDR_USERAGENT, 0) != -1 && _m->user_agent &&
498
+	if (parse_headers(_m, HDR_USERAGENT_F, 0) != -1 && _m->user_agent &&
499 499
 	    _m->user_agent->body.len > 0) {
500 500
 		ua.len = _m->user_agent->body.len;
501 501
 		ua.s = _m->user_agent->body.s;
... ...
@@ -74,7 +74,7 @@ int parse_message(struct sip_msg* _m)
74 74
 {
75 75
 	struct hdr_field* ptr;
76 76
 	
77
-	if (parse_headers(_m, HDR_EOH, 0) == -1) {
77
+	if (parse_headers(_m, HDR_EOH_F, 0) == -1) {
78 78
 		rerrno = R_PARSE;
79 79
 		LOG(L_ERR, "parse_message(): Error while parsing headers\n");
80 80
 		return -1;
... ...
@@ -107,7 +107,7 @@ int parse_message(struct sip_msg* _m)
107 107
 	if (_m->contact) {
108 108
 		ptr = _m->contact;
109 109
 		while(ptr) {
110
-			if (ptr->type == HDR_CONTACT) {
110
+			if (ptr->type == HDR_CONTACT_T) {
111 111
 				if (!ptr->parsed && (parse_contact(ptr) < 0)) {
112 112
 					rerrno = R_PARSE_CONT;
113 113
 					LOG(L_ERR, "parse_message(): Error while parsing Contact body\n");
... ...
@@ -151,7 +151,7 @@ int check_contacts(struct sip_msg* _m, int* _s)
151 151
 		     /* Message must contain no other Contact HFs */
152 152
 		p = _m->contact->next;
153 153
 		while(p) {
154
-			if (p->type == HDR_CONTACT) {
154
+			if (p->type == HDR_CONTACT_T) {
155 155
 				rerrno = R_STAR_CONT;
156 156
 				return 1;
157 157
 			}
... ...
@@ -163,7 +163,7 @@ int check_contacts(struct sip_msg* _m, int* _s)
163 163
 		     /* Message must contain no star Contact HF */
164 164
 		p = _m->contact->next;
165 165
 		while(p) {
166
-			if (p->type == HDR_CONTACT) {
166
+			if (p->type == HDR_CONTACT_T) {
167 167
 				if (((contact_body_t*)p->parsed)->star == 1) {
168 168
 					rerrno = R_STAR_CONT;
169 169
 					return 1;
... ...
@@ -198,7 +198,7 @@ contact_t* get_next_contact(contact_t* _c)
198 198
 	if (_c->next == 0) {
199 199
 		p = act_contact->next;
200 200
 		while(p) {
201
-			if (p->type == HDR_CONTACT) {
201
+			if (p->type == HDR_CONTACT_T) {
202 202
 				act_contact = p;
203 203
 				return (((contact_body_t*)p->parsed)->contacts);
204 204
 			}
... ...
@@ -66,7 +66,7 @@ static int is_preloaded(struct sip_msg* msg)
66 66
 {
67 67
 	str tag;
68 68
 
69
-	if (!msg->to && parse_headers(msg, HDR_TO, 0) == -1) {
69
+	if (!msg->to && parse_headers(msg, HDR_TO_F, 0) == -1) {
70 70
 		LOG(L_ERR, "is_preloaded: Cannot parse To header field\n");
71 71
 		return -1;
72 72
 	}
... ...
@@ -95,7 +95,7 @@ static int is_preloaded(struct sip_msg* msg)
95 95
  */
96 96
 static inline int find_first_route(struct sip_msg* _m)
97 97
 {
98
-	if (parse_headers(_m, HDR_ROUTE, 0) == -1) {
98
+	if (parse_headers(_m, HDR_ROUTE_F, 0) == -1) {
99 99
 		LOG(L_ERR, "find_first_route: Error while parsing headers\n");
100 100
 		return -1;
101 101
 	} else {
... ...
@@ -233,19 +233,19 @@ static inline int find_next_route(struct sip_msg* _m, struct hdr_field** _hdr)
233 233
 
234 234
 	     /* Try to find already parsed Route headers */
235 235
 	while(ptr) {
236
-		if (ptr->type == HDR_ROUTE) goto found;
236
+		if (ptr->type == HDR_ROUTE_T) goto found;
237 237
 		ptr = ptr->next;
238 238
 	}
239 239
 
240 240
 	     /* There are no already parsed Route headers, try to find next
241 241
 	      * occurrence of Route header
242 242
 	      */
243
-	if (parse_headers(_m, HDR_ROUTE, 1) == -1) {
243
+	if (parse_headers(_m, HDR_ROUTE_F, 1) == -1) {
244 244
 		LOG(L_ERR, "find_next_route: Error while parsing headers\n");
245 245
 		return -1;
246 246
 	}
247 247
 
248
-	if ((_m->last_header->type != HDR_ROUTE) || (_m->last_header == *_hdr)) {
248
+	if ((_m->last_header->type != HDR_ROUTE_T) || (_m->last_header == *_hdr)) {
249 249
 		DBG("find_next_route: No next Route HF found\n");
250 250
 		return 1;
251 251
 	}
... ...
@@ -362,7 +362,7 @@ static inline int save_ruri(struct sip_msg* _m)
362 362
 	      * because Request-URI must be saved in last
363 363
 	      * Route HF in the message
364 364
 	      */
365
-	if (parse_headers(_m, HDR_EOH, 0) == -1) {
365
+	if (parse_headers(_m, HDR_EOH_F, 0) == -1) {
366 366
 		LOG(L_ERR, "save_ruri: Error while parsing message\n");
367 367
 		return -1;
368 368
 	}
... ...
@@ -451,7 +451,7 @@ static inline int find_rem_target(struct sip_msg* _m, struct hdr_field** _h, rr_
451 451
 {
452 452
 	struct hdr_field* ptr, *last;
453 453
 
454
-	if (parse_headers(_m, HDR_EOH, 0) == -1) {
454
+	if (parse_headers(_m, HDR_EOH_F, 0) == -1) {
455 455
 		LOG(L_ERR, "find_rem_target: Error while parsing message header\n");
456 456
 		return -1;
457 457
 	}
... ...
@@ -460,7 +460,7 @@ static inline int find_rem_target(struct sip_msg* _m, struct hdr_field** _h, rr_
460 460
 	last = 0;
461 461
 
462 462
 	while(ptr) {
463
-		if (ptr->type == HDR_ROUTE) last = ptr;
463
+		if (ptr->type == HDR_ROUTE_T) last = ptr;
464 464
 		ptr = ptr->next;
465 465
 	}
466 466
 
... ...
@@ -161,7 +161,7 @@ int sl_send_reply(struct sip_msg *msg ,int code ,char *text )
161 161
 		 * 100 replies */
162 162
        		/* msg->first_line.u.request.method_value==METHOD_INVITE && */
163 163
 		code>=180 &&
164
-		(msg->to || (parse_headers(msg,HDR_TO, 0)!=-1 && msg->to))
164
+		(msg->to || (parse_headers(msg,HDR_TO_F, 0)!=-1 && msg->to))
165 165
 		&& (get_to(msg)->tag_value.s==0 || get_to(msg)->tag_value.len==0) ) 
166 166
 	{
167 167
 		calc_crc_suffix( msg, tag_suffix );
... ...
@@ -241,7 +241,7 @@ int sl_filter_ACK(struct sip_msg *msg, void *bar )
241 241
 	}
242 242
 
243 243
 	/*force to parse to header -> we need it for tag param*/
244
-	if (parse_headers( msg, HDR_TO, 0 )==-1)
244
+	if (parse_headers( msg, HDR_TO_F, 0 )==-1)
245 245
 	{
246 246
 		LOG(L_ERR,"ERROR : SL_FILTER_ACK: unable to parse To header\n");
247 247
 		return -1;
... ...
@@ -208,8 +208,9 @@ int push_on_network(struct sip_msg *msg, int net)
208 208
 		msg->first_line.u.request.uri.len ,&uri)||!uri.user.len )
209 209
 		{
210 210
 			DBG("DEBUG:sms_push_on_net: string to get user from To\n");
211
-			if ( (!msg->to&&((parse_headers(msg,HDR_TO,0)==-1) || !msg->to)) ||
212
-			parse_uri( get_to(msg)->uri.s, get_to(msg)->uri.len, &uri)==-1
211
+			if ( (!msg->to&&((parse_headers(msg,HDR_TO_F,0)==-1) ||
212
+					!msg->to)) ||
213
+				parse_uri( get_to(msg)->uri.s, get_to(msg)->uri.len, &uri)==-1
213 214
 			|| !uri.user.len)
214 215
 			{
215 216
 				LOG(L_ERR,"ERROR:sms_push_on_net: unable to extract user"
... ...
@@ -445,7 +445,7 @@ static int remove_hf_f(struct sip_msg* msg, char* str_hf, char* foo)
445 445
 
446 446
 	cnt=0;
447 447
 	/* we need to be sure we have seen all HFs */
448
-	parse_headers(msg, HDR_EOH, 0);
448
+	parse_headers(msg, HDR_EOH_F, 0);
449 449
 	for (hf=msg->headers; hf; hf=hf->next) {
450 450
 		if (hf->name.len!=((str *)str_hf)->len)
451 451
 			continue;
... ...
@@ -466,7 +466,7 @@ static int is_present_hf_f(struct sip_msg* msg, char* str_hf, char* foo)
466 466
 	struct hdr_field *hf;
467 467
 
468 468
 	/* we need to be sure we have seen all HFs */
469
-	parse_headers(msg, HDR_EOH, 0);
469
+	parse_headers(msg, HDR_EOH_F, 0);
470 470
 	for (hf=msg->headers; hf; hf=hf->next) {
471 471
 		if (hf->name.len!=((str *)str_hf)->len)
472 472
 			continue;
... ...
@@ -579,7 +579,7 @@ static int append_hf_helper(struct sip_msg* msg, str *str1, str *str2)
579 579
 	char *s;
580 580
 	int len;
581 581
 
582
-	if (parse_headers(msg, HDR_EOH, 0) == -1) {
582
+	if (parse_headers(msg, HDR_EOH_F, 0) == -1) {
583 583
 		LOG(L_ERR, "append_hf(): Error while parsing message\n");
584 584
 		return -1;
585 585
 	}
... ...
@@ -56,7 +56,7 @@ int has_totag(struct sip_msg* _m, char* _foo, char* _bar)
56 56
 {
57 57
 	str tag;
58 58
 
59
-	if (!_m->to && parse_headers(_m, HDR_TO,0)==-1) {
59
+	if (!_m->to && parse_headers(_m, HDR_TO_F,0)==-1) {
60 60
 		LOG(L_ERR, "ERROR: has_totag: To parsing failed\n");
61 61
 		return -1;
62 62
 	}
... ...
@@ -161,7 +161,7 @@ static inline int check_username(struct sip_msg* _m, str* _uri)
161 161
  */
162 162
 int check_to(struct sip_msg* _m, char* _s1, char* _s2)
163 163
 {
164
-	if (!_m->to && ((parse_headers(_m, HDR_TO, 0) == -1) || (!_m->to))) {
164
+	if (!_m->to && ((parse_headers(_m, HDR_TO_F, 0) == -1) || (!_m->to))) {
165 165
 		LOG(L_ERR, "check_to(): Error while parsing To header field\n");
166 166
 		return -1;
167 167
 	}
... ...
@@ -255,7 +255,7 @@ static int xl_get_contact(struct sip_msg* msg, str* res, str *hp, int hi)
255 255
 	if(msg==NULL || res==NULL)
256 256
 		return -1;
257 257
 
258
-	if(msg->contact==NULL && parse_headers(msg, HDR_CONTACT, 0)==-1) 
258
+	if(msg->contact==NULL && parse_headers(msg, HDR_CONTACT_F, 0)==-1) 
259 259
 	{
260 260
 		DBG("XLOG: xl_get_contact: no contact header\n");
261 261
 		return xl_get_null(msg, res, hp, hi);
... ...
@@ -326,7 +326,7 @@ static int xl_get_to(struct sip_msg *msg, str *res, str *hp, int hi)
326 326
 	if(msg==NULL || res==NULL)
327 327
 		return -1;
328 328
 
329
-	if(msg->to==NULL && parse_headers(msg, HDR_TO, 0)==-1)
329
+	if(msg->to==NULL && parse_headers(msg, HDR_TO_F, 0)==-1)
330 330
 	{
331 331
 		LOG(L_ERR, "XLOG: xl_get_to: ERROR cannot parse TO header\n");
332 332
 		return xl_get_null(msg, res, hp, hi);
... ...
@@ -345,7 +345,7 @@ static int xl_get_to_tag(struct sip_msg* msg, str* res, str *hp, int hi)
345 345
 	if(msg==NULL || res==NULL)
346 346
 		return -1;
347 347
 
348
-	if(msg->to==NULL && ((parse_headers(msg, HDR_TO, 0)==-1) || 
348
+	if(msg->to==NULL && ((parse_headers(msg, HDR_TO_F, 0)==-1) || 
349 349
 				(msg->to==NULL)) )
350 350
 	{
351 351
 		LOG(L_ERR, "XLOG: xl_get_to: ERROR cannot parse TO header\n");
... ...
@@ -366,7 +366,7 @@ static int xl_get_cseq(struct sip_msg *msg, str *res, str *hp, int hi)
366 366
 	if(msg==NULL || res==NULL)
367 367
 		return -1;
368 368
 	
369
-	if(msg->cseq==NULL && ((parse_headers(msg, HDR_CSEQ, 0)==-1) || 
369
+	if(msg->cseq==NULL && ((parse_headers(msg, HDR_CSEQ_F, 0)==-1) || 
370 370
 				(msg->cseq==NULL)) )
371 371
 	{
372 372
 		LOG(L_ERR, "XLOG: xl_get_cseq: ERROR cannot parse CSEQ header\n");
... ...
@@ -425,7 +425,7 @@ static int xl_get_callid(struct sip_msg *msg, str *res, str *hp, int hi)
425 425
 	if(msg==NULL || res==NULL)
426 426
 		return -1;
427 427
 	
428
-	if(msg->callid==NULL && ((parse_headers(msg, HDR_CALLID, 0)==-1) ||
428
+	if(msg->callid==NULL && ((parse_headers(msg, HDR_CALLID_F, 0)==-1) ||
429 429
 				(msg->callid==NULL)) )
430 430
 	{
431 431
 		LOG(L_ERR, "XLOG: xl_get_cseq: ERROR cannot parse Call-Id header\n");
... ...
@@ -499,7 +499,7 @@ static int xl_get_useragent(struct sip_msg *msg, str *res, str *hp, int hi)
499 499
 {
500 500
 	if(msg==NULL || res==NULL) 
501 501
 		return -1;
502
-	if(msg->user_agent==NULL && ((parse_headers(msg, HDR_USERAGENT, 0)==-1)
502
+	if(msg->user_agent==NULL && ((parse_headers(msg, HDR_USERAGENT_F, 0)==-1)
503 503
 			 || (msg->user_agent==NULL)))
504 504
 	{
505 505
 		LOG(L_ERR, "XLOG: xl_get_useragent: ERROR cannot parse User-Agent header\n");
... ...
@@ -560,7 +560,7 @@ static int xl_get_header(struct sip_msg *msg, str *res, str *hp, int hi)
560 560
 	hf0 = NULL;
561 561
 
562 562
 	/* we need to be sure we have parsed all headers */
563
-	parse_headers(msg, HDR_EOH, 0);
563
+	parse_headers(msg, HDR_EOH_F, 0);
564 564
 	for (hf=msg->headers; hf; hf=hf->next)
565 565
 	{
566 566
 		if(hp->s==NULL)
... ...
@@ -885,7 +885,7 @@ int xl_parse_format(char *s, xl_elog_p *el)
885 885
 				}
886 886
 				e->hparam.len--;
887 887
 				e->hparam.s[e->hparam.len] = c;
888
-				if (hdr.type!=HDR_OTHER && hdr.type!=HDR_ERROR)
888
+				if (hdr.type!=HDR_OTHER_T && hdr.type!=HDR_ERROR_T)
889 889
 				{
890 890
 					LOG(L_INFO,"INFO:xlog: xl_parse_format: using "
891 891
 						"hdr type (%d) instead of <%.*s>\n",