Support for various peer action request extended

This commit is contained in:
2016-10-27 10:00:18 +02:00
parent fc008bcfb4
commit 654c965851
13 changed files with 160 additions and 166 deletions

View File

@@ -93,10 +93,9 @@ namespace eap
///
/// \sa [EapPeerProcessRequestPacket function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363621.aspx)
///
virtual void process_request_packet(
_In_bytecount_(dwReceivedPacketSize) const void *pReceivedPacket,
_In_ DWORD dwReceivedPacketSize,
_Out_ EapPeerMethodOutput *pEapOutput);
virtual EapPeerMethodResponseAction process_request_packet(
_In_bytecount_(dwReceivedPacketSize) const void *pReceivedPacket,
_In_ DWORD dwReceivedPacketSize);
///
/// Obtains a response packet from the EAP method.
@@ -139,10 +138,9 @@ namespace eap
///
/// \sa [EapPeerSetUIContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363626.aspx)
///
virtual void set_ui_context(
_In_count_(dwUIContextDataSize) const BYTE *pUIContextData,
_In_ DWORD dwUIContextDataSize,
_Out_ EapPeerMethodOutput *pEapOutput);
virtual EapPeerMethodResponseAction set_ui_context(
_In_count_(dwUIContextDataSize) const BYTE *pUIContextData,
_In_ DWORD dwUIContextDataSize);
/// @}
@@ -161,9 +159,7 @@ namespace eap
///
/// \sa [EapPeerSetResponseAttributes function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363625.aspx)
///
virtual void set_response_attributes(
_In_ const EapAttributes *pAttribs,
_Out_ EapPeerMethodOutput *pEapOutput);
virtual EapPeerMethodResponseAction set_response_attributes(_In_ const EapAttributes *pAttribs);
/// @}
@@ -171,24 +167,22 @@ namespace eap
///
/// Converts EapHost peer action to output structure.
///
/// \param[in ] action EapHost peer action
/// \param[out] pEapOutput EAP method output structure
/// \param[in] action EapHost peer action
///
inline void action_to_output(
_In_ EapHostPeerResponseAction action,
_Out_ EapPeerMethodOutput *pEapOutput)
/// \returns EAP method output action
///
inline EapPeerMethodResponseAction action_h2p(_In_ EapHostPeerResponseAction action)
{
switch (action) {
case EapHostPeerResponseDiscard : pEapOutput->action = EapPeerMethodResponseActionDiscard ; break;
case EapHostPeerResponseSend : pEapOutput->action = EapPeerMethodResponseActionSend ; break;
case EapHostPeerResponseResult : pEapOutput->action = EapPeerMethodResponseActionResult ; break;
case EapHostPeerResponseInvokeUi : pEapOutput->action = EapPeerMethodResponseActionInvokeUI; break;
case EapHostPeerResponseRespond : pEapOutput->action = EapPeerMethodResponseActionRespond ; break;
case EapHostPeerResponseStartAuthentication: pEapOutput->action = EapPeerMethodResponseActionDiscard ; break; // The session could not be found. So the supplicant either needs to start session again with the same packet or discard the packet.
case EapHostPeerResponseNone : pEapOutput->action = EapPeerMethodResponseActionNone ; break;
case EapHostPeerResponseDiscard : return EapPeerMethodResponseActionDiscard ;
case EapHostPeerResponseSend : return EapPeerMethodResponseActionSend ;
case EapHostPeerResponseResult : return EapPeerMethodResponseActionResult ;
case EapHostPeerResponseInvokeUi : return EapPeerMethodResponseActionInvokeUI;
case EapHostPeerResponseRespond : return EapPeerMethodResponseActionRespond ;
case EapHostPeerResponseStartAuthentication: return EapPeerMethodResponseActionDiscard ; // The session could not be found. So the supplicant either needs to start session again with the same packet or discard the packet.
case EapHostPeerResponseNone : return EapPeerMethodResponseActionNone ;
default : throw std::invalid_argument(winstd::string_printf(__FUNCTION__ " Unknown action (%u).", action).c_str());
}
pEapOutput->fAllowNotifications = TRUE;
}
protected:

View File

@@ -102,13 +102,11 @@ void eap::method_eaphost::end_session()
}
void eap::method_eaphost::process_request_packet(
_In_bytecount_(dwReceivedPacketSize) const void *pReceivedPacket,
_In_ DWORD dwReceivedPacketSize,
_Out_ EapPeerMethodOutput *pEapOutput)
EapPeerMethodResponseAction eap::method_eaphost::process_request_packet(
_In_bytecount_(dwReceivedPacketSize) const void *pReceivedPacket,
_In_ DWORD dwReceivedPacketSize)
{
assert(pReceivedPacket || dwReceivedPacketSize == 0);
assert(pEapOutput);
m_module.log_event(&EAPMETHOD_PACKET_RECV, event_data((unsigned int)m_cfg.get_method_id()), event_data((unsigned int)dwReceivedPacketSize), event_data::blank);
@@ -123,7 +121,7 @@ void eap::method_eaphost::process_request_packet(
&error._Myptr);
if (dwResult == ERROR_SUCCESS) {
// Packet successfuly processed.
action_to_output(action, pEapOutput);
return action_h2p(action);
} else if (error)
throw eap_runtime_error(*error , __FUNCTION__ " EapHostPeerProcessReceivedPacket failed.");
else
@@ -212,13 +210,10 @@ void eap::method_eaphost::get_ui_context(
}
void eap::method_eaphost::set_ui_context(
_In_count_(dwUIContextDataSize) const BYTE *pUIContextData,
_In_ DWORD dwUIContextDataSize,
_Out_ EapPeerMethodOutput *pEapOutput)
EapPeerMethodResponseAction eap::method_eaphost::set_ui_context(
_In_count_(dwUIContextDataSize) const BYTE *pUIContextData,
_In_ DWORD dwUIContextDataSize)
{
assert(pEapOutput);
// Set EapHost peer UI context data.
EapHostPeerResponseAction action;
eap_error_runtime error;
@@ -230,7 +225,7 @@ void eap::method_eaphost::set_ui_context(
&error._Myptr);
if (dwResult == ERROR_SUCCESS) {
// UI context data successfuly returned.
action_to_output(action, pEapOutput);
return action_h2p(action);
} else if (error)
throw eap_runtime_error(*error , __FUNCTION__ " EapHostPeerSetUIContext failed.");
else
@@ -255,9 +250,7 @@ void eap::method_eaphost::get_response_attributes(_Inout_ EapAttributes *pAttrib
}
void eap::method_eaphost::set_response_attributes(
_In_ const EapAttributes *pAttribs,
_Out_ EapPeerMethodOutput *pEapOutput)
EapPeerMethodResponseAction eap::method_eaphost::set_response_attributes(_In_ const EapAttributes *pAttribs)
{
// Set response attributes for EapHost peer.
EapHostPeerResponseAction action;
@@ -269,7 +262,7 @@ void eap::method_eaphost::set_response_attributes(
&error._Myptr);
if (dwResult == ERROR_SUCCESS) {
// Response attributes successfuly set.
action_to_output(action, pEapOutput);
return action_h2p(action);
} else if (error)
throw eap_runtime_error(*error , __FUNCTION__ " EapHostPeerGetResponseAttributes failed.");
else