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