Skip to content

Commit 831241d

Browse files
committed
BLE - Cleanup GenericSecurityManager conditional directives
- Inheritance lisr - Within constructor - Within member declaration - Private function declaration and definition.
1 parent e706b6c commit 831241d

File tree

2 files changed

+5
-45
lines changed

2 files changed

+5
-45
lines changed

features/FEATURE_BLE/ble/generic/GenericSecurityManager.h

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ template <template<class> class TPalSecurityManager, template<class> class Signi
3535
class GenericSecurityManager :
3636
public interface::SecurityManager<GenericSecurityManager<TPalSecurityManager, SigningMonitor > >, // SecurityManager
3737
public pal::SecurityManagerEventHandler<GenericSecurityManager<TPalSecurityManager, SigningMonitor> >, // PalSmEventHandler
38-
public pal::ConnectionEventMonitorEventHandler<GenericSecurityManager<TPalSecurityManager, SigningMonitor> > // ConnectionObserver
39-
#if BLE_FEATURE_SIGNING
40-
, public pal::SigningMonitorEventHandler<GenericSecurityManager<TPalSecurityManager, SigningMonitor> > //SigningObserver
41-
#endif // BLE_FEATURE_SIGNING
38+
public pal::ConnectionEventMonitorEventHandler<GenericSecurityManager<TPalSecurityManager, SigningMonitor> >, // ConnectionObserver
39+
public pal::SigningMonitorEventHandler<GenericSecurityManager<TPalSecurityManager, SigningMonitor> > //SigningObserver
4240
{
4341
// typedefs
4442
typedef interface::SecurityManager<GenericSecurityManager> SecurityManager;
@@ -272,20 +270,12 @@ class GenericSecurityManager :
272270

273271
public:
274272
GenericSecurityManager(
275-
PalSecurityManager &palImpl
276-
#if BLE_FEATURE_CONNECTABLE
277-
, pal::ConnectionEventMonitor<GenericSecurityManager> &connMonitorImpl
278-
#endif
279-
#if BLE_FEATURE_SIGNING
280-
, SigningEventMonitor &signingMonitorImpl
281-
#endif
273+
PalSecurityManager &palImpl,
274+
pal::ConnectionEventMonitor<GenericSecurityManager> &connMonitorImpl,
275+
SigningEventMonitor &signingMonitorImpl
282276
) : _pal(palImpl),
283-
#if BLE_FEATURE_CONNECTABLE
284277
_connection_monitor(connMonitorImpl),
285-
#endif
286-
#if BLE_FEATURE_SIGNING
287278
_signing_monitor(signingMonitorImpl),
288-
#endif
289279
_db(NULL),
290280
_default_authentication(0),
291281
_default_key_distribution(pal::KeyDistribution::KEY_DISTRIBUTION_ALL),
@@ -535,12 +525,8 @@ class GenericSecurityManager :
535525
};
536526

537527
PalSecurityManager &_pal;
538-
#if BLE_FEATURE_CONNECTABLE
539528
pal::ConnectionEventMonitor<GenericSecurityManager> &_connection_monitor;
540-
#endif
541-
#if BLE_FEATURE_SIGNING
542529
SigningEventMonitor &_signing_monitor;
543-
#endif
544530

545531
SecurityDb *_db;
546532

@@ -608,7 +594,6 @@ class GenericSecurityManager :
608594
connection_handle_t connection
609595
);
610596

611-
#if BLE_FEATURE_SIGNING
612597
/** @copydoc ble::pal::SecurityManager::on_signed_write_received
613598
*/
614599
void on_signed_write_received_(
@@ -625,7 +610,6 @@ class GenericSecurityManager :
625610
/** @copydoc ble::pal::SecurityManager::on_signed_write
626611
*/
627612
void on_signed_write_();
628-
#endif // BLE_FEATURE_SIGNING
629613

630614
/** @copydoc ble::pal::SecurityManager::on_slave_security_request
631615
*/

features/FEATURE_BLE/source/generic/GenericSecurityManager.tpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
#include "BLERoles.h"
1818

19-
#if BLE_FEATURE_SECURITY
20-
2119
#include "ble/SecurityManager.h"
2220
#include "ble/pal/PalSecurityManager.h"
2321
#include "ble/generic/GenericSecurityManager.h"
@@ -399,7 +397,6 @@ ble_error_t GenericSecurityManager<TPalSecurityManager, SigningMonitor>::setKeyp
399397
return BLE_ERROR_NONE;
400398
}
401399

402-
#if BLE_FEATURE_SIGNING
403400
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
404401
ble_error_t GenericSecurityManager<TPalSecurityManager, SigningMonitor>::enableSigning_(
405402
connection_handle_t connection,
@@ -441,7 +438,6 @@ ble_error_t GenericSecurityManager<TPalSecurityManager, SigningMonitor>::enableS
441438

442439
return BLE_ERROR_NONE;
443440
}
444-
#endif // BLE_FEATURE_SIGNING
445441

446442
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
447443
ble_error_t GenericSecurityManager<TPalSecurityManager, SigningMonitor>::setHintFutureRoleReversal_(bool enable) {
@@ -592,7 +588,6 @@ ble_error_t GenericSecurityManager<TPalSecurityManager, SigningMonitor>::setEncr
592588
////////////////////////////////////////////////////////////////////////////
593589
// Keys
594590
//
595-
#if BLE_FEATURE_SIGNING
596591
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
597592
ble_error_t GenericSecurityManager<TPalSecurityManager, SigningMonitor>::getSigningKey_(connection_handle_t connection, bool authenticated) {
598593
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
@@ -627,19 +622,16 @@ ble_error_t GenericSecurityManager<TPalSecurityManager, SigningMonitor>::getSign
627622
}
628623
}
629624
}
630-
#endif // BLE_FEATURE_SIGNING
631625

