Diff between c15edf746645ce3dca68eb1492088dfe6a737952 and ad17eb4eba127f8bdf3e0082532bb0768584ce3f

Changed Files

File Additions Deletions Status
btio/btio.c +11 -4 modified
btio/btio.h +1 -0 modified

Full Patch

diff --git a/btio/btio.c b/btio/btio.c
index bbf1208..cb8860a 100644
--- a/btio/btio.c
+++ b/btio/btio.c
@@ -64,6 +64,7 @@ struct set_opts {
 	bdaddr_t src;
 	bdaddr_t dst;
 	BtIOType type;
+	uint8_t src_type;
 	uint8_t dst_type;
 	int defer;
 	int sec_level;
@@ -316,8 +317,8 @@ static void accept_add(GIOChannel *io, BtIOConnect connect, gpointer user_data,
 					(GDestroyNotify) accept_remove);
 }
 
-static int l2cap_bind(int sock, const bdaddr_t *src, uint16_t psm,
-						uint16_t cid, GError **err)
+static int l2cap_bind(int sock, const bdaddr_t *src, uint8_t src_type,
+				uint16_t psm, uint16_t cid, GError **err)
 {
 	struct sockaddr_l2 addr;
 
@@ -330,6 +331,8 @@ static int l2cap_bind(int sock, const bdaddr_t *src, uint16_t psm,
 	else
 		addr.l2_psm = htobs(psm);
 
+	addr.l2_bdaddr_type = src_type;
+
 	if (bind(sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
 		int error = -errno;
 		ERROR_FAILED(err, "l2cap_bind", errno);
@@ -760,6 +763,7 @@ static gboolean parse_set_opts(struct set_opts *opts, GError **err,
 	opts->mode = L2CAP_MODE_BASIC;
 	opts->flushable = -1;
 	opts->priority = 0;
+	opts->src_type = BDADDR_BREDR;
 	opts->dst_type = BDADDR_BREDR;
 
 	while (opt != BT_IO_OPT_INVALID) {
@@ -771,6 +775,9 @@ static gboolean parse_set_opts(struct set_opts *opts, GError **err,
 		case BT_IO_OPT_SOURCE_BDADDR:
 			bacpy(&opts->src, va_arg(args, const bdaddr_t *));
 			break;
+		case BT_IO_OPT_SOURCE_TYPE:
+			opts->src_type = va_arg(args, int);
+			break;
 		case BT_IO_OPT_DEST:
 			str2ba(va_arg(args, const char *), &opts->dst);
 			break;
@@ -1342,8 +1349,8 @@ static GIOChannel *create_io(gboolean server, struct set_opts *opts,
 			ERROR_FAILED(err, "socket(SEQPACKET, L2CAP)", errno);
 			return NULL;
 		}
-		if (l2cap_bind(sock, &opts->src, server ? opts->psm : 0,
-							opts->cid, err) < 0)
+		if (l2cap_bind(sock, &opts->src, opts->src_type,
+				server ? opts->psm : 0, opts->cid, err) < 0)
 			goto failed;
 		if (!l2cap_set(sock, opts->sec_level, opts->imtu, opts->omtu,
 				opts->mode, opts->master, opts->flushable,
diff --git a/btio/btio.h b/btio/btio.h
index a6ff5a2..ac1366b 100644
--- a/btio/btio.h
+++ b/btio/btio.h
@@ -34,6 +34,7 @@ typedef enum {
 	BT_IO_OPT_INVALID = 0,
 	BT_IO_OPT_SOURCE,
 	BT_IO_OPT_SOURCE_BDADDR,
+	BT_IO_OPT_SOURCE_TYPE,
 	BT_IO_OPT_DEST,
 	BT_IO_OPT_DEST_BDADDR,
 	BT_IO_OPT_DEST_TYPE,