-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
Using lwip raw udp API, notice that only one UDP echo works then the device echoes back improperly after that (UDP packet seems to be malformed, missing payload)
#include "lwip/api.h"
#include "lwip/udp.h"
void udp_echo_recv(void *arg,
struct udp_pcb *pcb, struct pbuf *p,
const ip_addr_t *addr, u16_t port)
{
if (p != NULL) {
/* send received packet back to sender */
udp_sendto(pcb, p, addr, port);
/* free the pbuf */
pbuf_free(p);
}
}
void udp_echo_init(void)
{
struct udp_pcb * pcb;
/* get new pcb */
pcb = udp_new();
if (pcb == NULL) {
LWIP_DEBUGF(UDP_DEBUG, ("udp_new failed!\n"));
return;
}
/* bind to any IP address on port 7 */
if (udp_bind(pcb, IP_ADDR_ANY, 7) != ERR_OK) {
LWIP_DEBUGF(UDP_DEBUG, ("udp_bind failed!\n"));
return;
}
/* set udp_echo_recv() as callback function
for received packets */
udp_recv(pcb, udp_echo_recv, NULL);
}tcpdump after asking to echo '123':
00:09:21.434673 IP (tos 0x0, ttl 64, id 11414, offset 0, flags [none], proto UDP (17), length 32)
192.168.2.2.49738 > 192.168.2.179.echo: [udp sum ok] UDP, length 4
0x0000: 5ccf 7f3a 08ba 58b0 3561 d381 0800 4500 \..:..X.5a....E.
0x0010: 0020 2c96 0000 4011 c831 c0a8 0202 c0a8 ..,...@..1......
0x0020: 02b3 c24a 0007 000c 5342 3132 330a ...J....SB123.
00:09:21.636659 IP truncated-ip - 4 bytes missing! (tos 0x0, ttl 255, id 5, offset 0, flags [none], proto UDP (17), length 32)
192.168.2.179.echo > 192.168.2.2.49738: UDP, length 4
0x0000: 58b0 3561 d381 5ccf 7f3a 08ba 0800 4500 X.5a..\..:....E.
0x0010: 0020 0005 0000 ff11 35c2 c0a8 02b3 c0a8 ........5.......
0x0020: 0202 0007 c24a 000c 5342
Full code here
Any thoughts?
Metadata
Metadata
Assignees
Labels
No labels