Author: cgutman
Date: Mon Aug 3 22:10:47 2009
New Revision: 42375
URL:
http://svn.reactos.org/svn/reactos?rev=42375&view=rev
Log:
Broadcast fixes
- Treat 255.255.255.255 as an undefined address
- Choose the first interface when sending a broadcast packet (fixes failing with
STATUS_NETWORK_UNREACHABLE when trying to send a broadcast packet)
- Fix a broadcast address check so 255.255.255.255 will also pass (fixes sending queued
broadcast packets)
- Now a broadcast packet can be successfully sent from an interface with a valid IP
address (previously they could only be sent when the interface didn't have an NCE
entry)
Modified:
trunk/reactos/lib/drivers/ip/network/address.c
trunk/reactos/lib/drivers/ip/network/interface.c
trunk/reactos/lib/drivers/ip/network/neighbor.c
Modified: trunk/reactos/lib/drivers/ip/network/address.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/add…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/address.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/address.c [iso-8859-1] Mon Aug 3 22:10:47 2009
@@ -122,7 +122,8 @@
{
switch (Address->Type) {
case IP_ADDRESS_V4:
- return (Address->Address.IPv4Address == 0);
+ return (Address->Address.IPv4Address == 0 ||
+ Address->Address.IPv4Address == 0xFFFFFFFF);
case IP_ADDRESS_V6:
/* FIXME: IPv6 is not supported */
Modified: trunk/reactos/lib/drivers/ip/network/interface.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/int…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/interface.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/interface.c [iso-8859-1] Mon Aug 3 22:10:47
2009
@@ -152,6 +152,26 @@
return TRUE;
}
+static PIP_INTERFACE GetDefaultInterface(VOID)
+{
+ KIRQL OldIrql;
+ IF_LIST_ITER(CurrentIF);
+
+ TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
+ ForEachInterface(CurrentIF) {
+ if (CurrentIF->Context) {
+ TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
+ return CurrentIF;
+ }
+ } EndFor(CurrentIF);
+ TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
+
+ /* There are no physical interfaces on the system
+ * so we must pick the loopback interface */
+
+ return Loopback;
+}
+
PIP_INTERFACE FindOnLinkInterface(PIP_ADDRESS Address)
/*
* FUNCTION: Checks all on-link prefixes to find out if an address is on-link
@@ -166,6 +186,9 @@
TI_DbgPrint(DEBUG_ROUTER, ("Called. Address (0x%X)\n", Address));
TI_DbgPrint(DEBUG_ROUTER, ("Address (%s)\n", A2S(Address)));
+
+ if (AddrIsUnspecified(Address))
+ return GetDefaultInterface();
TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
Modified: trunk/reactos/lib/drivers/ip/network/neighbor.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/nei…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/neighbor.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/neighbor.c [iso-8859-1] Mon Aug 3 22:10:47 2009
@@ -421,7 +421,8 @@
if (NCE == NULL)
{
TI_DbgPrint(MID_TRACE,("BCAST: %s\n",
A2S(&Interface->Broadcast)));
- if( AddrIsEqual(Address, &Interface->Broadcast) ) {
+ if( AddrIsEqual(Address, &Interface->Broadcast) ||
+ AddrIsUnspecified(Address) ) {
TI_DbgPrint(MID_TRACE,("Packet targeted at broadcast addr\n"));
NCE = NBAddNeighbor(Interface, Address, NULL,
Interface->AddressLength, NUD_CONNECTED);