c - 如何解决 ‘struct iphdr’ 没有名为 ‘daddr’ 的成员之类的错误

标签 c linux fedora packet-capture packet-sniffers

我在我的 Fedora Core 5 中运行了一个程序(链接为 - http://www.security-freak.net/raw-sockets/sniffer_eth_ip_tcp.c )。在编译时,我收到以下错误:

[root@localhost ~]# gcc sniffer_eth_ip_tcp.c
    In file included from sniffer_eth_ip_tcp.c:12: /usr/include/linux/ip.h:97: error: expected specifier-qualifier-list before ‘uint8_t’
    In file included from /usr/include/linux/tcp.h:21,
                 from sniffer_eth_ip_tcp.c:13:
    /usr/include/asm/byteorder.h:6:2: warning: #warning using private kernel header; include   <endian.h> instead!
    sniffer_eth_ip_tcp.c: In function ‘ParseIpHeader’:
    sniffer_eth_ip_tcp.c:147: error: ‘struct iphdr’ has no member named ‘daddr’
    sniffer_eth_ip_tcp.c:148: error: ‘struct iphdr’ has no member named ‘saddr’
    sniffer_eth_ip_tcp.c: In function ‘ParseTcpHeader’:
    sniffer_eth_ip_tcp.c:185: error: ‘struct iphdr’ has no member named ‘protocol’
    sniffer_eth_ip_tcp.c:187: error: ‘struct iphdr’ has no member named ‘ihl’

但是,相应头文件中的struct iphdr包含了上述数据成员。 谁能帮忙..

最佳答案

出现该错误的唯一方法是您的程序引用的 iphdr 不包含这些数据成员。因此,搜索所有包含的内容,检查重复的内容等(此外,您可以通过预编译运行源代码并找出包含的所有内容,这通常会提供您的答案)

[编辑]
在源代码上运行 cpp 以找出包含哪些头文件(按顺序)。如果 header 在正确信息之前包含错误信息,则会出现问题。本质上,只包含编译程序所需的头文件
[/编辑]

关于c - 如何解决 ‘struct iphdr’ 没有名为 ‘daddr’ 的成员之类的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2034678/

相关文章:

c++ - 为什么这个结果是62呢?

regex - 查找目录中具有特定单词的 xml 文件的数量

linux - htpasswd : wrong credentials created

linux - 如何从 tcl 脚本记录 xterm 窗口

linux - glibc make 在 chroot 环境中失败

python - 在使用 imread 函数读取 jpg 文件时,是否有任何可能的原因在 opencv 中遇到一些困难?

python - 在 Linux (Fedora 15 Beta) 上使用 OpenCV 2.2 和 Python 捕获图像

c - 为什么 C 标准未定义不确定变量的使用?

c - system() 和 execve() 有什么区别

C程序行为怪异