2016-05-15 102 views
0

我正在尝试使用libnetfilter_conntrack来监视网络活动。解析nf_conntrack结构

所有我能找到的是this的例子。

我想能够从nf_conntrack结构中提取数据,并且我可以找到的唯一方法是使用nfct_snprintf然后解析缓冲区。

我希望将数据存储在这样的结构:

struct connection_details { 
    std::string src_ip; 
    int src_port; 
    std::string dst_ip; 
    int dst_port; 
    std::string type; 
    std::string state; 
}; 

是否有这样做的任何其他方式?

回答

0

回答此问题的其他人最终在这里,因为库实现的抽象,你不能直接解析struct nf_conntrack对象。

然而,您可以从库源代码libnetfilter_conntrack/include/internal/object.h中包含头文件直接访问nf_conntrack对象,但要小心,虽然存在抽象的原因。