Author: cgutman
Date: Fri Jan 13 07:28:16 2012
New Revision: 54929
URL:
http://svn.reactos.org/svn/reactos?rev=54929&view=rev
Log:
[TCPIP]
- Support media state changes properly
Modified:
branches/wlan-bringup/drivers/network/tcpip/datalink/lan.c
branches/wlan-bringup/drivers/network/tcpip/include/ip.h
branches/wlan-bringup/drivers/network/tcpip/include/lan.h
branches/wlan-bringup/drivers/network/tcpip/include/neighbor.h
branches/wlan-bringup/drivers/network/tcpip/include/router.h
branches/wlan-bringup/lib/drivers/ip/network/ip.c
branches/wlan-bringup/lib/drivers/ip/network/loopback.c
branches/wlan-bringup/lib/drivers/ip/network/neighbor.c
branches/wlan-bringup/lib/drivers/ip/network/router.c
Modified: branches/wlan-bringup/drivers/network/tcpip/datalink/lan.c
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/tc…
==============================================================================
--- branches/wlan-bringup/drivers/network/tcpip/datalink/lan.c [iso-8859-1] (original)
+++ branches/wlan-bringup/drivers/network/tcpip/datalink/lan.c [iso-8859-1] Fri Jan 13
07:28:16 2012
@@ -556,6 +556,216 @@
}
+BOOLEAN ReconfigureAdapter(PLAN_ADAPTER Adapter, BOOLEAN FinishedReset)
+{
+ PIP_INTERFACE Interface = Adapter->Context;
+ NDIS_STATUS NdisStatus;
+ IP_ADDRESS DefaultMask, Router;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ HANDLE ParameterHandle;
+ PKEY_VALUE_PARTIAL_INFORMATION KeyValueInfo;
+ WCHAR Buffer[150];
+ UNICODE_STRING IPAddress = RTL_CONSTANT_STRING(L"IPAddress");
+ UNICODE_STRING Netmask = RTL_CONSTANT_STRING(L"SubnetMask");
+ UNICODE_STRING Gateway = RTL_CONSTANT_STRING(L"DefaultGateway");
+ UNICODE_STRING EnableDhcp = RTL_CONSTANT_STRING(L"EnableDHCP");
+ UNICODE_STRING Prefix =
RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\");
+ UNICODE_STRING TcpipRegistryPath;
+ UNICODE_STRING RegistryDataU;
+ ANSI_STRING RegistryDataA;
+ ULONG Unused;
+ NTSTATUS Status;
+
+ /* Initalize the default unspecified address (0.0.0.0) */
+ AddrInitIPv4(&DefaultMask, 0);
+ if (Adapter->State == LAN_STATE_STARTED && !FinishedReset)
+ {
+ TcpipRegistryPath.MaximumLength = sizeof(WCHAR) * 150;
+ TcpipRegistryPath.Length = 0;
+ TcpipRegistryPath.Buffer = Buffer;
+
+ /* Build the registry path */
+ RtlAppendUnicodeStringToString(&TcpipRegistryPath, &Prefix);
+ RtlAppendUnicodeStringToString(&TcpipRegistryPath, &Interface->Name);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &TcpipRegistryPath,
+ OBJ_CASE_INSENSITIVE,
+ 0,
+ NULL);
+
+ /* Open a handle to the adapter parameters */
+ Status = ZwOpenKey(&ParameterHandle, KEY_READ, &ObjectAttributes);
+
+ if (!NT_SUCCESS(Status))
+ {
+ /* Just use defaults if the open fails for some reason */
+ Interface->Unicast = DefaultMask;
+ Interface->Netmask = DefaultMask;
+ }
+ else
+ {
+ KeyValueInfo = ExAllocatePool(PagedPool,
sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 16 * sizeof(WCHAR));
+ if (!KeyValueInfo)
+ {
+ ZwClose(ParameterHandle);
+ return FALSE;
+ }
+
+ /* Read the EnableDHCP entry */
+ Status = ZwQueryValueKey(ParameterHandle,
+ &EnableDhcp,
+ KeyValuePartialInformation,
+ KeyValueInfo,
+ sizeof(KEY_VALUE_PARTIAL_INFORMATION) +
sizeof(ULONG),
+ &Unused);
+ if (NT_SUCCESS(Status) && KeyValueInfo->DataLength ==
sizeof(ULONG) && (*(PULONG)KeyValueInfo->Data) == 0)
+ {
+ RegistryDataU.MaximumLength = 16 + sizeof(WCHAR);
+ RegistryDataU.Buffer = (PWCHAR)KeyValueInfo->Data;
+
+ /* Read the IP address */
+ Status = ZwQueryValueKey(ParameterHandle,
+ &IPAddress,
+ KeyValuePartialInformation,
+ KeyValueInfo,
+ sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 16 *
sizeof(WCHAR),
+ &Unused);
+ if (NT_SUCCESS(Status))
+ {
+ RegistryDataU.Length = KeyValueInfo->DataLength;
+
+ RtlUnicodeStringToAnsiString(&RegistryDataA,
+ &RegistryDataU,
+ TRUE);
+
+ AddrInitIPv4(&Interface->Unicast,
inet_addr(RegistryDataA.Buffer));
+
+ RtlFreeAnsiString(&RegistryDataA);
+
+ }
+ else
+ {
+ Interface->Unicast = DefaultMask;
+ }
+
+ Status = ZwQueryValueKey(ParameterHandle,
+ &Netmask,
+ KeyValuePartialInformation,
+ KeyValueInfo,
+ sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 16 *
sizeof(WCHAR),
+ &Unused);
+ if (NT_SUCCESS(Status))
+ {
+ RegistryDataU.Length = KeyValueInfo->DataLength;
+
+ RtlUnicodeStringToAnsiString(&RegistryDataA,
+ &RegistryDataU,
+ TRUE);
+
+ AddrInitIPv4(&Interface->Netmask,
inet_addr(RegistryDataA.Buffer));
+
+ RtlFreeAnsiString(&RegistryDataA);
+ }
+ else
+ {
+ Interface->Netmask = DefaultMask;
+ }
+
+ /* Read default gateway info */
+ Status = ZwQueryValueKey(ParameterHandle,
+ &Gateway,
+ KeyValuePartialInformation,
+ KeyValueInfo,
+ sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 16 *
sizeof(WCHAR),
+ &Unused);
+ if (NT_SUCCESS(Status))
+ {
+ RegistryDataU.Length = KeyValueInfo->DataLength;
+
+ RtlUnicodeStringToAnsiString(&RegistryDataA,
+ &RegistryDataU,
+ TRUE);
+
+ AddrInitIPv4(&Router, inet_addr(RegistryDataA.Buffer));
+
+ RtlFreeAnsiString(&RegistryDataA);
+
+ /* Create the default route */
+ if (!AddrIsUnspecified(&Router))
RouterCreateRoute(&DefaultMask, &DefaultMask, &Router, Interface, 1);
+ }
+ }
+ else
+ {
+ Interface->Unicast = DefaultMask;
+ Interface->Netmask = DefaultMask;
+ }
+
+ ZwClose(ParameterHandle);
+ }
+
+ /* Compute the broadcast address */
+ Interface->Broadcast.Type = IP_ADDRESS_V4;
+ Interface->Broadcast.Address.IPv4Address =
+ Interface->Unicast.Address.IPv4Address |
+ ~Interface->Netmask.Address.IPv4Address;
+ }
+ else if (!FinishedReset)
+ {
+ /* Clear IP configuration */
+ Interface->Unicast = DefaultMask;
+ Interface->Netmask = DefaultMask;
+ Interface->Broadcast = DefaultMask;
+
+ /* Remove all interface routes */
+ RouterRemoveRoutesForInterface(Interface);
+
+ /* Destroy all cached neighbors */
+ NBDestroyNeighborsForInterface(Interface);
+ }
+
+ /* We're done here if the adapter isn't connected */
+ if (Adapter->State != LAN_STATE_STARTED) return TRUE;
+
+ /* Get maximum link speed */
+ NdisStatus = NDISCall(Adapter,
+ NdisRequestQueryInformation,
+ OID_GEN_LINK_SPEED,
+ &Interface->Speed,
+ sizeof(UINT));
+
+ if (!NT_SUCCESS(NdisStatus))
+ Interface->Speed = IP_DEFAULT_LINK_SPEED;
+
+ Adapter->Speed = Interface->Speed * 100L;
+
+ /* Get maximum frame size */
+ NdisStatus = NDISCall(Adapter,
+ NdisRequestQueryInformation,
+ OID_GEN_MAXIMUM_FRAME_SIZE,
+ &Adapter->MTU,
+ sizeof(UINT));
+ if (NdisStatus != NDIS_STATUS_SUCCESS)
+ return FALSE;
+
+ Interface->MTU = Adapter->MTU;
+
+ /* Get maximum packet size */
+ NdisStatus = NDISCall(Adapter,
+ NdisRequestQueryInformation,
+ OID_GEN_MAXIMUM_TOTAL_SIZE,
+ &Adapter->MaxPacketSize,
+ sizeof(UINT));
+ if (NdisStatus != NDIS_STATUS_SUCCESS)
+ return FALSE;
+
+ /* Add the interface for a static IP */
+ if (!AddrIsUnspecified(&Interface->Unicast))
+ IPAddInterfaceRoute(Interface);
+
+ return TRUE;
+}
+
VOID NTAPI ProtocolStatus(
NDIS_HANDLE BindingContext,
NDIS_STATUS GeneralStatus,
@@ -576,25 +786,41 @@
switch(GeneralStatus)
{
- case NDIS_STATUS_MEDIA_CONNECT:
- DbgPrint("NDIS_STATUS_MEDIA_CONNECT\n");
- break;
-
- case NDIS_STATUS_MEDIA_DISCONNECT:
- DbgPrint("NDIS_STATUS_MEDIA_DISCONNECT\n");
- break;
-
- case NDIS_STATUS_RESET_START:
- Adapter->State = LAN_STATE_RESETTING;
- break;
-
- case NDIS_STATUS_RESET_END:
- Adapter->State = LAN_STATE_STARTED;
- break;
-
- default:
- DbgPrint("Unhandled status: %x", GeneralStatus);
- break;
+ case NDIS_STATUS_MEDIA_CONNECT:
+ DbgPrint("NDIS_STATUS_MEDIA_CONNECT\n");
+
+ if (Adapter->State == LAN_STATE_STARTED)
+ break;
+
+ Adapter->State = LAN_STATE_STARTED;
+ ReconfigureAdapter(Adapter, FALSE);
+
+ break;
+
+ case NDIS_STATUS_MEDIA_DISCONNECT:
+ DbgPrint("NDIS_STATUS_MEDIA_DISCONNECT\n");
+
+ if (Adapter->State == LAN_STATE_STOPPED)
+ break;
+
+ Adapter->State = LAN_STATE_STOPPED;
+ ReconfigureAdapter(Adapter, FALSE);
+ break;
+
+ case NDIS_STATUS_RESET_START:
+ Adapter->OldState = Adapter->State;
+ Adapter->State = LAN_STATE_RESETTING;
+ /* Nothing else to do here */
+ break;
+
+ case NDIS_STATUS_RESET_END:
+ Adapter->State = Adapter->OldState;
+ ReconfigureAdapter(Adapter, TRUE);
+ break;
+
+ default:
+ DbgPrint("Unhandled status: %x", GeneralStatus);
+ break;
}
}
@@ -1033,21 +1259,8 @@
PIP_INTERFACE IF;
NDIS_STATUS NdisStatus;
LLIP_BIND_INFO BindInfo;
- IP_ADDRESS DefaultMask, Router;
- ULONG Lookahead = LOOKAHEAD_SIZE, Unused;
+ ULONG Lookahead = LOOKAHEAD_SIZE;
NTSTATUS Status;
- OBJECT_ATTRIBUTES ObjectAttributes;
- HANDLE ParameterHandle;
- PKEY_VALUE_PARTIAL_INFORMATION KeyValueInfo;
- WCHAR Buffer[150];
- UNICODE_STRING IPAddress = RTL_CONSTANT_STRING(L"IPAddress");
- UNICODE_STRING Netmask = RTL_CONSTANT_STRING(L"SubnetMask");
- UNICODE_STRING Gateway = RTL_CONSTANT_STRING(L"DefaultGateway");
- UNICODE_STRING EnableDhcp = RTL_CONSTANT_STRING(L"EnableDHCP");
- UNICODE_STRING Prefix =
RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\");
- UNICODE_STRING TcpipRegistryPath;
- UNICODE_STRING RegistryDataU;
- ANSI_STRING RegistryDataA;
TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
@@ -1067,7 +1280,6 @@
BindInfo.Context = Adapter;
BindInfo.HeaderSize = Adapter->HeaderSize;
BindInfo.MinFrameSize = Adapter->MinFrameSize;
- BindInfo.MTU = Adapter->MTU;
BindInfo.Address = (PUCHAR)&Adapter->HWAddress;
BindInfo.AddressLength = Adapter->HWAddressLength;
BindInfo.Transmit = LANTransmit;
@@ -1100,148 +1312,15 @@
TI_DbgPrint(DEBUG_DATALINK,("Adapter Description: %wZ\n",
&IF->Description));
- TcpipRegistryPath.MaximumLength = sizeof(WCHAR) * 150;
- TcpipRegistryPath.Length = 0;
- TcpipRegistryPath.Buffer = Buffer;
-
- RtlAppendUnicodeStringToString(&TcpipRegistryPath,
- &Prefix);
-
- RtlAppendUnicodeStringToString(&TcpipRegistryPath,
- &IF->Name);
-
- InitializeObjectAttributes(&ObjectAttributes,
- &TcpipRegistryPath,
- OBJ_CASE_INSENSITIVE,
- 0,
- NULL);
-
- AddrInitIPv4(&DefaultMask, 0);
-
- Status = ZwOpenKey(&ParameterHandle, KEY_READ, &ObjectAttributes);
-
- if (!NT_SUCCESS(Status))
- {
- IF->Unicast = DefaultMask;
- IF->Netmask = DefaultMask;
- }
- else
- {
- KeyValueInfo = ExAllocatePool(PagedPool, sizeof(KEY_VALUE_PARTIAL_INFORMATION) +
16 * sizeof(WCHAR));
- if (!KeyValueInfo)
- {
- ZwClose(ParameterHandle);
- IPDestroyInterface(IF);
- return FALSE;
- }
-
- Status = ZwQueryValueKey(ParameterHandle,
- &EnableDhcp,
- KeyValuePartialInformation,
- KeyValueInfo,
- sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG),
- &Unused);
- if (NT_SUCCESS(Status) && KeyValueInfo->DataLength == sizeof(ULONG)
&& (*(PULONG)KeyValueInfo->Data) == 0)
- {
- RegistryDataU.MaximumLength = 16 + sizeof(WCHAR);
- RegistryDataU.Buffer = (PWCHAR)KeyValueInfo->Data;
-
- Status = ZwQueryValueKey(ParameterHandle,
- &IPAddress,
- KeyValuePartialInformation,
- KeyValueInfo,
- sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 16 *
sizeof(WCHAR),
- &Unused);
- if (NT_SUCCESS(Status))
- {
- RegistryDataU.Length = KeyValueInfo->DataLength;
-
- RtlUnicodeStringToAnsiString(&RegistryDataA,
- &RegistryDataU,
- TRUE);
-
- AddrInitIPv4(&IF->Unicast, inet_addr(RegistryDataA.Buffer));
-
- RtlFreeAnsiString(&RegistryDataA);
-
- }
- else
- {
- IF->Unicast = DefaultMask;
- }
-
- Status = ZwQueryValueKey(ParameterHandle,
- &Netmask,
- KeyValuePartialInformation,
- KeyValueInfo,
- sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 16 *
sizeof(WCHAR),
- &Unused);
- if (NT_SUCCESS(Status))
- {
- RegistryDataU.Length = KeyValueInfo->DataLength;
-
- RtlUnicodeStringToAnsiString(&RegistryDataA,
- &RegistryDataU,
- TRUE);
-
- AddrInitIPv4(&IF->Netmask, inet_addr(RegistryDataA.Buffer));
-
- RtlFreeAnsiString(&RegistryDataA);
- }
- else
- {
- IF->Netmask = DefaultMask;
- }
-
- Status = ZwQueryValueKey(ParameterHandle,
- &Gateway,
- KeyValuePartialInformation,
- KeyValueInfo,
- sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 16 *
sizeof(WCHAR),
- &Unused);
- if (NT_SUCCESS(Status))
- {
- RegistryDataU.Length = KeyValueInfo->DataLength;
-
- RtlUnicodeStringToAnsiString(&RegistryDataA,
- &RegistryDataU,
- TRUE);
-
- AddrInitIPv4(&Router, inet_addr(RegistryDataA.Buffer));
-
- RtlFreeAnsiString(&RegistryDataA);
-
- if (!AddrIsUnspecified(&Router)) RouterCreateRoute(&DefaultMask,
&DefaultMask, &Router, IF, 1);
- }
- }
- else
- {
- IF->Unicast = DefaultMask;
- IF->Netmask = DefaultMask;
- }
-
- ZwClose(ParameterHandle);
- }
-
- IF->Broadcast.Type = IP_ADDRESS_V4;
- IF->Broadcast.Address.IPv4Address =
- IF->Unicast.Address.IPv4Address |
- ~IF->Netmask.Address.IPv4Address;
-
- TI_DbgPrint(DEBUG_DATALINK,("BCAST(IF) %s\n",
A2S(&IF->Broadcast)));
-
- /* Get maximum link speed */
- NdisStatus = NDISCall(Adapter,
- NdisRequestQueryInformation,
- OID_GEN_LINK_SPEED,
- &IF->Speed,
- sizeof(UINT));
-
- if( !NT_SUCCESS(NdisStatus) )
- IF->Speed = IP_DEFAULT_LINK_SPEED;
-
/* Register interface with IP layer */
IPRegisterInterface(IF);
+
+ /* Set adapter state */
+ Adapter->State = LAN_STATE_STARTED;
+ Adapter->Context = IF;
+
+ /* Configure the adapter */
+ ReconfigureAdapter(Adapter, FALSE);
/* Set packet filter so we can send and receive packets */
NdisStatus = NDISCall(Adapter,
@@ -1257,8 +1336,6 @@
return FALSE;
}
- Adapter->Context = IF;
- Adapter->State = LAN_STATE_STARTED;
return TRUE;
}
@@ -1301,7 +1378,6 @@
UINT MediaIndex;
NDIS_MEDIUM MediaArray[MAX_MEDIA];
UINT AddressOID;
- UINT Speed;
TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
@@ -1372,30 +1448,6 @@
return NDIS_STATUS_NOT_SUPPORTED;
}
- /* Get maximum frame size */
- NdisStatus = NDISCall(IF,
- NdisRequestQueryInformation,
- OID_GEN_MAXIMUM_FRAME_SIZE,
- &IF->MTU,
- sizeof(UINT));
- if (NdisStatus != NDIS_STATUS_SUCCESS) {
- TI_DbgPrint(DEBUG_DATALINK,("denying adapter %wZ (NDISCall)\n",
AdapterName));
- ExFreePoolWithTag(IF, LAN_ADAPTER_TAG);
- return NdisStatus;
- }
-
- /* Get maximum packet size */
- NdisStatus = NDISCall(IF,
- NdisRequestQueryInformation,
- OID_GEN_MAXIMUM_TOTAL_SIZE,
- &IF->MaxPacketSize,
- sizeof(UINT));
- if (NdisStatus != NDIS_STATUS_SUCCESS) {
- TI_DbgPrint(MIN_TRACE, ("Query for maximum packet size failed.\n"));
- ExFreePoolWithTag(IF, LAN_ADAPTER_TAG);
- return NdisStatus;
- }
-
/* Get maximum number of packets we can pass to NdisSend(Packets) at one time */
NdisStatus = NDISCall(IF,
NdisRequestQueryInformation,
@@ -1418,21 +1470,6 @@
ExFreePoolWithTag(IF, LAN_ADAPTER_TAG);
return NdisStatus;
}
-
- /* Get maximum link speed */
- NdisStatus = NDISCall(IF,
- NdisRequestQueryInformation,
- OID_GEN_LINK_SPEED,
- &Speed,
- sizeof(UINT));
- if (NdisStatus != NDIS_STATUS_SUCCESS) {
- TI_DbgPrint(MIN_TRACE, ("Query for maximum link speed failed.\n"));
- ExFreePoolWithTag(IF, LAN_ADAPTER_TAG);
- return NdisStatus;
- }
-
- /* Convert returned link speed to bps (it is in 100bps increments) */
- IF->Speed = Speed * 100L;
/* Bind adapter to IP layer */
if( !BindAdapter(IF, RegistryPath) ) {
Modified: branches/wlan-bringup/drivers/network/tcpip/include/ip.h
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/tc…
==============================================================================
--- branches/wlan-bringup/drivers/network/tcpip/include/ip.h [iso-8859-1] (original)
+++ branches/wlan-bringup/drivers/network/tcpip/include/ip.h [iso-8859-1] Fri Jan 13
07:28:16 2012
@@ -127,7 +127,6 @@
PVOID Context; /* Pointer to link layer context information */
UINT HeaderSize; /* Size of link level header */
UINT MinFrameSize; /* Minimum frame size in bytes */
- UINT MTU; /* Maximum transmission unit */
PUCHAR Address; /* Pointer to interface address */
UINT AddressLength; /* Length of address in bytes */
LL_TRANSMIT_ROUTINE Transmit; /* Transmit function for this interface */
Modified: branches/wlan-bringup/drivers/network/tcpip/include/lan.h
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/tc…
==============================================================================
--- branches/wlan-bringup/drivers/network/tcpip/include/lan.h [iso-8859-1] (original)
+++ branches/wlan-bringup/drivers/network/tcpip/include/lan.h [iso-8859-1] Fri Jan 13
07:28:16 2012
@@ -39,7 +39,7 @@
typedef struct LAN_ADAPTER {
LIST_ENTRY ListEntry; /* Entry on list */
KSPIN_LOCK Lock; /* Lock for this structure */
- UCHAR State; /* State of the adapter */
+ UCHAR State, OldState; /* State of the adapter */
KEVENT Event; /* Opening event */
PVOID Context; /* Upper layer context information */
NDIS_HANDLE NdisHandle; /* NDIS binding handle */
Modified: branches/wlan-bringup/drivers/network/tcpip/include/neighbor.h
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/tc…
==============================================================================
--- branches/wlan-bringup/drivers/network/tcpip/include/neighbor.h [iso-8859-1]
(original)
+++ branches/wlan-bringup/drivers/network/tcpip/include/neighbor.h [iso-8859-1] Fri Jan 13
07:28:16 2012
@@ -105,4 +105,6 @@
VOID NBResetNeighborTimeout(
PIP_ADDRESS Address);
+VOID NBDestroyNeighborsForInterface(PIP_INTERFACE Interface);
+
/* EOF */
Modified: branches/wlan-bringup/drivers/network/tcpip/include/router.h
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/tc…
==============================================================================
--- branches/wlan-bringup/drivers/network/tcpip/include/router.h [iso-8859-1] (original)
+++ branches/wlan-bringup/drivers/network/tcpip/include/router.h [iso-8859-1] Fri Jan 13
07:28:16 2012
@@ -43,6 +43,8 @@
NTSTATUS RouterShutdown(
VOID);
+VOID RouterRemoveRoutesForInterface(PIP_INTERFACE Interface);
+
UINT CountFIBs(PIP_INTERFACE IF);
UINT CopyFIBs( PIP_INTERFACE IF, PFIB_ENTRY Target );
Modified: branches/wlan-bringup/lib/drivers/ip/network/ip.c
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/lib/drivers/ip/net…
==============================================================================
--- branches/wlan-bringup/lib/drivers/ip/network/ip.c [iso-8859-1] (original)
+++ branches/wlan-bringup/lib/drivers/ip/network/ip.c [iso-8859-1] Fri Jan 13 07:28:16
2012
@@ -206,7 +206,6 @@
IF->Context = BindInfo->Context;
IF->HeaderSize = BindInfo->HeaderSize;
IF->MinFrameSize = BindInfo->MinFrameSize;
- IF->MTU = BindInfo->MTU;
IF->Address = BindInfo->Address;
IF->AddressLength = BindInfo->AddressLength;
IF->Transmit = BindInfo->Transmit;
@@ -314,11 +313,6 @@
IF->Index = ChosenIndex;
- if (!AddrIsUnspecified(&IF->Unicast))
- {
- IPAddInterfaceRoute(IF);
- }
-
/* Add interface to the global interface list */
TcpipInterlockedInsertTailList(&InterfaceListHead,
&IF->ListEntry,
Modified: branches/wlan-bringup/lib/drivers/ip/network/loopback.c
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/lib/drivers/ip/net…
==============================================================================
--- branches/wlan-bringup/lib/drivers/ip/network/loopback.c [iso-8859-1] (original)
+++ branches/wlan-bringup/lib/drivers/ip/network/loopback.c [iso-8859-1] Fri Jan 13
07:28:16 2012
@@ -106,13 +106,14 @@
BindInfo.Context = NULL;
BindInfo.HeaderSize = 0;
BindInfo.MinFrameSize = 0;
- BindInfo.MTU = 16384;
BindInfo.Address = NULL;
BindInfo.AddressLength = 0;
BindInfo.Transmit = LoopTransmit;
Loopback = IPCreateInterface(&BindInfo);
if (!Loopback) return NDIS_STATUS_RESOURCES;
+
+ Loopback->MTU = 16384;
Loopback->Name.Buffer = L"Loopback";
Loopback->Name.MaximumLength = Loopback->Name.Length =
@@ -123,6 +124,8 @@
AddrInitIPv4(&Loopback->Broadcast, LOOPBACK_BCASTADDR_IPv4);
IPRegisterInterface(Loopback);
+
+ IPAddInterfaceRoute(Loopback);
TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
Modified: branches/wlan-bringup/lib/drivers/ip/network/neighbor.c
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/lib/drivers/ip/net…
==============================================================================
--- branches/wlan-bringup/lib/drivers/ip/network/neighbor.c [iso-8859-1] (original)
+++ branches/wlan-bringup/lib/drivers/ip/network/neighbor.c [iso-8859-1] Fri Jan 13
07:28:16 2012
@@ -221,6 +221,42 @@
ARPTransmit(&NCE->Address,
(NCE->State & NUD_INCOMPLETE) ? NULL : NCE->LinkAddress,
NCE->Interface);
+}
+
+VOID NBDestroyNeighborsForInterface(PIP_INTERFACE Interface)
+{
+ KIRQL OldIrql;
+ PNEIGHBOR_CACHE_ENTRY *PrevNCE;
+ PNEIGHBOR_CACHE_ENTRY NCE;
+ ULONG i;
+
+ KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
+ for (i = 0; i <= NB_HASHMASK; i++)
+ {
+ TcpipAcquireSpinLockAtDpcLevel(&NeighborCache[i].Lock);
+
+ for (PrevNCE = &NeighborCache[i].Cache;
+ (NCE = *PrevNCE) != NULL;)
+ {
+ if (NCE->Interface == Interface)
+ {
+ /* Unlink and destroy the NCE */
+ *PrevNCE = NCE->Next;
+
+ NBFlushPacketQueue(NCE, NDIS_STATUS_REQUEST_ABORTED);
+ ExFreePoolWithTag(NCE, NCE_TAG);
+
+ continue;
+ }
+ else
+ {
+ PrevNCE = &NCE->Next;
+ }
+ }
+
+ TcpipReleaseSpinLockFromDpcLevel(&NeighborCache[i].Lock);
+ }
+ KeLowerIrql(OldIrql);
}
PNEIGHBOR_CACHE_ENTRY NBAddNeighbor(
Modified: branches/wlan-bringup/lib/drivers/ip/network/router.c
URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/lib/drivers/ip/net…
==============================================================================
--- branches/wlan-bringup/lib/drivers/ip/network/router.c [iso-8859-1] (original)
+++ branches/wlan-bringup/lib/drivers/ip/network/router.c [iso-8859-1] Fri Jan 13 07:28:16
2012
@@ -339,6 +339,29 @@
return NCE;
}
+VOID RouterRemoveRoutesForInterface(PIP_INTERFACE Interface)
+{
+ KIRQL OldIrql;
+ PLIST_ENTRY CurrentEntry;
+ PLIST_ENTRY NextEntry;
+ PFIB_ENTRY Current;
+
+ TcpipAcquireSpinLock(&FIBLock, &OldIrql);
+
+ CurrentEntry = FIBListHead.Flink;
+ while (CurrentEntry != &FIBListHead) {
+ NextEntry = CurrentEntry->Flink;
+ Current = CONTAINING_RECORD(CurrentEntry, FIB_ENTRY, ListEntry);
+
+ if (Interface == Current->Router->Interface)
+ DestroyFIBE(Current);
+
+ CurrentEntry = NextEntry;
+ }
+
+ TcpipReleaseSpinLock(&FIBLock, OldIrql);
+}
+
NTSTATUS RouterRemoveRoute(PIP_ADDRESS Target, PIP_ADDRESS Router)
/*
* FUNCTION: Removes a route from the Forward Information Base (FIB)