- Live update of static IP address from ctl panel.

- Fix removing adapter route on IP address delete.

svn path=/trunk/; revision=21899
This commit is contained in:
Art Yerkes 2006-05-13 06:41:23 +00:00
parent a9680a89a6
commit c68622792c
4 changed files with 59 additions and 3 deletions

View file

@ -71,6 +71,7 @@ ManualDNS(HWND Dlg, BOOL Enabled) {
if (! Enabled) {
SendDlgItemMessage(Dlg, IDC_DNS1, IPM_CLEARADDRESS, 0, 0);
SendDlgItemMessage(Dlg, IDC_DNS2, IPM_CLEARADDRESS, 0, 0);
}
}
@ -132,10 +133,13 @@ static BOOL
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 @@ ValidateAndStore(HWND Dlg, PTCPIP_PROPERTIES_DATA DlgData)
} 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 @@ InternTCPIPSettings(HWND Dlg, PTCPIP_PROPERTIES_DATA DlgData) {
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:

View file

@ -1548,6 +1548,7 @@ NTSTATUS DispTdiDeleteIPAddress( PIRP Irp, PIO_STACK_LOCATION IrpSp ) {
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;

View file

@ -305,14 +305,19 @@ VOID IPRemoveInterfaceRoute( PIP_INTERFACE IF ) {
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(

View file

@ -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 @@ NTSTATUS RouterRemoveRoute(PIP_ADDRESS Target, PIP_ADDRESS Router)
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);
RouterDumpRoutes();
CurrentEntry = FIBListHead.Flink;
while (CurrentEntry != &FIBListHead) {
NextEntry = CurrentEntry->Flink;
Current = CONTAINING_RECORD(CurrentEntry, FIB_ENTRY, ListEntry);
Current = CONTAINING_RECORD(CurrentEntry, FIB_ENTRY, ListEntry);
NCE = Current->Router;
@ -356,6 +384,8 @@ NTSTATUS RouterRemoveRoute(PIP_ADDRESS Target, PIP_ADDRESS Router)
DestroyFIBE( Current );
}
RouterDumpRoutes();
TcpipReleaseSpinLock(&FIBLock, OldIrql);
TI_DbgPrint(DEBUG_ROUTER, ("Leaving\n"));