'lwip: using LWIP_PBUF_CUSTOM_DATA together with socket api

I'm trying to port a project to lwip. This project uses BSD sockets calls, so first, I used lwip's socket APIs.
The project I'm trying to port has to deal with packet timestamping, that's why I used LWIP_PBUF_CUSTOM_DATA as explained here https://savannah.nongnu.org/bugs/?55078
This way I can "enrich" the pbuf structure with metadata fields of my own.

The question is: how do I retrieve my metadata using the socket API? For example how do I get a read pbuf? Or how do I convert the socket to a netconn?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source