Commit graph

18591 commits

Author SHA1 Message Date
Arkadiusz Lichwa
c4a503b6b4 Bluetooth: BR/EDR: Use correct ACL Tx MTU and semaphore
Selects right ACL Tx MTU and semaphor based on connection link type
and indirectly controller buffers capabilities.

Change-Id: I1df1ba81e6b09d9d5bdcd34a93d9a3d255133143
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:24:51 -05:00
Arkadiusz Lichwa
746ae052ca Bluetooth: Refactor ACL Tx packet users
Make and use helper functions to get ACL Tx packets max length (MTU)
and get semaphore syncing out Tx packet to controller.

Change-Id: I52f60a71c6b179ff300b4fd21da27174e9d825d9
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:24:51 -05:00
Luiz Augusto von Dentz
7d2d2838fb Bluetooth: L2CAP: Implement segmentation for incoming packets
If the SDU length is bigger than the amount data received in the first
packet it means it will be segmented in 2 or more packet until the SDU
is completed.

Since the MTU required by the upper layer could be much bigger than the
ACL buffer the code now request a buffer to reassemble the SDU.

Change-Id: I286d16e185f59a8128c4357dddebdc13145dfe31
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:51 -05:00
Luiz Augusto von Dentz
81af3feb01 Bluetooth: L2CAP: Use semaphore to control credits
This use struct nano_sem to control the credits so when sending if the
credits hit zero it now waits more credits to continue instead of
failing.

Change-Id: I2da4692eaa16828f74a1df4346583258bb4cf8f0
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:51 -05:00
Luiz Augusto von Dentz
8f48f02cae Bluetooth: Add l2cap-send command to btshell
l2cap-send can be used to send data when connecting to an L2CAP channel:

btshell> l2cap-send 3
bt: bt_l2cap_chan_send (0x00114b0c): chan 0x00112824 buf 0x00112b00 len 23
bt: l2cap_chan_create_seg (0x00114b0c): chan 0x00112824 seg 0x001124f8 len 23
bt: l2cap_chan_le_send (0x00114b0c): chan 0x00112824 cid 0x0040 len 23 credits 7
bt: l2cap_chan_le_send (0x00114b0c): chan 0x00112824 cid 0x0040 len 2 credits 6
bt: bt_l2cap_chan_send (0x00114b0c): chan 0x00112824 buf 0x00112b00 len 23
bt: l2cap_chan_create_seg (0x00114b0c): chan 0x00112824 seg 0x001124f8 len 23
bt: l2cap_chan_le_send (0x00114b0c): chan 0x00112824 cid 0x0040 len 23 credits 5
bt: l2cap_chan_le_send (0x00114b0c): chan 0x00112824 cid 0x0040 len 2 credits 4
bt: bt_l2cap_chan_send (0x00114b0c): chan 0x00112824 buf 0x00112b00 len 23
bt: l2cap_chan_create_seg (0x00114b0c): chan 0x00112824 seg 0x001124f8 len 23
bt: l2cap_chan_le_send (0x00114b0c): chan 0x00112824 cid 0x0040 len 23 credits 3
bt: l2cap_chan_le_send (0x00114b0c): chan 0x00112824 cid 0x0040 len 2 credits 2

Change-Id: Ibc970d1ffd8c407c66b35e9f3bf49ccf826f7472
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:51 -05:00
Luiz Augusto von Dentz
6a4affef19 Bluetooth: L2CAP: Add bt_l2cap_chan_send
This adds bt_l2cap_chan_send which can be used to send data to
dynamic channels resulting in the following trace:

< ACL Data TX: Handle 3585 flags 0x01 dlen 17
      Channel: 64 len 24 [PSM 128 mode 0] {chan 5}
        a0 02 ff ff ff ff ff ff ff ff ff ff ff ff ff ff  ................
        ff ff ff ff ff ff ff ff                          ........

