tcpdump的源码分析

时间:2023-12-05 19:54:26

在源文件 tcpdump.c 中:

结构体数组“static struct printer printers[]”定义了tcpdump所跟参数及其对一个的处理函数。

struct printer {
        if_printer f;                  // 处理函数
    int type;                      // 类型
};

然后通过函数“lookup_printer”中传入的参数 type 来遍历结构体数组printers,并且返回处理函数。若查找不到,返回NULL.