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 */
};
enum PairingResult_t {
PAIRING_RESULT_AUTHENTICATED,
PAIRING_RESULT_UNAUTHENTICATED,
PAIRING_RESULT_FAILED
};
class SecurityManagerEventHandler {
SecurityManagerEventHandler() : _app_handler(NULL) { };
SecurityManagerEventHandler() : _app_event_handler(NULL) { };
virtual void security_setup_initiated(Gap::Handle_t handle, bool allowBonding,
bool requireMITM, SecurityManager::SecurityIOCapabilities_t iocaps) {
if (_app_handler) {
_app_handler->securitySetupInitiated(handle, allowBonding, requireMITM, iocaps);
if (_app_event_handler) {
_app_event_handler->securitySetupInitiated(handle, allowBonding, requireMITM, iocaps);
}
}
virtual void security_setup_completed(Gap::Handle_t handle,
SecurityManager::SecurityCompletionStatus_t status) {
if (_app_handler) {
_app_handler->securitySetupCompleted(handle, status);
if (_app_event_handler) {
_app_event_handler->securitySetupCompleted(handle, status);
}
}
virtual void link_secured(Gap::Handle_t handle, SecurityManager::SecurityMode_t securityMode) {
if (_app_handler) {
_app_handler->linkSecured(handle, securityMode);
if (_app_event_handler) {
_app_event_handler->linkSecured(handle, securityMode);
}
}
virtual void security_context_stored(Gap::Handle_t handle) {
if (_app_handler) {
_app_handler->securityContextStored(handle);
if (_app_event_handler) {
_app_event_handler->securityContextStored(handle);
}
}
virtual void passkey_display(Gap::Handle_t handle, const SecurityManager::Passkey_t passkey) {
if (_app_handler) {
_app_handler->passkeyDisplay(handle, passkey);
if (_app_event_handler) {
_app_event_handler->passkeyDisplay(handle, passkey);
}
}
virtual void valid_mic_timeout(Gap::Handle_t handle) {
if (_app_handler) {
_app_handler->validMicTimeout(handle);
if (_app_event_handler) {
_app_event_handler->validMicTimeout(handle);
}
}
virtual void link_key_failure(Gap::Handle_t handle) {
if (_app_handler) {
_app_handler->linkKeyFailure(handle);
if (_app_event_handler) {
_app_event_handler->linkKeyFailure(handle);
}
}
virtual void keypress_notification(Gap::Handle_t handle, SecurityManager::Keypress_t keypress) {
if (_app_handler) {
_app_handler->keypressNotification(handle, keypress);
if (_app_event_handler) {
_app_event_handler->keypressNotification(handle, keypress);
}
}
virtual void legacy_pariring_oob_request(Gap::Handle_t handle) {
if (_app_handler) {
_app_handler->legacyPairingOobRequest(handle);
if (_app_event_handler) {
_app_event_handler->legacyPairingOobRequest(handle);
}
}
virtual void oob_request(Gap::Handle_t handle) {
if (_app_handler) {
_app_handler->oobRequest(handle);
if (_app_event_handler) {
_app_event_handler->oobRequest(handle);
}
}
virtual void pin_request(Gap::Handle_t handle) {
if (_app_handler) {
_app_handler->pinRequest(handle);
if (_app_event_handler) {
_app_event_handler->pinRequest(handle);
}
}
virtual void passkey_request(Gap::Handle_t handle) {
if (_app_handler) {
_app_handler->passkeyRequest(handle);
if (_app_event_handler) {
_app_event_handler->passkeyRequest(handle);
}
}
virtual void confirmation_request(Gap::Handle_t handle) {
if (_app_handler) {
_app_handler->confirmationRequest(handle);
if (_app_event_handler) {
_app_event_handler->confirmationRequest(handle);
}
}
virtual void accept_pairing_request(Gap::Handle_t handle) {
if (_app_handler) {
_app_handler->acceptPairingRequest(handle);
if (_app_event_handler) {
_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 pairing_completed(Gap::Handle_t handle, PairingResult_t result);
virtual void set_app_event_handler(::SecurityManagerEventHandler *app_handler) {
_app_handler = app_handler;
virtual void set_app_event_handler(::SecurityManagerEventHandler *app_event_handler) {
_app_event_handler = app_event_handler;
}
private:
::SecurityManagerEventHandler *_app_handler;
::SecurityManagerEventHandler *_app_event_handler;
};
class SecurityManager : private mbed::NonCopyable<SecurityManager> {
public:
SecurityManager() : _event_handler(NULL) { };
SecurityManager() : _pal_event_handler(NULL) { };
virtual ~SecurityManager() { };
virtual ble_error_t initialize() {
@ -306,12 +299,12 @@ public:
virtual ble_error_t generate_csrk() {
return BLE_ERROR_NOT_IMPLEMENTED;
}
virtual ble_error_t set_irk(irk) {
(void)timeout_in_seconds;
virtual ble_error_t set_irk(irk_t irk) {
(void)irk;
return BLE_ERROR_NOT_IMPLEMENTED;
}
virtual ble_error_t set_csrk(csrk) {
(void)timeout_in_seconds;
virtual ble_error_t set_csrk(csrk_t csrk) {
(void)csrk;
return BLE_ERROR_NOT_IMPLEMENTED;
}
@ -398,17 +391,17 @@ public:
public:
SecurityManagerEventHandler& get_event_handler() {
/* guaranteed to be a valid pointer */
return _event_handler;
return _pal_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) {
_event_handler = &event_handler;
_pal_event_handler = &event_handler;
}
private:
SecurityManagerEventHandler *_event_handler;
SecurityManagerEventHandler *_pal_event_handler;
};