mirror of
https://github.com/reactos/reactos.git
synced 2025-07-25 11:53:54 +00:00
[IPCONFIG][DNSAPI][SDK] Renamed DNSCACHEENTRY and fixed its type field(s)
Now, 'ipconfig /displaydns' displays A- and AAAA-records correctly.
This commit is contained in:
parent
9bf672d4f1
commit
789edebfac
3 changed files with 201 additions and 159 deletions
|
@ -34,6 +34,59 @@
|
|||
HINSTANCE hInstance;
|
||||
HANDLE ProcessHeap;
|
||||
|
||||
BOOL
|
||||
DoNamesMatch(
|
||||
_In_ LPWSTR pszName,
|
||||
_In_ LPTSTR pszPattern)
|
||||
{
|
||||
if (pszPattern == NULL)
|
||||
return TRUE;
|
||||
|
||||
// if (_wcsicmp(pszName, pszPattern) == 0)
|
||||
// return TRUE;
|
||||
#if 0
|
||||
for (;;)
|
||||
{
|
||||
if (*pszPattern == L'*')
|
||||
{
|
||||
pszPattern++;
|
||||
if (*pszPattern == L'\0')
|
||||
return TRUE;
|
||||
|
||||
while (towlower(*pszName) != towlower(*pszPattern))
|
||||
{
|
||||
if (*pszName == L'\0')
|
||||
return FALSE;
|
||||
|
||||
pszName++;
|
||||
}
|
||||
}
|
||||
else if (*pszPattern == L'?')
|
||||
{
|
||||
pszPattern++;
|
||||
|
||||
if (*pszName == L'\0')
|
||||
return FALSE;
|
||||
|
||||
pszName++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*pszName == L'\0' && *pszPattern == L'\0')
|
||||
return TRUE;
|
||||
|
||||
if (towlower(*pszName) != towlower(*pszPattern))
|
||||
return FALSE;
|
||||
|
||||
pszName++;
|
||||
pszPattern++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int LoadStringAndOem(HINSTANCE hInst,
|
||||
UINT uID,
|
||||
LPTSTR szNode,
|
||||
|
@ -607,10 +660,6 @@ VOID Release(LPTSTR Index)
|
|||
IP_ADAPTER_INDEX_MAP AdapterInfo;
|
||||
DWORD ret;
|
||||
DWORD i;
|
||||
|
||||
/* if interface is not given, query GetInterfaceInfo */
|
||||
if (Index == NULL)
|
||||
{
|
||||
PIP_INTERFACE_INFO pInfo = NULL;
|
||||
ULONG ulOutBufLen = 0;
|
||||
|
||||
|
@ -623,6 +672,8 @@ VOID Release(LPTSTR Index)
|
|||
if (GetInterfaceInfo(pInfo, &ulOutBufLen) == NO_ERROR )
|
||||
{
|
||||
for (i = 0; i < pInfo->NumAdapters; i++)
|
||||
{
|
||||
if (DoNamesMatch(pInfo->Adapter[i].Name, Index))
|
||||
{
|
||||
CopyMemory(&AdapterInfo, &pInfo->Adapter[i], sizeof(IP_ADAPTER_INDEX_MAP));
|
||||
_tprintf(_T("name - %ls\n"), pInfo->Adapter[i].Name);
|
||||
|
@ -634,6 +685,7 @@ VOID Release(LPTSTR Index)
|
|||
DoFormatMessage(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HeapFree(ProcessHeap, 0, pInfo);
|
||||
}
|
||||
|
@ -650,30 +702,13 @@ VOID Release(LPTSTR Index)
|
|||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
;
|
||||
/* FIXME:
|
||||
* we need to be able to release connections by name with support for globbing
|
||||
* i.e. ipconfig /release Eth* will release all cards starting with Eth...
|
||||
* ipconfig /release *con* will release all cards with 'con' in their name
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VOID Renew(LPTSTR Index)
|
||||
{
|
||||
IP_ADAPTER_INDEX_MAP AdapterInfo;
|
||||
DWORD i;
|
||||
|
||||
/* if interface is not given, query GetInterfaceInfo */
|
||||
if (Index == NULL)
|
||||
{
|
||||
PIP_INTERFACE_INFO pInfo;
|
||||
ULONG ulOutBufLen = 0;
|
||||
DWORD i;
|
||||
|
||||
pInfo = (IP_INTERFACE_INFO *)HeapAlloc(ProcessHeap, 0, sizeof(IP_INTERFACE_INFO));
|
||||
if (pInfo == NULL)
|
||||
|
@ -699,6 +734,8 @@ VOID Renew(LPTSTR Index)
|
|||
if (GetInterfaceInfo(pInfo, &ulOutBufLen) == NO_ERROR)
|
||||
{
|
||||
for (i = 0; i < pInfo->NumAdapters; i++)
|
||||
{
|
||||
if (DoNamesMatch(pInfo->Adapter[i].Name, Index))
|
||||
{
|
||||
CopyMemory(&AdapterInfo, &pInfo->Adapter[i], sizeof(IP_ADAPTER_INDEX_MAP));
|
||||
_tprintf(_T("name - %ls\n"), pInfo->Adapter[i].Name);
|
||||
|
@ -711,6 +748,7 @@ VOID Renew(LPTSTR Index)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_tprintf(_T("\nGetInterfaceInfo failed : "));
|
||||
|
@ -719,16 +757,6 @@ VOID Renew(LPTSTR Index)
|
|||
|
||||
HeapFree(ProcessHeap, 0, pInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
;
|
||||
/* FIXME:
|
||||
* we need to be able to renew connections by name with support for globbing
|
||||
* i.e. ipconfig /renew Eth* will renew all cards starting with Eth...
|
||||
* ipconfig /renew *con* will renew all cards with 'con' in their name
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
FlushDns(VOID)
|
||||
|
@ -741,42 +769,40 @@ FlushDns(VOID)
|
|||
DoFormatMessage(GetLastError());
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
VOID
|
||||
DisplayDns(VOID)
|
||||
DisplayDnsRecord(
|
||||
PWSTR pszName,
|
||||
WORD wType)
|
||||
{
|
||||
PDNSCACHEENTRY DnsEntry = NULL, pThisEntry, pNextEntry;
|
||||
PDNS_RECORDW pQueryResults, pThisRecord, pNextRecord;
|
||||
PDNS_RECORDW pQueryResults = NULL, pThisRecord, pNextRecord;
|
||||
WCHAR szBuffer[48];
|
||||
IN_ADDR Addr4;
|
||||
IN6_ADDR Addr6;
|
||||
WCHAR szBuffer[48];
|
||||
DNS_STATUS Status;
|
||||
|
||||
_tprintf(_T("\nReactOS IP Configuration\n\n"));
|
||||
|
||||
if (!DnsGetCacheDataTable(&DnsEntry))
|
||||
{
|
||||
DoFormatMessage(GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
if (DnsEntry == NULL)
|
||||
return;
|
||||
|
||||
pThisEntry = DnsEntry;
|
||||
while (pThisEntry != NULL)
|
||||
{
|
||||
pNextEntry = pThisEntry->pNext;
|
||||
|
||||
pQueryResults = NULL;
|
||||
Status = DnsQuery_W(pThisEntry->pszName,
|
||||
pThisEntry->wType,
|
||||
Status = DnsQuery_W(pszName,
|
||||
wType,
|
||||
DNS_QUERY_NO_WIRE_QUERY,
|
||||
NULL,
|
||||
(PDNS_RECORD *)&pQueryResults,
|
||||
NULL);
|
||||
if (Status == 0)
|
||||
if (Status != ERROR_SUCCESS)
|
||||
{
|
||||
_tprintf(_T("\t%S\n"), pThisEntry->pszName);
|
||||
#if 0
|
||||
if (wType != 0)
|
||||
{
|
||||
_tprintf(_T("\t%S\n"), pszName);
|
||||
_tprintf(_T("\t----------------------------------------\n"));
|
||||
_tprintf(_T("\tNo records of type %hu\n\n"), wType);
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
_tprintf(_T("\t%S\n"), pszName);
|
||||
_tprintf(_T("\t----------------------------------------\n"));
|
||||
|
||||
pThisRecord = pQueryResults;
|
||||
|
@ -840,15 +866,34 @@ DisplayDns(VOID)
|
|||
}
|
||||
|
||||
DnsRecordListFree((PDNS_RECORD)pQueryResults, DnsFreeRecordList);
|
||||
pQueryResults = NULL;
|
||||
}
|
||||
else if (Status != ERROR_SUCCESS && pThisEntry->wType != 0)
|
||||
|
||||
|
||||
VOID
|
||||
DisplayDns(VOID)
|
||||
{
|
||||
_tprintf(_T("\t%S\n"), pThisEntry->pszName);
|
||||
_tprintf(_T("\t----------------------------------------\n"));
|
||||
_tprintf(_T("\tNo records of type %hu\n\n"), pThisEntry->wType);
|
||||
PDNS_CACHE_ENTRY DnsEntry = NULL, pThisEntry, pNextEntry;
|
||||
|
||||
_tprintf(_T("\nReactOS IP Configuration\n\n"));
|
||||
|
||||
if (!DnsGetCacheDataTable(&DnsEntry))
|
||||
{
|
||||
DoFormatMessage(GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
if (DnsEntry == NULL)
|
||||
return;
|
||||
|
||||
pThisEntry = DnsEntry;
|
||||
while (pThisEntry != NULL)
|
||||
{
|
||||
pNextEntry = pThisEntry->pNext;
|
||||
|
||||
DisplayDnsRecord(pThisEntry->pszName, pThisEntry->wType1);
|
||||
if (pThisEntry->wType2 != 0)
|
||||
DisplayDnsRecord(pThisEntry->pszName, pThisEntry->wType2);
|
||||
|
||||
if (pThisEntry->pszName)
|
||||
LocalFree(pThisEntry->pszName);
|
||||
LocalFree(pThisEntry);
|
||||
|
@ -890,8 +935,6 @@ VOID Usage(VOID)
|
|||
HeapFree(ProcessHeap, 0, lpUsage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -975,10 +1018,9 @@ int main(int argc, char *argv[])
|
|||
break;
|
||||
case 3: /* Process all the options that can have 1 parameter */
|
||||
if (DoRelease)
|
||||
_tprintf(_T("\nSorry /release [adapter] is not implemented yet\n"));
|
||||
//Release(argv[2]);
|
||||
Release(argv[2]);
|
||||
else if (DoRenew)
|
||||
_tprintf(_T("\nSorry /renew [adapter] is not implemented yet\n"));
|
||||
Renew(argv[2]);
|
||||
else if (DoShowclassid)
|
||||
_tprintf(_T("\nSorry /showclassid adapter is not implemented yet\n"));
|
||||
else if (DoSetclassid)
|
||||
|
|
|
@ -276,7 +276,7 @@ DnsGetBufferLengthForStringCopy()
|
|||
BOOL
|
||||
WINAPI
|
||||
DnsGetCacheDataTable(
|
||||
_Out_ PDNSCACHEENTRY *DnsCache)
|
||||
_Out_ PDNS_CACHE_ENTRY *DnsCache)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return TRUE;
|
||||
|
|
|
@ -9,10 +9,10 @@ typedef struct _DNS_CACHE_ENTRY
|
|||
{
|
||||
struct _DNS_CACHE_ENTRY *pNext; /* Pointer to next entry */
|
||||
PWSTR pszName; /* DNS Record Name */
|
||||
unsigned short wType; /* DNS Record Type */
|
||||
unsigned short wUnknown; /* Unknown */
|
||||
unsigned short wType1; /* DNS Record Type 1 */
|
||||
unsigned short wType2; /* DNS Record Type 2 */
|
||||
unsigned short wFlags; /* DNS Record Flags */
|
||||
} DNSCACHEENTRY, *PDNSCACHEENTRY;
|
||||
} DNS_CACHE_ENTRY, *PDNS_CACHE_ENTRY;
|
||||
|
||||
BOOL
|
||||
WINAPI
|
||||
|
@ -21,7 +21,7 @@ DnsFlushResolverCache(VOID);
|
|||
BOOL
|
||||
WINAPI
|
||||
DnsGetCacheDataTable(
|
||||
_Out_ PDNSCACHEENTRY *DnsCache);
|
||||
_Out_ PDNS_CACHE_ENTRY *DnsCache);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue