BLE: Move privacy subsystem to ::ble::Gap.

pull/8738/head
Vincent Coubard 2018-11-20 18:33:04 +00:00
parent c54e0d9862
commit 586aea553b
4 changed files with 232 additions and 211 deletions

View File

@ -865,119 +865,11 @@ public:
{}
};
/**
* Privacy Configuration of the peripheral role.
*
* @note This configuration also applies to the broadcaster role configuration.
*/
struct PeripheralPrivacyConfiguration_t {
/**
* Indicates if non resolvable random address should be used when the
* peripheral advertises non connectable packets.
*
* Resolvable random address continues to be used for connectable packets.
*/
bool use_non_resolvable_random_address;
/**
* Resolution strategy for initiator resolvable addresses when a
* connection request is received.
*/
enum ResolutionStrategy {
/**
* Do not resolve the address of the initiator and accept the
* connection request.
*/
DO_NOT_RESOLVE,
/**
* If a bond is present in the secure database and the address
* resolution fail then reject the connection request with the error
* code AUTHENTICATION_FAILLURE.
*/
REJECT_NON_RESOLVED_ADDRESS,
/**
* Perform the pairing procedure if the initiator resolvable
* address failed the resolution process.
*/
PERFORM_PAIRING_PROCEDURE,
/**
* Perform the authentication procedure if the initiator resolvable
* address failed the resolution process.
*/
PERFORM_AUTHENTICATION_PROCEDURE
};
/**
* Connection strategy to use when a connection request contains a
* private resolvable address.
*/
ResolutionStrategy resolution_strategy;
};
/**
* Privacy Configuration of the central role.
*
* @note This configuration is also used when the local device operates as
* an observer.
*/
struct CentralPrivacyConfiguration_t {
/**
* Indicates if non resolvable random address should be used when the
* central or observer sends scan request packets.
*
* Resolvable random address continue to be used for connection requests.
*/
bool use_non_resolvable_random_address;
/**
* Resolution strategy of resolvable addresses received in advertising
* packets.
*/
enum ResolutionStrategy {
/**
* Do not resolve the address received in advertising packets.
*/
DO_NOT_RESOLVE,
/**
* Resolve the resolvable addresses in the advertising packet and
* forward advertising packet to the application independently of
* the address resolution procedure result.
*/
RESOLVE_AND_FORWARD,
/**
* Filter out packets containing a resolvable that cannot be resolved
* by this device.
*
* @note Filtering is applied if the local device contains at least
* one bond.
*/
RESOLVE_AND_FILTER
};
/**
* Resolution strategy applied to advertising packets received by the
* local device.
*/
ResolutionStrategy resolution_strategy;
};
/**
* Number of microseconds in 1.25 milliseconds.
*/
static const uint16_t UNIT_1_25_MS = 1250;
static const PeripheralPrivacyConfiguration_t
default_peripheral_privacy_configuration;
static const CentralPrivacyConfiguration_t
default_central_privacy_configuration;
/**
* Convert milliseconds into 1.25ms units.
*
@ -2247,97 +2139,6 @@ public:
)
virtual ble_error_t initRadioNotification(void);
/**
* Enable or disable privacy mode of the local device.
*
* When privacy is enabled, the system use private addresses while it scans,
* advertises or initiate a connection. The device private address is
* renewed every 15 minutes.
*
* @par Configuration
*
* The privacy feature can be configured with the help of the functions
* setPeripheralPrivacyConfiguration and setCentralPrivacyConfiguration
* which respectively set the privacy configuration of the peripheral and
* central role.
*
* @par Default configuration of peripheral role
*
* By default private resolvable addresses are used for all procedures;
* including advertisement of non connectable packets. Connection request
* from an unknown initiator with a private resolvable address triggers the
* pairing procedure.
*
* @par Default configuration of central role
*
* By default private resolvable addresses are used for all procedures;
* including active scanning. Addresses present in advertisement packet are
* resolved and advertisement packets are forwarded to the application
* even if the advertiser private address is unknown.
*
* @param[in] enable Should be set to true to enable the privacy mode and
* false to disable it.
*
* @return BLE_ERROR_NONE in case of success or an appropriate error code.
*/
virtual ble_error_t enablePrivacy(bool enable) {
return BLE_ERROR_NOT_IMPLEMENTED;
}
/**
* Set the privacy configuration used by the peripheral role.
*
* @param[in] configuration The configuration to set.
*
* @return BLE_ERROR_NONE in case of success or an appropriate error code.
*/
virtual ble_error_t setPeripheralPrivacyConfiguration(
const PeripheralPrivacyConfiguration_t *configuration
) {
return BLE_ERROR_NOT_IMPLEMENTED;
}
/**
* Get the privacy configuration used by the peripheral role.
*
* @param[out] configuration The variable filled with the current
* configuration.
*
* @return BLE_ERROR_NONE in case of success or an appropriate error code.
*/
virtual ble_error_t getPeripheralPrivacyConfiguration(
PeripheralPrivacyConfiguration_t *configuration
) {
return BLE_ERROR_NOT_IMPLEMENTED;
}
/**
* Set the privacy configuration used by the central role.
*
* @param[in] configuration The configuration to set.
*
* @return BLE_ERROR_NONE in case of success or an appropriate error code.
*/
virtual ble_error_t setCentralPrivacyConfiguration(
const CentralPrivacyConfiguration_t *configuration
) {
return BLE_ERROR_NOT_IMPLEMENTED;
}
/**
* Get the privacy configuration used by the central role.
*
* @param[out] configuration The variable filled with the current
* configuration.
*
* @return BLE_ERROR_NONE in case of success or an appropriate error code.
*/
virtual ble_error_t getCentralPrivacyConfiguration(
CentralPrivacyConfiguration_t *configuration
) {
return BLE_ERROR_NOT_IMPLEMENTED;
}
private:
/**
* Set the advertising data and scan response in the vendor subsytem.

View File

@ -595,7 +595,196 @@ protected:
/* -------- soon to be deprecated API -------- */
public:
/**
* Privacy Configuration of the peripheral role.
*
* @note This configuration also applies to the broadcaster role configuration.
*/
struct PeripheralPrivacyConfiguration_t {
/**
* Indicates if non resolvable random address should be used when the
* peripheral advertises non connectable packets.
*
* Resolvable random address continues to be used for connectable packets.
*/
bool use_non_resolvable_random_address;
/**
* Resolution strategy for initiator resolvable addresses when a
* connection request is received.
*/
enum ResolutionStrategy {
/**
* Do not resolve the address of the initiator and accept the
* connection request.
*/
DO_NOT_RESOLVE,
/**
* If a bond is present in the secure database and the address
* resolution fail then reject the connection request with the error
* code AUTHENTICATION_FAILLURE.
*/
REJECT_NON_RESOLVED_ADDRESS,
/**
* Perform the pairing procedure if the initiator resolvable
* address failed the resolution process.
*/
PERFORM_PAIRING_PROCEDURE,
/**
* Perform the authentication procedure if the initiator resolvable
* address failed the resolution process.
*/
PERFORM_AUTHENTICATION_PROCEDURE
};
/**
* Connection strategy to use when a connection request contains a
* private resolvable address.
*/
ResolutionStrategy resolution_strategy;
};
/**
* Privacy Configuration of the central role.
*
* @note This configuration is also used when the local device operates as
* an observer.
*/
struct CentralPrivacyConfiguration_t {
/**
* Indicates if non resolvable random address should be used when the
* central or observer sends scan request packets.
*
* Resolvable random address continue to be used for connection requests.
*/
bool use_non_resolvable_random_address;
/**
* Resolution strategy of resolvable addresses received in advertising
* packets.
*/
enum ResolutionStrategy {
/**
* Do not resolve the address received in advertising packets.
*/
DO_NOT_RESOLVE,
/**
* Resolve the resolvable addresses in the advertising packet and
* forward advertising packet to the application independently of
* the address resolution procedure result.
*/
RESOLVE_AND_FORWARD,
/**
* Filter out packets containing a resolvable that cannot be resolved
* by this device.
*
* @note Filtering is applied if the local device contains at least
* one bond.
*/
RESOLVE_AND_FILTER
};
/**
* Resolution strategy applied to advertising packets received by the
* local device.
*/
ResolutionStrategy resolution_strategy;
};
static const PeripheralPrivacyConfiguration_t
default_peripheral_privacy_configuration;
static const CentralPrivacyConfiguration_t
default_central_privacy_configuration;
/**
* Enable or disable privacy mode of the local device.
*
* When privacy is enabled, the system use private addresses while it scans,
* advertises or initiate a connection. The device private address is
* renewed every 15 minutes.
*
* @par Configuration
*
* The privacy feature can be configured with the help of the functions
* setPeripheralPrivacyConfiguration and setCentralPrivacyConfiguration
* which respectively set the privacy configuration of the peripheral and
* central role.
*
* @par Default configuration of peripheral role
*
* By default private resolvable addresses are used for all procedures;
* including advertisement of non connectable packets. Connection request
* from an unknown initiator with a private resolvable address triggers the
* pairing procedure.
*
* @par Default configuration of central role
*
* By default private resolvable addresses are used for all procedures;
* including active scanning. Addresses present in advertisement packet are
* resolved and advertisement packets are forwarded to the application
* even if the advertiser private address is unknown.
*
* @param[in] enable Should be set to true to enable the privacy mode and
* false to disable it.
*
* @return BLE_ERROR_NONE in case of success or an appropriate error code.
*/
virtual ble_error_t enablePrivacy(bool enable);
/**
* Set the privacy configuration used by the peripheral role.
*
* @param[in] configuration The configuration to set.
*
* @return BLE_ERROR_NONE in case of success or an appropriate error code.
*/
virtual ble_error_t setPeripheralPrivacyConfiguration(
const PeripheralPrivacyConfiguration_t *configuration
);
/**
* Get the privacy configuration used by the peripheral role.
*
* @param[out] configuration The variable filled with the current
* configuration.
*
* @return BLE_ERROR_NONE in case of success or an appropriate error code.
*/
virtual ble_error_t getPeripheralPrivacyConfiguration(
PeripheralPrivacyConfiguration_t *configuration
);
/**
* Set the privacy configuration used by the central role.
*
* @param[in] configuration The configuration to set.
*
* @return BLE_ERROR_NONE in case of success or an appropriate error code.
*/
virtual ble_error_t setCentralPrivacyConfiguration(
const CentralPrivacyConfiguration_t *configuration
);
/**
* Get the privacy configuration used by the central role.
*
* @param[out] configuration The variable filled with the current
* configuration.
*
* @return BLE_ERROR_NONE in case of success or an appropriate error code.
*/
virtual ble_error_t getCentralPrivacyConfiguration(
CentralPrivacyConfiguration_t *configuration
);
protected:
/**

View File

@ -87,18 +87,6 @@ ble_error_t Gap::setWhitelist(const Whitelist_t &whitelist)
return BLE_ERROR_NOT_IMPLEMENTED;
}
const Gap::PeripheralPrivacyConfiguration_t Gap::default_peripheral_privacy_configuration = {
/* use_non_resolvable_random_address */ false,
/* resolution_strategy */ PeripheralPrivacyConfiguration_t::PERFORM_PAIRING_PROCEDURE
};
const Gap::CentralPrivacyConfiguration_t Gap::default_central_privacy_configuration = {
/* use_non_resolvable_random_address */ false,
/* resolution_strategy */ CentralPrivacyConfiguration_t::RESOLVE_AND_FORWARD
};
void Gap::processConnectionEvent(
Handle_t handle,
Role_t role,

View File

@ -294,5 +294,48 @@ ble_error_t Gap::setPhy(
return BLE_ERROR_NOT_IMPLEMENTED;
}
/* -------------------- Future deprecation ------------------------- */
const Gap::PeripheralPrivacyConfiguration_t Gap::default_peripheral_privacy_configuration = {
/* use_non_resolvable_random_address */ false,
/* resolution_strategy */ PeripheralPrivacyConfiguration_t::PERFORM_PAIRING_PROCEDURE
};
const Gap::CentralPrivacyConfiguration_t Gap::default_central_privacy_configuration = {
/* use_non_resolvable_random_address */ false,
/* resolution_strategy */ CentralPrivacyConfiguration_t::RESOLVE_AND_FORWARD
};
ble_error_t Gap::enablePrivacy(bool enable)
{
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t Gap::setPeripheralPrivacyConfiguration(
const PeripheralPrivacyConfiguration_t *configuration
) {
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t Gap::getPeripheralPrivacyConfiguration(
PeripheralPrivacyConfiguration_t *configuration
) {
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t Gap::setCentralPrivacyConfiguration(
const CentralPrivacyConfiguration_t *configuration
) {
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t Gap::getCentralPrivacyConfiguration(
CentralPrivacyConfiguration_t *configuration
) {
return BLE_ERROR_NOT_IMPLEMENTED;
}
} // namespace ble