Change-Id: I753e301b1125ef21a345ab96470f15bc53a4869a
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:51 -05:00
Mariusz Skamra
e54d74f696 Bluetooth: tester: Lookup for service handle while adding characteristic
Add characterictic command requires to provide service ID to which this
characteristic shall be added. With this patch initialization will
succeed only if service with given ID exists.

Change-Id: Ie6223f293b4cac06f211556d29896b2e1ccd96ac
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:51 -05:00
Arkadiusz Lichwa
375d8e4377 Bluetooth: BR/EDR: Supplement conn object with link type
Adds support to connection object allowing to set the link type.
At the moment only LE link is used since LE connection handling
is implemented when BR/EDR support is enabled.

Change-Id: I5204a93670308b0151deaa98106a1551b9b39493
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:24:51 -05:00
Arkadiusz Lichwa
17fcf67422 Bluetooth: BR/EDR: Initialize ACL Tx semaphore
Defines dedicated semaphore for sync ACL packets out.

Change-Id: I114daad24cd75fa4165128eab697af382ea10c3a
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:24:51 -05:00
Grzegorz Kolodziejczyk
dc82c46ea8 Bluetooth: Fix checking response len in read by type
Error should be responded if no previous attribute of the same type was
read (added to response buffer). In case if previous attributes were
added to buffer no error should be responded and read initiator should
perform read by type with increased start handle.

Change-Id: I31c4469e172a496890f049d9304a03673506c5f3
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-02-05 20:24:51 -05:00
Grzegorz Kolodziejczyk
559f7a07f3 Bluetooth: Add handling connect command for tester
This patch adds support for handling connect command in tester
application.

Change-Id: Ia35bcb33caf59b8df4a3cdc01c12d58fdeeecfe9
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-02-05 20:24:51 -05:00
Mariusz Skamra
50a13c5fc1 Bluetooth: tester: Handle Set Encryption Key Size command
This patch adds a command to the tester application that sets the
required encryption key size to access characteristic value or
descriptor.

> ACL Data RX: Handle 64 flags 0x02 dlen 8    [hci0] 16139.016504
      ATT: Write Request (0x12) len 3
        Handle: 0x0004
          Data: be
< ACL Data TX: Handle 64 flags 0x00 dlen 9    [hci0] 16139.024052
      ATT: Error Response (0x01) len 4
        Write Request (0x12)
        Handle: 0x0004
        Error: Insufficient Encryption Key Size (0x0c)

Change-Id: Ida8b0fdaffe2b1a941a0b87c8a11395a8b63ccd0
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:51 -05:00
Szymon Janc
71fe9c1994 Bluetooth: Allow to require FIPS security level for connection
If local IO capabilities allow MITM and LE SC is enabled then
FIPS level is reachable.

Change-Id: Icfb32fbffa0355117b6723d641a6d3db38feb87d
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:51 -05:00
Szymon Janc
cd1ed791b4 Bluetooth: Set correct security level for LE SC
If P256 key is present then authenticated link has FIPS security level.

Change-Id: Iaf50b83ac6973bbd40e5ef57bf1e6375eedf6b12
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:51 -05:00
Szymon Janc
ab81fe9d45 Bluetooth: SMP: Add LE SC smp_g6 init test
This runs smp_g2 function with test vectors from Core
Specification 4.2.

Change-Id: I96ef51e9133182a38c3fd007764bdd633d8f9e3f
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:51 -05:00
Szymon Janc
16e7c44fb2 Bluetooth: Add support for passkey confirmation in btshell
This allows to display passkey and confirm if it matches remote
device.

Change-Id: I22f706b6441210ef426702ec290a05112e06a4e2
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:51 -05:00
Szymon Janc
5720958d97 Bluetooth: SMP: Add support for passkey confirmation from user
This patch allows user to confirm or reject passkey. If passkey was
confirmed we proceed with pairing (depending on SMP state). If
passkey isn't confirmed pairing is cancelled.

Change-Id: I7a286b51957bee1064342625f2bc3f04124a82de
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:51 -05:00
Szymon Janc
f342a9af34 Bluetooth: SMP: Add initial support for Passkey Confirmation
This add support for generating Passkey for confirmation.

