LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 833|回复: 0

请解释一下这个赋值语句?多谢!

[复制链接]
发表于 2004-4-12 17:57:19 | 显示全部楼层 |阅读模式
请解释一下这个赋值语句?多谢!
static int check_tcp_packet(struct sk_buff *skb)
{
struct tcphdr *thead;
......
//----------------------------------------------------------
thead = (struct tcphdr *)(skb->data +
(skb->nh.iph->ihl * 4));
//---------------------------------------------------------
/* Now check the destination port */
if ((thead->dest) == *(unsigned short *)deny_port)
{
return NF_DROP;
}

return NF_ACCEPT;
}


skb->data +(skb->nh.iph->ihl * 4)
是什么意思啊?

不明白的地方是:
1。为什么要加上skb->data这个偏移量?
2。下面的结构前几句的#define语句看不懂(我知道大小ENDIAN的区别,但觉得ihl:4这种写法实在晦涩难懂,它的作用?)
struct iphdr {
#if defined(__LITTLE_ENDIAN_BITFIELD)
__u8 ihl:4,
version:4;
#elif defined (__BIG_ENDIAN_BITFIELD)
__u8 version:4,
ihl:4;
#else
#error "lease 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. */
};
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表