summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/device.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/device.c b/src/device.c
index 9c089eee..0ae81a02 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1685,10 +1685,9 @@ static void create_bond_req_exit(DBusConnection *conn, void *user_data)
static int l2raw_connect(const bdaddr_t *src, const bdaddr_t *dst,
gboolean *auth_required)
{
- struct bt_security sec;
struct sockaddr_l2 addr;
long arg;
- int sk, err;
+ int sk, err, opt;
sk = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_L2CAP);
if (sk < 0) {
@@ -1705,12 +1704,13 @@ static int l2raw_connect(const bdaddr_t *src, const bdaddr_t *dst,
goto failed;
}
- memset(&sec, 0, sizeof(sec));
- sec.level = BT_SECURITY_MEDIUM;
+ opt = L2CAP_LM_AUTH | L2CAP_LM_ENCRYPT;
- err = setsockopt(sk, SOL_BLUETOOTH, BT_SECURITY, &sec, sizeof(sec));
- if (auth_required)
- *auth_required = err < 0 ? TRUE : FALSE;
+ err = setsockopt(sk, SOL_L2CAP, L2CAP_LM, &opt, sizeof(opt));
+ if (err < 0) {
+ error("setsockopt: %s (%d)", strerror(errno), errno);
+ goto failed;
+ }
arg = fcntl(sk, F_GETFL);
if (arg < 0) {
@@ -1735,6 +1735,9 @@ static int l2raw_connect(const bdaddr_t *src, const bdaddr_t *dst,
goto failed;
}
+ if (auth_required)
+ *auth_required = TRUE;
+
return sk;
failed: