pack() => operator <<, unpack() => operator >>, get_pk_size() => pksizeof()

This commit is contained in:
Simon Rozman 2016-07-21 09:20:09 +02:00
parent 51428d290f
commit 627b20aabc
14 changed files with 779 additions and 792 deletions

View File

@ -45,15 +45,13 @@ namespace eap
class config_providers;
}
namespace eapserial
{
///
/// Packs a configuration
///
/// \param[inout] cursor Memory cursor
/// \param[in] val Configuration to pack
///
inline void pack(_Inout_ cursor_out &cursor, _In_ const eap::config &val);
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const eap::config &val);
///
/// Returns packed size of a configuration
@ -62,7 +60,7 @@ namespace eapserial
///
/// \returns Size of data when packed (in bytes)
///
inline size_t get_pk_size(const eap::config &val);
inline size_t pksizeof(const eap::config &val);
///
/// Unpacks a configuration
@ -70,8 +68,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[out] val Configuration to unpack to
///
inline void unpack(_Inout_ cursor_in &cursor, _Out_ eap::config &val);
}
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::config &val);
#pragma once
@ -181,7 +178,7 @@ namespace eap
///
/// \param[inout] cursor Memory cursor
///
virtual void pack(_Inout_ eapserial::cursor_out &cursor) const;
virtual void operator<<(_Inout_ cursor_out &cursor) const;
///
/// Returns packed size of a configuration
@ -195,7 +192,7 @@ namespace eap
///
/// \param[inout] cursor Memory cursor
///
virtual void unpack(_Inout_ eapserial::cursor_in &cursor);
virtual void operator>>(_Inout_ cursor_in &cursor);
/// @}
@ -288,7 +285,7 @@ namespace eap
///
/// \param[inout] cursor Memory cursor
///
virtual void pack(_Inout_ eapserial::cursor_out &cursor) const;
virtual void operator<<(_Inout_ cursor_out &cursor) const;
///
/// Returns packed size of a configuration
@ -302,7 +299,7 @@ namespace eap
///
/// \param[inout] cursor Memory cursor
///
virtual void unpack(_Inout_ eapserial::cursor_in &cursor);
virtual void operator>>(_Inout_ cursor_in &cursor);
/// @}
@ -412,7 +409,7 @@ namespace eap
///
/// \param[inout] cursor Memory cursor
///
virtual void pack(_Inout_ eapserial::cursor_out &cursor) const;
virtual void operator<<(_Inout_ cursor_out &cursor) const;
///
/// Returns packed size of a configuration
@ -426,7 +423,7 @@ namespace eap
///
/// \param[inout] cursor Memory cursor
///
virtual void unpack(_Inout_ eapserial::cursor_in &cursor);
virtual void operator>>(_Inout_ cursor_in &cursor);
/// @}
@ -531,7 +528,7 @@ namespace eap
///
/// \param[inout] cursor Memory cursor
///
virtual void pack(_Inout_ eapserial::cursor_out &cursor) const;
virtual void operator<<(_Inout_ cursor_out &cursor) const;
///
/// Returns packed size of a configuration
@ -545,7 +542,7 @@ namespace eap
///
/// \param[inout] cursor Memory cursor
///
virtual void unpack(_Inout_ eapserial::cursor_in &cursor);
virtual void operator>>(_Inout_ cursor_in &cursor);
/// @}
@ -555,22 +552,19 @@ namespace eap
}
namespace eapserial
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const eap::config &val)
{
inline void pack(_Inout_ cursor_out &cursor, _In_ const eap::config &val)
{
val.pack(cursor);
val.operator<<(cursor);
}
inline size_t get_pk_size(const eap::config &val)
inline size_t pksizeof(const eap::config &val)
{
return val.get_pk_size();
}
inline void unpack(_Inout_ cursor_in &cursor, _Out_ eap::config &val)
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::config &val)
{
val.unpack(cursor);
}
val.operator>>(cursor);
}

View File

@ -293,7 +293,7 @@ namespace eap
///
/// \param[inout] cursor Memory cursor
///
virtual void pack(_Inout_ eapserial::cursor_out &cursor) const;
virtual void operator<<(_Inout_ cursor_out &cursor) const;
///
/// Returns packed size of a configuration
@ -307,7 +307,7 @@ namespace eap
///
/// \param[inout] cursor Memory cursor
///
virtual void unpack(_Inout_ eapserial::cursor_in &cursor);
virtual void operator>>(_Inout_ cursor_in &cursor);
/// @}

View File

