mirror of
https://github.com/reactos/reactos.git
synced 2024-06-29 01:12:06 +00:00
[IPCONFIG] Improvements to ipconfig
- Simplify the cleanup-code in ShowInfo - Print the 'Primary DNS suffix' and the 'DNS Suffix Search List' - Move the /registerdns message into its own function
This commit is contained in:
parent
5af2570b37
commit
1ca7d5d948
|
@ -499,22 +499,37 @@ VOID ShowInfo(BOOL bAll)
|
||||||
ULONG netOutBufLen = 0;
|
ULONG netOutBufLen = 0;
|
||||||
PIP_PER_ADAPTER_INFO pPerAdapterInfo = NULL;
|
PIP_PER_ADAPTER_INFO pPerAdapterInfo = NULL;
|
||||||
ULONG ulPerAdapterInfoLength = 0;
|
ULONG ulPerAdapterInfoLength = 0;
|
||||||
|
PSTR pszDomainName = NULL;
|
||||||
|
DWORD dwDomainNameSize = 0;
|
||||||
ULONG ret = 0;
|
ULONG ret = 0;
|
||||||
|
|
||||||
|
GetComputerNameExA(ComputerNameDnsDomain,
|
||||||
|
NULL,
|
||||||
|
&dwDomainNameSize);
|
||||||
|
if (dwDomainNameSize > 0)
|
||||||
|
{
|
||||||
|
pszDomainName = HeapAlloc(ProcessHeap,
|
||||||
|
0,
|
||||||
|
dwDomainNameSize * sizeof(TCHAR));
|
||||||
|
if (pszDomainName != NULL)
|
||||||
|
GetComputerNameExA(ComputerNameDnsDomain,
|
||||||
|
pszDomainName,
|
||||||
|
&dwDomainNameSize);
|
||||||
|
}
|
||||||
|
|
||||||
/* call GetAdaptersInfo to obtain the adapter info */
|
/* call GetAdaptersInfo to obtain the adapter info */
|
||||||
ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
|
ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
|
||||||
if (ret == ERROR_BUFFER_OVERFLOW)
|
if (ret == ERROR_BUFFER_OVERFLOW)
|
||||||
{
|
{
|
||||||
pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
|
pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
|
||||||
if (pAdapterInfo == NULL)
|
if (pAdapterInfo == NULL)
|
||||||
return;
|
goto done;
|
||||||
|
|
||||||
ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
|
ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
|
||||||
if (ret != NO_ERROR)
|
if (ret != NO_ERROR)
|
||||||
{
|
{
|
||||||
DoFormatMessage(0);
|
DoFormatMessage(0);
|
||||||
HeapFree(ProcessHeap, 0, pAdapterInfo);
|
goto done;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -522,7 +537,7 @@ VOID ShowInfo(BOOL bAll)
|
||||||
if (ret != ERROR_NO_DATA)
|
if (ret != ERROR_NO_DATA)
|
||||||
{
|
{
|
||||||
DoFormatMessage(0);
|
DoFormatMessage(0);
|
||||||
return;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,25 +547,18 @@ VOID ShowInfo(BOOL bAll)
|
||||||
pFixedInfo = (FIXED_INFO *)HeapAlloc(ProcessHeap, 0, netOutBufLen);
|
pFixedInfo = (FIXED_INFO *)HeapAlloc(ProcessHeap, 0, netOutBufLen);
|
||||||
if (pFixedInfo == NULL)
|
if (pFixedInfo == NULL)
|
||||||
{
|
{
|
||||||
if (pAdapterInfo)
|
goto done;
|
||||||
HeapFree(ProcessHeap, 0, pAdapterInfo);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (GetNetworkParams(pFixedInfo, &netOutBufLen) != NO_ERROR)
|
if (GetNetworkParams(pFixedInfo, &netOutBufLen) != NO_ERROR)
|
||||||
{
|
{
|
||||||
DoFormatMessage(0);
|
DoFormatMessage(0);
|
||||||
if (pAdapterInfo)
|
goto done;
|
||||||
HeapFree(ProcessHeap, 0, pAdapterInfo);
|
|
||||||
HeapFree(ProcessHeap, 0, pFixedInfo);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (pAdapterInfo)
|
|
||||||
HeapFree(ProcessHeap, 0, pAdapterInfo);
|
|
||||||
DoFormatMessage(0);
|
DoFormatMessage(0);
|
||||||
return;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
pAdapter = pAdapterInfo;
|
pAdapter = pAdapterInfo;
|
||||||
|
@ -559,7 +567,7 @@ VOID ShowInfo(BOOL bAll)
|
||||||
if (bAll)
|
if (bAll)
|
||||||
{
|
{
|
||||||
_tprintf(_T("\tHost Name . . . . . . . . . . . . : %s\n"), pFixedInfo->HostName);
|
_tprintf(_T("\tHost Name . . . . . . . . . . . . : %s\n"), pFixedInfo->HostName);
|
||||||
_tprintf(_T("\tPrimary DNS Suffix. . . . . . . . : \n"));
|
_tprintf(_T("\tPrimary DNS Suffix. . . . . . . . : %s\n"), (pszDomainName != NULL) ? pszDomainName : "");
|
||||||
_tprintf(_T("\tNode Type . . . . . . . . . . . . : %s\n"), GetNodeTypeName(pFixedInfo->NodeType));
|
_tprintf(_T("\tNode Type . . . . . . . . . . . . : %s\n"), GetNodeTypeName(pFixedInfo->NodeType));
|
||||||
if (pFixedInfo->EnableRouting)
|
if (pFixedInfo->EnableRouting)
|
||||||
_tprintf(_T("\tIP Routing Enabled. . . . . . . . : Yes\n"));
|
_tprintf(_T("\tIP Routing Enabled. . . . . . . . : Yes\n"));
|
||||||
|
@ -569,7 +577,15 @@ VOID ShowInfo(BOOL bAll)
|
||||||
_tprintf(_T("\tWINS Proxy enabled. . . . . . . . : Yes\n"));
|
_tprintf(_T("\tWINS Proxy enabled. . . . . . . . : Yes\n"));
|
||||||
else
|
else
|
||||||
_tprintf(_T("\tWINS Proxy enabled. . . . . . . . : No\n"));
|
_tprintf(_T("\tWINS Proxy enabled. . . . . . . . : No\n"));
|
||||||
_tprintf(_T("\tDNS Suffix Search List. . . . . . : %s\n"), pFixedInfo->DomainName);
|
if (pszDomainName != NULL && pszDomainName[0] != 0)
|
||||||
|
{
|
||||||
|
_tprintf(_T("\tDNS Suffix Search List. . . . . . : %s\n"), pszDomainName);
|
||||||
|
_tprintf(_T("\t %s\n"), pFixedInfo->DomainName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_tprintf(_T("\tDNS Suffix Search List. . . . . . : %s\n"), pFixedInfo->DomainName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (pAdapter)
|
while (pAdapter)
|
||||||
|
@ -682,7 +698,11 @@ VOID ShowInfo(BOOL bAll)
|
||||||
pAdapter = pAdapter->Next;
|
pAdapter = pAdapter->Next;
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapFree(ProcessHeap, 0, pFixedInfo);
|
done:
|
||||||
|
if (pszDomainName)
|
||||||
|
HeapFree(ProcessHeap, 0, pszDomainName);
|
||||||
|
if (pFixedInfo)
|
||||||
|
HeapFree(ProcessHeap, 0, pFixedInfo);
|
||||||
if (pAdapterInfo)
|
if (pAdapterInfo)
|
||||||
HeapFree(ProcessHeap, 0, pAdapterInfo);
|
HeapFree(ProcessHeap, 0, pAdapterInfo);
|
||||||
}
|
}
|
||||||
|
@ -826,6 +846,12 @@ FlushDns(VOID)
|
||||||
DoFormatMessage(GetLastError());
|
DoFormatMessage(GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
RegisterDns(VOID)
|
||||||
|
{
|
||||||
|
/* FIXME */
|
||||||
|
_tprintf(_T("\nSorry /registerdns is not implemented yet\n"));
|
||||||
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
VOID
|
VOID
|
||||||
|
@ -1089,7 +1115,7 @@ int main(int argc, char *argv[])
|
||||||
else if (DoFlushdns)
|
else if (DoFlushdns)
|
||||||
FlushDns();
|
FlushDns();
|
||||||
else if (DoRegisterdns)
|
else if (DoRegisterdns)
|
||||||
_tprintf(_T("\nSorry /registerdns is not implemented yet\n"));
|
RegisterDns();
|
||||||
else if (DoDisplaydns)
|
else if (DoDisplaydns)
|
||||||
DisplayDns();
|
DisplayDns();
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue