mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Fixed broadcast UDP.
lan: Added calculation of broadcast address. fileobjs: Check for broadcast receive. neighbor: Check for broadcast send. interface: Use cached broadcast address. udp: Fix port allocation. svn path=/trunk/; revision=13223
This commit is contained in:
parent
063e4f41a5
commit
a23df2bed0
5 changed files with 49 additions and 16 deletions
|
@ -24,9 +24,7 @@ NTSTATUS GetInterfaceIPv4Address( PIP_INTERFACE Interface,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ADE_BROADCAST:
|
case ADE_BROADCAST:
|
||||||
*Address =
|
*Address = Interface->Broadcast.Address.IPv4Address;
|
||||||
Interface->Unicast.Address.IPv4Address |
|
|
||||||
~Interface->Netmask.Address.IPv4Address;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ADE_POINTOPOINT:
|
case ADE_POINTOPOINT:
|
||||||
|
|
|
@ -407,10 +407,19 @@ PNEIGHBOR_CACHE_ENTRY NBFindOrCreateNeighbor(
|
||||||
NCE = NBLocateNeighbor(Address);
|
NCE = NBLocateNeighbor(Address);
|
||||||
if (NCE == NULL)
|
if (NCE == NULL)
|
||||||
{
|
{
|
||||||
NCE = NBAddNeighbor(Interface, Address, NULL,
|
TI_DbgPrint(MID_TRACE,("BCAST: %s\n", A2S(&Interface->Broadcast)));
|
||||||
Interface->AddressLength, NUD_INCOMPLETE);
|
if( AddrIsEqual(Address, &Interface->Broadcast) ) {
|
||||||
NCE->EventTimer = 1;
|
TI_DbgPrint(MID_TRACE,("Packet targeted at broadcast addr\n"));
|
||||||
NCE->EventCount = 0;
|
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;
|
return NCE;
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
BOOLEAN UDPInitialized = FALSE;
|
BOOLEAN UDPInitialized = FALSE;
|
||||||
PORT_SET UDPPorts;
|
PORT_SET UDPPorts;
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS AddUDPHeaderIPv4(
|
NTSTATUS AddUDPHeaderIPv4(
|
||||||
PIP_ADDRESS RemoteAddress,
|
PIP_ADDRESS RemoteAddress,
|
||||||
USHORT RemotePort,
|
USHORT RemotePort,
|
||||||
|
@ -408,7 +407,7 @@ NTSTATUS UDPStartup(
|
||||||
RtlZeroMemory(&UDPStats, sizeof(UDP_STATISTICS));
|
RtlZeroMemory(&UDPStats, sizeof(UDP_STATISTICS));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PortsStartup( &UDPPorts, UDP_STARTING_PORT, UDP_DYNAMIC_PORTS );
|
PortsStartup( &UDPPorts, 1, 0xfffe );
|
||||||
|
|
||||||
/* Register this protocol with IP layer */
|
/* Register this protocol with IP layer */
|
||||||
IPRegisterProtocol(IPPROTO_UDP, UDPReceive);
|
IPRegisterProtocol(IPPROTO_UDP, UDPReceive);
|
||||||
|
@ -440,9 +439,11 @@ NTSTATUS UDPShutdown(
|
||||||
|
|
||||||
UINT UDPAllocatePort( UINT HintPort ) {
|
UINT UDPAllocatePort( UINT HintPort ) {
|
||||||
if( HintPort ) {
|
if( HintPort ) {
|
||||||
if( AllocatePort( &UDPPorts, HintPort ) ) return HintPort;
|
if( AllocatePort( &UDPPorts, HintPort ) ) return HintPort;
|
||||||
else return (UINT)-1;
|
else return (UINT)-1;
|
||||||
} else return AllocateAnyPort( &UDPPorts );
|
} else return AllocatePortFromRange
|
||||||
|
( &UDPPorts, UDP_STARTING_PORT,
|
||||||
|
UDP_STARTING_PORT + UDP_DYNAMIC_PORTS );
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID UDPFreePort( UINT Port ) {
|
VOID UDPFreePort( UINT Port ) {
|
||||||
|
|
|
@ -907,6 +907,14 @@ VOID BindAdapter(
|
||||||
if(NT_SUCCESS(Status))
|
if(NT_SUCCESS(Status))
|
||||||
Status = ReadIPAddressFromRegistry( RegHandle, L"SubnetMask",
|
Status = ReadIPAddressFromRegistry( RegHandle, L"SubnetMask",
|
||||||
&IF->Netmask );
|
&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)) {
|
if(NT_SUCCESS(Status)) {
|
||||||
Status = ReadStringFromRegistry( RegHandle, L"DeviceDesc",
|
Status = ReadStringFromRegistry( RegHandle, L"DeviceDesc",
|
||||||
&IF->Name );
|
&IF->Name );
|
||||||
|
|
|
@ -43,6 +43,20 @@ PADDRESS_FILE AddrSearchFirst(
|
||||||
return AddrSearchNext(SearchContext);
|
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
|
* FUNCTION: Searches through address file entries to find next match
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
|
@ -80,10 +94,11 @@ PADDRESS_FILE AddrSearchNext(
|
||||||
A2S(SearchContext->Address)));
|
A2S(SearchContext->Address)));
|
||||||
|
|
||||||
/* See if this address matches the search criteria */
|
/* See if this address matches the search criteria */
|
||||||
if (((Current->Port == SearchContext->Port) &&
|
if ((Current->Port == SearchContext->Port) &&
|
||||||
(Current->Protocol == SearchContext->Protocol) &&
|
(Current->Protocol == SearchContext->Protocol) &&
|
||||||
(AddrIsEqual(IPAddress, SearchContext->Address))) ||
|
(AddrIsEqual(IPAddress, SearchContext->Address) ||
|
||||||
(AddrIsUnspecified(IPAddress))) {
|
AddrIsBroadcast(IPAddress, SearchContext->Address) ||
|
||||||
|
AddrIsUnspecified(IPAddress))) {
|
||||||
/* We've found a match */
|
/* We've found a match */
|
||||||
Found = TRUE;
|
Found = TRUE;
|
||||||
break;
|
break;
|
||||||
|
@ -277,7 +292,9 @@ NTSTATUS FileOpenAddress(
|
||||||
TI_DbgPrint(MID_TRACE,("Allocating udp port\n"));
|
TI_DbgPrint(MID_TRACE,("Allocating udp port\n"));
|
||||||
AddrFile->Port =
|
AddrFile->Port =
|
||||||
UDPAllocatePort(Address->Address[0].Address[0].sin_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;
|
AddrFile->Send = UDPSendDatagram;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue