@@ -34,6 +34,7 @@ void esp_schedule();
34
34
35
35
#define PBUF_ALIGNER_ADJUST 4
36
36
#define PBUF_ALIGNER (x ) ((void *)((((intptr_t )(x))+3 )&~3 ))
37
+ #define PBUF_HELPER_FLAG 0xff // lwIP pbuf flag: u8_t
37
38
38
39
class UdpContext
39
40
{
@@ -243,21 +244,24 @@ class UdpContext
243
244
244
245
if (_rx_buf)
245
246
{
246
- // we have interleaved informations on addresses within reception pbuf chain:
247
- // before: (data-pbuf) -> (data-pbuf) -> (data-pbuf) -> ... in the receiving order
248
- // now: (address-info-pbuf -> data-pbuf) -> (address-info-pbuf -> data-pbuf) -> ...
247
+ if (_rx_buf->flags == PBUF_HELPER_FLAG)
248
+ {
249
+ // we have interleaved informations on addresses within reception pbuf chain:
250
+ // before: (data-pbuf) -> (data-pbuf) -> (data-pbuf) -> ... in the receiving order
251
+ // now: (address-info-pbuf -> data-pbuf) -> (address-info-pbuf -> data-pbuf) -> ...
249
252
250
- // so the first rx_buf contains an address helper,
251
- // copy it to "current address"
252
- auto helper = (AddrHelper*)PBUF_ALIGNER (_rx_buf->payload );
253
- _currentAddr = *helper;
253
+ // so the first rx_buf contains an address helper,
254
+ // copy it to "current address"
255
+ auto helper = (AddrHelper*)PBUF_ALIGNER (_rx_buf->payload );
256
+ _currentAddr = *helper;
254
257
255
- // destroy the helper in the about-to-be-released pbuf
256
- helper->~AddrHelper ();
258
+ // destroy the helper in the about-to-be-released pbuf
259
+ helper->~AddrHelper ();
257
260
258
- // forward in rx_buf list, next one is effective data
259
- // current (not ref'ed) one will be pbuf_free'd with deleteme
260
- _rx_buf = _rx_buf->next ;
261
+ // forward in rx_buf list, next one is effective data
262
+ // current (not ref'ed) one will be pbuf_free'd with deleteme
263
+ _rx_buf = _rx_buf->next ;
264
+ }
261
265
262
266
// this rx_buf is not nullptr by construction,
263
267
// ref'ing it to prevent release from the below pbuf_free(deleteme)
@@ -471,6 +475,7 @@ class UdpContext
471
475
}
472
476
// construct in place
473
477
new (PBUF_ALIGNER (pb_helper->payload )) AddrHelper (srcaddr, TEMPDSTADDR, srcport);
478
+ pb->flags = PBUF_HELPER_FLAG; // mark helper pbuf
474
479
// chain it
475
480
pbuf_cat (_rx_buf, pb_helper);
476
481
0 commit comments