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.

150 lines
3.8 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // EAPSession.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // This file declares the class EAPSession.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 01/15/1998 Original version.
  16. // 05/08/1998 Convert to new EAP interface.
  17. // 08/27/1998 Use new EAPFSM class.
  18. // 10/13/1998 Add maxPacketLength property.
  19. // 11/13/1998 Add event log handles.
  20. // 05/20/1999 Identity is now a Unicode string.
  21. //
  22. ///////////////////////////////////////////////////////////////////////////////
  23. #ifndef _EAPSESSION_H_
  24. #define _EAPSESSION_H_
  25. #if _MSC_VER >= 1000
  26. #pragma once
  27. #endif
  28. #include <nocopy.h>
  29. #include <raseapif.h>
  30. #include <iastlutl.h>
  31. using namespace IASTL;
  32. #include <eapfsm.h>
  33. // Forward references.
  34. class EAPType;
  35. ///////////////////////////////////////////////////////////////////////////////
  36. //
  37. // CLASS
  38. //
  39. // EAPStruct<T>
  40. //
  41. // DESCRIPTION
  42. //
  43. // Wraps a raseapif struct to handle initialization.
  44. //
  45. ///////////////////////////////////////////////////////////////////////////////
  46. template <class T>
  47. class EAPStruct : public T
  48. {
  49. public:
  50. EAPStruct() throw ()
  51. { clear(); }
  52. void clear() throw ()
  53. {
  54. memset(this, 0, sizeof(T));
  55. dwSizeInBytes = sizeof(T);
  56. }
  57. };
  58. typedef EAPStruct<PPP_EAP_INPUT> EAPInput;
  59. typedef EAPStruct<PPP_EAP_OUTPUT> EAPOutput;
  60. ///////////////////////////////////////////////////////////////////////////////
  61. //
  62. // CLASS
  63. //
  64. // EAPSession
  65. //
  66. // DESCRIPTION
  67. //
  68. // This class encapsulates the state of an ongoing EAP session.
  69. //
  70. ///////////////////////////////////////////////////////////////////////////////
  71. class EAPSession
  72. : NonCopyable
  73. {
  74. public:
  75. EAPSession(const IASAttribute& accountName, const EAPType& eapType);
  76. ~EAPSession() throw ();
  77. // Returns the ID for this session.
  78. DWORD getID() const throw ()
  79. { return id; }
  80. PCWSTR getAccountName() const throw ()
  81. { return account->Value.String.pszWide; }
  82. // Begin a new session.
  83. IASREQUESTSTATUS begin(
  84. IASRequest& request,
  85. PPPP_EAP_PACKET recvPacket
  86. );
  87. // Continue an extant session.
  88. IASREQUESTSTATUS process(
  89. IASRequest& request,
  90. PPPP_EAP_PACKET recvPacket
  91. );
  92. static HRESULT initialize() throw ();
  93. static void finalize() throw ();
  94. protected:
  95. // Performs the last action returned by the EAP DLL. May be called multiple
  96. // times per action due to retransmissions.
  97. IASREQUESTSTATUS doAction(IASRequest& request);
  98. //////////
  99. // Constant properties of a session.
  100. //////////
  101. const DWORD id; // Unique session ID.
  102. const EAPType& type; // EAP type being used.
  103. const IASAttribute account; // NT4-Account-Name of the user.
  104. const IASAttribute state; // State attribute.
  105. //////////
  106. // Current state of a session.
  107. //////////
  108. EAPFSM fsm; // FSM governing the session.
  109. DWORD maxPacketLength; // Max. length of the send packet.
  110. IASAttributeVector profile; // Authorization profile.
  111. PVOID workBuffer; // EAP DLL's context buffer.
  112. EAPOutput eapOutput; // Last output from the EAP DLL.
  113. PPPP_EAP_PACKET sendPacket; // Last packet sent.
  114. // Next available session ID.
  115. static LONG theNextID;
  116. // Initialization refCount.
  117. static LONG theRefCount;
  118. // Session-Timeout for non-interactive sessions.
  119. static IASAttribute theNormalTimeout;
  120. // Session-Timeout for interactive sessions.
  121. static IASAttribute theInteractiveTimeout;
  122. // IAS event log handle;
  123. static HANDLE theIASEventLog;
  124. // RAS event log handle;
  125. static HANDLE theRASEventLog;
  126. };
  127. #endif // _EAPSESSION_H_