15738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 25738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 35738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Copyright (C) 1999-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/****************************************************************************** 205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * This file contains functions for the SMP L2Cap utility functions 225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/ 245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bt_target.h" 255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if SMP_INCLUDED == TRUE 275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bt_types.h" 295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include <string.h> 305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include <ctype.h> 315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "hcidefs.h" 325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "btm_ble_api.h" 335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "l2c_api.h" 345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "l2c_int.h" 355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "smp_int.h" 365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define SMP_PAIRING_REQ_SIZE 7 395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define SMP_CONFIRM_CMD_SIZE (BT_OCTET16_LEN + 1) 405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define SMP_INIT_CMD_SIZE (BT_OCTET16_LEN + 1) 415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define SMP_ENC_INFO_SIZE (BT_OCTET16_LEN + 1) 425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define SMP_MASTER_ID_SIZE (BT_OCTET8_LEN + 2 + 1) 435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define SMP_ID_INFO_SIZE (BT_OCTET16_LEN + 1) 445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define SMP_ID_ADDR_SIZE (BD_ADDR_LEN + 1 + 1) 455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define SMP_SIGN_INFO_SIZE (BT_OCTET16_LEN + 1) 465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define SMP_PAIR_FAIL_SIZE 2 475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* type for action functions */ 505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projecttypedef BT_HDR * (*tSMP_CMD_ACT)(UINT8 cmd_code, tSMP_CB *p_cb); 515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_pairing_cmd(UINT8 cmd_code, tSMP_CB *p_cb); 535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_confirm_cmd(UINT8 cmd_code, tSMP_CB *p_cb); 545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_rand_cmd(UINT8 cmd_code, tSMP_CB *p_cb); 555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_pairing_fail(UINT8 cmd_code, tSMP_CB *p_cb); 565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_identity_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb); 575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_encrypt_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb); 585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_security_request(UINT8 cmd_code, tSMP_CB *p_cb); 595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_signing_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb); 605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_master_id_cmd(UINT8 cmd_code, tSMP_CB *p_cb); 615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_id_addr_cmd(UINT8 cmd_code, tSMP_CB *p_cb); 625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectconst tSMP_CMD_ACT smp_cmd_build_act[] = 645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project NULL, 665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_build_pairing_cmd, /* 0x01: pairing request */ 675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_build_pairing_cmd, /* 0x02: pairing response */ 685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_build_confirm_cmd, /* 0x03: pairing confirm */ 695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_build_rand_cmd, /* 0x04: pairing initializer request */ 705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_build_pairing_fail, /* 0x05: pairing failure */ 715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_build_encrypt_info_cmd, /* 0x06: security information command */ 725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_build_master_id_cmd, /* 0x07: master identity command */ 735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_build_identity_info_cmd, /* 0x08: identity information command */ 745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_build_id_addr_cmd, /* 0x09: signing information */ 755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_build_signing_info_cmd, /* 0x0A: signing information */ 765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_build_security_request /* 0x0B: security request */ 775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}; 785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_send_msg_to_L2CAP 815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Send message to L2CAP. 835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjectBOOLEAN smp_send_msg_to_L2CAP(BD_ADDR rem_bda, BT_HDR *p_toL2CAP) 865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 l2cap_ret; 885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT0("smp_send_msg_to_L2CAP"); 905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((l2cap_ret = L2CA_SendFixedChnlData (L2CAP_SMP_CID, rem_bda, p_toL2CAP)) == L2CAP_DW_FAILED) 925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_ERROR1("SMP failed to pass msg:0x%0x to L2CAP", 945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *((UINT8 *)(p_toL2CAP + 1) + p_toL2CAP->offset)); 955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_freebuf(p_toL2CAP); 965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return FALSE; 975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return TRUE; 1015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 1045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_send_cmd 1065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description send a SMP command on L2CAP channel. 1085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 1105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjectBOOLEAN smp_send_cmd(UINT8 cmd_code, tSMP_CB *p_cb) 1115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf; 1135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BOOLEAN sent = FALSE; 1145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 failure = SMP_PAIR_INTERNAL_ERR; 1155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT1("smp_send_cmd on l2cap cmd_code=0x%x", cmd_code); 1165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ( cmd_code < SMP_OPCODE_MAX && 1175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_cmd_build_act[cmd_code] != NULL) 1185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf = (*smp_cmd_build_act[cmd_code])(cmd_code, p_cb); 1205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_buf != NULL && 1225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_send_msg_to_L2CAP(p_cb->pairing_bda, p_buf)) 1235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project sent = TRUE; 1255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btu_stop_timer (&p_cb->rsp_timer_ent); 1275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btu_start_timer (&p_cb->rsp_timer_ent, BTU_TTYPE_SMP_PAIRING_CMD, 1285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_WAIT_FOR_RSP_TOUT); 1295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (!sent) 1335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &failure); 1355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return sent; 1375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 1425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_rsp_timeout 1445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Called when SMP wait for SMP command response timer expires 1465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 1485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 1505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid smp_rsp_timeout(TIMER_LIST_ENT *p_tle) 1515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tSMP_CB *p_cb = &smp_cb; 1535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 failure = SMP_RSP_TIMEOUT; 1545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT1("smp_rsp_timeout state:%d", p_cb->state); 1565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (smp_get_state() == SMP_ST_RELEASE_DELAY) 1585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_sm_event(p_cb, SMP_RELEASE_DELAY_TOUT_EVT, NULL); 1605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 1625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &failure); 1645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 1685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_build_pairing_req_cmd 1705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Build pairing request command. 1725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 1745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjectBT_HDR * smp_build_pairing_cmd(UINT8 cmd_code, tSMP_CB *p_cb) 1755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf = NULL ; 1775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p; 1785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT0("smp_build_pairing_cmd"); 1795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_PAIRING_REQ_SIZE + L2CAP_MIN_OFFSET)) != NULL) 1805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET; 1825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, cmd_code); 1845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, p_cb->loc_io_caps); 1855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, p_cb->loc_oob_flag); 1865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, p_cb->loc_auth_req); 1875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, p_cb->loc_enc_size); 1885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, p_cb->loc_i_key); 1895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, p_cb->loc_r_key); 1905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->offset = L2CAP_MIN_OFFSET; 1925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* 1B ERR_RSP op code + 1B cmd_op_code + 2B handle + 1B status */ 1935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len = SMP_PAIRING_REQ_SIZE; 1945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return p_buf; 1975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 2005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_build_confirm_cmd 2025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Build confirm request command. 2045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 2065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_confirm_cmd(UINT8 cmd_code, tSMP_CB *p_cb) 2075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf = NULL ; 2095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p; 2105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT0("smp_build_confirm_cmd"); 2115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_CONFIRM_CMD_SIZE + L2CAP_MIN_OFFSET)) != NULL) 2125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET; 2145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, SMP_OPCODE_CONFIRM); 2165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ARRAY_TO_STREAM (p, p_cb->confirm, BT_OCTET16_LEN); 2175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->offset = L2CAP_MIN_OFFSET; 2195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len = SMP_CONFIRM_CMD_SIZE; 2205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return p_buf; 2235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 2255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_build_rand_cmd 2275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Build Initializer command. 2295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 2315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_rand_cmd(UINT8 cmd_code, tSMP_CB *p_cb) 2325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf = NULL ; 2345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p; 2355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT0("smp_build_rand_cmd"); 2365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_INIT_CMD_SIZE + L2CAP_MIN_OFFSET)) != NULL) 2375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET; 2395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, SMP_OPCODE_INIT); 2415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ARRAY_TO_STREAM (p, p_cb->rand, BT_OCTET16_LEN); 2425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->offset = L2CAP_MIN_OFFSET; 2445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len = SMP_INIT_CMD_SIZE; 2455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return p_buf; 2485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 2505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_build_encrypt_info_cmd 2525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Build security information command. 2545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 2565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_encrypt_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb) 2575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf = NULL ; 2595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p; 2605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT0("smp_build_encrypt_info_cmd"); 2615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_ENC_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL) 2625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET; 2645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, SMP_OPCODE_ENCRYPT_INFO); 2665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ARRAY_TO_STREAM (p, p_cb->ltk, BT_OCTET16_LEN); 2675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->offset = L2CAP_MIN_OFFSET; 2695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len = SMP_ENC_INFO_SIZE; 2705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return p_buf; 2735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 2755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_build_master_id_cmd 2775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Build security information command. 2795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 2815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_master_id_cmd(UINT8 cmd_code, tSMP_CB *p_cb) 2825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf = NULL ; 2845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p; 2855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT0("smp_build_master_id_cmd "); 2865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_MASTER_ID_SIZE + L2CAP_MIN_OFFSET)) != NULL) 2875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET; 2895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, SMP_OPCODE_MASTER_ID); 2915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16_TO_STREAM (p, p_cb->ediv); 2925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ARRAY_TO_STREAM (p, p_cb->enc_rand, BT_OCTET8_LEN); 2935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->offset = L2CAP_MIN_OFFSET; 2955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len = SMP_MASTER_ID_SIZE; 2965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return p_buf; 2995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 3015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_build_identity_info_cmd 3035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Build identity information command. 3055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 3075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_identity_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb) 3085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf = NULL ; 3105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p; 3115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_OCTET16 irk; 3125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT0("smp_build_identity_info_cmd"); 3135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_ID_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL) 3145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET; 3165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTM_GetDeviceIDRoot(irk); 3185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, SMP_OPCODE_IDENTITY_INFO); 3205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ARRAY_TO_STREAM (p, irk, BT_OCTET16_LEN); 3215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->offset = L2CAP_MIN_OFFSET; 3235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len = SMP_ID_INFO_SIZE; 3245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return p_buf; 3275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 3295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_build_id_addr_cmd 3315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Build identity address information command. 3335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 3355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_id_addr_cmd(UINT8 cmd_code, tSMP_CB *p_cb) 3365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf = NULL ; 3385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p; 339ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BD_ADDR static_addr; 340ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 341ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 3425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT0("smp_build_id_addr_cmd"); 3435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_ID_ADDR_SIZE + L2CAP_MIN_OFFSET)) != NULL) 3445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET; 3465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, SMP_OPCODE_ID_ADDR); 3485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, 0); /* TODO: update with local address type */ 349ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTM_GetLocalDeviceAddr(static_addr); 350ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BDADDR_TO_STREAM (p, static_addr); 3515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->offset = L2CAP_MIN_OFFSET; 3535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len = SMP_ID_ADDR_SIZE; 3545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return p_buf; 3575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 3605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_build_signing_info_cmd 3625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Build signing information command. 3645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 3665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_signing_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb) 3675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf = NULL ; 3695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p; 370ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 3715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT0("smp_build_signing_info_cmd"); 3725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_SIGN_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL) 3735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET; 3755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, SMP_OPCODE_SIGN_INFO); 3775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ARRAY_TO_STREAM (p, p_cb->csrk, BT_OCTET16_LEN); 3785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->offset = L2CAP_MIN_OFFSET; 3805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len = SMP_SIGN_INFO_SIZE; 3815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return p_buf; 3845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 3865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_build_pairing_fail 3885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Build Pairing Fail command. 3905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 3925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_pairing_fail(UINT8 cmd_code, tSMP_CB *p_cb) 3935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf = NULL ; 3955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p; 3965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT0("smp_build_pairing_fail"); 3975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_PAIR_FAIL_SIZE + L2CAP_MIN_OFFSET)) != NULL) 3985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET; 4005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, SMP_OPCODE_PAIRING_FAILED); 4025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, p_cb->failure); 4035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->offset = L2CAP_MIN_OFFSET; 4055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len = SMP_PAIR_FAIL_SIZE; 4065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return p_buf; 4095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 4115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_build_security_request 4135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Build security request command. 4155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 4175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic BT_HDR * smp_build_security_request(UINT8 cmd_code, tSMP_CB *p_cb) 4185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 4195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf = NULL ; 4205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p; 4215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT0("smp_build_security_request"); 4225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + 2 + L2CAP_MIN_OFFSET)) != NULL) 4245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET; 4265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, SMP_OPCODE_SEC_REQ); 4285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8_TO_STREAM (p, p_cb->loc_auth_req); 4295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->offset = L2CAP_MIN_OFFSET; 4315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->len = 2; 4325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT2("opcode=%d auth_req=0x%x",SMP_OPCODE_SEC_REQ, p_cb->loc_auth_req ); 4345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return p_buf; 4375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 4415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_convert_string_to_tk 4435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function is called to convert a 6 to 16 digits numeric 4455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** character string into SMP TK. 4465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 4495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 4515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid smp_convert_string_to_tk(BT_OCTET16 tk, UINT32 passkey) 4525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 4535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p = tk; 4545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tSMP_KEY key; 4555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT0("smp_convert_string_to_tk"); 4565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT32_TO_STREAM(p, passkey); 4575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project key.key_type = SMP_KEY_TYPE_TK; 4595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project key.p_data = tk; 4605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_sm_event(&smp_cb, SMP_KEY_READY_EVT, &key); 4625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 4655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_mask_enc_key 4675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function is called to mask off the encryption key based 4695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** on the maximum encryption key size. 4705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 4735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 4755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid smp_mask_enc_key(UINT8 loc_enc_size, UINT8 * p_data) 4765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 4775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT0("smp_mask_enc_key"); 4785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (loc_enc_size < BT_OCTET16_LEN) 4795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (; loc_enc_size < BT_OCTET16_LEN; loc_enc_size ++) 4815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * (p_data + loc_enc_size) = 0; 4825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 4845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 4865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_xor_128 4885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description utility function to do an biteise exclusive-OR of two bit 4905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** strings of the length of BT_OCTET16_LEN. 4915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 4935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 4955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid smp_xor_128(BT_OCTET16 a, BT_OCTET16 b) 4965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 4975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 i, *aa = a, *bb = b; 4985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT0("smp_xor_128"); 5005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (i = 0; i < BT_OCTET16_LEN; i++) 5015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project aa[i] = aa[i] ^ bb[i]; 5035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 5055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 5085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_cb_cleanup 5105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Clean up SMP control block 5125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 5145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 5165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid smp_cb_cleanup(tSMP_CB *p_cb) 5175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 5185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tSMP_CALLBACK *p_callback = p_cb->p_callback; 5195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 trace_level = p_cb->trace_level; 5205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT0("smp_cb_cleanup"); 5225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memset(p_cb, 0, sizeof(tSMP_CB)); 5235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->p_callback = p_callback; 5245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->trace_level = trace_level; 5255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 5265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 5275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_reset_control_value 5295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function is called to reset the control block value when 5315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** pairing procedure finished. 5325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 5355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 5375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid smp_reset_control_value(tSMP_CB *p_cb) 5385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 5395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT0("smp_reset_control_value"); 5405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btu_stop_timer (&p_cb->rsp_timer_ent); 5415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if SMP_CONFORMANCE_TESTING == TRUE 5425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT1("smp_cb.remove_fixed_channel_disable=%d", smp_cb.remove_fixed_channel_disable); 5445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (!smp_cb.remove_fixed_channel_disable) 5455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project L2CA_RemoveFixedChnl (L2CAP_SMP_CID, p_cb->pairing_bda); 5475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 5495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_EVENT0("disable the removal of the fixed channel"); 5515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#else 5555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* We can tell L2CAP to remove the fixed channel (if it has one) */ 5565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project L2CA_RemoveFixedChnl (L2CAP_SMP_CID, p_cb->pairing_bda); 5575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 5595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_cb_cleanup(p_cb); 5605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 5625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 5635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_proc_pairing_cmpl 5655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function is called to process pairing complete 5675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 5705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 5725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid smp_proc_pairing_cmpl(tSMP_CB *p_cb) 5735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 5745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tSMP_EVT_DATA evt_data = {0}; 5755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_DEBUG0 ("smp_proc_pairing_cmpl "); 5775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project evt_data.cmplt.reason = p_cb->status; 5795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cb->status == SMP_SUCCESS) 5815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project evt_data.cmplt.sec_level = p_cb->sec_level; 5825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project evt_data.cmplt.is_pair_cancel = FALSE; 5845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cb->is_pair_cancel) 5865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project evt_data.cmplt.is_pair_cancel = TRUE; 5875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_DEBUG2 ("send SMP_COMPLT_EVT reason=0x%0x sec_level=0x%0x", 5905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project evt_data.cmplt.reason, 5915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project evt_data.cmplt.sec_level ); 5925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cb->p_callback) 5935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (*p_cb->p_callback) (SMP_COMPLT_EVT, p_cb->pairing_bda, &evt_data); 5945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if 0 /* TESTING CODE : as a master, reencrypt using LTK */ 5965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (evt_data.cmplt.reason == 0 && p_cb->role == HCI_ROLE_MASTER) 5975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btm_ble_start_encrypt(p_cb->pairing_bda, FALSE, NULL); 5995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 6015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_reset_control_value(p_cb); 6035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 6045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if SMP_CONFORMANCE_TESTING == TRUE 6065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 6075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_set_test_confirm_value 6095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function is called to set the test confirm value 6115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 6135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 6155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid smp_set_test_confirm_value(BOOLEAN enable, UINT8 *p_c_val) 6165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 6175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_DEBUG1("smp_set_test_confirm_value enable=%d", enable); 6185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_cb.enable_test_confirm_val = enable; 6195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(smp_cb.test_confirm, p_c_val, BT_OCTET16_LEN); 6205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 6215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 6245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_set_test_confirm_value 6265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function is called to set the test rand value 6285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 6305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 6325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid smp_set_test_rand_value(BOOLEAN enable, UINT8 *p_c_val) 6335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 6345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_DEBUG1("smp_set_test_rand_value enable=%d", enable); 6355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_cb.enable_test_rand_val = enable; 6365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(smp_cb.test_rand, p_c_val, BT_OCTET16_LEN); 6375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 6385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 6415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_set_test_pair_fail_status 6435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function is called to set the test fairing fair status 6455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 6475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 6495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid smp_set_test_pair_fail_status (BOOLEAN enable, UINT8 status) 6505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 6515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_DEBUG1("smp_set_test_confirm_value enable=%d", enable); 6525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_cb.enable_test_pair_fail = enable; 6535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_cb.pair_fail_status = status; 6545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 6555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 6575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function smp_set_test_pair_fail_status 6595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function is called to disable the removal of fixed channel 6615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** in smp_reset_control_value 6625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 6635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 6655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid smp_remove_fixed_channel_disable (BOOLEAN disable) 6665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 6675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SMP_TRACE_DEBUG1("smp_remove_fixed_channel_disable disable =%d", disable); 6685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project smp_cb.remove_fixed_channel_disable = disable; 6695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 670ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/******************************************************************************* 671ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 672ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Function smp_skip_compare_check 673ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 674ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Description This function is called to skip the compare value check 675ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 676ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Returns void 677ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** 678ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta*******************************************************************************/ 679ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battavoid smp_skip_compare_check(BOOLEAN enable) 680ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{ 681ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta SMP_TRACE_DEBUG1("smp_skip_compare_check enable=%d", enable); 682ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta smp_cb.skip_test_compare_check = enable; 683ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 6845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 6865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 6895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 690