1. 程式人生 > >備份個函式,應該能用到!!

備份個函式,應該能用到!!

sock_queu_rcv_skb()函式的實現如下:
  1. /* 
  2.  *  Queue a received datagram if it will fit. Stream and sequenced protocols 
  3.  *  can't normally use this as they need to fit buffers in and play with them. 
  4.  */
  5. int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)  
  6. {  
  7.     unsigned long flags;  
  8.     if(sk->rmem_alloc + skb->mem_len >= sk->rcvbuf)  
  9.         return -ENOMEM;  
  10.     save_flags(flags);  
  11.     cli();  
  12.     sk->rmem_alloc+=skb->mem_len;  
  13.     skb->sk=sk;  
  14.     restore_flags(flags);  
  15.     skb_queue_tail(&sk->receive_queue,skb);  
  16.     if(!sk->dead)  
  17.         sk->data_ready(sk,skb->len);  
  18.     return 0;  
  19. }  

這裡就完成了資料包從網路層到傳輸層的傳輸。下面的博文將會分析資料包的從上到下的傳輸過程。