ReactOS 0.4.15-dev-7093-g01a8288
rpcserver.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS DNS Resolver
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/services/dnsrslvr/rpcserver.c
5 * PURPOSE: RPC server interface
6 * COPYRIGHT: Copyright 2016 Christoph von Wittich
7 */
8
9#include "precomp.h"
10
11#define NDEBUG
12#include <debug.h>
13
17{
19
20 Status = RpcServerUseProtseqEpW(L"ncalrpc", 20, L"DNSResolver", NULL);
21 if (Status != RPC_S_OK)
22 {
23 DPRINT("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
24 return 0;
25 }
26
27 Status = RpcServerRegisterIf(DnsResolver_v2_0_s_ifspec, NULL, NULL);
28 if (Status != RPC_S_OK)
29 {
30 DPRINT("RpcServerRegisterIf() failed (Status %lx)\n", Status);
31 return 0;
32 }
33
35 if (Status != RPC_S_OK)
36 {
37 DPRINT("RpcServerListen() failed (Status %lx)\n", Status);
38 }
39
40 DPRINT("RpcServerListen finished\n");
41 return 0;
42}
43
44
45/* Function: 0x00 */
49 _In_ DNSRSLVR_HANDLE pwszServerName,
50 _Out_ DNS_CACHE_ENTRY **ppCacheEntries)
51{
52 DPRINT("CRrReadCache(%S %p)\n",
53 pwszServerName, ppCacheEntries);
54
55 return DnsIntCacheGetEntries(ppCacheEntries);
56}
57
58
59/* Function: 0x04 */
63 _In_ DNSRSLVR_HANDLE pszServerName)
64{
65 DPRINT("R_ResolverFlushCache(%S)\n",
66 pszServerName);
67
69}
70
71
72/* Function: 0x05 */
76 _In_ DNSRSLVR_HANDLE pszServerName,
77 _In_ LPCWSTR pszName,
78 _In_ WORD wType)
79{
80 DPRINT("R_ResolverFlushCacheEntry(%S %S %x)\n",
81 pszServerName, pszName, wType);
82
83 if (pszName == NULL)
85
86 return DnsIntFlushCacheEntry(pszName, wType);
87}
88
89
90/* Function: 0x07 */
94 _In_ DNSRSLVR_HANDLE pszServerName,
95 _In_ LPCWSTR pszName,
96 _In_ WORD wType,
98 _Inout_ DWORD *dwRecords,
99 _Out_ DNS_RECORDW **ppResultRecords)
100{
102 DNS_STATUS Status = ERROR_SUCCESS;
103
104 DPRINT("R_ResolverQuery(%S %S %x %lx %p %p)\n",
105 pszServerName, pszName, wType, dwFlags, dwRecords, ppResultRecords);
106
107 if (pszName == NULL || wType == 0 || ppResultRecords == NULL)
109
112
114 {
115 DPRINT("DNS query!\n");
116 Status = Query_Main(pszName,
117 wType,
118 dwFlags,
119 ppResultRecords);
120 }
122 {
123 DPRINT("DNS cache query!\n");
125 wType,
126 dwFlags,
127 ppResultRecords);
128 }
129 else
130 {
131 DPRINT("DNS cache query!\n");
133 wType,
134 dwFlags,
135 ppResultRecords);
137 {
138 DPRINT("DNS query!\n");
139 Status = Query_Main(pszName,
140 wType,
141 dwFlags,
142 ppResultRecords);
143 if (Status == ERROR_SUCCESS)
144 {
145 DPRINT("DNS query successful!\n");
146 DnsIntCacheAddEntry(*ppResultRecords, FALSE);
147 }
148 }
149 }
150
151 if (dwRecords)
152 {
153 *dwRecords = 0;
154
155 if (Status == ERROR_SUCCESS)
156 {
157 Record = *ppResultRecords;
158 while (Record)
159 {
160 DPRINT("Record: %S\n", Record->pName);
161 (*dwRecords)++;
162 Record = Record->pNext;
163 }
164 }
165 }
166
167 DPRINT("R_ResolverQuery result %ld %ld\n", Status, *dwRecords);
168
169 return Status;
170}
171
173{
175}
176
178{
180}
181
183{
184}
DWORD WINAPI RpcThreadRoutine(LPVOID lpParameter)
Definition: rpcserver.c:20
DNS_STATUS DnsIntCacheGetEntryByName(LPCWSTR Name, WORD wType, DWORD dwFlags, PDNS_RECORDW *Record)
Definition: cache.c:150
DNS_STATUS DnsIntCacheGetEntries(_Out_ DNS_CACHE_ENTRY **ppCacheEntries)
Definition: cache.c:264
DNS_STATUS DnsIntFlushCacheEntry(_In_ LPCWSTR pszName, _In_ WORD wType)
Definition: cache.c:106
DNS_STATUS DnsIntCacheFlush(_In_ ULONG ulFlags)
Definition: cache.c:69
VOID DnsIntCacheAddEntry(_In_ PDNS_RECORDW Record, _In_ BOOL bHostsFileEntry)
Definition: cache.c:233
#define CACHE_FLUSH_NON_HOSTS_FILE_ENTRIES
Definition: precomp.h:48
DWORD __stdcall CRrReadCache(_In_ DNSRSLVR_HANDLE pwszServerName, _Out_ DNS_CACHE_ENTRY **ppCacheEntries)
Definition: rpcserver.c:48
DWORD __stdcall R_ResolverQuery(_In_ DNSRSLVR_HANDLE pszServerName, _In_ LPCWSTR pszName, _In_ WORD wType, _In_ DWORD dwFlags, _Inout_ DWORD *dwRecords, _Out_ DNS_RECORDW **ppResultRecords)
Definition: rpcserver.c:93
DWORD __stdcall R_ResolverFlushCache(_In_ DNSRSLVR_HANDLE pszServerName)
Definition: rpcserver.c:62
void __RPC_USER DNSRSLVR_RPC_HANDLE_rundown(DNSRSLVR_HANDLE hClientHandle)
Definition: rpcserver.c:182
DWORD __stdcall R_ResolverFlushCacheEntry(_In_ DNSRSLVR_HANDLE pszServerName, _In_ LPCWSTR pszName, _In_ WORD wType)
Definition: rpcserver.c:75
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
DNS_STATUS WINAPI Query_Main(LPCWSTR Name, WORD Type, DWORD Options, PDNS_RECORD *QueryResultSet)
Definition: query.c:654
LPWSTR DNSRSLVR_HANDLE
Definition: dnsrslvr.idl:17
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
Status
Definition: gdiplustypes.h:25
GLenum GLsizei len
Definition: glext.h:6722
static PVOID ptr
Definition: dispmode.c:27
#define _Inout_
Definition: ms_sal.h:378
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define L(x)
Definition: ntvdm.h:50
RPC_STATUS WINAPI RpcServerListen(UINT MinimumCallThreads, UINT MaxCalls, UINT DontWait)
Definition: rpc_server.c:1520
RPC_STATUS WINAPI RpcServerRegisterIf(RPC_IF_HANDLE IfSpec, UUID *MgrTypeUuid, RPC_MGR_EPV *MgrEpv)
Definition: rpc_server.c:1116
RPC_STATUS WINAPI RpcServerUseProtseqEpW(RPC_WSTR Protseq, UINT MaxCalls, RPC_WSTR Endpoint, LPVOID SecurityDescriptor)
Definition: rpc_server.c:927
#define RPC_C_LISTEN_MAX_CALLS_DEFAULT
Definition: rpcdce.h:122
#define RPC_S_OK
Definition: rpcnterr.h:22
#define midl_user_free
Definition: rpc.h:45
#define __RPC_FAR
Definition: rpc.h:56
long RPC_STATUS
Definition: rpc.h:52
#define __RPC_USER
Definition: rpc.h:65
#define midl_user_allocate
Definition: rpc.h:44
#define DPRINT
Definition: sndvol32.h:71
Definition: windns_undoc.h:9
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define __stdcall
Definition: typedefs.h:25
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define DNS_QUERY_WIRE_ONLY
Definition: windns.h:18
#define DNS_QUERY_NO_WIRE_QUERY
Definition: windns.h:13
#define WINAPI
Definition: msvc.h:6
#define DNS_INFO_NO_RECORDS
Definition: winerror.h:1861
_In_ struct _KBUGCHECK_REASON_CALLBACK_RECORD * Record
Definition: ketypes.h:268
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185