mirror of
https://github.com/reactos/reactos.git
synced 2025-05-25 12:14:32 +00:00
Needed infrastructure for DHCP:
Corrected adapter index problem in iinfo.c. Now the index returned is from IF->Index. ninfo: ditto. ip.c: Expose IPAddInterfaceRoute and IPRemoveInterfaceRoute for use by set ip address IOCTL. if.c: Allow deleting of TCP context. main.c: Turn off debugging in CVS. svn path=/trunk/; revision=14644
This commit is contained in:
parent
24b6532712
commit
aa0b005b38
7 changed files with 65 additions and 29 deletions
|
@ -232,6 +232,27 @@ VOID IPDestroyInterface(
|
||||||
exFreePool(IF);
|
exFreePool(IF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID IPAddInterfaceRoute( PIP_INTERFACE IF ) {
|
||||||
|
PNEIGHBOR_CACHE_ENTRY NCE;
|
||||||
|
IP_ADDRESS NetworkAddress;
|
||||||
|
|
||||||
|
/* Add a permanent neighbor for this NTE */
|
||||||
|
NCE = NBAddNeighbor(IF, &IF->Unicast,
|
||||||
|
IF->Address, IF->AddressLength,
|
||||||
|
NUD_PERMANENT);
|
||||||
|
if (!NCE) {
|
||||||
|
TI_DbgPrint(MIN_TRACE, ("Could not create NCE.\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
AddrWidenAddress( &NetworkAddress, &IF->Unicast, &IF->Netmask );
|
||||||
|
|
||||||
|
if (!RouterAddRoute(&NetworkAddress, &IF->Netmask, NCE, 1)) {
|
||||||
|
TI_DbgPrint(MIN_TRACE, ("Could not add route due to insufficient resources.\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allow TCP to hang some configuration on this interface */
|
||||||
|
IF->TCPContext = TCPPrepareInterface( IF );
|
||||||
|
}
|
||||||
|
|
||||||
BOOLEAN IPRegisterInterface(
|
BOOLEAN IPRegisterInterface(
|
||||||
PIP_INTERFACE IF)
|
PIP_INTERFACE IF)
|
||||||
|
@ -246,8 +267,6 @@ BOOLEAN IPRegisterInterface(
|
||||||
KIRQL OldIrql;
|
KIRQL OldIrql;
|
||||||
UINT ChosenIndex = 1;
|
UINT ChosenIndex = 1;
|
||||||
BOOLEAN IndexHasBeenChosen;
|
BOOLEAN IndexHasBeenChosen;
|
||||||
IP_ADDRESS NetworkAddress;
|
|
||||||
PNEIGHBOR_CACHE_ENTRY NCE;
|
|
||||||
IF_LIST_ITER(Interface);
|
IF_LIST_ITER(Interface);
|
||||||
|
|
||||||
TI_DbgPrint(MID_TRACE, ("Called. IF (0x%X).\n", IF));
|
TI_DbgPrint(MID_TRACE, ("Called. IF (0x%X).\n", IF));
|
||||||
|
@ -267,35 +286,34 @@ BOOLEAN IPRegisterInterface(
|
||||||
|
|
||||||
IF->Index = ChosenIndex;
|
IF->Index = ChosenIndex;
|
||||||
|
|
||||||
/* Add a permanent neighbor for this NTE */
|
IPAddInterfaceRoute( IF );
|
||||||
NCE = NBAddNeighbor(IF, &IF->Unicast,
|
|
||||||
IF->Address, IF->AddressLength,
|
|
||||||
NUD_PERMANENT);
|
|
||||||
if (!NCE) {
|
|
||||||
TI_DbgPrint(MIN_TRACE, ("Could not create NCE.\n"));
|
|
||||||
TcpipReleaseSpinLock(&IF->Lock, OldIrql);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
AddrWidenAddress( &NetworkAddress, &IF->Unicast, &IF->Netmask );
|
|
||||||
|
|
||||||
if (!RouterAddRoute(&NetworkAddress, &IF->Netmask, NCE, 1)) {
|
|
||||||
TI_DbgPrint(MIN_TRACE, ("Could not add route due to insufficient resources.\n"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add interface to the global interface list */
|
/* Add interface to the global interface list */
|
||||||
TcpipInterlockedInsertTailList(&InterfaceListHead,
|
TcpipInterlockedInsertTailList(&InterfaceListHead,
|
||||||
&IF->ListEntry,
|
&IF->ListEntry,
|
||||||
&InterfaceListLock);
|
&InterfaceListLock);
|
||||||
|
|
||||||
/* Allow TCP to hang some configuration on this interface */
|
|
||||||
IF->TCPContext = TCPPrepareInterface( IF );
|
|
||||||
|
|
||||||
TcpipReleaseSpinLock(&IF->Lock, OldIrql);
|
TcpipReleaseSpinLock(&IF->Lock, OldIrql);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID IPRemoveInterfaceRoute( PIP_INTERFACE IF ) {
|
||||||
|
PNEIGHBOR_CACHE_ENTRY NCE;
|
||||||
|
IP_ADDRESS GeneralRoute;
|
||||||
|
|
||||||
|
TCPDisposeInterfaceData( IF->TCPContext );
|
||||||
|
IF->TCPContext = NULL;
|
||||||
|
|
||||||
|
AddrWidenAddress(&GeneralRoute,&IF->Unicast,&IF->Netmask);
|
||||||
|
RouterRemoveRoute(&GeneralRoute, &IF->Unicast);
|
||||||
|
|
||||||
|
/* Remove permanent NCE, but first we have to find it */
|
||||||
|
NCE = NBLocateNeighbor(&IF->Unicast);
|
||||||
|
if (NCE)
|
||||||
|
NBRemoveNeighbor(NCE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
VOID IPUnregisterInterface(
|
VOID IPUnregisterInterface(
|
||||||
PIP_INTERFACE IF)
|
PIP_INTERFACE IF)
|
||||||
|
@ -306,14 +324,10 @@ VOID IPUnregisterInterface(
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
KIRQL OldIrql3;
|
KIRQL OldIrql3;
|
||||||
PNEIGHBOR_CACHE_ENTRY NCE;
|
|
||||||
|
|
||||||
TI_DbgPrint(DEBUG_IP, ("Called. IF (0x%X).\n", IF));
|
TI_DbgPrint(DEBUG_IP, ("Called. IF (0x%X).\n", IF));
|
||||||
|
|
||||||
/* Remove permanent NCE, but first we have to find it */
|
IPRemoveInterfaceRoute( IF );
|
||||||
NCE = NBLocateNeighbor(&IF->Unicast);
|
|
||||||
if (NCE)
|
|
||||||
NBRemoveNeighbor(NCE);
|
|
||||||
|
|
||||||
TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql3);
|
TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql3);
|
||||||
RemoveEntryList(&IF->ListEntry);
|
RemoveEntryList(&IF->ListEntry);
|
||||||
|
|
|
@ -65,6 +65,10 @@ PVOID TCPPrepareInterface( PIP_INTERFACE IF ) {
|
||||||
return ifaddr;
|
return ifaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID TCPDisposeInterfaceData( PVOID Ptr ) {
|
||||||
|
exFreePool( Ptr );
|
||||||
|
}
|
||||||
|
|
||||||
POSK_IFADDR TCPFindInterface( void *ClientData,
|
POSK_IFADDR TCPFindInterface( void *ClientData,
|
||||||
OSK_UINT AddrType,
|
OSK_UINT AddrType,
|
||||||
OSK_UINT FindType,
|
OSK_UINT FindType,
|
||||||
|
|
|
@ -207,6 +207,12 @@ PIP_PACKET IPInitializePacket(
|
||||||
PIP_INTERFACE IPCreateInterface(
|
PIP_INTERFACE IPCreateInterface(
|
||||||
PLLIP_BIND_INFO BindInfo);
|
PLLIP_BIND_INFO BindInfo);
|
||||||
|
|
||||||
|
VOID IPAddInterfaceRoute(
|
||||||
|
PIP_INTERFACE IF);
|
||||||
|
|
||||||
|
VOID IPRemoveInterfaceRoute(
|
||||||
|
PIP_INTERFACE IF);
|
||||||
|
|
||||||
VOID IPDestroyInterface(
|
VOID IPDestroyInterface(
|
||||||
PIP_INTERFACE IF);
|
PIP_INTERFACE IF);
|
||||||
|
|
||||||
|
|
|
@ -156,6 +156,8 @@ NTSTATUS TCPClose( PCONNECTION_ENDPOINT Connection );
|
||||||
|
|
||||||
PVOID TCPPrepareInterface( PIP_INTERFACE IF );
|
PVOID TCPPrepareInterface( PIP_INTERFACE IF );
|
||||||
|
|
||||||
|
VOID TCPDisposeInterfaceData( PVOID Data );
|
||||||
|
|
||||||
NTSTATUS TCPTranslateError( int OskitError );
|
NTSTATUS TCPTranslateError( int OskitError );
|
||||||
|
|
||||||
VOID TCPTimeout();
|
VOID TCPTimeout();
|
||||||
|
|
|
@ -1483,10 +1483,20 @@ NTSTATUS DispTdiSetIPAddress( PIRP Irp, PIO_STACK_LOCATION IrpSp ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if( IF->Index == IpAddrChange->NteIndex ) {
|
if( IF->Index == IpAddrChange->NteIndex ) {
|
||||||
|
IPRemoveInterfaceRoute( IF );
|
||||||
|
|
||||||
IF->Unicast.Type = IP_ADDRESS_V4;
|
IF->Unicast.Type = IP_ADDRESS_V4;
|
||||||
IF->Unicast.Address.IPv4Address = IpAddrChange->Address;
|
IF->Unicast.Address.IPv4Address = IpAddrChange->Address;
|
||||||
IF->Netmask.Type = IP_ADDRESS_V4;
|
IF->Netmask.Type = IP_ADDRESS_V4;
|
||||||
IF->Netmask.Address.IPv4Address = IpAddrChange->Netmask;
|
IF->Netmask.Address.IPv4Address = IpAddrChange->Netmask;
|
||||||
|
|
||||||
|
TI_DbgPrint(MID_TRACE,("New Unicast Address: %x\n",
|
||||||
|
IF->Unicast.Address.IPv4Address));
|
||||||
|
TI_DbgPrint(MID_TRACE,("New Netmask : %x\n",
|
||||||
|
IF->Netmask.Address.IPv4Address));
|
||||||
|
|
||||||
|
IPAddInterfaceRoute( IF );
|
||||||
|
|
||||||
IpAddrChange->Address = IF->Index;
|
IpAddrChange->Address = IF->Index;
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
Irp->IoStatus.Information = IF->Index;
|
Irp->IoStatus.Information = IF->Index;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
*/
|
*/
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
|
||||||
//#define NDEBUG
|
#define NDEBUG
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
DWORD DebugTraceLevel = DEBUG_ULTRA & ~(DEBUG_LOCK | DEBUG_PBUFFER);
|
DWORD DebugTraceLevel = DEBUG_ULTRA & ~(DEBUG_LOCK | DEBUG_PBUFFER);
|
||||||
|
|
|
@ -30,7 +30,7 @@ TDI_STATUS InfoTdiQueryGetAddrTable( PNDIS_BUFFER Buffer,
|
||||||
TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
|
TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
|
||||||
|
|
||||||
ForEachInterface(CurrentIF) {
|
ForEachInterface(CurrentIF) {
|
||||||
IpCurrent->Index = Count;
|
IpCurrent->Index = CurrentIF->Index;
|
||||||
IpCurrent->Addr = 0;
|
IpCurrent->Addr = 0;
|
||||||
IpCurrent->BcastAddr = 0;
|
IpCurrent->BcastAddr = 0;
|
||||||
IpCurrent->Mask = 0;
|
IpCurrent->Mask = 0;
|
||||||
|
|
Loading…
Reference in a new issue