Skip to content

Commit

Permalink
Fix bug #60681: Initialize custom data in pbuf struct
Browse files Browse the repository at this point in the history
Add a #define that users can use to initialize LWIP_PBUF_CUSTOM_DATA fields.

see patch #10072
idea by Thomas Kindler <mail_lwip@t-kindler.de>
  • Loading branch information
Thomas Kindler authored and goldsimon committed Oct 12, 2023
1 parent f5e7e8e commit de0b978
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/pbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ pbuf_init_alloced_pbuf(struct pbuf *p, void *payload, u16_t tot_len, u16_t len,
p->flags = flags;
p->ref = 1;
p->if_idx = NETIF_NO_INDEX;

LWIP_PBUF_CUSTOM_DATA_INIT(p);
}

/**
Expand Down
12 changes: 12 additions & 0 deletions src/include/lwip/opt.h
Original file line number Diff line number Diff line change
Expand Up @@ -1628,10 +1628,22 @@
/**
* LWIP_PBUF_CUSTOM_DATA: Store private data on pbufs (e.g. timestamps)
* This extends struct pbuf so user can store custom data on every pbuf.
* e.g.:
* \#define LWIP_PBUF_CUSTOM_DATA u32_t myref;
*/
#if !defined LWIP_PBUF_CUSTOM_DATA || defined __DOXYGEN__
#define LWIP_PBUF_CUSTOM_DATA
#endif

/**
* LWIP_PBUF_CUSTOM_DATA_INIT: Initialize private data on pbufs.
* e.g. for the above example definition:
* \#define LWIP_PBUF_CUSTOM_DATA(p) (p)->myref = 0
*/
#if !defined LWIP_PBUF_CUSTOM_DATA_INIT || defined __DOXYGEN__
#define LWIP_PBUF_CUSTOM_DATA_INIT(p)
#endif

/**
* @}
*/
Expand Down

0 comments on commit de0b978

Please sign in to comment.