Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDP broadcasts do not reach bound pcbs #6

Open
tabascoeye opened this issue Jun 5, 2014 · 1 comment
Open

UDP broadcasts do not reach bound pcbs #6

tabascoeye opened this issue Jun 5, 2014 · 1 comment
Labels

Comments

@tabascoeye
Copy link
Owner

When a UDP broadcast is received (destination IP 255.255.255.255), the udp input function checks:

  1. is it a broadcast ==> yes
    AND
  2. is the local pcb bound to INADDR_ANY?
    OR
  3. does the destination IP match into the local IP/netmask?

So when you have bound you udp socket to a specific IP instead of INADDR_ANY, it will never receive UDP broadcasts because 2) and 3) will eval to false.

==> a third check is needed

@tabascoeye
Copy link
Owner Author

in src\core\udp.c change the udp_input() function.

#if IP_SOF_BROADCAST_RECV
            (broadcast && ip_get_option(pcb, SOF_BROADCAST) &&
             (ip_addr_isany(&pcb->local_ip) ||
              ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), &inp->netmask) ||
             (ip_addr_cmp(IP_ADDR_BROADCAST, ip_current_dest_addr()) && ip_addr_cmp(&inp->ip_addr, &pcb->local_ip)))) {
#else /* IP_SOF_BROADCAST_RECV */
            (broadcast &&
             (ip_addr_isany(&pcb->local_ip) ||
              ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), &inp->netmask) ||
             (ip_addr_cmp(IP_ADDR_BROADCAST, ip_current_dest_addr()) && ip_addr_cmp(&inp->ip_addr, &pcb->local_ip))))) {
#endif /* IP_SOF_BROADCAST_RECV */ 

@tabascoeye tabascoeye added the bug label Nov 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant