suricata 3.1 源码分析7

    DetectEngineCtx *de_ctx = NULL;
    if (!suri.disabled_detect) {     //detect设为启用
        SCClassConfInit();

解析Class相关正则

        SCReferenceConfInit();

解析Refference相关正则

        SetupDelayedDetect(&suri);

设置是否延迟检测。若delayed-detect为yes,则系统将在载入规则集之前就开始处理数据包,这样能够在IPS模式下减少系统的down time(宕机时间)。

        int mt_enabled = 0;
        (void)ConfGetBool("multi-detect.enabled", &mt_enabled);
        int default_tenant = 0;
        if (mt_enabled)
            (void)ConfGetBool("multi-detect.default", &default_tenant);
        if (DetectEngineMultiTenantSetup() == -1) {
            SCLogError(SC_ERR_INITIALIZATION, "initializing multi-detect "
                    "detection engine contexts failed.");
            exit(EXIT_FAILURE);
        }

这块的功能不是很清楚,留着以后再看。

        if ((suri.delayed_detect || (mt_enabled && !default_tenant)) &&
                (suri.run_mode != RUNMODE_CONF_TEST)) {
            de_ctx = DetectEngineCtxInitMinimal();
        } else {
            de_ctx = DetectEngineCtxInit();

初始化Decect engine。若配置文件中未指定mpm(多模式匹配器),则默认使用AC,即使用 mpm_table中AC那一项。SRepInit函数(与前面的SCReputationInitCtx不同!)会初始化检测引擎中域 reputaion相关信息,即从配置文件中指定的文件中读取声望数据。其余配置比较复杂,暂不关注。

        }
        if (de_ctx == NULL) {
            SCLogError(SC_ERR_INITIALIZATION, "initializing detection engine "
                    "context failed.");
            exit(EXIT_FAILURE);
        }

        if (!de_ctx->minimal) {
            if (LoadSignatures(de_ctx, &suri) != TM_ECODE_OK)
                exit(EXIT_FAILURE);

个人认为这是加载信号的相关处理,不能确定。

            if (suri.run_mode == RUNMODE_ENGINE_ANALYSIS) {
                exit(EXIT_SUCCESS);
            }
        }

        DetectEngineAddToMaster(de_ctx);

字面理解是将detectEngine加到Master中,这里的master不清楚是什么。

    } else {
        /* tell the app layer to consider only the log id */
        RegisterAppLayerGetActiveTxIdFunc(AppLayerTransactionGetActiveLogOnly);
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

高晓伟_Steven

相逢即是有缘,动力源于金钱。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值