All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 0/7] Add address type to L2CAP socket
@ 2012-04-25  1:42 Claudio Takahasi
  2012-04-25  1:42 ` [PATCH BlueZ 1/7] Add Bluetooth address type in sockaddr_l2 Claudio Takahasi
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Claudio Takahasi @ 2012-04-25  1:42 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

Dependency: "[PATCH 0/8] LE Connection"

Rebased version of the previous RFC: "[RFC BlueZ v1 1/7] Add Bluetooth
address type in sockaddr_l2"

Andre Guedes (1):
  l2test: Add option to inform the address type

Claudio Takahasi (6):
  Add Bluetooth address type in sockaddr_l2
  btio: Add address type in bt_io_connect
  Add address type for BLE bt_io_connect calls
  Remove leftover field in remote_dev_info struct
  Remove addr_type_t definition from adapter.h
  Remove MGMT address type definition

 btio/btio.c       |   21 +++++++++++---
 btio/btio.h       |    1 +
 lib/bluetooth.h   |    5 +++
 lib/l2cap.h       |    1 +
 lib/mgmt.h        |    5 ---
 mgmt/main.c       |   26 +++++++++---------
 plugins/hciops.c  |   51 ++++++++++++++++++----------------
 plugins/mgmtops.c |   77 +++++++++++++++++-----------------------------------
 src/adapter.c     |   70 ++++++++++++++++++++++++-----------------------
 src/adapter.h     |   45 +++++++++++++------------------
 src/device.c      |   59 +++++++++++++++++++++-------------------
 src/device.h      |    6 ++--
 src/event.c       |   29 ++++++++++---------
 src/event.h       |    6 ++--
 test/l2test.c     |   27 +++++++++++++++++-
 15 files changed, 221 insertions(+), 208 deletions(-)

-- 
1.7.8.5


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH BlueZ 1/7] Add Bluetooth address type in sockaddr_l2
  2012-04-25  1:42 [PATCH BlueZ 0/7] Add address type to L2CAP socket Claudio Takahasi
@ 2012-04-25  1:42 ` Claudio Takahasi
  2012-04-25  1:42 ` [PATCH BlueZ 2/7] btio: Add address type in bt_io_connect Claudio Takahasi
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Claudio Takahasi @ 2012-04-25  1:42 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

This patch adds the address type information to sockaddr_l2 structure,
allowing the userspace to inform the remote address type required for
LE Create Connection command.
---
 lib/bluetooth.h |    5 +++++
 lib/l2cap.h     |    1 +
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/lib/bluetooth.h b/lib/bluetooth.h
index 0541842..0fc4508 100644
--- a/lib/bluetooth.h
+++ b/lib/bluetooth.h
@@ -222,6 +222,11 @@ typedef struct {
 	uint8_t b[6];
 } __attribute__((packed)) bdaddr_t;
 
+/* BD Address type */
+#define BDADDR_BREDR           0x00
+#define BDADDR_LE_PUBLIC       0x01
+#define BDADDR_LE_RANDOM       0x02
+
 #define BDADDR_ANY   (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})
 #define BDADDR_ALL   (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}})
 #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}})
diff --git a/lib/l2cap.h b/lib/l2cap.h
index 5806aaa..5ce94c4 100644
--- a/lib/l2cap.h
+++ b/lib/l2cap.h
@@ -43,6 +43,7 @@ struct sockaddr_l2 {
 	unsigned short	l2_psm;
 	bdaddr_t	l2_bdaddr;
 	unsigned short	l2_cid;
+	uint8_t		l2_bdaddr_type;
 };
 
 /* L2CAP socket options */
-- 
1.7.8.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH BlueZ 2/7] btio: Add address type in bt_io_connect
  2012-04-25  1:42 [PATCH BlueZ 0/7] Add address type to L2CAP socket Claudio Takahasi
  2012-04-25  1:42 ` [PATCH BlueZ 1/7] Add Bluetooth address type in sockaddr_l2 Claudio Takahasi
@ 2012-04-25  1:42 ` Claudio Takahasi
  2012-04-25  1:42 ` [PATCH BlueZ 3/7] Add address type for BLE bt_io_connect calls Claudio Takahasi
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Claudio Takahasi @ 2012-04-25  1:42 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

