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