Commit graph

18591 commits

Author SHA1 Message Date
Jukka Rissanen
0179583391 net: Fix the include paths in Contiki sources
Fix the include paths in Contiki sources so that we do not
have to create links to include directories during compilation.

Change-Id: I9316f1e90474e0ee563557deadd0bdc321cbb0fa
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:46 -05:00
Jukka Rissanen
59e27cc9f8 net: Print more useful debug in dummy 15.4 driver
If the uart sending fails, then print more detailed info
so we can pin point the exact location where this sending failed.

Change-Id: I5548fb9af96455c60b58c7b956ebe01fe78da3ff
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:46 -05:00
Jukka Rissanen
31e5fccf30 net: Enable L2 buffers only when 802.15.4 is enabled
Because the L2 buffers are only used by 802.15.4 sub-system,
we must not compile and link them to the kernel.

Change-Id: Iab0352582ac1c57e0dd8f54ca8e757e47e4df3be
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:46 -05:00
Jukka Rissanen
2272312b8d net: Refactor code to use new generic net_buf API
Change-Id: Id008bbf43062ca0641a76edaabef47c650287444
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:46 -05:00
Mariusz Skamra
5fc0533414 Bluetooth: tester: Handle add descriptor command
This command will be used to add a descriptor to attributes database.

 >> send 2 4 0 02000302cccc
Received: hdr:  header(svc_id='\x02', op='\x04', ctrl_index='\x00',
							data_len=2)
Received data (hex): 04 00
Received data (ascii): ('\x04\x00',)

> ACL Data RX: Handle 64 flags 0x02 dlen 9
      ATT: Find Information Request (0x04) len 4
        Handle range: 0x0004-0x0004
< ACL Data TX: Handle 64 flags 0x00 dlen 10
      ATT: Find Information Response (0x05) len 5
        Format: UUID-16 (0x01)
        Handle: 0x0004
        UUID: Unknown (0xcccc)

Change-Id: I64b77ce735e2dff10ae15290fb174b7f99876014
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:46 -05:00
Mariusz Skamra
f83809991c Bluetooth: tester: Handle add included service command
This command is used by the tester to include service.
Service that is going to be included has to be already present
in the gatt database.

> ACL Data RX: Handle 64 flags 0x02 dlen 11
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x0001-0xffff
        Attribute type: Include (0x2802)
< ACL Data TX: Handle 64 flags 0x00 dlen 14
      ATT: Read By Type Response (0x09) len 9
        Attribute data length: 8
        Attribute data list: 1 entry
        Handle: 0x0007
        Value: 01000500aaaa

Change-Id: I12e1790be946c3cf10105c66a852da1cb23cf4bd
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:46 -05:00
Mariusz Skamra
6f047a7040 Bluetooth: Refactor adding attributes to the gatt database
This patch changes the way the attributes are added to the database.
From now, attributes will be registered one by one in gatt_db_add function.
This change is needed, because the handle of the attribute is assigned
in bt_gatt_register, and the tester application has to respond to the
command with valid attribute handles.
Moreover, Set Value command rely on the attribute handle, based on which
it looks for an attribute with handle spacified by tester to set it's
value.

Change-Id: I1f251f9bd5579bde2a52ebe3f1997da49c1b1721
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:46 -05:00
Mariusz Skamra
723405d685 Bluetooth: Add command to set the required Encryption Key Size
This will be needed to pass tests that require Insufficient Encryption
Key Size error response.

Change-Id: Ie358686d3a9843527e0c3dbd3918daed4e4d2f4c
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:46 -05:00
Grzegorz Kolodziejczyk
2e77f815f0 Bluetooth: Correct Device Disconnect Event opcode
The same opcode was used to Device Connected event.

Change-Id: I51640ed81822311817e82e43998c476795a28d49
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-02-05 20:24:46 -05:00
Grzegorz Kolodziejczyk
7c49f209b1 Bluetooth: Add possible values of addr type for GAP conn/disconn
This patch adds valid address types parameter for connect, disconnect
commands.

Change-Id: Ia54d503795c1ff04549f9813e197a1de923ef0bb
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-02-05 20:24:46 -05:00
Luiz Augusto von Dentz
bb27219ecb Bluetooth: ATT: Fix not releasing buffer before calling the callback
The cloned buffer is used to retry in case a security error happen but
since the buffer pool is now limited the callback may actually block if
it creates a new request which would need 2 buffers (original + clone)
but only one is available since the previous request clone is not
released yet.

