Author: arty
Date: Sat May 13 10:41:23 2006
New Revision: 21899
URL:
http://svn.reactos.ru/svn/reactos?rev=21899&view=rev
Log:
- Live update of static IP address from ctl panel.
- Fix removing adapter route on IP address delete.
Modified:
trunk/reactos/dll/cpl/ncpa/tcpip_properties.c
trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c
trunk/reactos/lib/drivers/ip/network/ip.c
trunk/reactos/lib/drivers/ip/network/router.c
Modified: trunk/reactos/dll/cpl/ncpa/tcpip_properties.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/cpl/ncpa/tcpip_properti…
==============================================================================
--- trunk/reactos/dll/cpl/ncpa/tcpip_properties.c (original)
+++ trunk/reactos/dll/cpl/ncpa/tcpip_properties.c Sat May 13 10:41:23 2006
@@ -71,6 +71,7 @@
if (! Enabled) {
SendDlgItemMessage(Dlg, IDC_DNS1, IPM_CLEARADDRESS, 0, 0);
SendDlgItemMessage(Dlg, IDC_DNS2, IPM_CLEARADDRESS, 0, 0);
+
}
}
@@ -132,10 +133,13 @@
ValidateAndStore(HWND Dlg, PTCPIP_PROPERTIES_DATA DlgData)
{
DWORD IpAddress;
+ MIB_IPFORWARDROW RowToAdd = { 0 }, RowToRem = { 0 };
DlgData->DhcpEnabled = (BST_CHECKED ==
IsDlgButtonChecked(Dlg, IDC_USEDHCP));
if (! DlgData->DhcpEnabled) {
+ DhcpReleaseIpAddressLease( DlgData->AdapterIndex );
+
if (4 != SendMessageW(GetDlgItem(Dlg, IDC_IPADDR), IPM_GETADDRESS,
0, (LPARAM) &IpAddress)) {
ShowError(Dlg, IDS_ENTER_VALID_IPADDRESS);
@@ -156,11 +160,26 @@
} else {
DlgData->Gateway = htonl(IpAddress);
}
+ DhcpStaticRefreshParams
+ ( DlgData->AdapterIndex, DlgData->IpAddress, DlgData->SubnetMask );
+
+ RowToRem.dwForwardMask = 0;
+ RowToRem.dwForwardMetric1 = 1;
+ RowToRem.dwForwardNextHop = DlgData->OldGateway;
+
+ DeleteIpForwardEntry( &RowToRem );
+
+ RowToAdd.dwForwardMask = 0;
+ RowToAdd.dwForwardMetric1 = 1;
+ RowToAdd.dwForwardNextHop = DlgData->Gateway;
+
+ CreateIpForwardEntry( &RowToAdd );
ASSERT(BST_CHECKED == IsDlgButtonChecked(Dlg, IDC_FIXEDDNS));
} else {
DlgData->IpAddress = INADDR_NONE;
DlgData->SubnetMask = INADDR_NONE;
DlgData->Gateway = INADDR_NONE;
+ DhcpLeaseIpAddress( DlgData->AdapterIndex );
}
if (BST_CHECKED == IsDlgButtonChecked(Dlg, IDC_FIXEDDNS)) {
@@ -251,7 +270,8 @@
goto cleanup;
}
- MessageBox(NULL, TEXT("You need to reboot before the new parameters take
effect."), TEXT("Reboot required"), MB_OK | MB_ICONWARNING);
+ // arty ... Not needed anymore ... We update the address live now
+ //MessageBox(NULL, TEXT("You need to reboot before the new parameters take
effect."), TEXT("Reboot required"), MB_OK | MB_ICONWARNING);
ret = TRUE;
cleanup:
Modified: trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/drivers/network/tcpip/tcpip…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c (original)
+++ trunk/reactos/drivers/network/tcpip/tcpip/dispatch.c Sat May 13 10:41:23 2006
@@ -1548,6 +1548,7 @@
ForEachInterface(IF) {
if( IF->Index == *NteIndex ) {
+ IPRemoveInterfaceRoute( IF );
IF->Unicast.Type = IP_ADDRESS_V4;
IF->Unicast.Address.IPv4Address = 0;
IF->Netmask.Type = IP_ADDRESS_V4;
Modified: trunk/reactos/lib/drivers/ip/network/ip.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/drivers/ip/network/ip.c…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/ip.c (original)
+++ trunk/reactos/lib/drivers/ip/network/ip.c Sat May 13 10:41:23 2006
@@ -305,14 +305,19 @@
TCPDisposeInterfaceData( IF->TCPContext );
IF->TCPContext = NULL;
+ TI_DbgPrint(DEBUG_IP,("Removing interface Addr %s\n",
A2S(&IF->Unicast)));
+ TI_DbgPrint(DEBUG_IP,(" Mask %s\n",
A2S(&IF->Netmask)));
+
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);
-
+ else
+ TI_DbgPrint(DEBUG_IP, ("Could not delete IF route (0x%X)\n", IF));
}
VOID IPUnregisterInterface(
Modified: trunk/reactos/lib/drivers/ip/network/router.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/drivers/ip/network/rout…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/router.c (original)
+++ trunk/reactos/lib/drivers/ip/network/router.c Sat May 13 10:41:23 2006
@@ -18,6 +18,30 @@
LIST_ENTRY FIBListHead;
KSPIN_LOCK FIBLock;
+void RouterDumpRoutes() {
+ PLIST_ENTRY CurrentEntry;
+ PLIST_ENTRY NextEntry;
+ PFIB_ENTRY Current;
+ PNEIGHBOR_CACHE_ENTRY NCE;
+
+ TI_DbgPrint(DEBUG_ROUTER,("Dumping Routes\n"));
+
+ CurrentEntry = FIBListHead.Flink;
+ while (CurrentEntry != &FIBListHead) {
+ NextEntry = CurrentEntry->Flink;
+ Current = CONTAINING_RECORD(CurrentEntry, FIB_ENTRY, ListEntry);
+
+ NCE = Current->Router;
+
+ TI_DbgPrint(DEBUG_ROUTER,("Examining FIBE %x\n", Current));
+ TI_DbgPrint(DEBUG_ROUTER,("... NetworkAddress %s\n",
A2S(&Current->NetworkAddress)));
+ TI_DbgPrint(DEBUG_ROUTER,("... NCE->Address . %s\n",
A2S(&NCE->Address)));
+
+ CurrentEntry = NextEntry;
+ }
+
+ TI_DbgPrint(DEBUG_ROUTER,("Dumping Routes ... Done\n"));
+}
VOID FreeFIB(
PVOID Object)
@@ -331,13 +355,17 @@
PNEIGHBOR_CACHE_ENTRY NCE;
TI_DbgPrint(DEBUG_ROUTER, ("Called\n"));
+ TI_DbgPrint(DEBUG_ROUTER, ("Deleting Route From: %s\n", A2S(Router)));
+ TI_DbgPrint(DEBUG_ROUTER, (" To: %s\n", A2S(Target)));
TcpipAcquireSpinLock(&FIBLock, &OldIrql);
- CurrentEntry = FIBListHead.Flink;
- while (CurrentEntry != &FIBListHead) {
- NextEntry = CurrentEntry->Flink;
- Current = CONTAINING_RECORD(CurrentEntry, FIB_ENTRY, ListEntry);
+ RouterDumpRoutes();
+
+ CurrentEntry = FIBListHead.Flink;
+ while (CurrentEntry != &FIBListHead) {
+ NextEntry = CurrentEntry->Flink;
+ Current = CONTAINING_RECORD(CurrentEntry, FIB_ENTRY, ListEntry);
NCE = Current->Router;
@@ -355,6 +383,8 @@
TI_DbgPrint(DEBUG_ROUTER, ("Deleting route\n"));
DestroyFIBE( Current );
}
+
+ RouterDumpRoutes();
TcpipReleaseSpinLock(&FIBLock, OldIrql);