在执行ip_fast_csum前忘记把ip头的check设置为0,导致接收数据包的程序无法收到数据包
/* set up IP header */
/* remember that ethernet packets have a minimum size */
pNewSkb->nh.iph = new_iph = ( struct iphdr * ) skb_put ( pNewSkb, len );
* new_iph = * iph;
new_iph->saddr = htonl ( tSrcMediaAddr.addr );
new_iph->daddr = htonl ( tDstMediaAddr.addr );
new_iph->ttl = 255;
new_iph->tot_len = htons ( len );
new_iph->check = 0; /* must */
new_iph->check = ip_fast_csum ( ( char * ) new_iph, new_iph->ihl );
因为不小心把new_iph->check = 0;漏掉了,所以在后面计算IP校验和的时候得出错误的值,
从抓包工具ethereal抓得的数据包分析得到,IP校验和错误,后把new_iph->check = 0;添加到代码中,则正常。
/* remember that ethernet packets have a minimum size */
pNewSkb->nh.iph = new_iph = ( struct iphdr * ) skb_put ( pNewSkb, len );
* new_iph = * iph;
new_iph->saddr = htonl ( tSrcMediaAddr.addr );
new_iph->daddr = htonl ( tDstMediaAddr.addr );
new_iph->ttl = 255;
new_iph->tot_len = htons ( len );
new_iph->check = 0; /* must */
new_iph->check = ip_fast_csum ( ( char * ) new_iph, new_iph->ihl );
因为不小心把new_iph->check = 0;漏掉了,所以在后面计算IP校验和的时候得出错误的值,
从抓包工具ethereal抓得的数据包分析得到,IP校验和错误,后把new_iph->check = 0;添加到代码中,则正常。