blob: d0ce842e9eeeb706dabbc9adf2b74b83a23cfe52 [file] [log] [blame]
Veerendranath Jakkamed6ac3f2018-04-18 00:03:06 +05301/*--------------------------------------------------------------------------
2Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
3
4Redistribution and use in source and binary forms, with or without
5modification, are permitted provided that the following conditions are
6met:
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
17THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27IF 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
50typedef 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
57typedef 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 */
64typedef 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 Jakkamed6ac3f2018-04-18 00:03:06 +053072typedef 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
82typedef 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
92typedef 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
99typedef 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 Kushwaha05c5ce32019-07-24 19:36:53 +0530106struct 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 Kushwahabde2d8f2021-01-29 16:08:36 +0530115 eloop_timeout_handler handler;
Purushottam Kushwaha05c5ce32019-07-24 19:36:53 +0530116
117 /* additional data for eap_reply */
118 qmi_client_error_type err_code;
119};
Veerendranath Jakkamed6ac3f2018-04-18 00:03:06 +0530120
Purushottam Kushwaha23bf4182019-09-11 11:51:00 +0530121typedef 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 Jakkamed6ac3f2018-04-18 00:03:06 +0530128struct 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 Laver17a3f922020-05-01 16:13:59 -0700134 bool iskey_valid;
Veerendranath Jakkamed6ac3f2018-04-18 00:03:06 +0530135 u8 *key;
Steven Laver17a3f922020-05-01 16:13:59 -0700136 bool is_state_changed;
Veerendranath Jakkamed6ac3f2018-04-18 00:03:06 +0530137 void *ctx;
138 void *msg_ctx;
139 struct eapol_callbacks *eapol_cb;
140 u8 *eapReqData;
141 size_t eapReqDataLen;
Steven Laver17a3f922020-05-01 16:13:59 -0700142 bool isEap;
Veerendranath Jakkamed6ac3f2018-04-18 00:03:06 +0530143 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 Laver17a3f922020-05-01 16:13:59 -0700149 bool qmi_uim_svc_client_initialized[MAX_NO_OF_SIM_SUPPORTED];
150 bool qmi_thread_joined;
Veerendranath Jakkamed6ac3f2018-04-18 00:03:06 +0530151 u8 *session_id;
152 size_t session_id_len;
153 u8 *emsk;
Purushottam Kushwaha597696f2019-06-21 18:40:22 +0530154 // To check if eap_proxy_sm for curernt interface is initialized/in use
Steven Laver17a3f922020-05-01 16:13:59 -0700155 bool initialized;
Purushottam Kushwaha05c5ce32019-07-24 19:36:53 +0530156 /* list to maintain qmi_cb_data list */
157 struct dl_list callback;
Purushottam Kushwaha23bf4182019-09-11 11:51:00 +0530158 // 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 Laver17a3f922020-05-01 16:13:59 -0700164 bool notifier_cb_initialized;
zhangjiea0af66e2023-06-25 09:42:14 +0800165 // To store the PPID of eap_proxy init caller
166 pid_t init_ppid;
Veerendranath Jakkamed6ac3f2018-04-18 00:03:06 +0530167};
168
169int eap_proxy_allowed_method(struct eap_peer_config *config, int vendor,
170 u32 method);
171
172#endif /* EAP_PROXY_QMI_H */