首页 > 编程知识 正文

skc管理,skc管理是什么意思

时间:2023-05-04 06:35:35 阅读:256792 作者:3250

四个操作函数直接的区别,如下图:

 

1 /** 2 * skb_put - add data to a buffer 3 * @skb: buffer to use 4 * @len: amount of data to add 5 * 6 * This function extends the used data area of the buffer. If this would 7 * exceed the total buffer size the kernel will panic. A pointer to the 8 * first byte of the extra data is returned. 9 */10 /*11 向skb尾部添加数据12 */13 unsigned char *skb_put(struct sk_buff *skb, unsigned int len)14 {15 /* 获取当前skb->tail */16 unsigned char *tmp = skb_tail_pointer(skb);17 18 /* 要求skb数据区必须为线性 */19 SKB_LINEAR_ASSERT(skb);20 21 /* skb尾部增加len字节 */22 skb->tail += len;23 /* skb数据总长度增加len字节 */24 skb->len += len;25 26 /* 如果增加之后的tail > end ,则panic */27 if (unlikely(skb->tail > skb->end))28 skb_over_panic(skb, len, __builtin_return_address(0));29 30 //返回添加数据的第一个字节位置31 return tmp;32 }

 

/** * skb_push - add data to the start of a buffer * @skb: buffer to use * @len: amount of data to add * * This function extends the used data area of the buffer at the buffer * start. If this would exceed the total buffer headroom the kernel will * panic. A pointer to the first byte of the extra data is returned. *//* 向skb数据区头部添加数据*/unsigned char *skb_push(struct sk_buff *skb, unsigned int len){ /* 数据区data指针前移len字节 */ skb->data -= len; /* 数据总长度增加len字节 */ skb->len += len; /* 添加数据长度溢出过header ,panic*/ if (unlikely(skb->data<skb->head)) skb_under_panic(skb, len, __builtin_return_address(0)); /* 返回新的data指针 */ return skb->data;}

 

1 /** 2 * skb_pull - remove data from the start of a buffer 3 * @skb: buffer to use 4 * @len: amount of data to remove 5 * 6 * This function removes data from the start of a buffer, returning 7 * the memory to the headroom. A pointer to the next data in the buffer 8 * is returned. Once the data has been pulled future pushes will overwrite 9 * the old data.10 */11 /*12 从数据区头部移除数据13 */14 unsigned char *skb_pull(struct sk_buff *skb, unsigned int len)15 {16 return skb_pull_inline(skb, len);17 }

 

1 /* 2 保留头部空间,只能对空的skb使用 3 */ 4 static inline void skb_reserve(struct sk_buff *skb, int len) 5 { 6 /* 数据区data指针增加len字节*/ 7 skb->data += len; 8 /* 数据区tail指针增加len字节 */ 9 skb->tail += len;10 }

 

转载于:https://www.cnblogs.com/wanpengcoder/p/7529512.html

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。

  •  标签:  
  • skc