我正在使用来自标头(TCP / IP)[linux tcp.h
和ip.h
]的属性通过LKM / netfilter在内核级别过滤数据包。
下面是代码示例:
static unsigned int Filter(void *priv,struct sk_buff *skb,const struct nf_hook_state *state) {
struct ethhdr *ethh;
struct iphdr *iph; // ip header struct
struct tcphdr *tcph; // tcp header struct
ethh = eth_hdr(skb);
iph = ip_hdr(skb);
if (!(iph)){
return NF_accEPT;
}
if (iph->protocol == IPPROTO_TCP){ // TCP Protocol
tcph = tcp_hdr(skb);
if (iph->tot_len > htons(64)) return NF_accEPT;
if ((iph->ttl > htons(254))
|| (iph->ttl == htons(64) && tcph->window > htons(1024))
|| (iph->ttl <= htons(65) && tcph->window <= htons(1024) && ((iph->frag_off & IP_DF)==0)))
return NF_DROP;
return NF_accEPT;
}
return NF_accEPT;
}
但是现在我必须包括一个基于 MSS值的条件,该条件是通过Wireshark分析并根据Wireshark Reference提出的:
- 字段名称:tcp.options.mss_val
- 说明:MSS值
- 类型:无符号整数,2个字节
我在此处通过Stack Overflow和Google进行了搜索,但没有找到如何从套接字缓冲区(skb)中检索此tcp.options.mss_val
的信息。
请问,关于如何找回它的任何想法?