如何解决“struct iphdr”等错误没有名为“daddr”的成员
我运行了一个程序(链接是 - 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
出现该错误的唯一方法是您的程序引用的 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]