Veerendranath Jakkam | ed6ac3f | 2018-04-18 00:03:06 +0530 | [diff] [blame] | 1 | /*-------------------------------------------------------------------------- |
| 2 | Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. |
| 3 | |
| 4 | Redistribution and use in source and binary forms, with or without |
| 5 | modification, are permitted provided that the following conditions are |
| 6 | met: |
| 7 | * Redistributions of source code must retain the above copyright |
| 8 | notice, this list of conditions and the following disclaimer. |
| 9 | * Redistributions in binary form must reproduce the above |
| 10 | copyright notice, this list of conditions and the following |
| 11 | disclaimer in the documentation and/or other materials provided |
| 12 | with the distribution. |
| 13 | * Neither the name of The Linux Foundation nor the names of its |
| 14 | contributors may be used to endorse or promote products derived |
| 15 | from this software without specific prior written permission. |
| 16 | |
| 17 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 21 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 26 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 27 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | --------------------------------------------------------------------------*/ |
| 29 | |
| 30 | #ifndef EAP_PROXY_QMI_H |
| 31 | #define EAP_PROXY_QMI_H |
| 32 | |
| 33 | |
| 34 | #include "eap_i.h" |
| 35 | #include "eap_config.h" |
| 36 | #include "eloop.h" |
| 37 | #include "eapol_supp/eapol_supp_sm.h" |
| 38 | #include "user_identity_module_v01.h" |
| 39 | |
| 40 | /*msec Response Timeout*/ |
| 41 | #define QMI_RESP_TIME_OUT 2000 |
| 42 | #define EAP_PROXY_KEYING_DATA_LEN 64 |
| 43 | |
| 44 | #ifdef CONFIG_EAP_PROXY_DUAL_SIM |
| 45 | #define MAX_NO_OF_SIM_SUPPORTED 2 |
| 46 | #else |
| 47 | #define MAX_NO_OF_SIM_SUPPORTED 1 |
| 48 | #endif /* CONFIG_EAP_PROXY_DUAL_SIM */ |
| 49 | |
| 50 | typedef enum { |
| 51 | QMI_STATE_IDLE = 0x00, |
| 52 | QMI_STATE_RESP_PENDING = 0x01, |
| 53 | QMI_STATE_RESP_RECEIVED = 0x02, |
| 54 | QMI_STATE_RESP_TIME_OUT = 0x03 |
| 55 | } qmi_state_e; |
| 56 | |
| 57 | typedef enum { |
| 58 | EAP_PROXY_QMI_SRVC_NO_RESULT, |
| 59 | EAP_PROXY_QMI_SRVC_SUCCESS, |
| 60 | EAP_PROXY_QMI_SRVC_FAILURE |
| 61 | } eap_proxy_qmi_srv_result; |
| 62 | |
| 63 | /* should match the EAP_state of eap_i.h */ |
| 64 | typedef enum { |
| 65 | EAP_PROXY_INITIALIZE, EAP_PROXY_DISABLED, EAP_PROXY_IDLE, EAP_PROXY_RECEIVED, |
| 66 | EAP_PROXY_GET_METHOD, EAP_PROXY_METHOD, EAP_PROXY_SEND_RESPONSE, |
| 67 | EAP_PROXY_DISCARD, EAP_PROXY_IDENTITY, EAP_PROXY_NOTIFICATION, |
| 68 | EAP_PROXY_RETRANSMIT, |
| 69 | EAP_PROXY_AUTH_SUCCESS, EAP_PROXY_AUTH_FAILURE |
| 70 | } eap_proxy_state; |
| 71 | |
Veerendranath Jakkam | ed6ac3f | 2018-04-18 00:03:06 +0530 | [diff] [blame] | 72 | typedef enum { |
| 73 | EAP_IDENTITY_ANNONYMOUS = 0x00, |
| 74 | EAP_IDENTITY_IMSI_RAW = 0x02, |
| 75 | EAP_IDENTITY_IMSI_3GPP_REALM = 0x03, |
| 76 | EAP_IDENTITY_IMSI_REALM = 0x04, |
| 77 | EAP_IDENTITY_CFG_RAW = 0x05, |
| 78 | EAP_IDENTITY_CFG_3GPP_REALM = 0x06, |
| 79 | EAP_IDENTITY_CFG_REALM = 0x07, |
| 80 | } eap_identity_format_e; |
| 81 | |
| 82 | typedef union |
| 83 | { |
| 84 | struct |
| 85 | { |
| 86 | void *resp_data; /* Pointer to the Response Packet*/ |
| 87 | unsigned long length; /*Length of the Response Packet*/ |
| 88 | }eap_send_pkt_resp; |
| 89 | |
| 90 | }qmi_eap_sync_rsp_data_type; |
| 91 | |
| 92 | typedef struct { |
| 93 | uim_card_state_enum_v01 card_state; |
| 94 | uim_card_error_code_enum_v01 card_error_code; |
| 95 | u8 app_state; |
| 96 | u8 app_type; |
| 97 | } wpa_uim_card_info_type; |
| 98 | |
| 99 | typedef struct { |
| 100 | int card_ready_idx; |
| 101 | wpa_uim_card_info_type card_info[QMI_UIM_CARDS_MAX_V01]; |
| 102 | qmi_client_type qmi_uim_svc_client_ptr; |
| 103 | int qmi_msg_lib_handle; |
| 104 | } wpa_uim_struct_type; |
| 105 | |
Purushottam Kushwaha | 05c5ce3 | 2019-07-24 19:36:53 +0530 | [diff] [blame] | 106 | struct qmi_cb_data { |
| 107 | struct dl_list list; |
| 108 | |
| 109 | /* Common data for a QMI callback */ |
| 110 | qmi_client_type userHandle; |
| 111 | unsigned int msg_id; |
| 112 | void *buf; |
| 113 | unsigned int buflen; |
| 114 | void *userdata; |
Purushottam Kushwaha | bde2d8f | 2021-01-29 16:08:36 +0530 | [diff] [blame] | 115 | eloop_timeout_handler handler; |
Purushottam Kushwaha | 05c5ce3 | 2019-07-24 19:36:53 +0530 | [diff] [blame] | 116 | |
| 117 | /* additional data for eap_reply */ |
| 118 | qmi_client_error_type err_code; |
| 119 | }; |
Veerendranath Jakkam | ed6ac3f | 2018-04-18 00:03:06 +0530 | [diff] [blame] | 120 | |
Purushottam Kushwaha | 23bf418 | 2019-09-11 11:51:00 +0530 | [diff] [blame] | 121 | typedef enum { |
| 122 | EAP_PROXY_MODEM_UNKNOWN = 0x00, |
| 123 | EAP_PROXY_MODEM_UIM_UP = 0x01, |
| 124 | EAP_PROXY_MODEM_AUTH_UP = 0x02, |
| 125 | EAP_PROXY_MODEM_FULL_UP = 0x03, |
| 126 | } qmi_modem_state; |
| 127 | |
Veerendranath Jakkam | ed6ac3f | 2018-04-18 00:03:06 +0530 | [diff] [blame] | 128 | struct eap_proxy_sm { |
| 129 | qmi_client_type qmi_auth_svc_client_ptr[MAX_NO_OF_SIM_SUPPORTED]; |
| 130 | qmi_state_e qmi_state; |
| 131 | eap_proxy_qmi_srv_result srvc_result; |
| 132 | qmi_eap_sync_rsp_data_type qmi_resp_data; |
| 133 | eap_proxy_state proxy_state; |
Steven Laver | 17a3f92 | 2020-05-01 16:13:59 -0700 | [diff] [blame] | 134 | bool iskey_valid; |
Veerendranath Jakkam | ed6ac3f | 2018-04-18 00:03:06 +0530 | [diff] [blame] | 135 | u8 *key; |
Steven Laver | 17a3f92 | 2020-05-01 16:13:59 -0700 | [diff] [blame] | 136 | bool is_state_changed; |
Veerendranath Jakkam | ed6ac3f | 2018-04-18 00:03:06 +0530 | [diff] [blame] | 137 | void *ctx; |
| 138 | void *msg_ctx; |
| 139 | struct eapol_callbacks *eapol_cb; |
| 140 | u8 *eapReqData; |
| 141 | size_t eapReqDataLen; |
Steven Laver | 17a3f92 | 2020-05-01 16:13:59 -0700 | [diff] [blame] | 142 | bool isEap; |
Veerendranath Jakkam | ed6ac3f | 2018-04-18 00:03:06 +0530 | [diff] [blame] | 143 | int eap_type; |
| 144 | int user_selected_sim; |
| 145 | int eap_auth_session_flag[MAX_NO_OF_SIM_SUPPORTED]; |
| 146 | int notification_code; |
| 147 | pthread_t thread_id; |
| 148 | wpa_uim_struct_type wpa_uim[MAX_NO_OF_SIM_SUPPORTED]; |
Steven Laver | 17a3f92 | 2020-05-01 16:13:59 -0700 | [diff] [blame] | 149 | bool qmi_uim_svc_client_initialized[MAX_NO_OF_SIM_SUPPORTED]; |
| 150 | bool qmi_thread_joined; |
Veerendranath Jakkam | ed6ac3f | 2018-04-18 00:03:06 +0530 | [diff] [blame] | 151 | u8 *session_id; |
| 152 | size_t session_id_len; |
| 153 | u8 *emsk; |
Purushottam Kushwaha | 597696f | 2019-06-21 18:40:22 +0530 | [diff] [blame] | 154 | // To check if eap_proxy_sm for curernt interface is initialized/in use |
Steven Laver | 17a3f92 | 2020-05-01 16:13:59 -0700 | [diff] [blame] | 155 | bool initialized; |
Purushottam Kushwaha | 05c5ce3 | 2019-07-24 19:36:53 +0530 | [diff] [blame] | 156 | /* list to maintain qmi_cb_data list */ |
| 157 | struct dl_list callback; |
Purushottam Kushwaha | 23bf418 | 2019-09-11 11:51:00 +0530 | [diff] [blame] | 158 | // To trigger initialization post SSR based on modem UP state. |
| 159 | qmi_modem_state modem_state; |
| 160 | qmi_client_os_params uim_notifier_os_params; |
| 161 | qmi_client_os_params auth_notifier_os_params; |
| 162 | qmi_client_type uim_notifier_handle; |
| 163 | qmi_client_type auth_notifier_handle; |
Steven Laver | 17a3f92 | 2020-05-01 16:13:59 -0700 | [diff] [blame] | 164 | bool notifier_cb_initialized; |
zhangjie | a0af66e | 2023-06-25 09:42:14 +0800 | [diff] [blame] | 165 | // To store the PPID of eap_proxy init caller |
| 166 | pid_t init_ppid; |
Veerendranath Jakkam | ed6ac3f | 2018-04-18 00:03:06 +0530 | [diff] [blame] | 167 | }; |
| 168 | |
| 169 | int eap_proxy_allowed_method(struct eap_peer_config *config, int vendor, |
| 170 | u32 method); |
| 171 | |
| 172 | #endif /* EAP_PROXY_QMI_H */ |