• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            大龍的博客

            常用鏈接

            統計

            最新評論

            struct sock結構的簡單注釋 --- 轉

            內核網絡四層結構:BSD socket層、INET socket層、IP層、數據鏈路層

            sock結構工作在INET socket層,所有BSD socket層的操作都通過struct sock
            及其域字段prot指針轉化為prot鎖指向的函數處理,所以sock結構是維系
            BSD socket層和INET socket層的紐帶,其重要性是不言而喻的。

            下面是對sock結構的簡單注釋,有些沒有的待我弄懂后再來修改,^_^

            struct sock {
             /* Socket demultiplex comparisons on incoming packets. */
             __u32   daddr;  /* 外部IP地址   */
             __u32   rcv_saddr; /* 綁定的本地IP地址  */
             __u16   dport;  /* 目標端口   */
             unsigned short  num;  /* 本地端口    */
             int   bound_dev_if; /* 綁定網卡接口的索引 不為0  */

             /* 用于各種協議查找表的哈希鏈表 */
             struct sock  *next;
             struct sock  **pprev;
             struct sock  *bind_next;
             struct sock  **bind_pprev;

             volatile unsigned char state,  /* 連接狀態   */
                zapped;  /* In ax25 & ipx means not linked */
             __u16   sport;  /* 源端口    */

             unsigned short  family;  /* 地址簇   */
             unsigned char  reuse;  /* SO_REUSEADDR設置,表示地址重用 */
             unsigned char  shutdown; /* 半關閉標志 SEND_SHUTDOWN和RCV_SHUTDOWN掩碼 */
             atomic_t  refcnt;  /* 引用計數   */

             socket_lock_t  lock;  /* 同步鎖.   */
             int   rcvbuf;  /* 接受緩沖區長度(單位:字節) */

             wait_queue_head_t *sleep;  /* 等待隊列,通常指向socket的wait域 */
             struct dst_entry *dst_cache; /* 目的地緩存,用于路由查找結果  */
             rwlock_t  dst_lock; /* 目的地緩存鎖*/
             atomic_t  rmem_alloc; /* 已接收隊列字節數 */
             struct sk_buff_head receive_queue; /* 接收包隊列   */
             atomic_t  wmem_alloc; /* 已發送字節數 */
             struct sk_buff_head write_queue; /* 包發送隊列   */
             atomic_t  omem_alloc; /* "o"是"option"(選項)或"other"(其它)的意思 */
             int   wmem_queued; /* 穩定的隊列長度 */
             int   forward_alloc; /* 提前分配的空間 */
             __u32   saddr;  /* 發送源地址   */
             unsigned int  allocation; /* 分配模式   */
             int   sndbuf;  /* 發送緩沖區長度(單位:字節)  */
             struct sock  *prev;

             /* Not all are volatile, but some are, so we might as well say they all are.
              * XXX Make this a flag word -DaveM
              */
             volatile char  dead,
                done,
                urginline,
                keepopen,
                linger,
                destroy,
                no_check, /*SO_NO_CHECK標志,表示是否檢查包*/
                broadcast,
                bsdism;
             unsigned char  debug;
             unsigned char  rcvtstamp;
             unsigned char  userlocks;/*SO_SNDBUF和SO_RCVBUF標志 */
             int   proc;
             unsigned long         lingertime;

             int   hashent;
             struct sock  *pair;

             /* The backlog queue is special, it is always used with
              * the per-socket spinlock held and requires low latency
              * access.  Therefore we special case it's implementation.
              */
             struct {
              struct sk_buff *head;
              struct sk_buff *tail;
             } backlog;

             rwlock_t  callback_lock;/*用于結構末尾的回調函數互斥*/

             /* 錯誤隊列,很少使用 */
             struct sk_buff_head error_queue;

             struct proto  *prot;/*網絡地址簇內部協議處理*/

            #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
             union {
              struct ipv6_pinfo af_inet6;
             } net_pinfo;
            #endif

             union {
              struct tcp_opt  af_tcp;
            #if defined(CONFIG_INET) || defined (CONFIG_INET_MODULE)
              struct raw_opt  tp_raw4;
            #endif
            #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
              struct raw6_opt  tp_raw;
            #endif /* CONFIG_IPV6 */
            #if defined(CONFIG_SPX) || defined (CONFIG_SPX_MODULE)
              struct spx_opt  af_spx;
            #endif /* CONFIG_SPX */

             } tp_pinfo;

             int   err, err_soft; /* Soft holds errors that don't
                     cause failure but are the cause
                     of a persistent failure not just
                     'timed out' */
             unsigned short  ack_backlog;
             unsigned short  max_ack_backlog;
             __u32   priority;
             unsigned short  type;  /*socket類型,如:SOCK_STREAM*/
             unsigned char  localroute; /* 僅用于本地路由 */
             unsigned char  protocol; /*socket 所屬網絡地址簇的協議*/
             struct ucred  peercred; /*對端sock信息 SO_PEERCRED標志設置*/
             int   rcvlowat; /*SO_RCVLOWAT標志位*/
             long   rcvtimeo; /*SO_RCVTIMEO標志位*/
             long   sndtimeo; /*SO_SNDTIMEO標志位*/

            #ifdef CONFIG_FILTER
             /* Socket過濾指令 */
             struct sk_filter       *filter;
            #endif /* CONFIG_FILTER */

             /* This is where all the private (optional) areas that don't
              * overlap will eventually live.
              */
             union {
              void *destruct_hook;
                struct unix_opt af_unix;
            #if defined(CONFIG_INET) || defined (CONFIG_INET_MODULE)
              struct inet_opt af_inet;
            #endif
            #if defined(CONFIG_ATALK) || defined(CONFIG_ATALK_MODULE)
              struct atalk_sock af_at;
            #endif
            #if defined(CONFIG_IPX) || defined(CONFIG_IPX_MODULE)
              struct ipx_opt  af_ipx;
            #endif
            #if defined (CONFIG_DECNET) || defined(CONFIG_DECNET_MODULE)
              struct dn_scp           dn;
            #endif
            #if defined (CONFIG_PACKET) || defined(CONFIG_PACKET_MODULE)
              struct packet_opt *af_packet;
            #endif
            #if defined(CONFIG_X25) || defined(CONFIG_X25_MODULE)
              x25_cb   *x25;
            #endif
            #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
              ax25_cb   *ax25;
            #endif
            #if defined(CONFIG_NETROM) || defined(CONFIG_NETROM_MODULE)
              nr_cb   *nr;
            #endif
            #if defined(CONFIG_ROSE) || defined(CONFIG_ROSE_MODULE)
              rose_cb   *rose;
            #endif
            #if defined(CONFIG_PPPOE) || defined(CONFIG_PPPOE_MODULE)
              struct pppox_opt *pppox;
            #endif
            #ifdef CONFIG_NETLINK
              struct netlink_opt *af_netlink;
            #endif
            #if defined(CONFIG_ECONET) || defined(CONFIG_ECONET_MODULE)
              struct econet_opt *af_econet;
            #endif
            #if defined(CONFIG_ATM) || defined(CONFIG_ATM_MODULE)
              struct atm_vcc  *af_atm;
            #endif
            #if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
              struct irda_sock        *irda;
            #endif
             } protinfo;   /*私有數據區,網絡地址簇規范*/ 


             /* This part is used for the timeout functions. */
             struct timer_list timer;  /* sock清除定時器. */
             struct timeval  stamp;  /*最后到達的包的時間戳*/

             /* Identd and reporting IO signals */
             struct socket  *socket; /*BSD socket層套接字*/

             /* RPC層私有數據 */
             void   *user_data;
             
             /* 回調函數 */
             void   (*state_change)(struct sock *sk);
             void   (*data_ready)(struct sock *sk,int bytes);
             void   (*write_space)(struct sock *sk);
             void   (*error_report)(struct sock *sk);

               int   (*backlog_rcv) (struct sock *sk,
                  struct sk_buff *skb); 
             void                    (*destruct)(struct sock *sk);
            }; 

            posted on 2013-02-16 21:25 大龍 閱讀(831) 評論(0)  編輯 收藏 引用

            久久精品国产亚洲欧美| 97久久国产亚洲精品超碰热| 久久伊人中文无码| 国产免费久久精品99re丫y| 99国产欧美精品久久久蜜芽| 国产免费久久精品99久久| 77777亚洲午夜久久多人| 精品人妻伦一二三区久久| 99久久国产宗和精品1上映| 99久久久久| 国产成人无码久久久精品一| 久久综合给合综合久久| 99久久免费国产精品热| 7777久久久国产精品消防器材| 国内精品久久久久久久影视麻豆| 午夜精品久久久久久99热| 久久免费视频6| 精品久久一区二区| 久久国产色AV免费看| 久久人妻AV中文字幕| 无码精品久久一区二区三区| 久久se精品一区二区| 日产精品久久久久久久| 久久人人添人人爽添人人片牛牛| 国内精品久久久久久久亚洲| 久久噜噜电影你懂的| 久久99精品国产| 久久久91精品国产一区二区三区| 久久久久亚洲AV无码网站| 性欧美丰满熟妇XXXX性久久久| 亚洲欧美成人久久综合中文网| 久久久久久亚洲精品不卡| 精品一久久香蕉国产线看播放| 91精品婷婷国产综合久久| 国产亚洲婷婷香蕉久久精品| 国产精品青草久久久久婷婷| 韩国三级大全久久网站| 国产成人精品久久亚洲| 99久久综合国产精品二区| 久久久久久噜噜精品免费直播| 久久综合九色欧美综合狠狠|