From 22a87bf90deff4d26ed3b78ba9e40b4bc3218406 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Thu, 4 Aug 2016 10:07:03 +0200 Subject: [PATCH] eap::session::get_response_packet() implemented --- EAPMethods/src/Main.cpp | 1 + lib/EAPBase/include/Session.h | 20 +++++++++++++++++++- lib/TTLS/include/Session.h | 14 -------------- lib/TTLS/src/Session.cpp | 14 -------------- lib/WinStd | 2 +- 5 files changed, 21 insertions(+), 30 deletions(-) diff --git a/EAPMethods/src/Main.cpp b/EAPMethods/src/Main.cpp index ed74a76..8678ec2 100644 --- a/EAPMethods/src/Main.cpp +++ b/EAPMethods/src/Main.cpp @@ -23,6 +23,7 @@ using namespace std; using namespace winstd; +#pragma comment(lib, "Ws2_32.lib") #if EAPMETHOD_TYPE==21 #define _EAPMETHOD_PEER eap::peer_ttls diff --git a/lib/EAPBase/include/Session.h b/lib/EAPBase/include/Session.h index 5a61bb1..e685afb 100644 --- a/lib/EAPBase/include/Session.h +++ b/lib/EAPBase/include/Session.h @@ -30,6 +30,8 @@ namespace eap #include "Module.h" +#include + #include #include // Must include after extern "C" { @@ -235,7 +237,22 @@ namespace eap virtual bool get_response_packet( _Inout_ DWORD *pdwSendPacketSize, _Inout_bytecap_(*dwSendPacketSize) EapPacket *pSendPacket, - _Out_ EAP_ERROR **ppEapError) = 0; + _Out_ EAP_ERROR **ppEapError) + { + assert(pdwSendPacketSize); + assert(pSendPacket); + assert(ppEapError); + + WORD size = m_packet.size(); + if (size > *pdwSendPacketSize) { + *ppEapError = m_module.make_error(ERROR_INSUFFICIENT_BUFFER, winstd::string_printf(_T(__FUNCTION__) _T(" Packet buffer is too small (%uB required, %uB provided)."), m_packet.size(), *pdwSendPacketSize).c_str()); + return false; + } + memcpy(pSendPacket, (const EapPacket*)m_packet, size); + *pdwSendPacketSize = size; + + return true; + } /// @@ -352,6 +369,7 @@ namespace eap module &m_module; ///< Reference of the EAP module config_providers m_cfg; ///< Session configuration credentials_type m_cred; ///< User credentials + winstd::eap_packet m_packet; ///< Response packet interactive_request_type m_intreq; ///< Interactive UI request data DWORD m_eap_flags; ///< A combination of EAP flags that describe the new EAP authentication session behavior HANDLE m_token; ///< Specifies a handle to the user impersonation token to use in this session diff --git a/lib/TTLS/include/Session.h b/lib/TTLS/include/Session.h index be85915..40d6225 100644 --- a/lib/TTLS/include/Session.h +++ b/lib/TTLS/include/Session.h @@ -93,20 +93,6 @@ namespace eap _Out_ EapPeerMethodOutput *pEapOutput, _Out_ EAP_ERROR **ppEapError); - /// - /// Obtains a response packet from the EAP method. - /// - /// \sa [EapPeerGetResponsePacket function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363610.aspx) - /// - /// \returns - /// - \c true if succeeded - /// - \c false otherwise. See \p ppEapError for details. - /// - virtual bool get_response_packet( - _Inout_ DWORD *pdwSendPacketSize, - _Inout_bytecap_(*dwSendPacketSize) EapPacket *pSendPacket, - _Out_ EAP_ERROR **ppEapError); - /// /// Obtains the result of an authentication session from the EAP method. /// diff --git a/lib/TTLS/src/Session.cpp b/lib/TTLS/src/Session.cpp index 62f4918..b6cc36c 100644 --- a/lib/TTLS/src/Session.cpp +++ b/lib/TTLS/src/Session.cpp @@ -79,20 +79,6 @@ bool eap::session_ttls::process_request_packet( } -bool eap::session_ttls::get_response_packet( - _Inout_ DWORD *pdwSendPacketSize, - _Inout_bytecap_(*dwSendPacketSize) EapPacket *pSendPacket, - _Out_ EAP_ERROR **ppEapError) -{ - UNREFERENCED_PARAMETER(pdwSendPacketSize); - UNREFERENCED_PARAMETER(pSendPacket); - assert(ppEapError); - - *ppEapError = m_module.make_error(ERROR_NOT_SUPPORTED, _T(__FUNCTION__) _T(" Not supported.")); - return false; -} - - bool eap::session_ttls::get_result( _In_ EapPeerMethodResultReason reason, _Out_ EapPeerMethodResult *ppResult, diff --git a/lib/WinStd b/lib/WinStd index b1f5846..431c7d9 160000 --- a/lib/WinStd +++ b/lib/WinStd @@ -1 +1 @@ -Subproject commit b1f5846d8c364eb6982b119786ee2c1f3a0c8740 +Subproject commit 431c7d99603d0457d586d7d722e3cad27ff42dd4