zoukankan      html  css  js  c++  java
  • libpcap 中的 struct block

    在pcap_compile 函数中

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

    ...中间没有对root 操作,

    if (root == NULL)
            root = gen_retblk(snaplen_arg);

    有必要判断吗? 有必要的

    root 是应全局变量 事实上

      在结束解析函数 finish_parse 有对全局变量的赋值, 这个赋值也是对整个解析结果的保存。 而root block也就是 cfg(control flow graph的根 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;        /* cfg 图中的一个标识 */
        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虚拟机的重要级函数

  • 相关阅读:
    VB Treeview控件 介绍与使用
    基于V4L2的视频驱动开发
    Jlinkv8 灯不亮重新烧写固件的办法
    使用JLink间接烧写S3C2410、S3C2440开发板Nor、Nand Flash的方法
    linux 开机自动执行脚本或者一些指定的程序
    FrameBuffer编程二(简单程序下)
    c语言内存分配函数
    FrameBuffer编程二(简单的程序上)
    FrameBuffer编程一(数据结构)
    mmap函数介绍
  • 原文地址:https://www.cnblogs.com/kwingmei/p/3627413.html
Copyright © 2011-2022 走看看