问题描述
我想在结构中获得fragment offset
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;
__u16 tot_len;
__u16 id;
__u16 frag_off;
__u8 ttl;
__u8 protocol;
__u16 check;
__u32 saddr;
__u32 daddr;
/*The options start here. */
};
根据this answer,我构建了该代码:
struct iphdr* iph;
printf ("offset = %d \n ",iph->frag_off &IP_OFFSET); # print 370
printf ("more fragment= %d \n ",iph->frag_off &IP_MF ); # print 8192
printf ("do not fragment = %d \n ",iph->frag_off &IP_DF ); # print 0
我已经用libpcap捕获了这个数据包,并用wireshark
观看了
iph->frag_off
等于0x2172
。
偏移量应等于2960(例如wireshark),但在我的计算中等于370
更多片段需要为1(例如wireshark),但在我的计算中等于8192 为什么呢?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)