乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Linux內(nèi)核--網(wǎng)絡(luò)內(nèi)核實(shí)現(xiàn)分析(一)--與sk_buff有關(guān)的幾個(gè)重要的結(jié)構(gòu)

       zhouADNjj 2014-03-10

      本文分析基于Linux Kernel 3.2.1

      幾個(gè)月之前做了關(guān)于Linux內(nèi)核版本1.2.13網(wǎng)絡(luò)棧的結(jié)構(gòu)框架分析并實(shí)現(xiàn)了基于Netfilter的包過(guò)濾防火墻,這里以內(nèi)核3.2.1內(nèi)核為例來(lái)進(jìn)一步分析,更全面的分析網(wǎng)絡(luò)棧的結(jié)構(gòu)。

      更多請(qǐng)查看 Linux內(nèi)核--網(wǎng)絡(luò)內(nèi)核實(shí)現(xiàn)分析

      1、先說(shuō)一下sk_buff結(jié)構(gòu)體

      這個(gè)結(jié)構(gòu)體是套接字的緩沖區(qū),詳細(xì)記錄了一個(gè)數(shù)據(jù)包的組成,時(shí)間、網(wǎng)絡(luò)設(shè)備、各層的首部及首部長(zhǎng)度和數(shù)據(jù)的首尾指針。

      下面是他的定義,挺長(zhǎng)

      1. struct sk_buff {  
      2.     /* These two members must be first. */  
      3.     struct sk_buff      *next;  
      4.     struct sk_buff      *prev;  
      5.   
      6.     ktime_t         tstamp;  
      7.   
      8.     struct sock     *sk;  
      9.     struct net_device   *dev;  
      10.   
      11.     /* 
      12.      * This is the control buffer. It is free to use for every 
      13.      * layer. Please put your private variables there. If you 
      14.      * want to keep them across layers you have to do a skb_clone() 
      15.      * first. This is owned by whoever has the skb queued ATM. 
      16.      */  
      17.     char            cb[48] __aligned(8);  
      18.   
      19.     unsigned long       _skb_refdst;  
      20. #ifdef CONFIG_XFRM   
      21.     struct  sec_path    *sp;  
      22. #endif   
      23.     unsigned int        len,  
      24.                 data_len;  
      25.     __u16           mac_len,  
      26.                 hdr_len;  
      27.     union {  
      28.         __wsum      csum;  
      29.         struct {  
      30.             __u16   csum_start;  
      31.             __u16   csum_offset;  
      32.         };  
      33.     };  
      34.     __u32           priority;  
      35.     kmemcheck_bitfield_begin(flags1);  
      36.     __u8            local_df:1,  
      37.                 cloned:1,  
      38.                 ip_summed:2,  
      39.                 nohdr:1,  
      40.                 nfctinfo:3;  
      41.     __u8            pkt_type:3,  
      42.                 fclone:2,  
      43.                 ipvs_property:1,  
      44.                 peeked:1,  
      45.                 nf_trace:1;  
      46.     kmemcheck_bitfield_end(flags1);  
      47.     __be16          protocol;  
      48.   
      49.     void            (*destructor)(struct sk_buff *skb);  
      50. #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)   
      51.     struct nf_conntrack *nfct;  
      52. #endif   
      53. #ifdef NET_SKBUFF_NF_DEFRAG_NEEDED   
      54.     struct sk_buff      *nfct_reasm;  
      55. #endif   
      56. #ifdef CONFIG_BRIDGE_NETFILTER   
      57.     struct nf_bridge_info   *nf_bridge;  
      58. #endif   
      59.   
      60.     int         skb_iif;  
      61. #ifdef CONFIG_NET_SCHED   
      62.     __u16           tc_index;   /* traffic control index */  
      63. #ifdef CONFIG_NET_CLS_ACT   
      64.     __u16           tc_verd;    /* traffic control verdict */  
      65. #endif   
      66. #endif   
      67.   
      68.     __u32           rxhash;  
      69.   
      70.     __u16           queue_mapping;  
      71.     kmemcheck_bitfield_begin(flags2);  
      72. #ifdef CONFIG_IPV6_NDISC_NODETYPE   
      73.     __u8            ndisc_nodetype:2;  
      74. #endif   
      75.     __u8            ooo_okay:1;  
      76.     __u8            l4_rxhash:1;  
      77.     kmemcheck_bitfield_end(flags2);  
      78.   
      79.     /* 0/13 bit hole */  
      80.   
      81. #ifdef CONFIG_NET_DMA   
      82.     dma_cookie_t        dma_cookie;  
      83. #endif   
      84. #ifdef CONFIG_NETWORK_SECMARK   
      85.     __u32           secmark;  
      86. #endif   
      87.     union {  
      88.         __u32       mark;  
      89.         __u32       dropcount;  
      90.     };  
      91.   
      92.     __u16           vlan_tci;  
      93.   
      94.     sk_buff_data_t      transport_header;  
      95.     sk_buff_data_t      network_header;  
      96.     sk_buff_data_t      mac_header;  
      97.     /* These elements must be at the end, see alloc_skb() for details.  */  
      98.     sk_buff_data_t      tail;  
      99.     sk_buff_data_t      end;  
      100.     unsigned char       *head,  
      101.                 *data;  
      102.     unsigned int        truesize;  
      103.     atomic_t        users;  
      104. };  

      可以看到新版本內(nèi)核中發(fā)生了很多變化,其中數(shù)據(jù)包的首部在早期版本是以u(píng)nion的形式定義的,例如mac_header的定義方式如下:

      1. union{  
      2.     struct ethhdr *ethernet;  
      3.     unsigned char *raw;  
      4. }mac;  

      這里是以指針的形式給出的

      1. #ifdef NET_SKBUFF_DATA_USES_OFFSET   
      2. typedef unsigned int sk_buff_data_t;  
      3. #else   
      4. typedef unsigned char *sk_buff_data_t;  
      5. #endif  
      linux

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多