Connection configuration is equipped with GUID now for multiple credential prompt disambiguation later

This commit is contained in:
Simon Rozman 2016-08-24 11:34:30 +02:00
parent 38e1443276
commit 1cb6ca5adb
4 changed files with 67 additions and 3 deletions

View File

@ -550,6 +550,7 @@ namespace eap
/// @}
public:
GUID m_connection_id; ///< Unique connection ID
std::vector<eap::config_provider> m_providers; ///< Array of provider configurations
};
}

View File

@ -391,6 +391,31 @@ template<size_t N> inline size_t pksizeof(_In_ const eap::sanitizing_blob_f<N> &
///
template<size_t N> inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::sanitizing_blob_f<N> &val);
///
/// Packs a GUID
///
/// \param[inout] cursor Memory cursor
/// \param[in] val Variable with data to pack
///
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const GUID &val);
///
/// Returns packed size of a GUID
///
/// \param[in] val Data to pack
///
/// \returns Size of data when packed (in bytes)
///
inline size_t pksizeof(_In_ const GUID &val);
///
/// Unpacks a GUID
///
/// \param[inout] cursor Memory cursor
/// \param[out] val Variable to receive unpacked value
///
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ GUID &val);
#ifndef htonll
///
/// Convert host converts an unsigned __int64 from host to TCP/IP network byte order.
@ -975,6 +1000,31 @@ inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::sanitizing_blo
}
inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const GUID &val)
{
eap::cursor_out::ptr_type ptr_end = cursor.ptr + sizeof(GUID);
assert(ptr_end <= cursor.ptr_end);
memcpy(cursor.ptr, &val, sizeof(GUID));
cursor.ptr = ptr_end;
}
inline size_t pksizeof(_In_ const GUID &val)
{
UNREFERENCED_PARAMETER(val);
return sizeof(GUID);
}
inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ GUID &val)
{
eap::cursor_in::ptr_type ptr_end = cursor.ptr + sizeof(GUID);
assert(ptr_end <= cursor.ptr_end);
memcpy(&val, cursor.ptr, sizeof(GUID));
cursor.ptr = ptr_end;
}
#ifndef htonll
inline unsigned __int64 htonll(unsigned __int64 val)

View File

@ -614,10 +614,12 @@ void eap::config_provider::operator>>(_Inout_ cursor_in &cursor)
eap::config_provider_list::config_provider_list(_In_ module &mod) : config(mod)
{
memset(&m_connection_id, 0, sizeof(m_connection_id));
}
eap::config_provider_list::config_provider_list(_In_ const config_provider_list &other) :
m_connection_id(other.m_connection_id),
m_providers(other.m_providers),
config(other)
{
@ -625,6 +627,7 @@ eap::config_provider_list::config_provider_list(_In_ const config_provider_list
eap::config_provider_list::config_provider_list(_Inout_ config_provider_list &&other) :
m_connection_id(std::move(other.m_connection_id)),
m_providers(std::move(other.m_providers)),
config(std::move(other))
{
@ -635,6 +638,7 @@ eap::config_provider_list& eap::config_provider_list::operator=(_In_ const confi
{
if (this != &other) {
(config&)*this = other;
m_connection_id = other.m_connection_id;
m_providers = other.m_providers;
}
@ -646,6 +650,7 @@ eap::config_provider_list& eap::config_provider_list::operator=(_Inout_ config_p
{
if (this != &other) {
(config&&)*this = std::move(other);
m_connection_id = std::move(other.m_connection_id);
m_providers = std::move(other.m_providers);
}
@ -693,6 +698,9 @@ void eap::config_provider_list::load(_In_ IXMLDOMNode *pConfigRoot)
config::load(pConfigRoot);
// On each configuration import reset ID.
CoCreateGuid(&m_connection_id);
// Iterate authentication providers (<EAPIdentityProvider>).
com_obj<IXMLDOMNodeList> pXmlListProviders;
if (FAILED(hr = eapxml::select_nodes(pConfigRoot, bstr(L"eap-metadata:EAPIdentityProviderList/eap-metadata:EAPIdentityProvider"), &pXmlListProviders)))
@ -717,6 +725,7 @@ void eap::config_provider_list::load(_In_ IXMLDOMNode *pConfigRoot)
void eap::config_provider_list::operator<<(_Inout_ cursor_out &cursor) const
{
config::operator<<(cursor);
cursor << m_connection_id;
cursor << m_providers;
}
@ -725,7 +734,8 @@ size_t eap::config_provider_list::get_pk_size() const
{
return
config::get_pk_size() +
pksizeof(m_providers);
pksizeof(m_connection_id) +
pksizeof(m_providers );
}
@ -733,6 +743,8 @@ void eap::config_provider_list::operator>>(_Inout_ cursor_in &cursor)
{
config::operator>>(cursor);
cursor >> m_connection_id;
list<config_provider>::size_type count;
cursor >> count;
m_providers.clear();

View File

@ -88,6 +88,7 @@ void eap::peer_ttls_ui::invoke_config_ui(
unpack(cfg, pConnectionDataIn, dwConnectionDataInSize);
} else {
// This is a blank network profile. Create default configuraton.
CoCreateGuid(&(cfg.m_connection_id));
// Start with PAP inner configuration.
unique_ptr<config_method_ttls> cfg_method(new config_method_ttls(*this));