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,33 +45,30 @@ namespace eap
class config_providers; class config_providers;
} }
namespace eapserial ///
{ /// Packs a configuration
/// ///
/// Packs a configuration /// \param[inout] cursor Memory cursor
/// /// \param[in] val Configuration to pack
/// \param[inout] cursor Memory cursor ///
/// \param[in] val Configuration to pack 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);
/// ///
/// Returns packed size of a configuration /// Returns packed size of a configuration
/// ///
/// \param[in] val Configuration to pack /// \param[in] val Configuration to pack
/// ///
/// \returns Size of data when packed (in bytes) /// \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 /// Unpacks a configuration
/// ///
/// \param[inout] cursor Memory cursor /// \param[inout] cursor Memory cursor
/// \param[out] val Configuration to unpack to /// \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 #pragma once
@ -181,7 +178,7 @@ namespace eap
/// ///
/// \param[inout] cursor Memory cursor /// \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 /// Returns packed size of a configuration
@ -195,7 +192,7 @@ namespace eap
/// ///
/// \param[inout] cursor Memory cursor /// \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 /// \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 /// Returns packed size of a configuration
@ -302,7 +299,7 @@ namespace eap
/// ///
/// \param[inout] cursor Memory cursor /// \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 /// \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 /// Returns packed size of a configuration
@ -426,7 +423,7 @@ namespace eap
/// ///
/// \param[inout] cursor Memory cursor /// \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 /// \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 /// Returns packed size of a configuration
@ -545,7 +542,7 @@ namespace eap
/// ///
/// \param[inout] cursor Memory cursor /// \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.operator<<(cursor);
{ }
val.pack(cursor);
}
inline size_t pksizeof(const eap::config &val)
{
inline size_t get_pk_size(const eap::config &val) return val.get_pk_size();
{ }
return val.get_pk_size();
}
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::config &val)
{
inline void unpack(_Inout_ cursor_in &cursor, _Out_ eap::config &val) val.operator>>(cursor);
{
val.unpack(cursor);
}
} }

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -561,13 +561,13 @@ namespace eap
if (!decrypt_md5(cp, pDataIn, dwDataInSize, data, ppEapError)) if (!decrypt_md5(cp, pDataIn, dwDataInSize, data, ppEapError))
return false; return false;
eapserial::cursor_in cursor = { data.data(), data.data() + data.size() }; cursor_in cursor = { data.data(), data.data() + data.size() };
eapserial::unpack(cursor, record); cursor >> record;
#else #else
UNREFERENCED_PARAMETER(ppEapError); UNREFERENCED_PARAMETER(ppEapError);
eapserial::cursor_in cursor = { pDataIn, pDataIn + dwDataInSize }; cursor_in cursor = { pDataIn, pDataIn + dwDataInSize };
eapserial::unpack(cursor, record); cursor >> record;
#endif #endif
return true; return true;
@ -596,11 +596,11 @@ namespace eap
#if EAP_ENCRYPT_BLOBS #if EAP_ENCRYPT_BLOBS
// Allocate BLOB. // Allocate BLOB.
std::vector<unsigned char, winstd::sanitizing_allocator<unsigned char> > data; std::vector<unsigned char, winstd::sanitizing_allocator<unsigned char> > data;
data.resize(eapserial::get_pk_size(record)); data.resize(pksizeof(record));
// Pack to BLOB. // Pack to BLOB.
eapserial::cursor_out cursor = { data.data(), data.data() + data.size() }; cursor_out cursor = { data.data(), data.data() + data.size() };
eapserial::pack(cursor, record); cursor << record;
data.resize(cursor.ptr - &data.front()); data.resize(cursor.ptr - &data.front());
// Prepare cryptographics provider. // Prepare cryptographics provider.
@ -629,7 +629,7 @@ namespace eap
// Allocate BLOB. // Allocate BLOB.
assert(ppDataOut); assert(ppDataOut);
assert(pdwDataOutSize); assert(pdwDataOutSize);
*pdwDataOutSize = (DWORD)eapserial::get_pk_size(record); *pdwDataOutSize = (DWORD)pksizeof(record);
*ppDataOut = alloc_memory(*pdwDataOutSize); *ppDataOut = alloc_memory(*pdwDataOutSize);
if (!*ppDataOut) { 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())); 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. // Pack to BLOB.
eapserial::cursor_out cursor = { *ppDataOut, *ppDataOut + *pdwDataOutSize }; cursor_out cursor = { *ppDataOut, *ppDataOut + *pdwDataOutSize };
eapserial::pack(cursor, record); cursor << record;
*pdwDataOutSize = cursor.ptr - *ppDataOut; *pdwDataOutSize = cursor.ptr - *ppDataOut;
#endif #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); 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); 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) : eap::config_method::config_method(_Inout_ config_method &&other) :
m_allow_save(move(other.m_allow_save)), m_allow_save(std::move(other.m_allow_save)),
m_anonymous_identity(move(other.m_anonymous_identity)), m_anonymous_identity(std::move(other.m_anonymous_identity)),
m_preshared(move(other.m_preshared)), m_preshared(std::move(other.m_preshared)),
config(move(other)) 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) eap::config_method& eap::config_method::operator=(_Inout_ config_method &&other)
{ {
if (this != &other) { if (this != &other) {
(config&&)*this = move(other); (config&&)*this = std::move(other);
m_allow_save = move(other.m_allow_save); m_allow_save = std::move(other.m_allow_save);
m_anonymous_identity = move(other.m_anonymous_identity); m_anonymous_identity = std::move(other.m_anonymous_identity);
m_preshared = move(other.m_preshared); m_preshared = std::move(other.m_preshared);
} }
return *this; return *this;
@ -222,7 +222,7 @@ bool eap::config_method::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR **p
unique_ptr<credentials> preshared(make_credentials()); unique_ptr<credentials> preshared(make_credentials());
assert(preshared); assert(preshared);
if (preshared->load(pXmlElClientSideCredential, ppEapError)) { if (preshared->load(pXmlElClientSideCredential, ppEapError)) {
m_preshared = move(preshared); m_preshared = std::move(preshared);
} else { } else {
// This is not really an error - merely an indication pre-shared credentials are unavailable. // This is not really an error - merely an indication pre-shared credentials are unavailable.
if (*ppEapError) { if (*ppEapError) {
@ -236,44 +236,44 @@ 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); config::operator<<(cursor);
eapserial::pack(cursor, m_allow_save ); cursor << m_allow_save ;
eapserial::pack(cursor, m_anonymous_identity); cursor << m_anonymous_identity;
if (m_preshared) { if (m_preshared) {
eapserial::pack(cursor, true); cursor << true;
m_preshared->pack(cursor); cursor << *m_preshared;
} else } else
eapserial::pack(cursor, false); cursor << false;
} }
size_t eap::config_method::get_pk_size() const size_t eap::config_method::get_pk_size() const
{ {
return return
config::get_pk_size() + config::get_pk_size() +
eapserial::get_pk_size(m_allow_save ) + pksizeof(m_allow_save ) +
eapserial::get_pk_size(m_anonymous_identity) + pksizeof(m_anonymous_identity) +
(m_preshared ? (m_preshared ?
eapserial::get_pk_size(true) + pksizeof(true ) +
m_preshared->get_pk_size() : pksizeof(*m_preshared) :
eapserial::get_pk_size(false)); pksizeof(false ));
} }
void eap::config_method::unpack(_Inout_ eapserial::cursor_in &cursor) void eap::config_method::operator>>(_Inout_ cursor_in &cursor)
{ {
config::unpack(cursor); config::operator>>(cursor);
eapserial::unpack(cursor, m_allow_save ); cursor >> m_allow_save ;
eapserial::unpack(cursor, m_anonymous_identity); cursor >> m_anonymous_identity;
bool use_preshared; bool use_preshared;
eapserial::unpack(cursor, use_preshared); cursor >> use_preshared;
if (use_preshared) { if (use_preshared) {
m_preshared.reset(make_credentials()); m_preshared.reset(make_credentials());
assert(m_preshared); assert(m_preshared);
m_preshared->unpack(cursor); cursor >> *m_preshared;
} else } else
m_preshared.reset(nullptr); m_preshared.reset(nullptr);
} }
@ -303,22 +303,22 @@ eap::config_provider::config_provider(_In_ const config_provider &other) :
config(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) 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) : eap::config_provider::config_provider(_Inout_ config_provider &&other) :
m_read_only(move(other.m_read_only)), m_read_only(std::move(other.m_read_only)),
m_id(move(other.m_id)), m_id(std::move(other.m_id)),
m_name(move(other.m_name)), m_name(std::move(other.m_name)),
m_help_email(move(other.m_help_email)), m_help_email(std::move(other.m_help_email)),
m_help_web(move(other.m_help_web)), m_help_web(std::move(other.m_help_web)),
m_help_phone(move(other.m_help_phone)), m_help_phone(std::move(other.m_help_phone)),
m_lbl_alt_credential(move(other.m_lbl_alt_credential)), m_lbl_alt_credential(std::move(other.m_lbl_alt_credential)),
m_lbl_alt_identity(move(other.m_lbl_alt_identity)), m_lbl_alt_identity(std::move(other.m_lbl_alt_identity)),
m_lbl_alt_password(move(other.m_lbl_alt_password)), m_lbl_alt_password(std::move(other.m_lbl_alt_password)),
m_methods(move(other.m_methods)), m_methods(std::move(other.m_methods)),
config(move(other)) config(std::move(other))
{ {
} }
@ -339,7 +339,7 @@ eap::config_provider& eap::config_provider::operator=(_In_ const config_provider
m_methods.clear(); 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) 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; 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) eap::config_provider& eap::config_provider::operator=(_Inout_ config_provider &&other)
{ {
if (this != &other) { if (this != &other) {
(config&&)*this = move(other); (config&&)*this = std::move(other);
m_read_only = move(m_read_only); m_read_only = std::move(m_read_only);
m_id = move(other.m_id); m_id = std::move(other.m_id);
m_name = move(other.m_name); m_name = std::move(other.m_name);
m_help_email = move(other.m_help_email); m_help_email = std::move(other.m_help_email);
m_help_web = move(other.m_help_web); m_help_web = std::move(other.m_help_web);
m_help_phone = move(other.m_help_phone); m_help_phone = std::move(other.m_help_phone);
m_lbl_alt_credential = move(other.m_lbl_alt_credential); m_lbl_alt_credential = std::move(other.m_lbl_alt_credential);
m_lbl_alt_identity = move(other.m_lbl_alt_identity); m_lbl_alt_identity = std::move(other.m_lbl_alt_identity);
m_lbl_alt_password = move(other.m_lbl_alt_password); m_lbl_alt_password = std::move(other.m_lbl_alt_password);
m_methods = move(other.m_methods); m_methods = std::move(other.m_methods);
} }
return *this; return *this;
@ -583,69 +583,69 @@ bool eap::config_provider::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR *
return false; return false;
// Add configuration to the list. // Add configuration to the list.
m_methods.push_back(move(cfg)); m_methods.push_back(std::move(cfg));
} }
return true; 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); config::operator<<(cursor);
eapserial::pack(cursor, m_read_only ); cursor << m_read_only ;
eapserial::pack(cursor, m_id ); cursor << m_id ;
eapserial::pack(cursor, m_name ); cursor << m_name ;
eapserial::pack(cursor, m_help_email ); cursor << m_help_email ;
eapserial::pack(cursor, m_help_web ); cursor << m_help_web ;
eapserial::pack(cursor, m_help_phone ); cursor << m_help_phone ;
eapserial::pack(cursor, m_lbl_alt_credential); cursor << m_lbl_alt_credential;
eapserial::pack(cursor, m_lbl_alt_identity ); cursor << m_lbl_alt_identity ;
eapserial::pack(cursor, m_lbl_alt_password ); cursor << m_lbl_alt_password ;
eapserial::pack(cursor, m_methods ); cursor << m_methods ;
} }
size_t eap::config_provider::get_pk_size() const size_t eap::config_provider::get_pk_size() const
{ {
return return
config::get_pk_size() + config::get_pk_size() +
eapserial::get_pk_size(m_read_only ) + pksizeof(m_read_only ) +
eapserial::get_pk_size(m_id ) + pksizeof(m_id ) +
eapserial::get_pk_size(m_name ) + pksizeof(m_name ) +
eapserial::get_pk_size(m_help_email ) + pksizeof(m_help_email ) +
eapserial::get_pk_size(m_help_web ) + pksizeof(m_help_web ) +
eapserial::get_pk_size(m_help_phone ) + pksizeof(m_help_phone ) +
eapserial::get_pk_size(m_lbl_alt_credential) + pksizeof(m_lbl_alt_credential) +
eapserial::get_pk_size(m_lbl_alt_identity ) + pksizeof(m_lbl_alt_identity ) +
eapserial::get_pk_size(m_lbl_alt_password ) + pksizeof(m_lbl_alt_password ) +
eapserial::get_pk_size(m_methods ); 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); config::operator>>(cursor);
eapserial::unpack(cursor, m_read_only ); cursor >> m_read_only ;
eapserial::unpack(cursor, m_id ); cursor >> m_id ;
eapserial::unpack(cursor, m_name ); cursor >> m_name ;
eapserial::unpack(cursor, m_help_email ); cursor >> m_help_email ;
eapserial::unpack(cursor, m_help_web ); cursor >> m_help_web ;
eapserial::unpack(cursor, m_help_phone ); cursor >> m_help_phone ;
eapserial::unpack(cursor, m_lbl_alt_credential); cursor >> m_lbl_alt_credential;
eapserial::unpack(cursor, m_lbl_alt_identity ); cursor >> m_lbl_alt_identity ;
eapserial::unpack(cursor, m_lbl_alt_password ); cursor >> m_lbl_alt_password ;
list<config_method>::size_type count; list<config_method>::size_type count;
bool is_nonnull; bool is_nonnull;
eapserial::unpack(cursor, count); cursor >> count;
m_methods.clear(); m_methods.clear();
for (list<config_method>::size_type i = 0; i < count; i++) { for (list<config_method>::size_type i = 0; i < count; i++) {
eapserial::unpack(cursor, is_nonnull); cursor >> is_nonnull;
if (is_nonnull) { if (is_nonnull) {
unique_ptr<config_method> el(m_module.make_config_method()); unique_ptr<config_method> el(m_module.make_config_method());
el->unpack(cursor); cursor >> *el;
m_methods.push_back(move(el)); m_methods.push_back(std::move(el));
} else } else
m_methods.push_back(nullptr); 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) : eap::config_providers::config_providers(_Inout_ config_providers &&other) :
m_providers(move(other.m_providers)), m_providers(std::move(other.m_providers)),
config(move(other)) 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) eap::config_providers& eap::config_providers::operator=(_Inout_ config_providers &&other)
{ {
if (this != &other) { if (this != &other) {
(config&&)*this = move(other); (config&&)*this = std::move(other);
m_providers = move(other.m_providers); m_providers = std::move(other.m_providers);
} }
return *this; return *this;
@ -769,17 +769,17 @@ bool eap::config_providers::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERROR
return false; return false;
// Add provider to the list. // Add provider to the list.
m_providers.push_back(move(prov)); m_providers.push_back(std::move(prov));
} }
return true; 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); config::operator<<(cursor);
eapserial::pack(cursor, m_providers); cursor << m_providers;
} }
@ -787,20 +787,20 @@ size_t eap::config_providers::get_pk_size() const
{ {
return return
config::get_pk_size() + 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; list<config_provider>::size_type count;
eapserial::unpack(cursor, count); cursor >> count;
m_providers.clear(); m_providers.clear();
for (list<config_provider>::size_type i = 0; i < count; i++) { for (list<config_provider>::size_type i = 0; i < count; i++) {
config_provider el(m_module); config_provider el(m_module);
el.unpack(cursor); cursor >> el;
m_providers.push_back(move(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); credentials::operator<<(cursor);
eapserial::pack(cursor, m_identity); cursor << m_identity;
eapserial::pack(cursor, m_password); cursor << m_password;
} }
size_t eap::credentials_pass::get_pk_size() const size_t eap::credentials_pass::get_pk_size() const
{ {
return return
eap::credentials::get_pk_size() + credentials::get_pk_size() +
eapserial::get_pk_size(m_identity) + pksizeof(m_identity) +
eapserial::get_pk_size(m_password); 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); credentials::operator>>(cursor);
eapserial::unpack(cursor, m_identity); cursor >> m_identity;
eapserial::unpack(cursor, m_password); cursor >> m_password;
} }

View File

@ -141,7 +141,7 @@ namespace eap
/// ///
/// \param[inout] cursor Memory cursor /// \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 /// Returns packed size of a configuration
@ -155,7 +155,7 @@ namespace eap
/// ///
/// \param[inout] cursor Memory cursor /// \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 /// \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 /// Returns packed size of a configuration
@ -151,7 +151,7 @@ namespace eap
/// ///
/// \param[inout] cursor Memory cursor /// \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) { if (this != &other) {
(config_method&)*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) { if (this != &other) {
(config_method&&)*this = std::move(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. // Log loaded CA certificates.
list<tstring> cert_names; 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) 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); 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); config_method::operator<<(cursor);
eapserial::pack(cursor, m_trusted_root_ca); cursor << m_trusted_root_ca;
eapserial::pack(cursor, m_server_names ); cursor << m_server_names ;
} }
size_t eap::config_method_tls::get_pk_size() const size_t eap::config_method_tls::get_pk_size() const
{ {
return return
eap::config_method::get_pk_size() + config_method::get_pk_size() +
eapserial::get_pk_size(m_trusted_root_ca) + pksizeof(m_trusted_root_ca) +
eapserial::get_pk_size(m_server_names ); 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); config_method::operator>>(cursor);
eapserial::unpack(cursor, m_trusted_root_ca); cursor >> m_trusted_root_ca;
eapserial::unpack(cursor, m_server_names ); 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 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); credentials::operator<<(cursor);
eapserial::pack(cursor, m_cert); cursor << m_cert;
} }
size_t eap::credentials_tls::get_pk_size() const size_t eap::credentials_tls::get_pk_size() const
{ {
return return
eap::credentials::get_pk_size() + credentials::get_pk_size() +
eapserial::get_pk_size(m_cert); 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); credentials::operator>>(cursor);
eapserial::unpack(cursor, m_cert); cursor >> m_cert;
} }
@ -279,7 +279,7 @@ std::wstring eap::credentials_tls::get_identity() const
tstring eap::credentials_tls::get_name() 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 /// \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 /// Returns packed size of a configuration
@ -141,7 +141,7 @@ namespace eap {
/// ///
/// \param[inout] cursor Memory cursor /// \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 /// Returns EAP method type of this configuration

View File

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

View File

@ -146,7 +146,7 @@ bool eap::config_method_ttls::load(_In_ IXMLDOMNode *pConfigRoot, _Out_ EAP_ERRO
{ {
// PAP // PAP
m_module.log_config((xpath + L"/NonEAPAuthMethod").c_str(), L"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)) if (!m_inner->load(pXmlElInnerAuthenticationMethod, ppEapError))
return false; return false;
} else { } 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 (m_inner) {
if (dynamic_cast<eap::config_method_pap*>(m_inner.get())) { if (dynamic_cast<config_method_pap*>(m_inner.get())) {
eapserial::pack(cursor, eap::type_pap); cursor << type_pap;
m_inner->pack(cursor); cursor << *m_inner;
} else { } else {
assert(0); // Unsupported inner authentication method type. assert(0); // Unsupported inner authentication method type.
eapserial::pack(cursor, eap::type_undefined); cursor << type_undefined;
} }
} else } 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; size_t size_inner;
if (m_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 = size_inner =
eapserial::get_pk_size(eap::type_pap) + pksizeof(type_pap) +
m_inner->get_pk_size(); pksizeof(*m_inner);
} else { } else {
assert(0); // Unsupported inner authentication method type. assert(0); // Unsupported inner authentication method type.
size_inner = eapserial::get_pk_size(eap::type_undefined); size_inner = pksizeof(type_undefined);
} }
} else } else
size_inner = eapserial::get_pk_size(eap::type_undefined); size_inner = pksizeof(type_undefined);
return return
eap::config_method_tls::get_pk_size() + config_method_tls::get_pk_size() +
size_inner; 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; type_t eap_type;
eapserial::unpack(cursor, eap_type); cursor >> eap_type;
switch (eap_type) { switch (eap_type) {
case eap::type_pap: case type_pap:
m_inner.reset(new eap::config_method_pap(m_module)); m_inner.reset(new config_method_pap(m_module));
m_inner->unpack(cursor); cursor >> *m_inner;
break; break;
default: default:
assert(0); // Unsupported inner authentication method type. 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 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 (m_inner) {
if (dynamic_cast<eap::credentials_pap*>(m_inner.get())) { if (dynamic_cast<credentials_pap*>(m_inner.get())) {
eapserial::pack(cursor, eap::type_pap); cursor << type_pap;
m_inner->pack(cursor); cursor << *m_inner;
} else { } else {
assert(0); // Unsupported inner authentication method type. assert(0); // Unsupported inner authentication method type.
eapserial::pack(cursor, eap::type_undefined); cursor << type_undefined;
} }
} else } 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; size_t size_inner;
if (m_inner) { if (m_inner) {
if (dynamic_cast<eap::credentials_pap*>(m_inner.get())) { if (dynamic_cast<credentials_pap*>(m_inner.get())) {
size_inner = size_inner =
eapserial::get_pk_size(eap::type_pap) + pksizeof(type_pap) +
m_inner->get_pk_size(); pksizeof(*m_inner);
} else { } else {
assert(0); // Unsupported inner authentication method type. assert(0); // Unsupported inner authentication method type.
size_inner = eapserial::get_pk_size(eap::type_undefined); size_inner = pksizeof(type_undefined);
} }
} else } else
size_inner = eapserial::get_pk_size(eap::type_undefined); size_inner = pksizeof(type_undefined);
return return
eap::credentials_tls::get_pk_size() + credentials_tls::get_pk_size() +
size_inner; 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; type_t eap_type;
eapserial::unpack(cursor, eap_type); cursor >> eap_type;
switch (eap_type) { switch (eap_type) {
case eap::type_pap: case type_pap:
m_inner.reset(new eap::credentials_pap(m_module)); m_inner.reset(new credentials_pap(m_module));
m_inner->unpack(cursor); cursor >> *m_inner;
break; break;
default: default:
assert(0); // Unsupported inner authentication method type. assert(0); // Unsupported inner authentication method type.