Diff between 4ba06534140e04c134154cc2682f2a1ec4d0d007 and 0573fc7cb121fdb771908551d2051ef7ec031478

Changed Files

File Additions Deletions Status
doc/mgmt-api.txt +7 -0 modified
lib/mgmt.h +2 -2 modified
mgmt/main.c +10 -5 modified
plugins/mgmtops.c +4 -3 modified

Full Patch

diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
index 7dfae60..6c2e441 100644
--- a/doc/mgmt-api.txt
+++ b/doc/mgmt-api.txt
@@ -259,10 +259,17 @@ Pair Device Command
 	Command Code:		0x0014
 	Controller Index:	<controller id>
 	Command Parameters:	Address (6 Octets)
+				Address_Type (1 Octet)
 				IO_Capability (1 Octet)
 	Return Parameters:	Address (6 Octets)
+				Address_Type (1 Octet)
 				Status (1 Octet)
 
+	Possible values for the Address_Type parameter:
+		0	BR/EDR
+		1	LE Public
+		2	LE Random
+
 
 User Confirmation Reply Command
 ===============================
diff --git a/lib/mgmt.h b/lib/mgmt.h
index 9eb6d2d..3960815 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -178,11 +178,11 @@ struct mgmt_cp_set_io_capability {
 
 #define MGMT_OP_PAIR_DEVICE		0x0014
 struct mgmt_cp_pair_device {
-	bdaddr_t bdaddr;
+	struct mgmt_addr_info addr;
 	uint8_t io_cap;
 } __packed;
 struct mgmt_rp_pair_device {
-	bdaddr_t bdaddr;
+	struct mgmt_addr_info addr;
 	uint8_t status;
 } __packed;
 
diff --git a/mgmt/main.c b/mgmt/main.c
index e9b0ee1..573cfb3 100644
--- a/mgmt/main.c
+++ b/mgmt/main.c
@@ -1166,7 +1166,7 @@ static void pair_rsp(int mgmt_sk, uint16_t op, uint16_t id, uint8_t status,
 		exit(EXIT_FAILURE);
 	}
 
-	ba2str(&rp->bdaddr, addr);
+	ba2str(&rp->addr.bdaddr, addr);
 
 	if (rp->status != 0) {
 		fprintf(stderr, "Pairing with %s failed with status %u\n",
@@ -1181,12 +1181,13 @@ static void pair_rsp(int mgmt_sk, uint16_t op, uint16_t id, uint8_t status,
 
 static void pair_usage(void)
 {
-	printf("Usage: btmgmt pair [-c cap] <remote address>\n");
+	printf("Usage: btmgmt pair [-c cap] [-t type] <remote address>\n");
 }
 
 static struct option pair_options[] = {
 	{ "help",	0, 0, 'h' },
 	{ "capability",	1, 0, 'c' },
+	{ "type",	1, 0, 't' },
 	{ 0, 0, 0, 0 }
 };
 
@@ -1194,15 +1195,18 @@ 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;
 	int opt;
 
-	while ((opt = getopt_long(argc, argv, "+c:h", pair_options,
+	while ((opt = getopt_long(argc, argv, "+c:t:h", pair_options,
 								NULL)) != -1) {
 		switch (opt) {
 		case 'c':
 			cap = strtol(optarg, NULL, 0);
 			break;
-
+		case 't':
+			type = strtol(optarg, NULL, 0);
+			break;
 		case 'h':
 		default:
 			pair_usage();
@@ -1223,7 +1227,8 @@ static void cmd_pair(int mgmt_sk, uint16_t index, int argc, char **argv)
 		index = 0;
 
 	memset(&cp, 0, sizeof(cp));
-	str2ba(argv[0], &cp.bdaddr);
+	str2ba(argv[0], &cp.addr.bdaddr);
+	cp.addr.type = type;
 	cp.io_cap = cap;
 
 	if (mgmt_send_cmd(mgmt_sk, MGMT_OP_PAIR_DEVICE, index, &cp, sizeof(cp),
diff --git a/plugins/mgmtops.c b/plugins/mgmtops.c
index 160bbd4..b9e9ad6 100644
--- a/plugins/mgmtops.c
+++ b/plugins/mgmtops.c
@@ -1010,7 +1010,7 @@ static void pair_device_complete(int sk, uint16_t index, void *buf, size_t len)
 		return;
 	}
 
-	ba2str(&rp->bdaddr, addr);
+	ba2str(&rp->addr.bdaddr, addr);
 
 	DBG("hci%d %s pairing complete status %u", index, addr, rp->status);
 
@@ -1021,7 +1021,8 @@ static void pair_device_complete(int sk, uint16_t index, void *buf, size_t len)
 
 	info = &controllers[index];
 
-	btd_event_bonding_complete(&info->bdaddr, &rp->bdaddr, rp->status);
+	btd_event_bonding_complete(&info->bdaddr, &rp->addr.bdaddr,
+								rp->status);
 }
 
 static void get_connections_complete(int sk, uint16_t index, void *buf,
@@ -2045,7 +2046,7 @@ static int mgmt_create_bonding(int index, bdaddr_t *bdaddr, uint8_t io_cap)
 	hdr->len = htobs(sizeof(*cp));
 	hdr->index = htobs(index);
 
-	bacpy(&cp->bdaddr, bdaddr);
+	bacpy(&cp->addr.bdaddr, bdaddr);
 	cp->io_cap = io_cap;
 
 	if (write(mgmt_sock, &buf, sizeof(buf)) < 0)