16#include <eaphostpeerconfigapis.h>
18#include <EapHostPeerTypes.h>
19#include <eapmethodtypes.h>
25#pragma warning(disable: 26812)
28#pragma warning(disable: 4505)
43static bool operator==(_In_
const EAP_METHOD_TYPE &a, _In_
const EAP_METHOD_TYPE &b)
noexcept
46 a.eapType.type == b.eapType.type &&
47 a.eapType.dwVendorId == b.eapType.dwVendorId &&
48 a.eapType.dwVendorType == b.eapType.dwVendorType &&
49 a.dwAuthorId == a.dwAuthorId;
62static bool operator!=(_In_
const EAP_METHOD_TYPE &a, _In_
const EAP_METHOD_TYPE &b)
noexcept
81 #pragma warning(suppress: 4480)
125 EapHostPeerFreeMemory((BYTE*)_Ptr);
132 typedef std::unique_ptr<BYTE[], EapHostPeerFreeMemory_delete>
eap_blob;
150 EapHostPeerFreeRuntimeMemory((BYTE*)_Ptr);
176 EapHostPeerFreeErrorMemory(_Ptr);
183 typedef std::unique_ptr<EAP_ERROR, EapHostPeerFreeErrorMemory_delete>
eap_error;
202 EapHostPeerFreeEapError(_Ptr);
214 #pragma warning(push)
215 #pragma warning(disable: 26432)
224 eaType = eatReserved;
235 dwLength = a.dwLength;
237 pValue =
new BYTE[a.dwLength];
239 memcpy(pValue, a.pValue, a.dwLength);
250 dwLength = a.dwLength;
275 dwLength = a.dwLength;
277 BYTE *pValueNew =
new BYTE[a.dwLength];
281 memcpy(pValueNew, a.pValue, a.dwLength);
298 dwLength = a.dwLength;
318 void create_ms_mppe_key(_In_ BYTE bVendorType, _In_count_(nKeySize) LPCBYTE pbKey, _In_ BYTE nKeySize)
320 const BYTE nPaddingLength =
static_cast<BYTE
>((16 - (1 +
static_cast<DWORD
>(nKeySize))) % 16);
321 const DWORD dwLengthNew =
330 #pragma warning(push)
331 #pragma warning(disable: 6386)
332 LPBYTE p =
new BYTE[dwLengthNew];
338 p[5] =
static_cast<BYTE
>(dwLengthNew - 4);
343 memcpy(p + 9, pbKey, nKeySize);
344 memset(p + 9 + nKeySize, 0, nPaddingLength);
349 #pragma warning(suppress: 26812)
350 eaType = eatVendorSpecific;
351 dwLength = dwLengthNew;
376 eapMethodPropertyType = type;
377 eapMethodPropertyValueType = empvtBool;
378 eapMethodPropertyValue.empvBool.length =
sizeof(BOOL);
379 eapMethodPropertyValue.empvBool.value = value;
390 eapMethodPropertyType = type;
391 eapMethodPropertyValueType = empvtDword;
392 eapMethodPropertyValue.empvDword.length =
sizeof(DWORD);
393 eapMethodPropertyValue.empvDword.value = value;
404 eapMethodPropertyType = type;
405 eapMethodPropertyValueType = empvtString;
406 eapMethodPropertyValue.empvString.length =
static_cast<DWORD
>(
sizeof(WCHAR)*(wcslen(value) + 1));
407 eapMethodPropertyValue.empvString.value =
const_cast<BYTE*
>(
reinterpret_cast<const BYTE*
>(value));
441 bool create(_In_ EapCode code, _In_ BYTE
id, _In_ WORD
size)
noexcept
447 h->Code =
static_cast<BYTE
>(code);
449 *
reinterpret_cast<WORD*
>(h->Length) = htons(
size);
454 SetLastError(ERROR_OUTOFMEMORY);
464 return m_h != NULL ? ntohs(*(WORD*)
m_h->Length) : 0;
473 HeapFree(GetProcessHeap(), 0,
m_h);
481 const WORD n = ntohs(*
reinterpret_cast<WORD*
>(h->Length));
484 SetLastError(ERROR_OUTOFMEMORY);
505 dwNumberOfMethods = 0;
516 dwNumberOfMethods = other.dwNumberOfMethods;
517 pEapMethods = other.pEapMethods;
518 other.dwNumberOfMethods = 0;
519 other.pEapMethods = NULL;
538 if (
this != std::addressof(other)) {
541 dwNumberOfMethods = other.dwNumberOfMethods;
542 pEapMethods = other.pEapMethods;
543 other.dwNumberOfMethods = 0;
544 other.pEapMethods = NULL;
552 void free_internal() noexcept
554 for (DWORD i = 0; i < dwNumberOfMethods; i++)
555 free_internal(pEapMethods + i);
557 EapHostPeerFreeMemory(
reinterpret_cast<BYTE*
>(pEapMethods));
560 static void free_internal(_In_ EAP_METHOD_INFO *pMethodInfo)
noexcept
562 if (pMethodInfo->pInnerMethodInfo)
563 free_internal(pMethodInfo->pInnerMethodInfo);
565 EapHostPeerFreeMemory(
reinterpret_cast<BYTE*
>(pMethodInfo->pwszAuthorName));
566 EapHostPeerFreeMemory(
reinterpret_cast<BYTE*
>(pMethodInfo->pwszFriendlyName));
624 const EAP_METHOD_TYPE&
type() const noexcept
Integrates WinStd classes with Microsoft WinSock2 API.
Base abstract template class to support object handle keeping for objects that support trivial handle...
Definition: Common.h:877
EAP_ATTRIBUTE wrapper class.
Definition: EAP.h:217
eap_attr() noexcept
Initializes a new EAP attribute set to eatReserved.
Definition: EAP.h:222
eap_attr(eap_attr &&a) noexcept
Moves an existing EAP attribute.
Definition: EAP.h:247
~eap_attr()
Destroys the EAP attribute.
Definition: EAP.h:262
eap_attr & operator=(eap_attr &&a) noexcept
Moves an existing EAP attribute.
Definition: EAP.h:294
eap_attr(const EAP_ATTRIBUTE &a)
Copies an existing EAP attribute.
Definition: EAP.h:232
void create_ms_mppe_key(BYTE bVendorType, LPCBYTE pbKey, BYTE nKeySize)
Creates MS-MPPE-Send-Key or MS-MPPE-Recv-Key.
Definition: EAP.h:318
eap_attr & operator=(const EAP_ATTRIBUTE &a)
Copies an existing EAP attribute.
Definition: EAP.h:271
EAP_METHOD_INFO_ARRAY wrapper class.
Definition: EAP.h:496
eap_method_info_array(eap_method_info_array &&other) noexcept
Move constructor.
Definition: EAP.h:514
eap_method_info_array() noexcept
Constructs an empty array.
Definition: EAP.h:503
~eap_method_info_array()
Destructor.
Definition: EAP.h:525
eap_method_info_array & operator=(eap_method_info_array &&other) noexcept
Move assignment.
Definition: EAP.h:536
EAP_METHOD_PROPERTY wrapper class.
Definition: EAP.h:366
eap_method_prop(EAP_METHOD_PROPERTY_TYPE type, BOOL value) noexcept
Constructs a BOOL method property.
Definition: EAP.h:374
eap_method_prop(EAP_METHOD_PROPERTY_TYPE type, DWORD value) noexcept
Constructs a DWORD method property.
Definition: EAP.h:388
eap_method_prop(EAP_METHOD_PROPERTY_TYPE type, LPCWSTR value) noexcept
Constructs a Unicode string method property.
Definition: EAP.h:402
EapPacket wrapper class.
Definition: EAP.h:415
WORD size() const noexcept
Returns total EAP packet size in bytes.
Definition: EAP.h:462
handle_type duplicate_internal(handle_type h) const noexcept override
Duplicates the EAP packet.
Definition: EAP.h:479
virtual ~eap_packet()
Destroys the EAP packet.
Definition: EAP.h:422
void free_internal() noexcept override
Destroys the EAP packet.
Definition: EAP.h:471
bool create(EapCode code, BYTE id, WORD size) noexcept
Create new EAP packet.
Definition: EAP.h:441
EapHost runtime error.
Definition: EAP.h:583
const EAP_METHOD_TYPE & type() const noexcept
Returns EAP method type.
Definition: EAP.h:624
GUID m_root_cause_id
A unique ID that identifies cause of error in EAPHost.
Definition: EAP.h:682
const wchar_t * root_cause() const noexcept
Returns root cause ID.
Definition: EAP.h:648
const GUID & repair_id() const noexcept
Returns repair ID.
Definition: EAP.h:656
std::wstring m_repair_desc
A localized and readable string that describes the possible repair action.
Definition: EAP.h:686
DWORD reason() const noexcept
Returns the reason code for error.
Definition: EAP.h:632
EAP_METHOD_TYPE m_type
Structure that identifies the EAP method that raised the error.
Definition: EAP.h:678
eap_runtime_error(const EAP_ERROR &err, const char *msg=nullptr)
Constructs an exception.
Definition: EAP.h:609
GUID m_repair_id
A unique ID that maps to a localizable string that identifies the repair action that can be taken to ...
Definition: EAP.h:685
eap_runtime_error(const EAP_ERROR &err, const std::string &msg)
Constructs an exception.
Definition: EAP.h:591
const wchar_t * repair() const noexcept
Returns root cause ID.
Definition: EAP.h:664
GUID m_help_link_id
A unique ID that maps to a localizable string that specifies an URL for a page that contains addition...
Definition: EAP.h:688
const GUID & root_cause_id() const noexcept
Returns root cause ID.
Definition: EAP.h:640
std::wstring m_root_cause_desc
A localized and readable string that describes the root cause of the error.
Definition: EAP.h:683
const GUID & help_link_id() const noexcept
Returns help_link ID.
Definition: EAP.h:672
DWORD m_reason
The reason code for the error.
Definition: EAP.h:680
EapPacket * handle_type
Datatype of the object handle this template class handles.
Definition: Common.h:620
handle_type m_h
Object handle.
Definition: Common.h:866
void attach(handle_type h) noexcept
Sets a new object handle for the class.
Definition: Common.h:829
Windows runtime error.
Definition: Common.h:1056
tstring msg(DWORD dwLanguageId=0) const
Returns a user-readable Windows error message.
Definition: Common.h:1101
std::unique_ptr< EAP_ERROR, EapHostPeerFreeEapError_delete > eap_error_runtime
EAP_ERROR wrapper class.
Definition: EAP.h:209
std::unique_ptr< BYTE[], EapHostPeerFreeMemory_delete > eap_blob
EapHost BLOB wrapper class.
Definition: EAP.h:132
static bool operator==(const EAP_METHOD_TYPE &a, const EAP_METHOD_TYPE &b) noexcept
Are EAP method types equal?
Definition: EAP.h:43
eap_type_t
EAP method numbers.
Definition: EAP.h:82
std::unique_ptr< EAP_ERROR, EapHostPeerFreeErrorMemory_delete > eap_error
EAP_ERROR wrapper class.
Definition: EAP.h:183
std::unique_ptr< BYTE[], EapHostPeerFreeRuntimeMemory_delete > eap_blob_runtime
EapHost BLOB wrapper class.
Definition: EAP.h:157
static bool operator!=(const EAP_METHOD_TYPE &a, const EAP_METHOD_TYPE &b) noexcept
Are EAP method types non-equal?
Definition: EAP.h:62
static const EAP_ATTRIBUTE blank_eap_attr
Blank EAP attribute.
Definition: EAP.h:360
@ notification
Notification.
@ md5_challenge
MD5-Challenge.
@ legacy_pap
PAP (Not actually an EAP method; Moved to the Unassigned area)
@ gtc
Generic Token Card (GTC)
@ undefined
Undefined EAP type.
@ end
End of EAP methods (non-inclusive)
@ gtcp
EAP-GTC using a password.
@ noneap_start
Start of non-EAP methods.
@ noneap_end
End of non-EAP methods (non-inclusive)
@ otp
One-Time Password (OTP)
@ legacy_mschapv2
MSCHAPv2 (Not actually an EAP method; Moved to the Unassigned area)
@ ms_auth_tlv
MS-Authentication-TLV.
@ start
Start of EAP methods.
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition: Common.h:74
#define WINSTD_DPLHANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition: Common.h:183
static const EapPacket * invalid
Invalid handle value.
Definition: Common.h:625
Deleter for unique_ptr to EAP_ERROR using EapHostPeerFreeEapError.
Definition: EAP.h:189
EapHostPeerFreeEapError_delete() noexcept
Default constructor.
Definition: EAP.h:193
void operator()(EAP_ERROR *_Ptr) const noexcept
Delete a pointer.
Definition: EAP.h:200
Deleter for unique_ptr to EAP_ERROR using EapHostPeerFreeErrorMemory.
Definition: EAP.h:163
EapHostPeerFreeErrorMemory_delete() noexcept
Default constructor.
Definition: EAP.h:167
void operator()(EAP_ERROR *_Ptr) const noexcept
Delete a pointer.
Definition: EAP.h:174
Deleter for unique_ptr using EapHostPeerFreeMemory.
Definition: EAP.h:111
void operator()(_T *_Ptr) const
Delete a pointer.
Definition: EAP.h:123
EapHostPeerFreeMemory_delete() noexcept
Default constructor.
Definition: EAP.h:115
Deleter for unique_ptr using EapHostPeerFreeRuntimeMemory.
Definition: EAP.h:138
void operator()(_T *_Ptr) const
Delete a pointer.
Definition: EAP.h:148
EapHostPeerFreeRuntimeMemory_delete() noexcept
Default constructor.
Definition: EAP.h:142