Skip to contentSkip to conversation

autopair: add autopair plugin

RFC PATCH Superseded Scott James Remnant 4 participants 11 messages Jan 24, 2012 – Feb 15, 2012

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH v2 1/1 autopair: add autopair plugin

This plugin handles automatically generating PIN codes for certain device types following rules specified in an XML file derived from that used by the GNOME Bluetooth wizard.

The plugin deliberately ignores unknown elements and attributes so that this file can be extended by the UI, for example adding hints that pairing shouldn't be attempted for certain devices (e.g. mice) or other special pairing considerations.

Should autopairing fail for a device, it is blacklisted and will be retried using the agent as usual. These blacklist files can be harvested by distributions in order to further improve the database.

---
 Makefile.am                   |    9 +
 acinclude.m4                  |    6 +
 plugins/autopair.c            |  363 +++++++++++++++++++++++++++++++++++++++++
 plugins/pin-code-database.xml |  174 ++++++++++++++++++++
 4 files changed, 552 insertions(+), 0 deletions(-)
 create mode 100644 plugins/autopair.c
 create mode 100644 plugins/pin-code-database.xml
Makefile.am +9 -0
index 102ee62..798f3ec 100644
@@ -278,6 +278,15 @@ builtin_modules += dbusoob
 builtin_sources += plugins/dbusoob.c
 endif
 
+if AUTOPAIRPLUGIN
+builtin_modules += autopair
+builtin_sources += plugins/autopair.c
+
+if DATAFILES
+conf_DATA += plugins/pin-code-database.xml
+endif
+endif
+
 if MAINTAINER_MODE
 plugin_LTLIBRARIES += plugins/external-dummy.la
 plugins_external_dummy_la_SOURCES = plugins/external-dummy.c
acinclude.m4 +6 -0
index 57fc5e0..187a049 100644
@@ -218,6 +218,7 @@ AC_DEFUN([AC_ARG_BLUEZ], [
 	dbusoob_enable=no
 	wiimote_enable=no
 	thermometer_enable=no
+	autopair_enable=no
 
 	AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization], [disable code optimization]), [
 		optimization_enable=${enableval}
@@ -374,6 +375,10 @@ AC_DEFUN([AC_ARG_BLUEZ], [
 		thermometer_enable=${enableval}
 	])
 
+	AC_ARG_ENABLE(autopair, AC_HELP_STRING([--enable-autopair], [enable auto-pairplugin]), [
+		autopair_enable=${enableval}
+	])
+
 	if (test "${fortify_enable}" = "yes"); then
 		CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
 	fi
@@ -432,4 +437,5 @@ AC_DEFUN([AC_ARG_BLUEZ], [
 	AM_CONDITIONAL(DBUSOOBPLUGIN, test "${dbusoob_enable}" = "yes")
 	AM_CONDITIONAL(WIIMOTEPLUGIN, test "${wiimote_enable}" = "yes")
 	AM_CONDITIONAL(THERMOMETERPLUGIN, test "${thermometer_enable}" = "yes")
+	AM_CONDITIONAL(AUTOPAIRPLUGIN, test "${autopair_enable}" = "yes")
 ])
plugins/autopair.c new file +363 -0

363 lines not on this page · raw message

plugins/pin-code-database.xml new file +174 -0

174 lines not on this page · raw message

Signature · 1 line
1.7.7.3
maintainer
#1 lore raw

Hi Scott,

Quoted 20 lines

This plugin handles automatically generating PIN codes for certain device types following rules specified in an XML file derived from that used by the GNOME Bluetooth wizard.

The plugin deliberately ignores unknown elements and attributes so that this file can be extended by the UI, for example adding hints that pairing shouldn't be attempted for certain devices (e.g. mice) or other special pairing considerations.

Should autopairing fail for a device, it is blacklisted and will be retried using the agent as usual. These blacklist files can be harvested by distributions in order to further improve the database.

---
 Makefile.am                   |    9 +
 acinclude.m4                  |    6 +
 plugins/autopair.c            |  363 +++++++++++++++++++++++++++++++++++++++++
 plugins/pin-code-database.xml |  174 ++++++++++++++++++++
 4 files changed, 552 insertions(+), 0 deletions(-)
 create mode 100644 plugins/autopair.c
 create mode 100644 plugins/pin-code-database.xml

<snip>

Quoted 6 lines

+<!--

plugins/pin-code-database.xml new file +5 -0
+  The autopair plugin will match devices, following the order of the XML
+  file [1], on any combination of type, OUI, or name.
+
+  [1]: So specific devices should be at the top, and generic ones at the bottom,
+  so settings for specific devices are overridden as expected.

plugins/pin-code-database.xml line 38

Quoted 10 lines
plugins/pin-code-database.xml new file +10 -0
+-->
+
+<!DOCTYPE devices [
+	<!ELEMENT devices (device)+>
+	<!ELEMENT device EMPTY>
+	<!ATTLIST device type (any|mouse|tablet|keyboard|headset|headphones|audio|printer|network) "any">
+	<!ATTLIST device oui CDATA #IMPLIED>
+	<!ATTLIST device name CDATA #IMPLIED>
+	<!ATTLIST device pin CDATA #REQUIRED>
+]>

I think we need to have a discussion on this database format first. I honestly do not like it at all. It does matching and result handling in a single XML element. That seems like a bad idea.

And in addition making pin attribute required and then trying to disable PIN with "NULL" magic is something that I rather not have.

I am also wondering why this has to be XML and not simple key-value INI style files.

Regards

Marcel

#2 lore raw
Quoted 46 lines · Marcel Holtmann

Hi Scott,

Quoted 20 lines

This plugin handles automatically generating PIN codes for certain device types following rules specified in an XML file derived from that used by the GNOME Bluetooth wizard.

The plugin deliberately ignores unknown elements and attributes so that this file can be extended by the UI, for example adding hints that pairing shouldn't be attempted for certain devices (e.g. mice) or other special pairing considerations.

Should autopairing fail for a device, it is blacklisted and will be retried using the agent as usual. These blacklist files can be harvested by distributions in order to further improve the database.

---
 Makefile.am                   |    9 +
 acinclude.m4                  |    6 +
 plugins/autopair.c            |  363 +++++++++++++++++++++++++++++++++++++++++
 plugins/pin-code-database.xml |  174 ++++++++++++++++++++
 4 files changed, 552 insertions(+), 0 deletions(-)
 create mode 100644 plugins/autopair.c
 create mode 100644 plugins/pin-code-database.xml

<snip>

Quoted 6 lines

+<!--

plugins/pin-code-database.xml new file +5 -0
+  The autopair plugin will match devices, following the order of the XML
+  file [1], on any combination of type, OUI, or name.
+
+  [1]: So specific devices should be at the top, and generic ones at the bottom,
+  so settings for specific devices are overridden as expected.

plugins/pin-code-database.xml line 38

Quoted 10 lines
plugins/pin-code-database.xml new file +10 -0
+-->
+
+<!DOCTYPE devices [
+	<!ELEMENT devices (device)+>
+	<!ELEMENT device EMPTY>
+	<!ATTLIST device type (any|mouse|tablet|keyboard|headset|headphones|audio|printer|network) "any">
+	<!ATTLIST device oui CDATA #IMPLIED>
+	<!ATTLIST device name CDATA #IMPLIED>
+	<!ATTLIST device pin CDATA #REQUIRED>
+]>

I think we need to have a discussion on this database format first. I honestly do not like it at all. It does matching and result handling in a single XML element. That seems like a bad idea.

Quoted 5 lines

And in addition making pin attribute required and then trying to disable PIN with "NULL" magic is something that I rather not have.

I am also wondering why this has to be XML and not simple key-value INI style files.

Mostly because:
- it already exists
- it can be validated without writing another tool

I'm fine if you want to change the parsing code, but removing the use of XML seems like a not very useful requirement to me.

As for the patch itself, we will still need from the wizard to check for those NULL hints (CreateDevice vs. CreatePairedDevice), or presentation hints (ICADE and keyboard for example), so the file itself needs to be made available to the front-ends (and its location exported).

For the NULL hints, I would like to see something like CreatePairedDevice() but that would get whether to pair or not from the database.

The PIN length hint is also ignored in the current code:
+ <device type="audio" oui="00:1A:80:" name="CMT-DH5BT" pin="max:4"/>

Cheers

#3 lore raw
Quoted 5 lines · Bastien Nocera

As for the patch itself, we will still need from the wizard to check for those NULL hints (CreateDevice vs. CreatePairedDevice), or presentation hints (ICADE and keyboard for example), so the file itself needs to be made available to the front-ends (and its location exported).

Actually after a few minutes thought, I wondered whether we could handle this by exporting a D-Bus interface from the autopair plugin (like dbus-oob) so you could simply query whether or not a device has presentation hints/needs encryption hints.

Quoted 4 lines

For the NULL hints, I would like to see something like CreatePairedDevice() but that would get whether to pair or not from the database.

This is another good solution, a plugin callback from here could verify whether or not to pair, etc.

Quoted 2 lines

The PIN length hint is also ignored in the current code:
+ =A0 =A0 =A0 <device type=3D"audio" oui=3D"00:1A:80:" name=3D"CMT-DH5BT"=

pin=3D"max:4"/>

Quoted 1 line

Because that's a UI restriction, no?

I didn't put any PIN-generation code here, because I'm not entirely sure what the UI for "generate random PIN' should look like or which spec you're following.

Scott
--=20
Have you ever, ever felt like this?
Had strange things happen? =A0Are you going round the twist?

#4 lore raw

Em Mon, 2012-01-30 =C3=A0s 13:42 -0800, Scott James Remnant escreveu:

Quoted 9 lines
Quoted 2 lines

The PIN length hint is also ignored in the current code:
+ <device type=3D"audio" oui=3D"00:1A:80:" name=3D"CMT-DH5BT"

pin=3D"max:4"/>

Quoted 1 line

Because that's a UI restriction, no?
=20
I didn't put any PIN-generation code here, because I'm not entirely sure what the UI for "generate random PIN' should look like or which spec you're following.=20

It means that a generated PIN shouldn't have more than 4 digits for it to work with this device.

#5 lore raw
Quoted 3 lines · Bastien Nocera

Em Mon, 2012-01-30 =E0s 13:42 -0800, Scott James Remnant escreveu:

Quoted 2 lines
Quoted 2 lines

The PIN length hint is also ignored in the current code:
+ =A0 =A0 =A0 <device type=3D"audio" oui=3D"00:1A:80:" name=3D"CMT-DH5=

BT"

Quoted 11 lines
Quoted 7 lines

pin=3D"max:4"/>

Quoted 1 line

Because that's a UI restriction, no?

I didn't put any PIN-generation code here, because I'm not entirely sure what the UI for "generate random PIN' should look like or which spec you're following.

It means that a generated PIN shouldn't have more than 4 digits for it to work with this device.

What generated PIN? Which spec/profile says you have to generate a PIN for this device?

How does the user know what PIN has been generated?

Do you display the PIN in the UI in any way?

Are they expected to confirm the PIN with a remote display?

Are they expected to type the PIN into the remote device? Or even the host, perhaps it's displayed there?

Or do these devices simply just accept any PIN without question? In which case, why does it matter whether you send a random PIN or 0000?

Scott
--=20
Have you ever, ever felt like this?
Had strange things happen? =A0Are you going round the twist?

#6 lore raw

Em Mon, 2012-01-30 =C3=A0s 14:35 -0800, Scott James Remnant escreveu:

Quoted 1 line

On Mon, Jan 30, 2012 at 2:33 PM, Bastien Nocera <[email protected]> wro=

te:

Quoted 3 lines
Quoted 3 lines

Em Mon, 2012-01-30 =C3=A0s 13:42 -0800, Scott James Remnant escreveu:

Quoted 2 lines
Quoted 2 lines

The PIN length hint is also ignored in the current code:
+ <device type=3D"audio" oui=3D"00:1A:80:" name=3D"CMT-DH5BT=

"

Quoted 9 lines
Quoted 9 lines
Quoted 7 lines

pin=3D"max:4"/>

Quoted 1 line

Because that's a UI restriction, no?

I didn't put any PIN-generation code here, because I'm not entirely sure what the UI for "generate random PIN' should look like or which spec you're following.

It means that a generated PIN shouldn't have more than 4 digits for i=

t

Quoted 4 lines
Quoted 2 lines

to work with this device.

What generated PIN? Which spec/profile says you have to generate a PIN for this device?

It's recommended that the UIs try to generate PINs for the users, rather than relying on them entering random numbers.

Quoted 1 line

How does the user know what PIN has been generated?

You will display it to them.

Quoted 1 line

Do you display the PIN in the UI in any way?

Yep, in the UI, because that's the PIN you will have to enter on the devi= ce.

Quoted 1 line

Are they expected to confirm the PIN with a remote display?

Not confirm, but enter.

Quoted 2 lines

Are they expected to type the PIN into the remote device? Or even the host, perhaps it's displayed there?

They're supposed to enter it. The device is a Hi-Fi with Bluetooth functionality:
http://www.sony.co.uk/support/en/product/CMT-DH5BT

You have a UI to enter the PIN but it will only allow you to enter 4 digits. So any number longer than 4 digits will fail to pair.

Quoted 2 lines

Or do these devices simply just accept any PIN without question? In which case, why does it matter whether you send a random PIN or 0000?

It doesn't.

#7 lore raw
Quoted 2 lines · Bastien Nocera

Em Mon, 2012-01-30 =E0s 14:35 -0800, Scott James Remnant escreveu:

Quoted 1 line

On Mon, Jan 30, 2012 at 2:33 PM, Bastien Nocera <[email protected]> wrot=

e:

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Em Mon, 2012-01-30 =E0s 13:42 -0800, Scott James Remnant escreveu:

Quoted 2 lines
Quoted 2 lines

The PIN length hint is also ignored in the current code:
+ =A0 =A0 =A0 <device type=3D"audio" oui=3D"00:1A:80:" name=3D"CMT-=

DH5BT"

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

pin=3D"max:4"/>

Quoted 1 line

Because that's a UI restriction, no?

I didn't put any PIN-generation code here, because I'm not entirely sure what the UI for "generate random PIN' should look like or which spec you're following.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

It means that a generated PIN shouldn't have more than 4 digits for it to work with this device.

What generated PIN? Which spec/profile says you have to generate a PIN for this device?

It's recommended that the UIs try to generate PINs for the users, rather than relying on them entering random numbers.

Recommended where? Can you point at least at the correct document?

The only recommendation I'm aware of is in the HID profile, which would not apply here, and strangely you don't use this max: form for keyboards which would be the only devices they applied to.

The description matches the HID profile behavior I've sumitted as a separate set of CLs.

Scott
--=20
Have you ever, ever felt like this?
Had strange things happen? =A0Are you going round the twist?

#8 lore raw

Hi Scott

Quoted 1 line · Scott James Remnant

On Mon, Jan 30, 2012 at 3:03 PM, Bastien Nocera <[email protected]> wrote=

:

Quoted 2 lines
Quoted 2 lines

Em Mon, 2012-01-30 =E0s 14:35 -0800, Scott James Remnant escreveu:

Quoted 1 line

On Mon, Jan 30, 2012 at 2:33 PM, Bastien Nocera <[email protected]> wro=

te:

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Em Mon, 2012-01-30 =E0s 13:42 -0800, Scott James Remnant escreveu:

Quoted 2 lines
Quoted 2 lines

The PIN length hint is also ignored in the current code:
+ =A0 =A0 =A0 <device type=3D"audio" oui=3D"00:1A:80:" name=3D"CMT=

-DH5BT"

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines

pin=3D"max:4"/>

Quoted 1 line

Because that's a UI restriction, no?

I didn't put any PIN-generation code here, because I'm not entirely sure what the UI for "generate random PIN' should look like or which spec you're following.

It means that a generated PIN shouldn't have more than 4 digits for i=

t

Quoted 10 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

to work with this device.

What generated PIN? Which spec/profile says you have to generate a PIN for this device?

It's recommended that the UIs try to generate PINs for the users, rather than relying on them entering random numbers.

Recommended where? Can you point at least at the correct document?

Quoted 8 lines

The only recommendation I'm aware of is in the HID profile, which would not apply here, and strangely you don't use this max: form for keyboards which would be the only devices they applied to.

The description matches the HID profile behavior I've sumitted as a separate set of CLs.

Any update on this plugin? It would make the wiimote plugin obsolete and allow us to select PINs based on device-names.

If you do not intend to continue your work here I will try fixing the stuff and resubmit it.

Regards
David

#9 lore raw

No update just yet,

Project cycles what they are, the rough first draft of this plugin is sufficient for our testing needs right now, and I'm working on the rough first draft of the integration with the rest of the system.

I'll be coming back to clean this up in a few weeks :) if you want to do any work on it in the mean time, please do, multiple people working on a patch is always a good thing!

Scott

Quoted 50 lines · David Herrmann

Hi Scott

Quoted 1 line · Scott James Remnant

On Mon, Jan 30, 2012 at 3:03 PM, Bastien Nocera <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines

Em Mon, 2012-01-30 às 14:35 -0800, Scott James Remnant escreveu:

Quoted 1 line

On Mon, Jan 30, 2012 at 2:33 PM, Bastien Nocera <[email protected]>

Quoted 5 lines · wrote:
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Em Mon, 2012-01-30 às 13:42 -0800, Scott James Remnant escreveu:

Quoted 4 lines
Quoted 2 lines

The PIN length hint is also ignored in the current code:
+ <device type="audio" oui="00:1A:80:" name="CMT-DH5BT"

pin="max:4"/>

Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

Because that's a UI restriction, no?

I didn't put any PIN-generation code here, because I'm not entirely sure what the UI for "generate random PIN' should look like or which spec you're following.

It means that a generated PIN shouldn't have more than 4 digits for

it

Quoted 10 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

to work with this device.

What generated PIN? Which spec/profile says you have to generate a PIN for this device?

It's recommended that the UIs try to generate PINs for the users, rather than relying on them entering random numbers.

Recommended where? Can you point at least at the correct document?

Quoted 8 lines

The only recommendation I'm aware of is in the HID profile, which would not apply here, and strangely you don't use this max: form for keyboards which would be the only devices they applied to.

The description matches the HID profile behavior I've sumitted as a separate set of CLs.

Any update on this plugin? It would make the wiimote plugin obsolete and allow us to select PINs based on device-names.

If you do not intend to continue your work here I will try fixing the stuff and resubmit it.

Regards
David

Signature · 2 lines
Have you ever, ever felt like this?
Had strange things happen?  Are you going round the twist?
#10 lore raw
In reply to Marcel Holtmann

On Mon, Jan 30, 2012 at 11:49 AM, Marcel Holtmann <[email protected]> wro= te:

Quoted 2 lines
Quoted 2 lines

+<!--
+ =A0The autopair plugin will match devices, following the order of the =

XML

Quoted 3 lines
Quoted 3 lines

+ =A0file [1], on any combination of type, OUI, or name.
+
+ =A0[1]: So specific devices should be at the top, and generic ones at =

the bottom,

Quoted 7 lines
Quoted 7 lines

+ =A0so settings for specific devices are overridden as expected. +-->
+
+<!DOCTYPE devices [
+ =A0 =A0 <!ELEMENT devices (device)+>
+ =A0 =A0 <!ELEMENT device EMPTY>
+ =A0 =A0 <!ATTLIST device type (any|mouse|tablet|keyboard|headset|headp=

hones|audio|printer|network) "any">

Quoted 9 lines
Quoted 4 lines

+ =A0 =A0 <!ATTLIST device oui CDATA #IMPLIED>
+ =A0 =A0 <!ATTLIST device name CDATA #IMPLIED>
+ =A0 =A0 <!ATTLIST device pin CDATA #REQUIRED>
+]>

I think we need to have a discussion on this database format first. I honestly do not like it at all. It does matching and result handling in a single XML element. That seems like a bad idea.

Quoted 6 lines

And in addition making pin attribute required and then trying to disable PIN with "NULL" magic is something that I rather not have.

I am also wondering why this has to be XML and not simple key-value INI style files.

I tend to agree ;-)

The reason it couldn't be pure INI-style (at least, parseable by glib) though is because you then need unique group names for each match, which is equally urgh to write.

Scott
--=20
Have you ever, ever felt like this?
Had strange things happen? =A0Are you going round the twist?