Change-Id: Ife508b09c4b326b8213fd0b130ebf3c2e7fe47c9
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
b85593fb09 Bluetooth: Increase ATT buffers to count for buffer cloning
When sending ATT packets we may need to clone the original buffer.
Because of this one buffer per connection is not enough. Add one extra
buffer to the pool to cover for this.

Change-Id: I9fd9cb806f79ff99f1415a0fd7293ef0baf1d3f9
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
72e3b3fdb2 Bluetooth: uart: Simplify bt_uart_discard() with the help of min()
There's no need to do manual minumum calculation when there's the
min() helper available.

Change-Id: I4d5cfb088d9e6499750664680419ab4beb56e0d5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
1d92308078 Bluetooth: uart: Simplify send callback logic
We can remove the need for the extra 1-byte headroom by simply
directly writing the H:4 header with uart_poll_out(). Also the
separate uart_out() function can be removed by taking advantage of the
counters already present in the net_buf.

Change-Id: I54bd852e28f416b3de250cd9f8a126269cccfc14
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
f3214d3a1f Bluetooth: Kconfig: Add missing help texts
All user visible options should have at least some help text to them.

Change-Id: I97db035f2a4939b4d3c26b7260ad1a39351664b2
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
ec147cebfe Bluetooth: Kconfig: Fix comment about outgoing buffers
There's no BLUETOOTH_ACL_OUT_COUNT configuration option anymore so
update the text accordingly.

Change-Id: I431e3d63b8a3e9aebe855e4b5c0083e7d5e50f8b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
d6d8c3193a Bluetooth: Kconfig: Move BLUETOOTH_CONN selectors to a better place
It's move intuitive to have the BLUETOOTH_CONN selectors right before
the section for choosing options that depend on them.

Change-Id: If3d1a1fcb9c78d715b502b58fba9293ca69d0835
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
600a3d3f8b Bluetooth: Kconfig: Move debug options into separate section
This makes it easier to visualize all debug options under a single
sub-menu.

Change-Id: If69a71138450a4cae24ede2c110f42ced9ee762f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
4810bb1b16 Bluetooth: Kconfig: Clean up and remove redundancies
Clean up and remove redundancies in Kconfig. Many 'depends on'
statements can be removed by moving entries behind common if-endif
blocks.

Change-Id: Iaa1c4e717e8353f4c09e991413588cf840281c5d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
9af971ac0a Bluetooth: Clean up hci_core.c include order
The stack.h will eventually be moved to a generic place. Also separate
BLUETOOTH_CONN includes clearly.

Change-Id: I52bf657ac6458c3a7c99a462d17e4a0d420d709f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
bf0dd9a969 Bluetooth: Fix using right define for event buffer size
The right size for event buffers is EVT_BUF_SIZE.

Change-Id: I7cc9c43b6699aafac8b8deccfe87f5390c09ccfa
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Jukka Rissanen
0b9736dce4 net: contiki: Add debug function to print buffer content
Change-Id: I04c76798394651f9026d869e3a9491c4e452b396
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:45 -05:00
Jukka Rissanen
a2a702a986 net: 802.15.4: Dummy radio driver must reset status on error
In order to avoid memory corruption, the dummy 802.15.4 radio
must reset its internal state when there is an error when
reading packet data from UART.

Change-Id: Ifeba5181f014426b95d21e5726c638eae555b649
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
c9f1ce2639 Bluetooth: Increase default ATT MTU when possible
The 23 bytes default is quite limiting. When SMP has been enabled we
can do a bit better since we know that we can fit two complete ACL
packets to the buffers (23 bytes payload in the first, and 27 in the
second).

Change-Id: I71d9c484c962b1ff46d325f7182511f168608b8e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
3bc43254e0 Bluetooth: Use event/cmd lengths instead of buffer sizes in KConfig
It's more intuitive to specify needed command or event lengths rather
than the raw buffer size in Kconfig. The exact buffer size calculation
can be done in the code itself.

