lwIP协议栈的pbuf结构体

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 */
};


 

  • 4
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值