593 // Trap must be set here because the OS independent portion of EAP protected setup |
594 // Trap must be set here because the OS independent portion of EAP protected setup |
594 // that calls this function does not know anything about Symbian. |
595 // that calls this function does not know anything about Symbian. |
595 |
596 |
596 eap_status_e status(eap_status_ok); |
597 eap_status_e status(eap_status_ok); |
597 |
598 |
598 eap_variable_data_c wanted_field(m_am_tools); |
599 if (cf_str_EAP_SIMPLE_CONFIG_device_password.get_field()->compare( |
599 eap_variable_data_c type_field(m_am_tools); |
600 m_am_tools, |
600 |
601 field) == true) |
601 status = wanted_field.set_buffer( |
|
602 field->get_field(), |
|
603 field->get_field_length(), |
|
604 false, |
|
605 false); |
|
606 if (status != eap_status_ok) |
|
607 { |
|
608 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
609 return EAP_STATUS_RETURN(m_am_tools, status); |
|
610 } |
|
611 |
|
612 status = type_field.set_buffer( |
|
613 cf_str_EAP_SIMPLE_CONFIG_device_password.get_field()->get_field(), |
|
614 cf_str_EAP_SIMPLE_CONFIG_device_password.get_field()->get_field_length(), |
|
615 false, |
|
616 false); |
|
617 if (status != eap_status_ok) |
|
618 { |
|
619 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
620 return EAP_STATUS_RETURN(m_am_tools, status); |
|
621 } |
|
622 |
|
623 if (!wanted_field.compare(&type_field)) |
|
624 { |
602 { |
625 // We have to get the device password here. It is nothing but the PIN code in PIN based protected setup. |
603 // We have to get the device password here. It is nothing but the PIN code in PIN based protected setup. |
626 |
604 |
627 TRAPD(err, read_device_passwordL( |
605 status = read_memory_store( |
628 field->get_field(), |
606 eap_type_protected_setup_stored_preshared_key, |
629 field->get_field_length(), |
607 data); |
630 data)); |
|
631 if (err != KErrNone) |
|
632 { |
|
633 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
634 } |
|
635 |
608 |
636 m_am_tools->trace_configuration( |
609 m_am_tools->trace_configuration( |
637 status, |
610 status, |
638 field, |
611 field, |
639 data); |
612 data); |
640 |
613 |
641 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
614 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
642 return EAP_STATUS_RETURN(m_am_tools, status); |
615 return EAP_STATUS_RETURN(m_am_tools, status); |
643 |
616 } |
644 } // if (!wanted_field.compare(&type_field)) |
|
645 |
617 |
646 |
618 |
647 // Read is routed to partner object. |
619 // Read is routed to partner object. |
648 status = m_partner->read_configure( |
620 status = m_partner->read_configure( |
649 field, |
621 field, |
658 } |
630 } |
659 |
631 |
660 //-------------------------------------------------- |
632 //-------------------------------------------------- |
661 |
633 |
662 // |
634 // |
|
635 eap_status_e CEapAmProtectedSetupSymbian::read_memory_store( |
|
636 const eap_type_protected_setup_stored_e data_type, |
|
637 eap_variable_data_c * const data) |
|
638 { |
|
639 // Read data from memory store. |
|
640 |
|
641 eap_variable_data_c memory_store_key(m_am_tools); |
|
642 |
|
643 eap_status_e status = memory_store_key.set_copy_of_buffer( |
|
644 EAP_WPS_CONFIGURATION_MEMORY_STORE_KEY, |
|
645 sizeof(EAP_WPS_CONFIGURATION_MEMORY_STORE_KEY)); |
|
646 if (status != eap_status_ok) |
|
647 { |
|
648 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
649 return EAP_STATUS_RETURN(m_am_tools, status); |
|
650 } |
|
651 |
|
652 status = memory_store_key.add_data( |
|
653 &m_is_client, |
|
654 sizeof(m_is_client)); |
|
655 if (status != eap_status_ok) |
|
656 { |
|
657 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
658 return EAP_STATUS_RETURN(m_am_tools, status); |
|
659 } |
|
660 |
|
661 eap_network_id_selector_c state_selector( |
|
662 m_am_tools, |
|
663 &m_receive_network_id); |
|
664 |
|
665 status = memory_store_key.add_data( |
|
666 &state_selector); |
|
667 if (status != eap_status_ok) |
|
668 { |
|
669 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
670 return EAP_STATUS_RETURN(m_am_tools, status); |
|
671 } |
|
672 |
|
673 eap_tlv_message_data_c tlv_data(m_am_tools); |
|
674 |
|
675 status = m_am_tools->memory_store_get_data( |
|
676 &memory_store_key, |
|
677 &tlv_data); |
|
678 if (status != eap_status_ok) |
|
679 { |
|
680 EAP_TRACE_DEBUG( |
|
681 m_am_tools, |
|
682 TRACE_FLAGS_DEFAULT, |
|
683 (EAPL("simple_config_record_c::complete_query_network_and_device_parameters(): cannot get WPS credentials\n"))); |
|
684 } |
|
685 else |
|
686 { |
|
687 EAP_TRACE_DEBUG( |
|
688 m_am_tools, |
|
689 TRACE_FLAGS_DEFAULT, |
|
690 (EAPL("simple_config_record_c::complete_query_network_and_device_parameters(): WPS credentials found\n"))); |
|
691 |
|
692 // Parse read data. |
|
693 eap_array_c<eap_tlv_header_c> tlv_blocks(m_am_tools); |
|
694 |
|
695 status = tlv_data.parse_message_data(&tlv_blocks); |
|
696 if (status != eap_status_ok) |
|
697 { |
|
698 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
699 return EAP_STATUS_RETURN(m_am_tools, status); |
|
700 } |
|
701 |
|
702 for (u32_t ind = 0ul; ind < tlv_blocks.get_object_count(); ind++) |
|
703 { |
|
704 eap_tlv_header_c * const tlv = tlv_blocks.get_object(ind); |
|
705 if (tlv != 0) |
|
706 { |
|
707 if (tlv->get_type() == data_type) |
|
708 { |
|
709 status = data->set_copy_of_buffer( |
|
710 tlv->get_value(tlv->get_value_length()), |
|
711 tlv->get_value_length()); |
|
712 if (status != eap_status_ok) |
|
713 { |
|
714 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
715 return EAP_STATUS_RETURN(m_am_tools, status); |
|
716 } |
|
717 } |
|
718 } |
|
719 } // for() |
|
720 |
|
721 if (data->get_is_valid_data() == false) |
|
722 { |
|
723 EAP_TRACE_ERROR( |
|
724 m_am_tools, |
|
725 TRACE_FLAGS_ERROR, |
|
726 (EAPL("simple_config_record_c::complete_query_network_and_device_parameters(): cannot get data %d\n"), |
|
727 data_type)); |
|
728 |
|
729 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
730 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter); |
|
731 } |
|
732 } |
|
733 |
|
734 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
735 return EAP_STATUS_RETURN(m_am_tools, status); |
|
736 } |
|
737 |
|
738 //-------------------------------------------------- |
|
739 |
|
740 #if 0 |
|
741 |
|
742 // |
663 void CEapAmProtectedSetupSymbian::read_device_passwordL( |
743 void CEapAmProtectedSetupSymbian::read_device_passwordL( |
664 eap_config_string /*field*/, |
744 eap_variable_data_c * const data) |
665 const u32_t /*field_length*/, |
|
666 eap_variable_data_c * const /* data */) |
|
667 { |
745 { |
668 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
746 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
669 |
747 |
670 // Get the things from commsdat here. |
748 // Get the things from commsdat here. |
671 |
749 |
672 #if 0 |
750 #if 1 |
|
751 |
|
752 // Read PIN from memory store. |
|
753 |
|
754 eap_status_e status = read_memory_store( |
|
755 eap_type_protected_setup_stored_preshared_key, |
|
756 data); |
|
757 |
|
758 #elif 0 |
|
759 |
|
760 { |
|
761 eap_variable_data_c memory_store_key(m_am_tools); |
|
762 |
|
763 eap_status_e status = memory_store_key.set_copy_of_buffer( |
|
764 EAP_WPS_CONFIGURATION_MEMORY_STORE_KEY, |
|
765 sizeof(EAP_WPS_CONFIGURATION_MEMORY_STORE_KEY)); |
|
766 if (status != eap_status_ok) |
|
767 { |
|
768 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
769 (void) EAP_STATUS_RETURN(m_am_tools, status); |
|
770 return; |
|
771 } |
|
772 |
|
773 status = memory_store_key.add_data( |
|
774 &m_is_client, |
|
775 sizeof(m_is_client)); |
|
776 if (status != eap_status_ok) |
|
777 { |
|
778 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
779 (void) EAP_STATUS_RETURN(m_am_tools, status); |
|
780 return; |
|
781 } |
|
782 |
|
783 eap_network_id_selector_c state_selector( |
|
784 m_am_tools, |
|
785 &m_receive_network_id); |
|
786 |
|
787 status = memory_store_key.add_data( |
|
788 &state_selector); |
|
789 if (status != eap_status_ok) |
|
790 { |
|
791 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
792 (void) EAP_STATUS_RETURN(m_am_tools, status); |
|
793 return; |
|
794 } |
|
795 |
|
796 eap_tlv_message_data_c tlv_data(m_am_tools); |
|
797 |
|
798 status = m_am_tools->memory_store_get_data( |
|
799 &memory_store_key, |
|
800 &tlv_data); |
|
801 if (status != eap_status_ok) |
|
802 { |
|
803 EAP_TRACE_DEBUG( |
|
804 m_am_tools, |
|
805 TRACE_FLAGS_DEFAULT, |
|
806 (EAPL("simple_config_record_c::complete_query_network_and_device_parameters(): cannot get WPS credentials\n"))); |
|
807 } |
|
808 else |
|
809 { |
|
810 EAP_TRACE_DEBUG( |
|
811 m_am_tools, |
|
812 TRACE_FLAGS_DEFAULT, |
|
813 (EAPL("simple_config_record_c::complete_query_network_and_device_parameters(): WPS credentials found\n"))); |
|
814 |
|
815 // Parse read data. |
|
816 eap_array_c<eap_tlv_header_c> tlv_blocks(m_am_tools); |
|
817 |
|
818 status = tlv_data.parse_message_data(&tlv_blocks); |
|
819 if (status != eap_status_ok) |
|
820 { |
|
821 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
822 (void) EAP_STATUS_RETURN(m_am_tools, status); |
|
823 return; |
|
824 } |
|
825 |
|
826 for (u32_t ind = 0ul; ind < tlv_blocks.get_object_count(); ind++) |
|
827 { |
|
828 eap_tlv_header_c * const tlv = tlv_blocks.get_object(ind); |
|
829 if (tlv != 0) |
|
830 { |
|
831 if (tlv->get_type() == eap_type_protected_setup_stored_preshared_key) |
|
832 { |
|
833 status = data->set_copy_of_buffer( |
|
834 tlv->get_value(tlv->get_value_length()), |
|
835 tlv->get_value_length()); |
|
836 if (status != eap_status_ok) |
|
837 { |
|
838 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
839 (void) EAP_STATUS_RETURN(m_am_tools, status); |
|
840 return; |
|
841 } |
|
842 } |
|
843 else if (tlv->get_type() == eap_type_protected_setup_stored_ssid) |
|
844 { |
|
845 status = m_SSID.set_copy_of_buffer( |
|
846 tlv->get_value(tlv->get_value_length()), |
|
847 tlv->get_value_length()); |
|
848 if (status != eap_status_ok) |
|
849 { |
|
850 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
851 (void) EAP_STATUS_RETURN(m_am_tools, status); |
|
852 return; |
|
853 } |
|
854 } |
|
855 } |
|
856 } // for() |
|
857 |
|
858 if (data->get_is_valid_data() == false) |
|
859 { |
|
860 EAP_TRACE_ERROR( |
|
861 m_am_tools, |
|
862 TRACE_FLAGS_ERROR, |
|
863 (EAPL("simple_config_record_c::complete_query_network_and_device_parameters(): cannot get WPS PIN\n"))); |
|
864 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
865 (void) EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter); |
|
866 return; |
|
867 } |
|
868 } |
|
869 |
|
870 |
|
871 EAP_TRACE_DATA_DEBUG( |
|
872 m_am_tools, |
|
873 TRACE_FLAGS_DEFAULT, |
|
874 (EAPL("SIMPLE_CONFIG m_device_password"), |
|
875 m_device_password.get_data(), |
|
876 m_device_password.get_data_length())); |
|
877 |
|
878 if (m_device_password.get_data_length() == SIMPLE_CONFIG_PBC_DEVICE_PASSWORD_PIN_SIZE |
|
879 && m_am_tools->memcmp(m_device_password.get_data(), SIMPLE_CONFIG_PBC_DEVICE_PASSWORD_PIN, SIMPLE_CONFIG_PBC_DEVICE_PASSWORD_PIN_SIZE) == 0) |
|
880 { |
|
881 EAP_TRACE_DEBUG( |
|
882 m_am_tools, |
|
883 TRACE_FLAGS_DEFAULT, |
|
884 (EAPL("CEapAmProtectedSetupSymbian::read_device_passwordL(): WPS push button\n"))); |
|
885 |
|
886 m_Device_Password_ID = simple_config_Device_Password_ID_PushButton; |
|
887 } |
|
888 else |
|
889 { |
|
890 EAP_TRACE_DEBUG( |
|
891 m_am_tools, |
|
892 TRACE_FLAGS_DEFAULT, |
|
893 (EAPL("CEapAmProtectedSetupSymbian::read_device_passwordL(): WPS PIN\n"))); |
|
894 |
|
895 m_Device_Password_ID = simple_config_Device_Password_ID_Default_PIN; |
|
896 } |
|
897 } |
|
898 |
|
899 #else |
673 |
900 |
674 // We need PSK (PIN code for protected setup) from the CommsDat. |
901 // We need PSK (PIN code for protected setup) from the CommsDat. |
675 // CommDbIf is used to get the PSK. |
902 // CommDbIf is used to get the PSK. |
676 |
903 |
677 CWLanSettings* wlan_settings = new(ELeave) CWLanSettings; |
904 CWLanSettings* wlan_settings = new(ELeave) CWLanSettings; |
931 } |
1160 } |
932 } |
1161 } |
933 |
1162 |
934 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
1163 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
935 |
1164 |
|
1165 { |
|
1166 eap_variable_data_c device_password(m_am_tools); |
|
1167 |
|
1168 status = read_memory_store( |
|
1169 eap_type_protected_setup_stored_preshared_key, |
|
1170 &device_password); |
|
1171 if (status != eap_status_ok) |
|
1172 { |
|
1173 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1174 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1175 } |
|
1176 |
|
1177 EAP_TRACE_DATA_DEBUG( |
|
1178 m_am_tools, |
|
1179 TRACE_FLAGS_DEFAULT, |
|
1180 (EAPL("SIMPLE_CONFIG device_password"), |
|
1181 device_password.get_data(), |
|
1182 device_password.get_data_length())); |
|
1183 |
|
1184 if (device_password.get_data_length() == SIMPLE_CONFIG_PBC_DEVICE_PASSWORD_PIN_SIZE |
|
1185 && m_am_tools->memcmp(device_password.get_data(), SIMPLE_CONFIG_PBC_DEVICE_PASSWORD_PIN, SIMPLE_CONFIG_PBC_DEVICE_PASSWORD_PIN_SIZE) == 0) |
|
1186 { |
|
1187 EAP_TRACE_DEBUG( |
|
1188 m_am_tools, |
|
1189 TRACE_FLAGS_DEFAULT, |
|
1190 (EAPL("CEapAmProtectedSetupSymbian::read_device_passwordL(): WPS push button\n"))); |
|
1191 |
|
1192 m_Device_Password_ID = simple_config_Device_Password_ID_PushButton; |
|
1193 } |
|
1194 else |
|
1195 { |
|
1196 EAP_TRACE_DEBUG( |
|
1197 m_am_tools, |
|
1198 TRACE_FLAGS_DEFAULT, |
|
1199 (EAPL("CEapAmProtectedSetupSymbian::read_device_passwordL(): WPS PIN\n"))); |
|
1200 |
|
1201 m_Device_Password_ID = simple_config_Device_Password_ID_Default_PIN; |
|
1202 } |
|
1203 } |
|
1204 |
936 EAP_TRACE_DEBUG( |
1205 EAP_TRACE_DEBUG( |
937 m_am_tools, |
1206 m_am_tools, |
938 TRACE_FLAGS_DEFAULT, |
1207 TRACE_FLAGS_DEFAULT, |
939 (EAPL("CEapAmProtectedSetupSymbian::query_network_and_device_parameters() m_Device_Password_ID=%d\n"), |
1208 (EAPL("CEapAmProtectedSetupSymbian::query_network_and_device_parameters() m_Device_Password_ID=%d\n"), |
940 m_Device_Password_ID)); |
1209 m_Device_Password_ID)); |