Linux核心数据结构--sk_buff

用来描叙在协议层之间交换的网络数据。

struct sk_buff

{

  struct sk_buff      *next;
      /* Next buffer in list                   */

  struct sk_buff      *prev;     /* Previous buffer in list */

  struct sk_buff_head *list;       /* List we are on   */

  int                 magic_debug_cookie;

  struct sk_buff      *link3;
      /* Link for IP protocol level buffer chains */

struct sock         *sk;     /* Socket we are owned by    */

  unsigned long       when;        /* used to compute rtt's                 */

  struct timeval      stamp;       /* Time we arrived                       */

  struct device       *dev;        /* Device we arrived on/are leaving by   */

  union

  {

      struct tcphdr   *th;

      struct ethhdr   *eth;

      struct iphdr    *iph;

      struct udphdr   *uh;

      unsigned char   *raw;
      /* for passing file handles in a unix domain socket */

      void            *filp;
  } h;


 

union

  {
   

      /* As yet incomplete physical layer views */

     unsigned char   *raw;

      struct ethhdr   *ethernet;

  } mac;

 

  struct iphdr        *ip_hdr;     /* For IPPROTO_RAW                       */

  unsigned long       len;         /* Length of actual data                 */

  unsigned long       csum;        /* Checksum                              */

  __u32               saddr;       /* IP source address                     */

  __u32               daddr;       /* IP target address                     */

  __u32               raddr;       /* IP next hop address                   */

  __u32               seq;         /* TCP sequence number                   */

  __u32               end_seq;     /* seq [+ fin] [+ syn] + datalen         */

  __u32               ack_seq;     /* TCP ack sequence number               */

  unsigned char       proto_priv[16];

  volatile char       acked,     
/* Are we acked ?           */

                      used,        /* Are we in use ?       */

                      free,       /* How to free this buffer*/

                      arp;        /* Has IP/ARP resolution finished    */

  unsigned char       tries,       /* Times tried           */

                      lock,        /* Are we locked ?       */

                      localroute, /* Local routing asserted for this frame */

                      pkt_type,    /* Packet class      */

                      pkt_bridged, /* Tracker for bridging  */

                      ip_summed;   /* Driver fed us an IP checksum          */

#define PACKET_HOST         0        /* To us              */

#define PACKET_BROADCAST    1        /* To all            */

#define PACKET_MULTICAST    2        /* To group       */

#define PACKET_OTHERHOST    3        /* To someone else  */

  unsigned short      users;       /* User count - see datagram.c,tcp.c     */

  unsigned short      protocol;    /* Packet protocol from driver.          */

  unsigned int        truesize;    /* Buffer size           */

  atomic_t            count;       /* reference count       */

  struct sk_buff      *data_skb;   /* Link to the actual data skb           */

  unsigned char       *head;       /* Head of buffer        */

  unsigned char       *data;       /* Data head pointer     */

  unsigned char       *tail;       /* Tail pointer          */

  unsigned char       *end;        /* End pointer         */

  void                (*destructor)(struct sk_buff *); /* Destruct function */

  __u16               redirport;   /* Redirect port         */

};

你可能感兴趣的:(数据结构,linux,socket,unix,网络协议)