15738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************
25738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
35738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  Copyright (C) 2003-2012 Broadcom Corporation
45738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
55738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  Licensed under the Apache License, Version 2.0 (the "License");
65738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  you may not use this file except in compliance with the License.
75738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  You may obtain a copy of the License at:
85738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
95738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  http://www.apache.org/licenses/LICENSE-2.0
105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  Unless required by applicable law or agreed to in writing, software
125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  distributed under the License is distributed on an "AS IS" BASIS,
135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  See the License for the specific language governing permissions and
155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  limitations under the License.
165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/
185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bt_target.h"
205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if SMP_INCLUDED == TRUE
225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
23444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji#include <string.h>
24444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji#include "smp_int.h"
255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
26444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojiconst char *const smp_state_name [] =
275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
28444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SMP_STATE_IDLE",
29444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SMP_STATE_WAIT_APP_RSP",
30444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SMP_STATE_SEC_REQ_PENDING",
31444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SMP_STATE_PAIR_REQ_RSP",
32444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SMP_STATE_WAIT_CONFIRM",
33444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SMP_STATE_CONFIRM",
34444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SMP_STATE_RAND",
35444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SMP_STATE_PUBLIC_KEY_EXCH",
36444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SMP_STATE_SEC_CONN_PHS1_START",
37444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SMP_STATE_WAIT_COMMITMENT",
38444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SMP_STATE_WAIT_NONCE",
39444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SMP_STATE_SEC_CONN_PHS2_START",
40444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SMP_STATE_WAIT_DHK_CHECK",
41444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SMP_STATE_DHK_CHECK",
42444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SMP_STATE_ENCRYPTION_PENDING",
43444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SMP_STATE_BOND_PENDING",
44444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SMP_STATE_CREATE_LOCAL_SEC_CONN_OOB_DATA",
45444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SMP_STATE_MAX"
465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project};
47444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
48444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojiconst char *const smp_event_name [] =
495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "PAIRING_REQ_EVT",
515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "PAIRING_RSP_EVT",
525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "CONFIRM_EVT",
535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "RAND_EVT",
545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "PAIRING_FAILED_EVT",
555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "ENC_INFO_EVT",
565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "MASTER_ID_EVT",
575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "ID_INFO_EVT",
585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "ID_ADDR_EVT",
595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "SIGN_INFO_EVT",
605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "SECURITY_REQ_EVT",
61444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "PAIR_PUBLIC_KEY_EVT",
62444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "PAIR_DHKEY_CHECK_EVT",
63444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "PAIR_KEYPRESS_NOTIFICATION_EVT",
64444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "PAIR_COMMITMENT_EVT",
655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "KEY_READY_EVT",
665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "ENCRYPTED_EVT",
675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "L2CAP_CONN_EVT",
685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "L2CAP_DISCONN_EVT",
695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "API_IO_RSP_EVT",
705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "API_SEC_GRANT_EVT",
715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "TK_REQ_EVT",
725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "AUTH_CMPL_EVT",
735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "ENC_REQ_EVT",
745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "BOND_REQ_EVT",
755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    "DISCARD_SEC_REQ_EVT",
76444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "PUBLIC_KEY_EXCHANGE_REQ_EVT",
77444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "LOCAL_PUBLIC_KEY_CRTD_EVT",
78444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "BOTH_PUBLIC_KEYS_RCVD_EVT",
79444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SEC_CONN_DHKEY_COMPLETE_EVT",
80444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "HAVE_LOCAL_NONCE_EVT",
81444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SEC_CONN_PHASE1_CMPLT_EVT",
82444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SEC_CONN_CALC_NC_EVT",
83444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SEC_CONN_DISPLAY_NC_EVT",
84444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SEC_CONN_OK_EVT",
85444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SEC_CONN_2_DHCK_CHECKS_PRESENT_EVT",
86444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SEC_CONN_KEY_READY_EVT",
87444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "KEYPRESS_NOTIFICATION_EVT",
88444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "SEC_CONN_OOB_DATA_EVT",
89444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "CREATE_LOCAL_SEC_CONN_OOB_DATA_EVT",
90444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    "OUT_OF_RANGE_EVT"
915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project};
925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
93444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojiconst char *smp_get_event_name(tSMP_EVENT event);
94444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojiconst char *smp_get_state_name(tSMP_STATE state);
95444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
96444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji#define SMP_SM_IGNORE       0
97444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji#define SMP_NUM_ACTIONS     2
98444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji#define SMP_SME_NEXT_STATE  2
99444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji#define SMP_SM_NUM_COLS     3
100444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
101444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojitypedef const UINT8(*tSMP_SM_TBL)[SMP_SM_NUM_COLS];
1025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectenum
1045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
1055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_PROC_SEC_REQ,
1065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_SEND_PAIR_REQ,
1075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_SEND_PAIR_RSP,
1085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_SEND_CONFIRM,
1095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_SEND_PAIR_FAIL,
110444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_SEND_RAND,
111444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_SEND_ENC_INFO,
1125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_SEND_ID_INFO,
1135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_SEND_LTK_REPLY,
1145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_PROC_PAIR_CMD,
1155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_PROC_PAIR_FAIL,
1165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_PROC_CONFIRM,
117444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_PROC_RAND,
1185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_PROC_ENC_INFO,
1195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_PROC_MASTER_ID,
1205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_PROC_ID_INFO,
1215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_PROC_ID_ADDR,
1225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_PROC_SRK_INFO,
1235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_PROC_SEC_GRANT,
1245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_PROC_SL_KEY,
1255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_PROC_COMPARE,
1265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_PROC_IO_RSP,
1275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_GENERATE_COMPARE,
1285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_GENERATE_CONFIRM,
1295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_GENERATE_STK,
1305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_KEY_DISTRIBUTE,
1315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_START_ENC,
1325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_PAIRING_CMPL,
1335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_DECIDE_ASSO_MODEL,
1345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_SEND_APP_CBACK,
1355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_CHECK_AUTH_REQ,
1365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_PAIR_TERMINATE,
1375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_ENC_CMPL,
1385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_PROC_DISCARD,
139444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_CREATE_PRIVATE_KEY,
140444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_USE_OOB_PRIVATE_KEY,
141444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_SEND_PAIR_PUBLIC_KEY,
142444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_PROCESS_PAIR_PUBLIC_KEY,
143444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_HAVE_BOTH_PUBLIC_KEYS,
144444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_START_SEC_CONN_PHASE1,
145444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_PROCESS_LOCAL_NONCE,
146444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_SEND_COMMITMENT,
147444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_PROCESS_PAIRING_COMMITMENT,
148444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_PROCESS_PEER_NONCE,
149444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_CALCULATE_LOCAL_DHKEY_CHECK,
150444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_SEND_DHKEY_CHECK,
151444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_PROCESS_DHKEY_CHECK,
152444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_CALCULATE_PEER_DHKEY_CHECK,
153444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_MATCH_DHKEY_CHECKS,
154444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_CALCULATE_NUMERIC_COMPARISON_DISPLAY_NUMBER,
155444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_MOVE_TO_SEC_CONN_PHASE2,
156444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_PH2_DHKEY_CHECKS_ARE_PRESENT,
157444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_WAIT_FOR_BOTH_PUBLIC_KEYS,
158444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_START_PASSKEY_VERIFICATION,
159444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_SEND_KEYPRESS_NOTIFICATION,
160444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_PROCESS_KEYPRESS_NOTIFICATION,
161444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_PROCESS_SECURE_CONNECTION_OOB_DATA,
162444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_SET_LOCAL_OOB_KEYS,
163444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    SMP_SET_LOCAL_OOB_RAND_COMMITMENT,
1648fe58875ce67c6e1099e7ba2339dcd2b979491b0Ganesh Ganapathi Batta    SMP_IDLE_TERMINATE,
1658fe58875ce67c6e1099e7ba2339dcd2b979491b0Ganesh Ganapathi Batta    SMP_FAST_CONN_PARAM,
1665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    SMP_SM_NO_ACTION
1675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project};
1685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic const tSMP_ACT smp_sm_action[] =
1705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
1715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_proc_sec_req,
1725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_send_pair_req,
1735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_send_pair_rsp,
1745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_send_confirm,
1755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_send_pair_fail,
176444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_send_rand,
1775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_send_enc_info,
1785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_send_id_info,
1795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_send_ltk_reply,
1805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_proc_pair_cmd,
1815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_proc_pair_fail,
1825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_proc_confirm,
183444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_proc_rand,
1845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_proc_enc_info,
1855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_proc_master_id,
1865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_proc_id_info,
1875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_proc_id_addr,
1885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_proc_srk_info,
1895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_proc_sec_grant,
1905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_proc_sl_key,
1915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_proc_compare,
192444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_process_io_response,
1935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_generate_compare,
194444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_generate_srand_mrand_confirm,
1955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_generate_stk,
1965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_key_distribution,
1975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_start_enc,
1985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_pairing_cmpl,
199444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_decide_association_model,
2005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_send_app_cback,
2015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_check_auth_req,
2025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_pair_terminate,
2035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_enc_cmpl,
2045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_proc_discard,
205444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_create_private_key,
206444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_use_oob_private_key,
207444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_send_pair_public_key,
208444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_process_pairing_public_key,
209444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_both_have_public_keys,
210444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_start_secure_connection_phase1,
211444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_process_local_nonce,
212444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_send_commitment,
213444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_process_pairing_commitment,
214444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_process_peer_nonce,
215444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_calculate_local_dhkey_check,
216444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_send_dhkey_check,
217444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_process_dhkey_check,
218444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_calculate_peer_dhkey_check,
219444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_match_dhkey_checks,
220444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_calculate_numeric_comparison_display_number,
221444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_move_to_secure_connections_phase2,
222444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_phase_2_dhkey_checks_are_present,
223444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_wait_for_both_public_keys,
224444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_start_passkey_verification,
225444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_send_keypress_notification,
226444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_process_keypress_notification,
227444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_process_secure_connection_oob_data,
228444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_set_local_oob_keys,
229444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_set_local_oob_random_commitment,
2308fe58875ce67c6e1099e7ba2339dcd2b979491b0Ganesh Ganapathi Batta    smp_idle_terminate,
2318fe58875ce67c6e1099e7ba2339dcd2b979491b0Ganesh Ganapathi Batta    smp_fast_conn_param
2325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project};
233444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
2345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/************ SMP Master FSM State/Event Indirection Table **************/
235444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_master_entry_map[][SMP_STATE_MAX] =
236444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
237444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* state name:             Idle WaitApp SecReq Pair   Wait Confirm Rand PublKey SCPhs1  Wait  Wait  SCPhs2  Wait   DHKChk Enc   Bond  CrLocSc
238444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji                                 Rsp    Pend   ReqRsp Cfm               Exch    Strt    Cmtm  Nonce Strt    DHKChk        Pend  Pend  OobData   */
239444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_REQ             */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
240444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_RSP             */{ 0,    0,     0,      1,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
241444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* CONFIRM              */{ 0,    0,     0,      0,     0,   1,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
242444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* RAND                 */{ 0,    0,     0,      0,     0,   0,    1,   0,      0,      0,    1,    0,      0,     0,     0,    0,     0   },
243444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_FAIL            */{ 0,    0x81,  0,      0x81,  0x81,0x81, 0x81,0x81,   0x81,   0x81, 0x81, 0x81,   0x81,  0x81,  0,    0,     0   },
244444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ENC_INFO             */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    1,     0   },
245444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* MASTER_ID            */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    4,     0   },
246444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ID_INFO              */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    2,     0   },
247444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ID_ADDR              */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    5,     0   },
248444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SIGN_INFO            */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    3,     0   },
249444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SEC_REQ              */{ 2,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
250444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_PUBLIC_KEY      */{ 0,    0,     0,      0,     0,   0,    0,   2,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
251444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_DHKEY_CHCK      */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      1,     0,     0,    0,     0   },
252444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_KEYPR_NOTIF     */{ 0,    8,     0,      0,     0,   0,    0,   0,      5,      2,    0,    0,      0,     0,     0,    0,     0   },
253444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_COMMITM         */{ 0,    0,     0,      0,     0,   0,    0,   0,      6,      1,    0,    0,      0,     0,     0,    0,     0   },
254444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEY_READY            */{ 0,    3,     0,      3,     1,   0,    2,   0,      4,      0,    0,    0,      0,     0,     1,    6,     0   },
255444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ENC_CMPL             */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     2,    0,     0   },
256444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* L2C_CONN             */{ 1,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
257444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* L2C_DISC             */{ 3,    0x83,  0,      0x83,  0x83,0x83, 0x83,0x83,   0x83,   0x83, 0x83, 0x83,   0x83,  0x83,  0x83, 0x83,  0   },
258444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* IO_RSP               */{ 0,    2,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
259444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SEC_GRANT            */{ 0,    1,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
260444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* TK_REQ               */{ 0,    0,     0,      2,     0,   0,    0,   0,      3,      0,    0,    0,      0,     0,     0,    0,     0   },
261444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* AUTH_CMPL            */{ 4,    0x82,  0,      0x82,  0x82,0x82, 0x82,0x82,   0x82,   0x82, 0x82, 0x82,   0x82,  0x82,  0x82, 0x82,  0   },
262444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ENC_REQ              */{ 0,    4,     0,      0,     0,   0,    3,   0,      0,      0,    0,    0,      0,     2,     0,    0,     0   },
263444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* BOND_REQ             */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     3,    0,     0   },
264444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* DISCARD_SEC_REQ      */{ 0,    5,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     3,    0,     0   },
265444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PUBL_KEY_EXCH_REQ    */{ 0,    0,     0,      4,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
266444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* LOC_PUBL_KEY_CRTD    */{ 0,    0,     0,      0,     0,   0,    0,   1,      0,      0,    0,    0,      0,     0,     0,    0,     1   },
267444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* BOTH_PUBL_KEYS_RCVD  */{ 0,    0,     0,      0,     0,   0,    0,   3,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
268444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_DHKEY_CMPLT       */{ 0,    0,     0,      0,     0,   0,    0,   0,      1,      0,    0,    0,      0,     0,     0,    0,     0   },
269444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* HAVE_LOC_NONCE       */{ 0,    0,     0,      0,     0,   0,    0,   0,      2,      0,    0,    0,      0,     0,     0,    0,     2   },
270444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_PHASE1_CMPLT      */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    1,      0,     0,     0,    0,     0   },
271444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_CALC_NC           */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    2,    0,      0,     0,     0,    0,     0   },
272444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_DSPL_NC           */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    3,    0,      0,     0,     0,    0,     0   },
273444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_NC_OK             */{ 0,    6,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
274444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_2_DHCK_CHKS_PRES  */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
275444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_KEY_READY         */{ 0,    7,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     1,     0,    0,     0   },
276444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEYPR_NOTIF          */{ 0,    9,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
277444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_OOB_DATA          */{ 0,    10,    0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
278444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* CR_LOC_SC_OOB_DATA   */{ 5,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
279444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
280444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
281444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_all_table[][SMP_SM_NUM_COLS] =
282444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
283444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                       Event                     Action                 Next State */
284444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_FAIL */          {SMP_PROC_PAIR_FAIL,      SMP_PAIRING_CMPL, SMP_STATE_IDLE},
285444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* AUTH_CMPL */          {SMP_SEND_PAIR_FAIL,      SMP_PAIRING_CMPL, SMP_STATE_IDLE},
286444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* L2C_DISC  */          {SMP_PAIR_TERMINATE,      SMP_SM_NO_ACTION, SMP_STATE_IDLE}
287444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
288444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
289444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_master_idle_table[][SMP_SM_NUM_COLS] =
290444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
291444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                   Event                  Action               Next State */
292444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* L2C_CONN */      {SMP_SEND_APP_CBACK,     SMP_SM_NO_ACTION,   SMP_STATE_WAIT_APP_RSP},
293444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SEC_REQ  */      {SMP_PROC_SEC_REQ,       SMP_SEND_APP_CBACK, SMP_STATE_WAIT_APP_RSP},
294444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* L2C_DISC  */     {SMP_IDLE_TERMINATE,     SMP_SM_NO_ACTION, SMP_STATE_IDLE},
295444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* AUTH_CMPL */     {SMP_PAIRING_CMPL,       SMP_SM_NO_ACTION, SMP_STATE_IDLE}
296444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* CR_LOC_SC_OOB_DATA   */ ,{SMP_CREATE_PRIVATE_KEY, SMP_SM_NO_ACTION, SMP_STATE_CREATE_LOCAL_SEC_CONN_OOB_DATA}
297444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
298444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
299444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
300444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_master_wait_for_app_response_table[][SMP_SM_NUM_COLS] =
301444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
302444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                            Event                Action               Next State */
303444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SEC_GRANT            */ {SMP_PROC_SEC_GRANT, SMP_SEND_APP_CBACK, SMP_STATE_WAIT_APP_RSP},
304444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* IO_RSP               */ {SMP_SEND_PAIR_REQ, SMP_FAST_CONN_PARAM, SMP_STATE_PAIR_REQ_RSP},
305444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
306444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji                    /* TK ready */
307444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEY_READY            */ {SMP_GENERATE_CONFIRM, SMP_SM_NO_ACTION,   SMP_STATE_WAIT_CONFIRM},
308444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
309444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji                    /* start enc mode setup */
310444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ENC_REQ              */ { SMP_START_ENC, SMP_FAST_CONN_PARAM, SMP_STATE_ENCRYPTION_PENDING},
311444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* DISCARD_SEC_REQ      */ { SMP_PROC_DISCARD, SMP_SM_NO_ACTION, SMP_STATE_IDLE}
312444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* user confirms NC 'OK', i.e. phase 1 is completed */
313444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_NC_OK             */,{ SMP_MOVE_TO_SEC_CONN_PHASE2, SMP_SM_NO_ACTION, SMP_STATE_SEC_CONN_PHS2_START},
314444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* user-provided passkey is rcvd */
315444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_KEY_READY  */ { SMP_START_PASSKEY_VERIFICATION, SMP_SM_NO_ACTION, SMP_STATE_SEC_CONN_PHS1_START},
316444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_KEYPR_NOTIF */ { SMP_PROCESS_KEYPRESS_NOTIFICATION, SMP_SEND_APP_CBACK, SMP_STATE_WAIT_APP_RSP},
317444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEYPR_NOTIF          */ { SMP_SEND_KEYPRESS_NOTIFICATION, SMP_SM_NO_ACTION, SMP_STATE_WAIT_APP_RSP},
318444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_OOB_DATA      */ { SMP_USE_OOB_PRIVATE_KEY, SMP_SM_NO_ACTION, SMP_STATE_PUBLIC_KEY_EXCH}
319444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
320444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
321444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_master_pair_request_response_table[][SMP_SM_NUM_COLS] =
322444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
323444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*               Event                  Action                  Next State */
324444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_RSP */ { SMP_PROC_PAIR_CMD,     SMP_SM_NO_ACTION, SMP_STATE_PAIR_REQ_RSP},
325444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* TK_REQ   */ { SMP_SEND_APP_CBACK,    SMP_SM_NO_ACTION, SMP_STATE_WAIT_APP_RSP},
326444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
327444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji                    /* TK ready */
328444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEY_READY */{ SMP_GENERATE_CONFIRM,  SMP_SM_NO_ACTION, SMP_STATE_WAIT_CONFIRM}
329444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PUBL_KEY_EXCH_REQ    */,{ SMP_CREATE_PRIVATE_KEY, SMP_SM_NO_ACTION, SMP_STATE_PUBLIC_KEY_EXCH}
330444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
331444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
332444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_master_wait_for_confirm_table[][SMP_SM_NUM_COLS] =
333444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
334444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*              Event                   Action          Next State */
335444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEY_READY*/ {SMP_SEND_CONFIRM,     SMP_SM_NO_ACTION, SMP_STATE_CONFIRM}/* CONFIRM ready */
336444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
337444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
338444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_master_confirm_table[][SMP_SM_NUM_COLS] =
339444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
340444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*               Event                  Action                 Next State */
341444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* CONFIRM  */ { SMP_PROC_CONFIRM, SMP_SEND_RAND, SMP_STATE_RAND}
342444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
343444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
344444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_master_rand_table[][SMP_SM_NUM_COLS] =
345444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
346444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*               Event                  Action                   Next State */
347444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* RAND     */ { SMP_PROC_RAND,         SMP_GENERATE_COMPARE, SMP_STATE_RAND},
348444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEY_READY*/ { SMP_PROC_COMPARE,      SMP_SM_NO_ACTION,   SMP_STATE_RAND},  /* Compare ready */
349444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ENC_REQ  */ { SMP_GENERATE_STK,      SMP_SM_NO_ACTION, SMP_STATE_ENCRYPTION_PENDING}
350444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
351444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
352444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_master_public_key_exchange_table[][SMP_SM_NUM_COLS] =
353444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
354444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                        Action              Next State */
355444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* LOC_PUBL_KEY_CRTD    */{ SMP_SEND_PAIR_PUBLIC_KEY, SMP_SM_NO_ACTION, SMP_STATE_PUBLIC_KEY_EXCH},
356444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_PUBLIC_KEY      */{ SMP_PROCESS_PAIR_PUBLIC_KEY, SMP_SM_NO_ACTION, SMP_STATE_PUBLIC_KEY_EXCH},
357444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* BOTH_PUBL_KEYS_RCVD  */{ SMP_HAVE_BOTH_PUBLIC_KEYS, SMP_SM_NO_ACTION, SMP_STATE_SEC_CONN_PHS1_START},
358444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
359444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
360444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_master_sec_conn_phs1_start_table[][SMP_SM_NUM_COLS] =
361444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
362444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                Next State */
363444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_DHKEY_CMPLT       */{ SMP_START_SEC_CONN_PHASE1, SMP_SM_NO_ACTION, SMP_STATE_SEC_CONN_PHS1_START},
364444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* HAVE_LOC_NONCE       */{ SMP_PROCESS_LOCAL_NONCE, SMP_SM_NO_ACTION, SMP_STATE_WAIT_COMMITMENT},
365444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* TK_REQ               */{ SMP_SEND_APP_CBACK,    SMP_SM_NO_ACTION, SMP_STATE_WAIT_APP_RSP},
366444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SMP_MODEL_SEC_CONN_PASSKEY_DISP model, passkey is sent up to display,*/
367444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* It's time to start commitment calculation */
368444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEY_READY            */{ SMP_START_PASSKEY_VERIFICATION, SMP_SM_NO_ACTION, SMP_STATE_SEC_CONN_PHS1_START},
369444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_KEYPR_NOTIF  */{ SMP_PROCESS_KEYPRESS_NOTIFICATION,  SMP_SEND_APP_CBACK, SMP_STATE_SEC_CONN_PHS1_START},
370444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_COMMITM  */{ SMP_PROCESS_PAIRING_COMMITMENT, SMP_SM_NO_ACTION, SMP_STATE_SEC_CONN_PHS1_START},
371444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
372444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
373444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_master_wait_commitment_table[][SMP_SM_NUM_COLS] =
374444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
375444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
376444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_COMMITM         */{ SMP_PROCESS_PAIRING_COMMITMENT, SMP_SEND_RAND, SMP_STATE_WAIT_NONCE},
377444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_KEYPR_NOTIF */{ SMP_PROCESS_KEYPRESS_NOTIFICATION, SMP_SEND_APP_CBACK, SMP_STATE_WAIT_COMMITMENT},
378444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
379444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
380444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_master_wait_nonce_table[][SMP_SM_NUM_COLS] =
381444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
382444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
383444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* peer nonce is received */
384444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* RAND                 */{SMP_PROC_RAND,  SMP_PROCESS_PEER_NONCE, SMP_STATE_SEC_CONN_PHS2_START},
385444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* NC model, time to calculate number for NC */
386444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_CALC_NC           */{SMP_CALCULATE_NUMERIC_COMPARISON_DISPLAY_NUMBER, SMP_SM_NO_ACTION, SMP_STATE_WAIT_NONCE},
387444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* NC model, time to display calculated number for NC to the user */
388444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_DSPL_NC           */{SMP_SEND_APP_CBACK, SMP_SM_NO_ACTION, SMP_STATE_WAIT_APP_RSP},
389444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
390444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
391444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_master_sec_conn_phs2_start_table[][SMP_SM_NUM_COLS] =
392444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
393444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
394444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_PHASE1_CMPLT */{SMP_CALCULATE_LOCAL_DHKEY_CHECK, SMP_SEND_DHKEY_CHECK, SMP_STATE_WAIT_DHK_CHECK},
395444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
396444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
397444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_master_wait_dhk_check_table[][SMP_SM_NUM_COLS] =
398444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
399444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
400444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_DHKEY_CHCK  */{SMP_PROCESS_DHKEY_CHECK, SMP_CALCULATE_PEER_DHKEY_CHECK, SMP_STATE_DHK_CHECK},
401444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
402444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
403444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_master_dhk_check_table[][SMP_SM_NUM_COLS] =
404444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
405444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
406444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* locally calculated peer dhkey check is ready -> compare it withs DHKey Check actually received from peer */
407444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_KEY_READY         */{SMP_MATCH_DHKEY_CHECKS, SMP_SM_NO_ACTION, SMP_STATE_DHK_CHECK},
408444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* locally calculated peer dhkey check is ready -> calculate STK, go to sending */
409444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* HCI LE Start Encryption command */
410444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ENC_REQ              */{SMP_GENERATE_STK, SMP_SM_NO_ACTION, SMP_STATE_ENCRYPTION_PENDING},
411444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
412444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
413444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_master_enc_pending_table[][SMP_SM_NUM_COLS] =
414444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
415444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
416444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* STK ready */
417444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEY_READY */ { SMP_START_ENC,        SMP_SM_NO_ACTION, SMP_STATE_ENCRYPTION_PENDING},
418444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ENCRYPTED */ { SMP_CHECK_AUTH_REQ,   SMP_SM_NO_ACTION, SMP_STATE_ENCRYPTION_PENDING},
419444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* BOND_REQ  */ { SMP_KEY_DISTRIBUTE,   SMP_SM_NO_ACTION, SMP_STATE_BOND_PENDING}
420444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
421444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_master_bond_pending_table[][SMP_SM_NUM_COLS] =
422444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
423444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
424444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ENC_INFO */ { SMP_PROC_ENC_INFO,     SMP_SM_NO_ACTION, SMP_STATE_BOND_PENDING},
425444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ID_INFO  */ { SMP_PROC_ID_INFO,      SMP_SM_NO_ACTION, SMP_STATE_BOND_PENDING},
426444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SIGN_INFO*/ { SMP_PROC_SRK_INFO,     SMP_SM_NO_ACTION, SMP_STATE_BOND_PENDING},
427444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* MASTER_ID*/ { SMP_PROC_MASTER_ID,    SMP_SM_NO_ACTION, SMP_STATE_BOND_PENDING},
428444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ID_ADDR  */ { SMP_PROC_ID_ADDR,      SMP_SM_NO_ACTION, SMP_STATE_BOND_PENDING},
429444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEY_READY */{SMP_SEND_ENC_INFO,      SMP_SM_NO_ACTION, SMP_STATE_BOND_PENDING} /* LTK ready */
430444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
431444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
432444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_master_create_local_sec_conn_oob_data[][SMP_SM_NUM_COLS] =
433444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
434444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                       Event                   Action            Next State */
435444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* LOC_PUBL_KEY_CRTD */ {SMP_SET_LOCAL_OOB_KEYS,   SMP_SM_NO_ACTION, SMP_STATE_CREATE_LOCAL_SEC_CONN_OOB_DATA},
436444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* HAVE_LOC_NONCE    */ {SMP_SET_LOCAL_OOB_RAND_COMMITMENT, SMP_SM_NO_ACTION, SMP_STATE_IDLE}
4375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project};
4385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
4395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
4405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/************ SMP Slave FSM State/Event Indirection Table **************/
441444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_slave_entry_map[][SMP_STATE_MAX] =
442444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
443444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* state name:             Idle WaitApp SecReq Pair   Wait Confirm Rand PublKey SCPhs1  Wait  Wait  SCPhs2  Wait   DHKChk Enc   Bond  CrLocSc
444444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji                                 Rsp    Pend   ReqRsp Cfm               Exch    Strt    Cmtm  Nonce Strt    DHKChk        Pend  Pend  OobData   */
445444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_REQ             */{ 2,    0,     1,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
446444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_RSP             */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
447444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* CONFIRM              */{ 0,    4,     0,      1,     1,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
448444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* RAND                 */{ 0,    0,     0,      0,     0,   1,    2,   0,      0,      0,    1,    0,      0,     0,     0,    0,     0   },
449444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_FAIL            */{ 0,    0x81,  0x81,   0x81,  0x81,0x81, 0x81,0x81,   0x81,   0x81, 0x81, 0x81,   0x81,  0x81,  0x81, 0,     0   },
450444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ENC_INFO             */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    3,     0   },
451444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* MASTER_ID            */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    5,     0   },
452444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ID_INFO              */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    4,     0   },
453444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ID_ADDR              */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    6,     0   },
454444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SIGN_INFO            */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    2,     0   },
455444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SEC_REQ              */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
456444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_PUBLIC_KEY      */{ 0,    0,     0,      5,     0,   0,    0,   2,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
457444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_DHKEY_CHCK      */{ 0,    5,     0,      0,     0,   0,    0,   0,      0,      0,    0,    2,      1,     2,     0,    0,     0   },
458444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_KEYPR_NOTIF     */{ 0,    9,     0,      0,     0,   0,    0,   0,      5,      2,    0,    0,      0,     0,     0,    0,     0   },
459ea8292eab91f90c7f917252d27aeab2f5a2393e0Nitin Arora/* PAIR_COMMITM         */{ 0,    8,     0,      0,     0,   0,    0,   0,      6,      1,    0,    0,      0,     0,     0,    0,     0   },
460444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEY_READY            */{ 0,    3,     0,      3,     2,   2,    1,   0,      4,      0,    0,    0,      0,     0,     2,    1,     0   },
461444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ENC_CMPL             */{ 0,    0,     2,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     3,    0,     0   },
462444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* L2C_CONN             */{ 1,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
463444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* L2C_DISC             */{ 0,    0x83,  0x83,   0x83,  0x83,0x83, 0x83,0x83,   0x83,   0x83, 0x83, 0x83,   0x83,  0x83,  0x83, 0x83,  0   },
464444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* IO_RSP               */{ 0,    1,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
465444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SEC_GRANT            */{ 0,    2,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
466444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* TK_REQ               */{ 0,    0,     0,      2,     0,   0,    0,   0,      3,      0,    0,    0,      0,     0,     0,    0,     0   },
467444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* AUTH_CMPL            */{ 0,    0x82,  0x82,   0x82,  0x82,0x82, 0x82,0x82,   0x82,   0x82, 0x82, 0x82,   0x82,  0x82,  0x82, 0x82,  0   },
468444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ENC_REQ              */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     1,    0,     0   },
469444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* BOND_REQ             */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     4,    0,     0   },
470444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* DISCARD_SEC_REQ      */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
471444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PUBL_KEY_EXCH_REQ    */{ 0,    0,     0,      4,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
472444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* LOC_PUBL_KEY_CRTD    */{ 0,    0,     0,      0,     0,   0,    0,   1,      0,      0,    0,    0,      0,     0,     0,    0,     1   },
473444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* BOTH_PUBL_KEYS_RCVD  */{ 0,    0,     0,      0,     0,   0,    0,   3,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
474444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_DHKEY_CMPLT       */{ 0,    0,     0,      0,     0,   0,    0,   0,      1,      0,    0,    0,      0,     0,     0,    0,     0   },
475444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* HAVE_LOC_NONCE       */{ 0,    0,     0,      0,     0,   0,    0,   0,      2,      0,    0,    0,      0,     0,     0,    0,     2   },
476444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_PHASE1_CMPLT      */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    1,      0,     0,     0,    0,     0   },
477444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_CALC_NC           */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    2,    0,      0,     0,     0,    0,     0   },
478444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_DSPL_NC           */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    3,    0,      0,     0,     0,    0,     0   },
479444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_NC_OK             */{ 0,    6,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
480444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_2_DHCK_CHKS_PRES  */{ 0,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      2,     0,     0,    0,     0   },
481444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_KEY_READY         */{ 0,    7,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     1,     0,    0,     0   },
482444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEYPR_NOTIF          */{ 0,    10,    0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
483444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_OOB_DATA          */{ 0,    11,    0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
484444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* CR_LOC_SC_OOB_DATA   */{ 3,    0,     0,      0,     0,   0,    0,   0,      0,      0,    0,    0,      0,     0,     0,    0,     0   },
485444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
486444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
487444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_slave_idle_table[][SMP_SM_NUM_COLS] =
488444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
489444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                   Event                 Action                Next State */
490444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* L2C_CONN */      {SMP_SEND_APP_CBACK,  SMP_SM_NO_ACTION,      SMP_STATE_WAIT_APP_RSP},
491444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_REQ */      {SMP_PROC_PAIR_CMD,   SMP_SEND_APP_CBACK,     SMP_STATE_WAIT_APP_RSP}
492444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* CR_LOC_SC_OOB_DATA   */ ,{SMP_CREATE_PRIVATE_KEY, SMP_SM_NO_ACTION, SMP_STATE_CREATE_LOCAL_SEC_CONN_OOB_DATA}
493444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
494444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
495444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_slave_wait_for_app_response_table [][SMP_SM_NUM_COLS] =
496444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
497444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*               Event                   Action                 Next State */
498444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* IO_RSP    */ {SMP_PROC_IO_RSP,       SMP_FAST_CONN_PARAM, SMP_STATE_PAIR_REQ_RSP},
499444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SEC_GRANT */ {SMP_PROC_SEC_GRANT,    SMP_SEND_APP_CBACK, SMP_STATE_WAIT_APP_RSP},
500444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
501444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji                        /* TK ready */
502444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEY_READY */ {SMP_PROC_SL_KEY,   SMP_SM_NO_ACTION, SMP_STATE_WAIT_APP_RSP},
503444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* CONFIRM   */ {SMP_PROC_CONFIRM,   SMP_SM_NO_ACTION, SMP_STATE_CONFIRM}
504444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* DHKey Check from master is received before phase 1 is completed - race */
505444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_DHKEY_CHCK      */,{SMP_PROCESS_DHKEY_CHECK, SMP_SM_NO_ACTION,  SMP_STATE_WAIT_APP_RSP},
506444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* user confirms NC 'OK', i.e. phase 1 is completed */
507444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_NC_OK             */ {SMP_MOVE_TO_SEC_CONN_PHASE2, SMP_SM_NO_ACTION,  SMP_STATE_SEC_CONN_PHS2_START},
508444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* user-provided passkey is rcvd */
509444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_KEY_READY   */ {SMP_START_PASSKEY_VERIFICATION, SMP_SM_NO_ACTION, SMP_STATE_SEC_CONN_PHS1_START},
510444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_COMMITM   */ {SMP_PROCESS_PAIRING_COMMITMENT, SMP_SM_NO_ACTION, SMP_STATE_WAIT_APP_RSP},
511444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_KEYPR_NOTIF */ {SMP_PROCESS_KEYPRESS_NOTIFICATION, SMP_SEND_APP_CBACK, SMP_STATE_WAIT_APP_RSP},
512444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEYPR_NOTIF */ {SMP_SEND_KEYPRESS_NOTIFICATION, SMP_SM_NO_ACTION, SMP_STATE_WAIT_APP_RSP},
513444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_OOB_DATA          */ {SMP_SEND_PAIR_RSP,    SMP_SM_NO_ACTION,    SMP_STATE_PAIR_REQ_RSP},
514444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
515444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
516444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_slave_sec_request_table[][SMP_SM_NUM_COLS] =
517444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
518444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
519444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_REQ */{SMP_PROC_PAIR_CMD,       SMP_SM_NO_ACTION,       SMP_STATE_PAIR_REQ_RSP},
520444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ENCRYPTED*/{SMP_ENC_CMPL,            SMP_SM_NO_ACTION,       SMP_STATE_PAIR_REQ_RSP},
521444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
522444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
523444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_slave_pair_request_response_table[][SMP_SM_NUM_COLS] =
524444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
525444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
526444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* CONFIRM  */ {SMP_PROC_CONFIRM,       SMP_SM_NO_ACTION,   SMP_STATE_CONFIRM},
527444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* TK_REQ   */ {SMP_SEND_APP_CBACK,     SMP_SM_NO_ACTION,   SMP_STATE_WAIT_APP_RSP},
528444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
529444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji                    /* TK/Confirm ready */
530444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEY_READY */{SMP_PROC_SL_KEY,        SMP_SM_NO_ACTION,   SMP_STATE_PAIR_REQ_RSP}
531444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PUBL_KEY_EXCH_REQ    */,{ SMP_CREATE_PRIVATE_KEY, SMP_SM_NO_ACTION, SMP_STATE_PUBLIC_KEY_EXCH},
532444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_PUBLIC_KEY      */ { SMP_PROCESS_PAIR_PUBLIC_KEY, SMP_SM_NO_ACTION,   SMP_STATE_PAIR_REQ_RSP},
533444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
534444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
535444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_slave_wait_confirm_table[][SMP_SM_NUM_COLS] =
536444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
537444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
538444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* CONFIRM  */ {SMP_PROC_CONFIRM,       SMP_SEND_CONFIRM,   SMP_STATE_CONFIRM},
539444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEY_READY*/ {SMP_PROC_SL_KEY,        SMP_SM_NO_ACTION,   SMP_STATE_WAIT_CONFIRM}
540444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
541444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
542444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_slave_confirm_table[][SMP_SM_NUM_COLS] =
543444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
544444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
545444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* RAND     */ {SMP_PROC_RAND,          SMP_GENERATE_COMPARE,   SMP_STATE_RAND},
546444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
547444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji                    /* TK/Confirm ready */
548444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEY_READY*/ {SMP_PROC_SL_KEY,        SMP_SM_NO_ACTION,       SMP_STATE_CONFIRM}
549444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
550444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
551444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_slave_rand_table[][SMP_SM_NUM_COLS] =
552444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
553444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
554444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEY_READY */ {SMP_PROC_COMPARE,      SMP_SM_NO_ACTION,   SMP_STATE_RAND}, /* compare match */
555444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* RAND      */ {SMP_SEND_RAND,         SMP_SM_NO_ACTION, SMP_STATE_ENCRYPTION_PENDING}
556444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
557444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
558444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_slave_public_key_exch_table[][SMP_SM_NUM_COLS] =
559444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
560444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
561444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* LOC_PUBL_KEY_CRTD  */{ SMP_WAIT_FOR_BOTH_PUBLIC_KEYS, SMP_SM_NO_ACTION, SMP_STATE_PUBLIC_KEY_EXCH},
562444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_PUBLIC_KEY      */{ SMP_PROCESS_PAIR_PUBLIC_KEY, SMP_SM_NO_ACTION, SMP_STATE_PUBLIC_KEY_EXCH},
563444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* BOTH_PUBL_KEYS_RCVD */{ SMP_HAVE_BOTH_PUBLIC_KEYS, SMP_SM_NO_ACTION, SMP_STATE_SEC_CONN_PHS1_START},
564444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
565444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
566444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_slave_sec_conn_phs1_start_table[][SMP_SM_NUM_COLS] =
567444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
568444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
569444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_DHKEY_CMPLT       */{ SMP_START_SEC_CONN_PHASE1, SMP_SM_NO_ACTION, SMP_STATE_SEC_CONN_PHS1_START},
570444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* HAVE_LOC_NONCE       */{ SMP_PROCESS_LOCAL_NONCE,SMP_SM_NO_ACTION, SMP_STATE_WAIT_COMMITMENT},
571444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* TK_REQ               */{ SMP_SEND_APP_CBACK,      SMP_SM_NO_ACTION, SMP_STATE_WAIT_APP_RSP},
572444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SMP_MODEL_SEC_CONN_PASSKEY_DISP model, passkey is sent up to display, it's time to start */
573444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* commitment calculation */
574444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEY_READY */{ SMP_START_PASSKEY_VERIFICATION, SMP_SM_NO_ACTION, SMP_STATE_SEC_CONN_PHS1_START},
575444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_KEYPR_NOTIF  */{ SMP_PROCESS_KEYPRESS_NOTIFICATION,SMP_SEND_APP_CBACK, SMP_STATE_SEC_CONN_PHS1_START},
576ea8292eab91f90c7f917252d27aeab2f5a2393e0Nitin Arora/*COMMIT*/{SMP_PROCESS_PAIRING_COMMITMENT, SMP_SM_NO_ACTION, SMP_STATE_SEC_CONN_PHS1_START},
577444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
578444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
579444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_slave_wait_commitment_table[][SMP_SM_NUM_COLS] =
580444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
581444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
582444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_COMMITM  */{SMP_PROCESS_PAIRING_COMMITMENT, SMP_SEND_COMMITMENT,  SMP_STATE_WAIT_NONCE},
583444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_KEYPR_NOTIF */{SMP_PROCESS_KEYPRESS_NOTIFICATION, SMP_SEND_APP_CBACK, SMP_STATE_WAIT_COMMITMENT},
584444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
585444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
586444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_slave_wait_nonce_table[][SMP_SM_NUM_COLS] =
587444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
588444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
589444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* peer nonce is received */
590444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* RAND           */{SMP_PROC_RAND, SMP_PROCESS_PEER_NONCE, SMP_STATE_SEC_CONN_PHS2_START},
591444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* NC model, time to calculate number for NC */
592444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_CALC_NC  */{SMP_CALCULATE_NUMERIC_COMPARISON_DISPLAY_NUMBER, SMP_SM_NO_ACTION, SMP_STATE_WAIT_NONCE},
593444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* NC model, time to display calculated number for NC to the user */
594444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_DSPL_NC   */{SMP_SEND_APP_CBACK, SMP_SM_NO_ACTION, SMP_STATE_WAIT_APP_RSP},
595444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
596444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
597444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_slave_sec_conn_phs2_start_table[][SMP_SM_NUM_COLS] =
598444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
599444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
600444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_PHASE1_CMPLT */{SMP_CALCULATE_LOCAL_DHKEY_CHECK, SMP_PH2_DHKEY_CHECKS_ARE_PRESENT, SMP_STATE_WAIT_DHK_CHECK},
601444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* DHKey Check from master is received before slave DHKey calculation is completed - race */
602444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_DHKEY_CHCK  */{SMP_PROCESS_DHKEY_CHECK, SMP_SM_NO_ACTION, SMP_STATE_SEC_CONN_PHS2_START},
603444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
604444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
605444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_slave_wait_dhk_check_table[][SMP_SM_NUM_COLS] =
606444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
607444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
608444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_DHKEY_CHCK      */{SMP_PROCESS_DHKEY_CHECK, SMP_CALCULATE_PEER_DHKEY_CHECK, SMP_STATE_DHK_CHECK},
609444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* DHKey Check from master was received before slave came to this state */
610444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_2_DHCK_CHKS_PRES  */{SMP_CALCULATE_PEER_DHKEY_CHECK, SMP_SM_NO_ACTION, SMP_STATE_DHK_CHECK},
611444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
612444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
613444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_slave_dhk_check_table[][SMP_SM_NUM_COLS] =
614444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
615444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
616444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
617444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* locally calculated peer dhkey check is ready -> compare it withs DHKey Check */
618444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* actually received from peer */
619444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SC_KEY_READY         */{SMP_MATCH_DHKEY_CHECKS, SMP_SM_NO_ACTION, SMP_STATE_DHK_CHECK},
6205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
621444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* dhkey checks match -> send local dhkey check to master, go to wait for HCI LE */
622444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* Long Term Key Request Event */
623444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* PAIR_DHKEY_CHCK      */{SMP_SEND_DHKEY_CHECK, SMP_SM_NO_ACTION, SMP_STATE_ENCRYPTION_PENDING},
624444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
625444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
626444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_slave_enc_pending_table[][SMP_SM_NUM_COLS] =
627444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
628444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
629444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ENC_REQ   */ {SMP_GENERATE_STK,      SMP_SM_NO_ACTION, SMP_STATE_ENCRYPTION_PENDING},
630444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
631444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji                    /* STK ready */
632444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEY_READY */ {SMP_SEND_LTK_REPLY,    SMP_SM_NO_ACTION, SMP_STATE_ENCRYPTION_PENDING},
633444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ENCRYPTED */ {SMP_CHECK_AUTH_REQ,    SMP_SM_NO_ACTION, SMP_STATE_ENCRYPTION_PENDING},
634444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* BOND_REQ  */ {SMP_KEY_DISTRIBUTE,    SMP_SM_NO_ACTION, SMP_STATE_BOND_PENDING}
635444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
636444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_slave_bond_pending_table[][SMP_SM_NUM_COLS] =
637444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
638444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
639444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
640444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji                /* LTK ready */
641444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* KEY_READY */{ SMP_SEND_ENC_INFO,     SMP_SM_NO_ACTION, SMP_STATE_BOND_PENDING},
642444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
643444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji                /* rev SRK */
644444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* SIGN_INFO */{ SMP_PROC_SRK_INFO,     SMP_SM_NO_ACTION, SMP_STATE_BOND_PENDING},
645444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ENC_INFO */ { SMP_PROC_ENC_INFO,     SMP_SM_NO_ACTION, SMP_STATE_BOND_PENDING},
646444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ID_INFO  */ { SMP_PROC_ID_INFO,      SMP_SM_NO_ACTION,  SMP_STATE_BOND_PENDING},
647444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* MASTER_ID*/ { SMP_PROC_MASTER_ID,    SMP_SM_NO_ACTION, SMP_STATE_BOND_PENDING},
648444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* ID_ADDR  */ { SMP_PROC_ID_ADDR,      SMP_SM_NO_ACTION, SMP_STATE_BOND_PENDING}
649444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
650444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
651444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
652444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const UINT8 smp_slave_create_local_sec_conn_oob_data[][SMP_SM_NUM_COLS] =
653444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
654444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/*                          Event                  Action                 Next State */
655444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* LOC_PUBL_KEY_CRTD */ {SMP_SET_LOCAL_OOB_KEYS, SMP_SM_NO_ACTION, SMP_STATE_CREATE_LOCAL_SEC_CONN_OOB_DATA},
656444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji/* HAVE_LOC_NONCE    */ {SMP_SET_LOCAL_OOB_RAND_COMMITMENT, SMP_SM_NO_ACTION, SMP_STATE_IDLE}
657444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
658444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
659444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const tSMP_SM_TBL smp_state_table[][2] =
660444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
661444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    /* SMP_STATE_IDLE */
662444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    {smp_master_idle_table, smp_slave_idle_table},
663444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
664444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    /* SMP_STATE_WAIT_APP_RSP */
665444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    {smp_master_wait_for_app_response_table, smp_slave_wait_for_app_response_table},
666444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
667444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    /* SMP_STATE_SEC_REQ_PENDING */
668444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    {NULL, smp_slave_sec_request_table},
669444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
670444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    /* SMP_STATE_PAIR_REQ_RSP */
671444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    {smp_master_pair_request_response_table, smp_slave_pair_request_response_table},
672444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
673444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    /* SMP_STATE_WAIT_CONFIRM */
674444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    {smp_master_wait_for_confirm_table, smp_slave_wait_confirm_table},
675444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
676444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    /* SMP_STATE_CONFIRM */
677444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    {smp_master_confirm_table, smp_slave_confirm_table},
678444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
679444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    /* SMP_STATE_RAND */
680444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    {smp_master_rand_table, smp_slave_rand_table},
681444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
682444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    /* SMP_STATE_PUBLIC_KEY_EXCH */
683444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    {smp_master_public_key_exchange_table,smp_slave_public_key_exch_table},
684444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
685444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    /* SMP_STATE_SEC_CONN_PHS1_START */
686444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    {smp_master_sec_conn_phs1_start_table, smp_slave_sec_conn_phs1_start_table},
687444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
688444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    /* SMP_STATE_WAIT_COMMITMENT */
689444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    {smp_master_wait_commitment_table, smp_slave_wait_commitment_table},
690444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
691444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    /* SMP_STATE_WAIT_NONCE */
692444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    {smp_master_wait_nonce_table, smp_slave_wait_nonce_table},
693444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
694444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji     /* SMP_STATE_SEC_CONN_PHS2_START */
695444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    {smp_master_sec_conn_phs2_start_table, smp_slave_sec_conn_phs2_start_table},
696444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
697444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    /* SMP_STATE_WAIT_DHK_CHECK */
698444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    {smp_master_wait_dhk_check_table, smp_slave_wait_dhk_check_table},
699444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
700444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    /* SMP_STATE_DHK_CHECK */
701444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    {smp_master_dhk_check_table, smp_slave_dhk_check_table},
702444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
703444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    /* SMP_STATE_ENCRYPTION_PENDING */
704444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    {smp_master_enc_pending_table, smp_slave_enc_pending_table},
705444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
706444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji     /* SMP_STATE_BOND_PENDING */
707444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    {smp_master_bond_pending_table, smp_slave_bond_pending_table},
708444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
709444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    /* SMP_STATE_CREATE_LOCAL_SEC_CONN_OOB_DATA */
710444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    {smp_master_create_local_sec_conn_oob_data, smp_slave_create_local_sec_conn_oob_data}
711444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji};
712444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
713444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojitypedef const UINT8 (*tSMP_ENTRY_TBL)[SMP_STATE_MAX];
714444a8da807abaf5f9e813ce70c56a79160495fb3Satya Callojistatic const tSMP_ENTRY_TBL smp_entry_table[] =
715444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji{
716444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_master_entry_map,
717444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    smp_slave_entry_map
7185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project};
7195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
7205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if SMP_DYNAMIC_MEMORY == FALSE
7215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjecttSMP_CB  smp_cb;
7225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
7235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define SMP_ALL_TBL_MASK        0x80
7245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
7255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
7265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function     smp_set_state
7275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns      None
7285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
7295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid smp_set_state(tSMP_STATE state)
7305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
731444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    if (state < SMP_STATE_MAX)
7325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
733b44cc59d286ad255e872c60df02e032bd8d9d75bSharvil Nanavati        SMP_TRACE_DEBUG( "State change: %s(%d) ==> %s(%d)",
7345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                          smp_get_state_name(smp_cb.state), smp_cb.state,
7355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                          smp_get_state_name(state), state );
7365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        smp_cb.state = state;
7375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
7385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
7395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
740b44cc59d286ad255e872c60df02e032bd8d9d75bSharvil Nanavati        SMP_TRACE_DEBUG("smp_set_state invalid state =%d", state );
7415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
7425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
7435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
7445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
7455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function     smp_get_state
7465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns      The smp state
7475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
7485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjecttSMP_STATE smp_get_state(void)
7495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
7505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    return smp_cb.state;
7515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
7525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
7535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
7545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
7555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function     smp_sm_event
7565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
7575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description  Handle events to the state machine. It looks up the entry
7585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**              in the smp_entry_table array.
7595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**              If it is a valid entry, it gets the state table.Set the next state,
7605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**              if not NULL state.Execute the action function according to the
7615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**              state table. If the state returned by action function is not NULL
7625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**              state, adjust the new state to the returned state.If (api_evt != MAX),
7635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**              call callback function.
7645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
7655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns      void.
7665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
7675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
7685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid smp_sm_event(tSMP_CB *p_cb, tSMP_EVENT event, void *p_data)
7695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
7705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT8           curr_state = p_cb->state;
7715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tSMP_SM_TBL     state_table;
7725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT8           action, entry, i;
7735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tSMP_ENTRY_TBL  entry_table =  smp_entry_table[p_cb->role];
7745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
775b44cc59d286ad255e872c60df02e032bd8d9d75bSharvil Nanavati    SMP_TRACE_EVENT("main smp_sm_event");
776444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    if (curr_state >= SMP_STATE_MAX)
7775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
778b44cc59d286ad255e872c60df02e032bd8d9d75bSharvil Nanavati        SMP_TRACE_DEBUG( "Invalid state: %d", curr_state) ;
7795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        return;
7805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
7815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
782b44cc59d286ad255e872c60df02e032bd8d9d75bSharvil Nanavati    SMP_TRACE_DEBUG( "SMP Role: %s State: [%s (%d)], Event: [%s (%d)]",\
7835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                      (p_cb->role == 0x01) ?"Slave" : "Master", smp_get_state_name( p_cb->state),
7845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                      p_cb->state, smp_get_event_name(event), event) ;
7855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
7865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    /* look up the state table for the current state */
7875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    /* lookup entry /w event & curr_state */
7885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    /* If entry is ignore, return.
7895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project     * Otherwise, get state table (according to curr_state or all_state) */
790444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    if ((event <= SMP_MAX_EVT) && ( (entry = entry_table[event - 1][curr_state]) != SMP_SM_IGNORE ))
7915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
7925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (entry & SMP_ALL_TBL_MASK)
7935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
7945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            entry &= ~SMP_ALL_TBL_MASK;
7955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            state_table = smp_all_table;
7965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
7975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        else
7985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            state_table = smp_state_table[curr_state][p_cb->role];
7995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
8005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
8015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
802b44cc59d286ad255e872c60df02e032bd8d9d75bSharvil Nanavati        SMP_TRACE_DEBUG( "Ignore event [%s (%d)] in state [%s (%d)]",
803444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji                          smp_get_event_name(event), event, smp_get_state_name(curr_state),
804444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji                          curr_state);
8055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        return;
8065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
8075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
8085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    /* Get possible next state from state table. */
8095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
8105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    smp_set_state(state_table[entry-1][SMP_SME_NEXT_STATE]);
8115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
8125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    /* If action is not ignore, clear param, exec action and get next state.
8135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project     * The action function may set the Param for cback.
8145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project     * Depending on param, call cback or free buffer. */
8155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    /* execute action */
8165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    /* execute action functions */
8175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    for (i = 0; i < SMP_NUM_ACTIONS; i++)
8185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
8195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if ((action = state_table[entry-1][i]) != SMP_SM_NO_ACTION)
8205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
8215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            (*smp_sm_action[action])(p_cb, (tSMP_INT_DATA *)p_data);
8225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
8235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        else
8245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
8255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
8265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
8275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
828b44cc59d286ad255e872c60df02e032bd8d9d75bSharvil Nanavati    SMP_TRACE_DEBUG( "result state = %s", smp_get_state_name( p_cb->state ) ) ;
8295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
8305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
8315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
8325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function     smp_get_state_name
8335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns      The smp state name.
8345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
8355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectconst char * smp_get_state_name(tSMP_STATE state)
8365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
837444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    const char *p_str = smp_state_name[SMP_STATE_MAX];
8385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
839444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    if (state < SMP_STATE_MAX)
8405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
8415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_str = smp_state_name[state];
8425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
8435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    return p_str;
8445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
845444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
8465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
8475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function     smp_get_event_name
8485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns      The smp event name.
8495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
8505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectconst char * smp_get_event_name(tSMP_EVENT event)
8515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
852444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    const char *p_str = smp_event_name[SMP_MAX_EVT];
8535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
854444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji    if (event <= SMP_MAX_EVT)
8555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
8565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_str = smp_event_name[event- 1];
8575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
8585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    return p_str;
8595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
860444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji
8615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
8625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
863