1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-22 21:23:07 +03:00

udp remote pbuf helper: honor fragmented packets (#6222)

fix for #5960 didn't take fragmented packets into account
fixes #6218
This commit is contained in:
david gauchard 2019-06-26 21:35:43 +02:00 committed by GitHub
parent 961b558a91
commit 5306976db1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,6 +34,7 @@ void esp_schedule();
#define PBUF_ALIGNER_ADJUST 4
#define PBUF_ALIGNER(x) ((void*)((((intptr_t)(x))+3)&~3))
#define PBUF_HELPER_FLAG 0xff // lwIP pbuf flag: u8_t
class UdpContext
{
@ -242,6 +243,8 @@ public:
_rx_buf = _rx_buf->next;
if (_rx_buf)
{
if (_rx_buf->flags == PBUF_HELPER_FLAG)
{
// we have interleaved informations on addresses within reception pbuf chain:
// before: (data-pbuf) -> (data-pbuf) -> (data-pbuf) -> ... in the receiving order
@ -258,6 +261,7 @@ public:
// forward in rx_buf list, next one is effective data
// current (not ref'ed) one will be pbuf_free'd with deleteme
_rx_buf = _rx_buf->next;
}
// this rx_buf is not nullptr by construction,
// ref'ing it to prevent release from the below pbuf_free(deleteme)
@ -471,6 +475,7 @@ private:
}
// construct in place
new(PBUF_ALIGNER(pb_helper->payload)) AddrHelper(srcaddr, TEMPDSTADDR, srcport);
pb->flags = PBUF_HELPER_FLAG; // mark helper pbuf
// chain it
pbuf_cat(_rx_buf, pb_helper);