我使用netfilter hooks
编写了一个应用程序。
似乎skb_transport_header
函数计算不正确(有时但并非总是):
struct tcphdr* tcp_header = NULL;
tcp_header = (struct tcphdr*)skb_transport_header(skb); // somtimes incorrect address.
tcp_header = (struct tcphdr*)((char*)ip_header + (ip_header->ihl * 4));// always correct address.
我哪里错了?
最佳答案
您可以在这里查看: http://www.roman10.net/how-to-filter-network-packets-using-netfilterpart-2-implement-the-hook-function/ 问题是netfilter在网络层实现,当数据包从物理层向上时,您在数据包到达tcp层之前捕获数据包,某些功能无法处理。
关于c++ - 为什么skb_transport_header计算不正确?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10162556/