ReactOS  0.4.14-dev-552-g2fad488
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 
14 DWORD
15 WINAPI
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 /* Function: 0x04 */
45 DWORD
48  _In_ DNSRSLVR_HANDLE pwszServerName)
49 {
50  DPRINT("R_ResolverFlushCache()\n");
51 
52  // FIXME Should store (and flush) entries by server handle
54  return ERROR_SUCCESS;
55 }
56 
57 /* Function: 0x07 */
58 DWORD
61  _In_ DNSRSLVR_HANDLE pszServerName,
62  _In_ LPCWSTR pszName,
63  _In_ WORD wType,
65  _Inout_ DWORD *dwRecords,
66  _Out_ DNS_RECORDW **ppResultRecords)
67 {
69  DNS_STATUS Status = ERROR_SUCCESS;
70 
71  DPRINT("R_ResolverQuery(%S %S %x %lx %p %p)\n",
72  pszServerName, pszName, wType, dwFlags, dwRecords, ppResultRecords);
73 
74  if (pszName == NULL || wType == 0 || ppResultRecords == NULL)
76 
79 
81  {
82  DPRINT("DNS query!\n");
83  Status = Query_Main(pszName,
84  wType,
85  dwFlags,
86  ppResultRecords);
87  }
89  {
90  DPRINT("DNS cache query!\n");
92  wType,
93  dwFlags,
94  ppResultRecords);
95  }
96  else
97  {
98  DPRINT("DNS cache query!\n");
100  wType,
101  dwFlags,
102  ppResultRecords);
104  {
105  DPRINT("DNS query!\n");
106  Status = Query_Main(pszName,
107  wType,
108  dwFlags,
109  ppResultRecords);
110  if (Status == ERROR_SUCCESS)
111  {
112  DPRINT("DNS query successful!\n");
113  DnsIntCacheAddEntry(*ppResultRecords);
114  }
115  }
116  }
117 
118  if (dwRecords)
119  {
120  *dwRecords = 0;
121 
122  if (Status == ERROR_SUCCESS)
123  {
124  Record = *ppResultRecords;
125  while (Record)
126  {
127  DPRINT("Record: %S\n", Record->pName);
128  (*dwRecords)++;
129  Record = Record->pNext;
130  }
131  }
132  }
133 
134  DPRINT("R_ResolverQuery result %ld %ld\n", Status, *dwRecords);
135 
136  return Status;
137 }
138 
140 {
142 }
143 
145 {
146  HeapFree(GetProcessHeap(), 0, ptr);
147 }
148 
150 {
151 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define DNS_INFO_NO_RECORDS
Definition: winerror.h:1861
void __RPC_USER DNSRSLVR_RPC_HANDLE_rundown(DNSRSLVR_HANDLE hClientHandle)
Definition: rpcserver.c:149
DWORD __stdcall R_ResolverFlushCache(_In_ DNSRSLVR_HANDLE pwszServerName)
Definition: rpcserver.c:47
_In_ struct _KBUGCHECK_REASON_CALLBACK_RECORD * Record
Definition: ketypes.h:256
long RPC_STATUS
Definition: rpc.h:52
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:60
RPC_STATUS WINAPI RpcServerListen(UINT MinimumCallThreads, UINT MaxCalls, UINT DontWait)
Definition: rpc_server.c:1520
LPWSTR DNSRSLVR_HANDLE
Definition: dnsrslvr.idl:17
static PVOID ptr
Definition: dispmode.c:27
#define RPC_C_LISTEN_MAX_CALLS_DEFAULT
Definition: rpcdce.h:122
smooth NULL
Definition: ftsmooth.c:416
#define _Out_
Definition: no_sal2.h:323
void DPRINT(...)
Definition: polytest.cpp:61
void __RPC_FAR *__RPC_USER midl_user_allocate(SIZE_T len)
Definition: rpcserver.c:139
#define __RPC_FAR
Definition: rpc.h:56
#define __RPC_USER
Definition: rpc.h:65
VOID DnsIntCacheAddEntry(PDNS_RECORDW Record)
Definition: cache.c:181
#define DNS_QUERY_WIRE_ONLY
Definition: windns.h:18
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define WINAPI
Definition: msvc.h:8
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
RPC_STATUS WINAPI RpcServerRegisterIf(RPC_IF_HANDLE IfSpec, UUID *MgrTypeUuid, RPC_MGR_EPV *MgrEpv)
Definition: rpc_server.c:1116
#define __stdcall
Definition: typedefs.h:25
#define _Inout_
Definition: no_sal2.h:244
DNS_STATUS DnsIntCacheGetEntryByName(LPCWSTR Name, WORD wType, DWORD dwFlags, PDNS_RECORDW *Record)
Definition: cache.c:98
static const WCHAR L[]
Definition: oid.c:1250
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
LPVOID lpParameter
Definition: kernel32.h:241
GLenum GLsizei len
Definition: glext.h:6722
Status
Definition: gdiplustypes.h:24
RPC_STATUS WINAPI RpcServerUseProtseqEpW(RPC_WSTR Protseq, UINT MaxCalls, RPC_WSTR Endpoint, LPVOID SecurityDescriptor)
Definition: rpc_server.c:927
#define _In_
Definition: no_sal2.h:204
void __RPC_USER midl_user_free(void __RPC_FAR *ptr)
Definition: rpcserver.c:144
ULONG_PTR SIZE_T
Definition: typedefs.h:78
VOID DnsIntCacheFlush(VOID)
Definition: cache.c:69
DWORD WINAPI RpcThreadRoutine(LPVOID lpParameter)
Definition: rpcserver.c:16
#define DNS_QUERY_NO_WIRE_QUERY
Definition: windns.h:13
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
DNS_STATUS WINAPI Query_Main(LPCWSTR Name, WORD Type, DWORD Options, PDNS_RECORD *QueryResultSet)
Definition: query.c:560
#define HeapFree(x, y, z)
Definition: compat.h:402
#define RPC_S_OK
Definition: rpcnterr.h:22