Commit Graph

258 Commits (da26848afa1111707cb740dbb826b4959f3424b5)

Author SHA1 Message Date
Johan Hedberg 1c2e004183 Bluetooth: Add support for encryption key refresh
With LE/SMP the completion of a security level elavation from medium to
high is indicated by a HCI Encryption Key Refresh Complete event. The
necessary behavior upon receiving this event is a mix of what's done for
auth_complete and encryption_change, which is also where most of the
event handling code has been copied from.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
2012-06-08 21:00:40 -03:00
Gustavo Padovan d839c81372 Bluetooth: Report proper error number in disconnection
If encryption change fails we should disconnect with auth failure error
code.

Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-05-16 16:14:24 -03:00
Vishal Agarwal 9d939d9484 Bluetooth: Fix EIR data generation for mgmt_device_found
The mgmt_device_found function expects to receive only the significant
part of the EIR data so it needs to be removed before calling the
function. This patch adds a new eir_get_length() helper function to
calculate the length of the significant part.

Signed-off-by: Vishal Agarwal <vishal.agarwal@stericsson.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-05-16 16:13:19 -03:00
Johan Hedberg a24299e6c8 Bluetooth: Fix Inquiry with RSSI event mask
The right bit for "Inquiry with RSSI" is 0x02 and not 0x04 (which means
"Read Remote Extended Features Complete").

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2012-05-16 16:13:14 -03:00
Gustavo Padovan 08e6d907fe Merge git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth 2012-05-16 16:11:44 -03:00
Johan Hedberg 671267bf3a Bluetooth: mgmt: Fix device_connected sending order
The mgmt_ev_device_connected signal must be sent before any event
indications happen for sockets associated with the connection. Otherwise
e.g. device authorization for the sockets will fail with ENOTCONN as
user space things that there is no baseband link.