This patch adds a new BtIO option to allow setting the remote Bluetooth
address type for BLE connections. Allowed values for BT_IO_OPT_DEST_TYPE
option are: BDADDR_BREDR, BDADDR_LE_PUBLIC, and BDADDR_LE_RANDOM.
---
 btio/btio.c |   21 +++++++++++++++++----
 btio/btio.h |    1 +
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/btio/btio.c b/btio/btio.c
index 9781ec4..e81fb75 100644
--- a/btio/btio.c
+++ b/btio/btio.c
@@ -51,6 +51,7 @@
 struct set_opts {
 	bdaddr_t src;
 	bdaddr_t dst;
+	uint8_t dst_type;
 	int defer;
 	int sec_level;
 	uint8_t channel;
@@ -280,8 +281,8 @@ static int l2cap_bind(int sock, const bdaddr_t *src, uint16_t psm,
 	return 0;
 }
 
-static int l2cap_connect(int sock, const bdaddr_t *dst,
-					uint16_t psm, uint16_t cid)
+static int l2cap_connect(int sock, const bdaddr_t *dst, uint8_t dst_type,
+						uint16_t psm, uint16_t cid)
 {
 	int err;
 	struct sockaddr_l2 addr;
@@ -294,6 +295,8 @@ static int l2cap_connect(int sock, const bdaddr_t *dst,
 	else
 		addr.l2_psm = htobs(psm);
 
+	addr.l2_bdaddr_type = dst_type;
+
 	err = connect(sock, (struct sockaddr *) &addr, sizeof(addr));
 	if (err < 0 && !(errno == EAGAIN || errno == EINPROGRESS))
 		return -errno;
@@ -698,6 +701,7 @@ static gboolean parse_set_opts(struct set_opts *opts, GError **err,
 	opts->mode = L2CAP_MODE_BASIC;
 	opts->flushable = -1;
 	opts->priority = 0;
+	opts->dst_type = BDADDR_BREDR;
 
 	while (opt != BT_IO_OPT_INVALID) {
 		switch (opt) {
@@ -714,6 +718,9 @@ static gboolean parse_set_opts(struct set_opts *opts, GError **err,
 		case BT_IO_OPT_DEST_BDADDR:
 			bacpy(&opts->dst, va_arg(args, const bdaddr_t *));
 			break;
+		case BT_IO_OPT_DEST_TYPE:
+			opts->dst_type = va_arg(args, int);
+			break;
 		case BT_IO_OPT_DEFER_TIMEOUT:
 			opts->defer = va_arg(args, int);
 			break;
@@ -875,6 +882,10 @@ static gboolean l2cap_get(int sock, GError **err, BtIOOption opt1,
 		case BT_IO_OPT_DEST_BDADDR:
 			bacpy(va_arg(args, bdaddr_t *), &dst.l2_bdaddr);
 			break;
+		case BT_IO_OPT_DEST_TYPE:
+			g_set_error(err, BT_IO_ERROR, BT_IO_ERROR_INVALID_ARGS,
+							"Not implemented");
+			return FALSE;
 		case BT_IO_OPT_DEFER_TIMEOUT:
 			len = sizeof(int);
 			if (getsockopt(sock, SOL_BLUETOOTH, BT_DEFER_SETUP,
@@ -1366,11 +1377,13 @@ GIOChannel *bt_io_connect(BtIOType type, BtIOConnect connect,
 
 	switch (type) {
 	case BT_IO_L2RAW:
-		err = l2cap_connect(sock, &opts.dst, 0, opts.cid);
+		err = l2cap_connect(sock, &opts.dst, opts.dst_type, 0,
+								opts.cid);
 		break;
 	case BT_IO_L2CAP:
 	case BT_IO_L2ERTM:
-		err = l2cap_connect(sock, &opts.dst, opts.psm, opts.cid);
+		err = l2cap_connect(sock, &opts.dst, opts.dst_type,
+							opts.psm, opts.cid);
 		break;
 	case BT_IO_RFCOMM:
 		err = rfcomm_connect(sock, &opts.dst, opts.channel);
diff --git a/btio/btio.h b/btio/btio.h
index 429e8c0..cf0e070 100644
--- a/btio/btio.h
+++ b/btio/btio.h
@@ -51,6 +51,7 @@ typedef enum {
 	BT_IO_OPT_SOURCE_BDADDR,
 	BT_IO_OPT_DEST,
 	BT_IO_OPT_DEST_BDADDR,
+	BT_IO_OPT_DEST_TYPE,
 	BT_IO_OPT_DEFER_TIMEOUT,
 	BT_IO_OPT_SEC_LEVEL,
 	BT_IO_OPT_KEY_SIZE,
-- 
1.7.8.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH BlueZ 3/7] Add address type for BLE bt_io_connect calls
  2012-04-25  1:42 [PATCH BlueZ 0/7] Add address type to L2CAP socket Claudio Takahasi
  2012-04-25  1:42 ` [PATCH BlueZ 1/7] Add Bluetooth address type in sockaddr_l2 Claudio Takahasi
  2012-04-25  1:42 ` [PATCH BlueZ 2/7] btio: Add address type in bt_io_connect Claudio Takahasi
@ 2012-04-25  1:42 ` Claudio Takahasi
  2012-04-25  1:42 ` [PATCH BlueZ 4/7] Remove leftover field in remote_dev_info struct Claudio Takahasi
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Claudio Takahasi @ 2012-04-25  1:42 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

This patch adds the address type option in bt_io_connect calls for BLE
devices. BR/EDR is the default value, and it is not mandatory to inform
it. For BLE devices, it is necessary to inform if the type is public or
random.
---
 src/device.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/device.c b/src/device.c
index ea6fec2..1ea4854 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2001,6 +2001,7 @@ static gboolean att_connect(gpointer user_data)
 					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);
@@ -2086,6 +2087,7 @@ int device_browse_primary(struct btd_device *device, DBusConnection *conn,
 				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_CID, ATT_CID,
 				BT_IO_OPT_SEC_LEVEL, sec_level,
 				BT_IO_OPT_INVALID);
@@ -2488,7 +2490,8 @@ DBusMessage *device_create_bonding(struct btd_device *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_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);
-- 
1.7.8.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH BlueZ 4/7] Remove leftover field in remote_dev_info struct
  2012-04-25  1:42 [PATCH BlueZ 0/7] Add address type to L2CAP socket Claudio Takahasi
                   ` (2 preceding siblings ...)
  2012-04-25  1:42 ` [PATCH BlueZ 3/7] Add address type for BLE bt_io_connect calls Claudio Takahasi
@ 2012-04-25  1:42 ` Claudio Takahasi
  2012-04-25  1:42 ` [PATCH BlueZ 5/7] Remove addr_type_t definition from adapter.h Claudio Takahasi
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Claudio Takahasi @ 2012-04-25  1:42 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

Field "bdaddr_type" of the remote_dev_info structure is not being
referenced in the code. Field "type" is already being used to store
the Bluetooth address type.
---
 src/adapter.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/src/adapter.h b/src/adapter.h
index 57d2089..29b5ad5 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -78,7 +78,6 @@ struct remote_dev_info {
 	char **uuids;
 	size_t uuid_count;
 	GSList *services;
-	uint8_t bdaddr_type;
 	uint8_t flags;
 };
 
-- 
1.7.8.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH BlueZ 5/7] Remove addr_type_t definition from adapter.h
  2012-04-25  1:42 [PATCH BlueZ 0/7] Add address type to L2CAP socket Claudio Takahasi
                   ` (3 preceding siblings ...)
  2012-04-25  1:42 ` [PATCH BlueZ 4/7] Remove leftover field in remote_dev_info struct Claudio Takahasi
@ 2012-04-25  1:42 ` Claudio Takahasi
  2012-04-25  1:42 ` [PATCH BlueZ 6/7] Remove MGMT address type definition Claudio Takahasi
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Claudio Takahasi @ 2012-04-25  1:42 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

This patch replaces addr_type_t by the new Bluetooth address type
constants defined in bluetooth.h
---
 plugins/hciops.c  |   51 ++++++++++++++++++++------------------
 plugins/mgmtops.c |   51 +++++++++++++++++++-------------------
 src/adapter.c     |   70 +++++++++++++++++++++++++++-------------------------
 src/adapter.h     |   44 ++++++++++++++-------------------
 src/device.c      |   62 +++++++++++++++++++++++-----------------------
 src/device.h      |    6 ++--
 src/event.c       |   29 +++++++++++----------
 src/event.h       |    6 ++--
 8 files changed, 160 insertions(+), 159 deletions(-)

diff --git a/plugins/hciops.c b/plugins/hciops.c
index ef444da..678ca1b 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -1242,7 +1242,7 @@ static void return_link_keys(int index, void *ptr)
 
 /* 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];
@@ -1305,7 +1305,7 @@ static void user_confirm_request(int index, void *ptr)
 		usleep(5000);
 
 		if (hciops_confirm_reply(index, &req->bdaddr,
-						ADDR_TYPE_BREDR, TRUE) < 0)
+						BDADDR_BREDR, TRUE) < 0)
 			goto fail;
 
 		return;
@@ -2070,7 +2070,7 @@ static inline void remote_version_information(int index, void *ptr)
 				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)
 {
@@ -2098,7 +2098,7 @@ static void dev_found(struct dev_info *info, bdaddr_t *dba, addr_type_t type,
 	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);
 }
 
@@ -2113,7 +2113,7 @@ static inline void inquiry_result(int index, int plen, void *ptr)
 		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;
 	}
@@ -2134,7 +2134,7 @@ static inline void inquiry_result_with_rssi(int index, int plen, void *ptr)
 			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;
@@ -2144,7 +2144,7 @@ static inline void inquiry_result_with_rssi(int index, int plen, void *ptr)
 			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;
@@ -2174,7 +2174,7 @@ static inline void extended_inquiry_result(int index, int plen, void *ptr)
 		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;
 	}
@@ -2280,7 +2280,7 @@ static inline void conn_complete(int index, void *ptr)
 	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)
@@ -2300,14 +2300,14 @@ static inline void conn_complete(int index, void *ptr)
 		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;
 	}
 }
 
@@ -2318,7 +2318,7 @@ static inline void le_conn_complete(int index, void *ptr)
 	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,
@@ -2329,8 +2329,8 @@ static inline void le_conn_complete(int index, void *ptr)
 	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 */
@@ -3380,7 +3380,8 @@ static int hciops_read_bdaddr(int index, bdaddr_t *bdaddr)
 	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];
@@ -3394,7 +3395,8 @@ static int hciops_block_device(int index, bdaddr_t *bdaddr, addr_type_t type)
 	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];
@@ -3427,14 +3429,15 @@ static int hciops_get_conn_list(int index, GSList **conns)
 	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;
@@ -3493,8 +3496,8 @@ static int hciops_pincode_reply(int index, bdaddr_t *bdaddr, const char *pin,
 	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];
@@ -3726,7 +3729,7 @@ failed:
 }
 
 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;
@@ -3846,8 +3849,8 @@ static int hciops_remove_remote_oob_data(int index, bdaddr_t *bdaddr)
 	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;
diff --git a/plugins/mgmtops.c b/plugins/mgmtops.c
index 5663ef7..9ff1a75 100644
--- a/plugins/mgmtops.c
+++ b/plugins/mgmtops.c
@@ -463,28 +463,28 @@ static void mgmt_new_link_key(int sk, uint16_t index, void *buf, size_t len)
 	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;
@@ -668,7 +668,7 @@ static void mgmt_pin_code_request(int sk, uint16_t index, void *buf, size_t len)
 	}
 }
 
-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)];
@@ -691,7 +691,7 @@ static int mgmt_confirm_reply(int index, bdaddr_t *bdaddr, addr_type_t type,
 
 	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;
@@ -699,7 +699,7 @@ static int mgmt_confirm_reply(int index, bdaddr_t *bdaddr, addr_type_t type,
 	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)];
@@ -721,7 +721,7 @@ static int mgmt_passkey_reply(int index, bdaddr_t *bdaddr, addr_type_t type,
 
 		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 {
@@ -732,7 +732,7 @@ static int mgmt_passkey_reply(int index, bdaddr_t *bdaddr, addr_type_t type,
 
 		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);
@@ -2015,7 +2015,7 @@ static int mgmt_read_bdaddr(int index, bdaddr_t *bdaddr)
 	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;
@@ -2034,7 +2034,7 @@ static int mgmt_block_device(int index, bdaddr_t *bdaddr, addr_type_t type)
 
 	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);
 
@@ -2044,7 +2044,8 @@ static int mgmt_block_device(int index, bdaddr_t *bdaddr, addr_type_t type)
 	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;
@@ -2063,7 +2064,7 @@ static int mgmt_unblock_device(int index, bdaddr_t *bdaddr, addr_type_t type)
 
 	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);
 
@@ -2085,7 +2086,7 @@ static int mgmt_get_conn_list(int index, GSList **conns)
 	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;
@@ -2101,7 +2102,7 @@ static int mgmt_disconnect(int index, bdaddr_t *bdaddr, addr_type_t type)
 	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);
@@ -2109,7 +2110,7 @@ static int mgmt_disconnect(int index, bdaddr_t *bdaddr, addr_type_t type)
 	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;
@@ -2125,7 +2126,7 @@ static int mgmt_unpair_device(int index, bdaddr_t *bdaddr, addr_type_t type)
 	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)
