mirror of https://github.com/ARMmbed/mbed-os.git
BLE: Use peer_address_type_t instead of the legacy address in security manager.
parent
a052afdd40
commit
d361960aa3
|
@ -381,11 +381,12 @@ private:
|
||||||
virtual void on_connected(
|
virtual void on_connected(
|
||||||
connection_handle_t connection,
|
connection_handle_t connection,
|
||||||
Gap::Role_t role,
|
Gap::Role_t role,
|
||||||
BLEProtocol::AddressType_t peer_address_type,
|
peer_address_type_t peer_address_type,
|
||||||
const BLEProtocol::AddressBytes_t peer_address,
|
const BLEProtocol::AddressBytes_t peer_address,
|
||||||
BLEProtocol::AddressType_t local_address_type,
|
BLEProtocol::AddressType_t local_address_type,
|
||||||
const BLEProtocol::AddressBytes_t local_address,
|
const BLEProtocol::AddressBytes_t local_address,
|
||||||
const Gap::ConnectionParams_t *connection_params
|
const Gap::ConnectionParams_t *connection_params,
|
||||||
|
const BLEProtocol::AddressBytes_t resolved_peer_address
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -440,7 +440,7 @@ public:
|
||||||
* @return A handle to the entry.
|
* @return A handle to the entry.
|
||||||
*/
|
*/
|
||||||
virtual entry_handle_t open_entry(
|
virtual entry_handle_t open_entry(
|
||||||
BLEProtocol::AddressType_t peer_address_type,
|
peer_address_type_t peer_address_type,
|
||||||
const address_t &peer_address
|
const address_t &peer_address
|
||||||
) {
|
) {
|
||||||
entry_handle_t db_handle = find_entry_by_peer_address(peer_address_type, peer_address);
|
entry_handle_t db_handle = find_entry_by_peer_address(peer_address_type, peer_address);
|
||||||
|
@ -451,8 +451,8 @@ public:
|
||||||
SecurityDistributionFlags_t* flags = get_free_entry_flags();
|
SecurityDistributionFlags_t* flags = get_free_entry_flags();
|
||||||
if (flags) {
|
if (flags) {
|
||||||
const bool peer_address_public =
|
const bool peer_address_public =
|
||||||
(peer_address_type == BLEProtocol::AddressType::PUBLIC) ||
|
(peer_address_type == peer_address_type_t::PUBLIC) ||
|
||||||
(peer_address_type == BLEProtocol::AddressType::PUBLIC_IDENTITY);
|
(peer_address_type == peer_address_type_t::PUBLIC_IDENTITY);
|
||||||
/* we need some address to store, so we store even random ones
|
/* we need some address to store, so we store even random ones
|
||||||
* this address will be used as an id, possibly replaced later
|
* this address will be used as an id, possibly replaced later
|
||||||
* by identity address */
|
* by identity address */
|
||||||
|
@ -473,12 +473,12 @@ public:
|
||||||
* @return A handle to the entry.
|
* @return A handle to the entry.
|
||||||
*/
|
*/
|
||||||
virtual entry_handle_t find_entry_by_peer_address(
|
virtual entry_handle_t find_entry_by_peer_address(
|
||||||
BLEProtocol::AddressType_t peer_address_type,
|
peer_address_type_t peer_address_type,
|
||||||
const address_t &peer_address
|
const address_t &peer_address
|
||||||
) {
|
) {
|
||||||
const bool peer_address_public =
|
const bool peer_address_public =
|
||||||
(peer_address_type == BLEProtocol::AddressType::PUBLIC) ||
|
(peer_address_type == peer_address_type_t::PUBLIC) ||
|
||||||
(peer_address_type == BLEProtocol::AddressType::PUBLIC_IDENTITY);
|
(peer_address_type == peer_address_type_t::PUBLIC_IDENTITY);
|
||||||
|
|
||||||
for (size_t i = 0; i < get_entry_count(); i++) {
|
for (size_t i = 0; i < get_entry_count(); i++) {
|
||||||
entry_handle_t db_handle = get_entry_handle_by_index(i);
|
entry_handle_t db_handle = get_entry_handle_by_index(i);
|
||||||
|
@ -486,7 +486,7 @@ public:
|
||||||
|
|
||||||
/* only look among disconnected entries */
|
/* only look among disconnected entries */
|
||||||
if (flags && !flags->connected) {
|
if (flags && !flags->connected) {
|
||||||
if (peer_address_type == BLEProtocol::AddressType::PUBLIC_IDENTITY &&
|
if (peer_address_type == peer_address_type_t::PUBLIC_IDENTITY &&
|
||||||
flags->irk_stored == false) {
|
flags->irk_stored == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -536,7 +536,7 @@ public:
|
||||||
* @return A handle to the entry.
|
* @return A handle to the entry.
|
||||||
*/
|
*/
|
||||||
virtual void remove_entry(
|
virtual void remove_entry(
|
||||||
BLEProtocol::AddressType_t peer_address_type,
|
peer_address_type_t peer_address_type,
|
||||||
const address_t &peer_address
|
const address_t &peer_address
|
||||||
) {
|
) {
|
||||||
entry_handle_t db_handle = find_entry_by_peer_address(peer_address_type, peer_address);
|
entry_handle_t db_handle = find_entry_by_peer_address(peer_address_type, peer_address);
|
||||||
|
|
|
@ -48,15 +48,18 @@ public:
|
||||||
* @param[in] local_address_type type of address of the local device.
|
* @param[in] local_address_type type of address of the local device.
|
||||||
* @param[in] local_address Address of the local device that was used during connection.
|
* @param[in] local_address Address of the local device that was used during connection.
|
||||||
* @param[in] connection_params connection parameters like interval, latency and timeout.
|
* @param[in] connection_params connection parameters like interval, latency and timeout.
|
||||||
|
* @param[in] resolved_peer_address resolved address of the peer; may
|
||||||
|
* be NULL.
|
||||||
*/
|
*/
|
||||||
virtual void on_connected(
|
virtual void on_connected(
|
||||||
connection_handle_t connection,
|
connection_handle_t connection,
|
||||||
::Gap::Role_t role,
|
::Gap::Role_t role,
|
||||||
BLEProtocol::AddressType_t peer_address_type,
|
ble::peer_address_type_t peer_address_type,
|
||||||
const BLEProtocol::AddressBytes_t peer_address,
|
const BLEProtocol::AddressBytes_t peer_address,
|
||||||
BLEProtocol::AddressType_t local_address_type,
|
BLEProtocol::AddressType_t local_address_type,
|
||||||
const BLEProtocol::AddressBytes_t local_address,
|
const BLEProtocol::AddressBytes_t local_address,
|
||||||
const ::Gap::ConnectionParams_t *connection_params
|
const ::Gap::ConnectionParams_t *connection_params,
|
||||||
|
const BLEProtocol::AddressBytes_t resolved_peer_address
|
||||||
) = 0;
|
) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -964,11 +964,12 @@ void GenericSecurityManager::set_mitm_performed(connection_handle_t connection,
|
||||||
void GenericSecurityManager::on_connected(
|
void GenericSecurityManager::on_connected(
|
||||||
connection_handle_t connection,
|
connection_handle_t connection,
|
||||||
Gap::Role_t role,
|
Gap::Role_t role,
|
||||||
BLEProtocol::AddressType_t peer_address_type,
|
peer_address_type_t peer_address_type,
|
||||||
const BLEProtocol::AddressBytes_t peer_address,
|
const BLEProtocol::AddressBytes_t peer_address,
|
||||||
BLEProtocol::AddressType_t local_address_type,
|
BLEProtocol::AddressType_t local_address_type,
|
||||||
const BLEProtocol::AddressBytes_t local_address,
|
const BLEProtocol::AddressBytes_t local_address,
|
||||||
const Gap::ConnectionParams_t *connection_params
|
const Gap::ConnectionParams_t *connection_params,
|
||||||
|
const BLEProtocol::AddressBytes_t resolved_peer_address
|
||||||
) {
|
) {
|
||||||
MBED_ASSERT(_db);
|
MBED_ASSERT(_db);
|
||||||
ControlBlock_t *cb = acquire_control_block(connection);
|
ControlBlock_t *cb = acquire_control_block(connection);
|
||||||
|
@ -980,13 +981,20 @@ void GenericSecurityManager::on_connected(
|
||||||
cb->local_address = local_address;
|
cb->local_address = local_address;
|
||||||
cb->is_master = (role == Gap::CENTRAL);
|
cb->is_master = (role == Gap::CENTRAL);
|
||||||
|
|
||||||
|
// normalize the address
|
||||||
|
if (resolved_peer_address && resolved_peer_address != ble::address_t()) {
|
||||||
|
peer_address = resolved_peer_address;
|
||||||
|
}
|
||||||
|
|
||||||
// get the associated db handle and the distribution flags if any
|
// get the associated db handle and the distribution flags if any
|
||||||
cb->db_entry = _db->open_entry(peer_address_type, peer_address);
|
cb->db_entry = _db->open_entry(peer_address_type, peer_address);
|
||||||
|
|
||||||
SecurityDistributionFlags_t* flags = _db->get_distribution_flags(cb->db_entry);
|
SecurityDistributionFlags_t* flags = _db->get_distribution_flags(cb->db_entry);
|
||||||
|
|
||||||
flags->peer_address = peer_address;
|
flags->peer_address = peer_address;
|
||||||
flags->peer_address_is_public = (peer_address_type == BLEProtocol::AddressType::PUBLIC);
|
flags->peer_address_is_public =
|
||||||
|
(peer_address_type == peer_address_type_t::PUBLIC) ||
|
||||||
|
(peer_address_type == peer_address_type_t::PUBLIC_IDENTITY);
|
||||||
|
|
||||||
const bool signing = cb->signing_override_default ?
|
const bool signing = cb->signing_override_default ?
|
||||||
cb->signing_requested :
|
cb->signing_requested :
|
||||||
|
|
Loading…
Reference in New Issue