wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_eapol_handler.cpp
branchRCL_3
changeset 42 a828660c511c
parent 0 c40eb8fe8501
child 43 d3d7683d16f5
equal deleted inserted replaced
40:5fb7af913dfd 42:a828660c511c
   106         return handler_m->packet_send(
   106         return handler_m->packet_send(
   107             send_network_id,
   107             send_network_id,
   108             packet_data,
   108             packet_data,
   109             packet_data_length,
   109             packet_data_length,
   110             send_unencrypted );
   110             send_unencrypted );
       
   111         }
       
   112 
       
   113     if ( !server_m->get_connection_data()->current_ap_data() )
       
   114         {
       
   115         /**
       
   116          * EAPOL might try to send packets after a failed connection attempt,
       
   117          * filter them out. This check is only valid when no handler is registered.
       
   118          */
       
   119         DEBUG( "core_eapol_handler_c::packet_send() - not connected or attempting connection, ignoring" );
       
   120 
       
   121         return core_error_ok;
   111         }
   122         }
   112 
   123 
   113     server_m->send_data_frame(
   124     server_m->send_data_frame(
   114         *server_m->get_connection_data()->current_ap_data(),
   125         *server_m->get_connection_data()->current_ap_data(),
   115         core_frame_type_ethernet,
   126         core_frame_type_ethernet,
   579                 {
   590                 {
   580                 error = new_protected_setup_credentials(
   591                 error = new_protected_setup_credentials(
   581                     credential_list );
   592                     credential_list );
   582                 }
   593                 }
   583             break;
   594             break;
       
   595             }
       
   596         case wlan_eapol_if_message_type_function_complete_disassociation:
       
   597             {
       
   598             network_id_c network_id( NULL, 0, NULL, 0, 0 );
       
   599             
       
   600             error = function.parse_complete_disassociation(
       
   601                 &network_id );
       
   602             if ( error == core_error_ok )
       
   603                 {
       
   604                 error = complete_disassociation(
       
   605                     &network_id );
       
   606                 }
       
   607             break;
       
   608 
   584             }
   609             }
   585         case wlan_eapol_if_message_type_function_none:
   610         case wlan_eapol_if_message_type_function_none:
   586         default:
   611         default:
   587             DEBUG1( "core_eapol_handler_c::send_data() - Error: unknown function %i", func );
   612             DEBUG1( "core_eapol_handler_c::send_data() - Error: unknown function %i", func );
   588         }
   613         }
   851     }
   876     }
   852 
   877 
   853 // ---------------------------------------------------------------------------
   878 // ---------------------------------------------------------------------------
   854 // ---------------------------------------------------------------------------
   879 // ---------------------------------------------------------------------------
   855 //
   880 //
       
   881 core_error_e core_eapol_handler_c::complete_disassociation(
       
   882     network_id_c * receive_network_id )
       
   883     {
       
   884     DEBUG( "core_eapol_handler_c::complete_disassociation()" );
       
   885 
       
   886     if( !server_m->get_connection_data() ||
       
   887         !server_m->get_connection_data()->is_eapol_disconnecting() )
       
   888         {
       
   889         DEBUG( "core_eapol_handler_c::handle_wlan_authentication_state() - complete_disassociation received while not disconnecting, ignoring" );
       
   890 
       
   891         return core_error_general;
       
   892         }
       
   893 
       
   894     const core_mac_address_s cur_bssid(
       
   895         server_m->get_connection_data()->eapol_auth_bssid() );
       
   896     const core_mac_address_s bssid(
       
   897         receive_network_id->source() );
       
   898     DEBUG6( "core_eapol_handler_c::complete_disassociation() - function BSSID is %02X:%02X:%02X:%02X:%02X:%02X",
       
   899         bssid.addr[0], bssid.addr[1], bssid.addr[2], 
       
   900         bssid.addr[3], bssid.addr[4], bssid.addr[5] );
       
   901     DEBUG6( "core_eapol_handler_c::complete_disassociation() - current BSSID is %02X:%02X:%02X:%02X:%02X:%02X",
       
   902         cur_bssid.addr[0], cur_bssid.addr[1], cur_bssid.addr[2], 
       
   903         cur_bssid.addr[3], cur_bssid.addr[4], cur_bssid.addr[5] );
       
   904     DEBUG1( "core_eapol_handler_c::complete_disassociation() - EAPOL authentication failure status is %u",
       
   905         server_m->get_connection_data()->eapol_auth_failure() );
       
   906 
       
   907     bool_t is_eapol_authentication_started(
       
   908         server_m->get_connection_data()->is_eapol_authentication_started() );
       
   909     DEBUG( "core_eapol_handler_c::complete_disassociation() - marking is_eapol_authenticating as false" );
       
   910     server_m->get_connection_data()->set_eapol_authenticating(
       
   911         false_t );
       
   912     DEBUG( "core_eapol_handler_c::complete_disassociation() - marking is_eapol_authentication_started as false" );
       
   913     server_m->get_connection_data()->set_eapol_authentication_started(
       
   914         false_t );
       
   915     DEBUG( "core_eapol_handler_c::complete_disassociation() - marking is_eapol_disconnecting as false" );
       
   916     server_m->get_connection_data()->set_eapol_disconnecting(
       
   917         false_t );
       
   918 
       
   919     /**
       
   920      * We only care about the pending status notification in case the authentication
       
   921      * has been started by us, otherwise we'll just ignore it. 
       
   922      */
       
   923     if ( is_eapol_authentication_started )
       
   924         {
       
   925         DEBUG( "core_eapol_handler_c::complete_disassociation() - completing request" );
       
   926         server_m->request_complete(
       
   927             REQUEST_ID_CORE_INTERNAL,
       
   928             server_m->get_connection_data()->eapol_auth_failure() );
       
   929         }
       
   930     else
       
   931         {
       
   932         DEBUG( "core_eapol_handler_c::complete_disassociation() - completing request (authentication not started)" );
       
   933         server_m->request_complete(
       
   934             REQUEST_ID_CORE_INTERNAL,
       
   935             core_error_ok );
       
   936         }
       
   937 
       
   938     return core_error_ok;
       
   939     }
       
   940 
       
   941 // ---------------------------------------------------------------------------
       
   942 // ---------------------------------------------------------------------------
       
   943 //
   856 void core_eapol_handler_c::handle_error(
   944 void core_eapol_handler_c::handle_error(
   857     wlan_eapol_if_error_e errorcode,
   945     wlan_eapol_if_error_e errorcode,
   858     wlan_eapol_if_message_type_function_e function )
   946     wlan_eapol_if_message_type_function_e function )
   859     {
   947     {
   860     DEBUG2( "core_eapol_handler_c::handle_error() - Received error message: errorcode=%i, function=%i", errorcode, function );
   948     DEBUG2( "core_eapol_handler_c::handle_error() - Received error message: errorcode=%i, function=%i", errorcode, function );
   972         DEBUG( "core_ap_data_c::instance() - notification doesn't match the current BSSID, ignoring notification" );
  1060         DEBUG( "core_ap_data_c::instance() - notification doesn't match the current BSSID, ignoring notification" );
   973 
  1061 
   974         return;
  1062         return;
   975         }
  1063         }
   976 
  1064 
       
  1065     server_m->get_connection_data()->set_eapol_auth_failure(
       
  1066         eapol_wlan_authentication_state_to_error( state )  );
       
  1067 
       
  1068     if ( server_m->get_connection_data()->is_eapol_disconnecting() )
       
  1069         {
       
  1070         DEBUG( "core_ap_data_c::instance() - disassociation pending, request cannot be completed yet" );
       
  1071 
       
  1072         return;
       
  1073         }
       
  1074 
   977     bool_t is_authentication_started( server_m->get_connection_data()->is_eapol_authenticating() );
  1075     bool_t is_authentication_started( server_m->get_connection_data()->is_eapol_authenticating() );
   978     
  1076 
   979     DEBUG( "core_eapol_handler_c::handle_wlan_authentication_state() - marking is_eapol_authenticating as false" );
  1077     DEBUG( "core_eapol_handler_c::handle_wlan_authentication_state() - marking is_eapol_authenticating as false" );
   980     server_m->get_connection_data()->set_eapol_authenticating(
  1078     server_m->get_connection_data()->set_eapol_authenticating(
   981         false_t );
  1079         false_t );
   982     DEBUG( "core_eapol_handler_c::handle_wlan_authentication_state() - marking is_eapol_authentication_started as false" );
  1080     DEBUG( "core_eapol_handler_c::handle_wlan_authentication_state() - marking is_eapol_authentication_started as false" );
   983     server_m->get_connection_data()->set_eapol_authentication_started(
  1081     server_m->get_connection_data()->set_eapol_authentication_started(