Author: jgardou Date: Wed Nov 12 11:38:48 2014 New Revision: 65383
URL: http://svn.reactos.org/svn/reactos?rev=65383&view=rev Log: [TCPIP] - Add special handling case for UDP packet on DHCP server port. lwip refuses to send packets to addresses on which no interface is bound. Of course, DHCP packets are sent before any address is given to an interface, so we have to handle this case here. lwip DHCP discovery code does the same thing.
Modified: branches/tcpip_revolution/drivers/network/tcpip/address.c
Modified: branches/tcpip_revolution/drivers/network/tcpip/address.c URL: http://svn.reactos.org/svn/reactos/branches/tcpip_revolution/drivers/network... ============================================================================== --- branches/tcpip_revolution/drivers/network/tcpip/address.c [iso-8859-1] (original) +++ branches/tcpip_revolution/drivers/network/tcpip/address.c [iso-8859-1] Wed Nov 12 11:38:48 2014 @@ -583,7 +583,7 @@ Port = 0; }
- DPRINT1("Sending datagram to address 0x%08x, port %u\n", ip4_addr_get_u32(&IpAddr), Port); + DPRINT1("Sending datagram to address 0x%08x, port %u\n", ip4_addr_get_u32(&IpAddr), lwip_ntohs(Port));
/* Get the buffer */ Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress); @@ -600,7 +600,39 @@ switch (AddressFile->Protocol) { case IPPROTO_UDP: - lwip_error = udp_sendto(AddressFile->lwip_udp_pcb, p, &IpAddr, Port); + if (((ip4_addr_get_u32(&IpAddr) == IPADDR_ANY) || + (ip4_addr_get_u32(&IpAddr) == IPADDR_BROADCAST)) && + (Port == lwip_ntohs(67)) && AddressFile->Address.in_addr == 0) + { + struct netif* lwip_netif = netif_list; + + /* + * This is a DHCP packet for an address file with address 0.0.0.0. + * Try to find an ethernet interface with no address set, + * and send the packet through it. + */ + while (lwip_netif != NULL) + { + if (ip4_addr_get_u32(&lwip_netif->ip_addr) == 0) + break; + lwip_netif = lwip_netif->next; + } + + if (lwip_netif == NULL) + { + /* Do a regular send. (This will most likely fail) */ + lwip_error = udp_sendto(AddressFile->lwip_udp_pcb, p, &IpAddr, Port); + } + else + { + /* We found an interface with address being 0.0.0.0 */ + lwip_error = udp_sendto_if(AddressFile->lwip_udp_pcb, p, &IpAddr, Port, lwip_netif); + } + } + else + { + lwip_error = udp_sendto(AddressFile->lwip_udp_pcb, p, &IpAddr, Port); + } break; default: lwip_error = raw_sendto(AddressFile->lwip_raw_pcb, p, &IpAddr);