The following receive callback does not work properly:

static void UDP_Echo(void *arg, struct udp_pcb *upcb, struct pbuf *p,
struct ip_addr *addr, u16_t port) {
  udp_sendto(upcb, p, addr, port);
  pbuf_free(p);
}

The following code, which makes a copy of the received packet's source
address, works just fine:

static void UDP_Echo(void *arg, struct udp_pcb *upcb, struct pbuf *p,
struct ip_addr *addr, u16_t port) {
  struct ip_addr new_addr = *addr;
  udp_sendto(upcb, p, &new_addr, port);
  pbuf_free(p);
}

It looks like the source address of the received packet is changed on
line 591 of ip.c, when it sets the source address of the outgoing
packet:
  ip_addr_set(&(iphdr->src), src);

Is this correct behavior?  Shouldn't the source address of a received
packet be valid for the length of the callback, no matter what I do with
the pbuf?

Ben Hastings


_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to