diff --git a/dll/win32/ifmon/ip.c b/dll/win32/ifmon/ip.c index 5e2ba63f986..34136a58076 100644 --- a/dll/win32/ifmon/ip.c +++ b/dll/win32/ifmon/ip.c @@ -93,7 +93,8 @@ FormatIPv4Address( static DWORD IpShowAdapters( - _In_ DWORD DisplayFlags) + _In_ DWORD DisplayFlags, + _In_ PWSTR InterfaceName) { PIP_ADAPTER_ADDRESSES pAdapterAddresses = NULL, Ptr; PIP_ADAPTER_UNICAST_ADDRESS pUnicastAddress; @@ -132,111 +133,114 @@ IpShowAdapters( Ptr = pAdapterAddresses; while (Ptr) { - PrintMessageFromModule(hDllInstance, IDS_IP_HEADER, Ptr->FriendlyName); - - if (DisplayFlags & DISPLAY_ADRESSES) + if (InterfaceName == NULL || MatchToken(InterfaceName, Ptr->FriendlyName)) { - PrintMessageFromModule(hDllInstance, (Ptr->Flags & IP_ADAPTER_DHCP_ENABLED) ? IDS_DHCP_ON : IDS_DHCP_OFF); + PrintMessageFromModule(hDllInstance, IDS_IP_HEADER, Ptr->FriendlyName); - if (Ptr->FirstUnicastAddress == NULL) + if (DisplayFlags & DISPLAY_ADRESSES) { - PrintMessageFromModule(hDllInstance, IDS_NOIPADDRESS); - } - else - { - First = TRUE; - pUnicastAddress = Ptr->FirstUnicastAddress; - while (pUnicastAddress) + PrintMessageFromModule(hDllInstance, (Ptr->Flags & IP_ADAPTER_DHCP_ENABLED) ? IDS_DHCP_ON : IDS_DHCP_OFF); + + if (Ptr->FirstUnicastAddress == NULL) { - if (FormatIPv4Address(IpBuffer, &pUnicastAddress->Address)) - { - if (First) - { - PrintMessageFromModule(hDllInstance, (pUnicastAddress->Next)? IDS_IPADDRESSES : IDS_IPADDRESS, IpBuffer); - } - else - { - PrintMessageFromModule(hDllInstance, IDS_EMPTYLINE, IpBuffer); - } - First = FALSE; - } - - pUnicastAddress = pUnicastAddress->Next; + PrintMessageFromModule(hDllInstance, IDS_NOIPADDRESS); } - } - - if (Ptr->FirstPrefix == NULL) - { - PrintMessage(L" SubnetMask: %s\n", L"None"); - } - else - { - First = TRUE; - pPrefix = Ptr->FirstPrefix; - while (pPrefix) - { - if (FormatIPv4Address(IpBuffer, &pPrefix->Address)) - { - if (First) - { - if (pPrefix->Next) - PrintMessage(L" SubnetMasks: %s/%lu\n", IpBuffer, pPrefix->PrefixLength); - else - PrintMessage(L" IP Address: %s/%lu\n", IpBuffer, pPrefix->PrefixLength); - } - else - { - PrintMessage(L" %s/%lu\n", IpBuffer, pPrefix->PrefixLength); - } - First = FALSE; - } - - pPrefix = pPrefix->Next; - } - } - -// PrintMessage(L" Default Gateway: %s\n", L"---"); -// PrintMessage(L" Gateway Metric: %s\n", L"---"); -// PrintMessage(L" Interface Metric: %s\n", L"---"); - } - - if (DisplayFlags & DISPLAY_DNS) - { - if (Ptr->FirstDnsServerAddress == NULL) - { - if (Ptr->Flags & IP_ADAPTER_DHCP_ENABLED) - PrintMessage(L" DNS servers configured through DHCP: %s\n", L"None"); else - PrintMessage(L" Statically configured DNS Servers: %s\n", L"None"); - } - else - { - First = TRUE; - pDnsServer = Ptr->FirstDnsServerAddress; - while (pDnsServer) { - if (FormatIPv4Address(IpBuffer, &pDnsServer->Address)) + First = TRUE; + pUnicastAddress = Ptr->FirstUnicastAddress; + while (pUnicastAddress) { - if (First == TRUE) + if (FormatIPv4Address(IpBuffer, &pUnicastAddress->Address)) { - if (Ptr->Flags & IP_ADAPTER_DHCP_ENABLED) - PrintMessage(L" DNS servers configured through DHCP: %s\n", IpBuffer); + if (First) + { + PrintMessageFromModule(hDllInstance, (pUnicastAddress->Next)? IDS_IPADDRESSES : IDS_IPADDRESS, IpBuffer); + } else - PrintMessage(L" Statically configured DNS Servers: %s\n", IpBuffer); - } - else - { - PrintMessage(L" %s\n", IpBuffer); + { + PrintMessageFromModule(hDllInstance, IDS_EMPTYLINE, IpBuffer); + } + First = FALSE; } - First = FALSE; + pUnicastAddress = pUnicastAddress->Next; } - - pDnsServer = pDnsServer->Next; } + + if (Ptr->FirstPrefix == NULL) + { + PrintMessage(L" SubnetMask: %s\n", L"None"); + } + else + { + First = TRUE; + pPrefix = Ptr->FirstPrefix; + while (pPrefix) + { + if (FormatIPv4Address(IpBuffer, &pPrefix->Address)) + { + if (First) + { + if (pPrefix->Next) + PrintMessage(L" SubnetMasks: %s/%lu\n", IpBuffer, pPrefix->PrefixLength); + else + PrintMessage(L" IP Address: %s/%lu\n", IpBuffer, pPrefix->PrefixLength); + } + else + { + PrintMessage(L" %s/%lu\n", IpBuffer, pPrefix->PrefixLength); + } + First = FALSE; + } + + pPrefix = pPrefix->Next; + } + } + +// PrintMessage(L" Default Gateway: %s\n", L"---"); +// PrintMessage(L" Gateway Metric: %s\n", L"---"); +// PrintMessage(L" Interface Metric: %s\n", L"---"); } -// PrintMessage(L" Register with which suffix:\n"); + if (DisplayFlags & DISPLAY_DNS) + { + if (Ptr->FirstDnsServerAddress == NULL) + { + if (Ptr->Flags & IP_ADAPTER_DHCP_ENABLED) + PrintMessage(L" DNS servers configured through DHCP: %s\n", L"None"); + else + PrintMessage(L" Statically configured DNS Servers: %s\n", L"None"); + } + else + { + First = TRUE; + pDnsServer = Ptr->FirstDnsServerAddress; + while (pDnsServer) + { + if (FormatIPv4Address(IpBuffer, &pDnsServer->Address)) + { + if (First == TRUE) + { + if (Ptr->Flags & IP_ADAPTER_DHCP_ENABLED) + PrintMessage(L" DNS servers configured through DHCP: %s\n", IpBuffer); + else + PrintMessage(L" Statically configured DNS Servers: %s\n", IpBuffer); + } + else + { + PrintMessage(L" %s\n", IpBuffer); + } + + First = FALSE; + } + + pDnsServer = pDnsServer->Next; + } + } + +// PrintMessage(L" Register with which suffix:\n"); + } } Ptr = Ptr->Next; @@ -264,7 +268,15 @@ IpShowAddresses( LPCVOID pvData, BOOL *pbDone) { - return IpShowAdapters(DISPLAY_ADRESSES); + PWSTR pszInterfaceName = NULL; + + if (dwArgCount - dwCurrentIndex > 1) + return ERROR_INVALID_PARAMETER; + + if (dwArgCount - dwCurrentIndex == 1) + pszInterfaceName = argv[dwCurrentIndex]; + + return IpShowAdapters(DISPLAY_ADRESSES, pszInterfaceName); } @@ -280,7 +292,15 @@ IpShowConfig( LPCVOID pvData, BOOL *pbDone) { - return IpShowAdapters(DISPLAY_ADRESSES | DISPLAY_DNS); + PWSTR pszInterfaceName = NULL; + + if (dwArgCount - dwCurrentIndex > 1) + return ERROR_INVALID_PARAMETER; + + if (dwArgCount - dwCurrentIndex == 1) + pszInterfaceName = argv[dwCurrentIndex]; + + return IpShowAdapters(DISPLAY_ADRESSES | DISPLAY_DNS, pszInterfaceName); } @@ -296,7 +316,15 @@ IpShowDns( LPCVOID pvData, BOOL *pbDone) { - return IpShowAdapters(DISPLAY_DNS); + PWSTR pszInterfaceName = NULL; + + if (dwArgCount - dwCurrentIndex > 1) + return ERROR_INVALID_PARAMETER; + + if (dwArgCount - dwCurrentIndex == 1) + pszInterfaceName = argv[dwCurrentIndex]; + + return IpShowAdapters(DISPLAY_DNS, pszInterfaceName); } diff --git a/dll/win32/ifmon/lang/en-US.rc b/dll/win32/ifmon/lang/en-US.rc index dc138966dce..f7fd185191f 100644 --- a/dll/win32/ifmon/lang/en-US.rc +++ b/dll/win32/ifmon/lang/en-US.rc @@ -8,11 +8,11 @@ BEGIN IDS_HLP_IP_SHOW "Displays IP information." IDS_HLP_ADDRESSES "Displays IP address configuration." - IDS_HLP_ADDRESSES_EX "Usage: addresses\n\n Display IP address configuration.\n" + IDS_HLP_ADDRESSES_EX "Usage: addresses [string]\n\n Display IP address configuration.\n" IDS_HLP_CONFIG "Displays IP address and additional information." - IDS_HLP_CONFIG_EX "Usage: config\n\n Display IP address and additional information.\n" + IDS_HLP_CONFIG_EX "Usage: config [string]\n\n Display IP address and additional information.\n" IDS_HLP_DNS "Displays the DNS server addresses." - IDS_HLP_DNS_EX "Usage: dns\n\n Display DNS server adresses.\n" + IDS_HLP_DNS_EX "Usage: dns [string]\n\n Display DNS server adresses.\n" IDS_IP_HEADER "\nConfiguration for interface ""%s""\n" IDS_DHCP_ON " DHCP enabled: Yes\n"