public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Crane <steve.crane@rococosoft.com>
To: bluez-devel@lists.sourceforge.net
Cc: marcel@holtmann.org
Subject: RFComm dynamic channel allocation
Date: Fri, 21 May 2004 12:17:17 +0100	[thread overview]
Message-ID: <1085138236.2777.10.camel@baroque.rococosoft.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 496 bytes --]

Hi,
The attached patch (against 2.6.6) provides dynamic channel allocation
for RFComm listening sockets. This means that you can bind to channel #0
and the kernel will allocate a channel for you when you call listen() on
it. Retrieve the allocated channel number via getsockname().

The only query I have is what to return if there are no free channels.
Is ENOMEM right?

Steve
-- 
Stephen Crane, Rococo Software Ltd. http://www.rococosoft.com
steve.crane@rococosoft.com +353-1-6601315 (ext 209)

[-- Attachment #2: rfcomm.dynamic.patch --]
[-- Type: text/x-patch, Size: 564 bytes --]

--- net/bluetooth/rfcomm/sock.c-	2004-05-21 11:49:58.375676516 +0100
+++ net/bluetooth/rfcomm/sock.c	2004-05-21 12:00:33.374126744 +0100
@@ -397,6 +397,19 @@
 		err = -EBADFD;
 		goto done;
 	}
+	if (!rfcomm_pi(sk)->channel) {
+		u8 channel;
+		bdaddr_t *src = &bt_sk(sk)->src;
+		for (channel = 1; channel < 31; channel++)
+			if (!__rfcomm_get_sock_by_addr(channel, src)) {
+				rfcomm_pi(sk)->channel = channel;
+				break;
+			}
+		if (channel == 31) {
+			err = -ENOMEM;
+			goto done;
+		}
+	}
 
 	sk->sk_max_ack_backlog = backlog;
 	sk->sk_ack_backlog = 0;

             reply	other threads:[~2004-05-21 11:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-21 11:17 Stephen Crane [this message]
2004-07-08 13:02 ` [Bluez-devel] RFComm dynamic channel allocation Collin R. Mulliner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1085138236.2777.10.camel@baroque.rococosoft.com \
    --to=steve.crane@rococosoft.com \
    --cc=bluez-devel@lists.sourceforge.net \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox