1
我得到這個錯誤:'struct iphdr'沒有成員名爲'ip_ttl' 同樣爲其他成員但不是協議feild 它是什麼解決方案?發生? PS:我看到這個在各種論壇,但無法得到它爲什麼能夠訪問ipHeader->的協議,而不是別人無法讀取TCP/IP頭
我得到這個錯誤:'struct iphdr'沒有成員名爲'ip_ttl' 同樣爲其他成員但不是協議feild 它是什麼解決方案?發生? PS:我看到這個在各種論壇,但無法得到它爲什麼能夠訪問ipHeader->的協議,而不是別人無法讀取TCP/IP頭
假設你正在使用Linux,儘量考慮看看/usr/include/linux/ip.h
。這頭文件定義結構:
struct iphdr {
#if defined(__LITTLE_ENDIAN_BITFIELD)
__u8 ihl:4,
version:4;
#elif defined (__BIG_ENDIAN_BITFIELD)
__u8 version:4,
ihl:4;
#else
#error "Please fix <asm/byteorder.h>"
#endif
__u8 tos;
__be16 tot_len;
__be16 id;
__be16 frag_off;
__u8 ttl;
__u8 protocol;
__sum16 check;
__be32 saddr;
__be32 daddr;
/*The options start here. */
};
正如你可以看到,該字段的名稱是ttl
,不ip_ttl
。
'ip_ttl'來自'/ usr/include/netinet/ip.h'中的BSD兼容IP頭聲明。 – 2011-03-28 04:04:48
你能發表一些代碼嗎?此外,是不是字段只是「ttl」而不是「ip_ttl」? – 2011-03-24 21:22:04