Commit 8b553217 authored by Marcel Holtmann's avatar Marcel Holtmann

[Bluetooth] Add dynamic channel allocation for RFCOMM server sockets

If no channel is specified for a RFCOMM server socket, it will search
for the next free one and automaticly bind to it.

Proposed by Stephen Crane <steve.crane@rococosoft.com>
parent f70c2ac2
......@@ -50,7 +50,7 @@
#include <net/bluetooth/l2cap.h>
#include <net/bluetooth/rfcomm.h>
#define VERSION "1.2"
#define VERSION "1.3"
#ifndef CONFIG_BT_RFCOMM_DEBUG
#undef BT_DBG
......
......@@ -398,6 +398,27 @@ int rfcomm_sock_listen(struct socket *sock, int backlog)
goto done;
}
if (!rfcomm_pi(sk)->channel) {
bdaddr_t *src = &bt_sk(sk)->src;
u8 channel;
err = -EINVAL;
write_lock_bh(&rfcomm_sk_list.lock);
for (channel = 1; channel < 31; channel++)
if (!__rfcomm_get_sock_by_addr(channel, src)) {
rfcomm_pi(sk)->channel = channel;
err = 0;
break;
}
write_unlock_bh(&rfcomm_sk_list.lock);
if (err < 0)
goto done;
}
sk->sk_max_ack_backlog = backlog;
sk->sk_ack_backlog = 0;
sk->sk_state = BT_LISTEN;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment