Commit Graph

1142 Commits

Author SHA1 Message Date
Szymon Janc c6bcb591f6 Bluetooth: Add initial support for OOB data
This allows to query information needed for Out Of Band pairing
or connection creation. Currently supports only BT addresses.

Change-Id: I60bf9344baee552e7743fa8fc1b3cfb3a4765334
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-20 20:20:44 +02:00
Johan Hedberg 211ae314e8 Bluetooth: Pass net_buf_simple to scan callback
This lets the callback take advantage of the powerful net_buf API for
parsing the advertising data content.

Change-Id: Id65e6e83efd60c0f36c47bc5446a2e8ec2833d7c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-20 16:19:01 +00:00
Szymon Janc a0a52691f2 Bluetooth: Add support for rotating RPA
If privacy is enabled we always use RPA, even for active scan.
This makes single point of controlling current random address
making code simple and not prone to subtle bugs with concurent
advertising, scanning and connecting.

Currently used RPA is rotated to improve privacy. Timeout value is
controlled by Kconfig and by default is 900 seconds (15 minutes).

Change-Id: I27a15666a4f2e2962cf6eb20c7cd06f90b7f2bb1
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-20 16:18:50 +00:00
Luiz Augusto von Dentz c51bcbb9d9 Bluetooth: GATT: Add write struct parameter to its callback
This makes bt_gatt_write consistent with the rest of the API where the
parameters are passed back to its callback.

Change-Id: Ie94208aa661d3620d0cbc5be4a4fb5b3c3ef061c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-20 13:40:55 +00:00
Szymon Janc ae96c91109 Bluetooth: GATT: Fix using non-ASCII characters
Some non-ASCII characters were used in code comments.

Change-Id: Ie00e0b7d7a42a50503c601225cdd0896c375dee3
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-19 09:49:17 +00:00
Arkadiusz Lichwa 796d467653 Bluetooth: L2CAP: Set BR/EDR CoC channel as connected
Finalizes CoC channel configuration setup. The channel's CONNECTED state
can be set depending on context path by two responsible for that handlers.
Then one of them announces to all registered clients the connection is
set successfully.

> ACL Data RX: Handle 12 flags 0x02 dlen 12                   [hci1] 108.666944
      L2CAP: Connection Request (0x02) ident 3 len 4
        PSM: 3 (0x0003)
        Source CID: 64
> HCI Event: Number of Completed Packets (0x13) plen 5        [hci1] 108.668572
        Num handles: 1
        Handle: 12
        Count: 2
< ACL Data TX: Handle 12 flags 0x00 dlen 16                   [hci1] 108.673002
      L2CAP: Connection Response (0x03) ident 3 len 8
        Destination CID: 64
        Source CID: 64
        Result: Connection successful (0x0000)
        Status: No further information available (0x0000)
< HCI Command: Host Number of Complet.. (0x03|0x0035) plen 5  [hci1] 108.673548
        Num handles: 1
        Handle: 12
        Count: 1
< ACL Data TX: Handle 12 flags 0x00 dlen 16                   [hci1] 108.674725
      L2CAP: Configure Request (0x04) ident 5 len 8
        Destination CID: 64
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 48
> HCI Event: Number of Completed Packets (0x13) plen 5        [hci1] 108.707579
        Num handles: 1
        Handle: 12
        Count: 2
> ACL Data RX: Handle 12 flags 0x02 dlen 16                   [hci1] 108.714206
      L2CAP: Configure Request (0x04) ident 4 len 8
        Destination CID: 64
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 560
> ACL Data RX: Handle 12 flags 0x02 dlen 18                   [hci1] 108.715442
      L2CAP: Configure Response (0x05) ident 5 len 10
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 48
< HCI Command: Host Number of Complet.. (0x03|0x0035) plen 5  [hci1] 108.720451
        Num handles: 1
        Handle: 12
        Count: 1
< ACL Data TX: Handle 12 flags 0x00 dlen 14                   [hci1] 108.720472
      L2CAP: Configure Response (0x05) ident 4 len 6
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)

