root/include/linux/skbuff.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. skb_peek

   1 /*
   2  *      Definitions for the 'struct sk_buff' memory handlers.
   3  *
   4  *      Authors:
   5  *              Alan Cox, <gw4pts@gw4pts.ampr.org>
   6  *              Florian La Roche, <rzsfl@rz.uni-sb.de>
   7  *
   8  *      This program is free software; you can redistribute it and/or
   9  *      modify it under the terms of the GNU General Public License
  10  *      as published by the Free Software Foundation; either version
  11  *      2 of the License, or (at your option) any later version.
  12  */
  13  
  14 #ifndef _LINUX_SKBUFF_H
  15 #define _LINUX_SKBUFF_H
  16 #include <linux/malloc.h>
  17 #include <linux/wait.h>
  18 #include <linux/time.h>
  19 
  20 #define CONFIG_SKB_CHECK        1
  21 
  22 #define HAVE_ALLOC_SKB          /* For the drivers to know */
  23 
  24 
  25 #define FREE_READ       1
  26 #define FREE_WRITE      0
  27 
  28 
  29 struct sk_buff_head {
  30   struct sk_buff                * volatile next;
  31   struct sk_buff                * volatile prev;
  32 #if CONFIG_SKB_CHECK
  33   int                           magic_debug_cookie;
  34 #endif
  35 };
  36 
  37 
  38 struct sk_buff {
  39   struct sk_buff                * volatile next;
  40   struct sk_buff                * volatile prev;
  41 #if CONFIG_SKB_CHECK
  42   int                           magic_debug_cookie;
  43 #endif
  44   struct sk_buff                * volatile link3;
  45   struct sock                   *sk;
  46   volatile unsigned long        when;   /* used to compute rtt's        */
  47   struct timeval                stamp;
  48   struct device                 *dev;
  49   struct sk_buff                *mem_addr;
  50   union {
  51         struct tcphdr   *th;
  52         struct ethhdr   *eth;
  53         struct iphdr    *iph;
  54         struct udphdr   *uh;
  55         unsigned char   *raw;
  56         unsigned long   seq;
  57   } h;
  58   struct iphdr          *ip_hdr;                /* For IPPROTO_RAW */
  59   unsigned long                 mem_len;
  60   unsigned long                 len;
  61   unsigned long                 fraglen;
  62   struct sk_buff                *fraglist;      /* Fragment list */
  63   unsigned long                 truesize;
  64   unsigned long                 saddr;
  65   unsigned long                 daddr;
  66   unsigned long                 raddr;          /* next hop addr */
  67   volatile char                 acked,
  68                                 used,
  69                                 free,
  70                                 arp;
  71   unsigned char                 tries,lock,localroute,pkt_type;
  72 #define PACKET_HOST             0               /* To us */
  73 #define PACKET_BROADCAST        1
  74 #define PACKET_MULTICAST        2
  75 #define PACKET_OTHERHOST        3               /* Unmatched promiscuous */
  76   unsigned short                users;          /* User count - see datagram.c (and soon seqpacket.c/stream.c) */
  77 #ifdef CONFIG_SLAVE_BALANCING
  78   unsigned short                in_dev_queue;
  79 #endif  
  80   unsigned long                 padding[0];
  81   unsigned char                 data[0];
  82 };
  83 
  84 #define SK_WMEM_MAX     32767
  85 #define SK_RMEM_MAX     32767
  86 
  87 #ifdef CONFIG_SKB_CHECK
  88 #define SK_FREED_SKB    0x0DE2C0DE
  89 #define SK_GOOD_SKB     0xDEC0DED1
  90 #define SK_HEAD_SKB     0x12231298
  91 #endif
  92 
  93 #ifdef __KERNEL__
  94 /*
  95  *      Handling routines are only of interest to the kernel
  96  */
  97  
  98 #if 0
  99 extern void                     print_skb(struct sk_buff *);
 100 #endif
 101 extern void                     kfree_skb(struct sk_buff *skb, int rw);
 102 extern void                     skb_queue_head_init(struct sk_buff_head *list);
 103 extern void                     skb_queue_head(struct sk_buff_head *list,struct sk_buff *buf);
 104 extern void                     skb_queue_tail(struct sk_buff_head *list,struct sk_buff *buf);
 105 extern struct sk_buff *         skb_dequeue(struct sk_buff_head *list);
 106 extern void                     skb_insert(struct sk_buff *old,struct sk_buff *newsk);
 107 extern void                     skb_append(struct sk_buff *old,struct sk_buff *newsk);
 108 extern void                     skb_unlink(struct sk_buff *buf);
 109 extern struct sk_buff *         skb_peek_copy(struct sk_buff_head *list);
 110 extern struct sk_buff *         alloc_skb(unsigned int size, int priority);
 111 extern void                     kfree_skbmem(struct sk_buff *skb, unsigned size);
 112 extern struct sk_buff *         skb_clone(struct sk_buff *skb, int priority);
 113 extern void                     skb_device_lock(struct sk_buff *skb);
 114 extern void                     skb_device_unlock(struct sk_buff *skb);
 115 extern void                     dev_kfree_skb(struct sk_buff *skb, int mode);
 116 extern int                      skb_device_locked(struct sk_buff *skb);
 117 /*
 118  *      Peek an sk_buff. Unlike most other operations you _MUST_
 119  *      be careful with this one. A peek leaves the buffer on the
 120  *      list and someone else may run off with it. For an interrupt
 121  *      type system cli() peek the buffer copy the data and sti();
 122  */
 123 static __inline__ struct sk_buff *skb_peek(struct sk_buff_head *list_)
     /* [previous][next][first][last][top][bottom][index][help] */
 124 {
 125         struct sk_buff *list = (struct sk_buff *)list_;
 126         return (list->next != list)? list->next : NULL;
 127 }
 128 
 129 #if CONFIG_SKB_CHECK
 130 extern int                      skb_check(struct sk_buff *skb,int,int, char *);
 131 #define IS_SKB(skb)             skb_check((skb), 0, __LINE__,__FILE__)
 132 #define IS_SKB_HEAD(skb)        skb_check((skb), 1, __LINE__,__FILE__)
 133 #else
 134 #define IS_SKB(skb)             0
 135 #define IS_SKB_HEAD(skb)        0
 136 #endif
 137 
 138 extern struct sk_buff *         skb_recv_datagram(struct sock *sk,unsigned flags,int noblock, int *err);
 139 extern int                      datagram_select(struct sock *sk, int sel_type, select_table *wait);
 140 extern void                     skb_copy_datagram(struct sk_buff *from, int offset, char *to,int size);
 141 extern void                     skb_free_datagram(struct sk_buff *skb);
 142 
 143 #endif  /* __KERNEL__ */
 144 #endif  /* _LINUX_SKBUFF_H */

/* [previous][next][first][last][top][bottom][index][help] */