Change-Id: I3b66675a5410292ebe05c66d77e7b4c7a95a2896
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:51 -05:00
Szymon Janc
48249bf34a Bluetooth: Add public API for passkey confirmation
This allows to request user to confirm displayed passkey with remote
device. This allows to have authenticated LE SC link resulting in FIPS
security level.

Change-Id: I5b6c1666e3d1687cc04c5d66529372db090dd000
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:51 -05:00
Mariusz Skamra
9fecda938a Bluetooth: gatt: Add missing error handling
The attribute protocol Read By Type is used to perform
Read Using Characteristic UUID procedure. This procedure
is used to read characteristic value if Characteristic Value UUID
is known, while handle is not known.
Errors received from application like Insufficient Encryption
Key Size must be send as a response to Read By Type Request

> ACL Data RX: Handle 64 flags 0x02 dlen 11                                                                                                                          [hci0] 94382.244804
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x0003-0x0003
        Attribute type: Unknown (0xaa51)
< ACL Data TX: Handle 64 flags 0x00 dlen 9                                                                                                                           [hci0] 94382.255987
      ATT: Error Response (0x01) len 4
        Read By Type Request (0x08)
        Handle: 0x0003
        Error: Insufficient Encryption Key Size (0x0c)

With this patch we can pass TC_GAR_SR_BI_11_C test.

Change-Id: Id47109f673cb725b2edd9cc0e154cc055fc8d0ef
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:51 -05:00
Szymon Janc
5872a2094e Bluetooth: SMP: Fix remote DHKey check calculation
In smp_f6 local and remote random was in wrong order in
bt_smp_dhkey_ready.

Change-Id: Iba6ee6595c1d8e873d72571d1e4fb3d0c0b9717e
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:51 -05:00
Grzegorz Kolodziejczyk
04c03c1a92 Bluetooth: Fix read by type request attr permissions handling
This patch fixes checking permissions and sending response to read by
type request. If multiple (or if one is found) attributess are found
within handle range and first of them don't have read permission,
error should be send. If any of attribute don't have read permission
but isn't first in set, the attributes before this attribute should
be returned.

Change-Id: I532a8701521505c02845de5db62c94f7edc9d567
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-02-05 20:24:51 -05:00
Jukka Rissanen
36c372d8cd net: 802.15.4: Loopback test app needs bigger TX fiber stack
Because of the way the loopback tester works, it needs much
bigger stack when sending packets in TX fiber.

Change-Id: I360f0cf1f35e654cb139565f19f24628fb5ab5ee
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:51 -05:00
Jukka Rissanen
9a2927ac57 net: contiki: Handle 802.15.4 retransmissions properly
When the 802.15.4 radio driver tells there was a TX collision,
we must resend the frame. The resent and failed network packets
were not freed properly which eventually eat all memory reserved
for this purpose. Now the resent frames are discarded after
resending has failed couple of times.

Change-Id: I421e680605a0d164272a786edf8e15fe4c712d03
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:50 -05:00
Jukka Rissanen
bdc14da01a net: Timer fiber stack increased to 1536 bytes
The earlier 1kb stack was too small.

Change-Id: Iaa0b6e375cc79a7066bee9ec3a114246fb2ed377
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:50 -05:00
Jukka Rissanen
99a9a55aee net: Fix timer fiber that was missing events
We run event timers (etimers) checker every two ticks in order
not to loose events that are scheduled in very short intervals.
These events can come for example when network driver wants
to resend network packets.

Change-Id: Id48977f4de66583351551b5bf403d6e230d189c0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:50 -05:00
Jukka Rissanen
53c43ebe45 net: Initialize the callback timers
The ctimers are not run without this. Callback timers are
used for example when retransmitting network packets.

Change-Id: Iae55848e615814d89573df326a2c20bb8ca88230
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:50 -05:00
Jukka Rissanen
9026763fab net: 802.15.4: Decreasing transmit stack to 1536 bytes
The 4kb stack was too big so setting the stack to 1536 bytes.