Change-Id: If831777f7bd87489eefbd200a1ca8883b83aae3e
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-15 11:31:06 +02:00
Arkadiusz Lichwa 22bdf50615 Bluetooth: L2CAP: Mark finishing CoC configuration on BR/EDR
When each side involved in getting configured L2CAP CoC channel on
BR/EDR transport aggrees on configuration contract regarding in/out MTU,
set proper context flags to start prepare finalize config process.

Change-Id: Ic821ea3b961442be758ad4e2d91b2d812e2a54b5
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-15 11:01:17 +02:00
Arkadiusz Lichwa c28720f167 Bluetooth: L2CAP: Introduce CoC channel states
Adds CoC channel's context to hold channel setup state and SM routine
that evaluates validness of transitions.
At the beginning DISCONNECTED, CONNECT and CONFIG states are added and
used by CoC setup on BR/EDR transport.

Change-Id: I1bbd16ec2f59ea961791786b78f22834d6f4b4d8
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-15 04:54:03 +00:00
Szymon Janc c9e2fc1929 Bluetooth: Fix changing advertising random address when scanning
If active scan was started while advertising random adress was
set to NRPA. This results in device advertising with new adress
instead of RPA making it imposible to resolve its identity by
remote devices.

To fix this NRPA for active scan is set only if advertising is
not enabled. This resulst in RPA being used for scan requests
but this is OK since device is advertising anyway.

Change-Id: I35e98bee72f4abc033f5adc664698c14c5d8a2b0
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-14 15:26:50 +00:00
Szymon Janc 40cf82bc60 Bluetooth: Track if active scan is being perfomed
Add new bt_dev flag for tracking if performing active scan.

Change-Id: I7eacaa94372bae933f648a49d2f55fc200f9d0bf
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-14 15:26:42 +00:00
Szymon Janc 9303331bbd Bluetooth: SMP: Fix disabling debug logs
SMP debugs should be enabled only if CONFIG_BLUETOOTH_DEBUG_SMP is
defined.

Change-Id: I17f8ad5e1a9504dcbd3df545af9205db88ee2849
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-14 11:52:48 +02:00
Mariusz Skamra d98b9bd139 Bluetooth: Get the included service 128bit UUID
This adds reading of included service attribute 128bit UUID.
The limitation of this solution is that if several attr handle-range
pairs will be received, this will read first attribute UUID and then
start discovery from the the succeeding handle.

ZEP-373

Discovery related test results:

 2/76   GATT   TC_GAD_CL_BV_02_C   PASS
 3/76   GATT   TC_GAD_CL_BV_03_C   PASS
 4/76   GATT   TC_GAD_CL_BV_04_C   PASS
 5/76   GATT   TC_GAD_CL_BV_05_C   PASS
 6/76   GATT   TC_GAD_CL_BV_06_C   PASS

Change-Id: I27185b3a3ae96c9c03b0f356492df18ba83b183a
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-07-13 14:18:03 +00:00
Szymon Janc 48eee87a39 Bluetooth: Fix using NRPA for connectable advertising
If privacy is disabled and static random address is used for identity
we need to restore static address before enabling advertising.
Otherwise NRPA used for any previous active scan could be used instead.

Change-Id: Ifea0d2863d78060c84e61d89ef384a94e86895b6
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-13 04:53:22 +00:00
Szymon Janc 832b808177 Bluetooth: ATT: Fix using non-ASCII characters
Some non-ASCII characters were used in code comments.

Change-Id: I77f13ca1648f34dc5dbd9ea78ccd2964a73a1712
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-12 15:13:23 +00:00
Arkadiusz Lichwa ca57a7816d Bluetooth: L2CAP: Start servicing configuration request from remote
To make channel operational in basic mode a process of BR/EDR CoC
channel configuration needs to be performed in both directions. Remote
peer is mandated as well to inform local about its segmentation
requirements. Here is added such request handler focused on grabbing
remote MTU which is mandatory in channel setup.

> ACL Data RX: Handle 12 flags 0x02 dlen 12  [hci1] 12.133539
      L2CAP: Connection Request (0x02) ident 3 len 4
        PSM: 1 (0x0001)
        Source CID: 64
