Author: phater
Date: Thu Jun 1 15:22:06 2017
New Revision: 74730
URL:
http://svn.reactos.org/svn/reactos?rev=74730&view=rev
Log:
[MSWSOCK] Change functions to be able to use control flags with DnsQuery.
Add host aliases to hostent if available and requested.
Only copy servent aliases if available and requested.
Modified:
trunk/reactos/dll/win32/mswsock/mswhelper.c
trunk/reactos/dll/win32/mswsock/mswhelper.h
trunk/reactos/dll/win32/mswsock/nsplookup.c
Modified: trunk/reactos/dll/win32/mswsock/mswhelper.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/mswsock/mswhelpe…
==============================================================================
--- trunk/reactos/dll/win32/mswsock/mswhelper.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/mswsock/mswhelper.c [iso-8859-1] Thu Jun 1 15:22:06 2017
@@ -226,6 +226,7 @@
BOOL
mswBufferAppendBlob_Hostent(_Inout_ PMSW_BUFFER mswBuf,
_Inout_ LPWSAQUERYSETW lpRes,
+ _In_ char** hostAliasesA,
_In_ char* hostnameA,
_In_ DWORD ip4addr)
{
@@ -256,8 +257,18 @@
/* aliases */
phe->h_aliases = (char**)(mswBufferEndPtr(mswBuf) - bytesOfs);
- if (!mswBufferAppendPtr(mswBuf, NULL))
- return FALSE;
+ if (hostAliasesA)
+ {
+ if (!mswBufferAppendStrLstA(mswBuf,
+ (void**)hostAliasesA,
+ -(DWORD)bytesOfs))
+ return FALSE;
+ }
+ else
+ {
+ if (!mswBufferAppendPtr(mswBuf, NULL))
+ return FALSE;
+ }
/* addr_list */
RtlZeroMemory(lst, sizeof(lst));
@@ -308,10 +319,18 @@
pse->s_aliases = (char**)(mswBufferEndPtr(mswBuf) - bytesOfs);
- if (!mswBufferAppendStrLstA(mswBuf,
- (void**)serviceAliasesA,
- -(DWORD)bytesOfs))
- return FALSE;
+ if (serviceAliasesA)
+ {
+ if (!mswBufferAppendStrLstA(mswBuf,
+ (void**)serviceAliasesA,
+ -(DWORD)bytesOfs))
+ return FALSE;
+ }
+ else
+ {
+ if (!mswBufferAppendPtr(mswBuf, NULL))
+ return FALSE;
+ }
pse->s_name = (char*)(mswBufferEndPtr(mswBuf) - bytesOfs);
Modified: trunk/reactos/dll/win32/mswsock/mswhelper.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/mswsock/mswhelpe…
==============================================================================
--- trunk/reactos/dll/win32/mswsock/mswhelper.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/mswsock/mswhelper.h [iso-8859-1] Thu Jun 1 15:22:06 2017
@@ -69,7 +69,8 @@
mswBufferAppendBlob_Hostent(
_Inout_ PMSW_BUFFER mswBuf,
_Inout_ LPWSAQUERYSETW lpRes,
- _In_ char* hostnameA,
+ _In_ char** hostAliasesA,
+ _In_ char* hostnameA,
_In_ DWORD ip4addr);
BOOL
Modified: trunk/reactos/dll/win32/mswsock/nsplookup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/mswsock/nsplooku…
==============================================================================
--- trunk/reactos/dll/win32/mswsock/nsplookup.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/mswsock/nsplookup.c [iso-8859-1] Thu Jun 1 15:22:06 2017
@@ -106,7 +106,7 @@
INT
NSP_LookupServiceNextW(
_In_ PWSHANDLEINTERN data,
- _In_ DWORD CallID,
+ _In_ DWORD dwControlFlags,
_Inout_ LPWSAQUERYSETW lpRes,
_Inout_ LPDWORD lpResLen);
@@ -116,14 +116,14 @@
INT
NSP_GetHostByNameHeapAllocW(
- _In_ WCHAR* name,
- _In_ GUID* lpProviderId,
+ _In_ PWSHANDLEINTERN data,
+ _In_ DWORD dwControlFlags,
_Out_ PWSHOSTINFOINTERN hostinfo);
INT
NSP_GetServiceByNameHeapAllocW(
- _In_ WCHAR* nameW,
- _In_ GUID* lpProviderId,
+ _In_ PWSHANDLEINTERN data,
+ _In_ DWORD dwControlFlags,
_Out_ PWSHOSTINFOINTERN hostinfo);
/* Implementations - Internal */
@@ -303,7 +303,7 @@
lpqsResults->dwSize = sizeof(*lpqsResults);
wsaErr = NSP_LookupServiceNextW(pLook,
- pLook->CallID,
+ dwControlFlags,
lpqsResults,
lpdwBufferLength);
@@ -464,8 +464,8 @@
}
INT
-NSP_GetHostByNameHeapAllocW(_In_ WCHAR* name,
- _In_ GUID* lpProviderId,
+NSP_GetHostByNameHeapAllocW(_In_ PWSHANDLEINTERN data,
+ _In_ DWORD dwControlFlags,
_Out_ PWSHOSTINFOINTERN hostinfo)
{
HANDLE hHeap = GetProcessHeap();
@@ -474,21 +474,27 @@
PDNS_RECORD dp;
PDNS_RECORD curr;
INT result = ERROR_SUCCESS;
+ DWORD dwQueryFlags = DNS_QUERY_STANDARD;
/* needed to be cleaned up if != NULL */
dp = NULL;
- if (name == NULL)
+ if (data->hostnameW == NULL)
{
result = ERROR_INVALID_PARAMETER;
goto cleanup;
}
+ if ((data->dwControlFlags & LUP_DEEP) == 0)
+ {
+ dwQueryFlags |= DNS_QUERY_NO_RECURSION;
+ }
+
/* DNS_TYPE_A: include/WinDNS.h */
/* DnsQuery -- lib/dnsapi/dnsapi/query.c */
- dns_status = DnsQuery(name,
+ dns_status = DnsQuery(data->hostnameW,
DNS_TYPE_A,
- DNS_QUERY_STANDARD,
+ dwQueryFlags,
/* extra dns servers */ 0,
&dp,
0);
@@ -511,6 +517,7 @@
curr = dp;
while ((curr->pNext != NULL) || (curr->wType != DNS_TYPE_A))
{
+ /* FIXME build aliases list */
curr = curr->pNext;
}
@@ -522,6 +529,7 @@
hostinfo->hostnameW = StrCpyHeapAllocW(hHeap, curr->pName);
hostinfo->addr4 = curr->Data.A.IpAddress;
+ /* FIXME attach built aliases list */
result = ERROR_SUCCESS;
cleanup:
@@ -684,8 +692,8 @@
}
INT
-NSP_GetServiceByNameHeapAllocW(_In_ WCHAR* nameW,
- _In_ GUID* lpProviderId,
+NSP_GetServiceByNameHeapAllocW(_In_ PWSHANDLEINTERN data,
+ _In_ DWORD dwControlFlags,
_Out_ PWSHOSTINFOINTERN hostinfo)
{
BOOL Found = FALSE;
@@ -703,14 +711,14 @@
PCHAR nameProtoA = NULL;
INT res = WSANO_RECOVERY;
- if (!nameW)
+ if (!data->hostnameW)
{
res = WSANO_RECOVERY;
goto End;
}
hHeap = GetProcessHeap();
- nameA = StrW2AHeapAlloc(hHeap, nameW);
+ nameA = StrW2AHeapAlloc(hHeap, data->hostnameW);
/* nameA has the form <service-name>/<protocol>
we split these now */
@@ -837,7 +845,7 @@
INT
NSP_LookupServiceNextW(_In_ PWSHANDLEINTERN data,
- _In_ DWORD CallID,
+ _In_ DWORD dwControlFlags,
_Inout_ LPWSAQUERYSETW lpRes,
_Inout_ LPDWORD lpResLen)
{
@@ -860,9 +868,9 @@
lpRes->dwSize = sizeof(*lpRes);
lpRes->dwNameSpace = NS_DNS;
- if ((CallID == NSP_CALLID_HOSTNAME) ||
- (CallID == NSP_CALLID_HOSTBYNAME) ||
- (CallID == NSP_CALLID_SERVICEBYNAME))
+ if ((data->CallID == NSP_CALLID_HOSTNAME) ||
+ (data->CallID == NSP_CALLID_HOSTBYNAME) ||
+ (data->CallID == NSP_CALLID_SERVICEBYNAME))
{
if (data->CallIDCounter >= 1)
{
@@ -877,7 +885,7 @@
}
data->CallIDCounter++;
- if (CallID == NSP_CALLID_HOSTNAME)
+ if (data->CallID == NSP_CALLID_HOSTNAME)
{
result = NSP_GetHostNameHeapAllocW(&hostinfo.hostnameW);
@@ -886,19 +894,19 @@
hostinfo.addr4 = 0;
}
- else if (CallID == NSP_CALLID_HOSTBYNAME)
- {
- result = NSP_GetHostByNameHeapAllocW(data->hostnameW,
- &data->providerId,
+ else if (data->CallID == NSP_CALLID_HOSTBYNAME)
+ {
+ result = NSP_GetHostByNameHeapAllocW(data,
+ dwControlFlags,
&hostinfo);
if (result != ERROR_SUCCESS)
goto End;
}
else
{
- ASSERT(CallID == NSP_CALLID_SERVICEBYNAME);
- result = NSP_GetServiceByNameHeapAllocW(data->hostnameW,
- &data->providerId,
+ ASSERT(data->CallID == NSP_CALLID_SERVICEBYNAME);
+ result = NSP_GetServiceByNameHeapAllocW(data,
+ dwControlFlags,
&hostinfo);
if (result != ERROR_SUCCESS)
goto End;
@@ -907,7 +915,7 @@
if (((LUP_RETURN_BLOB & data->dwControlFlags) != 0) ||
((LUP_RETURN_NAME & data->dwControlFlags) != 0))
{
- if (CallID == NSP_CALLID_HOSTNAME || CallID == NSP_CALLID_HOSTBYNAME)
+ if (data->CallID == NSP_CALLID_HOSTNAME || data->CallID ==
NSP_CALLID_HOSTBYNAME)
{
ServiceInstanceNameW = hostinfo.hostnameW;
ServiceInstanceNameA = StrW2AHeapAlloc(hHeap, ServiceInstanceNameW);
@@ -918,7 +926,7 @@
}
}
- if (CallID == NSP_CALLID_SERVICEBYNAME)
+ if (data->CallID == NSP_CALLID_SERVICEBYNAME)
{
ServiceInstanceNameW = hostinfo.servnameW;
ServiceInstanceNameA = StrW2AHeapAlloc(hHeap, ServiceInstanceNameW);
@@ -950,11 +958,12 @@
if ((LUP_RETURN_BLOB & data->dwControlFlags) != 0)
{
- if (CallID == NSP_CALLID_HOSTBYNAME)
+ if (data->CallID == NSP_CALLID_HOSTBYNAME)
{
/* Write data for PBLOB (hostent) */
if (!mswBufferAppendBlob_Hostent(&buf,
lpRes,
+ (LUP_RETURN_ALIASES &
data->dwControlFlags) != 0 ? hostinfo.servaliasesA : NULL,
ServiceInstanceNameA,
hostinfo.addr4))
{
@@ -963,13 +972,13 @@
goto End;
}
}
- else if (CallID == NSP_CALLID_SERVICEBYNAME)
+ else if (data->CallID == NSP_CALLID_SERVICEBYNAME)
{
/* Write data for PBLOB (servent) */
if (!mswBufferAppendBlob_Servent(&buf,
lpRes,
ServiceInstanceNameA,/* ServiceName */
- hostinfo.servaliasesA,
+ (LUP_RETURN_ALIASES &
data->dwControlFlags) != 0 ? hostinfo.servaliasesA : NULL,
ServiceProtocolNameA,
hostinfo.servport))
{