Linux bluetooth development
 help / color / mirror / Atom feed
From: Stephen Crane <steve.crane@rococosoft.com>
To: Marcel Holtmann <marcel@rvs.uni-bielefeld.de>
Cc: Alexandros Karypidis <karypid@inf.uth.gr>,
	BlueZ Mailing List <bluez-users@lists.sourceforge.net>
Subject: Re: [Bluez-users] How do I obtain a free PSM automatically?
Date: 08 Feb 2003 11:42:24 +0000	[thread overview]
Message-ID: <1044704544.2164.1436.camel@baroque.rococosoft.com> (raw)
In-Reply-To: <1044653120.32671.4.camel@pegasus.local>

On Fri, 2003-02-07 at 21:25, Marcel Holtmann wrote:
> Hi Alexandros,
> 
> > I was assuming that the setting the psm field to zero would get you a 
> > dynamically assigned free PSM on the local host:
> > 
> >   addr.l2_family = AF_BLUETOOTH;
> >   bacpy(&addr.l2_bdaddr, BDADDR_ANY);  
> >   addr.l2_psm = htobs(0);
> > 
> > Calling bind() for this address succeeds.
> > Calling listen() afterwards fails and perror() gives: "Invalid argument"
> 
> you can't listen on PSM 0, because such PSM did not exists. You have to
> choose one.

It would be nice if it had the expected semantics (i.e., those of IP sockets).
I think this is a bug.

In the meantime, here is some code:

   for (;;) {
      while (psm++ < 0xffff)
         if ((psm & 0x0001) && !(psm & 0x0100))
            break;
      if (psm == 0x10000) {
         // no resources
         close(s);
         return -EBUSY;
      }
      addr.l2_psm = htobs(psm);
      if (0 == bind(s, (struct sockaddr *)&addr, sizeof(addr)))
         break;
      if (errno != EADDRINUSE) {
         int e = -errno;
         close(s);
	 return e;
      }
   }

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

       reply	other threads:[~2003-02-08 11:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200302071951.35073.karypid@inf.uth.gr>
     [not found] ` <1044653120.32671.4.camel@pegasus.local>
2003-02-08 11:42   ` Stephen Crane [this message]
     [not found] ` <200302072329.21333.karypid@inf.uth.gr>
     [not found]   ` <1044653775.32672.14.camel@pegasus.local>
2003-02-08 15:40     ` [Bluez-users] How do I obtain a free PSM automatically? Alexandros Karypidis
2003-02-08 16:14       ` [Bluez-devel] " Alexandros Karypidis
2003-02-10 21:13         ` Max Krasnyansky
2003-02-11 12:01           ` Marcel Holtmann
2003-02-11 17:26             ` Alexandros Karypidis
2003-02-11 17:52               ` Maksim Yevmenkin
2003-02-11 18:58               ` Max Krasnyansky
2003-02-11 18:06             ` Max Krasnyansky
2003-02-17 14:12               ` Marcel Holtmann
2003-02-18 21:06                 ` Max Krasnyansky
2003-02-18 23:00                   ` Marcel Holtmann
2003-02-19 20:04                     ` Max Krasnyansky
2003-02-11 16:30           ` Alexandros Karypidis
2003-02-10 20:49       ` Max Krasnyansky
2003-02-11 16:22         ` Alexandros Karypidis
2003-02-11 18:04           ` [Bluez-devel] " Maksim Yevmenkin
2003-02-11 18:52             ` Max Krasnyansky
2003-02-11 20:01               ` Maksim Yevmenkin
2003-02-11 21:09                 ` Max Krasnyansky
2003-02-11 18:23           ` [Bluez-devel] Re: [Bluez-users] " Max Krasnyansky

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=1044704544.2164.1436.camel@baroque.rococosoft.com \
    --to=steve.crane@rococosoft.com \
    --cc=bluez-users@lists.sourceforge.net \
    --cc=karypid@inf.uth.gr \
    --cc=marcel@rvs.uni-bielefeld.de \
    /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