Browse code

various modules: don't access route_type directly

route_type should be accessed only through get_route_type() or
is_route_type(FOO).
Replaced all the route_type==FOO_ROUTE with
is_route_type(FOO_ROUTE).

Andrei Pelinescu-Onciul authored on 22/02/2010 18:45:14
Showing 7 changed files
... ...
@@ -288,7 +288,7 @@ static int dp_update(struct sip_msg * msg, pv_spec_t * src, pv_spec_t * dest,
288 288
 		return -1;
289 289
 	}
290 290
 
291
-	if(route_type==FAILURE_ROUTE
291
+	if(is_route_type(FAILURE_ROUTE)
292 292
 				&& (dest->type==PVT_RURI || dest->type==PVT_RURI_USERNAME)) {
293 293
 		if (append_branch(msg, 0, 0, 0, Q_UNSPECIFIED, 0, 0)!=1 ){
294 294
 			LM_ERR("append_branch action failed\n");
... ...
@@ -2048,7 +2048,7 @@ static int next_gw(struct sip_msg* _m, char* _s1, char* _s2)
2048 2048
 	}
2049 2049
     }
2050 2050
 
2051
-    if ((route_type == REQUEST_ROUTE) && (ru_avp == NULL)) {
2051
+    if ((is_route_type(REQUEST_ROUTE)) && (ru_avp == NULL)) {
2052 2052
 
2053 2053
 	/* First invocation in route block => Rewrite Request URI. */
2054 2054
 	memset(&act, '\0', sizeof(act));
... ...
@@ -337,7 +337,7 @@ static struct dlg_cell *get_current_dialog(struct sip_msg *msg)
337 337
 	struct cell *trans;
338 338
 	struct tm_callback* x;
339 339
 
340
-	if (route_type==REQUEST_ROUTE) {
340
+	if (is_route_type(REQUEST_ROUTE)) {
341 341
 		/* use the per-process static holder */
342 342
 		if (msg->id==current_dlg_msg_id)
343 343
 			return current_dlg_pointer;
... ...
@@ -478,7 +478,7 @@ int set_dlg_profile(struct sip_msg *msg, str *value, struct dlg_profile_table *p
478 478
 	/* get current dialog */
479 479
 	dlg = get_current_dialog(msg);
480 480
 
481
-	if (dlg==NULL && route_type!=REQUEST_ROUTE) {
481
+	if (dlg==NULL && !is_route_type(REQUEST_ROUTE)) {
482 482
 		LM_CRIT("BUG - dialog not found in a non REQUEST route (%d)\n",
483 483
 			REQUEST_ROUTE);
484 484
 		return -1;
... ...
@@ -534,7 +534,7 @@ int unset_dlg_profile(struct sip_msg *msg, str *value,
534 534
 	/* get current dialog */
535 535
 	dlg = get_current_dialog(msg);
536 536
 
537
-	if (dlg==NULL || route_type==REQUEST_ROUTE) {
537
+	if (dlg==NULL || is_route_type(REQUEST_ROUTE)) {
538 538
 		LM_CRIT("BUG - dialog NULL or del_profile used in request route\n");
539 539
 		return -1;
540 540
 	}
... ...
@@ -1237,7 +1237,7 @@ static inline int ds_update_dst(struct sip_msg *msg, str *uri, int mode)
1237 1237
 			}	
1238 1238
 		break;
1239 1239
 	}
1240
-	if(ds_append_branch!=0 && route_type==FAILURE_ROUTE)
1240
+	if(ds_append_branch!=0 && is_route_type(FAILURE_ROUTE))
1241 1241
 	{
1242 1242
 		if (append_branch(msg, 0, duri, 0, Q_UNSPECIFIED, 0, 0)!=1 )
1243 1243
 		{
... ...
@@ -168,13 +168,13 @@ int is_uri_host_local(struct sip_msg* _msg, char* _s1, char* _s2)
168 168
 	qvalue_t q;
169 169
 	struct sip_uri puri;
170 170
 
171
-	if ( route_type&(REQUEST_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE) ) {
171
+	if ( is_route_type(REQUEST_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE) ) {
172 172
 		if (parse_sip_msg_uri(_msg) < 0) {
173 173
 			LM_ERR("Error while parsing R-URI\n");
174 174
 			return -1;
175 175
 		}
176 176
 		return is_domain_local(&(_msg->parsed_uri.host));
177
-	} else if (route_type == FAILURE_ROUTE) {
177
+	} else if (is_route_type(FAILURE_ROUTE)) {
178 178
 			branch.s = get_branch(0, &branch.len, &q, 0, 0, 0, 0);
179 179
 			if (branch.s) {
180 180
 				if (parse_uri(branch.s, branch.len, &puri) < 0) {
... ...
@@ -765,7 +765,7 @@ int dp_can_connect(struct sip_msg* _msg, char* _s1, char* _s2) {
765 765
 	str domain;
766 766
 	int ret;
767 767
 
768
-	if (route_type != REQUEST_ROUTE) {
768
+	if (!is_route_type(REQUEST_ROUTE)) {
769 769
 		LM_ERR("unsupported route type\n");
770 770
 		return -1;
771 771
 	}
... ...
@@ -823,7 +823,7 @@ int dp_apply_policy(struct sip_msg* _msg, char* _s1, char* _s2) {
823 823
 	int port, proto;
824 824
 	struct socket_info* si;
825 825
 
826
-	if (route_type != REQUEST_ROUTE) {
826
+	if (!is_route_type(REQUEST_ROUTE)) {
827 827
 		LM_ERR("unsupported route type\n");
828 828
 		return -1;
829 829
 	}
... ...
@@ -784,13 +784,13 @@ int save(struct sip_msg* _m, char* _d, char* _cflags)
784 784
 	update_stat(accepted_registrations, 1);
785 785
 
786 786
 	/* Only send reply upon request, not upon reply */
787
-	if ((route_type == REQUEST_ROUTE) && !is_cflag_set(REG_SAVE_NORPL_FL) && (reg_send_reply(_m) < 0))
787
+	if ((is_route_type(REQUEST_ROUTE)) && !is_cflag_set(REG_SAVE_NORPL_FL) && (reg_send_reply(_m) < 0))
788 788
 		return -1;
789 789
 
790 790
 	return ret;
791 791
 error:
792 792
 	update_stat(rejected_registrations, 1);
793
-	if ((route_type == REQUEST_ROUTE) && !is_cflag_set(REG_SAVE_NORPL_FL) )
793
+	if (is_route_type(REQUEST_ROUTE) && !is_cflag_set(REG_SAVE_NORPL_FL) )
794 794
 		reg_send_reply(_m);
795 795
 
796 796
 	return 0;