This patch fixes the issue by ensuring that the device_connected event
if sent (if it hasn't been so already) as soon as the first ACL data
packet arrives from the remote device.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2012-05-14 13:56:15 -04:00
Gustavo Padovan a7d7723ae7 Bluetooth: notify userspace of security level change
It fixes L2CAP socket based security level elevation during a
connection. The HID profile needs this (for keyboards) and it is the only
way to achieve the security level elevation when using the management
interface to talk to the kernel (hence the management enabling patch
being the one that exposes this issue).

It enables the userspace a security level change when the socket is
already connected and create a way to notify the socket the result of the
request. At the moment of the request the socket is made non writable, if
the request fails the connections closes, otherwise the socket is made
writable again, POLL_OUT is emmited.

Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2012-05-14 13:51:25 -04:00
Marcel Holtmann 9d42820f37 Bluetooth: Enable Low Energy support by default
The Bluetooth Low Energy support so far was disabled by default via
a module parameter. With this change the module parameter will be removed
and Low Energy is enabled by default.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
2012-05-09 01:40:52 -03:00
Andre Guedes 479453d5fe Bluetooth: Remove advertising cache
User-space pass the remote device address type to kernel through
struct sockaddr_l2 what makes the advertising useless. This patch
removes all advertising cache code.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2012-05-09 01:40:46 -03:00
Hemant Gupta 328c9248bf Bluetooth: mgmt: Fix missing connect failed event for LE
This patch adds management connect failed event when LE Create Connection
Command fails to inform user space that LE Connection failed to get
established.

Signed-off-by: Hemant Gupta <hemant.gupta@stericsson.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-05-09 00:41:38 -03:00
Andre Guedes 1519cc177a Bluetooth: Ignore inquiry results from periodic inquiry
This patch changes inquiry result function handlers so they ignore
inquiry result events if periodic inquiry is enabled.

Signed-off-by: Andre Guedes <aguedespe@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
2012-05-09 00:41:34 -03:00
Andre Guedes ae854a70df Bluetooth: Add HCI_PERIODIC_INQ to dev_flags
This patch adds the HCI_PERIODIC_INQ flag to dev_flags. This flag
tracks if periodic inquiry is enabled or not.

Signed-off-by: Andre Guedes <aguedespe@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
2012-05-09 00:41:34 -03:00
Andre Guedes 4d93483b1c Bluetooth: Add Periodic Inquiry command complete handler
This patch adds a handler function to Periodic Inquiry command
complete event.

Signed-off-by: Andre Guedes <aguedespe@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
2012-05-09 00:41:34 -03:00
Andre Guedes c9ecc48e2f Bluetooth: LE support for MGMT stop discovery
This patch adds LE support to MGMT stop discovery command. So,
now we are able to cancel LE discovery procedures (LE-only and
interleaved).

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-05-09 00:41:33 -03:00
Andrei Emeltchenko 035100c8a8 Bluetooth: Fix type in cpu_to_le conversion
Use struct hci_cp_write_def_link_policy to overcome sparse
warnigs below:

...
net/bluetooth/hci_event.c:633:21: warning: incorrect type in assignment
(different base types)
net/bluetooth/hci_event.c:633:21:    expected unsigned short [unsigned]
[assigned] [usertype] link_policy
net/bluetooth/hci_event.c:633:21:    got restricted __le16 [usertype] <noident>
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-05-09 00:41:32 -03:00
Marcel Holtmann 91c4e9b1ac Bluetooth: Add TX power tag to EIR data
The Inquiry Response TX power tag should be added to the Extended
Inquiry Data (EIR) as well.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-05-09 00:41:30 -03:00
Andre Guedes bc3dd33cef Bluetooth: Check FINDING state in interleaved discovery
In order to do interleaved discovery we should be in DISCOVERY_
FINDING state. Otherwise, discovery should be stopped.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2012-05-09 00:41:29 -03:00
Andrei Emeltchenko e46668819c Bluetooth: trivial: Correct endian conversion
Correct endian conversion reported by sparse

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2012-05-09 00:41:28 -03:00
John W. Linville 4dcc0637fc Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth 2012-04-27 15:16:43 -04:00
Szymon Janc 16cde9931b Bluetooth: Fix missing break in hci_cmd_complete_evt
Command complete event for HCI_OP_USER_PASSKEY_NEG_REPLY would result
in calling handler function also for HCI_OP_LE_SET_SCAN_PARAM. This
could result in undefined behaviour.

Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
2012-04-24 11:38:41 -03:00
Vishal Agarwal 6ec5bcadc2 Bluetooth: Temporary keys should be retained during connection
If a key is non persistent then it should not be used in future
connections but it should be kept for current connection. And it
should be removed when connecion is removed.

Signed-off-by: Vishal Agarwal <vishal.agarwal@stericsson.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-04-16 12:57:45 +03:00
David Howells 9ffc93f203 Remove all #inclusions of asm/system.h
Remove all #inclusions of asm/system.h preparatory to splitting and killing
it.  Performed with the following command:

perl -p -i -e 's!^#\s*include\s*<asm/system[.]h>.*\n!!' `grep -Irl '^#\s*include\s*<asm/system[.]h>' *`

Signed-off-by: David Howells <dhowells@redhat.com>
2012-03-28 18:30:03 +01:00
Gustavo F. Padovan 04124681f1 Bluetooth: fix conding style issues all over the tree
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2012-03-08 02:02:26 -03:00
Johan Hedberg 2b4bf39742 Bluetooth: mgmt: Fix updating local name when powering on
When powering on we need to apply whatever name has been set through
mgmt_set_local_name. The appropriate place for this is mgmt_powered()
and not hci_setup() since this needs to be applied also if the HCI init
sequence was already completed but the adapter was still "powered off"
from a mgmt perspective due the the HCI_AUTO_OFF still being set.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
2012-03-03 01:28:47 +02:00
Johan Hedberg 9f8ce967ca Bluetooth: Fix clearing of HCI_PENDING_CLASS flag
When doing reset HCI_PENDING_CLASS is one of the flags that should be
cleared (since it's used for a pending HCI command and a reset clear all
pending commands).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
2012-03-02 03:19:24 +02:00
Gustavo F. Padovan 00abfe4442 Bluetooth: Fix coding style with breaking lines
Our limit is 80 and broken lines should as right as possible.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2012-03-01 01:27:54 -03:00
Szymon Janc 95b23582d7 Bluetooth: Use NULL instead of integer for mgmt_device_connected param
Last param of mgmt_device_connected is of pointer type, so use NULL
instead of 0 for it. This fix following sparse warning:

CHECK   net/bluetooth/hci_event.c
net/bluetooth/hci_event.c:3262:74: warning: Using plain integer as NULL pointer

Signed-off-by: Szymon Janc <szymon@janc.net.pl>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-02-29 17:48:31 +02:00
Johan Hedberg 02b7cc62b6 Bluetooth: Use LMP_HOST_SSP define instead of magic values
This patch fixes the code to use the proper LMP_HOST_SSP define instead
of magic values and thereby makes the code more readable.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
2012-02-28 02:30:00 +02:00
Johan Hedberg 8f984dfaf0 Bluetooth: Remove redundant read_host_features commands
Previously the write_le_enable would trigger a read_host_features
command but since we have access to the value LE support was set to we
can simply just clear or set the bit in hdev->host_features. This also
removes a second unnecessary read_host_features command from the device
initialization procedure since LE is only enabled after the first
read_host_features command completes.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
2012-02-28 01:54:19 +02:00
Andrei Emeltchenko 28b8df7744 Bluetooth: Fix init request completion with AMP controllers
Mark request status as done for Read Local Version HCI command. In AMP
initialization this HCI command is the last and needs to be completed.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-02-24 14:02:21 +02:00
Johan Hedberg 3159d3843a Bluetooth: Fix init request completion with old controllers
With Bluetooth 1.1 controllers the last command in the HCI init sequence
will be a write_local_name, however there was no callback to indicate
init request completion in this case. This patch fixes the issue by
adding the necessary callback to the write_local_name_complete handler.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-02-24 14:01:20 +02:00
Johan Hedberg 08c79b6133 Bluetooth: mgmt: Add flags parameter to device_connected
This patch updates the Device Connected events to match the latest API
by adding a flags parameter to them.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
2012-02-23 22:39:17 +02:00
Andre Guedes 69775ff6d1 Bluetooth: Set DISCOVERY_STOPPED if controller resets
If controller is reset during the discovery procedure, Start Discovery
command stops working. This can be easily reproduced by running
"hciconfig hci0 reset" while discovering devices, for instance.

We should force discovery state to DISCOVERY_STOPPED in case we receive
a reset command complete event. Otherwise we may stuck in one of the
active discovery states (DISCOVERY_INQUIRY, DISCOVERY_LE_SCAN and
DISCOVERY_RESOLVING) and subsequent Start Discovery commands will simply
fail.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-02-23 16:51:47 +02:00
Johan Hedberg 388fc8faf2 Bluetooth: mgmt: Add legacy pairing info to dev_found events
This patch makes sure that legacy pairing vs SSP infomation gets
properly propageted to the device_found events in the form of the legacy
pairing flag.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
2012-02-23 13:07:01 +02:00
Johan Hedberg 28cc7bde59 Bluetooth: mgmt: Allow local name changes while powered off
This patch makes it possible to set the local name before powering on
the device. The name will be applied using the hci_write_local_name
command once the device gets powered on.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
2012-02-23 13:07:00 +02:00
Johan Hedberg db99b5fc77 Bluetooth: Fix read_name updating when HCI_SETUP is not set
The local name should only be updated as a consequence of a
hci_read_local_name if we are in the HCI_SETUP state. In all other
scenarios it should only be updated through hci_write_local_name.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
2012-02-23 13:07:00 +02:00
Marcel Holtmann 7f9a903c57 Bluetooth: Send management event for class of device changes
Currently there are no events to other management sockets if the class of
device got changed. So make sure they are sent.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-02-23 13:07:00 +02:00
Johan Hedberg f51d5b2489 Bluetooth: mgmt: Fix updating EIR when updating the name
Whenever we update the local device name the EIR data also needs to be
updated to reflect this. The update_eir() function in mgmt.c depends on
hdev->dev_name to be up to date so the patch also makes sure that the
mgmt function is called from hci_event.c after the update has happened.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
2012-02-23 13:06:59 +02:00
Johan Hedberg 06199cf86a Bluetooth: mgmt: Implement Set LE command
This patch implements support for the Set LE mgmt command. Now, in
addition to the enable_le module parameter user space needs to send an
explicit Enable LE command to enable LE support.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
2012-02-23 13:06:59 +02:00
Johan Hedberg 54d04dbbb9 Bluetooth: Explicitly clear EIR data upon hci_dev setup
Some controllers preserve their EIR data even after a reset so we need
to explicitly clear this during the device setup procedure.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
2012-02-23 13:06:59 +02:00
Johan Hedberg c0ecddc250 Bluetooth: mgmt: Make Set SSP command callable while powered off
This patch makes it possible to enable SSP through mgmt even when
powered off. The setting will then get automatically actiated when
powering on.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
2012-02-23 13:06:58 +02:00
Johan Hedberg 2e99b0afc7 Bluetooth: Remove unneeded hci_cc_read_ssp_mode function
The kernel has no need to track the hci_read_ssp_mode command since it
has the hci_sent_cmd_data function to check what value was set when
hci_write_ssp_mode completes.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
2012-02-23 13:06:58 +02:00
Johan Hedberg 47990ea09d Bluetooth: mgmt: Make Set Link Security callable while powered off
This patch makes it possible to change the Link Security setting while
powered off and have it automatically enabled when powering on a device.
To track the desired state once powered on a new HCI_LINK_SECURITY flag
is added.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
2012-02-23 13:06:58 +02:00
Johan Hedberg a297e97cf7 Bluetooth: Fix clearing of persistent dev_flags
Now that most flags are persistent, only the LE_SCAN flag should be
cleared after a reset.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
2012-02-21 20:04:39 +02:00
Marcel Holtmann d7b7e79688 Bluetooth: Set supported settings based on enabled HS and/or LE
Since neither High Speed (HS) nor Low Energy (LE) are fully implemented
yet, only expose them in supported settings when enabled.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-02-20 23:08:17 +02:00
Marcel Holtmann 040030ef7d Bluetooth: Remove HCI notifier handling
The HCI notifier handling was never used outside of Bluetooth core layer
and thus remove it and replace it with direct function calls. Also move
the stack internal event generation into the HCI socket layer.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-02-20 15:59:22 +02:00
Marcel Holtmann 470fe1b540 Bluetooth: Split sending for HCI raw and control sockets
The sending functions for HCI raw and control sockets have nothing in
common except that they iterate over the socket list. Split them into
two so they can do their job more efficient. In addition the code becomes
more readable.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-02-20 15:55:11 +02:00
Andre Guedes 5e0452c00a Bluetooth: Interleaved discovery support
This patch adds interleaved discovery support to MGMT Start
Discovery command.

In case interleaved discovery is not supported (not a dual mode
device), we perform BR/EDR or LE-only discovery according to the
device capabilities.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-02-19 12:34:55 +02:00
Andre Guedes 343f935bfa Bluetooth: Merge INQUIRY and LE_SCAN discovery states
This patch merges DISCOVERY_INQUIRY and DISCOVERY_LE_SCAN states
into a new state called DISCOVERY_FINDING.

From the discovery perspective, we are pretty much worried about
to know just if we are finding devices than what exactly phase of
"finding devices" (inquiry or LE scan) we are currently running.
Besides, to know if the controller is performing inquiry or LE scan
we should check HCI_INQUIRY or HCI_LE_SCAN bits in hdev flags.

Moreover, merging this two states will simplify the discovery state
machine and will keep interleaved discovery implementation simpler.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2012-02-19 12:34:09 +02:00
Johan Hedberg ed2c4ee360 Bluetooth: mgmt: Add support for Set SSP command
The Set SSP mgmt command can be used for enabling and disabling Secure
Simple Pairing support for controllers that support it.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
2012-02-17 11:27:11 +02:00