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.

308 lines
8.1 KiB

  1. //#--------------------------------------------------------------
  2. //
  3. // File: packetradius.h
  4. //
  5. // Synopsis: This file holds the declarations of the
  6. // CPacketRadius class
  7. //
  8. //
  9. // History: 9/23/97 MKarki Created
  10. //
  11. // Copyright (C) 1997-2001 Microsoft Corporation
  12. // All rights reserved.
  13. //
  14. //----------------------------------------------------------------
  15. #ifndef _PACKETRADIUS_H_
  16. #define _PACKETRADIUS_H_
  17. #include "mempool.h"
  18. #include "client.h"
  19. #include "proxyinfo.h"
  20. #include "hashmd5.h"
  21. #include "hashhmac.h"
  22. #include "dictionary.h"
  23. #include "reportevent.h"
  24. #include <new>
  25. class CPacketRadius
  26. {
  27. public:
  28. inline SOCKET GetSocket () {return (m_socket);}
  29. inline DWORD GetInRadiusAttributeCount (VOID)
  30. {return (m_dwInAttributeCount);}
  31. inline DWORD GetInAttributeCount (VOID)
  32. {return (m_dwInAttributeCount + COMPONENT_SPECIFIC_ATTRIBUTE_COUNT);}
  33. inline PATTRIBUTEPOSITION GetInAttributes (VOID)
  34. {return (m_pIasAttribPos);}
  35. inline WORD GetInPort (VOID)
  36. {return (m_wInPort);}
  37. inline WORD GetOutPort (VOID)
  38. {return (m_wOutPort);}
  39. inline DWORD GetInAddress (VOID)
  40. {return (m_dwInIPaddress);}
  41. inline DWORD GetOutAddress (VOID)
  42. {return (m_dwOutIPaddress);}
  43. PATTRIBUTE GetUserName() const throw ()
  44. { return m_pUserName; }
  45. PIASATTRIBUTE GetUserPassword() const throw ()
  46. { return m_pPasswordAttrib; }
  47. HRESULT cryptBuffer(
  48. BOOL encrypt,
  49. BOOL salted,
  50. PBYTE buf,
  51. ULONG buflen
  52. ) const throw ();
  53. HRESULT GetClient (
  54. /*[out]*/ IIasClient **ppIIasClient
  55. );
  56. LPCWSTR GetClientName() const throw ()
  57. { return m_pIIasClient->GetClientNameW(); }
  58. HRESULT PrelimVerification (
  59. /*[in]*/ CDictionary *pDictionary,
  60. /*[in]*/ DWORD dwBufferSize
  61. );
  62. HRESULT SetPassword (
  63. /*[in]*/ PBYTE pPassword,
  64. /*[in]*/ DWORD dwBufferSize
  65. );
  66. HRESULT GetPassword (
  67. /*[out]*/ PBYTE pPassword,
  68. /*[in/out]*/ PDWORD pdwBufferSize
  69. );
  70. BOOL GetUserName (
  71. /*[out]*/ PBYTE pbyUserName,
  72. /*[in/out]*/ PDWORD pdwBufferSize
  73. );
  74. BOOL IsProxyStatePresent (VOID);
  75. PACKETTYPE GetInCode (VOID);
  76. PACKETTYPE GetOutCode (VOID);
  77. WORD GetOutLength (VOID);
  78. WORD GetInLength (VOID) const
  79. { return m_dwInLength; }
  80. HRESULT GetInAuthenticator (
  81. /*[out]*/ PBYTE pAuthenticator,
  82. /*[in/out]*/ PDWORD pdwBufSize
  83. );
  84. BOOL SetOutAuthenticator (
  85. /*[in]*/ PBYTE pAuthenticator
  86. );
  87. HRESULT SetOutSignature (
  88. /*[in]*/ PBYTE pSignature
  89. );
  90. inline PBYTE GetInPacket (VOID) const
  91. {return (m_pInPacket);}
  92. inline PBYTE GetOutPacket (VOID)
  93. {return (m_pOutPacket);}
  94. BOOL SetProxyInfo (
  95. /*[in]*/ CProxyInfo *pCProxyInfo
  96. );
  97. HRESULT BuildOutPacket (
  98. /*[in]*/ PACKETTYPE ePacketType,
  99. /*[in]*/ PATTRIBUTEPOSITION pAttribPos,
  100. /*[in]*/ DWORD dwAttribCount
  101. );
  102. VOID SetProxyState (VOID);
  103. BOOL GetInSignature (
  104. /*[out]*/ PBYTE pSignatureValue
  105. );
  106. BOOL GenerateInAuthenticator (
  107. /*[in]*/ PBYTE pInAuthenticator,
  108. /*[out]*/ PBYTE pOutAuthenticator
  109. );
  110. BOOL GenerateOutAuthenticator();
  111. BOOL IsUserPasswordPresent (VOID)
  112. {return (NULL != m_pPasswordAttrib); }
  113. BOOL IsOutSignaturePresent (VOID)
  114. {return (NULL != m_pOutSignature); }
  115. BOOL ValidateSignature (VOID);
  116. HRESULT GenerateInSignature (
  117. /*[out]*/ PBYTE pSignatureValue,
  118. /*[in/out]*/ PDWORD pdwSigSize
  119. );
  120. HRESULT GenerateOutSignature (
  121. /*[out]*/ PBYTE pSignatureValue,
  122. /*[in/out]*/ PDWORD pdwSigSize
  123. );
  124. BOOL IsOutBoundAttribute (
  125. /*[in]*/ PACKETTYPE ePacketType,
  126. /*[in]*/ PIASATTRIBUTE pIasAttribute
  127. );
  128. CPacketRadius(
  129. /*[in]*/ CHashMD5 *pCHashMD5,
  130. /*[in]*/ CHashHmacMD5 *pCHashHmacMD5,
  131. /*[in]*/ IIasClient *pIIasClient,
  132. /*[in]*/ CReportEvent *pCReportEvent,
  133. /*[in]*/ PBYTE pInBuffer,
  134. /*[in]*/ DWORD dwInLength,
  135. /*[in]*/ DWORD dwIPAddress,
  136. /*[in]*/ WORD wInPort,
  137. /*[in]*/ SOCKET sock,
  138. /*[in]*/ PORTTYPE portType
  139. );
  140. virtual ~CPacketRadius();
  141. private:
  142. BOOL XorBuffers (
  143. /*[in/out]*/ PBYTE pbData1,
  144. /*[in]*/ DWORD dwDataLength1,
  145. /*[in]*/ PBYTE pbData2,
  146. /*[in]*/ DWORD dwDataLength2
  147. );
  148. HRESULT FillSharedSecretInfo (
  149. /*[in]*/ PIASATTRIBUTE pIasAttrib
  150. );
  151. HRESULT FillClientIPInfo (
  152. /*[in]*/ PIASATTRIBUTE pIasAttrib
  153. );
  154. HRESULT FillClientPortInfo (
  155. /*[in]*/ PIASATTRIBUTE pIasAttrib
  156. );
  157. HRESULT FillPacketHeaderInfo (
  158. /*[in]*/ PIASATTRIBUTE pIasAttrib
  159. );
  160. HRESULT FillClientVendorType (
  161. /*[in]*/ PIASATTRIBUTE pIasAttrib
  162. );
  163. HRESULT FillClientName (
  164. /*[in]*/ PIASATTRIBUTE pIasAttrib
  165. );
  166. HRESULT FillInAttributeInfo (
  167. /*[in]*/ CDictionary *pCDictionary,
  168. /*[in]*/ PACKETTYPE ePacketType,
  169. /*[in]*/ PIASATTRIBUTE pIasAttrib,
  170. /*[in]*/ PATTRIBUTE pRadiusAttrib
  171. );
  172. HRESULT FillOutAttributeInfo (
  173. /*[in]*/ PATTRIBUTE pRadiusAttrib,
  174. /*[in]*/ PIASATTRIBUTE pIasAttrib,
  175. /*[out]*/ PWORD pwActualAttributeLength,
  176. /*[in]*/ DWORD dwMaxPossibleAttribLength
  177. );
  178. BOOL InternalGenerator (
  179. /*[in]*/ PBYTE pInAuthenticator,
  180. /*[out]*/ PBYTE pOutAuthenticator,
  181. /*[in]*/ PRADIUSPACKET pPacket
  182. );
  183. HRESULT ValidatePacketFields (
  184. /*[in]*/ DWORD dwBufferSize
  185. );
  186. HRESULT CreateAttribCollection(
  187. /*[in]*/ CDictionary *pCDictionary
  188. );
  189. HRESULT InternalSignatureGenerator (
  190. /*[in]*/ PBYTE pSignatureValue,
  191. /*[in/out]*/PDWORD pdwSigSize,
  192. /*[in]*/ PRADIUSPACKET pPacket,
  193. /*[in]*/ PATTRIBUTE pSignatureAttr
  194. );
  195. PORTTYPE GetPortType (){return (m_porttype);}
  196. void reportMalformed() const throw ();
  197. PIASATTRIBUTE m_pPasswordAttrib;
  198. PATTRIBUTEPOSITION m_pIasAttribPos;
  199. enum
  200. {
  201. RADIUS_CREATOR_STATE = 1
  202. };
  203. PBYTE m_pInPacket;
  204. DWORD m_dwInLength;
  205. PBYTE m_pOutPacket;
  206. PATTRIBUTE m_pInSignature;
  207. PATTRIBUTE m_pOutSignature;
  208. PATTRIBUTE m_pUserName;
  209. WORD m_wInPort;
  210. WORD m_wOutPort;
  211. WORD m_wInPacketLength;
  212. DWORD m_dwInIPaddress;
  213. DWORD m_dwOutIPaddress;
  214. DWORD m_dwInAttributeCount;
  215. SOCKET m_socket;
  216. PORTTYPE m_porttype;
  217. HRESULT VerifyAttributes (
  218. /*[in]*/ CDictionary *pCDictionary
  219. );
  220. CHashMD5 *m_pCHashMD5;
  221. CHashHmacMD5 *m_pCHashHmacMD5;
  222. IIasClient *m_pIIasClient;
  223. CReportEvent *m_pCReportEvent;
  224. //
  225. // here is the private data for proxy
  226. //
  227. CProxyInfo *m_pCProxyInfo;
  228. //
  229. // here are the COM interfaces
  230. //
  231. IRequest *m_pIRequest;
  232. IAttributesRaw *m_pIAttributesRaw;
  233. //
  234. // the memory pool for outbound UDP buffer
  235. //
  236. static memory_pool <MAX_PACKET_SIZE, task_allocator> m_OutBufferPool;
  237. };
  238. #endif // !defined(PACKET_RADIUS_H_)