Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

338 lines
8.5 KiB

  1. //#--------------------------------------------------------------
  2. //
  3. // File: controller.h
  4. //
  5. // Synopsis: This file holds the declarations of the
  6. // CCollection class
  7. //
  8. //
  9. // History: 9/23/97 MKarki Created
  10. // 6/04/98 SBens Added the InfoBase class.
  11. //
  12. // Copyright (C) 1997-98 Microsoft Corporation
  13. // All rights reserved.
  14. //
  15. //#--------------------------------------------------------------
  16. #ifndef _CONTROLLER_H_
  17. #define _CONTROLLER_H_
  18. #include "radcommon.h"
  19. #include "iasradius.h"
  20. #include "resource.h"
  21. #include "dictionary.h"
  22. #include "prevalidator.h"
  23. #include "preprocessor.h"
  24. #include "packetreceiver.h"
  25. #include "hashmd5.h"
  26. #include "hashhmac.h"
  27. #include "proxystate.h"
  28. #include "packetsender.h"
  29. #include "reportevent.h"
  30. #include "sendtopipe.h"
  31. #include "tunnelpassword.h"
  32. #include "ports.h"
  33. class CController:
  34. public IDispatchImpl<IIasComponent,
  35. &__uuidof (IIasComponent),
  36. &__uuidof (IASRadiusLib)
  37. >,
  38. public IPersistPropertyBag2,
  39. public CComObjectRoot,
  40. public CComCoClass<RadiusProtocol,&__uuidof (RadiusProtocol)>
  41. {
  42. public:
  43. //
  44. // registry declaration for the Radius Protocol
  45. //
  46. IAS_DECLARE_REGISTRY (RadiusProtocol, 1, 0, IASRadiusLib)
  47. //
  48. // this COM Component is not aggregatable
  49. //
  50. DECLARE_NOT_AGGREGATABLE(CController)
  51. //
  52. // this COM component is a singelton
  53. //
  54. DECLARE_CLASSFACTORY_SINGLETON (CController)
  55. //
  56. // MACROS for ATL required methods
  57. //
  58. BEGIN_COM_MAP(CController)
  59. COM_INTERFACE_ENTRY2(IDispatch, IIasComponent)
  60. COM_INTERFACE_ENTRY(IIasComponent)
  61. COM_INTERFACE_ENTRY(IPersistPropertyBag2)
  62. COM_INTERFACE_ENTRY_FUNC(__uuidof (IRequestSource), 0, &CController::QueryInterfaceReqSrc)
  63. END_COM_MAP()
  64. //
  65. // MACRO to declare Controlling IUnknown method
  66. //
  67. DECLARE_GET_CONTROLLING_UNKNOWN()
  68. CController (VOID);
  69. ~CController (VOID);
  70. public:
  71. //
  72. // methods of IPersistPropertyBag2 interface
  73. //
  74. STDMETHOD(Load) (
  75. /*[in]*/ IPropertyBag2 *pIPropertyBag,
  76. /*[in]*/ IErrorLog *pIErrLog
  77. );
  78. STDMETHOD(Save) (
  79. /*[in]*/ IPropertyBag2 *pIPropertyBag,
  80. /*[in]*/ BOOL bClearDirty,
  81. /*[in]*/ BOOL bSaveAllProperties
  82. );
  83. STDMETHOD(IsDirty)();
  84. //
  85. // IPersist Method
  86. //
  87. STDMETHOD (GetClassID) (
  88. /*[out]*/ CLSID *pClsid
  89. )
  90. {
  91. if (NULL == pClsid)
  92. return (E_FAIL);
  93. *pClsid = __uuidof (RadiusProtocol);
  94. return (S_OK);
  95. }
  96. //
  97. // IIasPropertyNotify method
  98. //
  99. STDMETHOD (OnPropertyChange)(
  100. /*[in]*/ ULONG ulProperties,
  101. /*[in]*/ ULONG *pulProperties,
  102. /*[in]*/ IPropertyBag2 *pIPropertyBag
  103. );
  104. //
  105. // methods of IIasComponent interface
  106. //
  107. STDMETHOD(Initialize)();
  108. STDMETHOD(Shutdown)();
  109. STDMETHOD(GetProperty)(
  110. /*[in]*/ LONG id,
  111. /*[out]*/ VARIANT *pValue
  112. );
  113. STDMETHOD(PutProperty)(
  114. /*[in]*/ LONG id,
  115. /*[in]*/ VARIANT *pValue
  116. );
  117. STDMETHOD(InitNew)();
  118. STDMETHOD (Suspend) ();
  119. STDMETHOD (Resume) ();
  120. private:
  121. CProxyState *m_pCProxyState;
  122. CPacketReceiver *m_pCPacketReceiver;
  123. CRecvFromPipe *m_pCRecvFromPipe;
  124. CPreProcessor *m_pCPreProcessor;
  125. CPreValidator *m_pCPreValidator;
  126. CDictionary *m_pCDictionary;
  127. CClients *m_pCClients;
  128. CHashMD5 *m_pCHashMD5;
  129. CHashHmacMD5 *m_pCHashHmacMD5;
  130. CSendToPipe *m_pCSendToPipe;
  131. CPacketSender *m_pCPacketSender;
  132. CReportEvent *m_pCReportEvent;
  133. CTunnelPassword *m_pCTunnelPassword;
  134. VSAFilter *m_pCVSAFilter;
  135. IIasComponent *m_pInfoBase; // Auditor that tracks RADIUS events.
  136. CPorts m_objAuthPort;
  137. CPorts m_objAcctPort;
  138. //
  139. // here the Request servers
  140. //
  141. IRequestHandler *m_pIRequestHandler;
  142. //
  143. // here is the port info
  144. //
  145. WORD m_wAuthPort;
  146. WORD m_wAcctPort;
  147. DWORD m_dwAuthHandle;
  148. DWORD m_dwAcctHandle;
  149. BOOL OpenPorts ();
  150. BOOL ClosePorts ();
  151. //
  152. // here is the definition of the CRequestSource
  153. // which implements the method of the IRequestSource
  154. // interface
  155. //
  156. class CRequestSource : public IRequestSource
  157. {
  158. public:
  159. CRequestSource (CController *pCController);
  160. ~CRequestSource ();
  161. //
  162. // IUnknown methods - delegate to outer IUnknown
  163. //
  164. STDMETHOD(QueryInterface)(
  165. /*[in]*/ REFIID riid,
  166. /*[out]*/ void **ppv
  167. )
  168. {
  169. IUnknown *pUnknown = m_pCController->GetControllingUnknown();
  170. return (pUnknown->QueryInterface(riid,ppv));
  171. }
  172. STDMETHOD_(ULONG,AddRef)(void)
  173. {
  174. IUnknown *pUnknown = m_pCController->GetControllingUnknown();
  175. return (pUnknown->AddRef());
  176. }
  177. STDMETHOD_(ULONG,Release)(void)
  178. {
  179. IUnknown *pUnknown = m_pCController->GetControllingUnknown();
  180. return (pUnknown->Release());
  181. }
  182. //
  183. // IDispatch methods - delegate to outer class object
  184. //
  185. STDMETHOD(GetTypeInfoCount)(
  186. /*[out]*/ UINT *pctinfo
  187. )
  188. {
  189. return (m_pCController->GetTypeInfoCount (pctinfo));
  190. }
  191. STDMETHOD(GetTypeInfo)(
  192. /*[in]*/ UINT iTInfo,
  193. /*[in]*/ LCID lcid,
  194. /*[out]*/ ITypeInfo **ppTInfo
  195. )
  196. {
  197. return (m_pCController->GetTypeInfo (iTInfo, lcid, ppTInfo));
  198. }
  199. STDMETHOD(GetIDsOfNames)(
  200. /*[in]*/ const IID& riid,
  201. /*[in]*/ LPOLESTR *rgszNames,
  202. /*[in]*/ UINT cNames,
  203. /*[in]*/ LCID lcid,
  204. /*[out]*/ DISPID *rgDispId)
  205. {
  206. return (m_pCController->GetIDsOfNames (
  207. riid, rgszNames, cNames, lcid, rgDispId
  208. )
  209. );
  210. }
  211. STDMETHOD(Invoke)(
  212. /*[in]*/ DISPID dispIdMember,
  213. /*[in]*/ const IID& riid,
  214. /*[in]*/ LCID lcid,
  215. /*[in]*/ WORD wFlags,
  216. /*[in/out]*/DISPPARAMS *pDispParams,
  217. /*[out]*/ VARIANT *pVarResult,
  218. /*[out]*/ EXCEPINFO *pExcepInfo,
  219. /*[out]*/ UINT *puArgErr
  220. )
  221. {
  222. return (m_pCController->Invoke (
  223. dispIdMember,
  224. riid,
  225. lcid,
  226. wFlags,
  227. pDispParams,
  228. pVarResult,
  229. pExcepInfo,
  230. puArgErr
  231. )
  232. );
  233. }
  234. //
  235. // IRequestSource Interface method
  236. //
  237. STDMETHOD(OnRequestComplete)(
  238. /*[in]*/ IRequest *pIRequest,
  239. /*[in]*/ IASREQUESTSTATUS eStatus
  240. );
  241. private:
  242. CController* m_pCController;
  243. }; // End of nested class CRequestSource
  244. //
  245. // this method is called when somone whants the
  246. // IRequestHandlercallback interface
  247. //
  248. static HRESULT WINAPI QueryInterfaceReqSrc (
  249. VOID *pThis,
  250. REFIID riid,
  251. LPVOID *ppv,
  252. ULONG_PTR ulpValue
  253. );
  254. //
  255. // instantiate this nested class
  256. //
  257. CRequestSource m_objCRequestSource;
  258. //
  259. // now we can call into private methods of CController
  260. //
  261. friend class CRequestSource;
  262. typedef enum _component_state_
  263. {
  264. COMP_SHUTDOWN,
  265. COMP_UNINITIALIZED,
  266. COMP_INITIALIZED,
  267. COMP_SUSPENDED
  268. } COMPONENTSTATE, *PCOMPONENTSTATE;
  269. COMPONENTSTATE m_eRadCompState;
  270. //
  271. // this is the internal initialization method of CController class
  272. // object
  273. //
  274. HRESULT InternalInit (VOID);
  275. //
  276. // does the internal cleanup of resources
  277. //
  278. VOID InternalCleanup (VOID);
  279. };
  280. #endif // !define _CONTROLLER_H_