Bluetooth: Add bt_conn prefix for auth APIs

All of the authentication APIs deal with bt_conn objects. For
consistency it makes therefore sense to use the proper bt_conn name
space with them.

Change-Id: I47912d542373df511524cc6ad2532d6c9a76ca68
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2016-01-14 22:12:28 +02:00 committed by Anas Nashif
commit bc073cdb59
9 changed files with 44 additions and 44 deletions

View file

@ -74,22 +74,22 @@ int bt_le_set_auto_conn(bt_addr_le_t *addr,
return -ENOSYS; return -ENOSYS;
} }
int bt_auth_cb_register(const struct bt_auth_cb *cb) int bt_conn_auth_cb_register(const struct bt_conn_auth_cb *cb)
{ {
return -ENOSYS; return -ENOSYS;
} }
int bt_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey) int bt_conn_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey)
{ {
return -ENOSYS; return -ENOSYS;
} }
int bt_auth_cancel(struct bt_conn *conn) int bt_conn_auth_cancel(struct bt_conn *conn)
{ {
return -ENOSYS; return -ENOSYS;
} }
int bt_auth_passkey_confirm(struct bt_conn *conn, bool match) int bt_conn_auth_passkey_confirm(struct bt_conn *conn, bool match)
{ {
return -ENOSYS; return -ENOSYS;
} }

View file

