summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
AgeCommit message (Collapse)AuthorFilesLines
2013-10-14Bluetooth: Reorganize set_connectable HCI command sendingJohan Hedberg1-16/+20
This patch moves all the decisions of which HCI commands to send (or not to send) to the code between hci_req_init() and hci_req_run() this allows us to further extend the request with further commands but still keep the same logic of handling whether to return a direct mgmt response in the case that no HCI commands were sent. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2013-10-13Bluetooth: Remove pointless bdaddr_to_le() helper functionMarcel Holtmann1-3/+7
The bdaddr_to_le() function tries to convert the internal address type to one that matches the HCI address type for LE. It does not handle any address types not used by LE and in the end just make the code a lot harder to read. So instead of just hiding behind a magic function, just convert the internal address type where it needs to be converted. And it turns out that these are only two cases anyway. One when creating new LE connections and the other when loading the long term keys. In both cases this makes it more clear on what it going on. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-12Bluetooth: Add MGMT_OP_SET_SCAN_PARAMS to supported commands listMarcel Holtmann1-0/+1
When adding support for MGMT_OP_SET_SCAN_PARAMS command the addition to the supported commands list has been forgotten. This is needed for userspace to detect if the command is supported or not. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-11Bluetooth: Don't advertise high speed support without SSPMarcel Holtmann1-4/+5
It is not allowed to enable high speed support when Secure Simple Pairing is not available or disabled. However the support for high speed gets advertised on a controller that does not even support Secure Simple Pairing. Since there is no way to enable high speed support on such a controller, do not even advertise its support. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-11Bluetooth: Add management command for setting LE scan parametersMarcel Holtmann1-0/+38
The scan interval and window parameters are used for LE passive background scanning and connection establishment. This allows userspace to change the values. These two values should be kept in sync with whatever is used for the scan parameters service on remote devices. And it puts the controlling daemon (for example bluetoothd) in charge of setting the values. Main use case would be to switch between two sets of values. One for foreground applications and one for background applications. At this moment, the values are only used for manual connection establishment, but soon that should be extended to background scanning and automatic connection establishment. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-11Bluetooth: Move smp.h header file into net/bluetooth/Marcel Holtmann1-1/+2
The smp.h header file is only used internally by the bluetooth.ko module and is not a public API. So make it local to the core Bluetooth module. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-10Bluetooth: Use hci_conn_num() for checking number of LE connectionsMarcel Holtmann1-2/+2
When checking for the current number of LE connections, use hci_conn_num() function instead of a full blown lookup within the connection hash or direct access of the counters. In the case of re-enabling advertising, it is more useful to check for any connection attempt or existing connection. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-10Bluetooth: Fix too long line with set_advertising() functionMarcel Holtmann1-1/+2
The function declaration goes over 80 characters, so break it down. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-10Bluetooth: Fix checking for HCI_SETUP flag when receiving mgmt commandsJohan Hedberg1-1/+2
When the HCI_SETUP flag is set the controller has not yet been announced over mgmt and therefore doesn't exist from that perspective. If we nevertheless get a mgmt command for it we should respond with the appropriate INVALID_INDEX error. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2013-10-10Bluetooth: Restrict high speed support to SSP enabled controllersMarcel Holtmann1-10/+32
The support for Bluetooth High Speed can only be enabled on controllers where also Secure Simple Pairing has been enabled. Trying to enable high speed when SSP is disabled will result into an error. Disabling SSP will at the same time disable high speed as well. It is required to enforce this dependency on SSP since high speed support is only defined for authenticated, unauthenticated and debug link keys. These link key types require SSP. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-10Bluetooth: Remove unneeded val variable when setting SSPMarcel Holtmann1-5/+3
The variable val in the set_ssp() function of the management interface is not needed. Just use cp->val directly since its input values have already been validated. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-08Bluetooth: Fix changing advertising setting while LE is connectedJohan Hedberg1-1/+7
We only (re)enable advertising when LE is disconnected. Trying to enable advertising using mgmt_set_advertising while connected should simply change the flag but not do anything else (until the connection gets dropped). This patch fixes this by making an LE connection lookup to determine whether there are any connected devices or not. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2013-10-07Bluetooth: Make mgmt_discovering() return voidMarcel Holtmann1-2/+2
The return value of mgmt_discovering() function is not used and so just change it to return void. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07Bluetooth: Make mgmt_remote_name() return voidMarcel Holtmann1-4/+3
The return value of mgmt_remote_name() function is not used and so just change it to return void. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07Bluetooth: Make mgmt_device_found() return voidMarcel Holtmann1-6/+6
The return value of mgmt_device_found() function is not used and so just change it to return void. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07Bluetooth: Make mgmt_device_disconnected() return voidMarcel Holtmann1-7/+3
The return value of mgmt_device_disconnected() function is not used and so just change it to return void. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07Bluetooth: Make mgmt_device_connected() return voidMarcel Holtmann1-5/+5
The return value of mgmt_device_connected() function is not used and so just change it to return void. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07Bluetooth: Make mgmt_connect_failed() return voidMarcel Holtmann1-3/+3
The return value of mgmt_connect_failed() function is not used so change it to just return void. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07Bluetooth: Make mgmt_disconnect_failed() return voidMarcel Holtmann1-8/+5
The return value of mgmt_disconnect_failed() function is not used so change it to just return void. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07Bluetooth: Make mgmt_set_powered_failed() return voidMarcel Holtmann1-5/+3
The return value of mgmt_set_powered_failed() function is never used and so make the function just return void. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07Bluetooth: Make mgmt_index_added() and mgmt_index_removed() return voidMarcel Holtmann1-6/+6
The return value from mgmt_index_added() and mgmt_index_removed() functions is never used. So do not pretend that returning an error would actually be handled and just make both functions return void. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-07Bluetooth: Send new settings only when pairable changesMarcel Holtmann1-5/+7
In case the current value of pairable is already configured, do not send a new settings event indicating that something has changed while in reality everything is the same. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-06Bluetooth: Remove mgmt_valid_hdev() helper functionMarcel Holtmann1-16/+8
The helper function mgmt_valid_hdev() is more obfuscating the code then it makes it easier to read. So intead of this helper, use the direct check for BR/EDR device type. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-06Bluetooth: Remove no longer needed mgmt_new_settings() functionMarcel Holtmann1-7/+2
The mgmt_new_settings() function was only needed to handle the error case when re-enabling advertising failed. Since that is now handled internally inside the management core, this function is not needed anymore. So just remove it. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-06Bluetooth: Use helper function for re-enabling advertisingMarcel Holtmann1-0/+33
When the all LE connections have been disconneted, then it is up to the host to re-enable advertising at that point. To ensure that the correct advertising parameters are used, force the usage of the common helper to enable advertising. The change just moves the manual enabling of advertising from the event handler into the management core so that the helper can be actually shared. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-06Bluetooth: Set LE advertising parameters before enabling itMarcel Holtmann1-4/+18
The LE advertising parameters can only be modified when advertising is disabled. So before enabling it, make sure the controller has all the right parameters. Right now all default values are used and thus this does no change any existing behavior. One minor exception is that in case of single mode LE-only controllers without a public address, now the random address is used for advertising. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-06Bluetooth: Use helper functions for enabling/disabling advertisingMarcel Holtmann1-11/+22
The tasks of enabling and disabling advertising are required in many cases. So refactor the actual HCI operations into two common helpers to make the code simpler. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-06Bluetooth: Make it clear that disabling LE disables advertisingMarcel Holtmann1-2/+5
This is not a functional change, just change the code to make it easy to understand that advertising gets disabled before LE support will be turned off. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-06Bluetooth: Use random address if public address is not availableMarcel Holtmann1-0/+4
For single mode LE-only controllers, it is possible that they come without a public address. If a public address is not available, then use the random address for connection establishment and scanning. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-05Bluetooth: Add public mgmt function to send New Settings eventJohan Hedberg1-0/+5
A function is needed so that the HCI event processing can ask the mgmt code to emit a new settings event. This is necessary e.g. when the event processing does updates to mgmt related states without any dependency of actual mgmt commands. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2013-10-05Bluetooth: Rename HCI_LE_PERIPHERAL to HCI_ADVERTISINGJohan Hedberg1-9/+9
This flag is used to indicate whether we want to have advertising enabled or not, so give it a more suitable name. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2013-10-03Bluetooth: Allow changing device class when BR/EDR is disabledMarcel Holtmann1-1/+1
Changing the device class when BR/EDR is disabled has no visible effect for remote devices. However to simplify the logic allow it as long as the controller supports BR/EDR operations. If it is not allowed, then the overall logic becomes rather complicated since the class of device values would need clearing or restoring when BR/EDR setting changes. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-03Bluetooth: Restrict loading of long term keys to LE capable controllersMarcel Holtmann1-0/+6
Loading long term keys into a BR/EDR only controller make no sense. The kernel would never use any of these keys. So instead of allowing userspace to waste memory, reject such operation with a not supported error message. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-03Bluetooth: Restrict loading of link keys to BR/EDR capable controllersMarcel Holtmann1-0/+6
Loading link keys into a LE only controller make no sense. The kernel would never use any of these keys. So instead of allowing userspace to waste memory, reject such operation with a not supported error message. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-03Bluetooth: Allow setting static address even if LE is disabledMarcel Holtmann1-4/+2
Setting the static address does not depend on LE beeing enabled. It only depends on a controller with LE support. When depending on LE enabled this command becomes really complicated since in case LE gets disabled, it would be required to clear the static address and also its random address representation inside the controller. With future support for private addresses such complex setup should be avoided. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-03Bluetooth: Restrict SSP setting changes to BR/EDR enabled controllersMarcel Holtmann1-1/+5
Only when BR/EDR is supported and enabled, allow changing of the SSP setting. Just checking if the hardware supports SSP is not enough since it might be the case that BR/EDR is disabled. In the case that BR/EDR is disabled, but SSP supported by the controller the not supported error message is now returned. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-02Bluetooth: Increment management interface revisionMarcel Holtmann1-1/+1
This patch increments the management interface revision due to the various fixes, improvements and other changes that have gone in lately. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-02Bluetooth: Fix REJECTED vs NOT_SUPPORTED mgmt responsesJohan Hedberg1-25/+51
The REJECTED management response should mainly be used when the adapter is in a state where we cannot accept some command or a specific parameter value. The NOT_SUPPORTED response in turn means that the adapter really cannot support the command or parameter value. This patch fixes this distinction and adds two helper functions to easily get the appropriate LE or BR/EDR related status response. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2013-10-02Bluetooth: Add management command for setting static addressMarcel Holtmann1-0/+49
On dual-mode BR/EDR/LE and LE only controllers it is possible to configure a random address. There are two types or random addresses, one is static and the other private. Since the random private addresses require special privacy feature to be supported, the configuration of these two are kept separate. This command allows for setting the static random address. It is only supported on controllers with LE support. The static random address is suppose to be valid for the lifetime of the controller or at least until the next power cycle. To ensure such behavior, setting of the address is limited to when the controller is powered off. The special BDADDR_ANY address (00:00:00:00:00:00) can be used to disable the static address. This is also the default value. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-02Bluetooth: Restrict disabling of HS when controller is powered offMarcel Holtmann1-2/+9
Disabling the high speed setting when the controller is powered on has too many side effects that are not taken care of. And in general it is not an useful operation anyway. So just make such a command fail with a rejection error message. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-02Bluetooth: Add a new mgmt_set_bredr commandJohan Hedberg1-0/+120
This patch introduces a new mgmt command for enabling/disabling BR/EDR functionality. This can be convenient when one wants to make a dual-mode controller behave like a single-mode one. The command is only available for dual-mode controllers and requires that LE is enabled before using it. The BR/EDR setting can be enabled at any point, however disabling it requires the controller to be powered off (otherwise a "rejected" response will be sent). Disabling the BR/EDR setting will automatically disable all other BR/EDR related settings. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2013-10-02Bluetooth: Introduce a new HCI_BREDR_ENABLED flagJohan Hedberg1-11/+13
To allow treating dual-mode (BR/EDR/LE) controllers as single-mode ones (LE-only) we want to introduce a new HCI_BREDR_ENABLED flag to track whether BR/EDR is enabled or not (previously we simply looked at the feature bit with lmp_bredr_enabled). This patch add the new flag and updates the relevant places to test against it instead of using lmp_bredr_enabled. The flag is by default enabled when registering an adapter and only cleared if necessary once the local features have been read during the HCI init procedure. We cannot completely block BR/EDR usage in case user space uses raw HCI sockets but the patch tries to block this in places where possible, such as the various BR/EDR specific ioctls. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2013-10-02Bluetooth: Send new settings event when changing high speed optionMarcel Holtmann1-3/+16
When enabling or disabling high speed setting it is required to send a new settings event to inform other management interface users about the changed settings. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-10-02Bluetooth: Provide high speed configuration optionMarcel Holtmann1-9/+2
Hiding the Bluetooth high speed support behind a module parameter is not really useful. This can be enabled and disabled at runtime via the management interface. This also has the advantage that this can now be changed per controller and not just global. This patch removes the module parameter and exposes the high speed setting of the management interface to all controllers. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2013-09-25Bluetooth: Add new mgmt_set_advertising commandJohan Hedberg1-1/+96
This patch adds a new mgmt command for enabling and disabling LE advertising. The command depends on the LE setting being enabled first and will return a "rejected" response otherwise. The patch also adds safeguards so that there will ever only be one set_le or set_advertising command pending per adapter. The response handling and new_settings event sending is done in an asynchronous request callback, meaning raw HCI access from user space to enable advertising (e.g. hciconfig leadv) will not trigger the new_settings event. This is intentional since trying to support mixed raw HCI and mgmt access would mean adding extra state tracking or new helper functions, essentially negating the benefit of using the asynchronous request framework. The HCI_LE_ENABLED and HCI_LE_PERIPHERAL flags however are updated correctly even with raw HCI access so this will not completely break subsequent access over mgmt. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
2013-09-25Bluetooth: Add new mgmt setting for LE advertisingJohan Hedberg1-1/+20
This patch adds a new mgmt setting for LE advertising and hooks up the necessary places in the mgmt code to operate on the HCI_LE_PERIPHERAL flag (which corresponds to this setting). This patch does not yet add any new command for enabling the setting - that is left for a subsequent patch. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
2013-09-25Bluetooth: Use async request for LE enable/disableJohan Hedberg1-40/+27
This patch updates the code to use an asynchronous request for handling the enabling and disabling of LE support. This refactoring is necessary as a preparation for adding advertising support, since when LE is disabled we should also disable advertising, and the cleanest way to do this is to perform the two respective HCI commands in the same asynchronous request. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
2013-09-25Bluetooth: Move mgmt response convenience functions to a better locationJohan Hedberg1-30/+30
The settings_rsp and cmd_status_rsp functions can be useful for all mgmt command handlers when asynchronous request callbacks are used. They will e.g. be used by subsequent patches to change set_le to use an async request as well as a new set_advertising command. Therefore, move them higher up in the mgmt.c file to avoid unnecessary forward declarations or mixing this trivial change with other patches. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
2013-09-25Bluetooth: Fix busy return for mgmt_set_powered in some casesJohan Hedberg1-6/+6
We should return a "busy" error always when there is another mgmt_set_powered operation in progress. Previously when powering on while the auto off timer was still set the code could have let two or more pending power on commands to be queued. This patch fixes the issue by moving the check for duplicate commands to an earlier point in the set_powered handler. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
2013-09-16Bluetooth: Introduce user channel flag for HCI devicesMarcel Holtmann1-0/+9
This patch introduces a new user channel flag that allows to give full control of a HCI device to a user application. The kernel will stay away from the device and does not allow any further modifications of the device states. The existing raw flag is not used since it has a bit of unclear meaning due to its legacy. Using a new flag makes the code clearer. A device with the user channel flag set can still be enumerate using the legacy API, but it does not longer enumerate using the new management interface used by BlueZ 5 and beyond. This is intentional to not confuse users of modern systems. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>