Some EapHost peer helper classes introduced
This commit is contained in:
parent
d029358086
commit
129b9c9a10
@ -21,6 +21,7 @@
|
||||
#include "Common.h"
|
||||
|
||||
#include <Windows.h>
|
||||
#include <eaphostpeerconfigapis.h>
|
||||
#include <eaptypes.h> // Must include after <Windows.h>
|
||||
|
||||
namespace winstd
|
||||
@ -38,6 +39,16 @@ namespace winstd
|
||||
///
|
||||
enum eap_type_t;
|
||||
|
||||
///
|
||||
/// Deleter for unique_ptr using EapHostPeerFreeMemory
|
||||
///
|
||||
struct WINSTD_API EapHostPeerFreeMemory_delete;
|
||||
|
||||
///
|
||||
/// Deleter for unique_ptr to EAP_ERROR using EapHostPeerFreeEapError
|
||||
///
|
||||
struct WINSTD_API EapHostPeerFreeErrorMemory_delete;
|
||||
|
||||
///
|
||||
/// EAP_ATTRIBUTE wrapper class
|
||||
///
|
||||
@ -53,6 +64,11 @@ namespace winstd
|
||||
///
|
||||
class WINSTD_API eap_packet;
|
||||
|
||||
///
|
||||
/// EAP_METHOD_INFO_ARRAY wrapper class
|
||||
///
|
||||
class WINSTD_API eap_method_info_array;
|
||||
|
||||
/// @}
|
||||
}
|
||||
|
||||
@ -87,6 +103,40 @@ namespace winstd
|
||||
};
|
||||
|
||||
|
||||
struct WINSTD_API EapHostPeerFreeMemory_delete
|
||||
{
|
||||
///
|
||||
/// Default constructor
|
||||
///
|
||||
EapHostPeerFreeMemory_delete() {}
|
||||
|
||||
///
|
||||
/// Delete a pointer
|
||||
///
|
||||
void operator()(BYTE *_Ptr) const
|
||||
{
|
||||
EapHostPeerFreeMemory(_Ptr);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct WINSTD_API EapHostPeerFreeErrorMemory_delete
|
||||
{
|
||||
///
|
||||
/// Default constructor
|
||||
///
|
||||
EapHostPeerFreeErrorMemory_delete() {}
|
||||
|
||||
///
|
||||
/// Delete a pointer
|
||||
///
|
||||
void operator()(EAP_ERROR *_Ptr) const
|
||||
{
|
||||
EapHostPeerFreeErrorMemory(_Ptr);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class WINSTD_API __declspec(novtable) eap_attr : public EAP_ATTRIBUTE
|
||||
{
|
||||
public:
|
||||
@ -304,4 +354,60 @@ namespace winstd
|
||||
///
|
||||
virtual handle_type duplicate_internal(_In_ handle_type h) const;
|
||||
};
|
||||
|
||||
|
||||
class WINSTD_API __declspec(novtable) eap_method_info_array : public EAP_METHOD_INFO_ARRAY
|
||||
{
|
||||
WINSTD_NONCOPYABLE(eap_method_info_array)
|
||||
|
||||
public:
|
||||
///
|
||||
/// Constructs an empty array
|
||||
///
|
||||
inline eap_method_info_array()
|
||||
{
|
||||
dwNumberOfMethods = 0;
|
||||
pEapMethods = NULL;
|
||||
}
|
||||
|
||||
///
|
||||
/// Move constructor
|
||||
///
|
||||
/// \param[inout] other A rvalue reference of another object
|
||||
///
|
||||
inline eap_method_info_array(_Inout_ eap_method_info_array &&other)
|
||||
{
|
||||
dwNumberOfMethods = other.dwNumberOfMethods;
|
||||
pEapMethods = other.pEapMethods;
|
||||
other.dwNumberOfMethods = 0;
|
||||
other.pEapMethods = NULL;
|
||||
}
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
~eap_method_info_array();
|
||||
|
||||
///
|
||||
/// Move assignment
|
||||
///
|
||||
/// \param[inout] other A rvalue reference of another object
|
||||
///
|
||||
inline eap_method_info_array& operator=(_Inout_ eap_method_info_array &&other)
|
||||
{
|
||||
if (this != std::addressof(other)) {
|
||||
if (pEapMethods)
|
||||
free_internal();
|
||||
dwNumberOfMethods = other.dwNumberOfMethods;
|
||||
pEapMethods = other.pEapMethods;
|
||||
other.dwNumberOfMethods = 0;
|
||||
other.pEapMethods = NULL;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
void free_internal();
|
||||
static void free_internal(_In_ EAP_METHOD_INFO *pMethodInfo);
|
||||
};
|
||||
}
|
||||
|
32
src/EAP.cpp
32
src/EAP.cpp
@ -20,6 +20,8 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#pragma comment(lib, "Eappcfg.lib")
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// winstd::eap_attr
|
||||
@ -99,3 +101,33 @@ winstd::eap_packet::handle_type winstd::eap_packet::duplicate_internal(_In_ hand
|
||||
|
||||
return h2;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// winstd::eap_method_info_array
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
winstd::eap_method_info_array::~eap_method_info_array()
|
||||
{
|
||||
if (pEapMethods)
|
||||
free_internal();
|
||||
}
|
||||
|
||||
|
||||
void winstd::eap_method_info_array::free_internal()
|
||||
{
|
||||
for (DWORD i = 0; i < dwNumberOfMethods; i++)
|
||||
free_internal(pEapMethods + i);
|
||||
|
||||
EapHostPeerFreeMemory((BYTE*)pEapMethods);
|
||||
}
|
||||
|
||||
|
||||
void winstd::eap_method_info_array::free_internal(_In_ EAP_METHOD_INFO *pMethodInfo)
|
||||
{
|
||||
if (pMethodInfo->pInnerMethodInfo)
|
||||
free_internal(pMethodInfo->pInnerMethodInfo);
|
||||
|
||||
EapHostPeerFreeMemory((BYTE*)pMethodInfo->pwszAuthorName);
|
||||
EapHostPeerFreeMemory((BYTE*)pMethodInfo->pwszFriendlyName);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user