毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> linux >> 正文

应给如何取得sk_buff的tcp的信息呢

更新时间:2012-11-12:  来源:毕业论文

下面的几个方法都试了,就是不好用。

 struct tcphdr  *tchp;
 1、 tchp = (struct tcphdr *)skb_transport_header(pack);
 2、 tchp = (struct tcphdr *)tcp_hdr(pack);
 3、 tchp = (struct tcphdr *)pack->data+20;

哪位给你取得tcp信息的例子,感激不尽!

iph = ip_hdr(pack);应该是iph = ip_hdr(*pack);
程序中其余地方请检查 pack是sk_buff ** 所以*pack才是sk_buff指针

另外 你的输入sk_buff看起来像是完整的raw packet 所以 即使正确使用了*pack 你的第3种也不对
3、 tchp = (struct tcphdr *)pack->data+20;

应该是 (*pack)->data + 34

另外的14是以太网头 毕业论文 

/* reference to tcp.c */struct sk_buff *tcp_tso_segment(struct sk_buff *skb, int features) {     struct sk_buff *segs = ERR_PTR(-EINVAL);     struct tcphdr *th;     unsigned thlen;     unsigned int seq;     unsigned int delta;     unsigned int oldlen;     unsigned int len;       if (!pskb_may_pull(skb, sizeof(*th)))         goto out;       th = skb->h.th;     thlen = th->doff * 4;     if (thlen < sizeof(*th))         goto out;       if (!pskb_may_pull(skb, thlen))         goto out;       oldlen = (u16)~skb->len;     __skb_pull(skb, thlen);       if (skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST)) {         /* Packet is from an untrusted source, reset gso_segs. */        int type = skb_shinfo(skb)->gso_type;         int mss;           if (unlikely(type &                  ~(SKB_GSO_TCPV4 |                    SKB_GSO_DODGY |                    SKB_GSO_TCP_ECN |                    SKB_GSO_TCPV6 |                    0) ||                  !(type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))))             goto out;           mss = skb_shinfo(skb)->gso_size;         skb_shinfo(skb)->gso_segs = (skb->len + mss - 1) / mss;           segs = NULL;         goto out;     }       segs = skb_segment(skb, features);     if (IS_ERR(segs))         goto out;       len = skb_shinfo(skb)->gso_size;     delta = htonl(oldlen + (thlen + len));       skb = segs;     th = skb->h.th;     seq = ntohl(th->seq);       do {         th->fin = th->psh = 0;           th->check = ~csum_fold(th->check + delta);         if (skb->ip_summed != CHECKSUM_HW)             th->check = csum_fold(csum_partial(skb->h.raw, thlen,                                skb->csum));           seq += len;         skb = skb->next;         th = skb->h.th;           th->seq = htonl(seq);         th->cwr = 0;     } while (skb->next);       delta = htonl(oldlen + (skb->tail - skb->h.raw) + skb->data_len);     th->check = ~csum_fold(th->check + delta);     if (skb->ip_summed != CHECKSUM_HW)         th->check = csum_fold(csum_partial(skb->h.raw, thlen,         

[1] [2] 下一页

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。