Beispiel #1
0
/**
 * init module function
 */
static int mod_init(void)
{
	int fl;
	if (_dbg_cfgtrace_facility_str!=NULL)
	{
		fl = str2facility(_dbg_cfgtrace_facility_str);
		if (fl != -1)
		{
			_dbg_cfgtrace_facility = fl;
		} else {
			LM_ERR("invalid log facility configured");
			return -1;
		}
	}

	if(dbg_init_rpc()!=0)
	{
		LM_ERR("failed to register RPC commands\n");
		return -1;
	}

	if(cfg_declare("dbg", dbg_cfg_def, &default_dbg_cfg, cfg_sizeof(dbg), &dbg_cfg))
	{
		LM_ERR("Fail to declare the configuration\n");
		return -1;
	}
	LM_DBG("cfg level_mode:%d hash_size:%d\n",
		cfg_get(dbg, dbg_cfg, mod_level_mode),
		cfg_get(dbg, dbg_cfg, mod_hash_size));

	if(dbg_init_mod_levels(cfg_get(dbg, dbg_cfg, mod_hash_size))<0)
	{
		LM_ERR("failed to init per module log level\n");
		return -1;
	}

	if(_dbg_log_assign>0)
	{
		if(dbg_init_pvcache()!=0)
		{
			LM_ERR("failed to create pvcache\n");
			return -1;
		}
	}
	if(_dbg_reset_msgid==1)
	{
		unsigned int ALL = REQUEST_CB+FAILURE_CB+ONREPLY_CB
		  +BRANCH_CB+ONSEND_CB+ERROR_CB+LOCAL_CB+EVENT_CB+BRANCH_FAILURE_CB;
		if (register_script_cb(dbg_msgid_filter, PRE_SCRIPT_CB|ALL, 0) != 0) {
			LM_ERR("could not insert callback");
			return -1;
		}
	}
	return dbg_init_bp_list();
}
Beispiel #2
0
/**
 * init module function
 */
static int mod_init(void)
{
	int fl;
	if (_dbg_cfgtrace_facility_str!=NULL)
	{
		fl = str2facility(_dbg_cfgtrace_facility_str);
		if (fl != -1)
		{
			_dbg_cfgtrace_facility = fl;
		} else {
			LM_ERR("invalid log facility configured");
			return -1;
		}
	}

	if(dbg_init_rpc()!=0)
	{
		LM_ERR("failed to register RPC commands\n");
		return -1;
	}

	return dbg_init_bp_list();
}
Beispiel #3
0
/**
 * init module function
 */
static int mod_init(void)
{
    int fl;
    bind_cfgt_t bind_cfgt;

    if (register_mi_mod(exports.name, mi_cmds) != 0)
    {
        LM_ERR("failed to register MI commands\n");
        return -1;
    }

    if (_dbg_cfgtrace_facility_str!=NULL)
    {
        fl = str2facility(_dbg_cfgtrace_facility_str);
        if (fl != -1)
        {
            _dbg_cfgtrace_facility = fl;
        } else {
            LM_ERR("invalid log facility configured");
            return -1;
        }
    }

    if(dbg_init_rpc()!=0)
    {
        LM_ERR("failed to register RPC commands\n");
        return -1;
    }

    if(cfg_declare("dbg", dbg_cfg_def, &default_dbg_cfg, cfg_sizeof(dbg), &dbg_cfg))
    {
        LM_ERR("Fail to declare the configuration\n");
        return -1;
    }

    /* anyhow, should fail before */
    if (!dbg_cfg) {
        return -1;
    }

    LM_DBG("cfg level_mode:%d facility_mode:%d hash_size:%d\n",
           cfg_get(dbg, dbg_cfg, mod_level_mode),
           cfg_get(dbg, dbg_cfg, mod_facility_mode),
           cfg_get(dbg, dbg_cfg, mod_hash_size));

    if(dbg_init_mod_levels(cfg_get(dbg, dbg_cfg, mod_hash_size))<0)
    {
        LM_ERR("failed to init per module log level\n");
        return -1;
    }

    if(_dbg_log_assign>0)
    {
        if(dbg_init_pvcache()!=0)
        {
            LM_ERR("failed to create pvcache\n");
            return -1;
        }
    }
    if(_dbg_reset_msgid==1)
    {
        unsigned int ALL = REQUEST_CB+FAILURE_CB+ONREPLY_CB
                           +BRANCH_CB+ONSEND_CB+ERROR_CB+LOCAL_CB+EVENT_CB+BRANCH_FAILURE_CB;
        if (register_script_cb(dbg_msgid_filter, PRE_SCRIPT_CB|ALL, 0) != 0) {
            LM_ERR("could not insert callback");
            return -1;
        }
    }
    if(_dbg_cfgtest==1)
    {
        bind_cfgt = (bind_cfgt_t)find_export("cfgt_bind_cfgt", 1, 0);
        if (!bind_cfgt) {
            LM_ERR("can't find cfgt module\n");
            return -1;
        }

        if (bind_cfgt(&_dbg_cfgt) < 0) {
            return -1;
        }
        LM_INFO("bind to cfgt module\n");
    }
    return dbg_init_bp_list();
}