【问题标题】:Correct filter expression in libpcap for outgoing packets更正 libpcap 中用于传出数据包的过滤器表达式
【发布时间】:2015-02-05 19:13:42
【问题描述】:

我只想从我的系统中嗅探传出的“TCP-ACK”数据包。因此,我在lib-pcap 程序中将过滤器表达式设置为:

char filter_exp[] = "src host 172.16.0.1 and tcp[tcpflags] & (tcp-syn | tcp-fin | tcp-rst | tcp-psh) == 0";

但它在运行时显示 lib-pcap 语法错误为:

无法解析过滤器 src 主机 172.16.0.1 和 tcp[tcpflags] 和 (tcp-syn | tcp-fin | tcp-rst | tcp-psh) == 0:语法错误

谁能说出这里出了什么问题以及正确的过滤器表达式是什么?

我从here 获得了语法(在示例部分)。

【问题讨论】:

    标签: c libpcap bpf


    【解决方案1】:

    语法不正确,因为tcp-psh 不是有效语法。正确的是tcp-push。所以正确的过滤器表达式是:

    char filter_exp[] = "src host 172.16.0.1 and tcp[tcpflags] & (tcp-syn | tcp-fin | tcp-rst | tcp-push) == 0";
    

    【讨论】:

      猜你喜欢
      • 2014-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-15
      • 1970-01-01
      • 1970-01-01
      • 2016-11-28
      相关资源
      最近更新 更多