Skip to content

Instantly share code, notes, and snippets.

@Akagi201
Created April 30, 2014 05:30
Show Gist options
  • Save Akagi201/3727eb0abab45737d599 to your computer and use it in GitHub Desktop.
Save Akagi201/3727eb0abab45737d599 to your computer and use it in GitHub Desktop.
layout title description category
post
Libnids抓不到包
解决Libnids编译通过但不能抓包的问题
编程

用libnids提供的example编译通过,竟然捕不到包。很是郁闷 找了很多资料,终于发现了这么一个办法。 nids.h 中有这么一段

    struct nids_chksum_ctl{
	u_int netaddr;
	u_int mask;
	u_int action;
	u_int reserved;
    }
    extern void nids_register_chksum_ctl(struct nids_chksum_ctl *, int);

这段是和计算校验和相关,比较新的网卡会自动计算校验和,所以我们只要将关了就行。在main()最开始加上如下代码

    strcut nids_chksum_ctl temp;
    temp.netaddr = 0;
    temp.mask = 0;
    temp.action = 1;
    nids_register_chksum_ctl(&temp,1);

大功告成,我终于能捕获数据包了,555555

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment