2004-05-11 14:27:38

by Julien Campana

[permalink] [raw]
Subject: [Bluez-devel] Error while setting RFCOMM security options

Hi!

I'm trying to connect to a device over RFCOMM using the flags
"authenticate", "encryption" and "master". Part of the code is:=20

/******************************************/
if ((fd =3D socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)) < 0)
return fd;

memset(&local_addr, 0, sizeof(local_addr));
local_addr.rc_family =3D AF_BLUETOOTH;
bacpy(&local_addr.rc_bdaddr, BDADDR_ANY);
if ((err =3D bind(fd, (struct sockaddr *)&local_addr, sizeof(local_addr)))
< 0) {
close(fd);
return err;
}

int opt =3D 0;
if (master) opt |=3D L2CAP_LM_MASTER;
if (auth) opt |=3D L2CAP_LM_AUTH;
if (encrypt) opt |=3D L2CAP_LM_ENCRYPT;



if (setsockopt(fd, SOL_RFCOMM, L2CAP_LM, &opt, sizeof(opt)) < 0) {
printf("WARNING can't set link Mode (reason: %s)\n\n",
strerror(errno));
}
/*******************************************/

This programm outputs the following message:=20
WARNING can't set link Mode (reason: Protocol not available)

Why? The L2CAP protocol is available as well as the RFCOMM protocol on
my machine (l2ping actually works and my program exchanges data over
RFCOMM without any problem).

Am I wrong in the way of setting these security flags?

Thank you for your answers.

Julien Campana





-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver
higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel


2004-05-12 13:25:22

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-devel] Error while setting RFCOMM security options

Hi Julien,

> This programm outputs the following message:
> WARNING can't set link Mode (reason: Protocol not available)
>
> Why? The L2CAP protocol is available as well as the RFCOMM protocol on
> my machine (l2ping actually works and my program exchanges data over
> RFCOMM without any problem).
>
> Am I wrong in the way of setting these security flags?

why do you think that you can set L2CAP options on a RFCOMM socket ;)

Regards

Marcel




-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver
higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2004-05-11 14:35:30

by Stephen Crane

[permalink] [raw]
Subject: Re: [Bluez-devel] Error while setting RFCOMM security options

BlueZ doesn't support these socket options for RFComm yet.

On Tue, 2004-05-11 at 15:27, Julien Campana wrote:
> Hi!
>
> I'm trying to connect to a device over RFCOMM using the flags
> "authenticate", "encryption" and "master". Part of the code is:
>
> /******************************************/
> if ((fd = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)) < 0)
> return fd;
>
> memset(&local_addr, 0, sizeof(local_addr));
> local_addr.rc_family = AF_BLUETOOTH;
> bacpy(&local_addr.rc_bdaddr, BDADDR_ANY);
> if ((err = bind(fd, (struct sockaddr *)&local_addr, sizeof(local_addr)))
> < 0) {
> close(fd);
> return err;
> }
>
> int opt = 0;
> if (master) opt |= L2CAP_LM_MASTER;
> if (auth) opt |= L2CAP_LM_AUTH;
> if (encrypt) opt |= L2CAP_LM_ENCRYPT;
>
>
>
> if (setsockopt(fd, SOL_RFCOMM, L2CAP_LM, &opt, sizeof(opt)) < 0) {
> printf("WARNING can't set link Mode (reason: %s)\n\n",
> strerror(errno));
> }
> /*******************************************/
>
> This programm outputs the following message:
> WARNING can't set link Mode (reason: Protocol not available)
>
> Why? The L2CAP protocol is available as well as the RFCOMM protocol on
> my machine (l2ping actually works and my program exchanges data over
> RFCOMM without any problem).
>
> Am I wrong in the way of setting these security flags?
>
> Thank you for your answers.
>
> Julien Campana
>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by Sleepycat Software
> Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver
> higher performing products faster, at low TCO.
> http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
> _______________________________________________
> Bluez-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/bluez-devel
--
Stephen Crane, Rococo Software Ltd. http://www.rococosoft.com
[email protected] +353-1-6601315 (ext 209)



-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver
higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel