如何解决“struct iphdr”等错误没有名为“daddr”的成员

发布于 2024-08-17 20:03:04 字数 1134 浏览 9 评论 0原文

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

[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 包含上述数据成员。 谁能帮忙..

I ran a program ( the link is - http://www.security-freak.net/raw-sockets/sniffer_eth_ip_tcp.c ) in my fedora core 5. On compilation , i get the following errors :

[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’

But , the struct iphdr in the corresponding header file contains the above mentioned data members.
can anyone please help..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

徒留西风 2024-08-24 20:03:04

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

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

The only way to get that error is if the iphdr your program is referring to does not include those data members. So, search through all your includes, check for dup's, etc. (also, you can run the source through a precompile and find out EVERYTHING that has been included, that usually provides your answer)

[edit]
run cpp on your source to find out which header files are included (in which order). If you have a header with the wrong information included before the correct information, you will have a problem. In essence, only include the header files necessary to compile the program
[/edit]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文