備份個函式,應該能用到!!
阿新 • • 發佈:2019-02-04
sock_queu_rcv_skb()函式的實現如下:
這裡就完成了資料包從網路層到傳輸層的傳輸。下面的博文將會分析資料包的從上到下的傳輸過程。
- /*
- * Queue a received datagram if it will fit. Stream and sequenced protocols
- * can't normally use this as they need to fit buffers in and play with them.
- */
- int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
- {
- unsigned long flags;
- if(sk->rmem_alloc + skb->mem_len >= sk->rcvbuf)
- return -ENOMEM;
- save_flags(flags);
- cli();
- sk->rmem_alloc+=skb->mem_len;
- skb->sk=sk;
- restore_flags(flags);
- skb_queue_tail(&sk->receive_queue,skb);
- if(!sk->dead)
- sk->data_ready(sk,skb->len);
- return 0;
- }
這裡就完成了資料包從網路層到傳輸層的傳輸。下面的博文將會分析資料包的從上到下的傳輸過程。