lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Raw UDP API, connecting to a multicast IP address results i


From: Bilal Majeed
Subject: [lwip-users] Raw UDP API, connecting to a multicast IP address results in dropped messages
Date: Wed, 25 Mar 2020 16:54:23 -0400

Hi,

 

I noticed a bug while trying to integrate lwIP IPv6 into my code. I'm not sure if its a bug or if I'm mistaken and utilizing the API incorrectly. The application that I am writing calls for sending a msg to a multicast address and

receiving a response back from some server.

 

To accomplish this I setup my UDP connection as so:

 

static ip_addr_t mulitcast_ip_addr;

struct udp_pcb * udp_pcb = udp_new();

ip6_addr_set_allnodes_linklocal(&mulitcast_ip_addr);

udp_bind(udp_pcb, IP_ADDR_ANY, 0);

udp_connect(udp_pcb, &mulitcast_ip_addr, 7);

 

I noticed that when I would receive a response message from some device in the *udp_input()* function it performs the following check on line 289 of udp.c in the git-head:

 

/* compare PCB remote addr+port to UDP source addr+port */

if ((pcb->remote_port == src) &&

    (ip_addr_isany_val(pcb->remote_ip) ||

     ip_addr_cmp(&pcb->remote_ip, ip_current_src_addr()))) {

  ...

}

 

Here it just checks if the remote ip address ISANY or if the remote address matches the current source address. Since I had set the remote address to multicast (FF02::1) this if statement would evaluate to false just set pcb to NULL which in return causes incoming packets to be ignored.

 

For my application I'm using only one udp pcb, so a workaround that I used instead was after calling *udp_connect()* to set the remote ip and port, I called *udp_clear_flags(udp_pcb, UDP_FLAGS_CONNECTED)*. This allowed the *udp_input()* function to  use the first unconnected pcb in the pcb list (and since I have only one it picks that every time).

 

Going forward I wouldn't prefer using this workaround as its not universal. It is possible that I am using the udp api incorrectly and there is a different way to do what I want, perhaps someone could guide me in the right direction.

 

Thanks


reply via email to

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