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