@ -44,10 +44,7 @@ namespace eap
/// \sa [Extensible Authentication Protocol (EAP) Registry (Chapter: Method Types)](https://www.iana.org/assignments/eap-numbers/eap-numbers.xhtml#eap-numbers-4)
///
enum type_t;
}
namespace eapserial
{
///
/// Output BLOB cursor
///
@ -57,6 +54,7 @@ namespace eapserial
/// Input BLOB cursor
///
struct cursor_in;
}
///
/// Packs a boolean
@ -64,7 +62,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[in] val Variable with data to pack
///
inline void pack(_Inout_ cursor_out &cursor, _In_ const bool &val);
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const bool &val);
///
/// Returns packed size of a boolean
@ -73,7 +71,7 @@ namespace eapserial
///
/// \returns Size of data when packed (in bytes)
///
inline size_t get_pk_size(_In_ const bool &val);
inline size_t pksizeof(_In_ const bool &val);
///
/// Unpacks a boolean
@ -81,7 +79,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[out] val Variable to receive unpacked value
///
inline void unpack(_Inout_ cursor_in &cursor, _Out_ bool &val);
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ bool &val);
///
/// Packs a byte
@ -89,7 +87,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[in] val Variable with data to pack
///
inline void pack(_Inout_ cursor_out &cursor, _In_ const unsigned char &val);
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const unsigned char &val);
///
/// Returns packed size of a byte
@ -98,7 +96,7 @@ namespace eapserial
///
/// \returns Size of data when packed (in bytes)
///
inline size_t get_pk_size(_In_ const unsigned char &val);
inline size_t pksizeof(_In_ const unsigned char &val);
///
/// Unpacks a byte
@ -106,7 +104,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[out] val Variable to receive unpacked value
///
inline void unpack(_Inout_ cursor_in &cursor, _Out_ unsigned char &val);
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ unsigned char &val);
///
/// Packs an unsigned int
@ -114,7 +112,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[in] val Variable with data to pack
///
inline void pack(_Inout_ cursor_out &cursor, _In_ const unsigned int &val);
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const unsigned int &val);
///
/// Returns packed size of an unsigned int
@ -123,7 +121,7 @@ namespace eapserial
///
/// \returns Size of data when packed (in bytes)
///
inline size_t get_pk_size(_In_ const unsigned int &val);
inline size_t pksizeof(_In_ const unsigned int &val);
///
/// Unpacks an unsigned int
@ -131,7 +129,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[out] val Variable to receive unpacked value
///
inline void unpack(_Inout_ cursor_in &cursor, _Out_ unsigned int &val);
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ unsigned int &val);
#ifdef _WIN64
///
@ -140,7 +138,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[in] val Variable with data to pack
///
inline void pack(_Inout_ cursor_out &cursor, _In_ const size_t &val);
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const size_t &val);
///
/// Returns packed size of a size_t
@ -149,7 +147,7 @@ namespace eapserial
///
/// \returns Size of data when packed (in bytes)
///
inline size_t get_pk_size(_In_ const size_t &val);
inline size_t pksizeof(_In_ const size_t &val);
///
/// Unpacks a size_t
@ -157,7 +155,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[out] val Variable to receive unpacked value
///
inline void unpack(_Inout_ cursor_in &cursor, _Out_ size_t &val);
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ size_t &val);
#endif
///
@ -166,7 +164,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[in] val String to pack
///
template<class _Elem, class _Traits, class _Ax> inline void pack(_Inout_ cursor_out &cursor, _In_ const std::basic_string<_Elem, _Traits, _Ax> &val);
template<class _Elem, class _Traits, class _Ax> inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const std::basic_string<_Elem, _Traits, _Ax> &val);
///
/// Returns packed size of a string
@ -175,7 +173,7 @@ namespace eapserial
///
/// \returns Size of data when packed (in bytes)
///
template<class _Elem, class _Traits, class _Ax> inline size_t get_pk_size(const std::basic_string<_Elem, _Traits, _Ax> &val);
template<class _Elem, class _Traits, class _Ax> inline size_t pksizeof(const std::basic_string<_Elem, _Traits, _Ax> &val);
///
/// Unpacks a string
@ -183,7 +181,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[out] val String to unpack to
///
template<class _Elem, class _Traits, class _Ax> inline void unpack(_Inout_ cursor_in &cursor, _Out_ std::basic_string<_Elem, _Traits, _Ax> &val);
template<class _Elem, class _Traits, class _Ax> inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ std::basic_string<_Elem, _Traits, _Ax> &val);
///
/// Packs a wide string
@ -191,7 +189,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[in] val String to pack
///
template<class _Traits, class _Ax> inline void pack(_Inout_ cursor_out &cursor, _In_ const std::basic_string<wchar_t, _Traits, _Ax> &val);
template<class _Traits, class _Ax> inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const std::basic_string<wchar_t, _Traits, _Ax> &val);
///
/// Returns packed size of a wide string
@ -200,7 +198,7 @@ namespace eapserial
///
/// \returns Size of data when packed (in bytes)
///
template<class _Traits, class _Ax> inline size_t get_pk_size(const std::basic_string<wchar_t, _Traits, _Ax> &val);
template<class _Traits, class _Ax> inline size_t pksizeof(const std::basic_string<wchar_t, _Traits, _Ax> &val);
///
/// Unpacks a wide string
@ -208,7 +206,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[out] val String to unpack to
///
template<class _Traits, class _Ax> inline void unpack(_Inout_ cursor_in &cursor, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &val);
template<class _Traits, class _Ax> inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &val);
///
/// Packs a vector
@ -216,7 +214,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[in] val Vector to pack
///
template<class _Ty, class _Ax> inline void pack(_Inout_ cursor_out &cursor, _In_ const std::vector<_Ty, _Ax> &val);
template<class _Ty, class _Ax> inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const std::vector<_Ty, _Ax> &val);
///
/// Returns packed size of a vector
@ -225,7 +223,7 @@ namespace eapserial
///
/// \returns Size of data when packed (in bytes)
///
template<class _Ty, class _Ax> inline size_t get_pk_size(const std::vector<_Ty, _Ax> &val);
template<class _Ty, class _Ax> inline size_t pksizeof(const std::vector<_Ty, _Ax> &val);
///
/// Unpacks a vector
@ -233,7 +231,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[out] val Vector to unpack to
///
template<class _Ty, class _Ax> inline void unpack(_Inout_ cursor_in &cursor, _Out_ std::vector<_Ty, _Ax> &val);
template<class _Ty, class _Ax> inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ std::vector<_Ty, _Ax> &val);
///
/// Packs a list
@ -241,7 +239,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[in] val List to pack
///
template<class _Ty, class _Ax> inline void pack(_Inout_ cursor_out &cursor, _In_ const std::list<_Ty, _Ax> &val);
template<class _Ty, class _Ax> inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const std::list<_Ty, _Ax> &val);
///
/// Returns packed size of a list
@ -250,7 +248,7 @@ namespace eapserial
///
/// \returns Size of data when packed (in bytes)
///
template<class _Ty, class _Ax> inline size_t get_pk_size(const std::list<_Ty, _Ax> &val);
template<class _Ty, class _Ax> inline size_t pksizeof(const std::list<_Ty, _Ax> &val);
///
/// Unpacks a list
@ -258,7 +256,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[out] val List to unpack to
///
template<class _Ty, class _Ax> inline void unpack(_Inout_ cursor_in &cursor, _Out_ std::list<_Ty, _Ax> &val);
template<class _Ty, class _Ax> inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ std::list<_Ty, _Ax> &val);
///
/// Packs a std::unique_ptr
@ -266,7 +264,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[in] val std::unique_ptr to pack
///
template<class _Ty, class _Dx> inline void pack(_Inout_ cursor_out &cursor, _In_ const std::unique_ptr<_Ty, _Dx> &val);
template<class _Ty, class _Dx> inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const std::unique_ptr<_Ty, _Dx> &val);
///
/// Returns packed size of a std::unique_ptr
@ -275,7 +273,7 @@ namespace eapserial
///
/// \returns Size of data when packed (in bytes)
///
template<class _Ty, class _Dx> inline size_t get_pk_size(const std::unique_ptr<_Ty, _Dx> &val);
template<class _Ty, class _Dx> inline size_t pksizeof(const std::unique_ptr<_Ty, _Dx> &val);
/////
///// Unpacks a std::unique_ptr
@ -285,7 +283,7 @@ namespace eapserial
///// \param[inout] cursor Memory cursor
///// \param[out] val std::unique_ptr to unpack to
/////
//template<class _Ty, class _Dx> inline void unpack(_Inout_ cursor_in &cursor, _Out_ std::unique_ptr<_Ty, _Dx> &val);
//template<class _Ty, class _Dx> inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ std::unique_ptr<_Ty, _Dx> &val);
///
/// Packs a certificate context
@ -293,7 +291,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[in] val Certificate context to pack
///
inline void pack(_Inout_ cursor_out &cursor, _In_ const winstd::cert_context &val);
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const winstd::cert_context &val);
///
/// Returns packed size of a certificate context
@ -302,7 +300,7 @@ namespace eapserial
///
/// \returns Size of data when packed (in bytes)
///
inline size_t get_pk_size(const winstd::cert_context &val);
inline size_t pksizeof(const winstd::cert_context &val);
///
/// Unpacks a certificate context
@ -310,7 +308,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[out] val Certificate context to unpack to
///
inline void unpack(_Inout_ cursor_in &cursor, _Out_ winstd::cert_context &val);
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ winstd::cert_context &val);
///
/// Packs an EAP method type
@ -318,7 +316,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[in] val EAP method type to pack
///
inline void pack(_Inout_ cursor_out &cursor, _In_ const eap::type_t &val);
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const eap::type_t &val);
///
/// Returns packed size of an EAP method type
@ -327,7 +325,7 @@ namespace eapserial
///
/// \returns Size of data when packed (in bytes)
///
inline size_t get_pk_size(const eap::type_t &val);
inline size_t pksizeof(const eap::type_t &val);
///
/// Unpacks an EAP method type
@ -335,8 +333,7 @@ namespace eapserial
/// \param[inout] cursor Memory cursor
/// \param[out] val EAP method type to unpack to
///
inline void unpack(_Inout_ cursor_in &cursor, _Out_ eap::type_t &val);
}
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::type_t &val);
#pragma once
@ -351,11 +348,7 @@ namespace eap
type_mschapv2 = 26, ///< EAP-MSCHAPv2
type_pap = 192, ///< PAP (Not actually an EAP method; Moved to the Unassigned area)
};
}
namespace eapserial
{
struct cursor_out
{
typedef unsigned char *ptr_type;
@ -371,77 +364,78 @@ namespace eapserial
ptr_type ptr; ///< Pointer to first data unread
ptr_type ptr_end; ///< Pointer to the end of BLOB
};
}
inline void pack(_Inout_ cursor_out &cursor, _In_ const bool &val)
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const bool &val)
{
cursor_out::ptr_type ptr_end = cursor.ptr + 1;
eap::cursor_out::ptr_type ptr_end = cursor.ptr + 1;
assert(ptr_end <= cursor.ptr_end);
*cursor.ptr = val ? 1 : 0;
cursor.ptr = ptr_end;
}
inline size_t get_pk_size(_In_ const bool &val)
inline size_t pksizeof(_In_ const bool &val)
{
UNREFERENCED_PARAMETER(val);
return sizeof(unsigned char);
}
inline void unpack(_Inout_ cursor_in &cursor, _Out_ bool &val)
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ bool &val)
{
cursor_in::ptr_type ptr_end = cursor.ptr + 1;
eap::cursor_in::ptr_type ptr_end = cursor.ptr + 1;
assert(ptr_end <= cursor.ptr_end);
val = *cursor.ptr ? true : false;
cursor.ptr = ptr_end;
}
inline void pack(_Inout_ cursor_out &cursor, _In_ const unsigned char &val)
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const unsigned char &val)
{
cursor_out::ptr_type ptr_end = cursor.ptr + 1;
eap::cursor_out::ptr_type ptr_end = cursor.ptr + 1;
assert(ptr_end <= cursor.ptr_end);
*cursor.ptr = val;
cursor.ptr = ptr_end;
}
inline size_t get_pk_size(_In_ const unsigned char &val)
inline size_t pksizeof(_In_ const unsigned char &val)
{
UNREFERENCED_PARAMETER(val);
return sizeof(unsigned char);
}
inline void unpack(_Inout_ cursor_in &cursor, _Out_ unsigned char &val)
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ unsigned char &val)
{
cursor_in::ptr_type ptr_end = cursor.ptr + 1;
eap::cursor_in::ptr_type ptr_end = cursor.ptr + 1;
assert(ptr_end <= cursor.ptr_end);
val = *cursor.ptr;
cursor.ptr = ptr_end;
}
inline void pack(_Inout_ cursor_out &cursor, _In_ const unsigned int &val)
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const unsigned int &val)
{
cursor_out::ptr_type ptr_end = cursor.ptr + sizeof(unsigned int);
eap::cursor_out::ptr_type ptr_end = cursor.ptr + sizeof(unsigned int);
assert(ptr_end <= cursor.ptr_end);
*(unsigned int*)cursor.ptr = val;
cursor.ptr = ptr_end;
}
inline size_t get_pk_size(_In_ const unsigned int &val)
inline size_t pksizeof(_In_ const unsigned int &val)
{
UNREFERENCED_PARAMETER(val);
return sizeof(unsigned int);
}
inline void unpack(_Inout_ cursor_in &cursor, _Out_ unsigned int &val)
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ unsigned int &val)
{
cursor_in::ptr_type ptr_end = cursor.ptr + sizeof(unsigned int);
eap::cursor_in::ptr_type ptr_end = cursor.ptr + sizeof(unsigned int);
assert(ptr_end <= cursor.ptr_end);
val = *(unsigned int*)cursor.ptr;
cursor.ptr = ptr_end;
@ -449,25 +443,25 @@ namespace eapserial
#ifdef _WIN64
inline void pack(_Inout_ cursor_out &cursor, _In_ const size_t &val)
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const size_t &val)
{
cursor_out::ptr_type ptr_end = cursor.ptr + sizeof(size_t);
eap::cursor_out::ptr_type ptr_end = cursor.ptr + sizeof(size_t);
assert(ptr_end <= cursor.ptr_end);
*(size_t*)cursor.ptr = val;
cursor.ptr = ptr_end;
}
inline size_t get_pk_size(_In_ const size_t &val)
inline size_t pksizeof(_In_ const size_t &val)
{
UNREFERENCED_PARAMETER(val);
return sizeof(size_t);
}
inline void unpack(_Inout_ cursor_in &cursor, _Out_ size_t &val)
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ size_t &val)
{
cursor_in::ptr_type ptr_end = cursor.ptr + sizeof(size_t);
eap::cursor_in::ptr_type ptr_end = cursor.ptr + sizeof(size_t);
assert(ptr_end <= cursor.ptr_end);
val = *(size_t*)cursor.ptr;
cursor.ptr = ptr_end;
@ -476,12 +470,12 @@ namespace eapserial
template<class _Elem, class _Traits, class _Ax>
inline void pack(_Inout_ cursor_out &cursor, _In_ const std::basic_string<_Elem, _Traits, _Ax> &val)
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const std::basic_string<_Elem, _Traits, _Ax> &val)
{
std::basic_string<_Elem, _Traits, _Ax>::size_type count = val.length();
assert(strlen(val.c_str()) == count); // String should not contain zero terminators.
size_t size = sizeof(_Elem)*(count + 1);
cursor_out::ptr_type ptr_end = cursor.ptr + size;
eap::cursor_out::ptr_type ptr_end = cursor.ptr + size;
assert(ptr_end <= cursor.ptr_end);
memcpy(cursor.ptr, (const _Elem*)val.c_str(), size);
cursor.ptr = ptr_end;
@ -489,14 +483,14 @@ namespace eapserial
template<class _Elem, class _Traits, class _Ax>
inline size_t get_pk_size(const std::basic_string<_Elem, _Traits, _Ax> &val)
inline size_t pksizeof(const std::basic_string<_Elem, _Traits, _Ax> &val)
{
return sizeof(_Elem)*(val.length() + 1);
}
template<class _Elem, class _Traits, class _Ax>
inline void unpack(_Inout_ cursor_in &cursor, _Out_ std::basic_string<_Elem, _Traits, _Ax> &val)
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ std::basic_string<_Elem, _Traits, _Ax> &val)
{
size_t count_max = cursor.ptr_end - cursor.ptr;
std::basic_string<_Elem, _Traits, _Ax>::size_type count = strnlen((const _Elem*&)cursor.ptr, count_max);
@ -507,61 +501,61 @@ namespace eapserial
template<class _Traits, class _Ax>
inline void pack(_Inout_ cursor_out &cursor, _In_ const std::basic_string<wchar_t, _Traits, _Ax> &val)
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const std::basic_string<wchar_t, _Traits, _Ax> &val)
{
std::string val_utf8;
WideCharToMultiByte(CP_UTF8, 0, val.c_str(), (int)val.length(), val_utf8, NULL, NULL);
pack(cursor, val_utf8);
cursor << val_utf8;
}
template<class _Traits, class _Ax>
inline size_t get_pk_size(const std::basic_string<wchar_t, _Traits, _Ax> &val)
inline size_t pksizeof(const std::basic_string<wchar_t, _Traits, _Ax> &val)
{
return sizeof(char)*(WideCharToMultiByte(CP_UTF8, 0, val.c_str(), (int)val.length(), NULL, 0, NULL, NULL) + 1);
}
template<class _Traits, class _Ax>
inline void unpack(_Inout_ cursor_in &cursor, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &val)
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &val)
{
std::string val_utf8;
unpack(cursor, val_utf8);
cursor >> val_utf8;
MultiByteToWideChar(CP_UTF8, 0, val_utf8.c_str(), (int)val_utf8.length(), val);
}
template<class _Ty, class _Ax>
inline void pack(_Inout_ cursor_out &cursor, _In_ const std::vector<_Ty, _Ax> &val)
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const std::vector<_Ty, _Ax> &val)
{
std::vector<_Ty, _Ax>::size_type count = val.size();
pack(cursor, count);
cursor << count;
// Since we do not know wheter vector elements are primitives or objects, iterate instead of memcpy.
// For performance critical vectors of flat opaque data types write specialized template instantiation.
for (std::vector<_Ty, _Ax>::size_type i = 0; i < count; i++)
pack(cursor, val[i]);
cursor << val[i];
}
template<class _Ty, class _Ax>
inline size_t get_pk_size(const std::vector<_Ty, _Ax> &val)
inline size_t pksizeof(const std::vector<_Ty, _Ax> &val)
{
// Since we do not know wheter vector elements are primitives or objects, iterate instead of sizeof().
// For performance critical vectors of flat opaque data types write specialized template instantiation.
std::vector<_Ty, _Ax>::size_type count = val.size();
size_t size = get_pk_size(count);
size_t size = pksizeof(count);
for (std::vector<_Ty, _Ax>::size_type i = 0; i < count; i++)
size += get_pk_size(val[i]);
size += pksizeof(val[i]);
return size;
}
template<class _Ty, class _Ax>
inline void unpack(_Inout_ cursor_in &cursor, _Out_ std::vector<_Ty, _Ax> &val)
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ std::vector<_Ty, _Ax> &val)
{
std::vector<_Ty, _Ax>::size_type count;
unpack(cursor, count);
cursor >> count;
// Since we do not know wheter vector elements are primitives or objects, iterate instead of assign().
// For performance critical vectors of flat opaque data types write specialized template instantiation.
@ -569,115 +563,115 @@ namespace eapserial
val.reserve(count);
for (std::vector<_Ty, _Ax>::size_type i = 0; i < count; i++) {
_Ty el;
unpack(cursor, el);
cursor >> el;
val.push_back(el);
}
}
template<class _Ty, class _Ax>
inline void pack(_Inout_ cursor_out &cursor, _In_ const std::list<_Ty, _Ax> &val)
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const std::list<_Ty, _Ax> &val)
{
std::list<_Ty, _Ax>::size_type count = val.size();
pack(cursor, count);
cursor << count;
// Since we do not know wheter list elements are primitives or objects, iterate instead of memcpy.
// For performance critical vectors of flat opaque data types write specialized template instantiation.
for (std::list<_Ty, _Ax>::const_iterator i = val.cbegin(), i_end = val.cend(); i != i_end; ++i)
pack(cursor, *i);
cursor << *i;
}
template<class _Ty, class _Ax>
inline size_t get_pk_size(const std::list<_Ty, _Ax> &val)
inline size_t pksizeof(const std::list<_Ty, _Ax> &val)
{
// Since we do not know wheter list elements are primitives or objects, iterate instead of sizeof().
// For performance critical vectors of flat opaque data types write specialized template instantiation.
std::list<_Ty, _Ax>::size_type count = val.size();
size_t size = get_pk_size(count);
size_t size = pksizeof(count);
for (std::list<_Ty, _Ax>::const_iterator i = val.cbegin(), i_end = val.cend(); i != i_end; ++i)
size += get_pk_size(*i);
size += pksizeof(*i);
return size;
}
template<class _Ty, class _Ax>
inline void unpack(_Inout_ cursor_in &cursor, _Out_ std::list<_Ty, _Ax> &val)
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ std::list<_Ty, _Ax> &val)
{
std::list<_Ty, _Ax>::size_type count;
unpack(cursor, count);
cursor >> count;
// Since we do not know wheter list elements are primitives or objects, iterate instead of assign().
// For performance critical vectors of flat opaque data types write specialized template instantiation.
val.clear();
for (std::list<_Ty, _Ax>::size_type i = 0; i < count; i++) {
_Ty el;
unpack(cursor, el);
cursor >> el;
val.push_back(el);
}
}
template<class _Ty, class _Dx>
inline void pack(_Inout_ cursor_out &cursor, _In_ const std::unique_ptr<_Ty, _Dx> &val)
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const std::unique_ptr<_Ty, _Dx> &val)
{
if (val) {
pack(cursor, true);
pack(cursor, *val);
cursor << true;
cursor << *val;
} else
pack(cursor, false);
cursor << false;
}
template<class _Ty, class _Dx>
inline size_t get_pk_size(const std::unique_ptr<_Ty, _Dx> &val)
inline size_t pksizeof(const std::unique_ptr<_Ty, _Dx> &val)
{
return
val ?
get_pk_size(true) +
get_pk_size(*val) :
get_pk_size(false);
pksizeof(true) +
pksizeof(*val) :
pksizeof(false);
}
inline void pack(_Inout_ cursor_out &cursor, _In_ const winstd::cert_context &val)
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const winstd::cert_context &val)
{
if (val) {
pack(cursor, (unsigned int)val->dwCertEncodingType);
pack(cursor, (unsigned int)val->cbCertEncoded );
cursor_out::ptr_type ptr_end = cursor.ptr + val->cbCertEncoded;
cursor << (unsigned int)val->dwCertEncodingType;
cursor << (unsigned int)val->cbCertEncoded ;
eap::cursor_out::ptr_type ptr_end = cursor.ptr + val->cbCertEncoded;
assert(ptr_end <= cursor.ptr_end);
memcpy(cursor.ptr, val->pbCertEncoded, val->cbCertEncoded);
cursor.ptr = ptr_end;
} else {
pack(cursor, (unsigned int)0);
pack(cursor, (unsigned int)0);
cursor << (unsigned int)0;
cursor << (unsigned int)0;
}
}
inline size_t get_pk_size(const winstd::cert_context &val)
inline size_t pksizeof(const winstd::cert_context &val)
{
return
val ?
get_pk_size((unsigned int)val->dwCertEncodingType) +
get_pk_size((unsigned int)val->cbCertEncoded ) +
pksizeof((unsigned int)val->dwCertEncodingType) +
pksizeof((unsigned int)val->cbCertEncoded ) +
val->cbCertEncoded :
get_pk_size((unsigned int)0) +
get_pk_size((unsigned int)0);
pksizeof((unsigned int)0) +
pksizeof((unsigned int)0);
}
inline void unpack(_Inout_ cursor_in &cursor, _Out_ winstd::cert_context &val)
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ winstd::cert_context &val)
{
DWORD dwCertEncodingType;
unpack(cursor, (unsigned int&)dwCertEncodingType);
cursor >> (unsigned int&)dwCertEncodingType;
DWORD dwCertEncodedSize;
unpack(cursor, (unsigned int&)dwCertEncodedSize);
cursor >> (unsigned int&)dwCertEncodedSize;
if (dwCertEncodedSize) {
cursor_in::ptr_type ptr_end = cursor.ptr + dwCertEncodedSize;
eap::cursor_in::ptr_type ptr_end = cursor.ptr + dwCertEncodedSize;
assert(ptr_end <= cursor.ptr_end);
val.create(dwCertEncodingType, (BYTE*)cursor.ptr, dwCertEncodedSize);
cursor.ptr = ptr_end;
@ -686,24 +680,23 @@ namespace eapserial
}
inline void pack(_Inout_ cursor_out &cursor, _In_ const eap::type_t &val)
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const eap::type_t &val)
{
pack(cursor, (unsigned char)val);
cursor << (unsigned char)val;
}
inline size_t get_pk_size(_In_ const eap::type_t &val)
inline size_t pksizeof(_In_ const eap::type_t &val)
{
return get_pk_size((unsigned char)val);
return pksizeof((unsigned char)val);
}
inline void unpack(_Inout_ cursor_in &cursor, _Out_ eap::type_t &val)
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::type_t &val)
{
unsigned char t;
unpack(cursor, t);
cursor >> t;
val = (eap::type_t)t;
}
}
#endif

