原文地址: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 */
};
|