Modified: trunk/reactos/drivers/lib/ip/network/interface.c
Modified: trunk/reactos/drivers/lib/ip/network/neighbor.c
Modified: trunk/reactos/drivers/lib/ip/transport/udp/udp.c
Modified: trunk/reactos/drivers/net/tcpip/datalink/lan.c
Modified: trunk/reactos/drivers/net/tcpip/tcpip/fileobjs.c
--- trunk/reactos/drivers/lib/ip/network/interface.c 2005-01-23 01:33:35 UTC (rev 13222)
+++ trunk/reactos/drivers/lib/ip/network/interface.c 2005-01-23 09:51:03 UTC (rev 13223)
@@ -24,9 +24,7 @@
break;
case ADE_BROADCAST:
- *Address =
- Interface->Unicast.Address.IPv4Address |
- ~Interface->Netmask.Address.IPv4Address;
+ *Address = Interface->Broadcast.Address.IPv4Address;
break;
case ADE_POINTOPOINT:
--- trunk/reactos/drivers/lib/ip/network/neighbor.c 2005-01-23 01:33:35 UTC (rev 13222)
+++ trunk/reactos/drivers/lib/ip/network/neighbor.c 2005-01-23 09:51:03 UTC (rev 13223)
@@ -407,10 +407,19 @@
NCE = NBLocateNeighbor(Address);
if (NCE == NULL)
{
- NCE = NBAddNeighbor(Interface, Address, NULL,
- Interface->AddressLength, NUD_INCOMPLETE);
- NCE->EventTimer = 1;
- NCE->EventCount = 0;
+ TI_DbgPrint(MID_TRACE,("BCAST: %s\n", A2S(&Interface->Broadcast)));
+ if( AddrIsEqual(Address, &Interface->Broadcast) ) {
+ TI_DbgPrint(MID_TRACE,("Packet targeted at broadcast addr\n"));
+ NCE = NBAddNeighbor(Interface, Address, NULL,
+ Interface->AddressLength, NUD_CONNECTED);
+ NCE->EventTimer = 0;
+ NCE->EventCount = 0;
+ } else {
+ NCE = NBAddNeighbor(Interface, Address, NULL,
+ Interface->AddressLength, NUD_INCOMPLETE);
+ NCE->EventTimer = 1;
+ NCE->EventCount = 0;
+ }
}
return NCE;
--- trunk/reactos/drivers/lib/ip/transport/udp/udp.c 2005-01-23 01:33:35 UTC (rev 13222)
+++ trunk/reactos/drivers/lib/ip/transport/udp/udp.c 2005-01-23 09:51:03 UTC (rev 13223)
@@ -14,7 +14,6 @@
BOOLEAN UDPInitialized = FALSE;
PORT_SET UDPPorts;
-
NTSTATUS AddUDPHeaderIPv4(
PIP_ADDRESS RemoteAddress,
USHORT RemotePort,
@@ -408,7 +407,7 @@
RtlZeroMemory(&UDPStats, sizeof(UDP_STATISTICS));
#endif
- PortsStartup( &UDPPorts, UDP_STARTING_PORT, UDP_DYNAMIC_PORTS );
+ PortsStartup( &UDPPorts, 1, 0xfffe );
/* Register this protocol with IP layer */
IPRegisterProtocol(IPPROTO_UDP, UDPReceive);
@@ -440,9 +439,11 @@
UINT UDPAllocatePort( UINT HintPort ) {
if( HintPort ) {
- if( AllocatePort( &UDPPorts, HintPort ) ) return HintPort;
- else return (UINT)-1;
- } else return AllocateAnyPort( &UDPPorts );
+ if( AllocatePort( &UDPPorts, HintPort ) ) return HintPort;
+ else return (UINT)-1;
+ } else return AllocatePortFromRange
+ ( &UDPPorts, UDP_STARTING_PORT,
+ UDP_STARTING_PORT + UDP_DYNAMIC_PORTS );
}
VOID UDPFreePort( UINT Port ) {
--- trunk/reactos/drivers/net/tcpip/datalink/lan.c 2005-01-23 01:33:35 UTC (rev 13222)
+++ trunk/reactos/drivers/net/tcpip/datalink/lan.c 2005-01-23 09:51:03 UTC (rev 13223)
@@ -907,6 +907,14 @@
if(NT_SUCCESS(Status))
Status = ReadIPAddressFromRegistry( RegHandle, L"SubnetMask",
&IF->Netmask );
+
+ IF->Broadcast.Type = IP_ADDRESS_V4;
+ IF->Broadcast.Address.IPv4Address =
+ IF->Unicast.Address.IPv4Address |
+ ~IF->Netmask.Address.IPv4Address;
+
+ TI_DbgPrint(MID_TRACE,("BCAST(IF) %s\n", A2S(&IF->Broadcast)));
+
if(NT_SUCCESS(Status)) {
Status = ReadStringFromRegistry( RegHandle, L"DeviceDesc",
&IF->Name );
--- trunk/reactos/drivers/net/tcpip/tcpip/fileobjs.c 2005-01-23 01:33:35 UTC (rev 13222)
+++ trunk/reactos/drivers/net/tcpip/tcpip/fileobjs.c 2005-01-23 09:51:03 UTC (rev 13223)
@@ -43,6 +43,20 @@
return AddrSearchNext(SearchContext);
}
+BOOLEAN AddrIsBroadcast(
+ PIP_ADDRESS PossibleMatch,
+ PIP_ADDRESS TargetAddress ) {
+ IF_LIST_ITER(IF);
+
+ ForEachInterface(IF) {
+ if( AddrIsEqual( &IF->Unicast, PossibleMatch ) &&
+ AddrIsEqual( &IF->Broadcast, TargetAddress ) )
+ return TRUE;
+ } EndFor(IF);
+
+ return FALSE;
+}
+
/*
* FUNCTION: Searches through address file entries to find next match
* ARGUMENTS:
@@ -80,10 +94,11 @@
A2S(SearchContext->Address)));
/* See if this address matches the search criteria */
- if (((Current->Port == SearchContext->Port) &&
+ if ((Current->Port == SearchContext->Port) &&
(Current->Protocol == SearchContext->Protocol) &&
- (AddrIsEqual(IPAddress, SearchContext->Address))) ||
- (AddrIsUnspecified(IPAddress))) {
+ (AddrIsEqual(IPAddress, SearchContext->Address) ||
+ AddrIsBroadcast(IPAddress, SearchContext->Address) ||
+ AddrIsUnspecified(IPAddress))) {
/* We've found a match */
Found = TRUE;
break;
@@ -277,7 +292,9 @@
TI_DbgPrint(MID_TRACE,("Allocating udp port\n"));
AddrFile->Port =
UDPAllocatePort(Address->Address[0].Address[0].sin_port);
- TI_DbgPrint(MID_TRACE,("Setting port %d\n", AddrFile->Port));
+ TI_DbgPrint(MID_TRACE,("Setting port %d (wanted %d)\n",
+ AddrFile->Port,
+ Address->Address[0].Address[0].sin_port));
AddrFile->Send = UDPSendDatagram;
break;