lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Data passed to UDP receive callback


From: Ben Hastings
Subject: [lwip-users] Data passed to UDP receive callback
Date: Sun, 9 Aug 2009 16:13:37 -0400

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]