2012-04-04 20:16:08

by Claudio Takahasi

[permalink] [raw]
Subject: [RFC BlueZ 1/4] Add Bluetooth address type in sockaddr_l2

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/l2cap.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

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



2012-04-05 23:17:17

by Andre Guedes

[permalink] [raw]
Subject: Re: [RFC BlueZ 4/4] l2test: Add option to inform the address type

Hi Andrei,

On Thu, Apr 5, 2012 at 3:35 AM, Andrei Emeltchenko
<[email protected]> wrote:
> Hi Claudio,
>
> On Wed, Apr 04, 2012 at 05:16:11PM -0300, Claudio Takahasi wrote:
> ...
>
>> + ? ? addr.l2_bdaddr_type = bdaddr_type;
>> ? ? ? if (cid)
>
> ...
>
>> @@ -1020,6 +1022,7 @@ static void info_request(char *svr)
>> + ? ? addr.l2_bdaddr_type = bdaddr_type;
>
> ...
>
>> @@ -1167,6 +1170,7 @@ static void do_pairing(char *svr)
>> + ? ? addr.l2_bdaddr_type = bdaddr_type;
>
> ...
>
>> + ? ? ? ? ? ? case 'V':
>> + ? ? ? ? ? ? ? ? ? ? bdaddr_type = atoi(optarg);
>
> Apparently there is no check that value is correct. I think that you can
> use here lookup_table (see l2cap_modes and chan_policies).

Sure, I'll do it.

Thanks,

Andre

2012-04-05 22:38:57

by Claudio Takahasi

[permalink] [raw]
Subject: [RFC BlueZ v1 7/7] l2test: Add option to inform the address type

From: Andre Guedes <[email protected]>

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


2012-04-05 22:38:40

by Claudio Takahasi

[permalink] [raw]
Subject: [RFC BlueZ v1 3/7] Add address type for BLE bt_io_connect calls

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 df3fbac..f9b2fea 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1999,6 +1999,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);
@@ -2084,6 +2085,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);
@@ -2486,7 +2488,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


2012-04-05 22:38:36

by Claudio Takahasi

[permalink] [raw]
Subject: [RFC BlueZ v1 2/7] btio: Add address type in bt_io_connect

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


2012-04-05 22:38:30

by Claudio Takahasi

[permalink] [raw]
Subject: [RFC BlueZ v1 1/7] Add Bluetooth address type in sockaddr_l2

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


2012-04-05 10:30:11

by Johan Hedberg

[permalink] [raw]
Subject: Re: [RFC BlueZ 1/4] Add Bluetooth address type in sockaddr_l2

Hi Claudio,

On Wed, Apr 04, 2012, Claudio Takahasi wrote:
> 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/l2cap.h | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> 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 */

To answer my question about what defines/enum values are passed to the
BtIO API, this patch should probably be adding the same BDADDR_* defines
that Andre's patch 2/5 is adding on the kernel side, and then your BtIO
patch should use BDADDR_BREDR to initialize opts->dst_type.

Johan

2012-04-05 10:28:05

by Johan Hedberg

[permalink] [raw]
Subject: Re: [RFC BlueZ 2/4] btio: Add address type in bt_io_connect

Hi Claudio,

On Wed, Apr 04, 2012, Claudio Takahasi wrote:
> @@ -714,6 +717,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;

I'd prefer that you also add a line to the "Set defaults" section of
this function to initialize opts->dst_type (I know the default is
implicitly 0 but it's good to have it there for clarity). Also, are you
planning to add BT_IO_* defines/enum for the types or what value is the
new BtIO API expecting to receive (this should probably be documented
and you do need to know the answer to the question before adding the
initialization line I requested).

Johan

2012-04-05 06:35:15

by Andrei Emeltchenko

[permalink] [raw]
Subject: Re: [RFC BlueZ 4/4] l2test: Add option to inform the address type

Hi Claudio,

On Wed, Apr 04, 2012 at 05:16:11PM -0300, Claudio Takahasi wrote:
...

> + addr.l2_bdaddr_type = bdaddr_type;
> if (cid)

...

> @@ -1020,6 +1022,7 @@ static void info_request(char *svr)
> + addr.l2_bdaddr_type = bdaddr_type;

...

> @@ -1167,6 +1170,7 @@ static void do_pairing(char *svr)
> + addr.l2_bdaddr_type = bdaddr_type;

...

> + case 'V':
> + bdaddr_type = atoi(optarg);

Apparently there is no check that value is correct. I think that you can
use here lookup_table (see l2cap_modes and chan_policies).

Best regards
Andrei Emeltchenko


2012-04-04 20:16:11

by Claudio Takahasi

[permalink] [raw]
Subject: [RFC BlueZ 4/4] l2test: Add option to inform the address type

From: Andre Guedes <[email protected]>

This patch adds 'V' option to inform the address type. Possible values
are: 0 (BR/EDR), 1 (LE Public), and 2 (LE Random).
---
test/l2test.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/test/l2test.c b/test/l2test.c
index ae81aec..9085d3e 100644
--- a/test/l2test.c
+++ b/test/l2test.c
@@ -87,6 +87,7 @@ static long buffer_size = 2048;

/* Default addr and psm and cid */
static bdaddr_t bdaddr;
+static unsigned char bdaddr_type;
static unsigned short psm = 0x1011;
static unsigned short cid = 0;

@@ -362,6 +363,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 +1022,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 +1170,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 +1228,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] Set address type: 0 (BR/EDR), 1 (LE Public), 2 (LE Random)\n");
}

int main(int argc, char *argv[])
@@ -1235,7 +1240,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 +1435,10 @@ int main(int argc, char *argv[])
rcvbuf = atoi(optarg);
break;

+ case 'V':
+ bdaddr_type = atoi(optarg);
+ break;
+
default:
usage();
exit(1);
--
1.7.8.5


2012-04-04 20:16:10

by Claudio Takahasi

[permalink] [raw]
Subject: [RFC BlueZ 3/4] Add address type for BLE bt_io_connect calls

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 df3fbac..f9b2fea 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1999,6 +1999,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);
@@ -2084,6 +2085,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);
@@ -2486,7 +2488,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


2012-04-04 20:16:09

by Claudio Takahasi

[permalink] [raw]
Subject: [RFC BlueZ 2/4] btio: Add address type in bt_io_connect

This patch adds a new BtIO option to allow setting the remote Bluetooth
address type for BLE connections.
---
btio/btio.c | 20 ++++++++++++++++----
btio/btio.h | 1 +
2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/btio/btio.c b/btio/btio.c
index 9781ec4..d553da8 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;
@@ -714,6 +717,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 +881,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 +1376,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