Suricata之源代码(一)

        第一次系统性的写blog,写的不好,请大家多多包涵。

        在介绍Suricata源代码之前,大致介绍一下Suricata的工作流程。在suricata中主要使用了回调函数将所有的模块连接起来的。最后是通过DetectEngineCtx *global_de_ctx这个结构体启动起来的。整个的启动过程我用鞭炮来进行比喻,回调函数就好像鞭炮的引线一样,将所有的小的鞭炮连接起来,连接起来之后如果要放鞭炮就的要使用火柴将引线点燃。所以我将global_de_ctx比喻为火柴。在suricata中也是这样,最后通过global_de_ctx将suricata运行起来的。就好比是global_de_ctx打通了suricata的任督二脉。

DetectEngineCtx结构体在detect.h中。

typedef structDetectEngineCtx_ {

    uint8_t flags;

    int failure_fatal;

 

    Signature *sig_list;

    uint32_t sig_cnt;

 

    /* version of the srep data */

    uint32_t srep_version;

 

    Signature **sig_array;

    uint32_t sig_array_size; /* size in bytes*/

    uint32_t sig_array_len;  /* size in array members */

 

    uint32_t signum;

 

    /* used by the signature ordering module */

    struct SCSigOrderFunc_ *sc_sig_order_funcs;

    struct SCSigSignatureWrapper_*sc_sig_sig_wrapper;

 

    /*hash table used for holding the classification config info */

    HashTable *class_conf_ht;

    /* hash table used for holding thereference config info */

    HashTable *reference_conf_ht;

 

    /* main sigs */

    DetectEngineLookupFlowflow_gh[FLOW_STATES];

 

    uint32_t mpm_unique, mpm_reuse, mpm_none,

        mpm_uri_unique, mpm_uri_reuse,mpm_uri_none;

    uint32_t gh_unique, gh_reuse;

 

    uint32_t mpm_max_patcnt, mpm_min_patcnt,mpm_tot_patcnt,

        mpm_uri_max_patcnt, mpm_uri_min_patcnt,mpm_uri_tot_patcnt;

 

    /* init phase vars */

    HashListTable *sgh_hash_table;

 

    …….

}DetectEngineCtx;

下面还有很长没有贴出来,这个结构体非常的大。想想它确实是应该这么大的。毕竟它就是suricata的心脏嘛!

Suricata是c语言开发的,而c语言的起始点是从main()函数开始的,为了好找到入口点,所以在写代码的时候就规定了从main函数开始。而suricata的入口main函数是在suricata.c文件中。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值