< HCI Command: Host Number of Completed Packets (0x03|0x0035) plen 5  [hci1] 12.133631
        Num handles: 1
        Handle: 12
        Count: 1
> HCI Event: Number of Completed Packets (0x13) plen 5  [hci1] 12.133792
        Num handles: 1
        Handle: 12
        Count: 2
< ACL Data TX: Handle 12 flags 0x00 dlen 16  [hci1] 12.141644
      L2CAP: Connection Response (0x03) ident 3 len 8
        Destination CID: 64
        Source CID: 64
        Result: Connection successful (0x0000)
        Status: No further information available (0x0000)
< HCI Command: Host Number of Completed Packets (0x03|0x0035) plen 5  [hci1] 12.142054
        Num handles: 1
        Handle: 12
        Count: 1
< ACL Data TX: Handle 12 flags 0x00 dlen 16  [hci1] 12.143276
      L2CAP: Configure Request (0x04) ident 6 len 8
        Destination CID: 64
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 48
> HCI Event: Number of Completed Packets (0x13) plen 5  [hci1] 12.150945
        Num handles: 1
        Handle: 12
        Count: 2
> ACL Data RX: Handle 12 flags 0x02 dlen 16  [hci1] 12.150959
      L2CAP: Configure Request (0x04) ident 4 len 8
        Destination CID: 64
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 128
> ACL Data RX: Handle 12 flags 0x02 dlen 18  [hci1] 12.152160
      L2CAP: Configure Response (0x05) ident 6 len 10
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 48
< HCI Command: Host Number of Completed Packets (0x03|0x0035) plen 5  [hci1] 12.158806
        Num handles: 1
        Handle: 12
        Count: 1
< ACL Data TX: Handle 12 flags 0x00 dlen 14  [hci1] 12.161822
      L2CAP: Configure Response (0x05) ident 4 len 6
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)
< HCI Command: Host Number of Completed Packets (0x03|0x0035) plen 5  [hci1] 12.163197
        Num handles: 1
        Handle: 12
        Count: 1

Change-Id: I7919fe180cf1d761023bb1478d8e1fb2d21a94d9
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-11 19:34:17 +00:00
Luiz Augusto von Dentz d98068be94 Bluetooth: L2CAP: Fix not canceling RTX work
If the channel is being destroyed the RTX work should be cancelled as
it may cause destroy to be called again.

Change-Id: I49c10d64a2108719d28e456fb5b4bfb50ef8a140
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-11 15:40:39 +00:00
Luiz Augusto von Dentz a6a78bfbca Bluetooth: L2CAP: Unify code for adding and deleting channels
The code for adding and removing channels is very similar for LE and
BR/EDR so it can be unified and just leave the CID allocation up for the
bearer implementation.

Change-Id: Icf4c66262c4e973039381ebd1861fad4d46e1535
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-11 15:39:59 +00:00
Luiz Augusto von Dentz 2329d82432 Bluetooth: L2CAP: Make l2cap_chan_add initialize the destroy callback
This is cleaner and safer as destroy is garanteed to be initialized once
it is added to the list of channels.

Change-Id: Iae674f6e25527d71c03c5903337b0bd18c3dd0be
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-11 15:38:30 +00:00
Johan Hedberg 4efe39ff04 Bluetooth: SMP: Take advantage of new bt_hex helper
The h() helper isn't needed anymore.

Change-Id: Ica1b4beb086237c1c792d5376e8ee71bc64394fe
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-11 09:44:13 +00:00
Johan Hedberg 6e701275af Bluetooth: Add hexadecimal conversion logging helper
This has so far been used in SMP code as the h() function. Now it has
a more generic name and is accessible by all parts of the Bluetooth
subsystem.

Change-Id: Iae4607da9c8b3e6779d9c97f84a4e486d5258ef0
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-11 09:38:53 +00:00
Johan Hedberg f7d802b1e3 Bluetooth: Fix enabling ECDH HCI events when SMP is not selected
Now that there's an API always exposed for this the events should
always be enabled whenever the controller supports this feature.

