打印
[应用相关]

lwIP协议栈的pbuf结构体

[复制链接]
943|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
wowu|  楼主 | 2018-9-15 22:31 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
原文地址:https://blog.csdn.net/zhzht19861011/article/details/6591252

pbuf结构体位于src/include/lwip/pbuf.h中

以太网中断收到的数据就先存放到这个结构体组成的数据链中,然后将它交付给上层协议.

这个结构体可以说是无处不在.



  • struct pbuf {



  •   /** next pbuf in singly linked pbuf chain 指向下一个pbuf*/



  •   struct pbuf *next;







  •   /** pointer to the actual data in the buffer 指向有效数据区*/



  •   void *payload;







  •   /**



  •    * total length of this buffer and all next buffers in chain



  •    * belonging to the same packet.



  •    * 数据链的总长度



  •    * For non-queue packet chains this is the invariant:



  •    * p->tot_len == p->len + (p->next? p->next->tot_len: 0)



  •    */



  •   u16_t tot_len;







  •   /** length of this buffer 这个缓冲区的长度*/



  •   u16_t len;  







  •   /** pbuf_type as u8_t instead of enum to save space



  •       pbuf的类型,有PBUF_RAM、PBUF_ROM、PBUF_REF和PBUF_POOL,这些类型指明指针payload指向的数据的类型*/



  •   u8_t /*pbuf_type*/ type;







  •   /** misc flags 混合标志位,每一位代表一个标志*/



  •   u8_t flags;







  •   /**



  •    * the reference count always equals the number of pointers



  •    * that refer to this pbuf. This can be pointers from an application,



  •    * the stack itself, or pbuf->next pointers from a chain.



  •      统计有多少个指针指向这个pbuf.这些指针可能是应用程序的指针,



  •          协议栈自己的指针或者数据链中的pbuf->next指针,ref为0时,才可以释放该pbuf







  •    */



  •   u16_t ref;







  • #if LWIP_PTPD                   //如果使能了网络测量和控制系统的精密时钟同步协议标准



  •   /* the time at which the packet was received, seconds component */



  •   u32_t time_s;







  •   /* the time at which the packet was received, nanoseconds component */



  •   u32_t time_ns;



  • #endif /* #if LWIP_PTPD */



  • };









沙发
mmuuss586| | 2018-12-23 19:51 | 只看该作者
感谢分享;

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

80

主题

3892

帖子

1

粉丝