Skip to contentSkip to conversation

ioctl: setting link mode and link policy

Bluez-devel Marco Pracucci 3 participants 6 messages Aug 31, 2006 Bluetooth drivers

lore
Share & tools
lore
#1 lore raw
In reply to Marco Pracucci

Hi Marco,

depending on which level you want to set the linkmode use setsockopt() for your connection. E.g. for rfcomm use something like :

// set security options for this service

if(authenticate) {
	linkmode |= RFCOMM_LM_AUTH ;
	if(encrypted) linkmode |= RFCOMM_LM_ENCRYPT ;
}
if (linkmode && setsockopt(sfd, SOL_RFCOMM, RFCOMM_LM, &linkmode, sizeof(linkmode)) < 0) {
	close(sfd); sfd = 0 ; 
	return -1;
}

Ciao,

Peter

Quoted 43 lines · Marco Pracucci

Hi list,

I have some problem when I try to set link mode and link policy using ioctl() system call. In particular, when I set link policy or link mode, it seems that nothing happens.

-----------------
int deviceDescriptor;
struct hci_dev_req request;

// Open device
deviceDescriptor = hci_open_dev(deviceID);
[...]

// Set link mode
memset(&request, 0, sizeof(request));
request.dev_id = deviceID;
request.dev_opt = HCI_LM_MASTER; ioctl(deviceDescriptor, HCISETLINKMODE, (unsigned long) &request); [...]

// Set link policy
memset(&request, 0, sizeof(request));
request.dev_id = deviceID;
request.dev_opt = policy;
ioctl(deviceDescriptor, HCISETLINKPOL, (unsigned long) &request); [...]
-----------------

ioctl() system calls do not return any error, but when I check the link mode and link policy with "hciconfig -a" nothing has changed. Moreover, I have tried to debug it with "hcidump -V" but no related hci commands are reported.

Bluez-libs: 2.25
Bluez-utils: 2.25

Have you any idea and/or suggestion?

Thanks,
Marco Pracucci

Quoted 10 lines

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

|       Peter Wippich                   Voice: +49 30 46776411          |
|       G&W Instruments GmbH            fax:   +49 30 46776419          |
|       Gustav-Meyer-Allee 25, Geb. 12  Email: [email protected]   |
|       D-13355 Berlin  / Germany                                       |

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#0 lore raw

Hi list,

I have some problem when I try to set link mode and link policy using ioctl() system call. In particular, when I set link policy or link mode, it seems that nothing happens.

-----------------
int deviceDescriptor;
struct hci_dev_req request;

// Open device
deviceDescriptor = hci_open_dev(deviceID);
[...]

// Set link mode
memset(&request, 0, sizeof(request));
request.dev_id = deviceID;
request.dev_opt = HCI_LM_MASTER; ioctl(deviceDescriptor, HCISETLINKMODE, (unsigned long) &request); [...]

// Set link policy
memset(&request, 0, sizeof(request));
request.dev_id = deviceID;
request.dev_opt = policy;
ioctl(deviceDescriptor, HCISETLINKPOL, (unsigned long) &request); [...]
-----------------

ioctl() system calls do not return any error, but when I check the link mode and link policy with "hciconfig -a" nothing has changed. Moreover, I have tried to debug it with "hcidump -V" but no related hci commands are reported.

Bluez-libs: 2.25
Bluez-utils: 2.25

Have you any idea and/or suggestion?

Thanks,
Marco Pracucci

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#2 lore raw
In reply to Peter Wippich

Hi Peter,

I would like to set a "global" link mode and link policy that will be the default for every connection. Something similar to hcid.

Marco

Quoted 11 lines

Hi Marco,

depending on which level you want to set the linkmode use setsockopt() for your connection. E.g. for rfcomm use something like :

// set security options for this service

if(authenticate) {
	linkmode |= RFCOMM_LM_AUTH ;
	if(encrypted) linkmode |= RFCOMM_LM_ENCRYPT ;
}
Quoted 9 lines
if (linkmode && setsockopt(sfd, SOL_RFCOMM, RFCOMM_LM, &linkmode, sizeof(linkmode)) < 0) {
	close(sfd); sfd = 0 ; 
	return -1;
}

Ciao,

Peter

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#3 lore raw

Hi Marco,

Quoted 2 lines

I would like to set a "global" link mode and link policy that will be the default for every connection. Something similar to hcid.

what do you expect from doing this? It is not a good idea to change it globally except you know exactly what you are doing. Changes these settings can have implications you might not be aware of. So what is your purpose on changing them?

Regards

Marcel

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#4 lore raw

Hi Marcel,

Quoted 8 lines
Quoted 3 lines

I would like to set a "global" link mode and link policy that will be the default for every connection. Something similar to hcid.

what do you expect from doing this? It is not a good idea to change it globally except you know exactly what you are doing. Changes these settings can have implications you might not be aware of. So what is your purpose on changing them?

I would become master on incoming connections and I would deny role switch on outgoing connections. If I'm not wrong, I should set MASTER as link mode and disable role switch from link policy. However, I can't use hcid, so I would do this from a custom application.
Is it possible?

Thanks,
Marco

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#5 lore raw

Hi Marco,

Quoted 11 lines
Quoted 8 lines
Quoted 3 lines

I would like to set a "global" link mode and link policy that will be the default for every connection. Something similar to hcid.

what do you expect from doing this? It is not a good idea to change it globally except you know exactly what you are doing. Changes these settings can have implications you might not be aware of. So what is your purpose on changing them?

I would become master on incoming connections and I would deny role switch on outgoing connections. If I'm not wrong, I should set MASTER as link mode and disable role switch from link policy.

this can't work. You must allow role switching. The initiator of a piconet is always the master in the first place. They have to switch the role to make the acceptor the master. So don't touch the link policy, it must allow the role switch. Setting the link mode to MASTER will request an immediate role switch after connection creation. However if both sides have the MASTER link mode set, you will never get a connection, because the initiator will refuse the switch the role.

Quoted 3 lines

However, I can't use
hcid, so I would do this from a custom application. Is it possible?

It is not wise at all to work without hcid. And you know that your custom application must be placed under GPL.

Regards

Marcel

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel