This source file includes following definitions.
- skb_queue_empty
- skb_peek
- skb_queue_len
- skb_queue_head_init
- __skb_queue_head
- skb_queue_head
- __skb_queue_tail
- skb_queue_tail
- __skb_dequeue
- skb_dequeue
- __skb_insert
- skb_insert
- skb_append
- __skb_unlink
- 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
17 #include <linux/config.h>
18 #include <linux/time.h>
19
20 #include <asm/atomic.h>
21 #include <asm/types.h>
22
23 #define CONFIG_SKB_CHECK 0
24
25 #define HAVE_ALLOC_SKB
26 #define HAVE_ALIGNABLE_SKB
27
28
29 #define FREE_READ 1
30 #define FREE_WRITE 0
31
32 #define CHECKSUM_NONE 0
33 #define CHECKSUM_HW 1
34 #define CHECKSUM_UNNECESSARY 2
35
36 struct sk_buff_head
37 {
38 struct sk_buff * next;
39 struct sk_buff * prev;
40 __u32 qlen;
41
42 #if CONFIG_SKB_CHECK
43 int magic_debug_cookie;
44 #endif
45 };
46
47
48 struct sk_buff
49 {
50 struct sk_buff * next;
51 struct sk_buff * prev;
52 struct sk_buff_head * list;
53 #if CONFIG_SKB_CHECK
54 int magic_debug_cookie;
55 #endif
56 struct sk_buff *link3;
57 struct sock *sk;
58 unsigned long when;
59 struct timeval stamp;
60 struct device *dev;
61 union
62 {
63 struct tcphdr *th;
64 struct ethhdr *eth;
65 struct iphdr *iph;
66 struct udphdr *uh;
67 unsigned char *raw;
68
69 void *filp;
70 } h;
71
72 union
73 {
74
75 unsigned char *raw;
76 struct ethhdr *ethernet;
77 } mac;
78
79 struct iphdr *ip_hdr;
80 unsigned long len;
81 unsigned long csum;
82 __u32 saddr;
83 __u32 daddr;
84 __u32 raddr;
85 __u32 seq;
86 __u32 end_seq;
87 __u32 ack_seq;
88 unsigned char proto_priv[16];
89 volatile char acked,
90 used,
91 free,
92 arp;
93 unsigned char tries,
94 lock,
95 localroute,
96 pkt_type,
97 pkt_bridged,
98 ip_summed;
99 #define PACKET_HOST 0
100 #define PACKET_BROADCAST 1
101 #define PACKET_MULTICAST 2
102 #define PACKET_OTHERHOST 3
103 unsigned short users;
104 unsigned short protocol;
105 unsigned short truesize;
106
107 atomic_t count;
108 struct sk_buff *data_skb;
109 unsigned char *head;
110 unsigned char *data;
111 unsigned char *tail;
112 unsigned char *end;
113 void (*destructor)(struct sk_buff *this);
114 };
115
116 #ifdef CONFIG_SKB_LARGE
117 #define SK_WMEM_MAX 65535
118 #define SK_RMEM_MAX 65535
119 #else
120 #define SK_WMEM_MAX 32767
121 #define SK_RMEM_MAX 32767
122 #endif
123
124 #if CONFIG_SKB_CHECK
125 #define SK_FREED_SKB 0x0DE2C0DE
126 #define SK_GOOD_SKB 0xDEC0DED1
127 #define SK_HEAD_SKB 0x12231298
128 #endif
129
130 #ifdef __KERNEL__
131
132
133
134 #include <linux/malloc.h>
135
136 #include <asm/system.h>
137
138 #if 0
139 extern void print_skb(struct sk_buff *);
140 #endif
141 extern void kfree_skb(struct sk_buff *skb, int rw);
142 extern void skb_queue_head_init(struct sk_buff_head *list);
143 extern void skb_queue_head(struct sk_buff_head *list,struct sk_buff *buf);
144 extern void skb_queue_tail(struct sk_buff_head *list,struct sk_buff *buf);
145 extern struct sk_buff * skb_dequeue(struct sk_buff_head *list);
146 extern void skb_insert(struct sk_buff *old,struct sk_buff *newsk);
147 extern void skb_append(struct sk_buff *old,struct sk_buff *newsk);
148 extern void skb_unlink(struct sk_buff *buf);
149 extern __u32 skb_queue_len(struct sk_buff_head *list);
150 extern struct sk_buff * skb_peek_copy(struct sk_buff_head *list);
151 extern struct sk_buff * alloc_skb(unsigned int size, int priority);
152 extern struct sk_buff * dev_alloc_skb(unsigned int size);
153 extern void kfree_skbmem(struct sk_buff *skb);
154 extern struct sk_buff * skb_clone(struct sk_buff *skb, int priority);
155 extern struct sk_buff * skb_copy(struct sk_buff *skb, int priority);
156 extern void skb_device_lock(struct sk_buff *skb);
157 extern void skb_device_unlock(struct sk_buff *skb);
158 extern void dev_kfree_skb(struct sk_buff *skb, int mode);
159 extern int skb_device_locked(struct sk_buff *skb);
160 extern unsigned char * skb_put(struct sk_buff *skb, int len);
161 extern unsigned char * skb_push(struct sk_buff *skb, int len);
162 extern unsigned char * skb_pull(struct sk_buff *skb, int len);
163 extern int skb_headroom(struct sk_buff *skb);
164 extern int skb_tailroom(struct sk_buff *skb);
165 extern void skb_reserve(struct sk_buff *skb, int len);
166 extern void skb_trim(struct sk_buff *skb, int len);
167
168 extern __inline__ int skb_queue_empty(struct sk_buff_head *list)
169 {
170 return (list->next == (struct sk_buff *) list);
171 }
172
173
174
175
176
177
178
179 extern __inline__ struct sk_buff *skb_peek(struct sk_buff_head *list_)
180 {
181 struct sk_buff *list = ((struct sk_buff *)list_)->next;
182 if (list == (struct sk_buff *)list_)
183 list = NULL;
184 return list;
185 }
186
187
188
189
190
191 extern __inline__ __u32 skb_queue_len(struct sk_buff_head *list_)
192 {
193 return(list_->qlen);
194 }
195
196 #if CONFIG_SKB_CHECK
197 extern int skb_check(struct sk_buff *skb,int,int, char *);
198 #define IS_SKB(skb) skb_check((skb), 0, __LINE__,__FILE__)
199 #define IS_SKB_HEAD(skb) skb_check((skb), 1, __LINE__,__FILE__)
200 #else
201 #define IS_SKB(skb)
202 #define IS_SKB_HEAD(skb)
203
204 extern __inline__ void skb_queue_head_init(struct sk_buff_head *list)
205 {
206 list->prev = (struct sk_buff *)list;
207 list->next = (struct sk_buff *)list;
208 list->qlen = 0;
209 }
210
211
212
213
214
215
216
217
218 extern __inline__ void __skb_queue_head(struct sk_buff_head *list, struct sk_buff *newsk)
219 {
220 struct sk_buff *prev, *next;
221
222 newsk->list = list;
223 list->qlen++;
224 prev = (struct sk_buff *)list;
225 next = prev->next;
226 newsk->next = next;
227 newsk->prev = prev;
228 next->prev = newsk;
229 prev->next = newsk;
230 }
231
232 extern __inline__ void skb_queue_head(struct sk_buff_head *list, struct sk_buff *newsk)
233 {
234 unsigned long flags;
235
236 save_flags(flags);
237 cli();
238 __skb_queue_head(list, newsk);
239 restore_flags(flags);
240 }
241
242
243
244
245
246 extern __inline__ void __skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk)
247 {
248 struct sk_buff *prev, *next;
249
250 newsk->list = list;
251 list->qlen++;
252 next = (struct sk_buff *)list;
253 prev = next->prev;
254 newsk->next = next;
255 newsk->prev = prev;
256 next->prev = newsk;
257 prev->next = newsk;
258 }
259
260 extern __inline__ void skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk)
261 {
262 unsigned long flags;
263
264 save_flags(flags);
265 cli();
266 __skb_queue_tail(list, newsk);
267 restore_flags(flags);
268 }
269
270
271
272
273
274 extern __inline__ struct sk_buff *__skb_dequeue(struct sk_buff_head *list)
275 {
276 struct sk_buff *next, *prev, *result;
277
278 prev = (struct sk_buff *) list;
279 next = prev->next;
280 result = NULL;
281 if (next != prev) {
282 result = next;
283 next = next->next;
284 list->qlen--;
285 next->prev = prev;
286 prev->next = next;
287 result->next = NULL;
288 result->prev = NULL;
289 result->list = NULL;
290 }
291 return result;
292 }
293
294 extern __inline__ struct sk_buff *skb_dequeue(struct sk_buff_head *list)
295 {
296 long flags;
297 struct sk_buff *result;
298
299 save_flags(flags);
300 cli();
301 result = __skb_dequeue(list);
302 restore_flags(flags);
303 return result;
304 }
305
306
307
308
309
310 extern __inline__ void __skb_insert(struct sk_buff *newsk,
311 struct sk_buff * prev, struct sk_buff *next,
312 struct sk_buff_head * list)
313 {
314 newsk->next = next;
315 newsk->prev = prev;
316 next->prev = newsk;
317 prev->next = newsk;
318 newsk->list = list;
319 list->qlen++;
320 }
321
322
323
324
325 extern __inline__ void skb_insert(struct sk_buff *old, struct sk_buff *newsk)
326 {
327 unsigned long flags;
328
329 save_flags(flags);
330 cli();
331 __skb_insert(newsk, old->prev, old, old->list);
332 restore_flags(flags);
333 }
334
335
336
337
338
339 extern __inline__ void skb_append(struct sk_buff *old, struct sk_buff *newsk)
340 {
341 unsigned long flags;
342
343 save_flags(flags);
344 cli();
345 __skb_insert(newsk, old, old->next, old->list);
346 restore_flags(flags);
347 }
348
349
350
351
352
353 extern __inline__ void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list)
354 {
355 struct sk_buff * next, * prev;
356
357 list->qlen--;
358 next = skb->next;
359 prev = skb->prev;
360 skb->next = NULL;
361 skb->prev = NULL;
362 skb->list = NULL;
363 next->prev = prev;
364 prev->next = next;
365 }
366
367
368
369
370
371
372
373
374 extern __inline__ void skb_unlink(struct sk_buff *skb)
375 {
376 unsigned long flags;
377
378 save_flags(flags);
379 cli();
380 if(skb->list)
381 __skb_unlink(skb, skb->list);
382 restore_flags(flags);
383 }
384
385
386
387
388
389 extern __inline__ unsigned char *skb_put(struct sk_buff *skb, int len)
390 {
391 unsigned char *tmp=skb->tail;
392 skb->tail+=len;
393 skb->len+=len;
394 if(skb->tail>skb->end)
395 {
396 __label__ here;
397 panic("skput:over: %p:%d", &&here,len);
398 here:
399 }
400 return tmp;
401 }
402
403 extern __inline__ unsigned char *skb_push(struct sk_buff *skb, int len)
404 {
405 skb->data-=len;
406 skb->len+=len;
407 if(skb->data<skb->head)
408 {
409 __label__ here;
410 panic("skpush:under: %p:%d", &&here,len);
411 here:
412 }
413 return skb->data;
414 }
415
416 extern __inline__ unsigned char * skb_pull(struct sk_buff *skb, int len)
417 {
418 if(len > skb->len)
419 return NULL;
420 skb->data+=len;
421 skb->len-=len;
422 return skb->data;
423 }
424
425 extern __inline__ int skb_headroom(struct sk_buff *skb)
426 {
427 return skb->data-skb->head;
428 }
429
430 extern __inline__ int skb_tailroom(struct sk_buff *skb)
431 {
432 return skb->end-skb->tail;
433 }
434
435 extern __inline__ void skb_reserve(struct sk_buff *skb, int len)
436 {
437 skb->data+=len;
438 skb->tail+=len;
439 }
440
441 extern __inline__ void skb_trim(struct sk_buff *skb, int len)
442 {
443 if(skb->len>len)
444 {
445 skb->len=len;
446 skb->tail=skb->data+len;
447 }
448 }
449
450 #endif
451
452 extern struct sk_buff * skb_recv_datagram(struct sock *sk,unsigned flags,int noblock, int *err);
453 extern int datagram_select(struct sock *sk, int sel_type, select_table *wait);
454 extern void skb_copy_datagram(struct sk_buff *from, int offset, char *to,int size);
455 extern void skb_copy_datagram_iovec(struct sk_buff *from, int offset, struct iovec *to,int size);
456 extern void skb_free_datagram(struct sock * sk, struct sk_buff *skb);
457
458 #endif
459 #endif