我跑一個程序(該鏈接 - http://www.security-freak.net/raw-sockets/sniffer_eth_ip_tcp.c)在我的Fedora Core 5,在編譯時,我得到了以下錯誤:如何解決類似「結構iphdr」錯誤沒有名爲成員「DADDR」
[[email protected] ~]# 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包含上述數據成員。 任何人都可以請幫忙..
這些是第一個發生的錯誤,還是在他們面前有其他錯誤?你能發佈編譯器的_entire_輸出嗎?另外,請查看/usr/include/linux/ip.h中的'struct iphdr'的定義以查看這些成員是否實際定義。 – 2010-01-09 20:23:12
什麼是您正在編譯的實際文件。編譯器輸出說文件名是「tcp.c」,而不是「sniffer_eth_ip_tcp.c」。此外,「sniffer_eth_ip_tcp.c」(在該鏈接中提供)只有268行。 – 2010-01-09 20:27:34
我現在也發佈了警告。我應該怎麼做糾正..(tcp.c也有相同的代碼) – trinity 2010-01-10 08:06:38