@@ -2370,7 +2371,7 @@ static int mgmt_remove_remote_oob_data(int index, bdaddr_t *bdaddr)
 	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)];
@@ -2388,7 +2389,7 @@ static int mgmt_confirm_name(int index, bdaddr_t *bdaddr, addr_type_t type,
 	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)
@@ -2429,7 +2430,7 @@ static int mgmtops_load_ltks(int index, GSList *keys)
 		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));
diff --git a/src/adapter.c b/src/adapter.c
index 94df0a2..93b55e8 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -472,7 +472,7 @@ static GSList *remove_bredr(GSList *all)
 
 	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;
 		}
@@ -926,14 +926,14 @@ void adapter_service_remove(struct btd_adapter *adapter, void *r)
 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;
 
@@ -993,7 +993,7 @@ struct btd_device *adapter_get_device(DBusConnection *conn,
 		return device;
 
 	return adapter_create_device(conn, adapter, address,
-						ADDR_TYPE_BREDR);
+						BDADDR_BREDR);
 }
 
 static gboolean discovery_cb(gpointer user_data)
@@ -1386,17 +1386,17 @@ static struct btd_device *create_device_internal(DBusConnection *conn,
 	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;
 
@@ -1705,7 +1705,7 @@ static void create_stored_device_from_profiles(char *key, char *value,
 				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;
 
@@ -1792,7 +1792,7 @@ static struct smp_ltk_info *get_ltk_info(const char *addr, const char *value)
 	ptr = (char *) value + 2 * sizeof(ltk->val) + 1;
 
 	ret = sscanf(ptr, " %hhd %hhd %hhd %hhd %hd %n",
-					(uint8_t *) &ltk->addr_type,
+					(uint8_t *) &ltk->bdaddr_type,
 					&ltk->authenticated, &ltk->master,
 					&ltk->enc_size, &ltk->ediv, &i);
 	if (ret < 2) {
@@ -1822,7 +1822,7 @@ static void create_stored_device_from_linkkeys(char *key, char *value,
 					(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);
@@ -1855,7 +1855,7 @@ static void create_stored_device_from_ltks(char *key, char *value,
 	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);
@@ -1872,7 +1872,7 @@ static void create_stored_device_from_blocked(char *key, char *value,
 				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);
@@ -1926,7 +1926,7 @@ static void create_stored_device_from_primary(char *key, char *value,
 		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;
 
@@ -2000,15 +2000,16 @@ static void load_devices(struct btd_adapter *adapter)
 }
 
 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)
@@ -2699,7 +2700,7 @@ void adapter_emit_device_found(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;
 
@@ -2749,7 +2750,7 @@ void adapter_emit_device_found(struct btd_adapter *adapter,
 }
 
 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)
 {
@@ -2757,7 +2758,7 @@ static struct remote_dev_info *found_device_new(const bdaddr_t *bdaddr,
 
 	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;
@@ -2826,7 +2827,7 @@ static char *read_stored_data(bdaddr_t *local, bdaddr_t *peer, const char *file)
 }
 
 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)
 {
@@ -2881,7 +2882,7 @@ void adapter_update_found_devices(struct btd_adapter *adapter,
 
 	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);
 
@@ -2896,13 +2897,13 @@ void adapter_update_found_devices(struct btd_adapter *adapter,
 	}
 
 	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);
 
@@ -3453,16 +3454,17 @@ int btd_adapter_read_clock(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 }
 
 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,
@@ -3473,16 +3475,16 @@ 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);
 }
 
diff --git a/src/adapter.h b/src/adapter.h
index 29b5ad5..b7ea62b 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -41,12 +41,6 @@
 /* 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 {
@@ -58,7 +52,7 @@ 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;
@@ -69,7 +63,7 @@ struct smp_ltk_info {
 
 struct remote_dev_info {
 	bdaddr_t bdaddr;
-	addr_type_t type;
+	uint8_t bdaddr_type;
 	int8_t rssi;
 	uint32_t class;
 	char *name;
@@ -115,7 +109,7 @@ void adapter_get_address(struct btd_adapter *adapter, bdaddr_t *bdaddr);
 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,
@@ -195,16 +189,16 @@ struct btd_adapter_ops {
 	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);
@@ -216,14 +210,14 @@ struct btd_adapter_ops {
 	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);
 };
@@ -250,22 +244,22 @@ int btd_adapter_read_clock(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 				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);
@@ -275,7 +269,7 @@ int btd_adapter_set_did(struct btd_adapter *adapter, uint16_t vendor,
 					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);
 
diff --git a/src/device.c b/src/device.c
index 1ea4854..021b200 100644
--- a/src/device.c
+++ b/src/device.c
@@ -130,7 +130,7 @@ struct att_callbacks {
 
 struct btd_device {
 	bdaddr_t	bdaddr;
-	addr_type_t	type;
+	uint8_t		bdaddr_type;
 	gchar		*path;
 	char		name[MAX_NAME_LENGTH + 1];
 	char		*alias;
@@ -291,12 +291,12 @@ static void device_free(gpointer user_data)
 
 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)
@@ -516,7 +516,7 @@ static gboolean do_disconnect(gpointer user_data)
 	device->disconn_timer = 0;
 
 	btd_adapter_disconnect_device(device->adapter, &device->bdaddr,
-								device->type);
+							device->bdaddr_type);
 
 	return FALSE;
 }
@@ -537,7 +537,7 @@ int device_block(DBusConnection *conn, struct btd_device *device,
 
 	if (!update_only)
 		err = btd_adapter_block_address(device->adapter,
-						&device->bdaddr, device->type);
+					&device->bdaddr, device->bdaddr_type);
 
 	if (err < 0)
 		return err;
@@ -569,7 +569,7 @@ int device_unblock(DBusConnection *conn, struct btd_device *device,
 
 	if (!update_only)
 		err = btd_adapter_unblock_address(device->adapter,
-						&device->bdaddr, device->type);
+					&device->bdaddr, device->bdaddr_type);
 
 	if (err < 0)
 		return err;
@@ -1036,7 +1036,7 @@ static void device_set_version(struct btd_device *device, uint16_t value)
 
 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;
@@ -1065,7 +1065,7 @@ struct btd_device *device_create(DBusConnection *conn,
 
 	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);
@@ -1158,7 +1158,7 @@ static void device_remove_stored(struct btd_device *device)
 		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);
@@ -1998,13 +1998,13 @@ static gboolean att_connect(gpointer user_data)
 					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) {
@@ -2087,7 +2087,7 @@ int device_browse_primary(struct btd_device *device, DBusConnection *conn,
 				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);
@@ -2182,19 +2182,19 @@ 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)
+							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)
@@ -2393,7 +2393,7 @@ void device_set_paired(struct btd_device *device, gboolean value)
 
 	if (!value)
 		btd_adapter_remove_bonding(device->adapter, &device->bdaddr,
-								device->type);
+							device->bdaddr_type);
 
 	device->paired = value;
 
@@ -2488,13 +2488,13 @@ DBusMessage *device_create_bonding(struct btd_device *device,
 		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,
@@ -2508,7 +2508,7 @@ DBusMessage *device_create_bonding(struct btd_device *device,
 	}
 
 	err = adapter_create_bonding(adapter, &device->bdaddr,
-					device->type, capability);
+					device->bdaddr_type, capability);
 	if (err < 0)
 		return btd_error_failed(msg, strerror(-err));
 
diff --git a/src/device.h b/src/device.h
index 690c64d..51140c7 100644
--- a/src/device.h
+++ b/src/device.h
@@ -36,7 +36,7 @@ typedef enum {
 
 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);
@@ -60,8 +60,8 @@ GSList *device_services_from_record(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);
diff --git a/src/event.c b/src/event.c
index 876bd37..f576102 100644
--- a/src/event.c
+++ b/src/event.c
@@ -144,11 +144,12 @@ static int confirm_reply(struct btd_adapter *adapter,
 				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)
@@ -166,14 +167,14 @@ static void passkey_cb(struct agent *agent, DBusError *err, uint32_t passkey,
 	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)
@@ -254,7 +255,7 @@ static void update_lastused(bdaddr_t *sba, bdaddr_t *dba)
 	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)
 {
@@ -271,7 +272,7 @@ void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, addr_type_t type,
 	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);
 }
 
@@ -367,7 +368,7 @@ static char *buf2str(uint8_t *data, int datalen)
 }
 
 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])
 {
@@ -382,7 +383,7 @@ static int store_longtermkey(bdaddr_t *local, bdaddr_t *peer,
 	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);
@@ -426,7 +427,7 @@ int btd_event_link_key_notify(bdaddr_t *local, bdaddr_t *peer,
 	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])
@@ -438,7 +439,7 @@ int btd_event_ltk_notify(bdaddr_t *local, bdaddr_t *peer, addr_type_t addr_type,
 	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);
@@ -450,7 +451,7 @@ int btd_event_ltk_notify(bdaddr_t *local, bdaddr_t *peer, addr_type_t addr_type,
 	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;
@@ -469,7 +470,7 @@ void btd_event_conn_complete(bdaddr_t *local, bdaddr_t *peer, addr_type_t type,
 			write_remote_class(local, peer, class);
 	}
 
-	device_set_addr_type(device, type);
+	device_set_addr_type(device, bdaddr_type);
 
 	adapter_add_connection(adapter, device);
 
diff --git a/src/event.h b/src/event.h
index 503d35f..c4ae18f 100644
--- a/src/event.h
+++ b/src/event.h
@@ -23,13 +23,13 @@
  */
 
 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);
