Replace BD_ADDR with bt_bdaddr_t in JV related code
Test: compilation test
Change-Id: Ie0cf491506ebb898ba968586048d2b58248ba112
diff --git a/bta/include/bta_jv_api.h b/bta/include/bta_jv_api.h
index 046ed81..8d68bd6 100644
--- a/bta/include/bta_jv_api.h
+++ b/bta/include/bta_jv_api.h
@@ -187,7 +187,7 @@
typedef struct {
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
uint32_t handle; /* The connection handle */
- BD_ADDR rem_bda; /* The peer address */
+ bt_bdaddr_t rem_bda; /* The peer address */
int32_t tx_mtu; /* The transmit MTU */
} tBTA_JV_L2CAP_OPEN;
@@ -195,7 +195,7 @@
typedef struct {
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
uint32_t handle; /* The connection handle */
- BD_ADDR rem_bda; /* The peer address */
+ bt_bdaddr_t rem_bda; /* The peer address */
int32_t tx_mtu; /* The transmit MTU */
void** p_p_cback; /* set them for new socket */
void** p_user_data; /* set them for new socket */
@@ -254,7 +254,7 @@
typedef struct {
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
uint16_t channel; /* The connection channel */
- BD_ADDR addr; /* The peer address */
+ bt_bdaddr_t addr; /* The peer address */
uint32_t req_id; /* The req_id in the associated BTA_JvL2capWrite() */
uint8_t* p_data; /* The buffer where data is held */
uint16_t len; /* The length of the data written. */
@@ -265,14 +265,14 @@
typedef struct {
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
uint32_t handle; /* The connection handle */
- BD_ADDR rem_bda; /* The peer address */
+ bt_bdaddr_t rem_bda; /* The peer address */
} tBTA_JV_RFCOMM_OPEN;
/* data associated with BTA_JV_RFCOMM_SRV_OPEN_EVT */
typedef struct {
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
uint32_t handle; /* The connection handle */
uint32_t new_listen_handle; /* The new listen handle */
- BD_ADDR rem_bda; /* The peer address */
+ bt_bdaddr_t rem_bda; /* The peer address */
} tBTA_JV_RFCOMM_SRV_OPEN;
/* data associated with BTA_JV_RFCOMM_CLOSE_EVT */
@@ -423,7 +423,7 @@
* false if not.
*
******************************************************************************/
-bool BTA_JvIsEncrypted(BD_ADDR bd_addr);
+bool BTA_JvIsEncrypted(const bt_bdaddr_t& bd_addr);
/*******************************************************************************
*
@@ -474,8 +474,8 @@
* BTA_JV_FAILURE, otherwise.
*
******************************************************************************/
-tBTA_JV_STATUS BTA_JvStartDiscovery(BD_ADDR bd_addr, uint16_t num_uuid,
- tSDP_UUID* p_uuid_list,
+tBTA_JV_STATUS BTA_JvStartDiscovery(const bt_bdaddr_t& bd_addr,
+ uint16_t num_uuid, tSDP_UUID* p_uuid_list,
uint32_t rfcomm_slot_id);
/*******************************************************************************
@@ -521,7 +521,8 @@
tBTA_JV_STATUS BTA_JvL2capConnectLE(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
const tL2CAP_ERTM_INFO* ertm_info,
uint16_t remote_chan, uint16_t rx_mtu,
- tL2CAP_CFG_INFO* cfg, BD_ADDR peer_bd_addr,
+ tL2CAP_CFG_INFO* cfg,
+ const bt_bdaddr_t& peer_bd_addr,
tBTA_JV_L2CAP_CBACK* p_cback,
uint32_t l2cap_socket_id);
@@ -540,13 +541,11 @@
* BTA_JV_FAILURE, otherwise.
*
******************************************************************************/
-tBTA_JV_STATUS BTA_JvL2capConnect(int conn_type, tBTA_SEC sec_mask,
- tBTA_JV_ROLE role,
- const tL2CAP_ERTM_INFO* ertm_info,
- uint16_t remote_psm, uint16_t rx_mtu,
- tL2CAP_CFG_INFO* cfg, BD_ADDR peer_bd_addr,
- tBTA_JV_L2CAP_CBACK* p_cback,
- uint32_t l2cap_socket_id);
+tBTA_JV_STATUS BTA_JvL2capConnect(
+ int conn_type, tBTA_SEC sec_mask, tBTA_JV_ROLE role,
+ const tL2CAP_ERTM_INFO* ertm_info, uint16_t remote_psm, uint16_t rx_mtu,
+ tL2CAP_CFG_INFO* cfg, const bt_bdaddr_t& peer_bd_addr,
+ tBTA_JV_L2CAP_CBACK* p_cback, uint32_t l2cap_socket_id);
/*******************************************************************************
*
@@ -704,7 +703,7 @@
* BTA_JV_FAILURE, otherwise.
*
******************************************************************************/
-tBTA_JV_STATUS BTA_JvL2capWriteFixed(uint16_t channel, BD_ADDR* addr,
+tBTA_JV_STATUS BTA_JvL2capWriteFixed(uint16_t channel, const bt_bdaddr_t& addr,
uint32_t req_id,
tBTA_JV_L2CAP_CBACK* p_cback,
uint8_t* p_data, uint16_t len,
@@ -727,7 +726,8 @@
*
******************************************************************************/
tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
- uint8_t remote_scn, BD_ADDR peer_bd_addr,
+ uint8_t remote_scn,
+ const bt_bdaddr_t& peer_bd_addr,
tBTA_JV_RFCOMM_CBACK* p_cback,
uint32_t rfcomm_slot_id);
diff --git a/bta/jv/bta_jv_act.cc b/bta/jv/bta_jv_act.cc
index f378a67..a4c4515 100644
--- a/bta/jv/bta_jv_act.cc
+++ b/bta/jv/bta_jv_act.cc
@@ -52,7 +52,7 @@
struct fc_client {
struct fc_client* next_all_list;
struct fc_client* next_chan_list;
- BD_ADDR remote_addr;
+ bt_bdaddr_t remote_addr;
uint32_t id;
tBTA_JV_L2CAP_CBACK* p_cback;
uint32_t l2cap_socket_id;
@@ -397,11 +397,12 @@
/* needs to be called if registered with bta pm, otherwise we may run out of
* dm pm slots! */
if (close_conn)
- bta_sys_conn_close(BTA_ID_JV, p_pm_cb->app_id, p_pm_cb->peer_bd_addr);
+ bta_sys_conn_close(BTA_ID_JV, p_pm_cb->app_id,
+ to_BD_ADDR(p_pm_cb->peer_bd_addr));
p_pm_cb->state = BTA_JV_PM_FREE_ST;
p_pm_cb->app_id = BTA_JV_PM_ALL;
p_pm_cb->handle = BTA_JV_PM_HANDLE_CLEAR;
- bdcpy(p_pm_cb->peer_bd_addr, to_BD_ADDR(bd_addr_null));
+ p_pm_cb->peer_bd_addr = bd_addr_null;
}
/*******************************************************************************
@@ -425,8 +426,7 @@
if ((bta_jv_cb.pm_cb[i].state != BTA_JV_PM_FREE_ST) &&
(jv_handle == bta_jv_cb.pm_cb[i].handle)) {
for (j = 0; j < BTA_JV_PM_MAX_NUM; j++) {
- if (bdcmp(bta_jv_cb.pm_cb[j].peer_bd_addr,
- bta_jv_cb.pm_cb[i].peer_bd_addr) == 0)
+ if (bta_jv_cb.pm_cb[j].peer_bd_addr == bta_jv_cb.pm_cb[i].peer_bd_addr)
bd_counter++;
if (bta_jv_cb.pm_cb[j].app_id == bta_jv_cb.pm_cb[i].app_id)
appid_counter++;
@@ -501,7 +501,7 @@
static tBTA_JV_PM_CB* bta_jv_alloc_set_pm_profile_cb(uint32_t jv_handle,
tBTA_JV_PM_ID app_id) {
bool bRfcHandle = (jv_handle & BTA_JV_RFCOMM_MASK) != 0;
- BD_ADDR peer_bd_addr;
+ bt_bdaddr_t peer_bd_addr;
int i, j;
tBTA_JV_PM_CB** pp_cb;
@@ -515,7 +515,7 @@
pp_cb = &bta_jv_cb.port_cb[j].p_pm_cb;
if (PORT_SUCCESS !=
PORT_CheckConnection(bta_jv_cb.port_cb[j].port_handle,
- peer_bd_addr, NULL))
+ to_BD_ADDR(peer_bd_addr), NULL))
i = BTA_JV_PM_MAX_NUM;
break;
}
@@ -527,8 +527,8 @@
pp_cb = &bta_jv_cb.l2c_cb[j].p_pm_cb;
const bt_bdaddr_t* p_bd_addr =
GAP_ConnGetRemoteAddr((uint16_t)jv_handle);
- if (NULL != p_bd_addr)
- bdcpy(peer_bd_addr, p_bd_addr->address);
+ if (p_bd_addr)
+ peer_bd_addr = *p_bd_addr;
else
i = BTA_JV_PM_MAX_NUM;
break;
@@ -547,7 +547,7 @@
*pp_cb = &bta_jv_cb.pm_cb[i];
bta_jv_cb.pm_cb[i].handle = jv_handle;
bta_jv_cb.pm_cb[i].app_id = app_id;
- bdcpy(bta_jv_cb.pm_cb[i].peer_bd_addr, peer_bd_addr);
+ bta_jv_cb.pm_cb[i].peer_bd_addr = peer_bd_addr;
bta_jv_cb.pm_cb[i].state = BTA_JV_PM_IDLE_ST;
return &bta_jv_cb.pm_cb[i];
}
@@ -890,7 +890,7 @@
*rfcomm_slot_id = p_data->start_discovery.rfcomm_slot_id;
if (!SDP_ServiceSearchAttributeRequest2(
- p_data->start_discovery.bd_addr, p_bta_jv_cfg->p_sdp_db,
+ to_BD_ADDR(p_data->start_discovery.bd_addr), p_bta_jv_cfg->p_sdp_db,
bta_jv_start_discovery_cback, (void*)rfcomm_slot_id)) {
bta_jv_cb.sdp_active = BTA_JV_SDP_ACT_NONE;
/* failed to start SDP. report the failure right away */
@@ -962,8 +962,7 @@
switch (event) {
case GAP_EVT_CONN_OPENED:
- bdcpy(evt_data.l2c_open.rem_bda,
- GAP_ConnGetRemoteAddr(gap_handle)->address);
+ evt_data.l2c_open.rem_bda = *GAP_ConnGetRemoteAddr(gap_handle);
evt_data.l2c_open.tx_mtu = GAP_ConnGetRemMtuSize(gap_handle);
p_cb->state = BTA_JV_ST_CL_OPEN;
p_cb->p_cback(BTA_JV_L2CAP_OPEN_EVT, &evt_data, p_cb->l2cap_socket_id);
@@ -1052,10 +1051,9 @@
if ((cc->type != BTA_JV_CONN_TYPE_L2CAP) ||
(bta_jv_check_psm(cc->remote_psm))) /* allowed */
{
- handle =
- GAP_ConnOpen("", sec_id, 0, &from_BD_ADDR(cc->peer_bd_addr),
- cc->remote_psm, &cfg, ertm_info, cc->sec_mask,
- chan_mode_mask, bta_jv_l2cap_client_cback, cc->type);
+ handle = GAP_ConnOpen("", sec_id, 0, &cc->peer_bd_addr, cc->remote_psm,
+ &cfg, ertm_info, cc->sec_mask, chan_mode_mask,
+ bta_jv_l2cap_client_cback, cc->type);
if (handle != GAP_INVALID_HANDLE) {
evt_data.status = BTA_JV_SUCCESS;
}
@@ -1126,8 +1124,7 @@
switch (event) {
case GAP_EVT_CONN_OPENED:
- bdcpy(evt_data.l2c_open.rem_bda,
- GAP_ConnGetRemoteAddr(gap_handle)->address);
+ evt_data.l2c_open.rem_bda = *GAP_ConnGetRemoteAddr(gap_handle);
evt_data.l2c_open.tx_mtu = GAP_ConnGetRemMtuSize(gap_handle);
p_cb->state = BTA_JV_ST_SR_OPEN;
p_cb->p_cback(BTA_JV_L2CAP_OPEN_EVT, &evt_data, p_cb->l2cap_socket_id);
@@ -1372,7 +1369,7 @@
evt_data.status = BTA_JV_FAILURE;
evt_data.channel = ls->channel;
- memcpy(evt_data.addr, ls->addr, sizeof(evt_data.addr));
+ evt_data.addr = ls->addr;
evt_data.req_id = ls->req_id;
evt_data.p_data = ls->p_data;
evt_data.len = 0;
@@ -1381,7 +1378,7 @@
msg->len = ls->len;
msg->offset = L2CAP_MIN_OFFSET;
- L2CA_SendFixedChnlData(ls->channel, from_BD_ADDR(ls->addr), msg);
+ L2CA_SendFixedChnlData(ls->channel, ls->addr, msg);
ls->p_cback(BTA_JV_L2CAP_WRITE_FIXED_EVT, (tBTA_JV*)&evt_data, ls->user_id);
}
@@ -1432,7 +1429,7 @@
tBTA_JV_RFC_CB* p_cb = bta_jv_rfc_port_to_cb(port_handle);
tBTA_JV_PCB* p_pcb = bta_jv_rfc_port_to_pcb(port_handle);
tBTA_JV evt_data;
- BD_ADDR rem_bda;
+ bt_bdaddr_t rem_bda;
uint16_t lcid;
tBTA_JV_RFCOMM_CBACK* p_cback; /* the callback function */
@@ -1443,12 +1440,12 @@
APPL_TRACE_DEBUG("bta_jv_port_mgmt_cl_cback code=%d port_handle:%d handle:%d",
code, port_handle, p_cb->handle);
- PORT_CheckConnection(port_handle, rem_bda, &lcid);
+ PORT_CheckConnection(port_handle, to_BD_ADDR(rem_bda), &lcid);
if (code == PORT_SUCCESS) {
evt_data.rfc_open.handle = p_cb->handle;
evt_data.rfc_open.status = BTA_JV_SUCCESS;
- bdcpy(evt_data.rfc_open.rem_bda, rem_bda);
+ evt_data.rfc_open.rem_bda = rem_bda;
p_pcb->state = BTA_JV_ST_CL_OPEN;
p_cb->p_cback(BTA_JV_RFCOMM_OPEN_EVT, &evt_data, p_pcb->rfcomm_slot_id);
} else {
@@ -1543,7 +1540,8 @@
if (evt_data.status == BTA_JV_SUCCESS &&
RFCOMM_CreateConnection(UUID_SERVCLASS_SERIAL_PORT, cc->remote_scn, false,
- BTA_JV_DEF_RFC_MTU, cc->peer_bd_addr, &handle,
+ BTA_JV_DEF_RFC_MTU, to_BD_ADDR(cc->peer_bd_addr),
+ &handle,
bta_jv_port_mgmt_cl_cback) != PORT_SUCCESS) {
APPL_TRACE_ERROR("bta_jv_rfcomm_connect, RFCOMM_CreateConnection failed");
evt_data.status = BTA_JV_FAILURE;
@@ -1644,7 +1642,7 @@
tBTA_JV_PCB* p_pcb = bta_jv_rfc_port_to_pcb(port_handle);
tBTA_JV_RFC_CB* p_cb = bta_jv_rfc_port_to_cb(port_handle);
tBTA_JV evt_data;
- BD_ADDR rem_bda;
+ bt_bdaddr_t rem_bda;
uint16_t lcid;
APPL_TRACE_DEBUG("bta_jv_port_mgmt_sr_cback, code:%d, port_handle:%d", code,
port_handle);
@@ -1659,12 +1657,12 @@
"p_pcb:%p, user:%d",
code, port_handle, p_cb->handle, p_pcb, p_pcb->rfcomm_slot_id);
- PORT_CheckConnection(port_handle, rem_bda, &lcid);
+ PORT_CheckConnection(port_handle, to_BD_ADDR(rem_bda), &lcid);
int failed = true;
if (code == PORT_SUCCESS) {
evt_data.rfc_srv_open.handle = p_pcb->handle;
evt_data.rfc_srv_open.status = BTA_JV_SUCCESS;
- bdcpy(evt_data.rfc_srv_open.rem_bda, rem_bda);
+ evt_data.rfc_srv_open.rem_bda = rem_bda;
tBTA_JV_PCB* p_pcb_new_listen = bta_jv_add_rfc_port(p_cb, p_pcb);
if (p_pcb_new_listen) {
evt_data.rfc_srv_open.new_listen_handle = p_pcb_new_listen->handle;
@@ -2115,37 +2113,41 @@
switch (state) {
case BTA_JV_CONN_OPEN:
- bta_sys_conn_open(BTA_ID_JV, p_cb->app_id, p_cb->peer_bd_addr);
+ bta_sys_conn_open(BTA_ID_JV, p_cb->app_id,
+ to_BD_ADDR(p_cb->peer_bd_addr));
break;
case BTA_JV_CONN_CLOSE:
- bta_sys_conn_close(BTA_ID_JV, p_cb->app_id, p_cb->peer_bd_addr);
+ bta_sys_conn_close(BTA_ID_JV, p_cb->app_id,
+ to_BD_ADDR(p_cb->peer_bd_addr));
break;
case BTA_JV_APP_OPEN:
- bta_sys_app_open(BTA_ID_JV, p_cb->app_id, p_cb->peer_bd_addr);
+ bta_sys_app_open(BTA_ID_JV, p_cb->app_id, to_BD_ADDR(p_cb->peer_bd_addr));
break;
case BTA_JV_APP_CLOSE:
- bta_sys_app_close(BTA_ID_JV, p_cb->app_id, p_cb->peer_bd_addr);
+ bta_sys_app_close(BTA_ID_JV, p_cb->app_id,
+ to_BD_ADDR(p_cb->peer_bd_addr));
break;
case BTA_JV_SCO_OPEN:
- bta_sys_sco_open(BTA_ID_JV, p_cb->app_id, p_cb->peer_bd_addr);
+ bta_sys_sco_open(BTA_ID_JV, p_cb->app_id, to_BD_ADDR(p_cb->peer_bd_addr));
break;
case BTA_JV_SCO_CLOSE:
- bta_sys_sco_close(BTA_ID_JV, p_cb->app_id, p_cb->peer_bd_addr);
+ bta_sys_sco_close(BTA_ID_JV, p_cb->app_id,
+ to_BD_ADDR(p_cb->peer_bd_addr));
break;
case BTA_JV_CONN_IDLE:
p_cb->state = BTA_JV_PM_IDLE_ST;
- bta_sys_idle(BTA_ID_JV, p_cb->app_id, p_cb->peer_bd_addr);
+ bta_sys_idle(BTA_ID_JV, p_cb->app_id, to_BD_ADDR(p_cb->peer_bd_addr));
break;
case BTA_JV_CONN_BUSY:
p_cb->state = BTA_JV_PM_BUSY_ST;
- bta_sys_busy(BTA_ID_JV, p_cb->app_id, p_cb->peer_bd_addr);
+ bta_sys_busy(BTA_ID_JV, p_cb->app_id, to_BD_ADDR(p_cb->peer_bd_addr));
break;
default:
@@ -2197,12 +2199,12 @@
/* pass NULL to find servers */
static struct fc_client* fcclient_find_by_addr(struct fc_client* start,
- BD_ADDR addr) {
+ const bt_bdaddr_t* addr) {
struct fc_client* t = start;
while (t) {
/* match client if have addr */
- if (addr && !memcmp(addr, &t->remote_addr, sizeof(t->remote_addr))) break;
+ if (addr && addr == &t->remote_addr) break;
/* match server if do not have addr */
if (!addr && t->server) break;
@@ -2314,7 +2316,7 @@
if (tc) {
t = fcclient_find_by_addr(
tc->clients,
- to_BD_ADDR(bd_addr)); // try to find an open socked for that addr
+ &bd_addr); // try to find an open socked for that addr
if (t) {
p_cback = t->p_cback;
l2cap_socket_id = t->l2cap_socket_id;
@@ -2327,8 +2329,7 @@
// it
new_conn = fcclient_alloc(chan, false, &t->sec_id);
if (new_conn) {
- memcpy(&new_conn->remote_addr, to_BD_ADDR(bd_addr),
- sizeof(new_conn->remote_addr));
+ new_conn->remote_addr = bd_addr;
new_conn->p_cback = NULL; // for now
new_conn->init_called = true; /*nop need to do it again */
@@ -2392,10 +2393,8 @@
tc = fcchan_get(chan, false);
if (tc) {
- t = fcclient_find_by_addr(
- tc->clients,
- to_BD_ADDR(
- bd_addr)); // try to find an open socked for that addr and channel
+ // try to find an open socked for that addr and channel
+ t = fcclient_find_by_addr(tc->clients, &bd_addr);
if (!t) {
// no socket -> drop it
return;
@@ -2437,11 +2436,11 @@
t->p_cback = cc->p_cback;
t->l2cap_socket_id = cc->l2cap_socket_id;
- memcpy(&t->remote_addr, &cc->peer_bd_addr, sizeof(t->remote_addr));
+ t->remote_addr = cc->peer_bd_addr;
id = t->id;
t->init_called = false;
- if (L2CA_ConnectFixedChnl(t->chan, from_BD_ADDR(t->remote_addr))) {
+ if (L2CA_ConnectFixedChnl(t->chan, t->remote_addr)) {
evt.l2c_cl_init.status = BTA_JV_SUCCESS;
evt.l2c_cl_init.handle = id;
}
diff --git a/bta/jv/bta_jv_api.cc b/bta/jv/bta_jv_api.cc
index c647999..8f6b34f 100644
--- a/bta/jv/bta_jv_api.cc
+++ b/bta/jv/bta_jv_api.cc
@@ -113,13 +113,12 @@
* false if not.
*
******************************************************************************/
-bool BTA_JvIsEncrypted(BD_ADDR bd_addr) {
+bool BTA_JvIsEncrypted(const bt_bdaddr_t& bd_addr) {
bool is_encrypted = false;
uint8_t sec_flags, le_flags;
- if (BTM_GetSecurityFlags(from_BD_ADDR(bd_addr), &sec_flags) &&
- BTM_GetSecurityFlagsByTransport(from_BD_ADDR(bd_addr), &le_flags,
- BT_TRANSPORT_LE)) {
+ if (BTM_GetSecurityFlags(bd_addr, &sec_flags) &&
+ BTM_GetSecurityFlagsByTransport(bd_addr, &le_flags, BT_TRANSPORT_LE)) {
if (sec_flags & BTM_SEC_FLAG_ENCRYPTED || le_flags & BTM_SEC_FLAG_ENCRYPTED)
is_encrypted = true;
}
@@ -214,8 +213,8 @@
* BTA_JV_FAILURE, otherwise.
*
******************************************************************************/
-tBTA_JV_STATUS BTA_JvStartDiscovery(BD_ADDR bd_addr, uint16_t num_uuid,
- tSDP_UUID* p_uuid_list,
+tBTA_JV_STATUS BTA_JvStartDiscovery(const bt_bdaddr_t& bd_addr,
+ uint16_t num_uuid, tSDP_UUID* p_uuid_list,
uint32_t rfcomm_slot_id) {
tBTA_JV_API_START_DISCOVERY* p_msg = (tBTA_JV_API_START_DISCOVERY*)osi_malloc(
sizeof(tBTA_JV_API_START_DISCOVERY));
@@ -223,7 +222,7 @@
APPL_TRACE_API("%s", __func__);
p_msg->hdr.event = BTA_JV_API_START_DISCOVERY_EVT;
- bdcpy(p_msg->bd_addr, bd_addr);
+ p_msg->bd_addr = bd_addr;
p_msg->num_uuid = num_uuid;
memcpy(p_msg->uuid_list, p_uuid_list, num_uuid * sizeof(tSDP_UUID));
p_msg->num_attr = 0;
@@ -302,7 +301,8 @@
tBTA_JV_STATUS BTA_JvL2capConnectLE(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
const tL2CAP_ERTM_INFO* ertm_info,
uint16_t remote_chan, uint16_t rx_mtu,
- tL2CAP_CFG_INFO* cfg, BD_ADDR peer_bd_addr,
+ tL2CAP_CFG_INFO* cfg,
+ const bt_bdaddr_t& peer_bd_addr,
tBTA_JV_L2CAP_CBACK* p_cback,
uint32_t l2cap_socket_id) {
APPL_TRACE_API("%s", __func__);
@@ -328,7 +328,7 @@
} else {
p_msg->has_ertm_info = false;
}
- memcpy(p_msg->peer_bd_addr, peer_bd_addr, sizeof(BD_ADDR));
+ p_msg->peer_bd_addr = peer_bd_addr;
p_msg->p_cback = p_cback;
p_msg->l2cap_socket_id = l2cap_socket_id;
@@ -352,13 +352,11 @@
* BTA_JV_FAILURE, otherwise.
*
******************************************************************************/
-tBTA_JV_STATUS BTA_JvL2capConnect(int conn_type, tBTA_SEC sec_mask,
- tBTA_JV_ROLE role,
- const tL2CAP_ERTM_INFO* ertm_info,
- uint16_t remote_psm, uint16_t rx_mtu,
- tL2CAP_CFG_INFO* cfg, BD_ADDR peer_bd_addr,
- tBTA_JV_L2CAP_CBACK* p_cback,
- uint32_t l2cap_socket_id) {
+tBTA_JV_STATUS BTA_JvL2capConnect(
+ int conn_type, tBTA_SEC sec_mask, tBTA_JV_ROLE role,
+ const tL2CAP_ERTM_INFO* ertm_info, uint16_t remote_psm, uint16_t rx_mtu,
+ tL2CAP_CFG_INFO* cfg, const bt_bdaddr_t& peer_bd_addr,
+ tBTA_JV_L2CAP_CBACK* p_cback, uint32_t l2cap_socket_id) {
APPL_TRACE_API("%s", __func__);
if (p_cback == NULL) return BTA_JV_FAILURE; /* Nothing to do */
@@ -383,7 +381,7 @@
} else {
p_msg->has_ertm_info = false;
}
- memcpy(p_msg->peer_bd_addr, peer_bd_addr, sizeof(BD_ADDR));
+ p_msg->peer_bd_addr = peer_bd_addr;
p_msg->p_cback = p_cback;
p_msg->l2cap_socket_id = l2cap_socket_id;
@@ -722,7 +720,7 @@
* BTA_JV_FAILURE, otherwise.
*
******************************************************************************/
-tBTA_JV_STATUS BTA_JvL2capWriteFixed(uint16_t channel, BD_ADDR* addr,
+tBTA_JV_STATUS BTA_JvL2capWriteFixed(uint16_t channel, const bt_bdaddr_t& addr,
uint32_t req_id,
tBTA_JV_L2CAP_CBACK* p_cback,
uint8_t* p_data, uint16_t len,
@@ -735,7 +733,7 @@
p_msg->hdr.event = BTA_JV_API_L2CAP_WRITE_FIXED_EVT;
p_msg->channel = channel;
- memcpy(p_msg->addr, addr, sizeof(p_msg->addr));
+ p_msg->addr = addr;
p_msg->req_id = req_id;
p_msg->p_data = p_data;
p_msg->p_cback = p_cback;
@@ -764,7 +762,8 @@
*
******************************************************************************/
tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
- uint8_t remote_scn, BD_ADDR peer_bd_addr,
+ uint8_t remote_scn,
+ const bt_bdaddr_t& peer_bd_addr,
tBTA_JV_RFCOMM_CBACK* p_cback,
uint32_t rfcomm_slot_id) {
APPL_TRACE_API("%s", __func__);
@@ -777,7 +776,7 @@
p_msg->sec_mask = sec_mask;
p_msg->role = role;
p_msg->remote_scn = remote_scn;
- memcpy(p_msg->peer_bd_addr, peer_bd_addr, sizeof(BD_ADDR));
+ p_msg->peer_bd_addr = peer_bd_addr;
p_msg->p_cback = p_cback;
p_msg->rfcomm_slot_id = rfcomm_slot_id;
diff --git a/bta/jv/bta_jv_int.h b/bta/jv/bta_jv_int.h
index 6b445ab..46b5b32 100644
--- a/bta/jv/bta_jv_int.h
+++ b/bta/jv/bta_jv_int.h
@@ -78,7 +78,7 @@
/* data type for BTA_JV_API_START_DISCOVERY_EVT */
typedef struct {
BT_HDR hdr;
- BD_ADDR bd_addr;
+ bt_bdaddr_t bd_addr;
uint16_t num_uuid;
tSDP_UUID uuid_list[BTA_JV_MAX_UUIDS];
uint16_t num_attr;
@@ -97,7 +97,7 @@
uint32_t handle; /* The connection handle */
uint8_t state; /* state: see above enum */
tBTA_JV_PM_ID app_id; /* JV app specific id indicating power table to use */
- BD_ADDR peer_bd_addr; /* Peer BD address */
+ bt_bdaddr_t peer_bd_addr; /* Peer BD address */
} tBTA_JV_PM_CB;
enum {
@@ -163,7 +163,7 @@
uint16_t remote_chan;
};
uint16_t rx_mtu;
- BD_ADDR peer_bd_addr;
+ bt_bdaddr_t peer_bd_addr;
int32_t has_cfg;
tL2CAP_CFG_INFO cfg;
int32_t has_ertm_info;
@@ -224,7 +224,7 @@
typedef struct {
BT_HDR hdr;
uint16_t channel;
- BD_ADDR addr;
+ bt_bdaddr_t addr;
uint32_t req_id;
tBTA_JV_L2CAP_CBACK* p_cback;
uint8_t* p_data;
@@ -238,7 +238,7 @@
tBTA_SEC sec_mask;
tBTA_JV_ROLE role;
uint8_t remote_scn;
- BD_ADDR peer_bd_addr;
+ bt_bdaddr_t peer_bd_addr;
tBTA_JV_RFCOMM_CBACK* p_cback;
uint32_t rfcomm_slot_id;
} tBTA_JV_API_RFCOMM_CONNECT;
diff --git a/btif/src/btif_gatt_util.cc b/btif/src/btif_gatt_util.cc
index cb6ebe1..647c93b 100644
--- a/btif/src/btif_gatt_util.cc
+++ b/btif/src/btif_gatt_util.cc
@@ -213,7 +213,7 @@
#if (BLE_DELAY_REQUEST_ENC == FALSE)
static bool btif_gatt_is_link_encrypted(const bt_bdaddr_t& bd_addr) {
- return BTA_JvIsEncrypted(to_BD_ADDR(bd_addr));
+ return BTA_JvIsEncrypted(bd_addr);
}
static void btif_gatt_set_encryption_cb(UNUSED_ATTR const bt_bdaddr_t& bd_addr,
diff --git a/btif/src/btif_sock_l2cap.cc b/btif/src/btif_sock_l2cap.cc
index d839b55..23a9b6e 100644
--- a/btif/src/btif_sock_l2cap.cc
+++ b/btif/src/btif_sock_l2cap.cc
@@ -1,19 +1,19 @@
/*
-* Copyright (C) 2014 Samsung System LSI
-* Copyright (C) 2013 The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Copyright (C) 2014 Samsung System LSI
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#define LOG_TAG "bt_btif_sock"
@@ -197,14 +197,6 @@
return true;
}
-static inline void bd_copy(uint8_t* dest, uint8_t* src, bool swap) {
- if (swap) {
- for (int i = 0; i < 6; i++) dest[i] = src[5 - i];
- } else {
- memcpy(dest, src, 6);
- }
-}
-
static char is_inited(void) {
std::unique_lock<std::mutex> lock(state_lock);
return pth != -1;
@@ -442,8 +434,7 @@
uint32_t new_listen_id;
// std::mutex locked by caller
- accept_rs = btsock_l2cap_alloc_l(
- sock->name, (const bt_bdaddr_t*)p_open->rem_bda, false, 0);
+ accept_rs = btsock_l2cap_alloc_l(sock->name, &p_open->rem_bda, false, 0);
accept_rs->connected = true;
accept_rs->security = sock->security;
accept_rs->fixed_chan = sock->fixed_chan;
@@ -490,8 +481,7 @@
uint32_t new_listen_id;
// std::mutex locked by caller
- accept_rs = btsock_l2cap_alloc_l(
- sock->name, (const bt_bdaddr_t*)p_open->rem_bda, false, 0);
+ accept_rs = btsock_l2cap_alloc_l(sock->name, &p_open->rem_bda, false, 0);
if (accept_rs) {
// swap IDs
new_listen_id = accept_rs->id;
@@ -527,7 +517,7 @@
static void on_cl_l2cap_psm_connect_l(tBTA_JV_L2CAP_OPEN* p_open,
l2cap_socket* sock) {
- bd_copy(sock->addr.address, p_open->rem_bda, 0);
+ sock->addr = p_open->rem_bda;
if (!send_app_psm_or_chan_l(sock)) {
APPL_TRACE_ERROR("send_app_psm_or_chan_l failed");
@@ -550,7 +540,7 @@
static void on_cl_l2cap_le_connect_l(tBTA_JV_L2CAP_LE_OPEN* p_open,
l2cap_socket* sock) {
- bd_copy(sock->addr.address, p_open->rem_bda, 0);
+ sock->addr = p_open->rem_bda;
if (!send_app_psm_or_chan_l(sock)) {
APPL_TRACE_ERROR("send_app_psm_or_chan_l failed");
@@ -926,7 +916,7 @@
} else {
if (fixed_chan) {
if (BTA_JvL2capConnectLE(sock->security, 0, NULL, channel,
- L2CAP_DEFAULT_MTU, NULL, sock->addr.address,
+ L2CAP_DEFAULT_MTU, NULL, sock->addr,
btsock_l2cap_cbk, sock->id) != BTA_JV_SUCCESS)
stat = BT_STATUS_FAIL;
@@ -934,13 +924,13 @@
if (sock->is_le_coc) {
if (BTA_JvL2capConnect(BTA_JV_CONN_TYPE_L2CAP_LE, sock->security, 0,
NULL, channel, L2CAP_MAX_SDU_LENGTH, &cfg,
- sock->addr.address, btsock_l2cap_cbk,
+ sock->addr, btsock_l2cap_cbk,
sock->id) != BTA_JV_SUCCESS)
stat = BT_STATUS_FAIL;
} else {
if (BTA_JvL2capConnect(BTA_JV_CONN_TYPE_L2CAP, sock->security, 0,
&obex_l2c_etm_opt, channel, L2CAP_MAX_SDU_LENGTH,
- &cfg, sock->addr.address, btsock_l2cap_cbk,
+ &cfg, sock->addr, btsock_l2cap_cbk,
sock->id) != BTA_JV_SUCCESS)
stat = BT_STATUS_FAIL;
}
@@ -1050,7 +1040,7 @@
"btsock_l2cap_signaled - %d bytes received from socket", count);
if (sock->fixed_chan) {
- if (BTA_JvL2capWriteFixed(sock->channel, (BD_ADDR*)&sock->addr,
+ if (BTA_JvL2capWriteFixed(sock->channel, sock->addr,
PTR_TO_UINT(buffer), btsock_l2cap_cbk,
buffer, count, user_id) != BTA_JV_SUCCESS) {
// On fail, free the buffer
diff --git a/btif/src/btif_sock_rfc.cc b/btif/src/btif_sock_rfc.cc
index 1db39ae..abb8b4f 100644
--- a/btif/src/btif_sock_rfc.cc
+++ b/btif/src/btif_sock_rfc.cc
@@ -353,8 +353,8 @@
if (is_uuid_empty(service_uuid)) {
tBTA_JV_STATUS ret =
- BTA_JvRfcommConnect(slot->security, slot->role, slot->scn,
- slot->addr.address, rfcomm_cback, slot->id);
+ BTA_JvRfcommConnect(slot->security, slot->role, slot->scn, slot->addr,
+ rfcomm_cback, slot->id);
if (ret != BTA_JV_SUCCESS) {
LOG_ERROR(LOG_TAG, "%s unable to initiate RFCOMM connection: %d",
__func__, ret);
@@ -373,7 +373,7 @@
memcpy(sdp_uuid.uu.uuid128, service_uuid, sizeof(sdp_uuid.uu.uuid128));
if (!is_requesting_sdp()) {
- BTA_JvStartDiscovery((uint8_t*)bd_addr->address, 1, &sdp_uuid, slot->id);
+ BTA_JvStartDiscovery(*bd_addr, 1, &sdp_uuid, slot->id);
slot->f.pending_sdp_request = false;
slot->f.doing_sdp_request = true;
} else {
@@ -501,9 +501,8 @@
rfc_slot_t* srv_rs = find_rfc_slot_by_id(id);
if (!srv_rs) return 0;
- accept_rs =
- create_srv_accept_rfc_slot(srv_rs, (const bt_bdaddr_t*)p_open->rem_bda,
- p_open->handle, p_open->new_listen_handle);
+ accept_rs = create_srv_accept_rfc_slot(
+ srv_rs, &p_open->rem_bda, p_open->handle, p_open->new_listen_handle);
if (!accept_rs) return 0;
// Start monitoring the socket.
@@ -529,7 +528,7 @@
}
slot->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_open->handle);
- memcpy(slot->addr.address, p_open->rem_bda, 6);
+ slot->addr = p_open->rem_bda;
if (send_app_connect_signal(slot->fd, &slot->addr, slot->scn, 0, -1)) {
slot->f.connected = true;
@@ -710,7 +709,7 @@
// Establish the connection if we successfully looked up a channel
// number to connect to.
if (BTA_JvRfcommConnect(slot->security, slot->role,
- p_data->disc_comp.scn, slot->addr.address,
+ p_data->disc_comp.scn, slot->addr,
rfcomm_cback, slot->id) == BTA_JV_SUCCESS) {
slot->scn = p_data->disc_comp.scn;
slot->f.doing_sdp_request = false;
@@ -737,8 +736,7 @@
sdp_uuid.len = 16;
memcpy(sdp_uuid.uu.uuid128, slot->service_uuid,
sizeof(sdp_uuid.uu.uuid128));
- BTA_JvStartDiscovery((uint8_t*)slot->addr.address, 1, &sdp_uuid,
- slot->id);
+ BTA_JvStartDiscovery(slot->addr, 1, &sdp_uuid, slot->id);
slot->f.pending_sdp_request = false;
slot->f.doing_sdp_request = true;
}