View File

@ -561,13 +561,13 @@ namespace eap
if (!decrypt_md5(cp, pDataIn, dwDataInSize, data, ppEapError))
return false;
eapserial::cursor_in cursor = { data.data(), data.data() + data.size() };
eapserial::unpack(cursor, record);
cursor_in cursor = { data.data(), data.data() + data.size() };
cursor >> record;
#else
UNREFERENCED_PARAMETER(ppEapError);
eapserial::cursor_in cursor = { pDataIn, pDataIn + dwDataInSize };
eapserial::unpack(cursor, record);
cursor_in cursor = { pDataIn, pDataIn + dwDataInSize };
cursor >> record;
#endif
return true;
@ -596,11 +596,11 @@ namespace eap
#if EAP_ENCRYPT_BLOBS
// Allocate BLOB.
std::vector<unsigned char, winstd::sanitizing_allocator<unsigned char> > data;
data.resize(eapserial::get_pk_size(record));
data.resize(pksizeof(record));
// Pack to BLOB.
eapserial::cursor_out cursor = { data.data(), data.data() + data.size() };
eapserial::pack(cursor, record);
cursor_out cursor = { data.data(), data.data() + data.size() };
cursor << record;
data.resize(cursor.ptr - &data.front());
// Prepare cryptographics provider.
@ -629,7 +629,7 @@ namespace eap
// Allocate BLOB.
assert(ppDataOut);
assert(pdwDataOutSize);
*pdwDataOutSize = (DWORD)eapserial::get_pk_size(record);
*pdwDataOutSize = (DWORD)pksizeof(record);
*ppDataOut = alloc_memory(*pdwDataOutSize);
if (!*ppDataOut) {
log_error(*ppEapError = g_peer.make_error(ERROR_OUTOFMEMORY, tstring_printf(_T(__FUNCTION__) _T(" Error allocating memory for BLOB (%uB)."), *pdwDataOutSize).c_str()));
@ -637,8 +637,8 @@ namespace eap
}
// Pack to BLOB.
eapserial::cursor_out cursor = { *ppDataOut, *ppDataOut + *pdwDataOutSize };
eapserial::pack(cursor, record);
cursor_out cursor = { *ppDataOut, *ppDataOut + *pdwDataOutSize };
cursor << record;
*pdwDataOutSize = cursor.ptr - *ppDataOut;
#endif

