make clear which event handler it is, remove pairing result as that's covered by security complete

pull/6188/head
paul-szczepanek-arm 2018-01-12 11:36:03 +00:00
parent 9a948b73da
commit 7325ca90fd
1 changed files with 41 additions and 48 deletions

View File

@ -79,110 +79,103 @@ struct bonded_list_t {
uint8_t capacity; /**< number of entries that can be stored */ uint8_t capacity; /**< number of entries that can be stored */
}; };
enum PairingResult_t {
PAIRING_RESULT_AUTHENTICATED,
PAIRING_RESULT_UNAUTHENTICATED,
PAIRING_RESULT_FAILED
};
class SecurityManagerEventHandler { class SecurityManagerEventHandler {
SecurityManagerEventHandler() : _app_handler(NULL) { }; SecurityManagerEventHandler() : _app_event_handler(NULL) { };
virtual void security_setup_initiated(Gap::Handle_t handle, bool allowBonding, virtual void security_setup_initiated(Gap::Handle_t handle, bool allowBonding,
bool requireMITM, SecurityManager::SecurityIOCapabilities_t iocaps) { bool requireMITM, SecurityManager::SecurityIOCapabilities_t iocaps) {
if (_app_handler) { if (_app_event_handler) {
_app_handler->securitySetupInitiated(handle, allowBonding, requireMITM, iocaps); _app_event_handler->securitySetupInitiated(handle, allowBonding, requireMITM, iocaps);
} }
} }
virtual void security_setup_completed(Gap::Handle_t handle, virtual void security_setup_completed(Gap::Handle_t handle,
SecurityManager::SecurityCompletionStatus_t status) { SecurityManager::SecurityCompletionStatus_t status) {
if (_app_handler) { if (_app_event_handler) {
_app_handler->securitySetupCompleted(handle, status); _app_event_handler->securitySetupCompleted(handle, status);
} }
} }
virtual void link_secured(Gap::Handle_t handle, SecurityManager::SecurityMode_t securityMode) { virtual void link_secured(Gap::Handle_t handle, SecurityManager::SecurityMode_t securityMode) {
if (_app_handler) { if (_app_event_handler) {
_app_handler->linkSecured(handle, securityMode); _app_event_handler->linkSecured(handle, securityMode);
} }
} }
virtual void security_context_stored(Gap::Handle_t handle) { virtual void security_context_stored(Gap::Handle_t handle) {
if (_app_handler) { if (_app_event_handler) {
_app_handler->securityContextStored(handle); _app_event_handler->securityContextStored(handle);
} }
} }
virtual void passkey_display(Gap::Handle_t handle, const SecurityManager::Passkey_t passkey) { virtual void passkey_display(Gap::Handle_t handle, const SecurityManager::Passkey_t passkey) {
if (_app_handler) { if (_app_event_handler) {
_app_handler->passkeyDisplay(handle, passkey); _app_event_handler->passkeyDisplay(handle, passkey);
} }
} }
virtual void valid_mic_timeout(Gap::Handle_t handle) { virtual void valid_mic_timeout(Gap::Handle_t handle) {
if (_app_handler) { if (_app_event_handler) {
_app_handler->validMicTimeout(handle); _app_event_handler->validMicTimeout(handle);
} }
} }
virtual void link_key_failure(Gap::Handle_t handle) { virtual void link_key_failure(Gap::Handle_t handle) {
if (_app_handler) { if (_app_event_handler) {
_app_handler->linkKeyFailure(handle); _app_event_handler->linkKeyFailure(handle);
} }
} }
virtual void keypress_notification(Gap::Handle_t handle, SecurityManager::Keypress_t keypress) { virtual void keypress_notification(Gap::Handle_t handle, SecurityManager::Keypress_t keypress) {
if (_app_handler) { if (_app_event_handler) {
_app_handler->keypressNotification(handle, keypress); _app_event_handler->keypressNotification(handle, keypress);
} }
} }
virtual void legacy_pariring_oob_request(Gap::Handle_t handle) { virtual void legacy_pariring_oob_request(Gap::Handle_t handle) {
if (_app_handler) { if (_app_event_handler) {
_app_handler->legacyPairingOobRequest(handle); _app_event_handler->legacyPairingOobRequest(handle);
} }
} }
virtual void oob_request(Gap::Handle_t handle) { virtual void oob_request(Gap::Handle_t handle) {
if (_app_handler) { if (_app_event_handler) {
_app_handler->oobRequest(handle); _app_event_handler->oobRequest(handle);
} }
} }
virtual void pin_request(Gap::Handle_t handle) { virtual void pin_request(Gap::Handle_t handle) {
if (_app_handler) { if (_app_event_handler) {
_app_handler->pinRequest(handle); _app_event_handler->pinRequest(handle);
} }
} }
virtual void passkey_request(Gap::Handle_t handle) { virtual void passkey_request(Gap::Handle_t handle) {
if (_app_handler) { if (_app_event_handler) {
_app_handler->passkeyRequest(handle); _app_event_handler->passkeyRequest(handle);
} }
} }
virtual void confirmation_request(Gap::Handle_t handle) { virtual void confirmation_request(Gap::Handle_t handle) {
if (_app_handler) { if (_app_event_handler) {
_app_handler->confirmationRequest(handle); _app_event_handler->confirmationRequest(handle);
} }
} }
virtual void accept_pairing_request(Gap::Handle_t handle) { virtual void accept_pairing_request(Gap::Handle_t handle) {
if (_app_handler) { if (_app_event_handler) {
_app_handler->acceptPairingRequest(handle); _app_event_handler->acceptPairingRequest(handle);
} }
} }
virtual void keys_exchanged(Gap::Handle_t handle, Address_t &peer_address, ediv_t &ediv, rand_t &rand, ltk_t &ltk, csrk_t &csrk); virtual void keys_exchanged(Gap::Handle_t handle, Address_t &peer_address, ediv_t &ediv, rand_t &rand, ltk_t &ltk, csrk_t &csrk);
virtual void pairing_completed(Gap::Handle_t handle, PairingResult_t result);
virtual void set_app_event_handler(::SecurityManagerEventHandler *app_handler) { virtual void set_app_event_handler(::SecurityManagerEventHandler *app_event_handler) {
_app_handler = app_handler; _app_event_handler = app_event_handler;
} }
private: private:
::SecurityManagerEventHandler *_app_handler; ::SecurityManagerEventHandler *_app_event_handler;
}; };
class SecurityManager : private mbed::NonCopyable<SecurityManager> { class SecurityManager : private mbed::NonCopyable<SecurityManager> {
public: public:
SecurityManager() : _event_handler(NULL) { }; SecurityManager() : _pal_event_handler(NULL) { };
virtual ~SecurityManager() { }; virtual ~SecurityManager() { };
virtual ble_error_t initialize() { virtual ble_error_t initialize() {
@ -306,12 +299,12 @@ public:
virtual ble_error_t generate_csrk() { virtual ble_error_t generate_csrk() {
return BLE_ERROR_NOT_IMPLEMENTED; return BLE_ERROR_NOT_IMPLEMENTED;
} }
virtual ble_error_t set_irk(irk) { virtual ble_error_t set_irk(irk_t irk) {
(void)timeout_in_seconds; (void)irk;
return BLE_ERROR_NOT_IMPLEMENTED; return BLE_ERROR_NOT_IMPLEMENTED;
} }
virtual ble_error_t set_csrk(csrk) { virtual ble_error_t set_csrk(csrk_t csrk) {
(void)timeout_in_seconds; (void)csrk;
return BLE_ERROR_NOT_IMPLEMENTED; return BLE_ERROR_NOT_IMPLEMENTED;
} }
@ -398,17 +391,17 @@ public:
public: public:
SecurityManagerEventHandler& get_event_handler() { SecurityManagerEventHandler& get_event_handler() {
/* guaranteed to be a valid pointer */ /* guaranteed to be a valid pointer */
return _event_handler; return _pal_event_handler;
} }
void set_app_event_handler(::SecurityManagerEventHandler &app_event_handler) { void set_app_event_handler(::SecurityManagerEventHandler &app_event_handler) {
_event_handler->set_app_event_handler(app_event_handler); _pal_event_handler->set_app_event_handler(app_event_handler);
} }
void set_event_handler(SecurityManagerEventHandler &event_handler) { void set_event_handler(SecurityManagerEventHandler &event_handler) {
_event_handler = &event_handler; _pal_event_handler = &event_handler;
} }
private: private:
SecurityManagerEventHandler *_event_handler; SecurityManagerEventHandler *_pal_event_handler;
}; };