瀏覽代碼

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 15 年之前
父節點
當前提交
d06c0f78f3

+ 1 - 1
modules/dialplan/dialplan.c

@@ -288,7 +288,7 @@ static int dp_update(struct sip_msg * msg, pv_spec_t * src, pv_spec_t * dest,
 		return -1;
 	}
 
-	if(route_type==FAILURE_ROUTE
+	if(is_route_type(FAILURE_ROUTE)
 				&& (dest->type==PVT_RURI || dest->type==PVT_RURI_USERNAME)) {
 		if (append_branch(msg, 0, 0, 0, Q_UNSPECIFIED, 0, 0)!=1 ){
 			LM_ERR("append_branch action failed\n");

+ 1 - 1
modules/lcr/lcr_mod.c

@@ -2048,7 +2048,7 @@ static int next_gw(struct sip_msg* _m, char* _s1, char* _s2)
 	}
     }
 
-    if ((route_type == REQUEST_ROUTE) && (ru_avp == NULL)) {
+    if ((is_route_type(REQUEST_ROUTE)) && (ru_avp == NULL)) {
 
 	/* First invocation in route block => Rewrite Request URI. */
 	memset(&act, '\0', sizeof(act));

+ 3 - 3
modules_k/dialog/dlg_profile.c

@@ -337,7 +337,7 @@ static struct dlg_cell *get_current_dialog(struct sip_msg *msg)
 	struct cell *trans;
 	struct tm_callback* x;
 
-	if (route_type==REQUEST_ROUTE) {
+	if (is_route_type(REQUEST_ROUTE)) {
 		/* use the per-process static holder */
 		if (msg->id==current_dlg_msg_id)
 			return current_dlg_pointer;
@@ -478,7 +478,7 @@ int set_dlg_profile(struct sip_msg *msg, str *value, struct dlg_profile_table *p
 	/* get current dialog */
 	dlg = get_current_dialog(msg);
 
-	if (dlg==NULL && route_type!=REQUEST_ROUTE) {
+	if (dlg==NULL && !is_route_type(REQUEST_ROUTE)) {
 		LM_CRIT("BUG - dialog not found in a non REQUEST route (%d)\n",
 			REQUEST_ROUTE);
 		return -1;
@@ -534,7 +534,7 @@ int unset_dlg_profile(struct sip_msg *msg, str *value,
 	/* get current dialog */
 	dlg = get_current_dialog(msg);
 
-	if (dlg==NULL || route_type==REQUEST_ROUTE) {
+	if (dlg==NULL || is_route_type(REQUEST_ROUTE)) {
 		LM_CRIT("BUG - dialog NULL or del_profile used in request route\n");
 		return -1;
 	}

+ 1 - 1
modules_k/dispatcher/dispatch.c

@@ -1237,7 +1237,7 @@ static inline int ds_update_dst(struct sip_msg *msg, str *uri, int mode)
 			}	
 		break;
 	}
-	if(ds_append_branch!=0 && route_type==FAILURE_ROUTE)
+	if(ds_append_branch!=0 && is_route_type(FAILURE_ROUTE))
 	{
 		if (append_branch(msg, 0, duri, 0, Q_UNSPECIFIED, 0, 0)!=1 )
 		{

+ 2 - 2
modules_k/domain/domain.c

@@ -168,13 +168,13 @@ int is_uri_host_local(struct sip_msg* _msg, char* _s1, char* _s2)
 	qvalue_t q;
 	struct sip_uri puri;
 
-	if ( route_type&(REQUEST_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE) ) {
+	if ( is_route_type(REQUEST_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE) ) {
 		if (parse_sip_msg_uri(_msg) < 0) {
 			LM_ERR("Error while parsing R-URI\n");
 			return -1;
 		}
 		return is_domain_local(&(_msg->parsed_uri.host));
-	} else if (route_type == FAILURE_ROUTE) {
+	} else if (is_route_type(FAILURE_ROUTE)) {
 			branch.s = get_branch(0, &branch.len, &q, 0, 0, 0, 0);
 			if (branch.s) {
 				if (parse_uri(branch.s, branch.len, &puri) < 0) {

+ 2 - 2
modules_k/domainpolicy/domainpolicy.c

@@ -765,7 +765,7 @@ int dp_can_connect(struct sip_msg* _msg, char* _s1, char* _s2) {
 	str domain;
 	int ret;
 
-	if (route_type != REQUEST_ROUTE) {
+	if (!is_route_type(REQUEST_ROUTE)) {
 		LM_ERR("unsupported route type\n");
 		return -1;
 	}
@@ -823,7 +823,7 @@ int dp_apply_policy(struct sip_msg* _msg, char* _s1, char* _s2) {
 	int port, proto;
 	struct socket_info* si;
 
-	if (route_type != REQUEST_ROUTE) {
+	if (!is_route_type(REQUEST_ROUTE)) {
 		LM_ERR("unsupported route type\n");
 		return -1;
 	}

+ 2 - 2
modules_k/registrar/save.c

@@ -784,13 +784,13 @@ int save(struct sip_msg* _m, char* _d, char* _cflags)
 	update_stat(accepted_registrations, 1);
 
 	/* Only send reply upon request, not upon reply */
-	if ((route_type == REQUEST_ROUTE) && !is_cflag_set(REG_SAVE_NORPL_FL) && (reg_send_reply(_m) < 0))
+	if ((is_route_type(REQUEST_ROUTE)) && !is_cflag_set(REG_SAVE_NORPL_FL) && (reg_send_reply(_m) < 0))
 		return -1;
 
 	return ret;
 error:
 	update_stat(rejected_registrations, 1);
-	if ((route_type == REQUEST_ROUTE) && !is_cflag_set(REG_SAVE_NORPL_FL) )
+	if (is_route_type(REQUEST_ROUTE) && !is_cflag_set(REG_SAVE_NORPL_FL) )
 		reg_send_reply(_m);
 
 	return 0;