/* Simple Pairing handling */
-static int hciops_confirm_reply(int index, bdaddr_t *bdaddr, addr_type_t type,
+static int hciops_confirm_reply(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
gboolean success)
{
struct dev_info *dev = &devs[index];
usleep(5000);
if (hciops_confirm_reply(index, &req->bdaddr,
- ADDR_TYPE_BREDR, TRUE) < 0)
+ BDADDR_BREDR, TRUE) < 0)
goto fail;
return;
btohs(evt->lmp_subver));
}
-static void dev_found(struct dev_info *info, bdaddr_t *dba, addr_type_t type,
+static void dev_found(struct dev_info *info, bdaddr_t *dba, uint8_t bdaddr_type,
uint8_t *cod, int8_t rssi, uint8_t cfm_name,
uint8_t *eir, size_t eir_len)
{
info->found_devs = g_slist_prepend(info->found_devs, dev);
event:
- btd_event_device_found(&info->bdaddr, dba, type, rssi, cfm_name,
+ btd_event_device_found(&info->bdaddr, dba, bdaddr_type, rssi, cfm_name,
eir, eir_len);
}
uint8_t eir[5];
memset(eir, 0, sizeof(eir));
- dev_found(dev, &info->bdaddr, ADDR_TYPE_BREDR, info->dev_class,
+ dev_found(dev, &info->bdaddr, BDADDR_BREDR, info->dev_class,
0, 1, eir, 0);
ptr += INQUIRY_INFO_SIZE;
}
inquiry_info_with_rssi_and_pscan_mode *info = ptr;
memset(eir, 0, sizeof(eir));
- dev_found(dev, &info->bdaddr, ADDR_TYPE_BREDR,
+ dev_found(dev, &info->bdaddr, BDADDR_BREDR,
info->dev_class, info->rssi,
1, eir, 0);
ptr += INQUIRY_INFO_WITH_RSSI_AND_PSCAN_MODE_SIZE;
inquiry_info_with_rssi *info = ptr;
memset(eir, 0, sizeof(eir));
- dev_found(dev, &info->bdaddr, ADDR_TYPE_BREDR,
+ dev_found(dev, &info->bdaddr, BDADDR_BREDR,
info->dev_class, info->rssi,
1, eir, 0);
ptr += INQUIRY_INFO_WITH_RSSI_SIZE;
else
cfm_name = TRUE;
- dev_found(dev, &info->bdaddr, ADDR_TYPE_BREDR, info->dev_class,
+ dev_found(dev, &info->bdaddr, BDADDR_BREDR, info->dev_class,
info->rssi, cfm_name, eir, eir_len);
ptr += EXTENDED_INQUIRY_INFO_SIZE;
}
conn = get_connection(dev, &evt->bdaddr);
conn->handle = btohs(evt->handle);
- btd_event_conn_complete(&dev->bdaddr, &evt->bdaddr, ADDR_TYPE_BREDR,
+ btd_event_conn_complete(&dev->bdaddr, &evt->bdaddr, BDADDR_BREDR,
NULL, NULL);
if (conn->secmode3)
free(str);
}
-static inline addr_type_t le_addr_type(uint8_t bdaddr_type)
+static inline uint8_t le_addr_type(uint8_t bdaddr_type)
{
switch (bdaddr_type) {
case LE_RANDOM_ADDRESS:
- return ADDR_TYPE_LE_RANDOM;
+ return BDADDR_LE_RANDOM;
case LE_PUBLIC_ADDRESS:
default:
- return ADDR_TYPE_LE_PUBLIC;
+ return BDADDR_LE_PUBLIC;
}
}
char filename[PATH_MAX];
char local_addr[18], peer_addr[18], *str;
struct bt_conn *conn;
- addr_type_t type;
+ uint8_t bdaddr_type;
if (evt->status) {
btd_event_conn_failed(&dev->bdaddr, &evt->peer_bdaddr,
conn = get_connection(dev, &evt->peer_bdaddr);
conn->handle = btohs(evt->handle);
- type = le_addr_type(evt->peer_bdaddr_type);
- btd_event_conn_complete(&dev->bdaddr, &evt->peer_bdaddr, type,
+ bdaddr_type = le_addr_type(evt->peer_bdaddr_type);
+ btd_event_conn_complete(&dev->bdaddr, &evt->peer_bdaddr, bdaddr_type,
NULL, NULL);
/* check if the remote version needs be requested */
return 0;
}
-static int hciops_block_device(int index, bdaddr_t *bdaddr, addr_type_t type)
+static int hciops_block_device(int index, bdaddr_t *bdaddr,
+ uint8_t bdaddr_type)
{
struct dev_info *dev = &devs[index];
char addr[18];
return 0;
}
-static int hciops_unblock_device(int index, bdaddr_t *bdaddr, addr_type_t type)
+static int hciops_unblock_device(int index, bdaddr_t *bdaddr,
+ uint8_t bdaddr_type)
{
struct dev_info *dev = &devs[index];
char addr[18];
return 0;
}
-static int hciops_disconnect(int index, bdaddr_t *bdaddr, addr_type_t type)
+static int hciops_disconnect(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type)
{
DBG("hci%d", index);
return disconnect_addr(index, bdaddr, HCI_OE_USER_ENDED_CONNECTION);
}
-static int hciops_remove_bonding(int index, bdaddr_t *bdaddr, addr_type_t type)
+static int hciops_remove_bonding(int index, bdaddr_t *bdaddr,
+ uint8_t bdaddr_type)
{
struct dev_info *dev = &devs[index];
delete_stored_link_key_cp cp;
return err;
}
-static int hciops_passkey_reply(int index, bdaddr_t *bdaddr, addr_type_t type,
- uint32_t passkey)
+static int hciops_passkey_reply(int index, bdaddr_t *bdaddr,
+ uint8_t bdaddr_type, uint32_t passkey)
{
struct dev_info *dev = &devs[index];
char addr[18];
}
static int hciops_create_bonding(int index, bdaddr_t *bdaddr,
- uint8_t addr_type, uint8_t io_cap)
+ uint8_t bdaddr_type, uint8_t io_cap)
{
struct dev_info *dev = &devs[index];
BtIOSecLevel sec_level;
return 0;
}
-static int hciops_confirm_name(int index, bdaddr_t *bdaddr, addr_type_t type,
- gboolean name_known)
+static int hciops_confirm_name(int index, bdaddr_t *bdaddr,
+ uint8_t bdaddr_type, gboolean name_known)
{
struct dev_info *info = &devs[index];
struct found_dev *dev;
bonding_complete(info, &ev->key.addr.bdaddr, 0);
}
-static inline addr_type_t addr_type(uint8_t mgmt_addr_type)
+static inline uint8_t addr_type(uint8_t mgmt_addr_type)
{
switch (mgmt_addr_type) {
case MGMT_ADDR_BREDR:
- return ADDR_TYPE_BREDR;
+ return BDADDR_BREDR;
case MGMT_ADDR_LE_PUBLIC:
- return ADDR_TYPE_LE_PUBLIC;
+ return BDADDR_LE_PUBLIC;
case MGMT_ADDR_LE_RANDOM:
- return ADDR_TYPE_LE_RANDOM;
+ return BDADDR_LE_RANDOM;
default:
- return ADDR_TYPE_BREDR;
+ return BDADDR_BREDR;
}
}
-static inline uint8_t mgmt_addr_type(addr_type_t addr_type)
+static inline uint8_t mgmt_addr_type(uint8_t addr_type)
{
switch (addr_type) {
- case ADDR_TYPE_BREDR:
+ case BDADDR_BREDR:
return MGMT_ADDR_BREDR;
- case ADDR_TYPE_LE_PUBLIC:
+ case BDADDR_LE_PUBLIC:
return MGMT_ADDR_LE_PUBLIC;
- case ADDR_TYPE_LE_RANDOM:
+ case BDADDR_LE_RANDOM:
return MGMT_ADDR_LE_RANDOM;
default:
return MGMT_ADDR_BREDR;
}
}
-static int mgmt_confirm_reply(int index, bdaddr_t *bdaddr, addr_type_t type,
+static int mgmt_confirm_reply(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
gboolean success)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_user_confirm_reply)];
cp = (void *) &buf[sizeof(*hdr)];
bacpy(&cp->addr.bdaddr, bdaddr);
- cp->addr.type = mgmt_addr_type(type);
+ cp->addr.type = mgmt_addr_type(bdaddr_type);
if (write(mgmt_sock, buf, sizeof(buf)) < 0)
return -errno;
return 0;
}
-static int mgmt_passkey_reply(int index, bdaddr_t *bdaddr, addr_type_t type,
+static int mgmt_passkey_reply(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
uint32_t passkey)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_user_passkey_reply)];
cp = (void *) &buf[sizeof(*hdr)];
bacpy(&cp->addr.bdaddr, bdaddr);
- cp->addr.type = mgmt_addr_type(type);
+ cp->addr.type = mgmt_addr_type(bdaddr_type);
buf_len = sizeof(*hdr) + sizeof(*cp);
} else {
cp = (void *) &buf[sizeof(*hdr)];
bacpy(&cp->addr.bdaddr, bdaddr);
- cp->addr.type = mgmt_addr_type(type);
+ cp->addr.type = mgmt_addr_type(bdaddr_type);
cp->passkey = htobl(passkey);
buf_len = sizeof(*hdr) + sizeof(*cp);
return 0;
}
-static int mgmt_block_device(int index, bdaddr_t *bdaddr, addr_type_t type)
+static int mgmt_block_device(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_block_device)];
struct mgmt_hdr *hdr = (void *) buf;
cp = (void *) &buf[sizeof(*hdr)];
bacpy(&cp->addr.bdaddr, bdaddr);
- cp->addr.type = mgmt_addr_type(type);
+ cp->addr.type = mgmt_addr_type(bdaddr_type);
buf_len = sizeof(*hdr) + sizeof(*cp);
return 0;
}
-static int mgmt_unblock_device(int index, bdaddr_t *bdaddr, addr_type_t type)
+static int mgmt_unblock_device(int index, bdaddr_t *bdaddr,
+ uint8_t bdaddr_type)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_unblock_device)];
struct mgmt_hdr *hdr = (void *) buf;
cp = (void *) &buf[sizeof(*hdr)];
bacpy(&cp->addr.bdaddr, bdaddr);
- cp->addr.type = mgmt_addr_type(type);
+ cp->addr.type = mgmt_addr_type(bdaddr_type);
buf_len = sizeof(*hdr) + sizeof(*cp);
return 0;
}
-static int mgmt_disconnect(int index, bdaddr_t *bdaddr, addr_type_t type)
+static int mgmt_disconnect(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_disconnect)];
struct mgmt_hdr *hdr = (void *) buf;
hdr->index = htobs(index);
bacpy(&cp->addr.bdaddr, bdaddr);
- cp->addr.type = mgmt_addr_type(type);
+ cp->addr.type = mgmt_addr_type(bdaddr_type);
if (write(mgmt_sock, buf, sizeof(buf)) < 0)
error("write: %s (%d)", strerror(errno), errno);
return 0;
}
-static int mgmt_unpair_device(int index, bdaddr_t *bdaddr, addr_type_t type)
+static int mgmt_unpair_device(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_unpair_device)];
struct mgmt_hdr *hdr = (void *) buf;
hdr->index = htobs(index);
bacpy(&cp->addr.bdaddr, bdaddr);
- cp->addr.type = mgmt_addr_type(type);
+ cp->addr.type = mgmt_addr_type(bdaddr_type);
cp->disconnect = 1;
if (write(mgmt_sock, buf, sizeof(buf)) < 0)
return 0;
}
-static int mgmt_confirm_name(int index, bdaddr_t *bdaddr, addr_type_t type,
+static int mgmt_confirm_name(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
gboolean name_known)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_confirm_name)];
hdr->len = htobs(sizeof(*cp));
bacpy(&cp->addr.bdaddr, bdaddr);
- cp->addr.type = mgmt_addr_type(type);
+ cp->addr.type = mgmt_addr_type(bdaddr_type);
cp->name_known = name_known;
if (write(mgmt_sock, &buf, sizeof(buf)) < 0)
struct smp_ltk_info *info = l->data;
bacpy(&key->addr.bdaddr, &info->bdaddr);
- key->addr.type = info->addr_type;
+ key->addr.type = info->bdaddr_type;
memcpy(key->val, info->val, sizeof(info->val));
memcpy(key->rand, info->rand, sizeof(info->rand));
memcpy(&key->ediv, &info->ediv, sizeof(key->ediv));
for (l = all, le = NULL; l; l = l->next) {
struct remote_dev_info *dev = l->data;
- if (dev->type == ADDR_TYPE_BREDR) {
+ if (dev->bdaddr_type == BDADDR_BREDR) {
dev_info_free(dev);
continue;
}
static struct btd_device *adapter_create_device(DBusConnection *conn,
struct btd_adapter *adapter,
const char *address,
- addr_type_t type)
+ uint8_t bdaddr_type)
{
struct btd_device *device;
const char *path;
DBG("%s", address);
- device = device_create(conn, adapter, address, type);
+ device = device_create(conn, adapter, address, bdaddr_type);
if (!device)
return NULL;
return device;
return adapter_create_device(conn, adapter, address,
- ADDR_TYPE_BREDR);
+ BDADDR_BREDR);
}
static gboolean discovery_cb(gpointer user_data)
struct remote_dev_info *dev;
struct btd_device *device;
bdaddr_t addr;
- addr_type_t type;
+ uint8_t bdaddr_type;
str2ba(address, &addr);
dev = adapter_search_found_devices(adapter, &addr);
if (dev)
- type = dev->type;
+ bdaddr_type = dev->bdaddr_type;
else
- type = ADDR_TYPE_BREDR;
+ bdaddr_type = BDADDR_BREDR;
- device = adapter_create_device(conn, adapter, address, type);
+ device = adapter_create_device(conn, adapter, address, bdaddr_type);
if (!device && err)
*err = -ENOMEM;
key, (GCompareFunc) device_address_cmp))
return;
- device = device_create(connection, adapter, key, ADDR_TYPE_BREDR);
+ device = device_create(connection, adapter, key, BDADDR_BREDR);
if (!device)
return;
ptr = (char *) value + 2 * sizeof(ltk->val) + 1;
ret = sscanf(ptr, " %hhd %hhd %hhd %hhd %hd %n",
- (uint8_t *) <k->addr_type,
+ (uint8_t *) <k->bdaddr_type,
<k->authenticated, <k->master,
<k->enc_size, <k->ediv, &i);
if (ret < 2) {
(GCompareFunc) device_address_cmp))
return;
- device = device_create(connection, adapter, key, ADDR_TYPE_BREDR);
+ device = device_create(connection, adapter, key, BDADDR_BREDR);
if (device) {
device_set_temporary(device, FALSE);
adapter->devices = g_slist_append(adapter->devices, device);
if (g_strcmp0(srcaddr, key) == 0)
return;
- device = device_create(connection, adapter, key, info->addr_type);
+ device = device_create(connection, adapter, key, info->bdaddr_type);
if (device) {
device_set_temporary(device, FALSE);
adapter->devices = g_slist_append(adapter->devices, device);
key, (GCompareFunc) device_address_cmp))
return;
- device = device_create(connection, adapter, key, ADDR_TYPE_BREDR);
+ device = device_create(connection, adapter, key, BDADDR_BREDR);
if (device) {
device_set_temporary(device, FALSE);
adapter->devices = g_slist_append(adapter->devices, device);
return;
/* FIXME: Get the correct LE addr type (public/random) */
- device = device_create(connection, adapter, key, ADDR_TYPE_LE_PUBLIC);
+ device = device_create(connection, adapter, key, BDADDR_LE_PUBLIC);
if (!device)
return;
}
int btd_adapter_block_address(struct btd_adapter *adapter, bdaddr_t *bdaddr,
- addr_type_t type)
+ uint8_t bdaddr_type)
{
- return adapter_ops->block_device(adapter->dev_id, bdaddr, type);
+ return adapter_ops->block_device(adapter->dev_id, bdaddr, bdaddr_type);
}
int btd_adapter_unblock_address(struct btd_adapter *adapter, bdaddr_t *bdaddr,
- addr_type_t type)
+ uint8_t bdaddr_type)
{
- return adapter_ops->unblock_device(adapter->dev_id, bdaddr, type);
+ return adapter_ops->unblock_device(adapter->dev_id, bdaddr,
+ bdaddr_type);
}
static void clear_blocked(struct btd_adapter *adapter)
} else
alias = g_strdup(dev->alias);
- if (dev->type != ADDR_TYPE_BREDR) {
+ if (dev->bdaddr_type != BDADDR_BREDR) {
gboolean broadcaster;
uint16_t app;
}
static struct remote_dev_info *found_device_new(const bdaddr_t *bdaddr,
- addr_type_t type, const char *name,
+ uint8_t bdaddr_type, const char *name,
const char *alias, uint32_t class,
gboolean legacy, int flags)
{
dev = g_new0(struct remote_dev_info, 1);
bacpy(&dev->bdaddr, bdaddr);
- dev->type = type;
+ dev->bdaddr_type = bdaddr_type;
dev->name = g_strdup(name);
dev->alias = g_strdup(alias);
dev->class = class;
}
void adapter_update_found_devices(struct btd_adapter *adapter,
- bdaddr_t *bdaddr, addr_type_t type,
+ bdaddr_t *bdaddr, uint8_t bdaddr_type,
int8_t rssi, uint8_t confirm_name,
uint8_t *data, uint8_t data_len)
{
name = read_stored_data(&adapter->bdaddr, bdaddr, "names");
- if (type == ADDR_TYPE_BREDR) {
+ if (bdaddr_type == BDADDR_BREDR) {
legacy = pairing_is_legacy(&adapter->bdaddr, bdaddr, data,
name);
}
if (confirm_name)
- adapter_ops->confirm_name(adapter->dev_id, bdaddr, type,
+ adapter_ops->confirm_name(adapter->dev_id, bdaddr, bdaddr_type,
name_known);
alias = read_stored_data(&adapter->bdaddr, bdaddr, "aliases");
- dev = found_device_new(bdaddr, type, name, alias, dev_class, legacy,
- eir_data.flags);
+ dev = found_device_new(bdaddr, bdaddr_type, name, alias, dev_class,
+ legacy, eir_data.flags);
free(name);
free(alias);
}
int btd_adapter_disconnect_device(struct btd_adapter *adapter,
- bdaddr_t *bdaddr, addr_type_t type)
+ bdaddr_t *bdaddr, uint8_t bdaddr_type)
{
- return adapter_ops->disconnect(adapter->dev_id, bdaddr, type);
+ return adapter_ops->disconnect(adapter->dev_id, bdaddr, bdaddr_type);
}
int btd_adapter_remove_bonding(struct btd_adapter *adapter, bdaddr_t *bdaddr,
- addr_type_t type)
+ uint8_t bdaddr_type)
{
- return adapter_ops->remove_bonding(adapter->dev_id, bdaddr, type);
+ return adapter_ops->remove_bonding(adapter->dev_id, bdaddr,
+ bdaddr_type);
}
int btd_adapter_pincode_reply(struct btd_adapter *adapter, bdaddr_t *bdaddr,
}
int btd_adapter_confirm_reply(struct btd_adapter *adapter, bdaddr_t *bdaddr,
- addr_type_t type, gboolean success)
+ uint8_t bdaddr_type, gboolean success)
{
- return adapter_ops->confirm_reply(adapter->dev_id, bdaddr, type,
+ return adapter_ops->confirm_reply(adapter->dev_id, bdaddr, bdaddr_type,
success);
}
int btd_adapter_passkey_reply(struct btd_adapter *adapter, bdaddr_t *bdaddr,
- addr_type_t type, uint32_t passkey)
+ uint8_t bdaddr_type, uint32_t passkey)
{
- return adapter_ops->passkey_reply(adapter->dev_id, bdaddr, type,
+ return adapter_ops->passkey_reply(adapter->dev_id, bdaddr, bdaddr_type,
passkey);
}
/* Invalid SSP passkey value used to indicate negative replies */
#define INVALID_PASSKEY 0xffffffff
-typedef enum {
- ADDR_TYPE_BREDR,
- ADDR_TYPE_LE_PUBLIC,
- ADDR_TYPE_LE_RANDOM,
-} addr_type_t;
-
struct btd_adapter;
struct link_key_info {
struct smp_ltk_info {
bdaddr_t bdaddr;
- addr_type_t addr_type;
+ uint8_t bdaddr_type;
uint8_t authenticated;
uint8_t master;
uint8_t enc_size;
struct remote_dev_info {
bdaddr_t bdaddr;
- addr_type_t type;
+ uint8_t bdaddr_type;
int8_t rssi;
uint32_t class;
char *name;
struct remote_dev_info *adapter_search_found_devices(struct btd_adapter *adapter,
bdaddr_t *bdaddr);
void adapter_update_found_devices(struct btd_adapter *adapter,
- bdaddr_t *bdaddr, addr_type_t type,
+ bdaddr_t *bdaddr, uint8_t bdaddr_type,
int8_t rssi, uint8_t confirm_name,
uint8_t *data, uint8_t data_len);
void adapter_emit_device_found(struct btd_adapter *adapter,
int (*read_clock) (int index, bdaddr_t *bdaddr, int which, int timeout,
uint32_t *clock, uint16_t *accuracy);
int (*read_bdaddr) (int index, bdaddr_t *bdaddr);
- int (*block_device) (int index, bdaddr_t *bdaddr, addr_type_t type);
- int (*unblock_device) (int index, bdaddr_t *bdaddr, addr_type_t type);
+ int (*block_device) (int index, bdaddr_t *bdaddr, uint8_t bdaddr_type);
+ int (*unblock_device) (int index, bdaddr_t *bdaddr, uint8_t bdaddr_type);
int (*get_conn_list) (int index, GSList **conns);
- int (*disconnect) (int index, bdaddr_t *bdaddr, addr_type_t type);
- int (*remove_bonding) (int index, bdaddr_t *bdaddr, addr_type_t type);
+ int (*disconnect) (int index, bdaddr_t *bdaddr, uint8_t bdaddr_type);
+ int (*remove_bonding) (int index, bdaddr_t *bdaddr, uint8_t bdaddr_type);
int (*pincode_reply) (int index, bdaddr_t *bdaddr, const char *pin,
size_t pin_len);
- int (*confirm_reply) (int index, bdaddr_t *bdaddr, addr_type_t type,
+ int (*confirm_reply) (int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
gboolean success);
- int (*passkey_reply) (int index, bdaddr_t *bdaddr, addr_type_t type,
+ int (*passkey_reply) (int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
uint32_t passkey);
int (*encrypt_link) (int index, bdaddr_t *bdaddr, bt_hci_result_t cb,
gpointer user_data);
int (*restore_powered) (int index);
int (*load_keys) (int index, GSList *keys, gboolean debug_keys);
int (*set_io_capability) (int index, uint8_t io_capability);
- int (*create_bonding) (int index, bdaddr_t *bdaddr, uint8_t addr_type,
- uint8_t io_cap);
+ int (*create_bonding) (int index, bdaddr_t *bdaddr,
+ uint8_t bdaddr_type, uint8_t io_cap);
int (*cancel_bonding) (int index, bdaddr_t *bdaddr);
int (*read_local_oob_data) (int index);
int (*add_remote_oob_data) (int index, bdaddr_t *bdaddr, uint8_t *hash,
uint8_t *randomizer);
int (*remove_remote_oob_data) (int index, bdaddr_t *bdaddr);
- int (*confirm_name) (int index, bdaddr_t *bdaddr, addr_type_t type,
+ int (*confirm_name) (int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
gboolean name_known);
int (*load_ltks) (int index, GSList *keys);
};
uint16_t *accuracy);
int btd_adapter_block_address(struct btd_adapter *adapter, bdaddr_t *bdaddr,
- addr_type_t type);
+ uint8_t bdaddr_type);
int btd_adapter_unblock_address(struct btd_adapter *adapter, bdaddr_t *bdaddr,
- addr_type_t type);
+ uint8_t bdaddr_type);
int btd_adapter_disconnect_device(struct btd_adapter *adapter,
- bdaddr_t *bdaddr, addr_type_t type);
+ bdaddr_t *bdaddr, uint8_t bdaddr_type);
int btd_adapter_remove_bonding(struct btd_adapter *adapter, bdaddr_t *bdaddr,
- addr_type_t type);
+ uint8_t bdaddr_type);
int btd_adapter_pincode_reply(struct btd_adapter *adapter, bdaddr_t *bdaddr,
const char *pin, size_t pin_len);
int btd_adapter_confirm_reply(struct btd_adapter *adapter, bdaddr_t *bdaddr,
- addr_type_t type, gboolean success);
+ uint8_t bdaddr_type, gboolean success);
int btd_adapter_passkey_reply(struct btd_adapter *adapter, bdaddr_t *bdaddr,
- addr_type_t type, uint32_t passkey);
+ uint8_t bdaddr_type, uint32_t passkey);
int btd_adapter_encrypt_link(struct btd_adapter *adapter, bdaddr_t *bdaddr,
bt_hci_result_t cb, gpointer user_data);
uint16_t source);
int adapter_create_bonding(struct btd_adapter *adapter, bdaddr_t *bdaddr,
- uint8_t addr_type, uint8_t io_cap);
+ uint8_t bdaddr_type, uint8_t io_cap);
int adapter_cancel_bonding(struct btd_adapter *adapter, bdaddr_t *bdaddr);
struct btd_device {
bdaddr_t bdaddr;
- addr_type_t type;
+ uint8_t bdaddr_type;
gchar *path;
char name[MAX_NAME_LENGTH + 1];
char *alias;
gboolean device_is_bredr(struct btd_device *device)
{
- return (device->type == ADDR_TYPE_BREDR);
+ return (device->bdaddr_type == BDADDR_BREDR);
}
gboolean device_is_le(struct btd_device *device)
{
- return (device->type != ADDR_TYPE_BREDR);
+ return (device->bdaddr_type != BDADDR_BREDR);
}
gboolean device_is_paired(struct btd_device *device)
device->disconn_timer = 0;
btd_adapter_disconnect_device(device->adapter, &device->bdaddr,
- device->type);
+ device->bdaddr_type);
return FALSE;
}
if (!update_only)
err = btd_adapter_block_address(device->adapter,
- &device->bdaddr, device->type);
+ &device->bdaddr, device->bdaddr_type);
if (err < 0)
return err;
if (!update_only)
err = btd_adapter_unblock_address(device->adapter,
- &device->bdaddr, device->type);
+ &device->bdaddr, device->bdaddr_type);
if (err < 0)
return err;
struct btd_device *device_create(DBusConnection *conn,
struct btd_adapter *adapter,
- const gchar *address, addr_type_t type)
+ const gchar *address, uint8_t bdaddr_type)
{
gchar *address_up;
struct btd_device *device;
str2ba(address, &device->bdaddr);
device->adapter = adapter;
- device->type = type;
+ device->bdaddr_type = bdaddr_type;
adapter_get_address(adapter, &src);
ba2str(&src, srcaddr);
read_device_name(srcaddr, address, device->name);
device_set_bonded(device, FALSE);
device->paired = FALSE;
btd_adapter_remove_bonding(device->adapter, &device->bdaddr,
- device->type);
+ device->bdaddr_type);
}
delete_entry(&src, "profiles", addr);
delete_entry(&src, "trusts", addr);
BT_IO_OPT_INVALID);
} else {
io = bt_io_connect(BT_IO_L2CAP, att_connect_cb,
- attcb, NULL, &gerr,
- BT_IO_OPT_SOURCE_BDADDR, &sba,
- BT_IO_OPT_DEST_BDADDR, &device->bdaddr,
- BT_IO_OPT_DEST_TYPE, device->type,
- BT_IO_OPT_CID, ATT_CID,
- BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
- BT_IO_OPT_INVALID);
+ attcb, NULL, &gerr,
+ BT_IO_OPT_SOURCE_BDADDR, &sba,
+ BT_IO_OPT_DEST_BDADDR, &device->bdaddr,
+ BT_IO_OPT_DEST_TYPE, device->bdaddr_type,
+ BT_IO_OPT_CID, ATT_CID,
+ BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
+ BT_IO_OPT_INVALID);
}
if (io == NULL) {
attcb, NULL, NULL,
BT_IO_OPT_SOURCE_BDADDR, &src,
BT_IO_OPT_DEST_BDADDR, &device->bdaddr,
- BT_IO_OPT_DEST_TYPE, device->type,
+ BT_IO_OPT_DEST_TYPE, device->bdaddr_type,
BT_IO_OPT_CID, ATT_CID,
BT_IO_OPT_SEC_LEVEL, sec_level,
BT_IO_OPT_INVALID);
}
void device_get_address(struct btd_device *device, bdaddr_t *bdaddr,
- addr_type_t *type)
+ uint8_t *bdaddr_type)
{
bacpy(bdaddr, &device->bdaddr);
- if (type != NULL)
- *type = device->type;
+ if (bdaddr_type != NULL)
+ *bdaddr_type = device->bdaddr_type;
}
-void device_set_addr_type(struct btd_device *device, addr_type_t type)
+void device_set_addr_type(struct btd_device *device, uint8_t bdaddr_type)
{
if (device == NULL)
return;
- device->type = type;
+ device->bdaddr_type = bdaddr_type;
}
const gchar *device_get_path(struct btd_device *device)
if (!value)
btd_adapter_remove_bonding(device->adapter, &device->bdaddr,
- device->type);
+ device->bdaddr_type);
device->paired = value;
attcb->user_data = device;
device->att_io = bt_io_connect(BT_IO_L2CAP, att_connect_cb,
- attcb, NULL, &gerr,
- BT_IO_OPT_SOURCE_BDADDR, &sba,
- BT_IO_OPT_DEST_BDADDR, &device->bdaddr,
- BT_IO_OPT_DEST_TYPE, device->type,
- BT_IO_OPT_CID, ATT_CID,
- BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
- BT_IO_OPT_INVALID);
+ attcb, NULL, &gerr,
+ BT_IO_OPT_SOURCE_BDADDR, &sba,
+ BT_IO_OPT_DEST_BDADDR, &device->bdaddr,
+ BT_IO_OPT_DEST_TYPE, device->bdaddr_type,
+ BT_IO_OPT_CID, ATT_CID,
+ BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
+ BT_IO_OPT_INVALID);
if (device->att_io == NULL) {
DBusMessage *reply = btd_error_failed(msg,
}
err = adapter_create_bonding(adapter, &device->bdaddr,
- device->type, capability);
+ device->bdaddr_type, capability);
if (err < 0)
return btd_error_failed(msg, strerror(-err));
struct btd_device *device_create(DBusConnection *conn,
struct btd_adapter *adapter,
- const char *address, addr_type_t type);
+ const char *address, uint8_t bdaddr_type);
void device_set_name(struct btd_device *device, const char *name);
void device_get_name(struct btd_device *device, char *name, size_t len);
uint16_t btd_device_get_vendor(struct btd_device *device);
void btd_device_add_uuid(struct btd_device *device, const char *uuid);
struct btd_adapter *device_get_adapter(struct btd_device *device);
void device_get_address(struct btd_device *device, bdaddr_t *bdaddr,
- addr_type_t *type);
-void device_set_addr_type(struct btd_device *device, addr_type_t type);
+ uint8_t *bdaddr_type);
+void device_set_addr_type(struct btd_device *device, uint8_t bdaddr_type);
const gchar *device_get_path(struct btd_device *device);
struct agent *device_get_agent(struct btd_device *device);
gboolean device_is_bredr(struct btd_device *device);
struct btd_device *device, gboolean success)
{
bdaddr_t bdaddr;
- addr_type_t type;
+ uint8_t bdaddr_type;
- device_get_address(device, &bdaddr, &type);
+ device_get_address(device, &bdaddr, &bdaddr_type);
- return btd_adapter_confirm_reply(adapter, &bdaddr, type, success);
+ return btd_adapter_confirm_reply(adapter, &bdaddr, bdaddr_type,
+ success);
}
static void confirm_cb(struct agent *agent, DBusError *err, void *user_data)
struct btd_device *device = user_data;
struct btd_adapter *adapter = device_get_adapter(device);
bdaddr_t bdaddr;
- addr_type_t type;
+ uint8_t bdaddr_type;
- device_get_address(device, &bdaddr, &type);
+ device_get_address(device, &bdaddr, &bdaddr_type);
if (err)
passkey = INVALID_PASSKEY;
- btd_adapter_passkey_reply(adapter, &bdaddr, type, passkey);
+ btd_adapter_passkey_reply(adapter, &bdaddr, bdaddr_type, passkey);
}
int btd_event_user_confirm(bdaddr_t *sba, bdaddr_t *dba, uint32_t passkey)
write_lastused_info(sba, dba, tm);
}
-void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, addr_type_t type,
+void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
int8_t rssi, uint8_t confirm_name,
uint8_t *data, uint8_t data_len)
{
if (data)
write_remote_eir(local, peer, data, data_len);
- adapter_update_found_devices(adapter, peer, type, rssi,
+ adapter_update_found_devices(adapter, peer, bdaddr_type, rssi,
confirm_name, data, data_len);
}
}
static int store_longtermkey(bdaddr_t *local, bdaddr_t *peer,
- addr_type_t addr_type, unsigned char *key,
+ uint8_t bdaddr_type, unsigned char *key,
uint8_t master, uint8_t authenticated,
uint8_t enc_size, uint16_t ediv, uint8_t rand[8])
{
newkey = g_string_new(val);
g_free(val);
- g_string_append_printf(newkey, " %d %d %d %d %d ", addr_type,
+ g_string_append_printf(newkey, " %d %d %d %d %d ", bdaddr_type,
authenticated, master, enc_size, ediv);
str = buf2str(rand, 8);
return ret;
}
-int btd_event_ltk_notify(bdaddr_t *local, bdaddr_t *peer, addr_type_t addr_type,
+int btd_event_ltk_notify(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
uint8_t *key, uint8_t master,
uint8_t authenticated, uint8_t enc_size,
uint16_t ediv, uint8_t rand[8])
if (!get_adapter_and_device(local, peer, &adapter, &device, TRUE))
return -ENODEV;
- ret = store_longtermkey(local, peer, addr_type, key, master,
+ ret = store_longtermkey(local, peer, bdaddr_type, key, master,
authenticated, enc_size, ediv, rand);
if (ret == 0) {
device_set_bonded(device, TRUE);
return ret;
}
-void btd_event_conn_complete(bdaddr_t *local, bdaddr_t *peer, addr_type_t type,
+void btd_event_conn_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
char *name, uint8_t *dev_class)
{
struct btd_adapter *adapter;
write_remote_class(local, peer, class);
}
- device_set_addr_type(device, type);
+ device_set_addr_type(device, bdaddr_type);
adapter_add_connection(adapter, device);
*/
int btd_event_request_pin(bdaddr_t *sba, bdaddr_t *dba, gboolean secure);
-void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, addr_type_t type,
+void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
int8_t rssi, uint8_t confirm_name,
uint8_t *data, uint8_t data_len);
void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer, gboolean legacy);
void btd_event_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t class);
void btd_event_remote_name(bdaddr_t *local, bdaddr_t *peer, char *name);
-void btd_event_conn_complete(bdaddr_t *local, bdaddr_t *peer, addr_type_t type,
+void btd_event_conn_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
char *name, uint8_t *dev_class);
void btd_event_conn_failed(bdaddr_t *local, bdaddr_t *peer, uint8_t status);
void btd_event_disconn_complete(bdaddr_t *local, bdaddr_t *peer);
void btd_event_device_unpaired(bdaddr_t *local, bdaddr_t *peer);
int btd_event_link_key_notify(bdaddr_t *local, bdaddr_t *peer, uint8_t *key,
uint8_t key_type, uint8_t pin_length);
-int btd_event_ltk_notify(bdaddr_t *local, bdaddr_t *peer, addr_type_t addr_type,
+int btd_event_ltk_notify(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
uint8_t *key, uint8_t master,
uint8_t authenticated, uint8_t enc_size,
uint16_t ediv, uint8_t rand[8]);