Change-Id: I4965c9463ae7b3f6424784dab2c03403fdf3f179
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-11 09:38:42 +00:00
Szymon Janc bccc1bf0e1 Bluetooth: SMP: Send pairing failed on unexpected PDU
If unexpected PDU is recevied it is better to reply with Pairing
Failed and abort pairing then just silently ingore such PDU as
pairing will most likely fail anyway.

Change-Id: I3c67a6997a5e8d33b1e97cb955981a52baf38d02
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-09 12:40:48 +00:00
Luiz Augusto von Dentz 1183e6b82a Bluetooth: L2CAP: Add timeout handling
This adds initial timeout handling as described in the spec:

BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part A] page 126:

  'The value of this timer is implementation-dependent but the minimum
   initial value is 1 second and the maximum initial value is 60
   seconds. One RTX timer shall exist for each outstanding signaling
   request, including each Echo Request. The timer disappears on the
   final expiration, when the response is received, or the physical
   link is lost.'

Note: As for the actual interval used they are based on the values used
in Linux but in case of disconnect the minimum of 1 seconds was used
to follow the text above.

Change-Id: Ib98899c3ff07334955aee9c8fb53b1b89ba7bf31
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-08 12:05:33 +00:00
Luiz Augusto von Dentz 076ed6bc13 Bluetooth: ATT: Add timeout handling
Accourding to the spec request should have a timeout of 30 seconds:

BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part F] page 480:

  'A transaction not completed within 30 seconds shall time out. Such a
   transaction shall be considered to have failed and the local higher
   layers shall be informed of this failure. No more attribute protocol
   requests, commands, indications or notifications shall be sent to the
   target device on this ATT Bearer.'

Change-Id: I5e5b9fb008d3019831c5f6cc3bd4c2b85dd6b90a
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-08 12:05:33 +00:00
Mariusz Skamra 6f11245d92 Bluetooth: Fix missing endian conversion
16 bit handles have to be converted to host order.

Change-Id: Iae5d9d79bacd90cd5b42a98d02165ec75bf1272e
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-07-07 06:04:33 +00:00
Luiz Augusto von Dentz 96b9425a64 Bluetooth: L2CAP: Only call disconnected callback for connected channels
If channel has conn set to NULL disconnected shall not be called as
may cause invalid actions as with bt_gatt_disconnected being called
with a NULL conn.

Change-Id: I11bc41a34c2a2a3bc5f8514ec4a948235473cfba
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-06 12:08:53 +00:00
Mariusz Skamra 2dda2a9835 Bluetooth: Use LE Rand workaround for MyNewt on Quark SE Devboard
LE Rand command crashing the MyNewt HCI firmware issue has been also
observed on Quark SE Devboard. Applying this workaround solves the problem.

Change-Id: I57a533309ced0b2d31517a65ac1899ed55112973
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-07-06 12:08:42 +00:00
Szymon Janc ad281d4dbe Bluetooth: L2CAP: Avoid double endianess convertion
We already have host order length in len variable.

Change-Id: I5b4ea652c5709eadd64b66584024501c40fd3abc
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-06 12:08:31 +00:00
Arkadiusz Lichwa fdfc92c80d Bluetooth: ATT: Fix ATT_CHAN() macro
ATT_CHAN() macro as a wrapper to CONTAINER_OF is been used by ATT
internals API wherein the main parameter is pointer to bt_l2cap_chan
object. The macro returns pointer to bt_att context object but
CONTAINER_OF's third parameter determines what member is taken into
account in getting right address. Luckily here this third parameter
"chan" of type bt_l2cap_le_chan got of its own sub-member the "chan" of
type bt_l2cap_chan on first position in structure order. If such order
would change somehow there could be taken wrong address.

Change-Id: I955c2af11e001dac90a1eacc281ff167ceb34fb9
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-05 16:52:05 +02:00
Johan Hedberg f1a82f8ebe Bluetooth: Fix incorrect public key size
The ECC public key is 64 bytes in length.

Change-Id: I0fec312cdd94ff181abf8ec7e4eab46e1dc11eb6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-03 17:07:48 +03:00
Luiz Augusto von Dentz b008f74b0b Bluetooth: L2CAP: Fix not cleanup properly if ACL is disconnected
If ACL is disconnected with channels still active the code should call
l2cap_chan_del to clean it up properly.

