一。skbuff的结构图如下
二.Basic functions for sk_buff
skb_headroom(), skb_tailroom()
Prototype / Description
int skb_headroom(const struct sk_buff *skb);
bytes at buffer head
int skb_tailroom(const struct sk_buff *skb);
bytes at buffer
Image
skb_reserve()
Prototype
void skb_reserve(struct sk_buff *skb, unsigned int len);
Description
adjust headroom
Image
skb_push()
Prototype
unsigned char *skb_push(struct sk_buff *skb, unsigned int len);
Description
add data to the start of a buffer
Image
skb_pull()
Prototype
unsigned char *skb_pull(struct sk_buff *skb, unsigned int len);
Description
remove data from the start of a buffer
Image
skb_put()
Prototype
unsigned char *skb_put(struct sk_buff *skb, unsigned int len);
Description
add data to a buffer
Image
skb_trim()
Prototype
void skb_trim(struct sk_buff *skb, unsigned int len);
Description
remove end from a buffer
Image
三.List of sk_buff
Prototype / Description
__u32 skb_queue_len(const struct sk_buff_head *list_);
get queue length
struct sk_buff *skb_peek(struct sk_buff_head *list);
get pointer to the head element
struct sk_buff *skb_peek_tail(struct sk_buff_head *list);
get pointer to the tail element
Image
skb_queue_head()
Prototype
void skb_queue_head(struct sk_buff_head *list, struct sk_buff *newsk);
Description
queue a buffer at the list head
Image
skb_queue_tail()
Prototype
void skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk);
Description
queue a buffer at the list ta
Image
skb_dequeue()
Prototype
struct sk_buff *skb_dequeue(struct sk_buff_head *list);
Description
remove from the head of the queue
Image
skb_dequeue_tail()
Prototype
struct sk_buff *skb_dequeue_tail(struct sk_buff_head *list);
Description
remove from the tail of the queue
Image
skb_insert()
Prototype
void skb_insert(struct sk_buff *old, struct sk_buff *newsk);
Description
insert a buffer
Image
skb_append()
Prototype
void skb_append(struct sk_buff *old, struct sk_buff *newsk);
Description
append a buffer
Image
skb_unlink()
Prototype
void skb_unlink(struct sk_buff *skb); Description
remove a buffer from a list
Image
![](https://i-blog.csdnimg.cn/blog_migrate/bb5e61c71e24d00ea6e9d00a9c487a6a.png)
二.Basic functions for sk_buff
skb_headroom(), skb_tailroom()
Prototype / Description
int skb_headroom(const struct sk_buff *skb);
bytes at buffer head
int skb_tailroom(const struct sk_buff *skb);
bytes at buffer
Image
![](https://i-blog.csdnimg.cn/blog_migrate/7ec114fb741e967b7c150ee4ef984e09.png)
skb_reserve()
Prototype
void skb_reserve(struct sk_buff *skb, unsigned int len);
Description
adjust headroom
Image
![](https://i-blog.csdnimg.cn/blog_migrate/4fe03a45e3f95f1c14eee312bf0bb883.png)
skb_push()
Prototype
unsigned char *skb_push(struct sk_buff *skb, unsigned int len);
Description
add data to the start of a buffer
Image
![](https://i-blog.csdnimg.cn/blog_migrate/1946fec2bf33b11bbef9242b57d07693.png)
skb_pull()
Prototype
unsigned char *skb_pull(struct sk_buff *skb, unsigned int len);
Description
remove data from the start of a buffer
Image
![](https://i-blog.csdnimg.cn/blog_migrate/f8f9f4bae28d62b83746f2e67e761d47.png)
skb_put()
Prototype
unsigned char *skb_put(struct sk_buff *skb, unsigned int len);
Description
add data to a buffer
Image
![](https://i-blog.csdnimg.cn/blog_migrate/0e2d5bec766a005c812e4e9a78318775.png)
skb_trim()
Prototype
void skb_trim(struct sk_buff *skb, unsigned int len);
Description
remove end from a buffer
Image
![](https://i-blog.csdnimg.cn/blog_migrate/e0d3e9c8ace725974026cd30a4f74bed.png)
三.List of sk_buff
Prototype / Description
__u32 skb_queue_len(const struct sk_buff_head *list_);
get queue length
struct sk_buff *skb_peek(struct sk_buff_head *list);
get pointer to the head element
struct sk_buff *skb_peek_tail(struct sk_buff_head *list);
get pointer to the tail element
Image
![](https://i-blog.csdnimg.cn/blog_migrate/70b08193a7748558393bfdb9b5aa599c.png)
skb_queue_head()
Prototype
void skb_queue_head(struct sk_buff_head *list, struct sk_buff *newsk);
Description
queue a buffer at the list head
Image
![](https://i-blog.csdnimg.cn/blog_migrate/8abe2fd540d61f9a317bbdbcfe5f73d4.png)
skb_queue_tail()
Prototype
void skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk);
Description
queue a buffer at the list ta
Image
![](https://i-blog.csdnimg.cn/blog_migrate/f191c62df4b465448be32b30d12c1e8b.png)
skb_dequeue()
Prototype
struct sk_buff *skb_dequeue(struct sk_buff_head *list);
Description
remove from the head of the queue
Image
![](https://i-blog.csdnimg.cn/blog_migrate/4e70260a10b642588f6c0c2a2419371a.png)
skb_dequeue_tail()
Prototype
struct sk_buff *skb_dequeue_tail(struct sk_buff_head *list);
Description
remove from the tail of the queue
Image
![](https://i-blog.csdnimg.cn/blog_migrate/674a154434415c3a4989ec6b88cc98b4.png)
skb_insert()
Prototype
void skb_insert(struct sk_buff *old, struct sk_buff *newsk);
Description
insert a buffer
Image
![](https://i-blog.csdnimg.cn/blog_migrate/bc6904f6a30c41ba0393115973b1d6ab.png)
skb_append()
Prototype
void skb_append(struct sk_buff *old, struct sk_buff *newsk);
Description
append a buffer
Image
![](https://i-blog.csdnimg.cn/blog_migrate/39f4b88478085a4d1ee1e239ecaf1279.png)
skb_unlink()
Prototype
void skb_unlink(struct sk_buff *skb); Description
remove a buffer from a list
Image
![](https://i-blog.csdnimg.cn/blog_migrate/b1b38af083ff713e888a1bd31836dec5.png)