10#include <eaphostpeerconfigapis.h>
12#include <EapHostPeerTypes.h>
13#include <eapmethodtypes.h>
19#pragma warning(disable: 26812)
22#pragma warning(disable: 4505)
40static bool operator==(_In_
const EAP_METHOD_TYPE &a, _In_
const EAP_METHOD_TYPE &b)
noexcept
43 a.eapType.type == b.eapType.type &&
44 a.eapType.dwVendorId == b.eapType.dwVendorId &&
45 a.eapType.dwVendorType == b.eapType.dwVendorType &&
46 a.dwAuthorId == a.dwAuthorId;
59static bool operator!=(_In_
const EAP_METHOD_TYPE &a, _In_
const EAP_METHOD_TYPE &b)
noexcept
61 return !operator==(a, b);
78 #pragma warning(suppress: 4480)
122 EapHostPeerFreeMemory((BYTE*)_Ptr);
129 typedef std::unique_ptr<BYTE[], EapHostPeerFreeMemory_delete>
eap_blob;
147 EapHostPeerFreeRuntimeMemory((BYTE*)_Ptr);
173 EapHostPeerFreeErrorMemory(_Ptr);
180 typedef std::unique_ptr<EAP_ERROR, EapHostPeerFreeErrorMemory_delete>
eap_error;
199 EapHostPeerFreeEapError(_Ptr);
211 #pragma warning(push)
212 #pragma warning(disable: 26432)
221 eaType = eatReserved;
232 dwLength = a.dwLength;
234 pValue =
new BYTE[a.dwLength];
236 memcpy(pValue, a.pValue, a.dwLength);
247 dwLength = a.dwLength;
272 dwLength = a.dwLength;
274 BYTE *pValueNew =
new BYTE[a.dwLength];
278 memcpy(pValueNew, a.pValue, a.dwLength);
295 dwLength = a.dwLength;
315 void create_ms_mppe_key(_In_ BYTE bVendorType, _In_count_(nKeySize) LPCBYTE pbKey, _In_ BYTE nKeySize)
317 const BYTE nPaddingLength =
static_cast<BYTE
>((16 - (1 +
static_cast<DWORD
>(nKeySize))) % 16);
318 const DWORD dwLengthNew =
327 #pragma warning(push)
328 #pragma warning(disable: 6386)
329 LPBYTE p =
new BYTE[dwLengthNew];
335 p[5] =
static_cast<BYTE
>(dwLengthNew - 4);
340 memcpy(p + 9, pbKey, nKeySize);
341 memset(p + 9 + nKeySize, 0, nPaddingLength);
346 #pragma warning(suppress: 26812)
347 eaType = eatVendorSpecific;
348 dwLength = dwLengthNew;
357 static const EAP_ATTRIBUTE blank_eap_attr = {};
373 eapMethodPropertyType = type;
374 eapMethodPropertyValueType = empvtBool;
375 eapMethodPropertyValue.empvBool.length =
sizeof(BOOL);
376 eapMethodPropertyValue.empvBool.value = value;
387 eapMethodPropertyType = type;
388 eapMethodPropertyValueType = empvtDword;
389 eapMethodPropertyValue.empvDword.length =
sizeof(DWORD);
390 eapMethodPropertyValue.empvDword.value = value;
401 eapMethodPropertyType = type;
402 eapMethodPropertyValueType = empvtString;
403 eapMethodPropertyValue.empvString.length =
static_cast<DWORD
>(
sizeof(WCHAR)*(wcslen(value) + 1));
404 eapMethodPropertyValue.empvString.value =
const_cast<BYTE*
>(
reinterpret_cast<const BYTE*
>(value));
438 bool create(_In_ EapCode code, _In_ BYTE
id, _In_ WORD
size)
noexcept
444 h->Code =
static_cast<BYTE
>(code);
446 *
reinterpret_cast<WORD*
>(h->Length) = htons(
size);
451 SetLastError(ERROR_OUTOFMEMORY);
461 return m_h != NULL ? ntohs(*(WORD*)
m_h->Length) : 0;
470 HeapFree(GetProcessHeap(), 0,
m_h);
478 const WORD n = ntohs(*
reinterpret_cast<WORD*
>(h->Length));
481 SetLastError(ERROR_OUTOFMEMORY);
502 dwNumberOfMethods = 0;
513 dwNumberOfMethods = other.dwNumberOfMethods;
514 pEapMethods = other.pEapMethods;
515 other.dwNumberOfMethods = 0;
516 other.pEapMethods = NULL;
535 if (
this != std::addressof(other)) {
538 dwNumberOfMethods = other.dwNumberOfMethods;
539 pEapMethods = other.pEapMethods;
540 other.dwNumberOfMethods = 0;
541 other.pEapMethods = NULL;
549 void free_internal() noexcept
551 for (DWORD i = 0; i < dwNumberOfMethods; i++)
552 free_internal(pEapMethods + i);
554 EapHostPeerFreeMemory(
reinterpret_cast<BYTE*
>(pEapMethods));
557 static void free_internal(_In_ EAP_METHOD_INFO *pMethodInfo)
noexcept
559 if (pMethodInfo->pInnerMethodInfo)
560 free_internal(pMethodInfo->pInnerMethodInfo);
562 EapHostPeerFreeMemory(
reinterpret_cast<BYTE*
>(pMethodInfo->pwszAuthorName));
563 EapHostPeerFreeMemory(
reinterpret_cast<BYTE*
>(pMethodInfo->pwszFriendlyName));
621 const EAP_METHOD_TYPE&
type() const noexcept
Base abstract template class to support object handle keeping for objects that support handle duplica...
Definition: Common.h:866
EAP_ATTRIBUTE wrapper class.
Definition: EAP.h:214
eap_attr() noexcept
Initializes a new EAP attribute set to eatReserved.
Definition: EAP.h:219
~eap_attr()
Destroys the EAP attribute.
Definition: EAP.h:259
eap_attr & operator=(1 const EAP_ATTRIBUTE &a)
Copies an existing EAP attribute.
Definition: EAP.h:268
eap_attr(1 const EAP_ATTRIBUTE &a)
Copies an existing EAP attribute.
Definition: EAP.h:229
eap_attr & operator=(1 eap_attr &&a) noexcept
Moves an existing EAP attribute.
Definition: EAP.h:291
void create_ms_mppe_key(1 BYTE bVendorType, LPCBYTE pbKey, 1 BYTE nKeySize)
Creates MS-MPPE-Send-Key or MS-MPPE-Recv-Key.
Definition: EAP.h:315
eap_attr(1 eap_attr &&a) noexcept
Moves an existing EAP attribute.
Definition: EAP.h:244
EAP_METHOD_INFO_ARRAY wrapper class.
Definition: EAP.h:493
eap_method_info_array & operator=(1 eap_method_info_array &&other) noexcept
Move assignment.
Definition: EAP.h:533
eap_method_info_array() noexcept
Constructs an empty array.
Definition: EAP.h:500
~eap_method_info_array()
Destructor.
Definition: EAP.h:522
eap_method_info_array(1 eap_method_info_array &&other) noexcept
Move constructor.
Definition: EAP.h:511
EAP_METHOD_PROPERTY wrapper class.
Definition: EAP.h:363
eap_method_prop(1 EAP_METHOD_PROPERTY_TYPE type, 1 BOOL value) noexcept
Constructs a BOOL method property.
Definition: EAP.h:371
eap_method_prop(1 EAP_METHOD_PROPERTY_TYPE type, 1 LPCWSTR value) noexcept
Constructs a Unicode string method property.
Definition: EAP.h:399
eap_method_prop(1 EAP_METHOD_PROPERTY_TYPE type, 1 DWORD value) noexcept
Constructs a DWORD method property.
Definition: EAP.h:385
EapPacket wrapper class.
Definition: EAP.h:412
WORD size() const noexcept
Returns total EAP packet size in bytes.
Definition: EAP.h:459
bool create(1 EapCode code, 1 BYTE id, 1 WORD size) noexcept
Create new EAP packet.
Definition: EAP.h:438
virtual ~eap_packet()
Destroys the EAP packet.
Definition: EAP.h:419
void free_internal() noexcept override
Destroys the EAP packet.
Definition: EAP.h:468
handle_type duplicate_internal(1 handle_type h) const noexcept override
Duplicates the EAP packet.
Definition: EAP.h:476
EapHost runtime error.
Definition: EAP.h:580
const EAP_METHOD_TYPE & type() const noexcept
Returns EAP method type.
Definition: EAP.h:621
GUID m_root_cause_id
A unique ID that identifies cause of error in EAPHost.
Definition: EAP.h:679
const wchar_t * root_cause() const noexcept
Returns root cause ID.
Definition: EAP.h:645
const GUID & repair_id() const noexcept
Returns repair ID.
Definition: EAP.h:653
std::wstring m_repair_desc
A localized and readable string that describes the possible repair action.
Definition: EAP.h:683
eap_runtime_error(1 const EAP_ERROR &err, 1 const char *msg=nullptr)
Constructs an exception.
Definition: EAP.h:606
DWORD reason() const noexcept
Returns the reason code for error.
Definition: EAP.h:629
EAP_METHOD_TYPE m_type
Structure that identifies the EAP method that raised the error.
Definition: EAP.h:675
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:682
eap_runtime_error(1 const EAP_ERROR &err, 1 const std::string &msg)
Constructs an exception.
Definition: EAP.h:588
const wchar_t * repair() const noexcept
Returns root cause ID.
Definition: EAP.h:661
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:685
const GUID & root_cause_id() const noexcept
Returns root cause ID.
Definition: EAP.h:637
std::wstring m_root_cause_desc
A localized and readable string that describes the root cause of the error.
Definition: EAP.h:680
const GUID & help_link_id() const noexcept
Returns help_link ID.
Definition: EAP.h:669
DWORD m_reason
The reason code for the error.
Definition: EAP.h:677
EapPacket * handle_type
Datatype of the object handle this template class handles.
Definition: Common.h:609
void attach(1 handle_type h) noexcept
Sets a new object handle for the class.
Definition: Common.h:818
handle_type m_h
Object handle.
Definition: Common.h:855
Windows runtime error.
Definition: Common.h:1048
tstring msg(1 DWORD dwLanguageId=0) const
Returns a user-readable Windows error message.
Definition: Common.h:1093
std::unique_ptr< EAP_ERROR, EapHostPeerFreeEapError_delete > eap_error_runtime
EAP_ERROR wrapper class.
Definition: EAP.h:206
std::unique_ptr< BYTE[], EapHostPeerFreeMemory_delete > eap_blob
EapHost BLOB wrapper class.
Definition: EAP.h:129
eap_type_t
EAP method numbers.
Definition: EAP.h:79
std::unique_ptr< EAP_ERROR, EapHostPeerFreeErrorMemory_delete > eap_error
EAP_ERROR wrapper class.
Definition: EAP.h:180
std::unique_ptr< BYTE[], EapHostPeerFreeRuntimeMemory_delete > eap_blob_runtime
EapHost BLOB wrapper class.
Definition: EAP.h:154
@ 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:53
#define WINSTD_DPLHANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition: Common.h:174
static const EapPacket * invalid
Invalid handle value.
Definition: Common.h:614
Deleter for unique_ptr to EAP_ERROR using EapHostPeerFreeEapError.
Definition: EAP.h:186
EapHostPeerFreeEapError_delete() noexcept
Default constructor.
Definition: EAP.h:190
void operator()(EAP_ERROR *_Ptr) const noexcept
Delete a pointer.
Definition: EAP.h:197
Deleter for unique_ptr to EAP_ERROR using EapHostPeerFreeErrorMemory.
Definition: EAP.h:160
EapHostPeerFreeErrorMemory_delete() noexcept
Default constructor.
Definition: EAP.h:164
void operator()(EAP_ERROR *_Ptr) const noexcept
Delete a pointer.
Definition: EAP.h:171
Deleter for unique_ptr using EapHostPeerFreeMemory.
Definition: EAP.h:108
void operator()(_T *_Ptr) const
Delete a pointer.
Definition: EAP.h:120
EapHostPeerFreeMemory_delete() noexcept
Default constructor.
Definition: EAP.h:112
Deleter for unique_ptr using EapHostPeerFreeRuntimeMemory.
Definition: EAP.h:135
void operator()(_T *_Ptr) const
Delete a pointer.
Definition: EAP.h:145
EapHostPeerFreeRuntimeMemory_delete() noexcept
Default constructor.
Definition: EAP.h:139