@@ -43,7 +43,7 @@ void btd_event_device_unblocked(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]);
-- 
1.7.8.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH BlueZ 6/7] Remove MGMT address type definition
  2012-04-25  1:42 [PATCH BlueZ 0/7] Add address type to L2CAP socket Claudio Takahasi
                   ` (4 preceding siblings ...)
  2012-04-25  1:42 ` [PATCH BlueZ 5/7] Remove addr_type_t definition from adapter.h Claudio Takahasi
@ 2012-04-25  1:42 ` Claudio Takahasi
  2012-04-25  1:42 ` [PATCH BlueZ 7/7] l2test: Add option to inform the address type Claudio Takahasi
  2012-04-25 10:07 ` [PATCH BlueZ 0/7] Add address type to L2CAP socket Johan Hedberg
  7 siblings, 0 replies; 9+ messages in thread
From: Claudio Takahasi @ 2012-04-25  1:42 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

This patch replaces the address type defined in management interface
header by the new address type constants defined in the bluetooth.h.
---
 lib/mgmt.h        |    5 ----
 mgmt/main.c       |   26 +++++++++++-----------
 plugins/mgmtops.c |   60 ++++++++++++++--------------------------------------
 3 files changed, 29 insertions(+), 62 deletions(-)

diff --git a/lib/mgmt.h b/lib/mgmt.h
index c9b0f1a..a58915b 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -53,11 +53,6 @@ struct mgmt_hdr {
 } __packed;
 #define MGMT_HDR_SIZE	6
 
-#define MGMT_ADDR_BREDR			0x00
-#define MGMT_ADDR_LE_PUBLIC		0x01
-#define MGMT_ADDR_LE_RANDOM		0x02
-#define MGMT_ADDR_INVALID		0xff
-
 struct mgmt_addr_info {
 	bdaddr_t bdaddr;
 	uint8_t type;
diff --git a/mgmt/main.c b/mgmt/main.c
index 3481e14..6e35071 100644
--- a/mgmt/main.c
+++ b/mgmt/main.c
@@ -306,7 +306,7 @@ static const char *typestr(uint8_t type)
 {
 	const char *str[] = { "BR/EDR", "LE Public", "LE Random" };
 
-	if (type <= MGMT_ADDR_LE_RANDOM)
+	if (type <= BDADDR_LE_RANDOM)
 		return str[type];
 
 	return "(unknown)";
@@ -1265,22 +1265,22 @@ static void cmd_find(int mgmt_sk, uint16_t index, int argc, char **argv)
 		index = 0;
 
 	type = 0;
-	hci_set_bit(MGMT_ADDR_BREDR, &type);
-	hci_set_bit(MGMT_ADDR_LE_PUBLIC, &type);
-	hci_set_bit(MGMT_ADDR_LE_RANDOM, &type);
+	hci_set_bit(BDADDR_BREDR, &type);
+	hci_set_bit(BDADDR_LE_PUBLIC, &type);
+	hci_set_bit(BDADDR_LE_RANDOM, &type);
 
 	while ((opt = getopt_long(argc, argv, "+lbh", find_options,
 								NULL)) != -1) {
 		switch (opt) {
 		case 'l':
-			hci_clear_bit(MGMT_ADDR_BREDR, &type);
-			hci_set_bit(MGMT_ADDR_LE_PUBLIC, &type);
-			hci_set_bit(MGMT_ADDR_LE_RANDOM, &type);
+			hci_clear_bit(BDADDR_BREDR, &type);
+			hci_set_bit(BDADDR_LE_PUBLIC, &type);
+			hci_set_bit(BDADDR_LE_RANDOM, &type);
 			break;
 		case 'b':
-			hci_set_bit(MGMT_ADDR_BREDR, &type);
-			hci_clear_bit(MGMT_ADDR_LE_PUBLIC, &type);
-			hci_clear_bit(MGMT_ADDR_LE_RANDOM, &type);
+			hci_set_bit(BDADDR_BREDR, &type);
+			hci_clear_bit(BDADDR_LE_PUBLIC, &type);
+			hci_clear_bit(BDADDR_LE_RANDOM, &type);
 			break;
 		case 'h':
 		default:
@@ -1388,7 +1388,7 @@ static void cmd_pair(int mgmt_sk, uint16_t index, int argc, char **argv)
 {
 	struct mgmt_cp_pair_device cp;
 	uint8_t cap = 0x01;
-	uint8_t type = MGMT_ADDR_BREDR;
+	uint8_t type = BDADDR_BREDR;
 	int opt;
 
 	while ((opt = getopt_long(argc, argv, "+c:t:h", pair_options,
@@ -1560,7 +1560,7 @@ static struct option block_options[] = {
 static void cmd_block(int mgmt_sk, uint16_t index, int argc, char **argv)
 {
 	struct mgmt_cp_block_device cp;
-	uint8_t type = MGMT_ADDR_BREDR;
+	uint8_t type = BDADDR_BREDR;
 	int opt;
 
 	while ((opt = getopt_long(argc, argv, "+t:h", block_options,
@@ -1607,7 +1607,7 @@ static void unblock_usage(void)
 static void cmd_unblock(int mgmt_sk, uint16_t index, int argc, char **argv)
 {
 	struct mgmt_cp_unblock_device cp;
-	uint8_t type = MGMT_ADDR_BREDR;
+	uint8_t type = BDADDR_BREDR;
 	int opt;
 
 	while ((opt = getopt_long(argc, argv, "+t:h", block_options,
diff --git a/plugins/mgmtops.c b/plugins/mgmtops.c
index 9ff1a75..ddd544d 100644
--- a/plugins/mgmtops.c
+++ b/plugins/mgmtops.c
@@ -463,34 +463,6 @@ static void mgmt_new_link_key(int sk, uint16_t index, void *buf, size_t len)
 	bonding_complete(info, &ev->key.addr.bdaddr, 0);
 }
 
-static inline uint8_t addr_type(uint8_t mgmt_addr_type)
-{
-	switch (mgmt_addr_type) {
-	case MGMT_ADDR_BREDR:
-		return BDADDR_BREDR;
-	case MGMT_ADDR_LE_PUBLIC:
-		return BDADDR_LE_PUBLIC;
-	case MGMT_ADDR_LE_RANDOM:
-		return BDADDR_LE_RANDOM;
-	default:
-		return BDADDR_BREDR;
-	}
-}
-
-static inline uint8_t mgmt_addr_type(uint8_t addr_type)
-{
-	switch (addr_type) {
-	case BDADDR_BREDR:
-		return MGMT_ADDR_BREDR;
-	case BDADDR_LE_PUBLIC:
-		return MGMT_ADDR_LE_PUBLIC;
-	case BDADDR_LE_RANDOM:
-		return MGMT_ADDR_LE_RANDOM;
-	default:
-		return MGMT_ADDR_BREDR;
-	}
-}
-
 static void mgmt_device_connected(int sk, uint16_t index, void *buf, size_t len)
 {
 	struct mgmt_ev_device_connected *ev = buf;
@@ -526,7 +498,7 @@ static void mgmt_device_connected(int sk, uint16_t index, void *buf, size_t len)
 		eir_parse(&eir_data, ev->eir, eir_len);
 
 	btd_event_conn_complete(&info->bdaddr, &ev->addr.bdaddr,
-						addr_type(ev->addr.type),
+						ev->addr.type,
 						eir_data.name,
 						eir_data.dev_class);
 
@@ -609,7 +581,7 @@ static int mgmt_pincode_reply(int index, bdaddr_t *bdaddr, const char *pin,
 
 		cp = (void *) &buf[sizeof(*hdr)];
 		bacpy(&cp->addr.bdaddr, bdaddr);
-		cp->addr.type = MGMT_ADDR_BREDR;
+		cp->addr.type = BDADDR_BREDR;
 
 		buf_len = sizeof(*hdr) + sizeof(*cp);
 	} else {
@@ -624,7 +596,7 @@ static int mgmt_pincode_reply(int index, bdaddr_t *bdaddr, const char *pin,
 
 		cp = (void *) &buf[sizeof(*hdr)];
 		bacpy(&cp->addr.bdaddr, bdaddr);
-		cp->addr.type = MGMT_ADDR_BREDR;
+		cp->addr.type = BDADDR_BREDR;
 		cp->pin_len = pin_len;
 		memcpy(cp->pin_code, pin, pin_len);
 
@@ -691,7 +663,7 @@ static int mgmt_confirm_reply(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
 
 	cp = (void *) &buf[sizeof(*hdr)];
 	bacpy(&cp->addr.bdaddr, bdaddr);
-	cp->addr.type = mgmt_addr_type(bdaddr_type);
+	cp->addr.type = bdaddr_type;
 
 	if (write(mgmt_sock, buf, sizeof(buf)) < 0)
 		return -errno;
@@ -721,7 +693,7 @@ static int mgmt_passkey_reply(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
 
 		cp = (void *) &buf[sizeof(*hdr)];
 		bacpy(&cp->addr.bdaddr, bdaddr);
-		cp->addr.type = mgmt_addr_type(bdaddr_type);
+		cp->addr.type = bdaddr_type;
 
 		buf_len = sizeof(*hdr) + sizeof(*cp);
 	} else {
@@ -732,7 +704,7 @@ static int mgmt_passkey_reply(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
 
 		cp = (void *) &buf[sizeof(*hdr)];
 		bacpy(&cp->addr.bdaddr, bdaddr);
-		cp->addr.type = mgmt_addr_type(bdaddr_type);
+		cp->addr.type = bdaddr_type;
 		cp->passkey = htobl(passkey);
 
 		buf_len = sizeof(*hdr) + sizeof(*cp);
@@ -1594,7 +1566,7 @@ static void mgmt_device_found(int sk, uint16_t index, void *buf, size_t len)
 	confirm_name = (flags & MGMT_DEV_FOUND_CONFIRM_NAME);
 
 	btd_event_device_found(&info->bdaddr, &ev->addr.bdaddr,
-						addr_type(ev->addr.type),
+						ev->addr.type,
 						ev->rssi, confirm_name,
 						eir, eir_len);
 }
@@ -1924,11 +1896,11 @@ static int mgmt_start_discovery(int index)
 	info->discov_type = 0;
 
 	if (mgmt_bredr(info->current_settings))
-		hci_set_bit(MGMT_ADDR_BREDR, &info->discov_type);
+		hci_set_bit(BDADDR_BREDR, &info->discov_type);
 
 	if (mgmt_low_energy(info->current_settings)) {
-		hci_set_bit(MGMT_ADDR_LE_PUBLIC, &info->discov_type);
-		hci_set_bit(MGMT_ADDR_LE_RANDOM, &info->discov_type);
+		hci_set_bit(BDADDR_LE_PUBLIC, &info->discov_type);
+		hci_set_bit(BDADDR_LE_RANDOM, &info->discov_type);
 	}
 
 	memset(buf, 0, sizeof(buf));
@@ -2034,7 +2006,7 @@ static int mgmt_block_device(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type)
 
 	cp = (void *) &buf[sizeof(*hdr)];
 	bacpy(&cp->addr.bdaddr, bdaddr);
-	cp->addr.type = mgmt_addr_type(bdaddr_type);
+	cp->addr.type = bdaddr_type;
 
 	buf_len = sizeof(*hdr) + sizeof(*cp);
 
@@ -2064,7 +2036,7 @@ static int mgmt_unblock_device(int index, bdaddr_t *bdaddr,
 
 	cp = (void *) &buf[sizeof(*hdr)];
 	bacpy(&cp->addr.bdaddr, bdaddr);
-	cp->addr.type = mgmt_addr_type(bdaddr_type);
+	cp->addr.type = bdaddr_type;
 
 	buf_len = sizeof(*hdr) + sizeof(*cp);
 
@@ -2102,7 +2074,7 @@ static int mgmt_disconnect(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type)
 	hdr->index = htobs(index);
 
 	bacpy(&cp->addr.bdaddr, bdaddr);
-	cp->addr.type = mgmt_addr_type(bdaddr_type);
+	cp->addr.type = bdaddr_type;
 
 	if (write(mgmt_sock, buf, sizeof(buf)) < 0)
 		error("write: %s (%d)", strerror(errno), errno);
@@ -2126,7 +2098,7 @@ static int mgmt_unpair_device(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type)
 	hdr->index = htobs(index);
 
 	bacpy(&cp->addr.bdaddr, bdaddr);
-	cp->addr.type = mgmt_addr_type(bdaddr_type);
+	cp->addr.type = bdaddr_type;
 	cp->disconnect = 1;
 
 	if (write(mgmt_sock, buf, sizeof(buf)) < 0)
@@ -2219,7 +2191,7 @@ static int mgmt_load_link_keys(int index, GSList *keys, gboolean debug_keys)
 		struct link_key_info *info = l->data;
 
 		bacpy(&key->addr.bdaddr, &info->bdaddr);
-		key->addr.type = MGMT_ADDR_BREDR;
+		key->addr.type = BDADDR_BREDR;
 		key->type = info->type;
 		memcpy(key->val, info->key, 16);
 		key->pin_len = info->pin_len;
@@ -2389,7 +2361,7 @@ static int mgmt_confirm_name(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
 	hdr->len = htobs(sizeof(*cp));
 
 	bacpy(&cp->addr.bdaddr, bdaddr);
-	cp->addr.type = mgmt_addr_type(bdaddr_type);
+	cp->addr.type = bdaddr_type;
 	cp->name_known = name_known;
 
 	if (write(mgmt_sock, &buf, sizeof(buf)) < 0)
-- 
1.7.8.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH BlueZ 7/7] l2test: Add option to inform the address type
  2012-04-25  1:42 [PATCH BlueZ 0/7] Add address type to L2CAP socket Claudio Takahasi
                   ` (5 preceding siblings ...)
  2012-04-25  1:42 ` [PATCH BlueZ 6/7] Remove MGMT address type definition Claudio Takahasi
@ 2012-04-25  1:42 ` Claudio Takahasi
  2012-04-25 10:07 ` [PATCH BlueZ 0/7] Add address type to L2CAP socket Johan Hedberg
  7 siblings, 0 replies; 9+ messages in thread
From: Claudio Takahasi @ 2012-04-25  1:42 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andre Guedes

From: Andre Guedes <andre.guedes@openbossa.org>

This patch adds 'V' option to inform the address type. Possible values
are: "bredr", "le_public", and "le_random".
---
 test/l2test.c |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/test/l2test.c b/test/l2test.c
index ae81aec..f66486d 100644
--- a/test/l2test.c
+++ b/test/l2test.c
@@ -117,6 +117,7 @@ static int defer_setup = 0;
 static int priority = -1;
 static int rcvbuf = 0;
 static int chan_policy = -1;
+static int bdaddr_type = 0;
 
 struct lookup_table {
 	char	*name;
@@ -141,6 +142,13 @@ static struct lookup_table chan_policies[] = {
 	{ NULL,		0					},
 };
 
+static struct lookup_table bdaddr_types[] = {
+	{ "bredr",	BDADDR_BREDR		},
+	{ "le_public",	BDADDR_LE_PUBLIC	},
+	{ "le_random",	BDADDR_LE_RANDOM	},
+	{ NULL,		0			},
+};
+
 static int get_lookup_flag(struct lookup_table *table, char *name)
 {
 	int i;
@@ -362,6 +370,7 @@ static int do_connect(char *svr)
 	memset(&addr, 0, sizeof(addr));
 	addr.l2_family = AF_BLUETOOTH;
 	str2ba(svr, &addr.l2_bdaddr);
+	addr.l2_bdaddr_type = bdaddr_type;
 	if (cid)
 		addr.l2_cid = htobs(cid);
 	else if (psm)
@@ -1020,6 +1029,7 @@ static void info_request(char *svr)
 	memset(&addr, 0, sizeof(addr));
 	addr.l2_family = AF_BLUETOOTH;
 	str2ba(svr, &addr.l2_bdaddr);
+	addr.l2_bdaddr_type = bdaddr_type;
 
 	if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0 ) {
 		perror("Can't connect socket");
@@ -1167,6 +1177,7 @@ static void do_pairing(char *svr)
 	memset(&addr, 0, sizeof(addr));
 	addr.l2_family = AF_BLUETOOTH;
 	str2ba(svr, &addr.l2_bdaddr);
+	addr.l2_bdaddr_type = bdaddr_type;
 
 	if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0 ) {
 		perror("Can't connect socket");
@@ -1224,7 +1235,8 @@ static void usage(void)
 		"\t[-E] request encryption\n"
 		"\t[-S] secure connection\n"
 		"\t[-M] become master\n"
-		"\t[-T] enable timestamps\n");
+		"\t[-T] enable timestamps\n"
+		"\t[-V type] address type (help for list, default = bredr)\n");
 }
 
 int main(int argc, char *argv[])
@@ -1235,7 +1247,7 @@ int main(int argc, char *argv[])
 	bacpy(&bdaddr, BDADDR_ANY);
 
 	while ((opt = getopt(argc, argv, "rdscuwmntqxyzpb:a:"
-		"i:P:I:O:J:B:N:L:W:C:D:X:F:Q:Z:Y:H:K:RUGAESMT")) != EOF) {
+		"i:P:I:O:J:B:N:L:W:C:D:X:F:Q:Z:Y:H:K:V:RUGAESMT")) != EOF) {
 		switch (opt) {
 		case 'r':
 			mode = RECV;
@@ -1430,6 +1442,17 @@ int main(int argc, char *argv[])
 			rcvbuf = atoi(optarg);
 			break;
 
+		case 'V':
+			bdaddr_type = get_lookup_flag(bdaddr_types, optarg);
+
+			if (bdaddr_type == -1) {
+				print_lookup_values(bdaddr_types,
+						"List Address types:");
+				exit(1);
+			}
+
+			break;
+
 		default:
 			usage();
 			exit(1);
-- 
1.7.8.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH BlueZ 0/7] Add address type to L2CAP socket
  2012-04-25  1:42 [PATCH BlueZ 0/7] Add address type to L2CAP socket Claudio Takahasi
                   ` (6 preceding siblings ...)
  2012-04-25  1:42 ` [PATCH BlueZ 7/7] l2test: Add option to inform the address type Claudio Takahasi
@ 2012-04-25 10:07 ` Johan Hedberg
  7 siblings, 0 replies; 9+ messages in thread
