various modules: don't access route_type directly
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Mon, 22 Feb 2010 18:45:14 +0000 (19:45 +0100)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Mon, 22 Feb 2010 18:45:14 +0000 (19:45 +0100)
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).

modules/dialplan/dialplan.c
modules/lcr/lcr_mod.c
modules_k/dialog/dlg_profile.c
modules_k/dispatcher/dispatch.c
modules_k/domain/domain.c
modules_k/domainpolicy/domainpolicy.c
modules_k/registrar/save.c

index 15477e1..e102748 100644 (file)
@@ -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");
index 3c83bfb..cd05b06 100644 (file)
@@ -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));
index 8df5792..723b9aa 100644 (file)
@@ -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;
        }
index befac12..5fdc86b 100644 (file)
@@ -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 )
                {
index 3b217c7..942a6ce 100644 (file)
@@ -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) {
index f77095e..ad138e3 100644 (file)
@@ -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;
        }
index 3b479f6..71c8021 100644 (file)
@@ -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;