This source file includes following definitions.
- 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 * volatile next;
37 struct sk_buff * volatile 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 * volatile next;
49 struct sk_buff * volatile 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 struct file *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
165
166
167
168
169
170 extern __inline__ struct sk_buff *skb_peek(struct sk_buff_head *list_)
171 {
172 struct sk_buff *list = ((struct sk_buff *)list_)->next;
173 if (list == (struct sk_buff *)list_)
174 list = NULL;
175 return list;
176 }
177
178
179
180
181
182 extern __inline__ __u32 skb_queue_len(struct sk_buff_head *list_)
183 {
184 return(list_->qlen);
185 }
186
187 #if CONFIG_SKB_CHECK
188 extern int skb_check(struct sk_buff *skb,int,int, char *);
189 #define IS_SKB(skb) skb_check((skb), 0, __LINE__,__FILE__)
190 #define IS_SKB_HEAD(skb) skb_check((skb), 1, __LINE__,__FILE__)
191 #else
192 #define IS_SKB(skb)
193 #define IS_SKB_HEAD(skb)
194
195 extern __inline__ void skb_queue_head_init(struct sk_buff_head *list)
196 {
197 list->prev = (struct sk_buff *)list;
198 list->next = (struct sk_buff *)list;
199 list->qlen = 0;
200 }
201
202
203
204
205
206
207
208
209 extern __inline__ void __skb_queue_head(struct sk_buff_head *list, struct sk_buff *newsk)
210 {
211 struct sk_buff *prev, *next;
212
213 newsk->list = list;
214 list->qlen++;
215 prev = (struct sk_buff *)list;
216 next = prev->next;
217 newsk->next = next;
218 newsk->prev = prev;
219 next->prev = newsk;
220 prev->next = newsk;
221 }
222
223 extern __inline__ void skb_queue_head(struct sk_buff_head *list, struct sk_buff *newsk)
224 {
225 unsigned long flags;
226
227 save_flags(flags);
228 cli();
229 __skb_queue_head(list, newsk);
230 restore_flags(flags);
231 }
232
233
234
235
236
237 extern __inline__ void __skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk)
238 {
239 struct sk_buff *prev, *next;
240
241 newsk->list = list;
242 list->qlen++;
243 next = (struct sk_buff *)list;
244 prev = next->prev;
245 newsk->next = next;
246 newsk->prev = prev;
247 next->prev = newsk;
248 prev->next = newsk;
249 }
250
251 extern __inline__ void skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk)
252 {
253 unsigned long flags;
254
255 save_flags(flags);
256 cli();
257 __skb_queue_tail(list, newsk);
258 restore_flags(flags);
259 }
260
261
262
263
264
265 extern __inline__ struct sk_buff *__skb_dequeue(struct sk_buff_head *list)
266 {
267 struct sk_buff *next, *prev, *result;
268
269 prev = (struct sk_buff *) list;
270 next = prev->next;
271 result = NULL;
272 if (next != prev) {
273 result = next;
274 next = next->next;
275 list->qlen--;
276 next->prev = prev;
277 prev->next = next;
278 result->next = NULL;
279 result->prev = NULL;
280 result->list = NULL;
281 }
282 return result;
283 }
284
285 extern __inline__ struct sk_buff *skb_dequeue(struct sk_buff_head *list)
286 {
287 long flags;
288 struct sk_buff *result;
289
290 save_flags(flags);
291 cli();
292 result = __skb_dequeue(list);
293 restore_flags(flags);
294 return result;
295 }
296
297
298
299
300
301 extern __inline__ void __skb_insert(struct sk_buff *next, struct sk_buff *newsk)
302 {
303 struct sk_buff * prev = next->prev;
304
305 newsk->next = next;
306 newsk->prev = prev;
307 next->prev = newsk;
308 prev->next = newsk;
309 newsk->list = next->list;
310 newsk->list->qlen++;
311 }
312
313 extern __inline__ void skb_insert(struct sk_buff *old, struct sk_buff *newsk)
314 {
315 unsigned long flags;
316
317 save_flags(flags);
318 cli();
319 __skb_insert(old, newsk);
320 restore_flags(flags);
321 }
322
323
324
325
326
327 extern __inline__ void __skb_append(struct sk_buff *prev, struct sk_buff *newsk)
328 {
329 struct sk_buff * next = prev->next;
330
331 newsk->next = next;
332 newsk->prev = prev;
333 next->prev = newsk;
334 prev->next = newsk;
335 newsk->list = prev->list;
336 newsk->list->qlen++;
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_append(old, newsk);
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 panic("skput:over: %p:%d", __builtin_return_address(0),len);
396 return tmp;
397 }
398
399 extern __inline__ unsigned char *skb_push(struct sk_buff *skb, int len)
400 {
401 skb->data-=len;
402 skb->len+=len;
403 if(skb->data<skb->head)
404 panic("skpush:under: %p:%d", __builtin_return_address(0),len);
405 return skb->data;
406 }
407
408 extern __inline__ unsigned char * skb_pull(struct sk_buff *skb, int len)
409 {
410 if(len > skb->len)
411 return NULL;
412 skb->data+=len;
413 skb->len-=len;
414 return skb->data;
415 }
416
417 extern __inline__ int skb_headroom(struct sk_buff *skb)
418 {
419 return skb->data-skb->head;
420 }
421
422 extern __inline__ int skb_tailroom(struct sk_buff *skb)
423 {
424 return skb->end-skb->tail;
425 }
426
427 extern __inline__ void skb_reserve(struct sk_buff *skb, int len)
428 {
429 skb->data+=len;
430 skb->tail+=len;
431 }
432
433 extern __inline__ void skb_trim(struct sk_buff *skb, int len)
434 {
435 if(skb->len>len)
436 {
437 skb->len=len;
438 skb->tail=skb->data+len;
439 }
440 }
441
442 #endif
443
444 extern struct sk_buff * skb_recv_datagram(struct sock *sk,unsigned flags,int noblock, int *err);
445 extern int datagram_select(struct sock *sk, int sel_type, select_table *wait);
446 extern void skb_copy_datagram(struct sk_buff *from, int offset, char *to,int size);
447 extern void skb_copy_datagram_iovec(struct sk_buff *from, int offset, struct iovec *to,int size);
448 extern void skb_free_datagram(struct sock * sk, struct sk_buff *skb);
449
450 #endif
451 #endif