首页 > 其他 > 详细

libpcap 中的 struct block

时间:2014-03-27 05:50:34      阅读:484      评论:0      收藏:0      [点我收藏+]

在pcap_compile 函数中

root = NULL; // root就是 struct block的指针

...中间没有对root 操作,有必要判断吗? 有必要的

中间的

***** (void)pcap_parse(); *******

if (root == NULL) /* 全局的block 结构 */
        root = gen_retblk(snaplen);

 

program->bf_insns = icode_to_fcode(root, &len); // root 作为参数的调用

---------------------------------------------------------

下面来认识一下这个结构

struct block {
    int id;
    struct slist *stmts;    /* side effect stmts */
    struct stmt s;        /* branch stmt 分支语句 */
    int mark;
    int longjt;        /* jt branch requires long jump */
    int longjf;        /* jf branch requires long jump */
    int level;
    int offset;
    int sense;
    struct edge et; // edge true
    struct edge ef; // edge false
    struct block *head; // 指向head部 , 如果没有其他block 则指向自身
    struct block *link;    /* link field used by optimizer */
    uset dom;  // uset的定义 typedef bpf_u_int32 *uset;
    uset closure;
    struct edge *in_edges;
    atomset def, kill;  // typedef bpf_u_int32 *uset; 定义
    atomset in_use;
    atomset out_use;
    int oval;
    int val[N_ATOMS]; // #define N_ATOMS (BPF_MEMWORDS+2) = 18
};

-------------------------------------------------------------------------------------

optimize.c:icode_to_fcode(root, lenp)   pcap虚拟机的重要级函数

libpcap 中的 struct block,布布扣,bubuko.com

libpcap 中的 struct block

原文:http://www.cnblogs.com/kwingmei/p/3627413.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!