Пример #1
0
EC_BOOL taskcfgchk_net_all(LOG *log, const TASK_CFG *task_cfg)
{
    UINT32 pos;

    CVECTOR_LOCK(TASK_CFG_TASKS_CFG_VEC(task_cfg), LOC_TASKCFGCHK_0015);
    for(pos = 0; pos < cvector_size(TASK_CFG_TASKS_CFG_VEC(task_cfg)); pos ++)
    {
        TASKS_CFG *tasks_cfg;
        TASK_CFG  *des_task_cfg;

        tasks_cfg = (TASKS_CFG *)cvector_get_no_lock(TASK_CFG_TASKS_CFG_VEC(task_cfg), pos);
        if(NULL_PTR == tasks_cfg)
        {
            continue;
        }

        sys_log(log, "[TASKCFGCHK] ------------------------------ check tcid %s, maski %s, maske %s ----------------------------------\n",
                    TASKS_CFG_TCID_STR(tasks_cfg),
                    TASKS_CFG_MASKI_STR(tasks_cfg),
                    TASKS_CFG_MASKE_STR(tasks_cfg)
                    );

        des_task_cfg = task_cfg_new();
        task_cfg_filter(task_cfg, TASKS_CFG_TCID(tasks_cfg), des_task_cfg);
        task_cfg_print_xml(log, des_task_cfg, 0);
        task_cfg_free(des_task_cfg);
    }

    return (EC_TRUE);
}
Пример #2
0
static EC_BOOL taskcfgchk_conn_test(const TASK_CFG *task_cfg, const TASKS_CFG *local_tasks_cfg, const UINT32 remote_tcid)
{
    UINT32 pos;

    CVECTOR_LOCK(TASK_CFG_TASKS_CFG_VEC(task_cfg), LOC_TASKCFGCHK_0008);
    for(pos = 0; pos < cvector_size(TASK_CFG_TASKS_CFG_VEC(task_cfg)); pos ++)
    {
        TASKS_CFG *remote_tasks_cfg;

        remote_tasks_cfg = (TASKS_CFG *)cvector_get_no_lock(TASK_CFG_TASKS_CFG_VEC(task_cfg), pos);
        if(NULL_PTR == remote_tasks_cfg)
        {
            continue;
        }

        if(
           (remote_tcid == TASKS_CFG_TCID(remote_tasks_cfg))
        &&
            (
               EC_TRUE == tasks_cfg_is_intranet(local_tasks_cfg, remote_tasks_cfg)
            || EC_TRUE == tasks_cfg_is_externet(local_tasks_cfg, remote_tasks_cfg)
            || EC_TRUE == tasks_cfg_is_lannet(local_tasks_cfg, remote_tasks_cfg)
            || EC_TRUE == tasks_cfg_is_dbgnet(local_tasks_cfg, remote_tasks_cfg)
            || EC_TRUE == tasks_cfg_is_monnet(local_tasks_cfg, remote_tasks_cfg)
            )
        )
        {
            CVECTOR_UNLOCK(TASK_CFG_TASKS_CFG_VEC(task_cfg), LOC_TASKCFGCHK_0009);
            return (EC_TRUE);
        }
    }
    CVECTOR_UNLOCK(TASK_CFG_TASKS_CFG_VEC(task_cfg), LOC_TASKCFGCHK_0010);
    return (EC_FALSE);
}
Пример #3
0
EC_BOOL taskcfgchk_route_print(LOG *log, const TASK_CFG *task_cfg, const UINT32 tcid, const UINT32 maski, const UINT32 maske)
{
    TASKS_CFG *tasks_cfg;
    UINT32 pos;

    tasks_cfg = task_cfg_searchs(task_cfg, tcid, maski, maske);
    if(NULL_PTR == tasks_cfg)
    {
        sys_log(log, "error:taskcfgchk_route_print: no tasks cfg for tcid %s maski %s, maske %s\n",
                        c_word_to_ipv4(tcid), c_word_to_ipv4(maski), c_word_to_ipv4(maske));
        return (EC_FALSE);
    }

    CVECTOR_LOCK(TASKS_CFG_TASKR_CFG_VEC(tasks_cfg), LOC_TASKCFGCHK_0003);
    for(pos = 0; pos < cvector_size(TASKS_CFG_TASKR_CFG_VEC(tasks_cfg)); pos ++)
    {
        TASKR_CFG *taskr_cfg;

        taskr_cfg = (TASKR_CFG *)cvector_get_no_lock(TASKS_CFG_TASKR_CFG_VEC(tasks_cfg), pos);
        if(NULL_PTR == taskr_cfg)
        {
            continue;
        }

        sys_log(log, "[TASKCFGCHK] route No. %ld: des_tcid = %s, maskr = %s, next_tcid = %s\n", pos,
                    TASKR_CFG_DES_TCID_STR(taskr_cfg),
                    TASKR_CFG_MASKR_STR(taskr_cfg),
                    TASKR_CFG_NEXT_TCID_STR(taskr_cfg));
    }
    CVECTOR_UNLOCK(TASKS_CFG_TASKR_CFG_VEC(tasks_cfg), LOC_TASKCFGCHK_0004);

    return (EC_TRUE);
}
Пример #4
0
CROUTER_NODE *crouter_node_vec_find(CROUTER_NODE_VEC *crouter_node_vec, const UINT32 des_tcid)
{
    UINT32 pos;

    CVECTOR_LOCK(CROUTER_NODE_VEC_NODES(crouter_node_vec), LOC_CROUTER_0033);
    for(pos = 0; pos < cvector_size(CROUTER_NODE_VEC_NODES(crouter_node_vec)); pos ++)
    {
        CROUTER_NODE *crouter_node;

        crouter_node = (CROUTER_NODE *)cvector_get_no_lock(CROUTER_NODE_VEC_NODES(crouter_node_vec), pos);
        if(NULL_PTR == crouter_node)
        {
            continue;
        }

        if(des_tcid == CROUTER_NODE_DES_TCID(crouter_node))
        {
            CVECTOR_UNLOCK(CROUTER_NODE_VEC_NODES(crouter_node_vec), LOC_CROUTER_0034);
            return (crouter_node);
        }
    }
    CVECTOR_UNLOCK(CROUTER_NODE_VEC_NODES(crouter_node_vec), LOC_CROUTER_0035);

    return (NULL_PTR);
}
Пример #5
0
TASKS_NODE * crouter_node_min_load_next_hop(const CROUTER_NODE *crouter_node)
{
    UINT32      pos;
    UINT32      min_load;
    TASKS_NODE *min_tasks_node;

    min_load = ((UINT32)-1);
    min_tasks_node = NULL_PTR;

    CVECTOR_LOCK(CROUTER_NODE_NEXT_HOPS(crouter_node), LOC_CROUTER_0015);
    for(pos = 0; pos < cvector_size(CROUTER_NODE_NEXT_HOPS(crouter_node)); pos ++)
    {
        TASKS_NODE *tasks_node;
        UINT32 cur_load;

        tasks_node = (TASKS_NODE *)cvector_get_no_lock(CROUTER_NODE_NEXT_HOPS(crouter_node), pos);
        if(NULL_PTR == tasks_node)
        {
            continue;
        }

        cur_load = TASKS_NODE_LOAD(tasks_node);/*replace it when TASKS_NOE implement load*/
        if(min_load > cur_load)
        {
            min_load = cur_load;
            min_tasks_node = tasks_node;
        }
    }
    CVECTOR_UNLOCK(CROUTER_NODE_NEXT_HOPS(crouter_node), LOC_CROUTER_0016);

    return (min_tasks_node);
}
Пример #6
0
EC_BOOL taskcfgchk_conn_print(LOG *log, const TASK_CFG *task_cfg, const UINT32 tcid, const UINT32 maski, const UINT32 maske, const UINT32 remote_tcid)
{
    TASKS_CFG *local_tasks_cfg;
    UINT32 pos;

    local_tasks_cfg = task_cfg_searchs(task_cfg, tcid, maski, maske);
    if(NULL_PTR == local_tasks_cfg)
    {
        sys_log(log, "error:taskcfgchk_conn_print: no tasks cfg for tcid %s maski %s, maske %s\n",
                        c_word_to_ipv4(tcid), c_word_to_ipv4(maski), c_word_to_ipv4(maske));
        return (EC_FALSE);
    }

    CVECTOR_LOCK(TASK_CFG_TASKS_CFG_VEC(task_cfg), LOC_TASKCFGCHK_0005);
    for(pos = 0; pos < cvector_size(TASK_CFG_TASKS_CFG_VEC(task_cfg)); pos ++)
    {
        TASKS_CFG *remote_tasks_cfg;

        remote_tasks_cfg = (TASKS_CFG *)cvector_get_no_lock(TASK_CFG_TASKS_CFG_VEC(task_cfg), pos);
        if(NULL_PTR == remote_tasks_cfg)
        {
            continue;
        }

        if(
           (remote_tcid == TASKS_CFG_TCID(remote_tasks_cfg))
        &&
            (
               EC_TRUE == tasks_cfg_is_intranet(local_tasks_cfg, remote_tasks_cfg)
            || EC_TRUE == tasks_cfg_is_externet(local_tasks_cfg, remote_tasks_cfg)
            || EC_TRUE == tasks_cfg_is_lannet(local_tasks_cfg, remote_tasks_cfg)
            || EC_TRUE == tasks_cfg_is_dbgnet(local_tasks_cfg, remote_tasks_cfg)
            || EC_TRUE == tasks_cfg_is_monnet(local_tasks_cfg, remote_tasks_cfg)
            )
        )
        {
            sys_log(log, "[TASKCFGCHK] tcid %s maski %s maske %s --> tcid %s maski %s maske %s\n",
                            TASKS_CFG_TCID_STR(local_tasks_cfg),
                            TASKS_CFG_MASKI_STR(local_tasks_cfg),
                            TASKS_CFG_MASKE_STR(local_tasks_cfg),

                            TASKS_CFG_TCID_STR(remote_tasks_cfg),
                            TASKS_CFG_MASKI_STR(remote_tasks_cfg),
                            TASKS_CFG_MASKE_STR(remote_tasks_cfg)
                            );
            CVECTOR_UNLOCK(TASK_CFG_TASKS_CFG_VEC(task_cfg), LOC_TASKCFGCHK_0006);
            return (EC_TRUE);
        }
    }
    CVECTOR_UNLOCK(TASK_CFG_TASKS_CFG_VEC(task_cfg), LOC_TASKCFGCHK_0007);
    return (EC_FALSE);
}
Пример #7
0
void chfsnp_mgr_print_db(LOG *log, const CHFSNP_MGR *chfsnp_mgr)
{
    uint32_t chfsnp_home_dir_num;
    uint32_t chfsnp_home_dir_pos;
    uint32_t chfsnp_num;
    uint32_t chfsnp_id;

    sys_log(log, "chfsnp mgr db root dir  : %s\n", (char *)CHFSNP_MGR_DB_ROOT_DIR_STR(chfsnp_mgr));
    sys_log(log, "chfsnp model            : %u\n", CHFSNP_MGR_NP_MODEL(chfsnp_mgr));
    sys_log(log, "chfsnp 1st hash algo id : %u\n", CHFSNP_MGR_NP_1ST_CHASH_ALGO_ID(chfsnp_mgr));
    sys_log(log, "chfsnp 2nd hash algo id : %u\n", CHFSNP_MGR_NP_2ND_CHASH_ALGO_ID(chfsnp_mgr));
    sys_log(log, "chfsnp item max num     : %u\n", CHFSNP_MGR_NP_ITEM_MAX_NUM(chfsnp_mgr));
    sys_log(log, "chfsnp max num          : %u\n", CHFSNP_MGR_NP_MAX_NUM(chfsnp_mgr));

    chfsnp_home_dir_num = (uint32_t)cvector_size(CHFSNP_MGR_NP_HOME_DIR_VEC(chfsnp_mgr));
    for(chfsnp_home_dir_pos = 0; chfsnp_home_dir_pos < chfsnp_home_dir_num; chfsnp_home_dir_pos ++)
    {
        CSTRING *chfsnp_home_dir_cstr;

        chfsnp_home_dir_cstr = cvector_get_no_lock(CHFSNP_MGR_NP_HOME_DIR_VEC(chfsnp_mgr), chfsnp_home_dir_pos);
        if(NULL_PTR == chfsnp_home_dir_cstr || EC_TRUE == cstring_is_empty(chfsnp_home_dir_cstr))
        {
            sys_log(log, "home dir %u #: (null)\n", chfsnp_home_dir_pos);
        }
        else
        {
            sys_log(log, "home dir %u #: %.*s\n", chfsnp_home_dir_pos,
                        cstring_get_len(chfsnp_home_dir_cstr), (char *)cstring_get_str(chfsnp_home_dir_cstr));
        }
    }

    chfsnp_num = (uint32_t)cvector_size(CHFSNP_MGR_NP_VEC(chfsnp_mgr));
    for(chfsnp_id = 0; chfsnp_id < chfsnp_num; chfsnp_id ++)
    {
        CHFSNP *chfsnp;

        chfsnp = CHFSNP_MGR_NP(chfsnp_mgr, chfsnp_id);
        if(NULL_PTR == chfsnp)
        {
            sys_log(log, "np %u #: (null)\n", chfsnp_id);
        }
        else
        {
            chfsnp_print(log, chfsnp);
        }
    }
    return;
}
Пример #8
0
CROUTER_NODE *crouter_node_vec_find_no_lock(CROUTER_NODE_VEC *crouter_node_vec, const UINT32 des_tcid)
{
    UINT32 pos;

    for(pos = 0; pos < cvector_size(CROUTER_NODE_VEC_NODES(crouter_node_vec)); pos ++)
    {
        CROUTER_NODE *crouter_node;

        crouter_node = (CROUTER_NODE *)cvector_get_no_lock(CROUTER_NODE_VEC_NODES(crouter_node_vec), pos);
        if(NULL_PTR == crouter_node)
        {
            continue;
        }

        if(des_tcid == CROUTER_NODE_DES_TCID(crouter_node))
        {
            return (crouter_node);
        }
    }

    return (NULL_PTR);
}
Пример #9
0
/*bind home_dir and name node, i.e., one name node owns unique home dir*/
EC_BOOL chfsnp_mgr_bind(CHFSNP_MGR *chfsnp_mgr, const CSTRING *path, const UINT32 chfsnp_id)
{
    CSTRING *home_dir;
    CSTRING *home_dir_old;
    uint32_t home_dir_pos;

    ASSERT(cvector_size(CHFSNP_MGR_NP_HOME_DIR_VEC(chfsnp_mgr)) == CHFSNP_MGR_NP_MAX_NUM(chfsnp_mgr));
    if(CHFSNP_MGR_NP_MAX_NUM(chfsnp_mgr) <= chfsnp_id)
    {
        sys_log(LOGSTDOUT, "error:chfsnp_mgr_bind: max np num %u but chfsnp id %u overflow\n", CHFSNP_MGR_NP_MAX_NUM(chfsnp_mgr), chfsnp_id);
        return (EC_FALSE);
    }

    home_dir_pos = __chfsnp_mgr_get_np_id_of_path(chfsnp_mgr, (uint32_t)cstring_get_len(path), cstring_get_str(path));
    if(CHFSNP_ERR_ID != home_dir_pos)
    {
        home_dir = cvector_get_no_lock(CHFSNP_MGR_NP_HOME_DIR_VEC(chfsnp_mgr), home_dir_pos);
        sys_log(LOGSTDOUT, "error:chfsnp_mgr_bind: some dir %s already bound to np %u, thus cannot accept binding %s\n", 
                            (char *)cstring_get_str(home_dir), home_dir_pos, (char *)cstring_get_str(path));
        return (EC_FALSE);
    }    

    home_dir = cstring_dup(path);
    if(NULL_PTR == home_dir)
    {
        sys_log(LOGSTDOUT, "error:chfsnp_mgr_bind: dup %s failed\n", (char *)cstring_get_str(path));
        return (EC_FALSE);
    }

    home_dir_old = (CSTRING *)cvector_set(CHFSNP_MGR_NP_HOME_DIR_VEC(chfsnp_mgr), chfsnp_id, (void *)home_dir);
    if(NULL_PTR != home_dir_old)
    {
        cstring_free(home_dir_old);
    }
    return (EC_TRUE);
}
Пример #10
0
TASKS_NODE *crouter_node_find_next_hop_by_tcid(CROUTER_NODE *crouter_node, const UINT32 next_hop_tcid)
{
    UINT32 pos;

    CVECTOR_LOCK(CROUTER_NODE_NEXT_HOPS(crouter_node), LOC_CROUTER_0012);
    for(pos = 0; pos < cvector_size(CROUTER_NODE_NEXT_HOPS(crouter_node)); pos ++)
    {
        TASKS_NODE *tasks_node;

        tasks_node = (TASKS_NODE *)cvector_get_no_lock(CROUTER_NODE_NEXT_HOPS(crouter_node), pos);
        if(NULL_PTR == tasks_node)
        {
            continue;
        }

        if(next_hop_tcid == TASKS_NODE_TCID(tasks_node))
        {
            CVECTOR_UNLOCK(CROUTER_NODE_NEXT_HOPS(crouter_node), LOC_CROUTER_0013);
            return (tasks_node);
        }
    }
    CVECTOR_UNLOCK(CROUTER_NODE_NEXT_HOPS(crouter_node), LOC_CROUTER_0014);
    return (NULL_PTR);
}
Пример #11
0
void crouter_node_print_in_plain(LOG *log, const CROUTER_NODE *crouter_node, UINT32 *index)
{
    UINT32 pos;

    CVECTOR_LOCK(CROUTER_NODE_NEXT_HOPS(crouter_node), LOC_CROUTER_0007);
    for(pos = 0; pos < cvector_size(CROUTER_NODE_NEXT_HOPS(crouter_node)); pos ++)
    {
        TASKS_NODE *tasks_node;

        tasks_node = (TASKS_NODE *)cvector_get_no_lock(CROUTER_NODE_NEXT_HOPS(crouter_node), pos);
        if(NULL_PTR == tasks_node)
        {
            sys_log(log, "Route No. %ld: des tcid %s, next hop [%ld]: (null)\n",
                        (*index) ++, CROUTER_NODE_DES_TCID_STR(crouter_node), pos);
            continue;
        }

        sys_log(log, "Route No. %ld: des tcid %s, next hop [%ld]: ",
                     (*index) ++, CROUTER_NODE_DES_TCID_STR(crouter_node), pos);
        tasks_node_print_in_plain(log, tasks_node);
    }
    CVECTOR_UNLOCK(CROUTER_NODE_NEXT_HOPS(crouter_node), LOC_CROUTER_0008);
    return;
}
Пример #12
0
EC_BOOL taskcfgchk_net_print(LOG *log, const TASK_CFG *task_cfg, const UINT32 tcid, const UINT32 maski, const UINT32 maske)
{
    TASKS_CFG *local_tasks_cfg;
    UINT32 pos;

    local_tasks_cfg = task_cfg_searchs(task_cfg, tcid, maski, maske);
    if(NULL_PTR == local_tasks_cfg)
    {
        sys_log(log, "error:taskcfgchk_net_print: no tasks cfg for tcid %s maski %s, maske %s\n",
                        c_word_to_ipv4(tcid), c_word_to_ipv4(maski), c_word_to_ipv4(maske));
        return (EC_FALSE);
    }

    CVECTOR_LOCK(TASK_CFG_TASKS_CFG_VEC(task_cfg), LOC_TASKCFGCHK_0001);
    for(pos = 0; pos < cvector_size(TASK_CFG_TASKS_CFG_VEC(task_cfg)); pos ++)
    {
        TASKS_CFG *remote_tasks_cfg;

        remote_tasks_cfg = (TASKS_CFG *)cvector_get_no_lock(TASK_CFG_TASKS_CFG_VEC(task_cfg), pos);
        if(NULL_PTR == remote_tasks_cfg)
        {
            continue;
        }

        if(EC_TRUE == tasks_cfg_is_intranet(local_tasks_cfg, remote_tasks_cfg))
        {
            sys_log(log, "[TASKCFGCHK][I]tcid = %s, maski = %s, maske = %s, srvipaddr = %s, srvport = %ld\n",
                            TASKS_CFG_TCID_STR(remote_tasks_cfg),
                            TASKS_CFG_MASKI_STR(remote_tasks_cfg),
                            TASKS_CFG_MASKE_STR(remote_tasks_cfg),
                            TASKS_CFG_SRVIPADDR_STR(remote_tasks_cfg),
                            TASKS_CFG_SRVPORT(remote_tasks_cfg));
        }
        if(EC_TRUE == tasks_cfg_is_externet(local_tasks_cfg, remote_tasks_cfg))
        {
            sys_log(log, "[TASKCFGCHK][E]tcid = %s, maski = %s, maske = %s, srvipaddr = %s, srvport = %ld\n",
                            TASKS_CFG_TCID_STR(remote_tasks_cfg),
                            TASKS_CFG_MASKI_STR(remote_tasks_cfg),
                            TASKS_CFG_MASKE_STR(remote_tasks_cfg),
                            TASKS_CFG_SRVIPADDR_STR(remote_tasks_cfg),
                            TASKS_CFG_SRVPORT(remote_tasks_cfg));
        }
        if(EC_TRUE == tasks_cfg_is_lannet(local_tasks_cfg, remote_tasks_cfg))
        {
            sys_log(log, "[TASKCFGCHK][L]tcid = %s, maski = %s, maske = %s, srvipaddr = %s, srvport = %ld\n",
                            TASKS_CFG_TCID_STR(remote_tasks_cfg),
                            TASKS_CFG_MASKI_STR(remote_tasks_cfg),
                            TASKS_CFG_MASKE_STR(remote_tasks_cfg),
                            TASKS_CFG_SRVIPADDR_STR(remote_tasks_cfg),
                            TASKS_CFG_SRVPORT(remote_tasks_cfg));
        }

        if(EC_TRUE == tasks_cfg_is_dbgnet(local_tasks_cfg, remote_tasks_cfg))
        {
            sys_log(log, "[TASKCFGCHK][D]tcid = %s, maski = %s, maske = %s, srvipaddr = %s, srvport = %ld\n",
                            TASKS_CFG_TCID_STR(remote_tasks_cfg),
                            TASKS_CFG_MASKI_STR(remote_tasks_cfg),
                            TASKS_CFG_MASKE_STR(remote_tasks_cfg),
                            TASKS_CFG_SRVIPADDR_STR(remote_tasks_cfg),
                            TASKS_CFG_SRVPORT(remote_tasks_cfg));
        }

        if(EC_TRUE == tasks_cfg_is_monnet(local_tasks_cfg, remote_tasks_cfg))
        {
            sys_log(log, "[TASKCFGCHK][D]tcid = %s, maski = %s, maske = %s, srvipaddr = %s, srvport = %ld\n",
                            TASKS_CFG_TCID_STR(remote_tasks_cfg),
                            TASKS_CFG_MASKI_STR(remote_tasks_cfg),
                            TASKS_CFG_MASKE_STR(remote_tasks_cfg),
                            TASKS_CFG_SRVIPADDR_STR(remote_tasks_cfg),
                            TASKS_CFG_SRVPORT(remote_tasks_cfg));
        }
    }
    CVECTOR_UNLOCK(TASK_CFG_TASKS_CFG_VEC(task_cfg), LOC_TASKCFGCHK_0002);
    return (EC_TRUE);
}
Пример #13
0
static EC_BOOL taskcfgchk_route_test(LOG *log, const TASK_CFG *task_cfg, TASKS_CFG *src_tasks_cfg, const UINT32 des_tcid, const UINT32 max_hops)
{
    UINT32 pos;

    if(EC_TRUE == taskcfgchk_conn_test(task_cfg, src_tasks_cfg, des_tcid))
    {
        sys_log(log, "[TASKCFGCHK] %s ==> %s [SUCC]\n", TASKS_CFG_TCID_STR(src_tasks_cfg), c_word_to_ipv4(des_tcid));
        return (EC_TRUE);
    }

    if(0 == max_hops)
    {
        sys_log(log, "[TASKCFGCHK] ==> %s [STOP]\n", TASKS_CFG_TCID_STR(src_tasks_cfg));
        return (EC_FALSE);
    }

    CVECTOR_LOCK(TASKS_CFG_TASKR_CFG_VEC(src_tasks_cfg), LOC_TASKCFGCHK_0011);
    for(pos = 0; pos < cvector_size(TASKS_CFG_TASKR_CFG_VEC(src_tasks_cfg)); pos ++)
    {
        TASKR_CFG *taskr_cfg;
        UINT32 taskr_cfg_mask;

        taskr_cfg = (TASKR_CFG *)cvector_get_no_lock(TASKS_CFG_TASKR_CFG_VEC(src_tasks_cfg), pos);
        if(NULL_PTR == taskr_cfg)
        {
            continue;
        }

        taskr_cfg_mask = TASKR_CFG_MASKR(taskr_cfg);

        /*when des_tcid belong to the intranet of taskr_cfg, i.e., belong to the route*/
        if((des_tcid & taskr_cfg_mask) == (TASKR_CFG_DES_TCID(taskr_cfg) & taskr_cfg_mask))
        {
            TASKS_CFG *rt_tasks_cfg;

            dbg_log(SEC_0057_TASKCFGCHK, 5)(LOGSTDNULL, "[TASKCFGCHK] %s & %s == %s & %s\n",
                            c_word_to_ipv4(des_tcid), c_word_to_ipv4(taskr_cfg_mask),
                            TASKR_CFG_DES_TCID_STR(taskr_cfg), c_word_to_ipv4(taskr_cfg_mask)
                            );

            rt_tasks_cfg = task_cfg_searchs(task_cfg, TASKR_CFG_NEXT_TCID(taskr_cfg), CMPI_ANY_MASK, CMPI_ANY_MASK);
            if(NULL_PTR == rt_tasks_cfg)
            {
                continue;
            }

            sys_log(log, "[TASKCFGCHK] %s ==> %s\n", TASKS_CFG_TCID_STR(src_tasks_cfg), TASKR_CFG_NEXT_TCID_STR(taskr_cfg));

            CVECTOR_UNLOCK(TASKS_CFG_TASKR_CFG_VEC(src_tasks_cfg), LOC_TASKCFGCHK_0012);
            if(EC_TRUE == taskcfgchk_route_test(log, task_cfg, rt_tasks_cfg, des_tcid, max_hops - 1))/*recursively*/
            {
                return (EC_TRUE);
            }
            CVECTOR_LOCK(TASKS_CFG_TASKR_CFG_VEC(src_tasks_cfg), LOC_TASKCFGCHK_0013);
        }
        else
        {
            dbg_log(SEC_0057_TASKCFGCHK, 5)(LOGSTDNULL, "[TASKCFGCHK] %s & %s != %s & %s\n",
                            c_word_to_ipv4(des_tcid), c_word_to_ipv4(taskr_cfg_mask),
                            TASKR_CFG_DES_TCID_STR(taskr_cfg), c_word_to_ipv4(taskr_cfg_mask)
                            );
        }
    }
    CVECTOR_UNLOCK(TASKS_CFG_TASKR_CFG_VEC(src_tasks_cfg), LOC_TASKCFGCHK_0014);
    return (EC_FALSE);
}
Пример #14
0
static EC_BOOL __chfsnp_mgr_flush_db(CHFSNP_MGR *chfsnp_mgr, int chfsnp_mgr_fd)
{
    UINT32 chfsnp_mgr_db_size;
    UINT8* chfsnp_mgr_db_buff;
    UINT32 chfsnp_mgr_db_offset;
    UINT32 chfsnp_home_dir_num;
    UINT32 chfsnp_home_dir_pos;

    /*init offset*/
    chfsnp_mgr_db_offset = 0;

    /*CHFSNP_MGR_NP_MODEL*/
    chfsnp_mgr_db_size   = sizeof(uint8_t);
    chfsnp_mgr_db_buff   = (UINT8 *)&(CHFSNP_MGR_NP_MODEL(chfsnp_mgr));    
    if(EC_FALSE == c_file_flush(chfsnp_mgr_fd, &chfsnp_mgr_db_offset, chfsnp_mgr_db_size, chfsnp_mgr_db_buff))
    {
        sys_log(LOGSTDOUT, "error:__chfsnp_mgr_flush_db: flush np model failed");
        return (EC_FALSE);
    }

    /*CHFSNP_MGR_NP_1ST_CHASH_ALGO_ID*/
    chfsnp_mgr_db_size   = sizeof(uint8_t);
    chfsnp_mgr_db_buff   = (UINT8 *)&(CHFSNP_MGR_NP_1ST_CHASH_ALGO_ID(chfsnp_mgr));    
    if(EC_FALSE == c_file_flush(chfsnp_mgr_fd, &chfsnp_mgr_db_offset, chfsnp_mgr_db_size, chfsnp_mgr_db_buff))
    {
        sys_log(LOGSTDOUT, "error:__chfsnp_mgr_flush_db: flush 1st chash algo id failed");
        return (EC_FALSE);
    }    

    /*CHFSNP_MGR_NP_2ND_CHASH_ALGO_ID*/
    chfsnp_mgr_db_size   = sizeof(uint8_t);
    chfsnp_mgr_db_buff   = (UINT8 *)&(CHFSNP_MGR_NP_2ND_CHASH_ALGO_ID(chfsnp_mgr));    
    if(EC_FALSE == c_file_flush(chfsnp_mgr_fd, &chfsnp_mgr_db_offset, chfsnp_mgr_db_size, chfsnp_mgr_db_buff))
    {
        sys_log(LOGSTDOUT, "error:__chfsnp_mgr_flush_db: flush 2nd chash algo id failed");
        return (EC_FALSE);
    }     

    /*CHFSNP_MGR_NP_ITEM_MAX_NUM*/
    chfsnp_mgr_db_size   = sizeof(uint32_t);
    chfsnp_mgr_db_buff   = (UINT8 *)&(CHFSNP_MGR_NP_ITEM_MAX_NUM(chfsnp_mgr));    
    if(EC_FALSE == c_file_flush(chfsnp_mgr_fd, &chfsnp_mgr_db_offset, chfsnp_mgr_db_size, chfsnp_mgr_db_buff))
    {
        sys_log(LOGSTDOUT, "error:__chfsnp_mgr_flush_db: flush item max num failed");
        return (EC_FALSE);
    }     

    /*CHFSNP_MGR_NP_MAX_NUM*/
    chfsnp_mgr_db_size   = sizeof(uint32_t);
    chfsnp_mgr_db_buff   = (UINT8 *)&(CHFSNP_MGR_NP_MAX_NUM(chfsnp_mgr));    
    if(EC_FALSE == c_file_flush(chfsnp_mgr_fd, &chfsnp_mgr_db_offset, chfsnp_mgr_db_size, chfsnp_mgr_db_buff))
    {
        sys_log(LOGSTDOUT, "error:__chfsnp_mgr_flush_db: flush disk max num failed");
        return (EC_FALSE);
    }

    /*CHFSNP_MGR_NP_HOME_DIR_VEC*/
    chfsnp_home_dir_num  = cvector_size(CHFSNP_MGR_NP_HOME_DIR_VEC(chfsnp_mgr));
    chfsnp_mgr_db_size   = sizeof(UINT32);
    chfsnp_mgr_db_buff   = (UINT8 *)&(chfsnp_home_dir_num);    
    if(EC_FALSE == c_file_flush(chfsnp_mgr_fd, &chfsnp_mgr_db_offset, chfsnp_mgr_db_size, chfsnp_mgr_db_buff))
    {
        sys_log(LOGSTDOUT, "error:__chfsnp_mgr_flush_db: flush home dir vec size failed");
        return (EC_FALSE);
    }    

    sys_log(LOGSTDOUT, "[DEBUG] __chfsnp_mgr_flush_db: np max num = %u\n", CHFSNP_MGR_NP_MAX_NUM(chfsnp_mgr));
    sys_log(LOGSTDOUT, "[DEBUG] __chfsnp_mgr_flush_db: np home dir vec size = %u\n", cvector_size(CHFSNP_MGR_NP_HOME_DIR_VEC(chfsnp_mgr)));

    for(chfsnp_home_dir_pos = 0; chfsnp_home_dir_pos < chfsnp_home_dir_num; chfsnp_home_dir_pos ++)
    {
        CSTRING *chfsnp_home_dir_cstr;

        chfsnp_home_dir_cstr = cvector_get_no_lock(CHFSNP_MGR_NP_HOME_DIR_VEC(chfsnp_mgr), chfsnp_home_dir_pos);
        if(EC_FALSE == cstring_flush(chfsnp_mgr_fd, &chfsnp_mgr_db_offset, chfsnp_home_dir_cstr))
        {
            sys_log(LOGSTDOUT, "error:__chfsnp_mgr_flush_db: flush home dir %u # failed\n", chfsnp_home_dir_pos);
            return (EC_FALSE);
        }
    }

    return (EC_TRUE);
}
Пример #15
0
CROUTER_NODE *crouter_node_vec_get_no_lock(CROUTER_NODE_VEC *crouter_node_vec, const UINT32 pos)
{
    return (CROUTER_NODE *)cvector_get_no_lock(CROUTER_NODE_VEC_NODES(crouter_node_vec), pos);
}