View File

@ -81,7 +81,7 @@ bool eap::config::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **ppEapErr
}
void eap::config::pack(_Inout_ eapserial::cursor_out &cursor) const
void eap::config::operator<<(_Inout_ cursor_out &cursor) const
{
UNREFERENCED_PARAMETER(cursor);
}
@ -93,7 +93,7 @@ size_t eap::config::get_pk_size() const
}
void eap::config::unpack(_Inout_ eapserial::cursor_in &cursor)
void eap::config::operator>>(_Inout_ cursor_in &cursor)
{
UNREFERENCED_PARAMETER(cursor);
}
@ -120,10 +120,10 @@ eap::config_method::config_method(_In_ const config_method &other) :
eap::config_method::config_method(_Inout_ config_method &&other) :
m_allow_save(move(other.m_allow_save)),
m_anonymous_identity(move(other.m_anonymous_identity)),
m_preshared(move(other.m_preshared)),
config(move(other))
m_allow_save(std::move(other.m_allow_save)),
m_anonymous_identity(std::move(other.m_anonymous_identity)),
m_preshared(std::move(other.m_preshared)),
config(std::move(other))
{
}
@ -144,10 +144,10 @@ eap::config_method& eap::config_method::operator=(_In_ const config_method &othe
eap::config_method& eap::config_method::operator=(_Inout_ config_method &&other)
{
if (this != &other) {
(config&&)*this = move(other);
m_allow_save = move(other.m_allow_save);
m_anonymous_identity = move(other.m_anonymous_identity);
m_preshared = move(other.m_preshared);
(config&&)*this = std::move(other);
m_allow_save = std::move(other.m_allow_save);
m_anonymous_identity = std::move(other.m_anonymous_identity);
m_preshared = std::move(other.m_preshared);
}
return *this;
@ -222,7 +222,7 @@ bool eap::config_method::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **p
unique_ptr<credentials> preshared(make_credentials());
assert(preshared);
if (preshared->load(pXmlElClientSideCredential, ppEapError)) {
m_preshared = move(preshared);
m_preshared = std::move(preshared);
} else {
// This is not really an error - merely an indication pre-shared credentials are unavailable.
if (*ppEapError) {
@ -236,16 +236,16 @@ bool eap::config_method::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **p
}
void eap::config_method::pack(_Inout_ eapserial::cursor_out &cursor) const
void eap::config_method::operator<<(_Inout_ cursor_out &cursor) const
{
config::pack(cursor);
eapserial::pack(cursor, m_allow_save );
eapserial::pack(cursor, m_anonymous_identity);
config::operator<<(cursor);
cursor << m_allow_save ;
cursor << m_anonymous_identity;
if (m_preshared) {
eapserial::pack(cursor, true);
m_preshared->pack(cursor);
cursor << true;
cursor << *m_preshared;
} else
eapserial::pack(cursor, false);
cursor << false;
}
@ -253,27 +253,27 @@ size_t eap::config_method::get_pk_size() const
{
return
config::get_pk_size() +
eapserial::get_pk_size(m_allow_save ) +
eapserial::get_pk_size(m_anonymous_identity) +
pksizeof(m_allow_save ) +
pksizeof(m_anonymous_identity) +
(m_preshared ?
eapserial::get_pk_size(true) +
m_preshared->get_pk_size() :
eapserial::get_pk_size(false));
pksizeof(true ) +
pksizeof(*m_preshared) :
pksizeof(false ));
}
void eap::config_method::unpack(_Inout_ eapserial::cursor_in &cursor)
void eap::config_method::operator>>(_Inout_ cursor_in &cursor)
{
config::unpack(cursor);
eapserial::unpack(cursor, m_allow_save );
eapserial::unpack(cursor, m_anonymous_identity);
config::operator>>(cursor);
cursor >> m_allow_save ;
cursor >> m_anonymous_identity;
bool use_preshared;
eapserial::unpack(cursor, use_preshared);
cursor >> use_preshared;
if (use_preshared) {
m_preshared.reset(make_credentials());
assert(m_preshared);
m_preshared->unpack(cursor);
cursor >> *m_preshared;
} else
m_preshared.reset(nullptr);
}
@ -303,22 +303,22 @@ eap::config_provider::config_provider(_In_ const config_provider &other) :
config(other)
{
for (list<unique_ptr<config_method> >::const_iterator method = other.m_methods.cbegin(), method_end = other.m_methods.cend(); method != method_end; ++method)
m_methods.push_back(move(unique_ptr<config_method>(*method ? (config_method*)method->get()->clone() : nullptr)));
m_methods.push_back(std::move(unique_ptr<config_method>(*method ? (config_method*)method->get()->clone() : nullptr)));
}
eap::config_provider::config_provider(_Inout_ config_provider &&other) :
m_read_only(move(other.m_read_only)),
m_id(move(other.m_id)),
m_name(move(other.m_name)),
m_help_email(move(other.m_help_email)),
m_help_web(move(other.m_help_web)),
m_help_phone(move(other.m_help_phone)),
m_lbl_alt_credential(move(other.m_lbl_alt_credential)),
m_lbl_alt_identity(move(other.m_lbl_alt_identity)),
m_lbl_alt_password(move(other.m_lbl_alt_password)),
m_methods(move(other.m_methods)),
config(move(other))
m_read_only(std::move(other.m_read_only)),
m_id(std::move(other.m_id)),
m_name(std::move(other.m_name)),
m_help_email(std::move(other.m_help_email)),
m_help_web(std::move(other.m_help_web)),
m_help_phone(std::move(other.m_help_phone)),
m_lbl_alt_credential(std::move(other.m_lbl_alt_credential)),
m_lbl_alt_identity(std::move(other.m_lbl_alt_identity)),
m_lbl_alt_password(std::move(other.m_lbl_alt_password)),
m_methods(std::move(other.m_methods)),
config(std::move(other))
{
}
@ -339,7 +339,7 @@ eap::config_provider& eap::config_provider::operator=(_In_ const config_provider
m_methods.clear();
for (list<unique_ptr<config_method> >::const_iterator method = other.m_methods.cbegin(), method_end = other.m_methods.cend(); method != method_end; ++method)
m_methods.push_back(move(unique_ptr<config_method>(*method ? (config_method*)method->get()->clone() : nullptr)));
m_methods.push_back(std::move(unique_ptr<config_method>(*method ? (config_method*)method->get()->clone() : nullptr)));
}
return *this;
@ -349,17 +349,17 @@ eap::config_provider& eap::config_provider::operator=(_In_ const config_provider
eap::config_provider& eap::config_provider::operator=(_Inout_ config_provider &&other)
{
if (this != &other) {
(config&&)*this = move(other);
m_read_only = move(m_read_only);
m_id = move(other.m_id);
m_name = move(other.m_name);
m_help_email = move(other.m_help_email);
m_help_web = move(other.m_help_web);
m_help_phone = move(other.m_help_phone);
m_lbl_alt_credential = move(other.m_lbl_alt_credential);
m_lbl_alt_identity = move(other.m_lbl_alt_identity);
m_lbl_alt_password = move(other.m_lbl_alt_password);
m_methods = move(other.m_methods);
(config&&)*this = std::move(other);
m_read_only = std::move(m_read_only);
m_id = std::move(other.m_id);
m_name = std::move(other.m_name);
m_help_email = std::move(other.m_help_email);
m_help_web = std::move(other.m_help_web);
m_help_phone = std::move(other.m_help_phone);
m_lbl_alt_credential = std::move(other.m_lbl_alt_credential);
m_lbl_alt_identity = std::move(other.m_lbl_alt_identity);
m_lbl_alt_password = std::move(other.m_lbl_alt_password);
m_methods = std::move(other.m_methods);
}
return *this;
@ -583,26 +583,26 @@ bool eap::config_provider::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR *
return false;
// Add configuration to the list.
m_methods.push_back(move(cfg));
m_methods.push_back(std::move(cfg));
}
return true;
}
void eap::config_provider::pack(_Inout_ eapserial::cursor_out &cursor) const
void eap::config_provider::operator<<(_Inout_ cursor_out &cursor) const
{
config::pack(cursor);
eapserial::pack(cursor, m_read_only );
eapserial::pack(cursor, m_id );
eapserial::pack(cursor, m_name );
eapserial::pack(cursor, m_help_email );
eapserial::pack(cursor, m_help_web );
eapserial::pack(cursor, m_help_phone );
eapserial::pack(cursor, m_lbl_alt_credential);
eapserial::pack(cursor, m_lbl_alt_identity );
eapserial::pack(cursor, m_lbl_alt_password );
eapserial::pack(cursor, m_methods );
config::operator<<(cursor);
cursor << m_read_only ;
cursor << m_id ;
cursor << m_name ;
cursor << m_help_email ;
cursor << m_help_web ;
cursor << m_help_phone ;
cursor << m_lbl_alt_credential;
cursor << m_lbl_alt_identity ;
cursor << m_lbl_alt_password ;
cursor << m_methods ;
}
@ -610,42 +610,42 @@ size_t eap::config_provider::get_pk_size() const
{
return
config::get_pk_size() +
eapserial::get_pk_size(m_read_only ) +
eapserial::get_pk_size(m_id ) +
eapserial::get_pk_size(m_name ) +
eapserial::get_pk_size(m_help_email ) +
eapserial::get_pk_size(m_help_web ) +
eapserial::get_pk_size(m_help_phone ) +
eapserial::get_pk_size(m_lbl_alt_credential) +
eapserial::get_pk_size(m_lbl_alt_identity ) +
eapserial::get_pk_size(m_lbl_alt_password ) +
eapserial::get_pk_size(m_methods );
pksizeof(m_read_only ) +
pksizeof(m_id ) +
pksizeof(m_name ) +
pksizeof(m_help_email ) +
pksizeof(m_help_web ) +
pksizeof(m_help_phone ) +
pksizeof(m_lbl_alt_credential) +
pksizeof(m_lbl_alt_identity ) +
pksizeof(m_lbl_alt_password ) +
pksizeof(m_methods );
}
void eap::config_provider::unpack(_Inout_ eapserial::cursor_in &cursor)
void eap::config_provider::operator>>(_Inout_ cursor_in &cursor)
{
config::unpack(cursor);
eapserial::unpack(cursor, m_read_only );
eapserial::unpack(cursor, m_id );
eapserial::unpack(cursor, m_name );
eapserial::unpack(cursor, m_help_email );
eapserial::unpack(cursor, m_help_web );
eapserial::unpack(cursor, m_help_phone );
eapserial::unpack(cursor, m_lbl_alt_credential);
eapserial::unpack(cursor, m_lbl_alt_identity );
eapserial::unpack(cursor, m_lbl_alt_password );
config::operator>>(cursor);
cursor >> m_read_only ;
cursor >> m_id ;
cursor >> m_name ;
cursor >> m_help_email ;
cursor >> m_help_web ;
cursor >> m_help_phone ;
cursor >> m_lbl_alt_credential;
cursor >> m_lbl_alt_identity ;
cursor >> m_lbl_alt_password ;
list<config_method>::size_type count;
bool is_nonnull;
eapserial::unpack(cursor, count);
cursor >> count;
m_methods.clear();
for (list<config_method>::size_type i = 0; i < count; i++) {
eapserial::unpack(cursor, is_nonnull);
cursor >> is_nonnull;
if (is_nonnull) {
unique_ptr<config_method> el(m_module.make_config_method());
el->unpack(cursor);
m_methods.push_back(move(el));
cursor >> *el;
m_methods.push_back(std::move(el));
} else
m_methods.push_back(nullptr);
}
@ -669,8 +669,8 @@ eap::config_providers::config_providers(_In_ const config_providers &other) :
eap::config_providers::config_providers(_Inout_ config_providers &&other) :
m_providers(move(other.m_providers)),
config(move(other))
m_providers(std::move(other.m_providers)),
config(std::move(other))
{
}
@ -689,8 +689,8 @@ eap::config_providers& eap::config_providers::operator=(_In_ const config_provid
eap::config_providers& eap::config_providers::operator=(_Inout_ config_providers &&other)
{
if (this != &other) {
(config&&)*this = move(other);
m_providers = move(other.m_providers);
(config&&)*this = std::move(other);
m_providers = std::move(other.m_providers);
}
return *this;
@ -769,17 +769,17 @@ bool eap::config_providers::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR
return false;
// Add provider to the list.
m_providers.push_back(move(prov));
m_providers.push_back(std::move(prov));
}
return true;
}
void eap::config_providers::pack(_Inout_ eapserial::cursor_out &cursor) const
void eap::config_providers::operator<<(_Inout_ cursor_out &cursor) const
{
config::pack(cursor);
eapserial::pack(cursor, m_providers);
config::operator<<(cursor);
cursor << m_providers;
}
@ -787,20 +787,20 @@ size_t eap::config_providers::get_pk_size() const
{
return
config::get_pk_size() +
eapserial::get_pk_size(m_providers);
pksizeof(m_providers);
}
void eap::config_providers::unpack(_Inout_ eapserial::cursor_in &cursor)
void eap::config_providers::operator>>(_Inout_ cursor_in &cursor)
{
config::unpack(cursor);
config::operator>>(cursor);
list<config_provider>::size_type count;
eapserial::unpack(cursor, count);
cursor >> count;
m_providers.clear();
for (list<config_provider>::size_type i = 0; i < count; i++) {
config_provider el(m_module);
el.unpack(cursor);
m_providers.push_back(move(el));
cursor >> el;
m_providers.push_back(std::move(el));
}
}

View File

@ -233,28 +233,28 @@ bool eap::credentials_pass::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR
}
void eap::credentials_pass::pack(_Inout_ eapserial::cursor_out &cursor) const
void eap::credentials_pass::operator<<(_Inout_ cursor_out &cursor) const
{
eap::credentials::pack(cursor);
eapserial::pack(cursor, m_identity);
eapserial::pack(cursor, m_password);
credentials::operator<<(cursor);
cursor << m_identity;
cursor << m_password;
}
size_t eap::credentials_pass::get_pk_size() const
{
return
eap::credentials::get_pk_size() +
eapserial::get_pk_size(m_identity) +
eapserial::get_pk_size(m_password);
credentials::get_pk_size() +
pksizeof(m_identity) +
pksizeof(m_password);
}
void eap::credentials_pass::unpack(_Inout_ eapserial::cursor_in &cursor)
void eap::credentials_pass::operator>>(_Inout_ cursor_in &cursor)
{
eap::credentials::unpack(cursor);
eapserial::unpack(cursor, m_identity);
eapserial::unpack(cursor, m_password);
credentials::operator>>(cursor);
cursor >> m_identity;
cursor >> m_password;
}

View File

@ -141,7 +141,7 @@ namespace eap
///
/// \param[inout] cursor Memory cursor
///
virtual void pack(_Inout_ eapserial::cursor_out &cursor) const;
virtual void operator<<(_Inout_ cursor_out &cursor) const;
///
/// Returns packed size of a configuration
@ -155,7 +155,7 @@ namespace eap
///
/// \param[inout] cursor Memory cursor
///
virtual void unpack(_Inout_ eapserial::cursor_in &cursor);
virtual void operator>>(_Inout_ cursor_in &cursor);
/// @}

View File

@ -137,7 +137,7 @@ namespace eap
///
/// \param[inout] cursor Memory cursor
///
virtual void pack(_Inout_ eapserial::cursor_out &cursor) const;
virtual void operator<<(_Inout_ cursor_out &cursor) const;
///
/// Returns packed size of a configuration
@ -151,7 +151,7 @@ namespace eap
///
/// \param[inout] cursor Memory cursor
///
virtual void unpack(_Inout_ eapserial::cursor_in &cursor);
virtual void operator>>(_Inout_ cursor_in &cursor);
/// @}

View File

@ -87,7 +87,7 @@ eap::config_method_tls::config_method_tls(_Inout_ config_method_tls &&other) :
}
eap::config_method_tls& eap::config_method_tls::operator=(_In_ const eap::config_method_tls &other)
eap::config_method_tls& eap::config_method_tls::operator=(_In_ const config_method_tls &other)
{
if (this != &other) {
(config_method&)*this = other;
@ -99,7 +99,7 @@ eap::config_method_tls& eap::config_method_tls::operator=(_In_ const eap::config
}
eap::config_method_tls& eap::config_method_tls::operator=(_Inout_ eap::config_method_tls &&other)
eap::config_method_tls& eap::config_method_tls::operator=(_Inout_ config_method_tls &&other)
{
if (this != &other) {
(config_method&&)*this = std::move(other);
@ -226,7 +226,7 @@ bool eap::config_method_tls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR
// Log loaded CA certificates.
list<tstring> cert_names;
for (std::list<winstd::cert_context>::const_iterator cert = m_trusted_root_ca.cbegin(), cert_end = m_trusted_root_ca.cend(); cert != cert_end; ++cert)
cert_names.push_back(std::move(eap::get_cert_title(*cert)));
cert_names.push_back(std::move(get_cert_title(*cert)));
m_module.log_config((xpathServerSideCredential + L"/CA").c_str(), cert_names);
}
@ -256,28 +256,28 @@ bool eap::config_method_tls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR
}
void eap::config_method_tls::pack(_Inout_ eapserial::cursor_out &cursor) const
void eap::config_method_tls::operator<<(_Inout_ cursor_out &cursor) const
{
eap::config_method::pack(cursor);
eapserial::pack(cursor, m_trusted_root_ca);
eapserial::pack(cursor, m_server_names );
config_method::operator<<(cursor);
cursor << m_trusted_root_ca;
cursor << m_server_names ;
}
size_t eap::config_method_tls::get_pk_size() const
{
return
eap::config_method::get_pk_size() +
eapserial::get_pk_size(m_trusted_root_ca) +
eapserial::get_pk_size(m_server_names );
config_method::get_pk_size() +
pksizeof(m_trusted_root_ca) +
pksizeof(m_server_names );
}
void eap::config_method_tls::unpack(_Inout_ eapserial::cursor_in &cursor)
void eap::config_method_tls::operator>>(_Inout_ cursor_in &cursor)
{
eap::config_method::unpack(cursor);
eapserial::unpack(cursor, m_trusted_root_ca);
eapserial::unpack(cursor, m_server_names );
config_method::operator>>(cursor);
cursor >> m_trusted_root_ca;
cursor >> m_server_names ;
}
@ -289,7 +289,7 @@ eap::credentials* eap::config_method_tls::make_credentials() const
eap::type_t eap::config_method_tls::get_method_id() const
{
return eap::type_tls;
return type_tls;
}

View File

@ -167,25 +167,25 @@ bool eap::credentials_tls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR *
}
void eap::credentials_tls::pack(_Inout_ eapserial::cursor_out &cursor) const
void eap::credentials_tls::operator<<(_Inout_ cursor_out &cursor) const
{
eap::credentials::pack(cursor);
eapserial::pack(cursor, m_cert);
credentials::operator<<(cursor);
cursor << m_cert;
}
size_t eap::credentials_tls::get_pk_size() const
{
return
eap::credentials::get_pk_size() +
eapserial::get_pk_size(m_cert);
credentials::get_pk_size() +
pksizeof(m_cert);
}
void eap::credentials_tls::unpack(_Inout_ eapserial::cursor_in &cursor)
void eap::credentials_tls::operator>>(_Inout_ cursor_in &cursor)
{
eap::credentials::unpack(cursor);
eapserial::unpack(cursor, m_cert);
credentials::operator>>(cursor);
cursor >> m_cert;
}
@ -279,7 +279,7 @@ std::wstring eap::credentials_tls::get_identity() const
tstring eap::credentials_tls::get_name() const
{
return m_cert ? std::move(eap::get_cert_title(m_cert)) : L"<blank>";
return m_cert ? std::move(get_cert_title(m_cert)) : L"<blank>";
}

View File

@ -127,7 +127,7 @@ namespace eap {
///
/// \param[inout] cursor Memory cursor
///
virtual void pack(_Inout_ eapserial::cursor_out &cursor) const;
virtual void operator<<(_Inout_ cursor_out &cursor) const;
///
/// Returns packed size of a configuration
@ -141,7 +141,7 @@ namespace eap {
///
/// \param[inout] cursor Memory cursor
///
virtual void unpack(_Inout_ eapserial::cursor_in &cursor);
virtual void operator>>(_Inout_ cursor_in &cursor);
///
/// Returns EAP method type of this configuration

View File

@ -133,7 +133,7 @@ namespace eap
///
/// \param[inout] cursor Memory cursor
///
virtual void pack(_Inout_ eapserial::cursor_out &cursor) const;
virtual void operator<<(_Inout_ cursor_out &cursor) const;
///
/// Returns packed size of a configuration
@ -147,7 +147,7 @@ namespace eap
///
/// \param[inout] cursor Memory cursor
///
virtual void unpack(_Inout_ eapserial::cursor_in &cursor);
virtual void operator>>(_Inout_ cursor_in &cursor);
/// \name Storage
/// @{

View File

@ -146,7 +146,7 @@ bool eap::config_method_ttls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERRO
{
// PAP
m_module.log_config((xpath + L"/NonEAPAuthMethod").c_str(), L"PAP");
m_inner.reset(new eap::config_method_pap(m_module));
m_inner.reset(new config_method_pap(m_module));
if (!m_inner->load(pXmlElInnerAuthenticationMethod, ppEapError))
return false;
} else {
@ -158,19 +158,19 @@ bool eap::config_method_ttls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERRO
}
void eap::config_method_ttls::pack(_Inout_ eapserial::cursor_out &cursor) const
void eap::config_method_ttls::operator<<(_Inout_ cursor_out &cursor) const
{
eap::config_method_tls::pack(cursor);
config_method_tls::operator<<(cursor);
if (m_inner) {
if (dynamic_cast<eap::config_method_pap*>(m_inner.get())) {
eapserial::pack(cursor, eap::type_pap);
m_inner->pack(cursor);
if (dynamic_cast<config_method_pap*>(m_inner.get())) {
cursor << type_pap;
cursor << *m_inner;
} else {
assert(0); // Unsupported inner authentication method type.
eapserial::pack(cursor, eap::type_undefined);
cursor << type_undefined;
}
} else
eapserial::pack(cursor, eap::type_undefined);
cursor << type_undefined;
}
@ -178,33 +178,33 @@ size_t eap::config_method_ttls::get_pk_size() const
{
size_t size_inner;
if (m_inner) {
if (dynamic_cast<eap::config_method_pap*>(m_inner.get())) {
if (dynamic_cast<config_method_pap*>(m_inner.get())) {
size_inner =
eapserial::get_pk_size(eap::type_pap) +
m_inner->get_pk_size();
pksizeof(type_pap) +
pksizeof(*m_inner);
} else {
assert(0); // Unsupported inner authentication method type.
size_inner = eapserial::get_pk_size(eap::type_undefined);
size_inner = pksizeof(type_undefined);
}
} else
size_inner = eapserial::get_pk_size(eap::type_undefined);
size_inner = pksizeof(type_undefined);
return
eap::config_method_tls::get_pk_size() +
config_method_tls::get_pk_size() +
size_inner;
}
void eap::config_method_ttls::unpack(_Inout_ eapserial::cursor_in &cursor)
void eap::config_method_ttls::operator>>(_Inout_ cursor_in &cursor)
{
eap::config_method_tls::unpack(cursor);
config_method_tls::operator>>(cursor);
eap::type_t eap_type;
eapserial::unpack(cursor, eap_type);
type_t eap_type;
cursor >> eap_type;
switch (eap_type) {
case eap::type_pap:
m_inner.reset(new eap::config_method_pap(m_module));
m_inner->unpack(cursor);
case type_pap:
m_inner.reset(new config_method_pap(m_module));
cursor >> *m_inner;
break;
default:
assert(0); // Unsupported inner authentication method type.
@ -215,5 +215,5 @@ void eap::config_method_ttls::unpack(_Inout_ eapserial::cursor_in &cursor)
eap::type_t eap::config_method_ttls::get_method_id() const
{
return eap::type_ttls;
return type_ttls;
}

View File

@ -149,19 +149,19 @@ bool eap::credentials_ttls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR
}
void eap::credentials_ttls::pack(_Inout_ eapserial::cursor_out &cursor) const
void eap::credentials_ttls::operator<<(_Inout_ cursor_out &cursor) const
{
eap::credentials_tls::pack(cursor);
credentials_tls::operator<<(cursor);
if (m_inner) {
if (dynamic_cast<eap::credentials_pap*>(m_inner.get())) {
eapserial::pack(cursor, eap::type_pap);
m_inner->pack(cursor);
if (dynamic_cast<credentials_pap*>(m_inner.get())) {
cursor << type_pap;
cursor << *m_inner;
} else {
assert(0); // Unsupported inner authentication method type.
eapserial::pack(cursor, eap::type_undefined);
cursor << type_undefined;
}
} else
eapserial::pack(cursor, eap::type_undefined);
cursor << type_undefined;
}
@ -169,33 +169,33 @@ size_t eap::credentials_ttls::get_pk_size() const
{
size_t size_inner;
if (m_inner) {
if (dynamic_cast<eap::credentials_pap*>(m_inner.get())) {
if (dynamic_cast<credentials_pap*>(m_inner.get())) {
size_inner =
eapserial::get_pk_size(eap::type_pap) +
m_inner->get_pk_size();
pksizeof(type_pap) +
pksizeof(*m_inner);
} else {
assert(0); // Unsupported inner authentication method type.
size_inner = eapserial::get_pk_size(eap::type_undefined);
size_inner = pksizeof(type_undefined);
}
} else
size_inner = eapserial::get_pk_size(eap::type_undefined);
size_inner = pksizeof(type_undefined);
return
eap::credentials_tls::get_pk_size() +
credentials_tls::get_pk_size() +
size_inner;
}
void eap::credentials_ttls::unpack(_Inout_ eapserial::cursor_in &cursor)
void eap::credentials_ttls::operator>>(_Inout_ cursor_in &cursor)
{
eap::credentials_tls::unpack(cursor);
credentials_tls::operator>>(cursor);
eap::type_t eap_type;
eapserial::unpack(cursor, eap_type);
type_t eap_type;
cursor >> eap_type;
switch (eap_type) {
case eap::type_pap:
m_inner.reset(new eap::credentials_pap(m_module));
m_inner->unpack(cursor);
case type_pap:
m_inner.reset(new credentials_pap(m_module));
cursor >> *m_inner;
break;
default:
assert(0); // Unsupported inner authentication method type.