Open tabascoeye opened 10 years ago
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 */
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