Change-Id: Iffa9345a9697ac80c1f2295578c7161ffeb44420
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-01 14:17:06 +00:00
Johan Hedberg 179f08f049 Bluetooth: Create proper abstraction for ECC access
This makes the SMP usage of ECC functionality properly encapsulated
and offers the chance of other protocols to utilize the functionality
in the future.

Change-Id: Iae14beafd5f8f7dbe2c6ffd33700471b8a62b8da
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-01 11:21:04 +03:00
Szymon Janc 19ff3d3e37 Bluetooth: Print events opcodes as hex
This makes logs easier to read as those are defined as hex values.

Change-Id: I67f1dc0da9056a69398faf55fd5535a67ec4ebb9
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-06-30 16:05:59 +00:00
Arkadiusz Lichwa caf83c96ed Bluetooth: L2CAP: Make public helper for LE channel conversion
Replaces all occurences of LE_CHAN() macro with new name
BT_L2CAP_LE_CHAN() and makes it public.

Change-Id: I426b17b0214f7ab4b69e5febbdca1917f22e7487
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-06-30 09:06:35 +00:00
Szymon Janc 9c68fd4e5b Bluetooth: Add priority buffer for handling critical HCI events
Command Status, Command Complete and Number of Complete Packets are
used for driving TX fibers (HCI and connection). Missing any of
those event will lead to HCI traffic stall.

Priority pool will be used when critical HCI event is received
or normal pool runs out of buffers. The difference with priority
pool is that buffer from it must not be passed to RX fiber and
must be freed from bt_recv.

If driver knows HCI event opcode before requesting buffer for event
it may hint HCI core about preferred pool selection.

Change-Id: Iad14724945bb59721c5ffb6b62d5a8a3e3f70be7
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-06-29 14:51:51 +00:00
Luiz Augusto von Dentz e9083dfcd7 Bluetooth: GATT: Add flags to attribute write callback
This adds flags parameter to write callback which can be used to indicate
that data only need to be prepared with use of BT_GATT_WRITE_FLAG_PREPARE
fixing qualification tests that needs to check authorization or other
errors that cannot be verified with just the permissions.

Change-Id: I3d662b2027718ffb52a280e3bbc9750be14f89ae
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-06-28 17:36:08 +03:00
Arkadiusz Lichwa 0e782884a0 Bluetooth: ATT: Add helper for LE ATT channel conversion
Change-Id: I4dec2690924764c29445b788a097828cd8c63ca3
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-06-27 10:52:35 +00:00
Johan Hedberg fbb2fe8acf Bluetooth: Make random number generation API public
Applications or higher level profiles that are not part of the core
Bluetooth stack may need an easy way to generate random numbers. Since
we already have an internal helper for this export it for others to
use as well.

Change-Id: I29af7cab30ad8f60d481bc847984e781eaecd6bf
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-27 11:09:51 +03:00
Arkadiusz Lichwa 2178fc5ab3 Bluetooth: L2CAP: Add configuration response handler
Adds L2CAP configuration response protocol definitions to be able handle
response from remote in reaction to issued local request to exchange
MTU. Current optimistic path of configuration initiated from local
assumes to set MTU contract in one iteration.

Change-Id: If86d96b37e9cd888ad10a624a79c864a137e027d
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-06-24 10:07:24 +02:00
Arkadiusz Lichwa 69882759b8 Bluetooth: L2CAP: Initiate MTU configuration request
Triggers conditionally outgoing configuration request to start exchange
MTU just after incoming PSM connection request was aknowledged by local
host. If local MTU differs from default (672) add MTU option in request,
otherwise send empty configuration meaning default is wanted.

Change-Id: I4eb382cc496345c051967640422e926f595ce854
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-06-23 19:59:16 +00:00
Luiz Augusto von Dentz c116fc42e0 Bluetooth: ATT: Merge all permission check in one place
This merges callback checks with permissions checks so there are done in
one place.