@ -254,7 +254,7 @@ void bt_conn_cb_register(struct bt_conn_cb *cb);
#if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR) #if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR)
/** Authenticated pairing callback structure */ /** Authenticated pairing callback structure */
struct bt_auth_cb { struct bt_conn_auth_cb {
void (*passkey_display)(struct bt_conn *conn, unsigned int passkey); void (*passkey_display)(struct bt_conn *conn, unsigned int passkey);
void (*passkey_entry)(struct bt_conn *conn); void (*passkey_entry)(struct bt_conn *conn);
void (*passkey_confirm)(struct bt_conn *conn, unsigned int passkey); void (*passkey_confirm)(struct bt_conn *conn, unsigned int passkey);
@ -273,19 +273,19 @@ struct bt_auth_cb {
* *
* @return Zero on success or negative error code otherwise * @return Zero on success or negative error code otherwise
*/ */
int bt_auth_cb_register(const struct bt_auth_cb *cb); int bt_conn_auth_cb_register(const struct bt_conn_auth_cb *cb);
/** @brief Reply with entered passkey. /** @brief Reply with entered passkey.
* *
* This function should be called only after passkey_entry callback from * This function should be called only after passkey_entry callback from
* bt_auth_cb structure was called. * bt_conn_auth_cb structure was called.
* *
* @param conn Connection object. * @param conn Connection object.
* @param passkey Entered passkey. * @param passkey Entered passkey.
* *
* @return Zero on success or negative error code otherwise * @return Zero on success or negative error code otherwise
*/ */
int bt_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey); int bt_conn_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey);
/** @brief Cancel ongoing authenticated pairing. /** @brief Cancel ongoing authenticated pairing.
* *
@ -295,33 +295,33 @@ int bt_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey);
* *
* @return Zero on success or negative error code otherwise * @return Zero on success or negative error code otherwise
*/ */
int bt_auth_cancel(struct bt_conn *conn); int bt_conn_auth_cancel(struct bt_conn *conn);
/** @brief Reply if passkey was confirmed by user. /** @brief Reply if passkey was confirmed by user.
* *
* This function should be called only after passkey_confirm callback from * This function should be called only after passkey_confirm callback from
* bt_auth_cb structure was called. If passkey is confirmed to match then match * bt_conn_auth_cb structure was called. If passkey is confirmed to match
* should be true. Otherwise match should be false. * then match should be true. Otherwise match should be false.
* *
* @param conn Connection object. * @param conn Connection object.
* @param match True if passkey was confirmed to match, false otherwise. * @param match True if passkey was confirmed to match, false otherwise.
* *
* @return Zero on success or negative error code otherwise * @return Zero on success or negative error code otherwise
*/ */
int bt_auth_passkey_confirm(struct bt_conn *conn, bool match); int bt_conn_auth_passkey_confirm(struct bt_conn *conn, bool match);
#if defined(CONFIG_BLUETOOTH_BREDR) #if defined(CONFIG_BLUETOOTH_BREDR)
/** @brief Reply with entered PIN code. /** @brief Reply with entered PIN code.
* *
* This function should be called only after PIN code callback from * This function should be called only after PIN code callback from
* bt_auth_cb structure was called. It's for legacy 2.0 devices. * bt_conn_auth_cb structure was called. It's for legacy 2.0 devices.
* *
* @param conn Connection object. * @param conn Connection object.
* @param pin Entered PIN code. * @param pin Entered PIN code.
* *
* @return Zero on success or negative error code otherwise * @return Zero on success or negative error code otherwise
*/ */
int bt_auth_pincode_entry(struct bt_conn *conn, const char *pin); int bt_conn_auth_pincode_entry(struct bt_conn *conn, const char *pin);
#endif /* CONFIG_BLUETOOTH_BREDR */ #endif /* CONFIG_BLUETOOTH_BREDR */
#endif /* CONFIG_BLUETOOTH_SMP || CONFIG_BLUETOOTH_BREDR */ #endif /* CONFIG_BLUETOOTH_SMP || CONFIG_BLUETOOTH_BREDR */

View file

@ -56,7 +56,7 @@ static NET_BUF_POOL(dummy_pool, CONFIG_BLUETOOTH_MAX_CONN, 0, &dummy, NULL, 0);
#define CONN_TIMEOUT (3 * sys_clock_ticks_per_sec) #define CONN_TIMEOUT (3 * sys_clock_ticks_per_sec)
#if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR) #if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR)
const struct bt_auth_cb *bt_auth; const struct bt_conn_auth_cb *bt_auth;
#endif /* CONFIG_BLUETOOTH_SMP || CONFIG_BLUETOOTH_BREDR */ #endif /* CONFIG_BLUETOOTH_SMP || CONFIG_BLUETOOTH_BREDR */
static struct bt_conn conns[CONFIG_BLUETOOTH_MAX_CONN]; static struct bt_conn conns[CONFIG_BLUETOOTH_MAX_CONN];
@ -1013,7 +1013,7 @@ struct net_buf *bt_conn_create_pdu(struct nano_fifo *fifo, size_t reserve)
} }
#if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR) #if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR)
int bt_auth_cb_register(const struct bt_auth_cb *cb) int bt_conn_auth_cb_register(const struct bt_conn_auth_cb *cb)
{ {
if (!cb) { if (!cb) {
bt_auth = NULL; bt_auth = NULL;
@ -1073,7 +1073,7 @@ static int pin_code_reply(struct bt_conn *conn, const char *pin, uint8_t len)
return bt_hci_cmd_send_sync(BT_HCI_OP_PIN_CODE_REPLY, buf, NULL); return bt_hci_cmd_send_sync(BT_HCI_OP_PIN_CODE_REPLY, buf, NULL);
} }
int bt_auth_pincode_entry(struct bt_conn *conn, const char *pin) int bt_conn_auth_pincode_entry(struct bt_conn *conn, const char *pin)
{ {
size_t len; size_t len;
@ -1116,7 +1116,7 @@ void bt_conn_pin_code_req(struct bt_conn *conn)
} }
#endif /* CONFIG_BLUETOOTH_BREDR */ #endif /* CONFIG_BLUETOOTH_BREDR */
int bt_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey) int bt_conn_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey)
{ {
if (!bt_auth) { if (!bt_auth) {
return -EINVAL; return -EINVAL;
@ -1131,7 +1131,7 @@ int bt_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey)
return -EINVAL; return -EINVAL;
} }
int bt_auth_passkey_confirm(struct bt_conn *conn, bool match) int bt_conn_auth_passkey_confirm(struct bt_conn *conn, bool match)
{ {
if (!bt_auth) { if (!bt_auth) {
return -EINVAL; return -EINVAL;
@ -1145,7 +1145,7 @@ int bt_auth_passkey_confirm(struct bt_conn *conn, bool match)
return -EINVAL; return -EINVAL;
} }
int bt_auth_cancel(struct bt_conn *conn) int bt_conn_auth_cancel(struct bt_conn *conn)
{ {
if (!bt_auth) { if (!bt_auth) {
return -EINVAL; return -EINVAL;

View file

@ -112,7 +112,7 @@ struct bt_dev {
extern struct bt_dev bt_dev; extern struct bt_dev bt_dev;
#if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR) #if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR)
extern const struct bt_auth_cb *bt_auth; extern const struct bt_conn_auth_cb *bt_auth;
#endif /* CONFIG_BLUETOOTH_SMP || CONFIG_BLUETOOTH_BREDR */ #endif /* CONFIG_BLUETOOTH_SMP || CONFIG_BLUETOOTH_BREDR */
static inline int bt_addr_cmp(const bt_addr_t *a, const bt_addr_t *b) static inline int bt_addr_cmp(const bt_addr_t *a, const bt_addr_t *b)

View file

@ -452,7 +452,7 @@ static void auth_cancel(struct bt_conn *conn)
printk("Pairing cancelled: %s\n", addr); printk("Pairing cancelled: %s\n", addr);
} }
static struct bt_auth_cb auth_cb_display = { static struct bt_conn_auth_cb auth_cb_display = {
.passkey_display = auth_passkey_display, .passkey_display = auth_passkey_display,
.passkey_entry = NULL, .passkey_entry = NULL,
.cancel = auth_cancel, .cancel = auth_cancel,
@ -478,7 +478,7 @@ void main(void)
bt_gatt_register(attrs, ARRAY_SIZE(attrs)); bt_gatt_register(attrs, ARRAY_SIZE(attrs));
bt_conn_cb_register(&conn_callbacks); bt_conn_cb_register(&conn_callbacks);
bt_auth_cb_register(&auth_cb_display); bt_conn_auth_cb_register(&auth_cb_display);
/* Implement notification. At the moment there is no suitable way /* Implement notification. At the moment there is no suitable way
* of starting delayed work so we do it here * of starting delayed work so we do it here

View file

@ -450,7 +450,7 @@ static void auth_cancel(struct bt_conn *conn)
printk("Pairing cancelled: %s\n", addr); printk("Pairing cancelled: %s\n", addr);
} }
static struct bt_auth_cb auth_cb_display = { static struct bt_conn_auth_cb auth_cb_display = {
.passkey_display = auth_passkey_display, .passkey_display = auth_passkey_display,
.passkey_entry = NULL, .passkey_entry = NULL,
.cancel = auth_cancel, .cancel = auth_cancel,
@ -476,7 +476,7 @@ void main(void)
bt_gatt_register(attrs, ARRAY_SIZE(attrs)); bt_gatt_register(attrs, ARRAY_SIZE(attrs));
bt_conn_cb_register(&conn_callbacks); bt_conn_cb_register(&conn_callbacks);
bt_auth_cb_register(&auth_cb_display); bt_conn_auth_cb_register(&auth_cb_display);
/* Implement notification. At the moment there is no suitable way /* Implement notification. At the moment there is no suitable way
* of starting delayed work so we do it here * of starting delayed work so we do it here

View file

@ -145,7 +145,7 @@ static void auth_cancel(struct bt_conn *conn)
printk("Pairing cancelled: %s\n", addr); printk("Pairing cancelled: %s\n", addr);
} }
static struct bt_auth_cb auth_cb_display = { static struct bt_conn_auth_cb auth_cb_display = {
.passkey_display = auth_passkey_display, .passkey_display = auth_passkey_display,
.passkey_entry = NULL, .passkey_entry = NULL,
.cancel = auth_cancel, .cancel = auth_cancel,
@ -169,7 +169,7 @@ void main(void)
bt_gatt_register(attrs, ARRAY_SIZE(attrs)); bt_gatt_register(attrs, ARRAY_SIZE(attrs));
bt_auth_cb_register(&auth_cb_display); bt_conn_auth_cb_register(&auth_cb_display);
bt_conn_cb_register(&conn_callbacks); bt_conn_cb_register(&conn_callbacks);
err = bt_le_adv_start(BT_LE_ADV(BT_LE_ADV_IND), ad, ARRAY_SIZE(ad), err = bt_le_adv_start(BT_LE_ADV(BT_LE_ADV_IND), ad, ARRAY_SIZE(ad),

View file

@ -1113,7 +1113,7 @@ static void auth_pincode_entry(struct bt_conn *conn, bool highsec)
} }
} }
static struct bt_auth_cb auth_cb_display = { static struct bt_conn_auth_cb auth_cb_display = {
.passkey_display = auth_passkey_display, .passkey_display = auth_passkey_display,
.passkey_entry = NULL, .passkey_entry = NULL,
.passkey_confirm = NULL, .passkey_confirm = NULL,
@ -1121,7 +1121,7 @@ static struct bt_auth_cb auth_cb_display = {
.cancel = auth_cancel, .cancel = auth_cancel,
}; };
static struct bt_auth_cb auth_cb_display_yes_no = { static struct bt_conn_auth_cb auth_cb_display_yes_no = {
.passkey_display = auth_passkey_display, .passkey_display = auth_passkey_display,
.passkey_entry = NULL, .passkey_entry = NULL,
.passkey_confirm = auth_passkey_confirm, .passkey_confirm = auth_passkey_confirm,
@ -1129,7 +1129,7 @@ static struct bt_auth_cb auth_cb_display_yes_no = {
.cancel = auth_cancel, .cancel = auth_cancel,
}; };
static struct bt_auth_cb auth_cb_input = { static struct bt_conn_auth_cb auth_cb_input = {
.passkey_display = NULL, .passkey_display = NULL,
.passkey_entry = auth_passkey_entry, .passkey_entry = auth_passkey_entry,
.passkey_confirm = NULL, .passkey_confirm = NULL,
@ -1137,7 +1137,7 @@ static struct bt_auth_cb auth_cb_input = {
.cancel = auth_cancel, .cancel = auth_cancel,
}; };
static struct bt_auth_cb auth_cb_all = { static struct bt_conn_auth_cb auth_cb_all = {
.passkey_display = auth_passkey_display, .passkey_display = auth_passkey_display,
.passkey_entry = auth_passkey_entry, .passkey_entry = auth_passkey_entry,
.passkey_confirm = auth_passkey_confirm, .passkey_confirm = auth_passkey_confirm,
@ -1154,15 +1154,15 @@ static void cmd_auth(int argc, char *argv[])
} }
if (!strcmp(argv[1], "all")) { if (!strcmp(argv[1], "all")) {
bt_auth_cb_register(&auth_cb_all); bt_conn_auth_cb_register(&auth_cb_all);
} else if (!strcmp(argv[1], "input")) { } else if (!strcmp(argv[1], "input")) {
bt_auth_cb_register(&auth_cb_input); bt_conn_auth_cb_register(&auth_cb_input);
} else if (!strcmp(argv[1], "display")) { } else if (!strcmp(argv[1], "display")) {
bt_auth_cb_register(&auth_cb_display); bt_conn_auth_cb_register(&auth_cb_display);
} else if (!strcmp(argv[1], "yesno")) { } else if (!strcmp(argv[1], "yesno")) {
bt_auth_cb_register(&auth_cb_display_yes_no); bt_conn_auth_cb_register(&auth_cb_display_yes_no);
} else if (!strcmp(argv[1], "none")) { } else if (!strcmp(argv[1], "none")) {
bt_auth_cb_register(NULL); bt_conn_auth_cb_register(NULL);
} else { } else {
printk("auth [display, yesno, input, all, none] " printk("auth [display, yesno, input, all, none] "
"parameter required\n"); "parameter required\n");
@ -1186,7 +1186,7 @@ static void cmd_auth_cancel(int argc, char *argv[])
return; return;
} }
bt_auth_cancel(conn); bt_conn_auth_cancel(conn);
} }
static void cmd_auth_passkey_confirm(int argc, char *argv[]) static void cmd_auth_passkey_confirm(int argc, char *argv[])
@ -1205,7 +1205,7 @@ static void cmd_auth_passkey_confirm(int argc, char *argv[])
match = !strcmp(argv[1], "true"); match = !strcmp(argv[1], "true");
bt_auth_passkey_confirm(default_conn, match); bt_conn_auth_passkey_confirm(default_conn, match);
} }
static void cmd_auth_passkey(int argc, char *argv[]) static void cmd_auth_passkey(int argc, char *argv[])
@ -1228,7 +1228,7 @@ static void cmd_auth_passkey(int argc, char *argv[])
return; return;
} }
bt_auth_passkey_entry(default_conn, passkey); bt_conn_auth_passkey_entry(default_conn, passkey);
} }
static void cmd_auth_pincode(int argc, char *argv[]) static void cmd_auth_pincode(int argc, char *argv[])
@ -1262,7 +1262,7 @@ static void cmd_auth_pincode(int argc, char *argv[])
printk("PIN code \"%s\" applied\n", argv[1]); printk("PIN code \"%s\" applied\n", argv[1]);
bt_auth_pincode_entry(conn, argv[1]); bt_conn_auth_pincode_entry(conn, argv[1]);
} }

View file

@ -35,7 +35,7 @@
#define CONTROLLER_ADDR (&(bt_addr_t) {{1, 2, 3, 4, 5, 6}}) #define CONTROLLER_ADDR (&(bt_addr_t) {{1, 2, 3, 4, 5, 6}})
static atomic_t current_settings; static atomic_t current_settings;
struct bt_auth_cb cb; struct bt_conn_auth_cb cb;
static void le_connected(struct bt_conn *conn, uint8_t err) static void le_connected(struct bt_conn *conn, uint8_t err)
{ {
@ -372,7 +372,7 @@ static void set_io_cap(const uint8_t *data, uint16_t len)
/* Reset io cap requirements */ /* Reset io cap requirements */
memset(&cb, 0, sizeof(cb)); memset(&cb, 0, sizeof(cb));
bt_auth_cb_register(NULL); bt_conn_auth_cb_register(NULL);
switch (cmd->io_cap) { switch (cmd->io_cap) {
case GAP_IO_CAP_DISPLAY_ONLY: case GAP_IO_CAP_DISPLAY_ONLY:
@ -397,7 +397,7 @@ static void set_io_cap(const uint8_t *data, uint16_t len)
goto rsp; goto rsp;
} }
if (bt_auth_cb_register(&cb)) { if (bt_conn_auth_cb_register(&cb)) {
status = BTP_STATUS_FAILED; status = BTP_STATUS_FAILED;
goto rsp; goto rsp;
} }
@ -445,7 +445,7 @@ static void passkey_entry(const uint8_t *data, uint16_t len)
goto rsp; goto rsp;
} }
bt_auth_passkey_entry(conn, sys_le32_to_cpu(cmd->passkey)); bt_conn_auth_passkey_entry(conn, sys_le32_to_cpu(cmd->passkey));
bt_conn_unref(conn); bt_conn_unref(conn);
status = BTP_STATUS_SUCCESS; status = BTP_STATUS_SUCCESS;