Change-Id: I2760cc1182a689b26405e4c2b1428f140b4aa88a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
8167ababe0 Bluetooth: Make Kconfig buffer sizes follow MTU sizes
It's more intuitive to specify needed MTU sizes instead of raw buffer
sizes. The exact buffer size calculations can instead be made
internally in the code (using the BT_L2CAP_BUF_SIZE helper macro).

Change-Id: I0637340a7d99e04020f57f49ecd8e6dcfcc4bcf4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
50256ea514 Bluetooth: Move BT_L2CAP_BUF_SIZE to a more appropriate place
This doesn't need to be exposed in the public API.

Change-Id: Ib6d4336684620bd1e03d128765f289b5ebd744ef
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
1ba3350157 Bluetooth: Fix leaving empty header space in ACL fragments
The outgoing fragments don't need to reserve space for the L2CAP
header since we're copying from an original buffer that already has
this header (and continuation fragments don't have it a all).

Change-Id: I3ce18bf45f2a31f5ab3db395a506e35aa246762b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
6d1864c55d Bluetooth: Make create_frag() responsible for copying data
We can simplify & shorten the code by doing the copying from the
original buffer straight in the create_frag() function.

Change-Id: I8e7676642a13095783071275fbccc248f55e245c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
03d9aa4ecc Bluetooth: Fix double-free when sending ACL buffers
When send_frag() is given the original buffer (from tx_fiber) the
tx_fiber itself takes care of unrefing in case of failure. We need to
therefore instruct send_frag() when it can fully assume to own the
buffer (in case it's a separately created fragment) and when it should
leave it alone in case of failure (when it's the original tx buffer).

Change-Id: If4804e1fe19a9c7a0aa0694fdc2cbb58b10ece2b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
7a39d44577 Bluetooth: Move ACL fragmentation from bt_conn_send to tx fiber
This way we're both able to properly utilize the fragments pool as
well as ensure that no two buffers for this connection end up being
fragmented into the tx_queue in an interleaved fashion (which would
just confuse the controller).

Change-Id: I3934cd3fbfc5e190d61475eb691a34a2df13ed74
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
f6bfb4377e Bluetooth: Fix buffer leak in bt_conn_send
Since bt_conn_send doesn't currently return an error code it must be
assumed to consume the buffer no matter what. The only failure
condition is the "not connected" case, so make sure the buffer is
unreffed there.

Change-Id: I30e9a81d6f801a67d90ab59c1040b6f55261e71c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
b9d13664ab Bluetooth: Create protocol-specific outgoing ACL buffer pools
With this split we get better control of the buffer sizes and counts.
We also anyway will need a fragments pool so a simple generic ACL_OUT
pool doesn't make sense anymore. The related Kconfig options for that
have been removed.

Change-Id: I616cf49915a1cc0dc0ddc724e2e182bcbe0c80f6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
1f6841c9c1 Bluetooth: Convert driver header info to hidden Kconfig options
We know the needed values at build-time, so there's no point in having
a runtime mechanism of accessing them in the code. Having the values
as defines makes it e.g. possible to use them as input for defining
the size of buffer pools.

Change-Id: Ib7556644719bfb631e638fa5bf29f3d1747a5072
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
4599fa1db3 Bluetooth: Move ACL_OUT buffer management to conn.c
This seems like a more appropriate place, and it's where we'll anyway
need to manage a separate pool for ACL_OUT fragments.

Change-Id: I6e0e2ec67d2f89a7f09787a3674405570d9b9cce
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Johan Hedberg
32f5826a1b Bluetooth: Add bt_conn_init() API
This helps move the ACL_OUT buffer management into conn.c.

Change-Id: Ie5ef48e02eeef5077f433e42c1e2eba9bdb94f63
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:45 -05:00
Mariusz Skamra
992237bc51 Bluetooth: Add bt_conn_enc_key_size function
This patch adds bt_conn_enc_key_size function which will be used
by application to check encryption keys size of a encrypted connection.
This will be used especialy by GATT applications, because some
attributes to be accessed require encryption with specified
minimum encryption key length.

> ACL Data RX: Handle 64 flags 0x02 dlen 7         [hci0] 708547.536685
      ATT: Read Request (0x0a) len 2
        Handle: 0x0003
< ACL Data TX: Handle 64 flags 0x00 dlen 9         [hci0] 708547.544302
      ATT: Error Response (0x01) len 4
        Read Request (0x0a)
        Handle: 0x0003
        Error: Insufficient Encryption Key Size (0x0c)

Change-Id: Idbc9afde7ec80504898bd8d1e193f3e71a93f3f9
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:45 -05:00
Szymon Janc
89cfd86f2f Bluetooth: SMP: Fix using JustWorks when MITM was required
JustWorks pairing should be forced only if both sides don't require
MITM. Code checking this was incorrect and forced JustWorks even if
one side required MITM.

Change-Id: I70312b6832218f430546896ae1f2283ae6ce7c60
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:45 -05:00
Szymon Janc
1baada5589 Bluetooth: Remove not needed key look-up in update_sec_level
Keys in struct conn are set before encryption is enabled so there is
no need to look-up those every time security level is updated.

Change-Id: Ib0edb3c40fd2c5deca00055ed3f3ae7414a5df8e
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:45 -05:00
Szymon Janc
47e3db235d Bluetooth: Fix not setting keys for connection as master
If no keys are set for connection look-up it done. If keys are already
present there is no need for another look-up.

Change-Id: I0518772c4c9d8458b4b79aa7cb34a049324fb552
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:44 -05:00
Johan Hedberg
3cae902928 Bluetooth: Make HCI driver send() consume the given buffer
It is more intuitive to assume that the driver send() consumes (takes
ownership) of the buffer given to it.

Change-Id: I53d9cbebc0564d1d11110fc78a62ce0bbb3cdfd2
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:44 -05:00
Arkadiusz Lichwa
555d0d2594 Bluetooth: Refactor bt_conn struct
Isolates existing LE connection specific attributes and
prepares for now empty BR/EDR specific connection internals.

Change-Id: Ib423306fbf60e8451998e3933aee00cb672a1106
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:24:44 -05:00
Mariusz Skamra
f3f63d0fb0 Bluetooth: Cleanup comments in GATT API
This removes some outdated comments, adds missing ones
and fixes some major typos.

Change-Id: I3e6c0c1b88c67852fc8c24eb2ff35d74af8bc656
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:24:44 -05:00
Arkadiusz Lichwa
4970defaa4 Bluetooth: Refactor br_init()
Don't jump to BR/EDR read buffer size if LE read buffer size
returned LE data packet length value > 0 in le_init().

Change-Id: If0efa9f239ef75d832cf0f89ae6f227788cbf175
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:24:44 -05:00
Arkadiusz Lichwa
99bd06deaa Bluetooth: Refactor bt_dev struct
Groups LE stack specific values.

Change-Id: Ia947d25c105f518287293b4f870466daa416385c
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:24:44 -05:00
Johan Hedberg
20d946efa8 net: buf: Fix minor typo
Change-Id: Ibe47982cf3aeb1f4e2d700c4e7d11a77991ef6df
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:44 -05:00
Johan Hedberg
72050e2352 net: buf: Require destroy callbacks to handle returning to free FIFO
There could be cases where the destroy callback needs more
fine-grained control of step ordering than "1. destroy, 2. put back to
free FIFO". One case could be when the the pool needs to be protected
by a microkernel mutex or semaphore. In such a case the putting back
to the FIFO may need to happen before a custom action in the destroy
callback.

Making the destroy callback responsible for returning to the free FIFO
gives full flexibility regarding the order of the cleanup actions.

Change-Id: Ib9532d1dd70e0a2042af54ebd3e40a853dd42d33
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:44 -05:00
Luiz Augusto von Dentz
47fd65fdcf Bluetooth: L2CAP: Add #ifdef for l2cap_chan_le_recv
l2cap_chan_le_recv and related code should only be compiled if
CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL is defined.

Change-Id: Ia83e2010cdf251afc0a5cbf24b54173926de84c5
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:44 -05:00
Luiz Augusto von Dentz
8eaae649a7 Bluetooth: L2CAP: Fix documentation of bt_l2cap_server_register
Fix format of bt_l2cap_server_register documentation.

Change-Id: I22322a235bb1d6b6752bfe13ce8e305481649125
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:24:44 -05:00
Johan Hedberg
a8bd3c358d Bluetooth: Fix missing sem_give() for ncmd when driver send() fails
If we fail to send an HCI command to the HCI driver we should give back the
semaphore that counts available commands.

Change-Id: I4aedf662c8b96d57ebafeb471deeb911c5f8ac7a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:44 -05:00