For LE Privacy support we'll need to be able to distinguish which
addresses are RPAs and which are Identity Addresses.
Change-Id: Ie244a4d53ffddc435edbd6d69d7ecca205202f18
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We use addresses in lots of places and with LE we always need to pass
around the type in addition to the address value. Defining dedicated
types for addresses makes the code much simpler.
Change-Id: Ie8b495dce50e3f084685909c19acc5d08e2cca10
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When debug is enabled the cmd_rx fiber seems to cause exceptions some
times. Increasing its stack size seems to help.
Change-Id: I8152645f5904758b771ffe73b1112c77c8bfe924
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Now that bt_hci_send_cmd_sync() is safe to be called from the rx fiber
(used for all HCI events besides Command Complete/Status) we can move
the le_rand() usage to the key distribution stage instead of the
workaround of generating them prematurely.
Change-Id: I8bbc8dc78922a275a0c9982474d60b0693b29af2
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Now that there's the split of Command Complete/Status events from all
other RX data we don't anymore need dedicated per-connection RX
fibers. Remove these fibers and their associated FIFO and use
bt_l2cap_recv() directly from bt_conn_recv().
Change-Id: Ib9740e76200cfa40d46ee234f9693dcb7e8387fd
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
These events are special since they release any blocking
bt_hci_cmd_send_sync() calls. In order to be able to use the send_sync
API from HCI Event handlers without deadlocking having the Command
Complete/Status events processed through a dedicated fiber is
essential.
Change-Id: Id5c597d618bf326a8efb7c9ca2500af60a502d77
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
To prepare for a dedicated Command Complete/Status processing fiber,
add 'tx' to the existing names to differentiate from the 'rx' in the
upcoming names.
Change-Id: I59e0ba34502e4a2341396f81bfb5829c296b35a5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Unknown buffers are likely a bug, but we should still put them back to
the buffer pool. Also, there's no reason to stop running the fiber.
Change-Id: I413f9ff115689da9b1487bc622a8d26693cfd6d0
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
UUID types don't come from any spec so it is safe to have a enum which
can be changed whenever we want.
Change-Id: I7549f3a487191eeb847a239936f882ff88f4d345
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Length of "Test beacon" is 11 + 1 of type that should be 12 not 16.
In addition to that make the data variable static since they are only
used locally.
Change-Id: I2d7fb16cf7d383dafc9b083da6cd63a4d9be21c0
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The bt_hci_cmd_send_sync function will deadlock if called from within
the rx fiber. Add prevention for this when debug is enabled by
verifying that the calling context is not the rx fiber.
Change-Id: Ib94bd5c10185165d017fe0aeafbce46d503ad705
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There's no point in enabling BLUETOOTH_DEBUG_HCI_CORE for the samples
as the user/developer is unlikely to be interested in this specific
sub-module of the Bluetooth stack. The samples already have the
BLUETOOTH_DEBUG enabled, so leave it up to the user/developer to
decide if they want to add specific sub-module debug options.
Change-Id: I327086464561667a2462db0aab00d0ffcdd40d4c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add support for distributing our LTK to the remote side. Normally we
would generate the needed random bytes when the connection becomes
encrypted, however using bt_hci_cmd_send_sync() from a HCI event
handler (which the encryption_change is) is not possible and will
deadlock (because it needs to wait for a HCI command of its own to
complete). Instead, pre-generate the LTK as part of the SMP context
when we receive the SMP Random PDU from the remote.
Change-Id: Id9cc34b7ddfd1804626cf8bdc81c25aa8cc7943c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We shouldn't send any unknown bits or bits that we do not support.
Change-Id: Ia1c1cfd1e70ca879fd070b5fbcceef3b66ba8237
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add more defines needed to do key distribution and using correct
values for the authentication requirement.
Change-Id: I674c143d26ee31e9473c50c181c2947a305025fd
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We also need to store the EDiv & Rand values to be able to do correct
look-up of LTKs.
Change-Id: If6dbfc7569d18a4c8597a401deccad3ef8cb51ad
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We'll soon need to generate other amounts of random bytes than 16.
Update the le_rand() helper to generate any amount of random bytes.
Change-Id: I9295e6e3d79b0577c7bced31604a0fa45f1a9424
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
UUID defines, etc, will be needed by multiple files including GATT.
Change-Id: I855d3934242f54a8b5bf31652a4f8b9dfb63ef06
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Now that we have the connected/disconnected callbacks available for
L2CAP channels we can use these to associate the bt_conn with a
respective protocol-specific context.
Change-Id: I7c4d9a54f73ae7029a73372a1b0c93d473b28881
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add callbacks to notify L2CAP channels of connections, disconnections
and changes in the encryption state.
Change-Id: I66f86f20f551f01459abdbec6ccd214992828470
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We'll either way need various callbacks as well as get rid of the
channel-specific contexts in conn.h, so add a dynamic way of
registering fixed channels. The LE signaling channel is handled in the
same way as any other channel.
Change-Id: I5f8c1af3c8e3d107212becf507a5a6485838e081
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There will be various scenarios where we need to know what the current
encryption mode for a connection is.
Change-Id: I9836ffe51bfb6ebfc09497c7c716bd13a4064305
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The handles do not need ACL data-like decoding and the handlers should
be no-op for any non-zero status.
Change-Id: I40006ef7e5d01e8841ae0bebeda87755b2a32938
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Now that the logging macros use printf we can use more appropriate
format specifiers for various values.
Change-Id: I01025133b6a075f3478957a60163a1574cd85df7
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add an event handler for LTK requests that looks up the LTK using the
new bt_keys API.
Change-Id: Ifc4e5f96e84026d7e8c68eacb64154dc0a9c72b3
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Take advantage of the new bt_keys API to store the generated STK.
Change-Id: I7dc20c8581e55a98f2f4f804d3a01bc636364ad0
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add runtime storage of pairing related keys, along with a config
option to control how many pairings are supported.
Change-Id: Ib5177d2b6fbb0d2d458b539a3f1095c1dce135ff
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The s1() crypto function is used to generate keys for SMP Legacy
Pairing.
Change-Id: I839cb8210d8babe64551f8d958c97d0addd459b4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add a kernel config option to specify how many simultaneous
connections can be supported.
Change-Id: I963aacb7cece3436ecd5049683a19a350224a156
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
These may help debug early initialization issues.
Change-Id: I18a8043b2da46ec50f03fedfce46e48d9b41b373
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The BLUETOOTH_DEBUG config option bumps the stack sizes to cope with
printf requirements. Since all the logs use printf now they should
only be available with the bigger stack sizes to avoid surprises.
There are still basically two levels of log enabling where
BLUETOOTH_DEBUG enables the ERR/WARN/INFO everywhere and the
BLUETOOTH_DEBUG_* enables BT_DBG for a specific subset of the stack.
Change-Id: Ie8d64e47f44485efde32b40cd5bb34389c8e39da
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
printf() '%x' expects type 'unsigned int' for 'x', but parameter has
pointer type.
Change-Id: Id2d365a32b2e3e711359bd56741370d8167db868
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Encoding the L2CAP header when allocating the buffer means that we
must know the final size up-front. This is not always possible, so
move the header encoding to bt_l2cap_send() and only have the
bt_l2cap_create_pdu() function reserve enough headroom without
actually encoding anything.
Change-Id: Ic1c3b6b72c265cd0db4e835790fa915e0acd9388
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When we notify the controller of our ACL MTU we should subtract from
the buffer size not just the ACL header but also the headroom reserved
by the driver.
Change-Id: Id05b1becab3682425f9b591217ac29659a13a6d0
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add debug logs to the rx/tx fibers so issues relating to them can be
more easily debugged.
Change-Id: Ie02d3e760772a3e47ff495c47d83b23744202941
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add debug logs to the HCI core data handling to catch potential
issues.
Change-Id: I39bd3aeec9ed7b64156a9e2e899a153c0d484f38
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Including the context ID in debug logs can help track down various
issues, e.g. stack corruption.
Change-Id: I3cd70edd5bfd1d726f6d35e7331afb313cf3cacb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The printf API has a much richer support for various format
specifiers. Switch the Bluetooth logging macros to use printf instead
of printk and make sure STDOUT_CONSOLE gets selected when
BLUETOOTH_DEBUG is selected (so printf actually works).
Change-Id: I9a9818d51a677c6c79a35fef6daca7979f61c78d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The debug logs may cause a considerable overhead to stack utilization
(especially with printf). Increasing the fiber stack sizes when debug
is enabled decreases the chance of stack overflow.
Change-Id: I26e96c6516e0c1210e787cc5491fd5d59cbc75db
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix stack initialization.
When LE read buffer size returns 0 length LE buffers and controller
supports LE & BR/EDR functionality then ask controller about max ACL data
length it can accepts using BR/EDR read buffer size.
It should return value that can initialize LE MTU if that one still has 0.
Change-Id: Ib0bce89d47de5549d629a4ce771325e640443378
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Build peripheral app for targets: pentium4 and ti_lm3s6965
Change-Id: Id98c94217ad39e1716b8f8bc6031b8814bae06f3
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>