Change-Id: I648d826225dd6312bba15100acf79e3783609d7a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:50 -05:00
Jukka Rissanen
9e675cf7c6 net: contiki: export ctimer_process so it can be called
We need to export ctimer_process so that net_core.c can
call it and let it set the corresponding event timers.
Without this the timers would not be called properly.

Change-Id: I623b60420eacfe326f6b18d89f3e008cc56379fc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:50 -05:00
Jukka Rissanen
b148130cdb net: contiki: Add clock function to busy wait a timeout
Add a function that allows the code to busy wait usec timeout.

Change-Id: I6c0bbe33a98d45c58667e1400e0ebcdc59d28bad
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:50 -05:00
Ravi kumar Veeramally
845dd9614a net: apps: Remove testcase.ini temporarily
Remove testcase.ini from net/test/test_15_4 from microkernel
version temporarily.

Change-Id: I1ee5d80142c6b2210629842e5e8d83370299657d
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:24:50 -05:00
Grzegorz Kolodziejczyk
d475229b4d Bluetooth: Refactor disconnect command
This patch adds missing connection unref in disconnect command. Also
lightly status setting was refactored.

Change-Id: Ic2502d8df15e45c4aea25632642af3d8a4fb23cc
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-02-05 20:24:50 -05:00
Grzegorz Kolodziejczyk
b11d431d98 Bluetooth: Add missing packed attribute to cmd/ev structs
This patch adds missing packed attribute to structures.

Change-Id: I9bcc8a677ae296e41eebb530584977660df52ebf
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-02-05 20:24:50 -05:00
Szymon Janc
e50e874ee4 Bluetooth: SMP: Fix missing timer restart on sending DHKey check
SMP timer should be restarted every time SMP PDU is send. To avoid
such issues in new code provide smp_send() helper that will always
restart timer. Only exceptions are Security Request and Pairing Failed
commands as those don't restart timer.

Change-Id: I96a7cd72b2249d25d1c3f9e8b3fbf1e74dc76222
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:50 -05:00
Szymon Janc
0480ecf7c4 Bluetooth: SMP: Always send error if DHKey generation failed
There is no point in going with pairing any further regardless of when
bt_smp_dhkey_ready was  called.

Change-Id: I0e0c71e91ecf36f74b429d9455a2f21161939069
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:50 -05:00
Szymon Janc
f2c4f06b15 Bluetooth: SMP: Refactor Pairing Failed sending
smp_reset is always called after Pairing Failed was sent so just
move it inside this function. This makes sure that new code won't
be missing reset after error. Also rename send_err_rsp to smp_error
as it now accept smp context instead of conn.

Change-Id: I25cdca066817f79f6c2f83d9f9bd0876b7909085
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:50 -05:00
Szymon Janc
7955cf9911 Bluetooth: SMP: Fix not reseting context after pairing failed
If Pairing Failed was send we should reset SMP context to be able to
restart pairing if needed.

Change-Id: Iea524ccf841ceba8a1194d94ead9c7256331ad14
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:50 -05:00
Szymon Janc
531e594217 Bluetooth: SMP: Correct comment for SMP_FLAG_DHKEY_SEND
This flag means that DHKey check should be generated and send on
next event.

Change-Id: I0dc9aa3713ad17ceabc4f5f890afa32f538f714f
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:50 -05:00
Arkadiusz Lichwa
0394ec6730 Bluetooth: ATT: Fix error handling on prepare write response
Don't generate error response for invalid offset or invalid
attribute value during queued write requests.
According to BT SIG specification such response needs to be done when
execute write request is performed.

Change-Id: If480228dc98f5713891b45b3f5ca31990cf5c633
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:24:50 -05:00
Szymon Janc
744cb36d79 Bluetooth: SMP: Fix setting pairing method for LE SC
request_tk is called only for legacy pairing. Due to this pairing
method must be selected in pairing request or response handler to
cover LE SC case. But it must be selected only after it is known if
pairing is legacy or LE SC.

