- 论坛徽章:
- 0
|
我想在bridge layer做切割
不過 ip_fragment這個是作用在IP 層
所以我該怎麼使用這個FUNCTION呢
目前我是想寫一個一模一樣的 但是內容做些修改
最後再呼叫ip_fragment(skb, dev_queue_xmit);
不知道可行不可行
1.iph = skb->nh.iph; 這個抓不到 ? 後來用mac.raw去抓 就可以了
2.struct rtable *rt = (struct rtable*)skb->dst; 這裡的rt抓不到 這裡的rt是用來算MTU
如果不用mtu = dst_pmtu(&rt->u.dst) - hlen; 那該如何計算MTU長度?
可以用iph->tot_len來計算?
int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
429{
430 struct iphdr *iph;
431 int raw = 0;
432 int ptr;
433 struct net_device *dev;
434 struct sk_buff *skb2;
435 unsigned int mtu, hlen, left, len, ll_rs;
436 int offset;
437 int not_last_frag;
438 struct rtable *rt = (struct rtable*)skb->dst;
439 int err = 0;
440
441 dev = rt->u.dst.dev;
442
443 /*
444 * Point into the IP datagram header.
445 */
446
447 iph = skb->nh.iph;
448
449 if (unlikely((iph->frag_off & htons(IP_DF)) && !skb->local_df)) {
450 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
451 htonl(dst_pmtu(&rt->u.dst)));
452 kfree_skb(skb);
453 return -EMSGSIZE;
454 }
455
456 /*
457 * Setup starting values.
458 */
459
460 hlen = iph->ihl * 4;
461 mtu = dst_pmtu(&rt->u.dst) - hlen; /* Size of data space */ |
|