00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
#ifndef _LINUX_SKBUFF_H
00015
#define _LINUX_SKBUFF_H
00016
00017
#include <linux/config.h>
00018
#include <linux/kernel.h>
00019
#include <linux/sched.h>
00020
#include <linux/time.h>
00021
#include <linux/cache.h>
00022
00023
#include <asm/atomic.h>
00024
#include <asm/types.h>
00025
#include <linux/spinlock.h>
00026
#include <linux/mm.h>
00027
#include <linux/highmem.h>
00028
00029 #define HAVE_ALLOC_SKB
00030 #define HAVE_ALIGNABLE_SKB
00031 #define SLAB_SKB
00032
00033 #define CHECKSUM_NONE 0
00034 #define CHECKSUM_HW 1
00035 #define CHECKSUM_UNNECESSARY 2
00036
00037 #define SKB_DATA_ALIGN(X) (((X) + (SMP_CACHE_BYTES-1)) & ~(SMP_CACHE_BYTES-1))
00038 #define SKB_MAX_ORDER(X,ORDER) (((PAGE_SIZE<<(ORDER)) - (X) - sizeof(struct skb_shared_info))&~(SMP_CACHE_BYTES-1))
00039 #define SKB_MAX_HEAD(X) (SKB_MAX_ORDER((X),0))
00040 #define SKB_MAX_ALLOC (SKB_MAX_ORDER(0,2))
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
#ifdef __i386__
00081
#define NET_CALLER(arg) (*(((void**)&arg)-1))
00082
#else
00083 #define NET_CALLER(arg) __builtin_return_address(0)
00084
#endif
00085
00086
#ifdef CONFIG_NETFILTER
00087
struct nf_conntrack {
00088 atomic_t use;
00089 void (*destroy)(
struct nf_conntrack *);
00090 };
00091
00092
struct nf_ct_info {
00093
struct nf_conntrack *master;
00094 };
00095
#endif
00096
00097 struct sk_buff_head {
00098
00099 struct sk_buff *
next;
00100 struct sk_buff *
prev;
00101
00102 __u32
qlen;
00103 spinlock_t
lock;
00104 };
00105
00106
struct sk_buff;
00107
00108 #define MAX_SKB_FRAGS 6
00109
00110 typedef struct skb_frag_struct skb_frag_t;
00111
00112 struct skb_frag_struct
00113 {
00114 struct page *
page;
00115 __u16
page_offset;
00116 __u16
size;
00117 };
00118
00119
00120
00121
00122 struct skb_shared_info {
00123 atomic_t
dataref;
00124 unsigned int nr_frags;
00125 struct sk_buff *
frag_list;
00126 skb_frag_t frags[
MAX_SKB_FRAGS];
00127 };
00128
00129 struct sk_buff {
00130
00131 struct sk_buff *
next;
00132 struct sk_buff *
prev;
00133
00134 struct sk_buff_head *
list;
00135 struct sock *
sk;
00136 struct timeval stamp;
00137 struct net_device *
dev;
00138 struct net_device *
real_dev;
00139
00140
00141
00142
00143
00144
union
00145
{
00146 struct tcphdr *th;
00147 struct udphdr *uh;
00148 struct icmphdr *icmph;
00149 struct igmphdr *igmph;
00150 struct iphdr *ipiph;
00151 struct spxhdr *spxh;
00152 unsigned char *raw;
00153 } h;
00154
00155
00156
union
00157
{
00158 struct iphdr *iph;
00159 struct ipv6hdr *ipv6h;
00160 struct arphdr *arph;
00161 struct ipxhdr *ipxh;
00162 unsigned char *raw;
00163 } nh;
00164
00165
00166
union
00167
{
00168 struct ethhdr *ethernet;
00169 unsigned char *raw;
00170 } mac;
00171
00172 struct dst_entry *
dst;
00173
00174
00175
00176
00177
00178
00179
00180 char cb[48];
00181
00182 unsigned int len;
00183 unsigned int data_len;
00184 unsigned int csum;
00185 unsigned char __unused,
00186
cloned,
00187
pkt_type,
00188
ip_summed;
00189 __u32
priority;
00190 atomic_t
users;
00191 unsigned short protocol;
00192 unsigned short security;
00193 unsigned int truesize;
00194
00195 unsigned char *
head;
00196 unsigned char *
data;
00197 unsigned char *
tail;
00198 unsigned char *
end;
00199
00200 void (*destructor)(
struct sk_buff *);
00201
#ifdef CONFIG_NETFILTER
00202
00203
unsigned long nfmark;
00204
00205 __u32 nfcache;
00206
00207
struct nf_ct_info *nfct;
00208
#ifdef CONFIG_NETFILTER_DEBUG
00209
unsigned int nf_debug;
00210
#endif
00211
#endif
00212
00213
#if defined(CONFIG_HIPPI)
00214
union{
00215 __u32 ifield;
00216 }
private;
00217
#endif
00218
00219
#ifdef CONFIG_NET_SCHED
00220
__u32 tc_index;
00221
#endif
00222
};
00223
00224 #define SK_WMEM_MAX 65535
00225 #define SK_RMEM_MAX 65535
00226
00227
#ifdef __KERNEL__
00228
00229
00230
00231
#include <linux/slab.h>
00232
00233
#include <asm/system.h>
00234
00235
extern void __kfree_skb(
struct sk_buff *skb);
00236
extern struct sk_buff *
alloc_skb(
unsigned int size,
int priority);
00237
extern void kfree_skbmem(
struct sk_buff *skb);
00238
extern struct sk_buff *
skb_clone(
struct sk_buff *skb,
int priority);
00239
extern struct sk_buff *
skb_copy(
const struct sk_buff *skb,
int priority);
00240
extern struct sk_buff *
pskb_copy(
struct sk_buff *skb,
int gfp_mask);
00241
extern int pskb_expand_head(
struct sk_buff *skb,
int nhead,
int ntail,
int gfp_mask);
00242
extern struct sk_buff *
skb_realloc_headroom(
struct sk_buff *skb,
unsigned int headroom);
00243
extern struct sk_buff *
skb_copy_expand(
const struct sk_buff *skb,
00244
int newheadroom,
00245
int newtailroom,
00246
int priority);
00247
extern struct sk_buff *
skb_pad(
struct sk_buff *skb,
int pad);
00248 #define dev_kfree_skb(a) kfree_skb(a)
00249
extern void skb_over_panic(
struct sk_buff *skb,
int len,
void *here);
00250
extern void skb_under_panic(
struct sk_buff *skb,
int len,
void *here);
00251
00252
00253 #define skb_shinfo(SKB) ((struct skb_shared_info *)((SKB)->end))
00254
00255
00256
00257
00258
00259
00260
00261
00262 static inline int skb_queue_empty(
struct sk_buff_head *list)
00263 {
00264
return (
list->
next == (
struct sk_buff *)
list);
00265 }
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275 static inline struct sk_buff *
skb_get(
struct sk_buff *skb)
00276 {
00277 atomic_inc(&skb->
users);
00278
return skb;
00279 }
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294 static inline void kfree_skb(
struct sk_buff *skb)
00295 {
00296
if (atomic_read(&skb->
users) == 1 || atomic_dec_and_test(&skb->
users))
00297
__kfree_skb(skb);
00298 }
00299
00300
00301 static inline void kfree_skb_fast(
struct sk_buff *skb)
00302 {
00303
if (atomic_read(&skb->
users) == 1 || atomic_dec_and_test(&skb->
users))
00304
kfree_skbmem(skb);
00305 }
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316 static inline int skb_cloned(
struct sk_buff *skb)
00317 {
00318
return skb->
cloned && atomic_read(&
skb_shinfo(skb)->dataref) != 1;
00319 }
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329 static inline int skb_shared(
struct sk_buff *skb)
00330 {
00331
return (atomic_read(&skb->
users) != 1);
00332 }
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348 static inline struct sk_buff *
skb_share_check(
struct sk_buff *skb,
int pri)
00349 {
00350
if (
skb_shared(skb)) {
00351
struct sk_buff *nskb;
00352 nskb =
skb_clone(skb, pri);
00353
kfree_skb(skb);
00354
return nskb;
00355 }
00356
return skb;
00357 }
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381 static inline struct sk_buff *
skb_unshare(
struct sk_buff *skb,
int pri)
00382 {
00383
struct sk_buff *nskb;
00384
if(!
skb_cloned(skb))
00385
return skb;
00386 nskb=
skb_copy(skb, pri);
00387
kfree_skb(skb);
00388
return nskb;
00389 }
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405 static inline struct sk_buff *
skb_peek(
struct sk_buff_head *list_)
00406 {
00407
struct sk_buff *
list = ((
struct sk_buff *)list_)->
next;
00408
if (
list == (
struct sk_buff *)list_)
00409
list = NULL;
00410
return list;
00411 }
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427 static inline struct sk_buff *
skb_peek_tail(
struct sk_buff_head *list_)
00428 {
00429
struct sk_buff *
list = ((
struct sk_buff *)list_)->
prev;
00430
if (
list == (
struct sk_buff *)list_)
00431
list = NULL;
00432
return list;
00433 }
00434
00435
00436
00437
00438
00439
00440
00441
00442 static inline __u32
skb_queue_len(
struct sk_buff_head *list_)
00443 {
00444
return(list_->
qlen);
00445 }
00446
00447 static inline void skb_queue_head_init(
struct sk_buff_head *list)
00448 {
00449 spin_lock_init(&
list->
lock);
00450
list->
prev = (
struct sk_buff *)
list;
00451
list->
next = (
struct sk_buff *)
list;
00452
list->
qlen = 0;
00453 }
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473 static inline void __skb_queue_head(
struct sk_buff_head *list,
struct sk_buff *newsk)
00474 {
00475
struct sk_buff *prev, *next;
00476
00477 newsk->
list =
list;
00478
list->
qlen++;
00479 prev = (
struct sk_buff *)
list;
00480 next = prev->
next;
00481 newsk->
next = next;
00482 newsk->
prev = prev;
00483 next->
prev = newsk;
00484 prev->
next = newsk;
00485 }
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500 static inline void skb_queue_head(
struct sk_buff_head *list,
struct sk_buff *newsk)
00501 {
00502
unsigned long flags;
00503
00504 spin_lock_irqsave(&
list->
lock, flags);
00505
__skb_queue_head(
list, newsk);
00506 spin_unlock_irqrestore(&
list->
lock, flags);
00507 }
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521 static inline void __skb_queue_tail(
struct sk_buff_head *list,
struct sk_buff *newsk)
00522 {
00523
struct sk_buff *prev, *next;
00524
00525 newsk->
list =
list;
00526
list->
qlen++;
00527 next = (
struct sk_buff *)
list;
00528 prev = next->
prev;
00529 newsk->
next = next;
00530 newsk->
prev = prev;
00531 next->
prev = newsk;
00532 prev->
next = newsk;
00533 }
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547 static inline void skb_queue_tail(
struct sk_buff_head *list,
struct sk_buff *newsk)
00548 {
00549
unsigned long flags;
00550
00551 spin_lock_irqsave(&
list->
lock, flags);
00552
__skb_queue_tail(
list, newsk);
00553 spin_unlock_irqrestore(&
list->
lock, flags);
00554 }
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565 static inline struct sk_buff *
__skb_dequeue(
struct sk_buff_head *list)
00566 {
00567
struct sk_buff *next, *prev, *result;
00568
00569 prev = (
struct sk_buff *)
list;
00570 next = prev->
next;
00571 result = NULL;
00572
if (next != prev) {
00573 result = next;
00574 next = next->
next;
00575
list->
qlen--;
00576 next->prev = prev;
00577 prev->next = next;
00578 result->next = NULL;
00579 result->prev = NULL;
00580 result->list = NULL;
00581 }
00582
return result;
00583 }
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594 static inline struct sk_buff *
skb_dequeue(
struct sk_buff_head *list)
00595 {
00596
unsigned long flags;
00597
struct sk_buff *result;
00598
00599 spin_lock_irqsave(&
list->
lock, flags);
00600 result =
__skb_dequeue(
list);
00601 spin_unlock_irqrestore(&
list->
lock, flags);
00602
return result;
00603 }
00604
00605
00606
00607
00608
00609 static inline void __skb_insert(
struct sk_buff *newsk,
00610
struct sk_buff * prev,
struct sk_buff *next,
00611
struct sk_buff_head * list)
00612 {
00613 newsk->
next = next;
00614 newsk->
prev = prev;
00615 next->
prev = newsk;
00616 prev->
next = newsk;
00617 newsk->
list =
list;
00618
list->
qlen++;
00619 }
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631 static inline void skb_insert(
struct sk_buff *old,
struct sk_buff *newsk)
00632 {
00633
unsigned long flags;
00634
00635 spin_lock_irqsave(&old->
list->
lock, flags);
00636
__skb_insert(newsk, old->
prev, old, old->
list);
00637 spin_unlock_irqrestore(&old->
list->
lock, flags);
00638 }
00639
00640
00641
00642
00643
00644 static inline void __skb_append(
struct sk_buff *old,
struct sk_buff *newsk)
00645 {
00646
__skb_insert(newsk, old, old->
next, old->
list);
00647 }
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660 static inline void skb_append(
struct sk_buff *old,
struct sk_buff *newsk)
00661 {
00662
unsigned long flags;
00663
00664 spin_lock_irqsave(&old->
list->
lock, flags);
00665
__skb_append(old, newsk);
00666 spin_unlock_irqrestore(&old->
list->
lock, flags);
00667 }
00668
00669
00670
00671
00672
00673
00674 static inline void __skb_unlink(
struct sk_buff *skb,
struct sk_buff_head *list)
00675 {
00676
struct sk_buff * next, * prev;
00677
00678
list->
qlen--;
00679 next = skb->
next;
00680 prev = skb->
prev;
00681 skb->
next = NULL;
00682 skb->
prev = NULL;
00683 skb->
list = NULL;
00684 next->
prev = prev;
00685 prev->
next = next;
00686 }
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701 static inline void skb_unlink(
struct sk_buff *skb)
00702 {
00703
struct sk_buff_head *
list = skb->
list;
00704
00705
if(
list) {
00706
unsigned long flags;
00707
00708 spin_lock_irqsave(&
list->
lock, flags);
00709
if(skb->
list ==
list)
00710
__skb_unlink(skb, skb->
list);
00711 spin_unlock_irqrestore(&
list->
lock, flags);
00712 }
00713 }
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726 static inline struct sk_buff *
__skb_dequeue_tail(
struct sk_buff_head *list)
00727 {
00728
struct sk_buff *skb =
skb_peek_tail(
list);
00729
if (skb)
00730
__skb_unlink(skb,
list);
00731
return skb;
00732 }
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743 static inline struct sk_buff *
skb_dequeue_tail(
struct sk_buff_head *list)
00744 {
00745
unsigned long flags;
00746
struct sk_buff *result;
00747
00748 spin_lock_irqsave(&
list->
lock, flags);
00749 result =
__skb_dequeue_tail(
list);
00750 spin_unlock_irqrestore(&
list->
lock, flags);
00751
return result;
00752 }
00753
00754 static inline int skb_is_nonlinear(
const struct sk_buff *skb)
00755 {
00756
return skb->
data_len;
00757 }
00758
00759 static inline unsigned int skb_headlen(
const struct sk_buff *skb)
00760 {
00761
return skb->
len - skb->
data_len;
00762 }
00763
00764 #define SKB_PAGE_ASSERT(skb) do { if (skb_shinfo(skb)->nr_frags) out_of_line_bug(); } while (0)
00765 #define SKB_FRAG_ASSERT(skb) do { if (skb_shinfo(skb)->frag_list) out_of_line_bug(); } while (0)
00766 #define SKB_LINEAR_ASSERT(skb) do { if (skb_is_nonlinear(skb)) out_of_line_bug(); } while (0)
00767
00768
00769
00770
00771
00772 static inline unsigned char *
__skb_put(
struct sk_buff *skb,
unsigned int len)
00773 {
00774
unsigned char *tmp=skb->
tail;
00775
SKB_LINEAR_ASSERT(skb);
00776 skb->
tail+=len;
00777 skb->
len+=len;
00778
return tmp;
00779 }
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791 static inline unsigned char *
skb_put(
struct sk_buff *skb,
unsigned int len)
00792 {
00793
unsigned char *tmp=skb->
tail;
00794
SKB_LINEAR_ASSERT(skb);
00795 skb->
tail+=len;
00796 skb->
len+=len;
00797
if(skb->
tail>skb->
end) {
00798
skb_over_panic(skb, len, current_text_addr());
00799 }
00800
return tmp;
00801 }
00802
00803 static inline unsigned char *
__skb_push(
struct sk_buff *skb,
unsigned int len)
00804 {
00805 skb->
data-=len;
00806 skb->
len+=len;
00807
return skb->
data;
00808 }
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820 static inline unsigned char *
skb_push(
struct sk_buff *skb,
unsigned int len)
00821 {
00822 skb->
data-=len;
00823 skb->
len+=len;
00824
if(skb->
data<skb->
head) {
00825
skb_under_panic(skb, len, current_text_addr());
00826 }
00827
return skb->
data;
00828 }
00829
00830 static inline char *
__skb_pull(
struct sk_buff *skb,
unsigned int len)
00831 {
00832 skb->
len-=len;
00833
if (skb->
len < skb->
data_len)
00834 out_of_line_bug();
00835
return skb->
data+=len;
00836 }
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849 static inline unsigned char *
skb_pull(
struct sk_buff *skb,
unsigned int len)
00850 {
00851
if (len > skb->
len)
00852
return NULL;
00853
return __skb_pull(skb,len);
00854 }
00855
00856
extern unsigned char *
__pskb_pull_tail(
struct sk_buff *skb,
int delta);
00857
00858 static inline char *
__pskb_pull(
struct sk_buff *skb,
unsigned int len)
00859 {
00860
if (len >
skb_headlen(skb) &&
00861
__pskb_pull_tail(skb, len-
skb_headlen(skb)) == NULL)
00862
return NULL;
00863 skb->len -= len;
00864
return skb->data += len;
00865 }
00866
00867 static inline unsigned char *
pskb_pull(
struct sk_buff *skb,
unsigned int len)
00868 {
00869
if (len > skb->
len)
00870
return NULL;
00871
return __pskb_pull(skb,len);
00872 }
00873
00874 static inline int pskb_may_pull(
struct sk_buff *skb,
unsigned int len)
00875 {
00876
if (len <=
skb_headlen(skb))
00877
return 1;
00878
if (len > skb->
len)
00879
return 0;
00880
return (
__pskb_pull_tail(skb, len-
skb_headlen(skb)) != NULL);
00881 }
00882
00883
00884
00885
00886
00887
00888
00889
00890 static inline int skb_headroom(
const struct sk_buff *skb)
00891 {
00892
return skb->
data-skb->
head;
00893 }
00894
00895
00896
00897
00898
00899
00900
00901
00902 static inline int skb_tailroom(
const struct sk_buff *skb)
00903 {
00904
return skb_is_nonlinear(skb) ? 0 : skb->
end-skb->
tail;
00905 }
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916 static inline void skb_reserve(
struct sk_buff *skb,
unsigned int len)
00917 {
00918 skb->
data+=len;
00919 skb->
tail+=len;
00920 }
00921
00922
extern int ___pskb_trim(
struct sk_buff *skb,
unsigned int len,
int realloc);
00923
00924 static inline void __skb_trim(
struct sk_buff *skb,
unsigned int len)
00925 {
00926
if (!skb->
data_len) {
00927 skb->
len = len;
00928 skb->
tail = skb->
data+len;
00929 }
else {
00930
___pskb_trim(skb, len, 0);
00931 }
00932 }
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943 static inline void skb_trim(
struct sk_buff *skb,
unsigned int len)
00944 {
00945
if (skb->
len > len) {
00946
__skb_trim(skb, len);
00947 }
00948 }
00949
00950
00951 static inline int __pskb_trim(
struct sk_buff *skb,
unsigned int len)
00952 {
00953
if (!skb->
data_len) {
00954 skb->
len = len;
00955 skb->
tail = skb->
data+len;
00956
return 0;
00957 }
else {
00958
return ___pskb_trim(skb, len, 1);
00959 }
00960 }
00961
00962 static inline int pskb_trim(
struct sk_buff *skb,
unsigned int len)
00963 {
00964
if (len < skb->
len)
00965
return __pskb_trim(skb, len);
00966
return 0;
00967 }
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979 static inline void skb_orphan(
struct sk_buff *skb)
00980 {
00981
if (skb->
destructor)
00982 skb->
destructor(skb);
00983 skb->
destructor = NULL;
00984 skb->
sk = NULL;
00985 }
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997 static inline void skb_queue_purge(
struct sk_buff_head *list)
00998 {
00999
struct sk_buff *skb;
01000
while ((skb=
skb_dequeue(
list))!=NULL)
01001
kfree_skb(skb);
01002 }
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014 static inline void __skb_queue_purge(
struct sk_buff_head *list)
01015 {
01016
struct sk_buff *skb;
01017
while ((skb=
__skb_dequeue(
list))!=NULL)
01018
kfree_skb(skb);
01019 }
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034 static inline struct sk_buff *
__dev_alloc_skb(
unsigned int length,
01035
int gfp_mask)
01036 {
01037
struct sk_buff *skb;
01038
01039 skb =
alloc_skb(length+16, gfp_mask);
01040
if (skb)
01041
skb_reserve(skb,16);
01042
return skb;
01043 }
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058 static inline struct sk_buff *
dev_alloc_skb(
unsigned int length)
01059 {
01060
return __dev_alloc_skb(length, GFP_ATOMIC);
01061 }
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
static inline int
01077 skb_cow(
struct sk_buff *skb,
unsigned int headroom)
01078 {
01079
int delta = (headroom > 16 ? headroom : 16) -
skb_headroom(skb);
01080
01081
if (delta < 0)
01082 delta = 0;
01083
01084
if (delta ||
skb_cloned(skb))
01085
return pskb_expand_head(skb, (delta+15)&~15, 0, GFP_ATOMIC);
01086
return 0;
01087 }
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101 static inline struct sk_buff *
skb_padto(
struct sk_buff *skb,
unsigned int len)
01102 {
01103
unsigned int size = skb->
len;
01104
if(likely(size >= len))
01105
return skb;
01106
return skb_pad(skb, len-size);
01107 }
01108
01109
01110
01111
01112
01113
01114
01115
01116
int skb_linearize(
struct sk_buff *skb,
int gfp);
01117
01118 static inline void *
kmap_skb_frag(
const skb_frag_t *frag)
01119 {
01120
#ifdef CONFIG_HIGHMEM
01121
if (in_irq())
01122 out_of_line_bug();
01123
01124 local_bh_disable();
01125
#endif
01126
return kmap_atomic(frag->
page, KM_SKB_DATA_SOFTIRQ);
01127 }
01128
01129 static inline void kunmap_skb_frag(
void *vaddr)
01130 {
01131 kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
01132
#ifdef CONFIG_HIGHMEM
01133
local_bh_enable();
01134
#endif
01135
}
01136
01137 #define skb_queue_walk(queue, skb) \
01138
for (skb = (queue)->next; \
01139
(skb != (struct sk_buff *)(queue)); \
01140
skb=skb->next)
01141
01142
01143
extern struct sk_buff *
skb_recv_datagram(
struct sock *sk,
unsigned flags,
int noblock,
int *err);
01144
extern unsigned int datagram_poll(
struct file *file,
struct socket *
sock,
struct poll_table_struct *wait);
01145
extern int skb_copy_datagram(
const struct sk_buff *from,
int offset,
char *to,
int size);
01146
extern int skb_copy_datagram_iovec(
const struct sk_buff *from,
int offset,
struct iovec *to,
int size);
01147
extern int skb_copy_and_csum_datagram(
const struct sk_buff *skb,
int offset, u8 *to,
int len,
unsigned int *csump);
01148
extern int skb_copy_and_csum_datagram_iovec(
const struct sk_buff *skb,
int hlen,
struct iovec *iov);
01149
extern void skb_free_datagram(
struct sock * sk,
struct sk_buff *skb);
01150
01151
extern unsigned int skb_checksum(
const struct sk_buff *skb,
int offset,
int len,
unsigned int csum);
01152
extern int skb_copy_bits(
const struct sk_buff *skb,
int offset,
void *to,
int len);
01153
extern unsigned int skb_copy_and_csum_bits(
const struct sk_buff *skb,
int offset, u8 *to,
int len,
unsigned int csum);
01154
extern void skb_copy_and_csum_dev(
const struct sk_buff *skb, u8 *to);
01155
01156
extern void skb_init(
void);
01157
extern void skb_add_mtu(
int mtu);
01158
01159
#ifdef CONFIG_NETFILTER
01160
static inline void
01161 nf_conntrack_put(
struct nf_ct_info *nfct)
01162 {
01163
if (nfct && atomic_dec_and_test(&nfct->master->use))
01164 nfct->master->destroy(nfct->master);
01165 }
01166
static inline void
01167 nf_conntrack_get(
struct nf_ct_info *nfct)
01168 {
01169
if (nfct)
01170 atomic_inc(&nfct->master->use);
01171 }
01172
#endif
01173
01174
#endif
01175
#endif