From: Johan Hedberg @ 2012-04-25 10:07 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: linux-bluetooth

Hi Claudio,

On Tue, Apr 24, 2012, Claudio Takahasi wrote:
> Dependency: "[PATCH 0/8] LE Connection"
> 
> Rebased version of the previous RFC: "[RFC BlueZ v1 1/7] Add Bluetooth
> address type in sockaddr_l2"
> 
> Andre Guedes (1):
>   l2test: Add option to inform the address type
> 
> Claudio Takahasi (6):
>   Add Bluetooth address type in sockaddr_l2
>   btio: Add address type in bt_io_connect
>   Add address type for BLE bt_io_connect calls
>   Remove leftover field in remote_dev_info struct
>   Remove addr_type_t definition from adapter.h
>   Remove MGMT address type definition
> 
>  btio/btio.c       |   21 +++++++++++---
>  btio/btio.h       |    1 +
>  lib/bluetooth.h   |    5 +++
>  lib/l2cap.h       |    1 +
>  lib/mgmt.h        |    5 ---
>  mgmt/main.c       |   26 +++++++++---------
>  plugins/hciops.c  |   51 ++++++++++++++++++----------------
>  plugins/mgmtops.c |   77 +++++++++++++++++-----------------------------------
>  src/adapter.c     |   70 ++++++++++++++++++++++++-----------------------
>  src/adapter.h     |   45 +++++++++++++------------------
>  src/device.c      |   59 +++++++++++++++++++++-------------------
>  src/device.h      |    6 ++--
>  src/event.c       |   29 ++++++++++---------
>  src/event.h       |    6 ++--
>  test/l2test.c     |   27 +++++++++++++++++-
>  15 files changed, 221 insertions(+), 208 deletions(-)

All patches in this set have been applied. Thanks.

Johan

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-04-25 10:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-25  1:42 [PATCH BlueZ 0/7] Add address type to L2CAP socket Claudio Takahasi
2012-04-25  1:42 ` [PATCH BlueZ 1/7] Add Bluetooth address type in sockaddr_l2 Claudio Takahasi
2012-04-25  1:42 ` [PATCH BlueZ 2/7] btio: Add address type in bt_io_connect Claudio Takahasi
2012-04-25  1:42 ` [PATCH BlueZ 3/7] Add address type for BLE bt_io_connect calls Claudio Takahasi
2012-04-25  1:42 ` [PATCH BlueZ 4/7] Remove leftover field in remote_dev_info struct Claudio Takahasi
2012-04-25  1:42 ` [PATCH BlueZ 5/7] Remove addr_type_t definition from adapter.h Claudio Takahasi
2012-04-25  1:42 ` [PATCH BlueZ 6/7] Remove MGMT address type definition Claudio Takahasi
2012-04-25  1:42 ` [PATCH BlueZ 7/7] l2test: Add option to inform the address type Claudio Takahasi
2012-04-25 10:07 ` [PATCH BlueZ 0/7] Add address type to L2CAP socket Johan Hedberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.