632626
////////////////////////////////////////////////////////////////////////////
633627
// Privacy
634628
//
635629

636-
#if BLE_FEATURE_PRIVACY
637630
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
638631
ble_error_t GenericSecurityManager<TPalSecurityManager, SigningMonitor>::setPrivateAddressTimeout_(uint16_t timeout_in_seconds) {
639632
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
640633
return _pal.set_private_address_timeout(timeout_in_seconds);
641634
}
642-
#endif // BLE_FEATURE_PRIVACY
643635

644636
////////////////////////////////////////////////////////////////////////////
645637
// Authentication
@@ -855,7 +847,6 @@ ble_error_t GenericSecurityManager<TPalSecurityManager, SigningMonitor>::init_da
855847
return BLE_ERROR_NONE;
856848
}
857849

858-
#if BLE_FEATURE_PRIVACY
859850
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
860851
ble_error_t GenericSecurityManager<TPalSecurityManager, SigningMonitor>::init_resolving_list() {
861852
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
@@ -881,9 +872,7 @@ ble_error_t GenericSecurityManager<TPalSecurityManager, SigningMonitor>::init_re
881872

882873
return BLE_ERROR_NONE;
883874
}
884-
#endif // BLE_FEATURE_PRIVACY
885875

886-
#if BLE_FEATURE_SIGNING
887876
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
888877
ble_error_t GenericSecurityManager<TPalSecurityManager, SigningMonitor>::init_signing() {
889878
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
@@ -905,7 +894,6 @@ ble_error_t GenericSecurityManager<TPalSecurityManager, SigningMonitor>::init_si
905894

906895
return _pal.set_csrk(*pcsrk, local_sign_counter);
907896
}
908-
#endif // BLE_FEATURE_SIGNING
909897

910898
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
911899
ble_error_t GenericSecurityManager<TPalSecurityManager, SigningMonitor>::get_random_data(uint8_t *buffer, size_t size) {
@@ -1020,7 +1008,6 @@ void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::set_ltk_cb(
10201008
}
10211009
}
10221010

1023-
#if BLE_FEATURE_SIGNING
10241011
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
10251012
void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::set_peer_csrk_cb(
10261013
SecurityDb::entry_handle_t db_entry,
@@ -1066,7 +1053,6 @@ void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::return_csrk_cb
10661053
flags->csrk_mitm_protected
10671054
);
10681055
}
1069-
#endif // BLE_FEATURE_SIGNING
10701056

10711057
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
10721058
void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::update_oob_presence(connection_handle_t connection) {
@@ -1190,7 +1176,6 @@ void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_security_en
11901176
#endif // BLE_FEATURE_PRIVACY
11911177
}
11921178

1193-
#if BLE_FEATURE_PRIVACY
11941179
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
11951180
void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_identity_list_retrieved(
11961181
ble::ArrayView<SecurityEntryIdentity_t>& identity_list,
@@ -1211,8 +1196,6 @@ void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_identity_li
12111196

12121197
delete [] identity_list.data();
12131198
}
1214-
#endif // BLE_FEATURE_PRIVACY
1215-
12161199

12171200
/* Implements ble::pal::SecurityManagerEventHandler */
12181201

@@ -1310,7 +1293,6 @@ void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_valid_mic_t
13101293
(void)connection;
13111294
}
13121295

1313-
#if BLE_FEATURE_SIGNING
13141296
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
13151297
void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_signed_write_received_(
13161298
connection_handle_t connection,
@@ -1355,7 +1337,6 @@ void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_signed_writ
13551337
MBED_ASSERT(_db);
13561338
_db->set_local_sign_counter(_db->get_local_sign_counter() + 1);
13571339
}
1358-
#endif // BLE_FEATURE_SIGNING
13591340

13601341
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
13611342
void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_slave_security_request_(
@@ -1644,7 +1625,6 @@ void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_keys_distri
16441625
_db->set_entry_local_ediv_rand(cb->db_entry, ediv, rand);
16451626
}
16461627

1647-
#if BLE_FEATURE_PRIVACY
16481628
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
16491629
void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_keys_distributed_irk_(
16501630
connection_handle_t connection,
@@ -1663,7 +1643,6 @@ void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_keys_distri
16631643

16641644
_db->set_entry_peer_irk(cb->db_entry, irk);
16651645
}
1666-
#endif // BLE_FEATURE_PRIVACY
16671646

16681647
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
16691648
void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_keys_distributed_bdaddr_(
@@ -1684,7 +1663,6 @@ void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_keys_distri
16841663
);
16851664
}
16861665

1687-
#if BLE_FEATURE_SIGNING
16881666
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
16891667
void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_keys_distributed_csrk_(
16901668
connection_handle_t connection,
@@ -1710,7 +1688,6 @@ void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_keys_distri
17101688
flags->csrk_mitm_protected
17111689
);
17121690
}
1713-
#endif // BLE_FEATURE_SIGNING
17141691

17151692
template<template<class> class TPalSecurityManager, template<class> class SigningMonitor>
17161693
void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::on_ltk_request_(
@@ -1849,4 +1826,3 @@ void GenericSecurityManager<TPalSecurityManager, SigningMonitor>::release_contro
18491826
} /* namespace generic */
18501827
} /* namespace ble */
18511828

1852-
#endif // BLE_FEATURE_SECURITY

0 commit comments

Comments
 (0)