Leaked source code of windows server 2003
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.

304 lines
8.3 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. BOOL GetUserName (
  67. /*[out]*/ PBYTE pbyUserName,
  68. /*[in/out]*/ PDWORD pdwBufferSize
  69. );
  70. BOOL IsProxyStatePresent (VOID);
  71. PACKETTYPE GetInCode (VOID);
  72. PACKETTYPE GetOutCode (VOID);
  73. WORD GetOutLength (VOID);
  74. WORD GetInLength (VOID) const
  75. { return m_dwInLength; }
  76. HRESULT GetInAuthenticator (
  77. /*[out]*/ PBYTE pAuthenticator,
  78. /*[in/out]*/ PDWORD pdwBufSize
  79. );
  80. BOOL SetOutAuthenticator (
  81. /*[in]*/ PBYTE pAuthenticator
  82. );
  83. HRESULT SetOutSignature (
  84. /*[in]*/ PBYTE pSignature
  85. );
  86. inline PBYTE GetInPacket (VOID) const
  87. {return (m_pInPacket);}
  88. inline PBYTE GetOutPacket (VOID)
  89. {return (m_pOutPacket);}
  90. BOOL SetProxyInfo (
  91. /*[in]*/ CProxyInfo *pCProxyInfo
  92. );
  93. HRESULT BuildOutPacket (
  94. /*[in]*/ PACKETTYPE ePacketType,
  95. /*[in]*/ PATTRIBUTEPOSITION pAttribPos,
  96. /*[in]*/ DWORD dwAttribCount
  97. );
  98. VOID SetProxyState (VOID);
  99. BOOL GetInSignature (
  100. /*[out]*/ PBYTE pSignatureValue
  101. );
  102. BOOL GenerateInAuthenticator (
  103. /*[in]*/ PBYTE pInAuthenticator,
  104. /*[out]*/ PBYTE pOutAuthenticator
  105. );
  106. BOOL GenerateOutAuthenticator();
  107. BOOL IsUserPasswordPresent (VOID)
  108. {return (NULL != m_pPasswordAttrib); }
  109. BOOL IsOutSignaturePresent (VOID)
  110. {return (NULL != m_pOutSignature); }
  111. BOOL ValidateSignature (VOID);
  112. HRESULT GenerateInSignature (
  113. /*[out]*/ PBYTE pSignatureValue,
  114. /*[in/out]*/ PDWORD pdwSigSize
  115. );
  116. HRESULT GenerateOutSignature (
  117. /*[out]*/ PBYTE pSignatureValue,
  118. /*[in/out]*/ PDWORD pdwSigSize
  119. );
  120. BOOL IsOutBoundAttribute (
  121. /*[in]*/ PACKETTYPE ePacketType,
  122. /*[in]*/ PIASATTRIBUTE pIasAttribute
  123. );
  124. CPacketRadius(
  125. /*[in]*/ CHashMD5 *pCHashMD5,
  126. /*[in]*/ CHashHmacMD5 *pCHashHmacMD5,
  127. /*[in]*/ IIasClient *pIIasClient,
  128. /*[in]*/ CReportEvent *pCReportEvent,
  129. /*[in]*/ PBYTE pInBuffer,
  130. /*[in]*/ DWORD dwInLength,
  131. /*[in]*/ DWORD dwIPAddress,
  132. /*[in]*/ WORD wInPort,
  133. /*[in]*/ SOCKET sock,
  134. /*[in]*/ PORTTYPE portType
  135. );
  136. virtual ~CPacketRadius();
  137. void reportMalformed() const throw ();
  138. private:
  139. BOOL XorBuffers (
  140. /*[in/out]*/ PBYTE pbData1,
  141. /*[in]*/ DWORD dwDataLength1,
  142. /*[in]*/ PBYTE pbData2,
  143. /*[in]*/ DWORD dwDataLength2
  144. );
  145. HRESULT FillSharedSecretInfo (
  146. /*[in]*/ PIASATTRIBUTE pIasAttrib
  147. );
  148. HRESULT FillClientIPInfo (
  149. /*[in]*/ PIASATTRIBUTE pIasAttrib
  150. );
  151. HRESULT FillClientPortInfo (
  152. /*[in]*/ PIASATTRIBUTE pIasAttrib
  153. );
  154. HRESULT FillPacketHeaderInfo (
  155. /*[in]*/ PIASATTRIBUTE pIasAttrib
  156. );
  157. HRESULT FillClientVendorType (
  158. /*[in]*/ PIASATTRIBUTE pIasAttrib
  159. );
  160. HRESULT FillClientName (
  161. /*[in]*/ PIASATTRIBUTE pIasAttrib
  162. );
  163. HRESULT FillInAttributeInfo (
  164. /*[in]*/ CDictionary *pCDictionary,
  165. /*[in]*/ PACKETTYPE ePacketType,
  166. /*[in]*/ PIASATTRIBUTE pIasAttrib,
  167. /*[in]*/ PATTRIBUTE pRadiusAttrib
  168. );
  169. HRESULT FillOutAttributeInfo (
  170. /*[in]*/ PATTRIBUTE pRadiusAttrib,
  171. /*[in]*/ PIASATTRIBUTE pIasAttrib,
  172. /*[out]*/ PWORD pwActualAttributeLength,
  173. /*[in]*/ DWORD dwMaxPossibleAttribLength
  174. );
  175. BOOL InternalGenerator (
  176. /*[in]*/ PBYTE pInAuthenticator,
  177. /*[out]*/ PBYTE pOutAuthenticator,
  178. /*[in]*/ PRADIUSPACKET pPacket
  179. );
  180. HRESULT ValidatePacketFields (
  181. /*[in]*/ DWORD dwBufferSize
  182. );
  183. HRESULT CreateAttribCollection(
  184. /*[in]*/ CDictionary *pCDictionary
  185. );
  186. HRESULT InternalSignatureGenerator (
  187. /*[in]*/ PBYTE pSignatureValue,
  188. /*[in/out]*/PDWORD pdwSigSize,
  189. /*[in]*/ PRADIUSPACKET pPacket,
  190. /*[in]*/ PATTRIBUTE pSignatureAttr
  191. );
  192. PORTTYPE GetPortType (){return (m_porttype);}
  193. PIASATTRIBUTE m_pPasswordAttrib;
  194. PATTRIBUTEPOSITION m_pIasAttribPos;
  195. enum
  196. {
  197. RADIUS_CREATOR_STATE = 1
  198. };
  199. PBYTE m_pInPacket;
  200. DWORD m_dwInLength;
  201. PBYTE m_pOutPacket;
  202. PATTRIBUTE m_pInSignature;
  203. PATTRIBUTE m_pOutSignature;
  204. PATTRIBUTE m_pUserName;
  205. WORD m_wInPort;
  206. WORD m_wOutPort;
  207. WORD m_wInPacketLength;
  208. DWORD m_dwInIPaddress;
  209. DWORD m_dwOutIPaddress;
  210. DWORD m_dwInAttributeCount;
  211. SOCKET m_socket;
  212. PORTTYPE m_porttype;
  213. HRESULT VerifyAttributes (
  214. /*[in]*/ CDictionary *pCDictionary
  215. );
  216. CHashMD5 *m_pCHashMD5;
  217. CHashHmacMD5 *m_pCHashHmacMD5;
  218. IIasClient *m_pIIasClient;
  219. CReportEvent *m_pCReportEvent;
  220. //
  221. // here is the private data for proxy
  222. //
  223. CProxyInfo *m_pCProxyInfo;
  224. //
  225. // here are the COM interfaces
  226. //
  227. IRequest *m_pIRequest;
  228. IAttributesRaw *m_pIAttributesRaw;
  229. //
  230. // the memory pool for outbound UDP buffer
  231. //
  232. static memory_pool <MAX_PACKET_SIZE, task_allocator> m_OutBufferPool;
  233. };
  234. #endif // !defined(PACKET_RADIUS_H_)