Bluetooth: Cleanup dependency build for LE/BREDR
Reorganizes mostly by using preprocessor (indirectly Kconfig options) strictly LE-SMP related interfaces and security interfaces shared between LE and BREDR connections. Change-Id: I90daa36d72403cd5b73e6791714fcaf7f1fbe8e5 Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
parent
2c121675f5
commit
aaa2650f0f
6 changed files with 38 additions and 28 deletions
|
@ -246,7 +246,7 @@ typedef enum __packed {
|
|||
*/
|
||||
} bt_security_t;
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_SMP)
|
||||
#if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR)
|
||||
/** @brief Set security level for a connection.
|
||||
*
|
||||
* This function enable security (encryption) for a connection. If device is
|
||||
|
@ -279,7 +279,7 @@ int bt_conn_security(struct bt_conn *conn, bt_security_t sec);
|
|||
* @return Encryption key size.
|
||||
*/
|
||||
uint8_t bt_conn_enc_key_size(struct bt_conn *conn);
|
||||
#endif /* CONFIG_BLUETOOTH_SMP */
|
||||
#endif /* CONFIG_BLUETOOTH_SMP || CONFIG_BLUETOOTH_BREDR */
|
||||
|
||||
/** Connection callback structure */
|
||||
struct bt_conn_cb {
|
||||
|
@ -291,8 +291,10 @@ struct bt_conn_cb {
|
|||
void (*identity_resolved)(struct bt_conn *conn,
|
||||
const bt_addr_le_t *rpa,
|
||||
const bt_addr_le_t *identity);
|
||||
#endif /* CONFIG_BLUETOOTH_SMP */
|
||||
#if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR)
|
||||
void (*security_changed)(struct bt_conn *conn, bt_security_t level);
|
||||
#endif
|
||||
#endif /* defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR) */
|
||||
struct bt_conn_cb *_next;
|
||||
};
|
||||
|
||||
|
|
|
@ -118,11 +118,6 @@ void notify_le_param_updated(struct bt_conn *conn)
|
|||
}
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_SMP)
|
||||
uint8_t bt_conn_enc_key_size(struct bt_conn *conn)
|
||||
{
|
||||
return conn->keys ? conn->keys->enc_size : 0;
|
||||
}
|
||||
|
||||
void bt_conn_identity_resolved(struct bt_conn *conn)
|
||||
{
|
||||
const bt_addr_le_t *rpa;
|
||||
|
@ -141,17 +136,6 @@ void bt_conn_identity_resolved(struct bt_conn *conn)
|
|||
}
|
||||
}
|
||||
|
||||
void bt_conn_security_changed(struct bt_conn *conn)
|
||||
{
|
||||
struct bt_conn_cb *cb;
|
||||
|
||||
for (cb = callback_list; cb; cb = cb->_next) {
|
||||
if (cb->security_changed) {
|
||||
cb->security_changed(conn, conn->sec_level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int bt_conn_le_start_encryption(struct bt_conn *conn, uint64_t rand,
|
||||
uint16_t ediv, const uint8_t *ltk, size_t len)
|
||||
{
|
||||
|
@ -175,11 +159,29 @@ int bt_conn_le_start_encryption(struct bt_conn *conn, uint64_t rand,
|
|||
|
||||
return bt_hci_cmd_send_sync(BT_HCI_OP_LE_START_ENCRYPTION, buf, NULL);
|
||||
}
|
||||
#endif /* CONFIG_BLUETOOTH_SMP */
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR)
|
||||
uint8_t bt_conn_enc_key_size(struct bt_conn *conn)
|
||||
{
|
||||
return conn->keys ? conn->keys->enc_size : 0;
|
||||
}
|
||||
|
||||
void bt_conn_security_changed(struct bt_conn *conn)
|
||||
{
|
||||
struct bt_conn_cb *cb;
|
||||
|
||||
for (cb = callback_list; cb; cb = cb->_next) {
|
||||
if (cb->security_changed) {
|
||||
cb->security_changed(conn, conn->sec_level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int start_security(struct bt_conn *conn)
|
||||
{
|
||||
switch (conn->role) {
|
||||
#if defined(CONFIG_BLUETOOTH_CENTRAL)
|
||||
#if defined(CONFIG_BLUETOOTH_CENTRAL) && defined(CONFIG_BLUETOOTH_SMP)
|
||||
case BT_HCI_ROLE_MASTER:
|
||||
{
|
||||
if (!conn->keys) {
|
||||
|
@ -215,11 +217,11 @@ static int start_security(struct bt_conn *conn)
|
|||
conn->keys->ltk.val,
|
||||
conn->keys->enc_size);
|
||||
}
|
||||
#endif /* CONFIG_BLUETOOTH_CENTRAL */
|
||||
#if defined(CONFIG_BLUETOOTH_PERIPHERAL)
|
||||
#endif /* CONFIG_BLUETOOTH_CENTRAL && CONFIG_BLUETOOTH_SMP */
|
||||
#if defined(CONFIG_BLUETOOTH_PERIPHERAL) && defined(CONFIG_BLUETOOTH_SMP)
|
||||
case BT_HCI_ROLE_SLAVE:
|
||||
return bt_smp_send_security_req(conn);
|
||||
#endif /* CONFIG_BLUETOOTH_PERIPHERAL */
|
||||
#endif /* CONFIG_BLUETOOTH_PERIPHERAL && CONFIG_BLUETOOTH_SMP */
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -155,10 +155,12 @@ int bt_conn_le_start_encryption(struct bt_conn *conn, uint64_t rand,
|
|||
|
||||
/* Notify higher layers that RPA was resolved */
|
||||
void bt_conn_identity_resolved(struct bt_conn *conn);
|
||||
#endif /* CONFIG_BLUETOOTH_SMP */
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR)
|
||||
/* Notify higher layers that connection security changed */
|
||||
void bt_conn_security_changed(struct bt_conn *conn);
|
||||
#endif /* CONFIG_BLUETOOTH_SMP */
|
||||
#endif /* CONFIG_BLUETOOTH_SMP || CONFIG_BLUETOOTH_BREDR */
|
||||
|
||||
/* Prepare a PDU to be sent over a connection */
|
||||
struct net_buf *bt_conn_create_pdu(struct nano_fifo *fifo, size_t reserve);
|
||||
|
|
|
@ -46,9 +46,9 @@
|
|||
#include "l2cap_internal.h"
|
||||
#endif /* CONFIG_BLUETOOTH_CONN */
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_SMP)
|
||||
#if defined(CONFIG_BLUETOOTH_CONN)
|
||||
#include "smp.h"
|
||||
#endif /* CONFIG_BLUETOOTH_SMP */
|
||||
#endif /* CONFIG_BLUETOOTH_CONN */
|
||||
|
||||
#if !defined(CONFIG_BLUETOOTH_DEBUG_HCI_CORE)
|
||||
#undef BT_DBG
|
||||
|
|
|
@ -62,9 +62,9 @@ struct bt_link_key {
|
|||
|
||||
struct bt_keys {
|
||||
bt_addr_le_t addr;
|
||||
#if defined(CONFIG_BLUETOOTH_SMP)
|
||||
#if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR)
|
||||
uint8_t enc_size;
|
||||
#endif
|
||||
#endif /* CONFIG_BLUETOOTH_SMP || CONFIG_BLUETOOTH_BREDR */
|
||||
atomic_t flags;
|
||||
uint16_t keys;
|
||||
|
||||
|
|
|
@ -104,6 +104,10 @@ static int bt_smp_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
void bt_smp_update_keys(struct bt_conn *conn)
|
||||
{
|
||||
}
|
||||
|
||||
int bt_smp_init(void)
|
||||
{
|
||||
static struct bt_l2cap_fixed_chan chan = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue