【发布时间】:2016-05-25 02:45:15
【问题描述】:
我正在使用 pcap C 库来读取数据包。目前,我使用以下方法来检查struct tcphdr(此结构在netinet/tcp.h库中定义)中是否设置了标志:
struct tcphdr *tcp = ....
if(tcp->th_flags & TH_SYN) {
//SYN FLAG IS SET?
}
这是否总是适用于检查结构中是否设置了特定标志?或者,还有更好的方法?非常感谢任何建议/提示:)
【问题讨论】:
-
对于那些对
tcphdr定义中的u_int16_t syn:1;表示法感到困惑的人,请参阅here
标签: c networking tcp libpcap packet-capture