This source file includes following definitions.
- skb_peek
- skb_queue_head_init
- skb_queue_head
- skb_queue_tail
- skb_dequeue
- skb_insert
- skb_append
- skb_unlink
- skb_put
- skb_push
- skb_pull
- skb_headroom
- skb_tailroom
- skb_reserve
- skb_trim
1
2
3
4
5
6
7
8
9
10
11
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 #include <linux/config.h>
20
21 #define CONFIG_SKB_CHECK 0
22
23 #define HAVE_ALLOC_SKB
24 #define HAVE_ALIGNABLE_SKB
25
26
27 #define FREE_READ 1
28 #define FREE_WRITE 0
29
30
31 struct sk_buff_head {
32 struct sk_buff * volatile next;
33 struct sk_buff * volatile prev;
34 #if CONFIG_SKB_CHECK
35 int magic_debug_cookie;
36 #endif
37 };
38
39
40 struct sk_buff {
41 struct sk_buff * volatile next;
42 struct sk_buff * volatile prev;
43 #if CONFIG_SKB_CHECK
44 int magic_debug_cookie;
45 #endif
46 struct sk_buff * volatile link3;
47 struct sock *sk;
48 volatile unsigned long when;
49 struct timeval stamp;
50 struct device *dev;
51 union {
52 struct tcphdr *th;
53 struct ethhdr *eth;
54 struct iphdr *iph;
55 struct udphdr *uh;
56 unsigned char *raw;
57 unsigned long seq;
58 } h;
59
60 union {
61 unsigned char *raw;
62 struct ethhdr *ethernet;
63 } mac;
64
65 struct iphdr *ip_hdr;
66 unsigned long len;
67 unsigned long saddr;
68 unsigned long daddr;
69 unsigned long raddr;
70 unsigned long csum;
71 volatile char acked,
72 used,
73 free,
74 arp;
75 unsigned char tries,
76 lock,
77 localroute,
78 pkt_type,
79 ip_summed;
80 #define PACKET_HOST 0
81 #define PACKET_BROADCAST 1
82 #define PACKET_MULTICAST 2
83 #define PACKET_OTHERHOST 3
84 unsigned short users;
85 unsigned short protocol;
86 unsigned short truesize;
87 unsigned char *head;
88 unsigned char *data;
89 unsigned char *tail;
90 unsigned char *end;
91 };
92
93 #define SK_WMEM_MAX 32767
94 #define SK_RMEM_MAX 32767
95
96 #if CONFIG_SKB_CHECK
97 #define SK_FREED_SKB 0x0DE2C0DE
98 #define SK_GOOD_SKB 0xDEC0DED1
99 #define SK_HEAD_SKB 0x12231298
100 #endif
101
102 #ifdef __KERNEL__
103
104
105
106
107 #include <asm/system.h>
108
109 #if 0
110 extern void print_skb(struct sk_buff *);
111 #endif
112 extern void kfree_skb(struct sk_buff *skb, int rw);
113 extern void skb_queue_head_init(struct sk_buff_head *list);
114 extern void skb_queue_head(struct sk_buff_head *list,struct sk_buff *buf);
115 extern void skb_queue_tail(struct sk_buff_head *list,struct sk_buff *buf);
116 extern struct sk_buff * skb_dequeue(struct sk_buff_head *list);
117 extern void skb_insert(struct sk_buff *old,struct sk_buff *newsk);
118 extern void skb_append(struct sk_buff *old,struct sk_buff *newsk);
119 extern void skb_unlink(struct sk_buff *buf);
120 extern struct sk_buff * skb_peek_copy(struct sk_buff_head *list);
121 extern struct sk_buff * alloc_skb(unsigned int size, int priority);
122 extern struct sk_buff * dev_alloc_skb(unsigned int size);
123 extern void kfree_skbmem(struct sk_buff *skb);
124 extern struct sk_buff * skb_clone(struct sk_buff *skb, int priority);
125 extern void skb_device_lock(struct sk_buff *skb);
126 extern void skb_device_unlock(struct sk_buff *skb);
127 extern void dev_kfree_skb(struct sk_buff *skb, int mode);
128 extern int skb_device_locked(struct sk_buff *skb);
129 extern unsigned char * skb_put(struct sk_buff *skb, int len);
130 extern unsigned char * skb_push(struct sk_buff *skb, int len);
131 extern int skb_pull(struct sk_buff *skb, int len);
132 extern int skb_headroom(struct sk_buff *skb);
133 extern int skb_tailroom(struct sk_buff *skb);
134 extern void skb_reserve(struct sk_buff *skb, int len);
135 extern void skb_trim(struct sk_buff *skb, int len);
136
137
138
139
140
141
142
143 static __inline__ struct sk_buff *skb_peek(struct sk_buff_head *list_)
144 {
145 struct sk_buff *list = (struct sk_buff *)list_;
146 return (list->next != list)? list->next : NULL;
147 }
148
149 #if CONFIG_SKB_CHECK
150 extern int skb_check(struct sk_buff *skb,int,int, char *);
151 #define IS_SKB(skb) skb_check((skb), 0, __LINE__,__FILE__)
152 #define IS_SKB_HEAD(skb) skb_check((skb), 1, __LINE__,__FILE__)
153 #else
154 #define IS_SKB(skb)
155 #define IS_SKB_HEAD(skb)
156
157 extern __inline__ void skb_queue_head_init(struct sk_buff_head *list)
158 {
159 list->prev = (struct sk_buff *)list;
160 list->next = (struct sk_buff *)list;
161 }
162
163
164
165
166
167 extern __inline__ void skb_queue_head(struct sk_buff_head *list_,struct sk_buff *newsk)
168 {
169 unsigned long flags;
170 struct sk_buff *list = (struct sk_buff *)list_;
171
172 save_flags(flags);
173 cli();
174 newsk->next = list->next;
175 newsk->prev = list;
176 newsk->next->prev = newsk;
177 newsk->prev->next = newsk;
178 restore_flags(flags);
179 }
180
181
182
183
184
185 extern __inline__ void skb_queue_tail(struct sk_buff_head *list_, struct sk_buff *newsk)
186 {
187 unsigned long flags;
188 struct sk_buff *list = (struct sk_buff *)list_;
189
190 save_flags(flags);
191 cli();
192
193 newsk->next = list;
194 newsk->prev = list->prev;
195
196 newsk->next->prev = newsk;
197 newsk->prev->next = newsk;
198
199 restore_flags(flags);
200 }
201
202
203
204
205
206
207
208
209 extern __inline__ struct sk_buff *skb_dequeue(struct sk_buff_head *list_)
210 {
211 long flags;
212 struct sk_buff *result;
213 struct sk_buff *list = (struct sk_buff *)list_;
214
215 save_flags(flags);
216 cli();
217
218 result = list->next;
219 if (result == list)
220 {
221 restore_flags(flags);
222 return NULL;
223 }
224 else
225 {
226 result->next->prev = list;
227 list->next = result->next;
228
229 result->next = NULL;
230 result->prev = NULL;
231
232 restore_flags(flags);
233
234 return result;
235 }
236 }
237
238
239
240
241
242 extern __inline__ void skb_insert(struct sk_buff *old, struct sk_buff *newsk)
243 {
244 unsigned long flags;
245
246 save_flags(flags);
247 cli();
248 newsk->next = old;
249 newsk->prev = old->prev;
250 old->prev = newsk;
251 newsk->prev->next = newsk;
252
253 restore_flags(flags);
254 }
255
256
257
258
259
260 extern __inline__ void skb_append(struct sk_buff *old, struct sk_buff *newsk)
261 {
262 unsigned long flags;
263
264 save_flags(flags);
265 cli();
266
267 newsk->prev = old;
268 newsk->next = old->next;
269 newsk->next->prev = newsk;
270 old->next = newsk;
271
272 restore_flags(flags);
273 }
274
275
276
277
278
279
280
281
282 extern __inline__ void skb_unlink(struct sk_buff *skb)
283 {
284 unsigned long flags;
285
286 save_flags(flags);
287 cli();
288
289 if(skb->prev && skb->next)
290 {
291 skb->next->prev = skb->prev;
292 skb->prev->next = skb->next;
293 skb->next = NULL;
294 skb->prev = NULL;
295 }
296 restore_flags(flags);
297 }
298
299
300
301
302
303 extern __inline__ unsigned char *skb_put(struct sk_buff *skb, int len)
304 {
305 unsigned char *tmp=skb->tail;
306 skb->tail+=len;
307 skb->len+=len;
308 if(skb->tail>skb->end)
309 panic("skput:over: %p:%d", __builtin_return_address(0),len);
310 return tmp;
311 }
312
313 extern __inline__ unsigned char *skb_push(struct sk_buff *skb, int len)
314 {
315 skb->data-=len;
316 skb->len+=len;
317 if(skb->data<skb->head)
318 panic("skpush:under: %p:%d", __builtin_return_address(0),len);
319 return skb->data;
320 }
321
322 extern __inline__ int skb_pull(struct sk_buff *skb, int len)
323 {
324 if(len>skb->len)
325 len=skb->len;
326 skb->data+=len;
327 skb->len-=len;
328 return len;
329 }
330
331 extern __inline__ int skb_headroom(struct sk_buff *skb)
332 {
333 return skb->data-skb->head;
334 }
335
336 extern __inline__ int skb_tailroom(struct sk_buff *skb)
337 {
338 return skb->end-skb->tail;
339 }
340
341 extern __inline__ void skb_reserve(struct sk_buff *skb, int len)
342 {
343 skb->data+=len;
344 skb->tail+=len;
345 }
346
347 extern __inline__ void skb_trim(struct sk_buff *skb, int len)
348 {
349 if(skb->len>len)
350 {
351 skb->len=len;
352 skb->tail=skb->data+len;
353 }
354 }
355
356 #endif
357
358 extern struct sk_buff * skb_recv_datagram(struct sock *sk,unsigned flags,int noblock, int *err);
359 extern int datagram_select(struct sock *sk, int sel_type, select_table *wait);
360 extern void skb_copy_datagram(struct sk_buff *from, int offset, char *to,int size);
361 extern void skb_free_datagram(struct sk_buff *skb);
362
363 #endif
364 #endif