mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-09-30 20:47:22 +00:00
Current implementation of hs flow control uses mbuf user header to associate mbuf with a connection handle. This unfortunately does not work well in most cases. One major problem is that host can reassemble data. This is done by os_mbuf_concat() which strips packet header from 2nd mbuf and this means we basically lose connection handle information. While this problem can be worked around by some extra mbuf counting, another way to lose connection handle information is to basically pass received buffer to application. For example, OIC uses user header for own purposes so it will either overwrite connection handle information (if our user header is large enough for OIC) or strip our packet header if it decides to use own mbuf for packet header. So it's better not to rely on user header to track store connection handle information. This patch uses a simple private array to store connection handle for each mbuf - array is indexed by mbuf index in a mempool. This is a bit of a hack since index of an mbuf in a mempool has to be calculated using mempool buffer address and block size, but I do not really see any simple alternative here.