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   void                          *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;
  72   unsigned short                users;          /* User count - see datagram.c (and soon seqpacket.c/stream.c) */
  73   unsigned long                 padding[0];
  74   unsigned char                 data[0];
  75 };
  76 
  77 #define SK_WMEM_MAX     32767
  78 #define SK_RMEM_MAX     32767
  79 
  80 #ifdef CONFIG_SKB_CHECK
  81 #define SK_FREED_SKB    0x0DE2C0DE
  82 #define SK_GOOD_SKB     0xDEC0DED1
  83 #define SK_HEAD_SKB     0x12231298
  84 #endif
  85 
  86 #ifdef __KERNEL__
  87 /*
  88  *      Handling routines are only of interest to the kernel
  89  */
  90  
  91 #if 0
  92 extern void                     print_skb(struct sk_buff *);
  93 #endif
  94 extern void                     kfree_skb(struct sk_buff *skb, int rw);
  95 extern void                     skb_queue_head_init(struct sk_buff_head *list);
  96 extern void                     skb_queue_head(struct sk_buff_head *list,struct sk_buff *buf);
  97 extern void                     skb_queue_tail(struct sk_buff_head *list,struct sk_buff *buf);
  98 extern struct sk_buff *         skb_dequeue(struct sk_buff_head *list);
  99 extern void                     skb_insert(struct sk_buff *old,struct sk_buff *newsk);
 100 extern void                     skb_append(struct sk_buff *old,struct sk_buff *newsk);
 101 extern void                     skb_unlink(struct sk_buff *buf);
 102 extern struct sk_buff *         skb_peek_copy(struct sk_buff_head *list);
 103 extern struct sk_buff *         alloc_skb(unsigned int size, int priority);
 104 extern void                     kfree_skbmem(void *mem, unsigned size);
 105 extern struct sk_buff *         skb_clone(struct sk_buff *skb, int priority);
 106 extern void                     skb_kept_by_device(struct sk_buff *skb);
 107 extern void                     skb_device_release(struct sk_buff *skb,
 108                                         int mode);
 109 extern int                      skb_device_locked(struct sk_buff *skb);
 110 /*
 111  *      Peek an sk_buff. Unlike most other operations you _MUST_
 112  *      be careful with this one. A peek leaves the buffer on the
 113  *      list and someone else may run off with it. For an interrupt
 114  *      type system cli() peek the buffer copy the data and sti();
 115  */
 116 static __inline__ struct sk_buff *skb_peek(struct sk_buff_head *list_)
     /* [previous][next][first][last][top][bottom][index][help] */
 117 {
 118         struct sk_buff *list = (struct sk_buff *)list_;
 119         return (list->next != list)? list->next : NULL;
 120 }
 121 
 122 #if CONFIG_SKB_CHECK
 123 extern int                      skb_check(struct sk_buff *skb,int,int, char *);
 124 #define IS_SKB(skb)             skb_check((skb), 0, __LINE__,__FILE__)
 125 #define IS_SKB_HEAD(skb)        skb_check((skb), 1, __LINE__,__FILE__)
 126 #else
 127 #define IS_SKB(skb)             0
 128 #define IS_SKB_HEAD(skb)        0
 129 #endif
 130 
 131 extern struct sk_buff *         skb_recv_datagram(struct sock *sk,unsigned flags,int noblock, int *err);
 132 extern int                      datagram_select(struct sock *sk, int sel_type, select_table *wait);
 133 extern void                     skb_copy_datagram(struct sk_buff *from, int offset, char *to,int size);
 134 extern void                     skb_free_datagram(struct sk_buff *skb);
 135 
 136 #endif  /* __KERNEL__ */
 137 #endif  /* _LINUX_SKBUFF_H */

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