Change-Id: I0418a679b73c199acff12795157389d5969adb05
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:50 -05:00
Szymon Janc
747a672d56 Bluetooth: SMP: Fix LE SC pairing method lookup
If both sides have KeyboardDisplay capabilities Passkey Confirmation
should be used.

Change-Id: I69d0909831cab0340ecbb418f035414b18e8c0c0
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:50 -05:00
Johan Hedberg
70742bdda8 Bluetooth: Perform check for BR/EDR support in a common place
Both of the br_init() functions should be checking for BR/EDR support
before issuing the commands. To not have to code the check twice, do
it in hci_init() before calling br_init().

Change-Id: I2de3aa3c2e85322257b27b1c716b37c326d5bae7
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:50 -05:00
Mariusz Skamra
5b58da915e Bluetooth: Extend BTP specification to cover GATT Client tests
This patch extends Bluetooth Testing Protocol with commands used
while testing IUT as GATT client.

Commands are mapped to the procedures from Core Specification to make
use of Read Supported Commands command. Based on the response to this
command tester can determine which PTS test cases should be enabled.
If the IUT don't support eg. Reliable Writes, this command won't be
set in Read Supported Commands response, so that test cases that
test this functionality won't be executed.

Change-Id: I204a295698d4b69f73d0556b172770c4fd018009
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:50 -05:00
Arkadiusz Lichwa
ffda52a7cd Bluetooth: BR/EDR: Get max ACL packet length
Uses dedicated initializing routine to start getting controller's
internal buffer capabilities. At first initialize ACL packet length
(MTU) with max value controller can accept.

Change-Id: If90dd16ebb5c0751fb65555b06c9fb18ed394a54
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:24:50 -05:00
Arkadiusz Lichwa
0c3c6ddd90 Bluetooth: BR/EDR: Make room for controller internals
Defines instance for controller specific information.
Prepare room for max ACL packet length controller can get.

Change-Id: I5fb5f83b3f7383337b6b86683dff05b675815b98
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:24:50 -05:00
Arkadiusz Lichwa
a34d114085 Bluetooth: Refactor init LE ACL Tx semaphore
Moves initialization of bt_dev.le.pkts_sem object to handlers reading
controller buffer capabilities. Therefore no need to keep anymore
bt_dev.le.pkts member.

Change-Id: I126cb1d9ad9feed9c11f35b26c44055075734685
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:24:50 -05:00
Mariusz Skamra
05426296ee Bluetooth: tester: Fix invalid type of buffer length
Buffer size is 512, so uint16 type shall be used to store it's length.

Change-Id: I5abaf7d783032ff41819f7b838d4016932dece20
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:50 -05:00
Mariusz Skamra
f47b828be7 Bluetooth: tester: Factor out helper for converting uuid to bt_uuid
This patch separates helper for converting uuid received from btp
command to bt_uuid.

Change-Id: If7f5423a839379763928ba5e87678697b1721d83
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:50 -05:00
Szymon Janc
a204dd7bc3 Bluetooth: SMP: Reduce stack usage of cmac_subkey
This removes extra zero buffer and reuses l as initial zero buffer.
This reduces stack usage from:
rx stack (real size 1024):      unused 96     usage 896 / 992 (90 %)
to
rx stack (real size 1024):      unused 112    usage 880 / 992 (88 %)
when using LE SC.

Change-Id: I961e4270f7b86b6d2615e23d6ace9cc81026eaf7
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:50 -05:00
Szymon Janc
1e67671152 Bluetooth: SMP: Reduce rx fiber stack usage
Mark constants used in crypto as static const. This reduced stack
usage from:
rx stack (real size 1024):      unused 20     usage 972 / 992 (97 %)
to
rx stack (real size 1024):      unused 96     usage 896 / 992 (90 %)
when using LE SC.

Change-Id: Iac39ccb91cc94508fa36243d477f6df787250527
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:50 -05:00