【发布时间】:2010-01-09 19:43:57
【问题描述】:
我在我的 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包含了上面提到的数据成员。 谁能帮忙..
【问题讨论】:
-
这些是第一个发生的错误,还是在它们之前还有其他错误?你能发布编译器的整个输出吗?另外,查看/usr/include/linux/ip.h 中
struct iphdr的定义,看看是否确实定义了这些成员。 -
您正在编译的实际文件是什么。编译器输出显示文件名是“tcp.c”,而不是“sniffer_eth_ip_tcp.c”。此外,“sniffer_eth_ip_tcp.c”(在该链接中提供)只有 268 行。
-
我现在也发布了警告。我应该怎么做才能纠正..(tcp.c 也有相同的代码)
标签: c linux fedora packet-capture packet-sniffers