Change-Id: Ic51b2be9cda67eac9e5dc1ebcbf6186ad5007bf4
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-06-21 14:56:04 +03:00
Arkadiusz Lichwa 8b1c837e28 Bluetooth: L2CAP: Handle incoming BR/EDR connection request
Enables L2CAP protocol definitions for connection request/response and
use it then to start handle incoming PSM connection request to valid
registered local PSM server. SDP PSM got no security restrictions.
The other PSM connections are validated against link encryption and
availability of SSP feature and if not matched are refused with
security error.

Change-Id: I429cf5dbce92300bd52639d5065e0144f8db4d13
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-06-21 07:41:27 +00:00
Johan Hedberg 8afe6078e1 Bluetooth: Avoid unnecessary indentation in read_remote_features_complete
Instead of having a dedicated branch for the success case jump to the
cleanup label in the inverse condition.

Change-Id: I271ce088a5b469d1fb96af1256fcafa5b1e6e2f7
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-20 13:39:28 +03:00
Arkadiusz Lichwa 16fda5f3d9 Bluetooth: Add support to read LMP remote features
Introduces HCI protocol defines to be able request and read remote LMP
features and if available extended data from peer when connected.

Change-Id: Ic274737d8b6c896eb9e83e2179829bcbadf6f635
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-06-20 10:13:03 +02:00
Luiz Augusto von Dentz 562b491182 Bluetooth: Add delay before sending Connection Update
BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part C] page 368:

  "The Peripheral device should not perform a Connection Parameter Update
   procedure within T GAP (conn_pause_peripheral) after establishing a
   connection."

> HCI Event: LE Meta Event (0x3e) plen 19 [hci1] 11:14:22.496358
      LE Connection Complete (0x01)
        Status: Success (0x00)
        Handle: 74
        Role: Slave (0x01)
        Peer address type: Public (0x00)
        Peer address: 7C:7A:91:18:82:46 (Intel Corporate)
        Connection interval: 70.00 msec (0x0038)
        Connection latency: 0.00 msec (0x0000)
        Supervision timeout: 420 msec (0x002a)
        Master clock accuracy: 0x01
...[5 seconds interval]...
< ACL Data TX: Handle 74 flags 0x00 dlen 16 [hci1] 11:14:27.493541
      LE L2CAP: Connection Parameter Update Request (0x12) ident 1 len 8
        Min interval: 24
        Max interval: 40
        Slave latency: 0
        Timeout multiplier: 42

Change-Id: Ibb301ea00c127542ba299ad0b94825ad1ed05c5c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-06-16 16:56:39 +03:00
Johan Hedberg 8ea57bd5d3 Bluetooth: Shorten limited discovery parameter name
The parameter is already inside a struct that's specific to BR/EDR
discovery, so there's no need to repeat "discovery" in its name.

Change-Id: Idb95788bfc9d62ecd52adecc35104e212724cb78
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-16 11:28:59 +03:00
Johan Hedberg 38564baf2f Bluetooth: Minor whitespace fix
Change-Id: Ia51eba21b0ba6f1a7a8ba45c76cd7a5224596870
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-16 10:58:50 +03:00
Johan Hedberg 1a756d6f8d Bluetooth: Fix validity check for Inquiry parameters
Since we only have a single user we can enforce length > 0x01. We
should also ensure that the results count is 1-255.

Change-Id: Id5d91acae06c6c6fc66dd59c0e367682a98dc08c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-16 10:58:50 +03:00
Johan Hedberg a6baf0651e Bluetooth: Pass Inquiry results array size to HCI_Inquiry
This way we avoid having to explicitly cancel the inquiry when we've
received the maximum amount of results.

Change-Id: I586cdd93f39042ac88384cfe6d2bf963ce8a1d99
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-16 10:39:47 +03:00
Johan Hedberg c2a5ab1917 Bluetooth: Add BR/EDR Inquiry length to bt_br_discovery_param
This way the application can control the maximum duration of the
Inquiry. The value 0x00 (which is invalid for HCI) is still accepted
for backwards compatibility and gets mapped to the old hard-coded 0x30
value.

Change-Id: Ibc9eb86bbb6c9e45b7b351278517b4a688015195
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-16 10:21:15 +03:00