[IFMON] Test for DHCP configuration in the 'add address' and 'delete address' commands

This commit is contained in:
Eric Kohl
2026-06-21 17:24:22 +02:00
parent 0232efdd19
commit 8b54dc6c0c
3 changed files with 19 additions and 0 deletions
+14
View File
@@ -711,6 +711,14 @@ IpAddAddress(
if (pszAddress && pszMask)
{
if (pProperties->dwDhcp)
{
PrintMessageFromModule(hDllInstance,
IDS_ERROR_ADD_DHCP_ADDRESS);
dwError = ERROR_SUPPRESS_OUTPUT;
goto done;
}
dwLength = wcslen(pProperties->pszIpAddress) + wcslen(pszAddress) + 2;
pszNewIpAddress = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLength * sizeof(WCHAR));
if (pszNewIpAddress == NULL)
@@ -1113,6 +1121,12 @@ IpDeleteAddress(
if (bHaveAddress && pszAddress)
{
if (pProperties->dwDhcp)
{
PrintMessageFromModule(hDllInstance,
IDS_ERROR_DELETE_DHCP_ADDRESS);
return ERROR_SUPPRESS_OUTPUT;
}
#if 0
dwLength = wcslen(pProperties->pszIpAddress) + 1;
pszNewIpAddress = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLength * sizeof(WCHAR));
+3
View File
@@ -218,4 +218,7 @@ Parameters:\n\n\
IDS_ERROR_BAD_VALUE "\n%1!s! is not an acceptable value for %1!s!.\n"
IDS_ERROR_ALREADY_DHCP "\nDhcp is already enabled on this interface.\n"
IDS_ERROR_GET_PROPERTIES "\nError obtaining configuration for interface %1!s!.\n"
IDS_ERROR_ADD_DHCP_ADDRESS "\nCannot add a static IP address to an interface configured for DHCP.\n"
IDS_ERROR_DELETE_DHCP_ADDRESS "\nCannot delete Dhcp configured IP Address.\n"
END
+2
View File
@@ -67,3 +67,5 @@
#define IDS_ERROR_BAD_VALUE 2001
#define IDS_ERROR_ALREADY_DHCP 2002
#define IDS_ERROR_GET_PROPERTIES 2003
#define IDS_ERROR_ADD_DHCP_ADDRESS 2004
#define IDS_ERROR_DELETE_DHCP_ADDRESS 2005