Commit Graph

1532 Commits

Author SHA1 Message Date
Jukka Rissanen 9641a0fed0 net: rpl: Enable timer debugging via Kconfig
User can activate RPL timer debugging by setting
CONFIG_NETWORK_IP_STACK_DEBUG_RPL_TIMERS config option.

Change-Id: I66079640e4135a0f85620cc4eca04612eee1a890
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-17 07:29:54 +00:00
Jukka Rissanen d19f08f104 net: rpl: Enable objective function debugging via Kconfig
User can activate RPL OF debugging by setting
CONFIG_NETWORK_IP_STACK_DEBUG_RPL_OF config option.

Change-Id: I9c7b59eb6d782702b5a9159f4915d3f58f732d5c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-17 07:29:45 +00:00
Jukka Rissanen 079be6caf2 net: rpl: Enable RPL ICMPv6 packet debugging via Kconfig
User can activate ICMPv6 RPL debugging by setting
CONFIG_NETWORK_IP_STACK_DEBUG_RPL_ICMPV6 config option.

Change-Id: I957ec5d32149ede00f87f63de28a4a7f43936c1a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-17 07:29:34 +00:00
Jukka Rissanen 063f113f83 net: rpl: Fix compile error if ICMPv6 debugging is activated
Change-Id: Id97d1eaaa529b3c79cf2fdbff10148c693e467d5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-17 07:29:16 +00:00
Jukka Rissanen d5cf9e4edb net: rpl: Enable debugging via Kconfig
User can activate generic RPL debugging by setting
CONFIG_NETWORK_IP_STACK_DEBUG_RPL config option.

Change-Id: I3b044c6308d6f20cb42d21edb59119321aa8bfbb
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-17 07:29:16 +00:00
Jukka Rissanen 5cef4d13eb net: 802.15.4: User can select desired RDC plugin
User is able to use either sicslowmac or nullrdc plugin for
RDC (Radio Duty Cycle) layer. Default is sicslowmac.

Change-Id: I51f72f0d5de67a271178b51f29644bea39ffa19f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-16 15:25:35 +00:00
Jukka Rissanen a0d9613033 net: contiki: Fix debug prints in MAC layer files
Make debug messages fit in one line which is much more readable.

Change-Id: Ia0087bdea03d2eb34fca104850cf3acd3f61ebe6
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-16 15:25:27 +00:00
Jukka Rissanen 2ec63ec481 net: Add debug configuration for 802.15.4 network driver
User can toggle 802.15.4 network driver debugging from Kconfig.

Change-Id: I63f8e319172bce0561123416d18397468da671bf
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-16 15:25:16 +00:00
Jukka Rissanen 978b880e48 net: Allow user to activate 802.15.4 packet framing debug
User can set CONFIG_NETWORK_IP_STACK_DEBUG_15_4_FRAMING
to get debugs from 802.15.4 packet framing code.

Change-Id: I58155df19b6d63686a96ea410801d45632eb566b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-16 15:25:06 +00:00
Jukka Rissanen ffcfe9c44f net: Allow user to activate 802.15.4 MAC layer debugging
User can set CONFIG_NETWORK_IP_STACK_DEBUG_15_4_MAC
to get debugs from 802.15.4 MAC layer code.

Change-Id: Ie385c586caad1602869260146a1ea92d961b73c3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-16 15:24:53 +00:00
Jukka Rissanen 54c1bd92f9 net: Allow user to activate 6lowpan compression debug
User can set CONFIG_NETWORK_IP_STACK_DEBUG_6LOWPAN_COMPRESSION
to get debugs from generic 6lowpan fragmentation code.
The generic code is shared between 802.15.4 and Bluetooth
bearers.

Change-Id: Iae6dcebe8fb4269e15bac5dcec2b63e79b4abcd3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-16 15:24:44 +00:00
Jukka Rissanen b7c6c2198f net: Allow user to activate 802.15.4 6lowpan frag debug
User can set CONFIG_NETWORK_IP_STACK_DEBUG_15_4_6LOWPAN_FRAG
to get debugs from 802.15.4 6lowpan fragmentation code.

Change-Id: I3a199cf9e5696a1017a290d182a0d7176b1c259e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-16 15:24:44 +00:00
Jukka Rissanen 7d805482c3 net: Kconfig debug option for debugging received and sent data
User can activate debugging in network stack when packets are
received and sent by setting CONFIG_NETWORK_IP_STACK_DEBUG_RECV_SEND
option in config file.

Change-Id: I7b45b6f9053664a03aa7dde79e7000b6063ac822
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-16 15:24:44 +00:00
Vlad Lungu 244d5f8d07 net: contiki: Fix net_buf lifecycle
siscslowpan_fragmentation would only free net_buf on failure.
nullmac does not touch the net_buf, this results in all net_buf
being exhausted eventually.
csma always frees the net_buf, so in case of failure there is a double
free with the one from siscslowpan_fragmentation.

Fix:
ref net_buf before every send, unref on every callback and once at the end,
regardless of result. Don't free or ref the net_buf in csma.

Also, replaced some code in fragment() with a call to send_packet()

Change-Id: I4f329810ace07c09cde8f7522a83a1d6681f0906
Signed-off-by: Vlad Lungu <vlad.lungu@windriver.com>
2016-03-16 14:20:56 +00:00
Vlad Lungu 0667c0fe0e net: contiki: move neighbor_list to struct l2_buf
When using the CSMA MAC driver, a new packet can be queued before
all the fragments of the previous one were sent. The transmit_packet_list()
function will start sending the old fragments with the new net_buf context.

Keep a per-context neighbor_list to avoid that

Change-Id: I9d41a923c48f597cc95a8f8c9f67884c5caac02c
Signed-off-by: Vlad Lungu <vlad.lungu@windriver.com>
2016-03-16 14:20:56 +00:00
Vlad Lungu 9be0ad915c net: contiki: Initialize uip_last_tx_status(mbuf) before use
When using the CSMA MAC driver, all send() calls but the last one
return without uip_last_tx_status(mbuf) being updated. If a mbuf
has uip_last_tx_status(mbuf) != MAC_TX_OK and is freed, the next time
it is allocated the first send() call will appear to fail and the packet
will be dropped.

Change-Id: I0fb388714f8071947fa0641fbe03e063550328db
Signed-off-by: Vlad Lungu <vlad.lungu@windriver.com>
2016-03-16 14:20:56 +00:00
Luiz Augusto von Dentz b50a582ea1 Bluetooth: ATT: Notify if a disconnect happen while a request is pending
If the client is waiting for a response but the link is disconnected it
should be notified as the request may never be complete otherwise.

Change-Id: I1fb83b63d8effb4ef2a8f838566c1e68deae9f2c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-03-16 07:26:01 +00:00
Johan Hedberg e4e04adb88 Bluetooth: Call HCI_Reset synchronously to catch errors
Change-Id: I882ec6ce5823afbf3cd423c36e0ac740c69574ce
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-03-14 18:05:24 +02:00
Johan Hedberg 54f5600fb5 Bluetooth: Take advantage of hci_cmd_done() helper
Change-Id: Id4945656407e567dcfe764d5d4df04427c8483af
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-03-14 18:05:24 +02:00
Johan Hedberg 809a4b847f Bluetooth: Fix print format for 4-byte opcodes
Change-Id: Ie37a6e02a5c024ccc02a2dbb17f30b16a4043406
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-03-14 18:05:24 +02:00
Ravi kumar Veeramally 6d740fd4ca net: coap: Use correct network buffer in registration
Need to use the network buffer when sending CoAP serial message
because the message was constructed to net_buf.

Change-Id: I9422ff3f5f93945f1f9f91f2ed8572e3715338ce
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-03-14 12:48:35 +00:00
Jukka Rissanen b650e8edb1 net: apps: User can set the loopback test count
User can set the desired number of network packets that are
sent. There is an example config that sends 10000 packets
and then stops the test application.

Change-Id: I5aa9049236f7bebdc9ea9997b9eb1f672c6adcbf
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-14 12:45:07 +00:00
Jukka Rissanen 37882875ef net: coap: Fix compilation error
The commit cd8d4eb2b7 caused
compilation error in coap.

Change-Id: Ie6fb24d7f213a12936d75a2a2fac350e4965e0b8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-14 12:14:07 +00:00
Szymon Janc 8d154104b6 Bluetooth: Add support for outgoing BR/EDR connections
This allows to create outgoing BR/EDR connection and cancel pending
connection before it succeed.

Change-Id: I5c08bb2e89f79c09fa7930f860d6080d902186a1
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-03-14 11:37:11 +00:00
Jukka Rissanen cd8d4eb2b7 net: User must provide storage for local IP address
When user creates a socket using net_context_get(), the function
requires local endpoint IP address. This should not be a NULL
pointer because the storage for that IP address was statically
allocated inside the function. Because of this the user needs
to allocate the storage for this and pass that local IP address
to the function. The net_context_get() will fill that local
address to sane value if user passes ANY address (== all bytes
are zeroes) to it.

Change-Id: I88314957f07912d9ecbe517a2402822401d81bd9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-14 11:05:52 +00:00
Jukka Rissanen 05e95423e5 net: tinydtls: Fix compile error if IPv4 was activated
Change-Id: Ic86ed449c863d9f2fb354067df076c35e0b4d51c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-14 11:03:33 +00:00
Vlad Lungu 20a4720b93 net: 802.15.4: Make MAC driver configurable, select nullmac as default
csma MAC driver queues outgoing frames, returning an OK status code immediately.
This defeats logic in sicslowpan fragmentation driver that drops remaining fragments
on send failure. The result is packets reported as sent successfully when they were
not, fragments sent that cannot be reassembled by receiver, packets dropped before
the first fragment even reached the radio driver.

nullmac MAC driver sends frames synchronously, resulting in sicslowpan driver working
as intended.

The MAC driver used by 802.15.4 is selectable now, nullmac is default but csma can be
used instead.

Change-Id: I261d551421a8f55634acb1c528f8f82bea49332d
Signed-off-by: Vlad Lungu <vlad.lungu@windriver.com>
2016-03-11 07:32:13 +00:00
Jukka Rissanen ed4f794ac8 net: apps: Change echo-server to use common testing header file
Move network testing setup from echo-server to common net_testing.h
file which makes the application much simpler.

Change-Id: I6f68826916c870ad7db597d30f20245bada70091
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-11 07:26:12 +00:00
Shaul Triebitz d95b3d9118 net: contiki: Fix application layer data offset
The link layer header length isn't always taken into account when
determining the application layer data offset. To avoid potential data
corruption, add the link layer header length where appropriate.

Change-Id: Id718dec8cd5991b561cb13e1304ffdb3dda09da5
Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com>
Signed-off-by: Ido Yariv <ido@wizery.com>
2016-03-10 16:04:52 +00:00
Szymon Janc ab8e7053e2 Bluetooth: Kconfig: Fix max HCI event length if BR/EDR is enabled
Extended Inquiry Result Event is 255 bytes.

Change-Id: Iabd754a85f21998059dfc36935e754ab8a857f54
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-03-10 12:12:13 +01:00
Arkadiusz Lichwa 1232ee3e08 Bluetooth: BR/EDR: Group interfaces in conn.c
Put together specific for BR/EDR interfaces.

Change-Id: Icfc4d0ebd129b8fcbb547a7f21336cd4c950657c
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-03-09 17:48:56 +00:00
Arkadiusz Lichwa dcd04f2a68 Bluetooth: BR/EDR: Add pairing mode flag
Since right now the stack supports as acceptor pre-2.1 devices pairing,
start set the state pairing flag in legacy PIN request handler and
resets it on Encryption Changed event.
When connection is 'in-pairing' mode disallow of local user to trigger
change security level on link.

> HCI Event: Command Status (0x0f) plen 4
	Accept Connection Request (0x01|0x0009) ncmd 1
	Status: Success (0x00)
> HCI Event: PIN Code Request (0x16) plen 6
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
< HCI Command: PIN Code Request Reply (0x01|0x000d) plen 23
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	PIN length: 4
	PIN code: 1234
> HCI Event: Command Complete (0x0e) plen 10
	PIN Code Request Reply (0x01|0x000d) ncmd 1
	Status: Success (0x00)
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: Link Key Notification (0x18) plen 23
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	Link key: 2a4eae1018ed248064166e765d946313
	Key type: Combination key (0x00)
> HCI Event: Connect Complete (0x03) plen 11
	Status: Success (0x00)
	Handle: 12
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	Link type: ACL (0x01)
	Encryption: Disabled (0x00)
> ACL Data RX: Handle 12 flags 0x02 dlen 10
	L2CAP: Information Request (0x0a) ident 1 len 2
	Type: Extended features supported (0x0002)
< HCI Command: Host Number of Completed Packets (0x03|0x0035) plen 5
	Num handles: 1
	Handle: 12
	Count: 1
> HCI Event: Encryption Change (0x08) plen 4
	Status: Success (0x00)
	Handle: 12
	Encryption: Enabled with E0 (0x01)

Change-Id: I5cbdaab1d6d52197795bfffd465ba59216afee00
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-03-09 12:41:44 +00:00
Arkadiusz Lichwa aaa2650f0f Bluetooth: Cleanup dependency build for LE/BREDR
Reorganizes mostly by using preprocessor (indirectly Kconfig options)
strictly LE-SMP related interfaces and security interfaces shared
between LE and BREDR connections.

Change-Id: I90daa36d72403cd5b73e6791714fcaf7f1fbe8e5
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-03-09 10:55:31 +00:00
Andrei Emeltchenko 3d08d16780 Bluetooth: Fix compare logic in ATT read rsp
The Read Response only contains a Characteristic Value that is less
than or equal to (ATT_MTU – 1) octets in length. Include also equal.

Change-Id: I139d1460159aafa2187e04cddd8df57d42807c67
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-03-09 10:16:38 +00:00
Jukka Rissanen d51288a4e1 net: contiki: Fix ICMPv6 error message debug print
There were no spaces around printed IPv6 address which
makes it hard to read.

Change-Id: Ia5f8dad7d21fe8a9a4feb9976b1a90fe624102ab
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-09 08:35:42 +00:00
Szymon Janc 6116d58b02 Bluetooth: Use bt_auth_cancel for pairing cancel
bt_auth_cancel can be used to cancel any type of pairing.

Change-Id: Ia1a6ba834186ab6d5082d3eb473319c2d70cf4a7
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-03-08 15:38:59 +00:00
Roger Lendenmann 6b08b37905 Bluetooth: Fix latency versus timeout check
As per 7.8.12 the check on timeout (time unit ajdusted) must be:
timeout * 10 > (1+latency) (max * 1.25 *2).

Change-Id: I0181b3ab2e1ad38bce9312b6bd83e49082d49024
Signed-off-by: Roger Lendenmann <roger.lendenmann@intel.com>
2016-03-08 10:56:34 +00:00
Szymon Janc 7148aa5422 Bluetooth: SMP: Add support for debug ECDH keys
This add following handling of LE SC debug keys:
- if debug keys are disabled locally generated public/private keys
  is  checked to not match debug keys by accident
- if debug keys are enabled those are used as local public/private
  keys pair allowing sniffing of encrypted air traffic
- tracking of remote device using debug keys
- debug keys are discarded after disconnection regardless of bonding
  flag being set or not
- due to HCI interface limitation debug keys are not supported for
  HCI based ECDH and compilation error will be rised for such
  configuration

Change-Id: Ie147b1893c4a6b9542b4d2c261973a7acbd8de96
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-03-07 18:21:10 +00:00
Luiz Augusto von Dentz 68ee16d85c Bluetooth: GATT: Add bt_gatt_indicate
This uses ATT Indicate Value command to indicate changes and wait for
confirmation response.

Change-Id: I123a00e374929d779f96a02440215c32c0e79423
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-03-07 16:44:15 +00:00
Luiz Augusto von Dentz 468ed2e989 Bluetooth: ATT: Handle Confirmations
This adds the callback necessary to parse Confirm PDU:

< ACL Data TX: Handle 3585 flags 0x00 dlen 8
      ATT: Handle Value Indication (0x1d) len 3
        Handle: 0x001d
          Data: 00
> ACL Data RX: Handle 3585 flags 0x02 dlen 5
      ATT: Handle Value Confirmation (0x1e) len 0

Change-Id: I870058150f27718541eae959dcd5d9d7c6414ad3
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-03-07 15:50:18 +00:00
Jukka Rissanen 371542780d net: contiki: Print prefix information properly when debugging
Change-Id: Ifbe2aa30477a192f8dd48f51154b0b035ac0b36c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-07 11:06:42 +00:00
Jukka Rissanen b1f2593a58 net: contiki: Fix debug prints for ICMPv6 echo request and reply
Change-Id: Ibf0c153f07af19868d89937dd1674da9d6348f95
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-07 11:06:42 +00:00
Jukka Rissanen e9d0bbb984 net: 802.15.4: Do not print anything when packet is discarded
If the received packet is discarded either if it was not meant
for us or it was malformed, then do not print anything.
This helps in an environment where there are lot of traffic
in the network.

Change-Id: I8db8dcec472ccceb9ba8b6cb7cee6c5f13ee34f0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-07 11:06:42 +00:00
Andrei Emeltchenko 920a5b1030 Bluetooth: Increment start handle with next discovery
Next discovery for primary and secondary services shall start from the
next handle.

Change-Id: I8bc7ccd9a84848d75b2d9ef0484429599b0c750f
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-03-06 07:13:56 +00:00
Luiz Augusto von Dentz 5d43dfd704 Bluetooth: L2CAP: Handle of Reject command
This handles Reject command which currently only affects pending
Connection Request where the remote may actually respond with Reject
when it is not implemented.

Change-Id: I0095259230955ee7dd605fad9339a7b5e8f1611b
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-03-05 19:43:37 +00:00
Andrei Emeltchenko a81c3080a2 Bluetooth: Fix typo subscribtions to subscriptions
Change-Id: Ibf015e304e34fddf0f508a1951ac504f07e20d83
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-03-04 11:21:27 +02:00
Ravi kumar Veeramally bf90337e87 net: 802.15.4: Fix the dummy driver
Do not depend on uart_pipe_send return value. Just assume
uart_pipe_send call to uart_poll_out sent data through uart.

Change-Id: Ifc7119f94b625d4f2895d92d44d660013bf50145
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-03-03 07:17:56 +00:00
Ravi kumar Veeramally 89ca24c779 net: Fix NETWORKING_WITH_15_4_TI_CC2520 config option
NETWORKING_WITH_15_4_TI_CC2520 is already depends on
NETWORKING_WITH_15_4, so no need to select again.

Change-Id: I74970a6d550a049dc69734048d1e6eaa13be36b6
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-03-03 07:17:29 +00:00
Jukka Rissanen b1fd0c6a2c net: License information was missing
Few configuration related header files were missing license
header.

Change-Id: Id4ef8273a80eb41f39248dd33ccefbeb30ef57dd
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-01 16:58:32 +00:00
Jukka Rissanen ca3d1adc43 net: Use the existing logging option in Kconfig for debugging
Instead of new config option for debugging, lets re-use the
existing logging option CONFIG_NETWORKING_WITH_LOGGING that
is found in Kconfig. Unselecting that option will turn off
the debug messages in IP stack.

Change-Id: I4c1e0e91f3959304b7dc2b62d2bf73ec87cd1114
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-01 13:49:55 +00:00
Luiz Augusto von Dentz 410d6849a6 net: Fix Bluetooth driver warning
This fixes warnings when compiling without
CONFIG_NETWORKING_WITH_LOGGING.

Change-Id: I50ee7004ba5c662ef2d6ff32b5dd3e1e41a92b5b
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-03-01 13:49:25 +00:00
Jukka Rissanen ce4919069b net: Print the stack usage in timer fiber less often
If enabled, the stack usage is now printed every 60 secs.
Also changing the code to use the kernel ticks clock API.

Change-Id: I44eabd0c372dfb8983ef379e12e38e5bf94a99d2
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-01 14:12:13 +02:00
Jukka Rissanen 1aeca8d569 net: Timer fiber now sleeps until next event
The network timers will now use the fiber wakeup to let the
network timer fiber to get the next event. This enables the
timer fiber to sleep much longer and only wakeup when there
is something to do.

Change-Id: Ia69d92392c02b884c036793de41b38b6489c4d2e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-01 14:12:13 +02:00
Arkadiusz Lichwa 847a1f6628 Bluetooth: BR/EDR: Add initial SSP Complete
Adds HCI protocol type for Secure Simple Pair Complete event and enables the
event in controller.
Then implements the initial SSP Complete event handler with catching
the status of SSP process.

Change-Id: Ic7cc5b4cab8a1b4120285815c24eeb6483d748df
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-26 08:43:31 +00:00
Arkadiusz Lichwa 2697d4fd5e Bluetooth: BR/EDR: Initial IO Capability reply to remote
Enables IO Capability Request event in controller.
Adds handler to react on controller's IO Capability Request event during
incoming pairing.
As a initial case respond to the request with negative reply setting
reason as 'pairing not allowed'.

Change-Id: I161c7ab7f1031a78cfa50444f41624232e5c5146
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-26 08:42:57 +00:00
Mariusz Skamra a7ad7dcf16 Bluetooth: SMP: Clear keys on SMP Timeout and Pairing Failed
Those two indicate SMP failure, so while in keys distribution phase,
if we receive Pairing Failed, or there is SMP Timeout, the keys
distributed so far shall considered as invalid and cleared.
Another flag SMP_FLAG_KEYS_DISTRO is needed to save the old keys
if this failure appears before distribution of new keys.

Change-Id: I9a917740c02955aa149170b84ae547f5c8c4b7ad
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-26 06:54:40 +00:00
Arkadiusz Lichwa dd8bf892f3 Bluetooth: BR/EDR: Handle IO Capability Response event
Enables IO Capability Response event in controller and adds remote IO Capability
and authentication fields to connection object.
Initializes them using IO exchange values delivered in SSP IO Capability
Response event data set representing remote as a part of incoming pairing
process.

Change-Id: Ia73a912f6fb633d1d1bb086ef3af9a280ac5a864
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-26 06:22:54 +00:00
Arkadiusz Lichwa 73e201cbce Bluetooth: BR/EDR: Enable SSP mode in controller
Turns on Secure Simple Pairing mode in controller. Since there's a prerequisite
the controller is 4.0+, turning the mode is unconditional.

Change-Id: Id4a10ccf8892a430b0daaa6750835516b17b7e8a
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-26 06:05:31 +00:00
Tomasz Bursztyka ee587244f4 net: ip: Enable Kconfig based debug options for the IP stack
It will be possible to enable/disable debug messages from IP stack from
make menuconfig, instead of modifying the relevant files to do so.

Change-Id: I065f10bcc2bc3579081b2fcdb1c47e12d148e2f1
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-25 11:03:55 +00:00
Arkadiusz Lichwa 0abd5dd7d5 Bluetooth: BR/EDR: Rename local variable
Changes the local netbuff name to be more generic and to be used later in code
initializing BR/EDR stack.

Change-Id: Iae177237c813a46cbd10720a7af3474632154678
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-25 10:37:55 +00:00
Luiz Augusto von Dentz 2f8a5967a8 net: Kconfig: Auto select mandatory features for Bluetooth
This makes sure NETWORKING_WITH_6LOWPAN and 6LOWPAN_COMPRESSION_IPHC are
selected properly and update IPSP sample to only include the minimal
config options so it can test if this is working properly.

Change-Id: I2565cbd4f79d91eaba348d43933aa893c6dc6ace
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-25 10:36:33 +00:00
Jukka Rissanen 791e6f2708 net: contiki: Original copyright notice was missing
Original copyright notice was lost when the file was copied
from Contiki.

Change-Id: I5e008b92cb3898255a7940dc2c61320014222610
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-24 09:50:50 +02:00
Jukka Rissanen 5562a9a811 net: contiki: Fix the description of 6lowpan files
The file names and types were incorrectly described in comments
in net/ip/contiki/sicslowpan/ directory.

Change-Id: Id6aba238a08ec603a57f9a438dbf6fab202220f8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-24 09:48:44 +02:00
Peter Mitsis 06e2b4e129 nanokernel: Change fiber_delayed_start() return type
Instead of returning a 'void *', the nanokernel fiber_delayed_start()
family of routines now return a handle of type nano_thread_id_t.

Consequently, the nanokernel fiber_delayed_start_cancel() family of
routines now accept a parameter of type nano_thread_id_t instead of
'void *'.

The complete list of affected nanokernel routines is:
    fiber_delayed_start()        fiber_delayed_start_cancel()
    fiber_fiber_delayed_start()  fiber_fiber_delayed_start_cancel()
    task_fiber_delayed_start()   task_fiber_delayed_start_cancel()

Change-Id: Ibd4658df3ef07e79a81b7643a8be9ea5ffe08ba0
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-23 10:48:54 -05:00
Jukka Rissanen 884061bbd9 net: Selecting Bluetooth IP networking selects BT support
It is more intuitive for the end user to enable IPSP by
selecting the BT network driver which then automatically
enables relevant Bluetooth options. The earlier way
required user to select L2CAP dynamic channel support
first before he could activate IPSP and this is not very
logical and user friendly.

Change-Id: Idde0da80a2a19670e217ae9a9a4717e8399559e7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-22 09:59:50 +00:00
Johan Hedberg bab3b49fdb Bluetooth: Change GATT callback return values to ssize_t
Since the return value of these callbacks is a number of bytes ssize_t
is more appropriate than int.

Change-Id: I3406fb382975d62f51e7a195666d0ae88364fd2c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-20 15:39:33 +00:00
Jukka Rissanen 3c44f7e0bc net: contiki: Enable packet queueing
Currently the packet is dropped if some other packet needs to
be sent instead. This does not make much sense in Zephyr so
activate packet queueing where the saved packet is sent later.
The queueing can happen e.g., with neighbor discovery where
the packet to be sent requires ND to be done before the actual
application packet is being sent.

Change-Id: Ia321d641eec5acfbc9f8f581de712801a483e32d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-19 12:38:04 +00:00
Tomasz Bursztyka 050ec13556 net: ip: Make sure CONFIG_NETWORKING_WITH_LOGGING is properly handled
If the user unsets CONFIG_NETWORKING_WITH_LOGGING, it will mean he
really doesn't want to get any network stack logging output.

Change-Id: I0629a045adbf8916327a8a9ba69b6e6e9ee2e7d9
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-19 12:33:45 +00:00
Tomasz Bursztyka 8a826102e0 net: ip: Fix a build issue when CONFIG_NETWORKING_WITH_LOGGING=n
Fixing this issue:
net/ip/l2_buf.c:81:31: note: in expansion of macro 'NULL'
 #define inc_free_l2_bufs_func NULL
                               ^
net/ip/l2_buf.c:88:2:
 note: in expansion of macro
 'inc_free_l2_bufs_func'
 inc_free_l2_bufs_func(buf);
 ^

Change-Id: Ie58f23af479ec4f2dd625b1f0f36720bbe54f928
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-19 12:33:19 +00:00
Johan Hedberg 6b7ecc47c4 Bluetooth: GATT: Fix error response to bt_gatt_attr_read()
Change-Id: Ic5ab95d2c5ff62975f59239fd79068025ec5c54f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-19 12:52:32 +02:00
Johan Hedberg dfaafb204f Bluetooth: Use BIT() macro wherever possible
Instead of manually creating bit shifts for individual bits use the
BIT() macro that exists for this purpose.

Change-Id: I599ecc16b3a2cffe8a355e19816c405e51937e91
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-19 10:47:29 +02:00
Iván Briano f24a02445e net: Include only the necessary headers
Including zephyr.h instead of microkernel.h will also bring in
sysgen.h, which may not be available at the time these files are used
during the build.

Change-Id: I5e9e33a06a5877c6077bceebbab1bee6479fddc0
Signed-off-by: Iván Briano <ivan.briano@intel.com>
2016-02-19 07:41:01 +00:00
Szymon Janc c1c21965d6 Bluetooth: GATT: Fix check if device is bonded
Keys storage is present also for non bonded devices. Add helper
that checks for actual keys being present in storage that may be
used inline.

Change-Id: Icfc758e3ac89e88ca48948e5193878cf5689611a
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-18 16:36:12 +01:00
Szymon Janc 194f9d9c89 Bluetooth: SMP: Add support for no bond pairing
If remote device indicates no bond pairing there is no point in
storing any keys. If no keys are stored key storage is freed on
disconnection. Keeping key storage around while device is connected
is important for GATT being able to check encryption key size also
for paired but not bonded devices.

Change-Id: If80e9d4c6da02e73c8730972a7a388b0b7d14ba6
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-18 14:54:29 +00:00
Luiz Augusto von Dentz c22f551940 Bluetooth: L2CAP: Log an error if data cannot be sent
This add an error to the output which helps detects failures in case
debug is not enabled.

Change-Id: I2f4ed357ccf288c15b231d637bf1986af9ecbf37
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-18 10:01:05 +00:00
Johan Hedberg a72d967d33 Bluetooth: GATT: Expose ATT error codes to application callbacks
Introduce BT_GATT_ERR macro to make it possible for application
callbacks to return exact ATT error codes.

Change-Id: I971536508e75036fbddc40b3f33e5201e11940bc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-17 15:05:34 +00:00
Johan Hedberg 96f9831304 Bluetooth: Add public att.h header file
For now this only exposes the various ATT error codes.

Change-Id: If568782e90dca22871681d2d3b2d81ae4cb8e5e4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-17 15:05:08 +00:00
Johan Hedberg 2f9ff6f11b Bluetooth: Rename att.h to att_internal.h
In preparation of creating a public att.h rename the existing internal
header appropriately.

Change-Id: I8588712bc5aa57d391c5ce0886c99692e5a2823e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-17 16:15:56 +02:00
Szymon Janc b7b0a16a07 Bluetooth: Fix tracking of advertising state
This fix not being able to stop advertising while connected due to
invalid use of BT_DEV_ADVERTISING flag.

Change-Id: If5578fa2c69dd18d6623d05ae44d4710cce9a9e5
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-17 13:15:08 +00:00
Szymon Janc 4dfb50e514 Bluetooth: Fix not calling connected callback on connect failed
If LE Create Connection fails notify application that connection
failed.

Change-Id: I3993bcb1bf3f8bd8fc08546e1fe683326b47db5b
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-17 13:07:46 +00:00
Luiz Augusto von Dentz 12a092757f Bluetooth: L2CAP: Fix use of '/n' with BT_DBG
BT_DBG already add a new line so that '/n' is not necessary.

Change-Id: I7b25470386e2a7228a684665301d2d28d1360808
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-17 11:50:12 +02:00
Luiz Augusto von Dentz ca90ac5e62 net: Select NETWORKING_IPV6_NO_ND in case of NETWORKING_WITH_BT
Bluetooth links are point to point so it shouldn't be necessary to do
neighbor discovery, futhermore it blocks transmission if the remote
doesn't respond which seems to be the case with Linux.

Change-Id: Ic8997f9c5bc832ba71f71e20e6317ee0c79d250d
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-16 15:44:26 +00:00
Szymon Janc c80cf24e03 Bluetooth: GATT: Fix possible bt_conn leak
If other peers were present but not in CONNECTED state temporary
connection reference was leaked.

Change-Id: Icc32bfe1a86f92a9d8472991476ebfd26c889d84
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-16 15:03:50 +00:00
Szymon Janc 7dc9210939 Bluetooth: ATT: Fix notifying GATT on disconnection
Channel context was cleared before calling bt_gatt_disconnected
which resulted in passing NULL conn to it.

Change-Id: I486d1cf6662716584c2c973366a9c9654f499802
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-16 14:25:34 +00:00
Arkadiusz Lichwa 1246df3c98 Bluetooth: BR/EDR: Validate security on encryption key refresh evt
During endup pairing as acceptor update security level on encryption key
refresh complete event.

Change-Id: Id1d252bfa5a7f6c69d52b3f6b23907025e711fb2
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-16 06:51:31 +00:00
Arkadiusz Lichwa 9c88e66935 Bluetooth: BR/EDR: Validate security on encryption change evt
During endup pairing as acceptor update security level on encryption change
event.

Change-Id: Icddedc09f70093cc05ac99d04053b3bd3ef22555
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-16 06:51:10 +00:00
Arkadiusz Lichwa bd81052d41 Bluetooth: BR/EDR: Validate security on connection complete evt
During endup pairing as acceptor update security level and link encryption
state on connection complete event.

Change-Id: I6189a3c6675c080e3ab2610c81b617294dbd98d5
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-15 20:46:19 +00:00
Arkadiusz Lichwa ac7e560ba9 Bluetooth: BR/EDR: Move part of BR/EDR core code up
To skip around forward declaration in next security update patch,
move up part of strictly BR/EDR related code.

Change-Id: Id44fc831f629e66660edbc43c187cbf9a88b771d
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-15 19:52:46 +00:00
Arkadiusz Lichwa f670d06643 Bluetooth: BR/EDR: Add user I/O context during pairing
When during legacy incoming pairing (as acceptor) the runtime is passed to user
to enter a PIN, mark such interaction and keep it valid until proper
authentication reply API handlers are called.

Change-Id: If63015f5beb256873925602adc6a8e5ff9d3b00f
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-15 17:20:20 +00:00
Arkadiusz Lichwa 998d72a986 Bluetooth: BR/EDR: Track 16 digits PIN code
As a pairing acceptor starts tracking 16 octets PIN entered by user
when pairing devices working in Security Mode 3. Based on PIN tracker
state, the generated link key is saved in keys database as combination of
un/authenticated and legacy key type.

Change-Id: I4cbb20942fb38697d952971df807aec8b16c74e4
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-15 17:19:40 +00:00
Jukka Rissanen e11295ebe4 net: contiki: If outgoing packet is dropped then print more info
Change-Id: Ibac9592f9af5bd5ad2b984752bd8e3a0542d00b5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-15 15:00:00 +00:00
Andrei Emeltchenko d650bc298e Bluetooth: Add missing print format specifier
Change-Id: Ia4a3e70a990da69bc5be22f693081f0dd6b6a5e1
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-12 16:57:30 +00:00
Andrei Emeltchenko 6e9de099d5 Bluetooth: Fix checking wrong variable
Check server instead of psm after lookup.

Change-Id: I80fe916432b69b376f04083980f1208aa7befbb1
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-12 16:25:20 +00:00
Johan Hedberg 1bc6597d4d Bluetooth: Take advantage of the new net_buf_pull_u8() helper
Change-Id: I41ac2bc721b916f6d939f23be293750a83d21523
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-12 16:03:43 +00:00
Johan Hedberg 9d6aaa1cc7 net: buf: Add net_buf_pull_u8() helper API
A helper for the (fairly common) task of decoding individual 8-bit
values.

Change-Id: Id7e97df152232d5dd9861cf1e107877f1b8febaa
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-12 15:10:20 +00:00
Johan Hedberg 984c7a6945 Bluetooth: Kconfig: Introduce BLUETOOTH_RX_STACK_SIZE
Applications may want to fine-tune the stack size of the fiber that's
used to make callbacks into the application.

Change-Id: I2cd3e79283fe85359389528e84d9bcc21e3e19f6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-12 13:01:13 +02:00
Szymon Janc ab013794a5 Bluetooth: Kconfig: Move TinyCrypt ECDH under SMP
This is used only for LE SC.

Change-Id: I60e5ac391fec1cf1f8648f16021a2956072f2d50
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-11 20:45:03 +00:00
Szymon Janc 7f9696c182 Bluetooth: SMP: Fix compilation with SC Only mode enabled
legacy_pairing_rsp is used only for legacy pairing. Fix following
with CONFIG_BLUETOOTH_SMP_SC_ONLY set.

  CC      net/bluetooth/smp.o
net/bluetooth/smp.c: In function 'legacy_pairing_rsp':
net/bluetooth/smp.c:1207:16: warning: implicit declaration of function
    'legacy_get_pair_method' [-Wimplicit-function-declaration]
  smp->method = legacy_get_pair_method(smp, remote_io);
                ^
net/bluetooth/smp.c:1209:8: warning: implicit declaration of function
    'legacy_request_tk' [-Wimplicit-function-declaration]
  ret = legacy_request_tk(smp);
        ^
net/bluetooth/smp.c:1216:10: warning: implicit declaration of function
    'legacy_send_pairing_confirm' [-Wimplicit-function-declaration]
   return legacy_send_pairing_confirm(smp);
          ^
net/bluetooth/smp.c: At top level:
net/bluetooth/smp.c:1201:16: warning: 'legacy_pairing_rsp' defined but not
    used [-Wunused-function]
 static uint8_t legacy_pairing_rsp(struct bt_smp *smp, uint8_t remote_io)
                ^
Change-Id: I0d65efa71859c23cf5b6f0bfa3386a23543bf907
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-11 20:44:58 +00:00
Szymon Janc dee44dee7c Bluetooth: Kconfig: Clarify BLUETOOTH_TINYCRYPT_ECC help message
If controller based ECC is to be used and it is not supported
LE SC are disabled.

Change-Id: I4cf48152fe28cb5678434925de63caaaba493d68
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-11 20:44:52 +00:00
Szymon Janc 8dbd8dcc5b Bluetooth: Remove dead code
Since now TinyCrypt is always enabled there is no need for HCI
backup code.

Change-Id: I6cf9c2bd15dc9a6c0dd98cd7aff0ea137eb0be8b
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-11 20:44:44 +00:00
Szymon Janc 3ed1a37a41 Bluetooth: SMP: Use TinyCrypt for AES CMAC
TinyCrypt provides implementation of AES CMAC so there is not need
for internal implementation in SMP code.

Change-Id: I15fe0daf8fca8c44b002636983b46502419c57a5
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-11 20:44:28 +00:00
Johan Hedberg 4c11dda411 Bluetooth: Take advantage of the new net_buf_add_u8() helper
Change-Id: Id062d4f68be1960006926ddf463c2c7ecf42d31a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-11 14:48:03 +02:00
Johan Hedberg 500513b5f0 Bluetooth: Add connection role to bt_conn_info
This can be useful for both LE and BR/EDR connections so it sits
outside of those specific structs. The values are intentionally
matching the HCI values so for the HCI case we can just do a direct
assignment.

Change-Id: Id78d304bb61e5fd941f2c35351758c1eecc6ab6a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-11 14:48:03 +02:00
Jukka Rissanen 4006f47627 net: Allow user to tweak 802.15.4 fibers stack sizes from Kconfig
User is able to tweak the stack sizes of 802.15.4 RX and TX fibers.
These fibers are responsible for receival and transmission of
6LoWPAN 802.15.4 network packets.

Change-Id: I28dea287c1d939333fef0c1ac4eb890295c7bd9e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-11 11:54:07 +00:00
Jukka Rissanen 5ae183a403 net: Allow user to tweak IP fibers stack sizes from Kconfig
User is able to tweak the stack sizes of RX, TX and timer
fibers. These fibers are responsible for receival, transmission
and re-transmission of IP network packets.

Change-Id: I43238180e628ed47f431ece0bc6dfcdfb035325f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-11 11:54:07 +00:00
Szymon Janc 60e781b6f6 Bluetooth: Kconfig: Remove not needed help quotation marks
There is no need to keep help message in quatation marks as those
will be shown in menuconfig.

Change-Id: If47e7bb029cfc17c7def971c563178ba38120731
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-11 11:20:41 +00:00
Szymon Janc 4318fc0e5b Bluetooth: Kconfig: Add TinyCrypt ECC config option
This enables use of ECC from TinyCrypt. Since ECC is heavy this option
is separated from general use of TinyCrypt in SMP code.

Change-Id: Ia550e4a5f89240c8e15d2b5acccc21993b44b471
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-11 10:56:40 +00:00
Johan Hedberg 754248aedc net: buf: Add convenience API for adding 8-bit integers
There are many situations when encoding data when we need to insert
single bytes to the buffer. With this helper the encoding code stays a
bit more readable.

Change-Id: Ibc0ce43af5ae25a1baa0f1adbc5816ae7c04e3bb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-11 11:14:20 +02:00
Szymon Janc 068fe1136e Bluetooth: SMP: Add support for TinyCrypt ECC
This allows to use ECC implementation from TinyCrypt instead of
controller based ECC.

Change-Id: I09bdff78899c1ac5cd1d10243d4c00c4d0a75d83
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-10 19:13:01 -05:00
Szymon Janc 708126cd30 Bluetooth: Use correct CONFIG option for TinyCrypt ECC define
The option is named CONFIG_TINYCRYPT_ECC_DH.

Change-Id: Ice30857d368582f5bc5d2f47e8ce6b1a89e29128
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-10 19:13:01 -05:00
Jukka Rissanen 4d3cb02446 net: Increase the 802.15.4 TX stack to 4096 bytes
If application needs to send large packets, the 802.15.4
fragmentation code needs to store the fragments somewhere.
Currently this somewhere is stack which means that we
need to increase the stack size quite a lot.

Change-Id: I9b08563e77c021e5ac103e637e331d7b977563cc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-10 19:13:01 -05:00
Szymon Janc 6de50c5aa6 Bluetooth: Store LE SC Public Key in SMP code
There is no need to keep this in bt_dev structure as this is not
used outside of SMP code.

Change-Id: I24a1d9daffb4d382bf1ed07a5645e4cbdafa3c5e
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-10 19:13:01 -05:00
Johan Hedberg fd28fc1b00 Bluetooth: Move address helper functions to hci.h
These are needed both by nble as well as the HCI stack and will likely
also be of use for applications.

Change-Id: Ifd10ae6df25151162d9d5491466324b4a42f5506
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-10 19:13:01 -05:00
Szymon Janc eccec2a5ac Bluetooth: Kconfig: Add option for enabling TinyCrypt
Add a single option for enabling use of TinyCrypt library for
crypto. This option selects all required TinyCrypt options
depending on BT features enabled. Thanks to this applications
only need to select single option instead of set of required
TinyCrypt features.

Change-Id: I2862e9ad3e204635f2ed3199433982bcfb7112f6
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-10 19:13:00 -05:00
Szymon Janc 47ecb52064 Bluetooth: Add support for TinyCrypt based bt_rand
This allows to use pseudo random numbers generator provided by
tinycrypt instead of constant using of HCI LE Rand command.

HCI LE Rand commands are used only to initialize and re-seed PRNG.

Using tinycrypt for NRPA increase size of sample shell application
from 86852 to 89700 bytes.

Change-Id: I06e7392d087908caf37cd3ae648ea0bd5cc4ce61
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-10 19:13:00 -05:00
Andrei Emeltchenko 7038367fe4 Bluetooth: trivial: Remove empty line
Change-Id: I23506caf37b66bb2c1b84b0121522431fe1748a9
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-10 19:13:00 -05:00
Jukka Rissanen cd14f65ebe net: Initialize Contiki vars related to L2 buffer mgmt
The l2_buf struct contains variables that Contiki uses
for it's state management. It is important that we
initialize these variables into sane values otherwise
there will be hard to catch errors like overwriting
memory in other parts of the system.

Change-Id: Id0f552a6f0f2858fc6e8e4964ada0715a40f46f8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-10 19:13:00 -05:00
Szymon Janc 843268d78d Bluetooth: GATT: Refactor read API
Add read parameters to read callabck

Merge bt_gatt_read_multiple functionality into bt_gatt_read.
This makes it easier for application to handle all types of reads
as same sematics is kept for them.

Instead of destroy callback, call read_func with NULL data to
indicated that read has completed. This makes it clear when
read is completed and parameters used for it are no longer needed.
Thanks to this application doesn't need to abuse user data destroy
callback for detecting if read has completed. Since destroy callback
is no longer needed it is removed.

Also note that bt_gatt_read doesn't take any user data parameter
and that destroy callback was acctually called with read parameters.

If application would require to pass user data along with parameters
it may use CONTAINER_OF macro along with bt_gatt_read_params.

Change-Id: I8d6ea136b1e61c1dae73cca868b53c48c45a5492
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-10 18:52:29 -05:00
Szymon Janc 51ac70d42b Bluetooth: GATT: Refactor subscription API
This removes destroy callback for userdata as bt_gatt_subscribe
doesn't take any user data parameters and that destroy callback
was acctually called with subscribe parameters.

We assume subscription is active if bt_gatt_subscribe returned 0
(ie write command was sent). This is due to remote might be sending
notifications before reply to write.

Also note that bt_gatt_subscribe doesn't take any user data parameters
and that destroy callback was acctually called with subscribe
parameters.

If application would require to pass user data along with parameters
it may use CONTAINER_OF macro along with bt_gatt_subscribe_params.

Change-Id: I58ac9cd481ffa08ccc2d7a0464ca75f61fb280c5
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-10 18:52:29 -05:00
Grzegorz Kolodziejczyk b3617ba937 Bluetooth: Fix checking parameters in bt_le_conn_params_valid
Parameters should be checked according to specification. Previous
implementation don't check properly given timeout. Additional check of
lower timeout limit was required.

Change-Id: Id6d302de9c8c9952c0f61107a1ef8d9fa727bffb
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
2016-02-05 20:25:33 -05:00
Louis Caron 9e58ac9840 Bluetooth: fix bswap order when building 128bit UUIDs
When building 128b UUIDs, the uint16_t needs to be swapped in the
big order case only, as explained in the comments

Change-Id: Ia998d333c9a22c9989763f3729fe42c0edf16545
Signed-off-by: Louis Caron <louis.caron@intel.com>
2016-02-05 20:25:33 -05:00
Louis Caron 48802c2212 Bluetooth: Add API to update LE connection parameters
Applications should be able to update the connection parameters.

Change-Id: I446f64fcd0b27b605e636e566fb35a362a92de96
Signed-off-by: Louis Caron <louis.caron@intel.com>
2016-02-05 20:25:33 -05:00
Jukka Rissanen 5205172dd4 net: contiki: Fix debug prints in ICMPv6 handling
Change-Id: I2a1df0dfb44ee6fbd94535d93a7504fa2c7f7f43
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:25:32 -05:00
Szymon Janc 6645d3f485 Bluetooth: GATT: Remove destroy callback from bt_gatt_discover_params
Instead of destroy callback, call discovery_func with NULL attribute to
indicated that discovery has completed. This makes it clear when
discovery is completed and parameters used for it are no longer used.
Thanks to this application doesn't need to abuse user data destroy
callback for detecting if discovery has completed.

Also note that bt_gatt_discover doesn't take any user data parameter
and that destroy callback was acctually called with discovery
parameters.

If application would require to pass user data along with parameters
it may use CONTAINER_OF macro along with bt_gatt_discover_params.

Change-Id: Iec4eb9795975ef2555502e13a682e13ff37742e0
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:32 -05:00
Louis Caron bcb61c6630 Bluetooth: add the connection parameters to le conn info
Applications that need it can retrieve the connection
parameters at any time, connected callback for example,
and eventually handle the connection update callback or
not, this gives maximum flexibility for handling these
parameters and requesting change.

Change-Id: Iba7d30ade045875ebc721fd332e031d9008e248c
Signed-off-by: Louis Caron <louis.caron@intel.com>
2016-02-05 20:25:32 -05:00
Jukka Rissanen 9f8ed3a6e0 net: Make sure timer fiber does not print stack usage too often
Sometimes the timer fiber was flooding stack usage to console.

Change-Id: I3518cc08f3c8d3ed8ccc19e7bbb6356811e28ab7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:25:32 -05:00
Jukka Rissanen c12fcb1bbd net: Clarified the neighbor discovery option in Kconfig
Change-Id: I31a725450120c29de33246f8602f97c8b4c852c7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:25:32 -05:00
Jukka Rissanen e6bffc88d2 net: Fix the statistics printing in timer fiber
Timer fiber printed statistics too fast.

Change-Id: Icb24e9866543316de3491edf89298350d9bee994
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:25:32 -05:00
Johan Hedberg 479d25d035 Bluetooth: Rename BT_LE_ADV_ADDR_PUBLIC to BT_LE_ADV_ADDR_IDENTITY
In anticipation of supporting a local static random address in the
future it makes more sense to call BT_LE_ADV_ADDR_PUBLIC
BT_LE_ADV_ADDR_IDENTITY.

Change-Id: I4826f1dfb50b54e13a35cbe7ee74e28641c81ad1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:31 -05:00
Jukka Rissanen 1b7b470cb0 net: contiki: Fix the debug printing support for ICMPv6 code
Change-Id: I01ea438e946ec597ac389bd26f0f26c307efa65e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:25:28 -05:00
Jukka Rissanen d9f50cdb9d net: contiki: Make sure ICMPv6 support is activated
We need ICMPv6 support if IPv6 is enabled.

Change-Id: I5e6ffe83d8299916bb268d136264f3e5cf6f91e6
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:25:28 -05:00
Jukka Rissanen 2822ed6537 net: contiki: Fix the NA ICMPv6 sending
The ICMPv6 NA (neighbor advertisement) packet length was not set
correctly so no NA message was sent.

Change-Id: I7ddf41545f4b07da669d29f2529f5b04d3bc8b75
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:25:28 -05:00
Jukka Rissanen 1e9fd8da9b net: Enable IPv6 neighbor discovery by default
The IPv6 neighbor discovery is needed when dealing with real
brearers like 802.15.4, so enabling ND by default.
In Qemu and if SLIP is used, then the ND needs to be disabled
as it does not work properly with tun devices.

Change-Id: I8baf11e71fb546b698a0a3d18fcacb142744db60
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:25:28 -05:00
Johan Hedberg a9404225e5 Bluetooth: Use NULL for "any" connection with bt_conn_lookup_state_le()
An all zeroes address is in principle not valid, but prototype devices
have been seen using it. To avoid false-positives with the
bt_conn_lookup_state_le() API use a NULL pointer rather than
BT_ADDR_LE_ANY to indicate that any connection in the specified state
is of interest.

Change-Id: I42a1946e47173b17be295b1b7e97a654dbdcdc6a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:28 -05:00
Johan Hedberg 27fe6fcb46 Bluetooth: L2CAP: Further simplify l2cap_chan_create_seg()
Change-Id: I57d45fcb0647459d9b5b465d175064fa3a194601
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:28 -05:00
Johan Hedberg aa1d49041b Bluetooth: L2CAP: Take advantage of net_buf_push_le16 helper
Change-Id: Iff5e2b8f7d16f829b93832f513113c6c6c292d37
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:28 -05:00
Johan Hedberg 8d98247c8f net: buf: Add net_buf_push_le16 helper function
Change-Id: Icce051392d1523df8ebfeccf76477a6264d3d216
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:28 -05:00
Szymon Janc 66413dad20 Bluetooth: L2CAP: Fix not sending all bytes of SDU
There are always 2 additional bytes for SDU length in first packet
and those needs to be taken into account.

Change-Id: I3c202cd969524036b42d919bc001e75b8c2faaa0
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:28 -05:00
Szymon Janc 719e8e4710 Bluetooth: Fix not updating LE keys on Key Refresh Event
If link is already encrypted controller issues "Encryption Key
Refresh Complete" for "LE Start Encryption".

Failing to update keys resulted in invalid security level being set.

Change-Id: I8d8dd1682937bd35a35111366ec6ebdaa619db7c
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:28 -05:00
Johan Hedberg 56ba2ffb6b Bluetooth: Remove unused bt_uuid_copy() API
There are no more users of this API, and the only user it had in the
past was quite a special corner case. Just remove it for the time
being.

Change-Id: I696139b493f9ca75530665de25a4a4e03fc0ac5b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:28 -05:00
Johan Hedberg d5e23e86d2 Bluetooth: UUID: Introduce new API
Introduce new UUID API with bt_uuid, bt_uuid_16 and bt_uuid_32
structs. The specific size structs are derived from the common bt_uuid
struct to make it possible to use CONTAINER_OF().

Change-Id: I9cb03c73406acb7768d410fdf29eae75d252163c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:28 -05:00
Szymon Janc 4e29c31512 Bluetooth: L2CAP: Fix not calling disconnect callback
Destination CID identifies the channel endpoint on the device
sending the response. So in disconnection response DCID matches
CID used for TX.

Change-Id: Id42d61536bcc208e868ac889c738e7c40bcf5a9a
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:28 -05:00
Luiz Augusto von Dentz 60ea587c59 Bluetooth: L2CAP: Fix bt_l2cap_chan_send
The l2cap_chan_le_send_sdu code was not taking into account that
bt_l2cap_send adds its on headers which means buf->len != ret won't
stop once the last remaining segment is sent since it reuses the
original buffer len is not consumed.

Change-Id: I774da976fb4f71127ae30adf1e02d52946fb9592
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:28 -05:00
Szymon Janc dfb9441221 Bluetooth: L2CAP: Fix missing unref if link was disconnected
Buffer returned by l2cap_chan_create_seg should be unreffed if
disconnected.

Change-Id: Ib794ecc98618eddc9d92b2dc2edf829c50123418
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:27 -05:00
Johan Hedberg 44541091dc Bluetooth: GATT: Remove unnecessary usage of full UUID structs
To access the 16-bit value of GATT UUIDs it's quite overkill to first
create anonymous UUID structs and then access the value member from
them. We can simplify this a lot with the help of the recently added
UUID value definitions.

Change-Id: Ib58012c20d07b3e60e5911cea6feb73301d1323c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:27 -05:00
Luiz Augusto von Dentz 7834061d12 Bluetooth: ATT: Check mask instead of specific permission
This enables simpler permissions as it is not longer needed to include
BT_GATT_PERM_READ or BT_GATT_PERM_WRITE.

Change-Id: I0c749b75bedb125bda8ea451474c82eec13d3c38
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:27 -05:00
Luiz Augusto von Dentz 16f398ddf7 Bluetooth: UUID: Fix conversion to 128 bit format
The current format used is a swap of RFC 4122 thus the 16 bit values do
come at the end not at the beggining and data need to be swapped.

Change-Id: I38a27cdf82a28d28e47675f719772278d85deaaa
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:27 -05:00
Andrei Emeltchenko 5da3fbdaf4 Bluetooth: att: Use correct format specification for size
Change-Id: Ida06f2d34bfd41256a98c79200717329497667ac
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:27 -05:00
Szymon Janc e6f0356df7 Bluetooth: SMP: Fix legacy passkey entry for central role
In legacy passkey entry method confirm value is sent first.

Change-Id: Ic379650dab64715be6d281fa8d3389f5ff34a978
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:27 -05:00
Szymon Janc 04f6d80ff3 Bluetooth: SMP: Fix not initializing context correctly
Use uint8_t for pointer arithmetic when clearing SMP context so that
correct memory is cleared.

Change-Id: I8b88bc4c2eb181397bce5fb80a6ab250086cb17d
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:26 -05:00
Jukka Rissanen f5a58453d4 net: contiki: Fix the RA ICMPv6 sending
The ICMPv6 RA payload was ignored and not sent. This was seen
as malformed packet by receiver. We must update the length of
the message by calling net_buf_add().

Change-Id: I3dc64cfce669de54283db290cfb009b2c6ea7225
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:25:26 -05:00
Jukka Rissanen a38fc2fc11 net: contiki: Fix the NS ICMPv6 sending
The ICMPv6 NS payload was ignored and not sent. This was seen
as malformed packet by receiver. We must update the length of
the message by calling net_buf_add().

Change-Id: I5bf53695c811c27a75320fea7331d91782a9748a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:25:26 -05:00
Jukka Rissanen 209119cd63 net: contiki: Fix the RS ICMPv6 sending
The ICMPv6 RS payload was ignored and not sent. This was seen
as malformed packet by receiver. We must update the length of
the message by calling net_buf_add().

Change-Id: Iddedb7b6674f30c7943c0ba59c0afc7d244a1e0d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:25:26 -05:00
Arkadiusz Lichwa ea3b162bac Bluetooth: BR/EDR: Add support for Link Key request
Delivers a valid Link Key to controller if found or responds negative
to Link Key request to controller.

Change-Id: I98061110a60b066421f35db44455925cbcd3076e
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:25 -05:00
Arkadiusz Lichwa a68db1fc57 Bluetooth: BR/EDR: Enable encryption handlers
Get access to available link encryption related handlers.

Change-Id: Ifcf4cf3af11368ca68cd93d3023a020bb01a7b74
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:25 -05:00
Michael LeMay fa484be4f4 net: ipv4: Add missing includes
This patch adds two missing includes necessary for building IPv4
support.

Change-Id: I381d0951df4ee615867743dbde551666b603fecc
Signed-off-by: Michael LeMay <michael.lemay@intel.com>
2016-02-05 20:25:25 -05:00
Peter Mitsis f23c498018 net: Ensure stacks are properly aligned
Applies '__stack' tag where necessary to ensure that stacks are
properly aligned.

Change-Id: Ibbce5d4656f69db6c9b5006d15e0a0eb231c7af4
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:25:23 -05:00
Tomasz Bursztyka 2b3e60e6df cc2520: Reworking radio on and transmission logic
FIFOP setting is a wrong assumption to know if radio is on.
Transmission runs on clock basis instead of pre-set loop counter. Thus
removing useless config option relevantly as well.
Opmitizing a bit the code as well, and making cc2520_on() public for
testing purpose.

Change-Id: I4495d1d6c19d10dcbc18f7e2fd5041720ec1f438
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:25:23 -05:00
Jukka Rissanen f1563253cf cc2520: Initial checkin for TI CC2520 802.15.4 driver
Integrating it into network stack. Centralizing all in drivers/802.15.4

Change-Id: Ia2916ff652afe5fe736f6560c2ed4a911a5f0679
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:25:23 -05:00
Tomasz Bursztyka fa79a5df21 contiki: clock: Tiny cleanup
Use existing macros from Zephyr and apply proper code style.

Change-Id: Ia3d572054aa702ce33ceae04eff931cfb900c45c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:25:23 -05:00
Arkadiusz Lichwa 32a86ca351 Bluetooth: BR/EDR: Store new combination link key
Updates connection object keys using generated link key and mark the
key as legacy after successful pairing initiated by remote.

Change-Id: Idcd02ea12c45f6f19f6675a2d6161a8349dde170
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:20 -05:00
Arkadiusz Lichwa 53de0818f9 Bluetooth: BR/EDR: Update keys management
Updates keys interfaces allowing to store and locate legacy link key
in keys database.

Change-Id: Ibd50edff890e998e3c6f80ee7f1442dff7a7c91f
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:20 -05:00
Luiz Augusto von Dentz d65dcc5e4b Bluetooth: GATT: Replace handle with attribute object in bt_gatt_notify
This make more sense since the handles are normally self allocated by
the stack.

Change-Id: I198dd9c3ef6259cff8a0e528514918ec18990dea
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:20 -05:00
Luiz Augusto von Dentz ea1534f100 Bluetooth: GATT: Add bt_gatt_attr_next function
This add bt_gatt_attr_next function that can be used to iterate to next
attribute which is convenient if original attribute is known and using
bt_gatt_foreach_attr would require a lookup and another function to pass
as callback.

Change-Id: I1bd522fd4ae784e08aa375b35320191cbfc03a54
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:20 -05:00
Mariusz Skamra 21198af4b8 Bluetooth: Fix missing curly brackets
Change-Id: Ia984448040d68e0f8674295028c6982887420e6a
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:20 -05:00
Mariusz Skamra 4b7124b637 Bluetooth: GATT: Fix error response in Find by Type response
We shouldn't respond with an error if the read of UUID failed.
It's because we don't know if this UUID was the one that client
requested in the Find by Type Value request.

Change-Id: I34c336b9afc3520194fbddaaee8a44d51beabad5
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:20 -05:00
Mariusz Skamra de6029ee25 Bluetooth: GATT: Fix Find by Type response
This fixes bug where wrong service handles have been sent while
discovering the primary services. We should skip Secondary Service
contained in range 0x0006-0x0009 in this case:

> ACL Data RX: Handle 64 flags 0x02 dlen 13    [hci0] 619772.398445
      ATT: Find By Type Value Request (0x06) len 8
        Handle range: 0x0001-0xffff
        Attribute type: Primary Service (0x2800)
          UUID: Generic Access Profile (0x1800)
< ACL Data TX: Handle 64 flags 0x00 dlen 9     [hci0] 619772.403821
      ATT: Find By Type Value Response (0x07) len 4
        Handle range: 0x0001-0x0009

With this patch:

> ACL Data RX: Handle 64 flags 0x02 dlen 13    [hci0] 618945.922607
      ATT: Find By Type Value Request (0x06) len 8
        Handle range: 0x0001-0xffff
        Attribute type: Primary Service (0x2800)
          UUID: Generic Access Profile (0x1800)
< ACL Data TX: Handle 64 flags 0x00 dlen 9     [hci0] 618945.927933
      ATT: Find By Type Value Response (0x07) len 4
        Handle range: 0x0001-0x0005

Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
Change-Id: I7bb743e8787bc294ba447be5e21e250f0128ec68
2016-02-05 20:25:20 -05:00
Luiz Augusto von Dentz c44ef91e56 Bluetooth: GATT: Add support for static DB
This enable applications to build with a single table representing the
database where attributes don't have to store a pointer to the next
attribute thus reducing its size.

Change-Id: I4c84e2d50f9088a2f9879068890f0646e586e007
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:20 -05:00
Mariusz Skamra 66cb6b335e Bluetooth: GATT: Fix invalid att pointer dereference
This fixes invalid att pointer dereference to get the tx MTU size.

Change-Id: Ifc7911ee58fd4ddff10d1839aff5df9a6e805de8
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:20 -05:00
Mariusz Skamra 76bc832607 Bluetooth: GATT: Fix Read by Group Type response
This fixes bug where wrong service handles have been sent while
discovering the primary services. We should skip Secondary Service
contained in range 0x0006-0x0009 in this case:

      ATT: Read By Group Type Response (0x11) len 13
        Attribute data length: 6
        Attribute group list: 2 entries
        Handle range: 0x0001-0x0009
        UUID: Generic Access Profile (0x1800)
        Handle range: 0x000a-0x000e
        UUID: Unknown (0xaa50)

With this patch:

      ATT: Read By Group Type Response (0x11) len 13
        Attribute data length: 6
        Attribute group list: 2 entries
        Handle range: 0x0001-0x0005
        UUID: Generic Access Profile (0x1800)
        Handle range: 0x000a-0x000e
        UUID: Unknown (0xaa50)

Change-Id: I8121521e76476826296a2bedf9e18ef008f81363
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg f190371781 Bluetooth: Add stubs for directed advertising API
Add API definition and stubs for directed advertising.

Change-Id: Ib22d3acb6d2e76b0c638b26b8e07860cd189f640
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg bc073cdb59 Bluetooth: Add bt_conn prefix for auth APIs
All of the authentication APIs deal with bt_conn objects. For
consistency it makes therefore sense to use the proper bt_conn name
space with them.

Change-Id: I47912d542373df511524cc6ad2532d6c9a76ca68
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg d72744984c Bluetooth: Move bt_auth_* implementation to conn.c
Change-Id: Ia73f898d782c3843d70a5186c21e22199bee593e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg 044dda711f Bluetooth: Move bt_le_set_auto_conn() to conn.c
Change-Id: I07763cab88c73eaf5cb3009651a6f20c9e9bb43d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg 25f6579016 Bluetooth: Move all bt_conn related APIs to conn.h
To have some proper split of conn.h and bluetooth.h APIs make sure all
bt_conn related ones are in conn.h. This also helps avoid forward
declarations for some upcoming patches where we need bluetooth.h
defines from within conn.h.

Change-Id: Ief3d32118a6749fb5785dab6cb3fee4ebb86ddb4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg 41e7ebfb72 Bluetooth: Return error if app gives invalid AD data
It's not a good idea to silently truncate the data if we got a too
large array from the app.

Change-Id: Ie4541599c6846efd53c81310c8d1e4dd5ec00cee
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg 02740a8083 Bluetooth: Refactor AD data HCI commands to helper function
The advertising data and scan response data HCI commands are almost
identical so we can save some code size by having a helper function
for them.

Change-Id: I9f80477ab7837c0a8efa0f9219552ea1426978d4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Luiz Augusto von Dentz 2d5dc34c94 Bluetooth: Kconfig: Add config option for dynamic GATT db
This option will be used to determine if bt_gatt_attr need to store the
next attribute or if it directly accessible by index.

Change-Id: I98fd43931d67d6c3be3b7a130e6fd2f97f2c4a3a
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg 672bf0d63c Bluetooth: SMP: Return errors from authentication APIs
This way we can pass any errors back to the application.

Change-Id: Ic53b858a73436e1c9c4d03e358aeffae7fd837ab
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg 432c2db4d8 Bluetooth: Add err/reason parameters to connected/disconnected calls
This is essential so that the application can be notified of
connection failures and also be able to know the reason for the
disconnection.

Change-Id: I30108958963f6aeac690612bb26738dc4c67ca80
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Szymon Janc 2dcde0fe04 Bluetooth: Fix registering LE fixed channels on BR/EDR link
This is a minimal fix as for now only LE fixed channels are supported.

Change-Id: Id88cae49f5cdbe3b9d3695995929d601a3b561bd
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:19 -05:00
Szymon Janc 66f0ad5335 Bluetooth: Fix updating SMP keys on BR/EDR
This should be done only for LE links.

Change-Id: I3037e5fbceb39de46ec0be389401f5e907837399
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:19 -05:00
Szymon Janc 28711287a5 Bluetooth: SMP: Remove not needed NULL check from bt_smp_update_keys
This function is always called with valid connection.

Change-Id: I756990a22f7c56939fd8e92c498d722a0467ab84
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:19 -05:00
Szymon Janc ff6b44dfcf Bluetooth: ATT: Use l2cap channel callback for security check
There is no need for using conn security calback while l2cap
channel provides encryption callback.

Change-Id: I84872bca7a7b4334b52810bafd0faa2bb1e381de
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg 0df7a2fac6 Bluetooth: Add error return to authentication APIs
The authentication APIs may fail, so it's fair to give the application
a chance to catch these errors.

Change-Id: I323df86b94a823b201fe22d412e6bbcaa9029550
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg 8bf880a388 Bluetooth: Use smallest possible size for enums
Use __packed so that enums consume the smallest possible size (in our
case the same as uint8_t).

Change-Id: I0440113e88a24509f406375d99173ddb54890925
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Johan Hedberg 3c47e9515c Bluetooth: Update advertising API
Update the advertising API according to what has recently been
discussed and agreed upon.

Naming-wise the most important change is the removal of "EIR" which
was confusing since this is mainly used with LE at the moment. The
Core Specification Supplement consistently uses the generic terms data
and data type to describe what we're dealing with here, so the new
names are bt_data and BT_DATA.

Another change is to detach the actual data from the struct by
converting it from an array to a pointer. This is not only essential
for supporting BR/EDR (which has a different length) but to also
minimize memory usage.

Another change is to require the caller of bt_le_adv_start() to
provide the array lengths of the ad and sd paramters. This way we
don't have to have the empty (8-byte) element at the end of each
array.

Lastly, the bt_le_adv_start() logic is slightly modified so that it
will always clear the respective data if necessary. Previously the
user might have been left with a previous callers data if it passed
NULL to the API.

Change-Id: I318026ceb1b52bb688edf4dcfed82613bd15c3e1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:19 -05:00
Szymon Janc 7c7b0653bb Bluetooth: Update bt_conn_get_info
Allow to query for connection info in every state. For BR/EDR
connection destination address is valid in every state. For LE
addresses are initialized to BT_ADDR_LE_ANY until connection is
completed.

Change-Id: I0f0abcd0ff0119a82ef8eeb40c8ee3af25eb89b4
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:18 -05:00
Szymon Janc 1a54c49ceb Bluetooth: Fix calling timeout fiber for BR/EDR connection
This timeout is used only on LE link to cancel ongoing LE connection.
For BR/EDR link controller will handle page timeout.

> HCI Event: PIN Code Request (0x16) plen 6
        Address: XX:XX:XX:XX:XX:XX (Sony Mobile Communications AB)
< HCI Command: LE Create Connection Cancel (0x08|0x000e) plen 0
> HCI Event: Command Complete (0x0e) plen 4
      LE Create Connection Cancel (0x08|0x000e) ncmd 1
        Status: Command Disallowed (0x0c)

Change-Id: I6a03da7f935f0c560d57f18abc16069d79e2be69
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:18 -05:00
Szymon Janc 76079bc53a Bluetooth: Fix missing negative PIN reply
If connection was not found or PIN handler is not present legacy
pairing should be terminatde with negative PIN reply.

Change-Id: I8a8658f6eb28173537f39226c3792957a28aa7b2
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:18 -05:00
Szymon Janc 64450f1933 Bluetooth: Simplify pin_code_reply function
Move PIN checks up to caller and make pin_code_reply handle just
HCI command.

Change-Id: I159aada8f097407d8ccdc53031ea280e69204091
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:18 -05:00
Szymon Janc d8355793d1 Bluetooth: Simplify pin_code_neg_reply function
There is no need for tracking if connection object exists.

Change-Id: I14047631b4697f892139a414c248542a2b3ae3d6
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:18 -05:00
Szymon Janc bdbd425d42 Bluetooth: SMP: Remove unused function declaration
Change-Id: I8de54a275a2d5bbc56792bf5f95af8f9e9800018
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:18 -05:00
Johan Hedberg 3f1e253c79 Bluetooth: Reorganize bt_conn to avoid padding
Change-Id: I9163bc532a664c7ba82ce11194e471de162078ea
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:18 -05:00
Arkadiusz Lichwa d9d26c2d1a Bluetooth: BR/EDR: Always enable security context fields
Always enable in connection object context fields related to security
requirements and encryption.
So far they were enabled only when Kconfig BLUETOOTH_SMP option is on.

Change-Id: Ib7da9ba1df97df5c08b00769c8ba078dfa63ff56
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:18 -05:00
Arkadiusz Lichwa e6bc2ebc98 Bluetooth: Reduce bt_keys size
Makes bt_keys struct more compact saving 4 bytes.

Change-Id: I30976068d546e02f59ae702b477cf8e5086ccec8
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:18 -05:00
Arkadiusz Lichwa 524ef5ee1d Bluetooth: Refactor type of keys as flags
Converts bt_keys type to atomic_t flags to enable consistent and
compact key type management.

Change-Id: Ie384168da6d5d0d1b305a33988ce7689ba3a4c6a
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:18 -05:00
Andrei Emeltchenko 2382ab3db7 Bluetooth: Remove unneeded NULL check
Removing unneeded check makes code consistent since there is check only
in one branch. Moreover since code is executed in tx_fiber frag cannot
be NULL (result of bt_conn_create_pdu()).

Change-Id: Id2f19279f604ad52019d9c334bc29641e4341037
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:18 -05:00
Ravi kumar Veeramally d4380a1e40 net: Fix uip debug hex dump format
Print two digits (0 prepended) till 0x0F. Do not print any
count in the beginning of output.

Change-Id: I07e8437f827604565fc8b86d81a105b3986f0a72
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:25:18 -05:00
Ravi kumar Veeramally 810c510664 net: coap: Fix wrong app data
CoAP context send message data pointer is internal to coap.
ip_buf_appdata points &uip_buf(buf)[UIP_IPUDPH_LEN]. coap
internal data pointer assignment to ip_buf_appdata is wrong.
So copy data to ip_buf_appdata.

Change-Id: I3f11da382a227572c9080b210104a5b8e3dc34b4
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-02-05 20:25:18 -05:00
Mariusz Skamra af8ec50e0d Bluetooth: GATT: Fix warning message
Warning shall indicate that characteristic don't have value,
not descriptor.

Change-Id: Ic368f57ddafb8bad597ec71d3cfcfb9e61fde434
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:18 -05:00
Mariusz Skamra dd0186c4d0 Bluetooth: GATT: Fix Read By Type response for Include attribute type
In Read By Type response, GATT Server shall send UUID of a included
service only if this service UUID is 16 bit. Otherwise GATT Client
will send Read Request to get 128 bit UUID.

Fix tested with PTS.

> ACL Data RX: Handle 64 flags 0x02 dlen 11     [hci0] 1125351.430506
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x0001-0xffff
        Attribute type: Include (0x2802)

< ACL Data TX: Handle 64 flags 0x00 dlen 12     [hci0] 1125351.435346
      ATT: Read By Type Response (0x09) len 7
        Attribute data length: 6
        Attribute data list: 1 entry
        Handle: 0x0002
        Value: 01000200

> ACL Data RX: Handle 64 flags 0x02 dlen 7      [hci0] 1125351.605504
      ATT: Read Request (0x0a) len 2
        Handle: 0x0001

< ACL Data TX: Handle 64 flags 0x00 dlen 21     [hci0] 1125351.613432
      ATT: Read Response (0x0b) len 16
        Value: efcdab89674523b10040510450aa00f0

Change-Id: Ie07ec7930663b04dc134ee1c5a95c4e0670f5926
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:17 -05:00
Mariusz Skamra 4e5d6581c0 Bluetooth: GATT: Split Authorization Permission for Read and Write
According to Core Specification 4.2 Vol 3, Part G, 3.3.3.4,
Server Characteristic Configuration descriptor shall be:
"Readable with no authentication or authorization.
Writable with authentication and authorization defined by a
higher layer specification or is implementation specific."
So there shall be separate authorization permissions
for write and read access.

Change-Id: Ia2850acbb976571743bf96cf9cbe0c1128534073
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:17 -05:00
Peter Mitsis 54b782a88b nano_sema: Simplify nano_xxx_sem_take() API family
Changes the nanokernel semaphore API so that the timeout parameter must be
specified when invoking nano_isr_sem_take(), nano_fiber_sem_take(),
nano_task_sem_take() and nano_sem_take().

This obsoletes the following APIs:
	nano_fiber_sem_take_wait()
	nano_fiber_sem_take_wait_timeout()
	nano_task_sem_take_wait()
	nano_task_sem_take_wait_timeout()
	nano_sem_take_wait()
	nano_sem_take_wait_timeout()

Change-Id: If7a4bce1bd8ec8d6410d04f3c16ff1922ff0910e
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:25:14 -05:00
Peter Mitsis cd6db374de nano_fifo: Simplify nano_xxx_fifo_get() API family
Changes the nanokernel FIFO API so that the timeout parameter must be
specified when invoking nano_isr_fifo_get(), nano_fiber_fifo_get(),
nano_task_fifo_get() and nano_fifo_get().

This obsoletes the following APIs:
	nano_fiber_fifo_get_wait()
	nano_fiber_fifo_get_wait_timeout()
	nano_task_fifo_get_wait()
	nano_task_fifo_get_wait_timeout()
	nano_fifo_get_wait()
	nano_fifo_get_wait_timeout()

Change-Id: Icbd2909292f1ced0bad8a70a075478536a141ef2
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:25:14 -05:00
Szymon Janc 075e2c430a Bluetooth: SMP: Fix missing buffer unref for LE SC only mode
If pairing is rejected due to unsatisfying auth requirements
pending response buffer should be freed.

Change-Id: I8bbdad5fac8cd6dbcd674c7ad9725cf44ef79004
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:10 -05:00
Szymon Janc f80deda9d2 Bluetooth: SMP: Add support for Secure Connection Only Mode
This patch introduce new Kconfig option that is used to indicate if
device should operate in Secure Connection Only Mode. Enabling this
option removes support for LE Legacy Pairing.

Change-Id: If224b6786f4c840959fe87a31f0224bc1e21f90e
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:10 -05:00
Johan Hedberg 005b9904a4 Bluetooth: Don't pass length of PIN code to bt_auth_pincode_entry
We can calculate the length with strlen() and there should be no need
to consider anything else except nul-terminated C strings.

Change-Id: I02ec4b1dddbb1bd457f035926c86b27f4c2ab050
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:10 -05:00
Arkadiusz Lichwa 9b861d9fee Bluetooth: BR/EDR: Enable link key notification handling
Enables generate link key notification event when legacy PIN code
pairing is done well and give possibility to grab the link key for
later connections.

Change-Id: I5e661c203bbebfa8aa931662a479a1b921f7ace9
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:10 -05:00
Arkadiusz Lichwa 05bdf42367 Bluetooth: BR/EDR: Enable cancel PIN code request
When PIN code authentication is requested now there's a way
for user to respond with negative reply.

Change-Id: I800bf535f6ae98ee367393c686d6897f50b5fe8b
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:10 -05:00
Arkadiusz Lichwa 6828fb7060 Bluetooth: BR/EDR: Implement PIN code reply API
Enables legacy PIN code reply API to user.

Change-Id: I65aa78c2f35dd39f60e48e7280d2379baf07107e
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:10 -05:00
Szymon Janc 9a367fc363 net: Fix not setting loopback address in loopback driver
Using empty eui64 array resulted in net_set_mac() failure and
address was never set. This used to work only due to
linkaddr_node_addr being being global (and hence zeroed).

Change-Id: Ie21de35a628956c6221b6f1e4c96a1807a1d2804
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:09 -05:00
Luiz Augusto von Dentz b839882c69 Bluetooth: UUID: Introduce bt_uuid_copy
This introduces bt_uuid_copy which can be used to copy UUID values.

Change-Id: I22d996bcace454769ac871a43b9acebe8b23db39
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:09 -05:00
Arkadiusz Lichwa d34e498d04 Bluetooth: BR/EDR: Extend bt_conn_info type
Enables get basic connection info support for non-LE connections.

Change-Id: If295b552567886256cfc1e215bfe3149d2f1f60c
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:09 -05:00
Arkadiusz Lichwa 1fb522d0ff Bluetooth: BR/EDR: Rename connection req event handler
Shorten conn_req_event handler name to conn_req.

Change-Id: I74e69cc9e105a4b8c35c08dc182b36d15bfcaa41
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:09 -05:00
Arkadiusz Lichwa 19ee83ec19 Bluetooth: BR/EDR: Handle PIN code request
Unmasks pin code request to be able service
pairing request from legacy 2.0 devices.

Change-Id: I5c09232d8e6e2c7673a35205e0bfeb8c8240388e
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:09 -05:00
Arkadiusz Lichwa 0afdae9677 Bluetooth: SMP: Refactor authentication
Moves object handling user authentication callback interface exposed
in public API to hci core module and exports internally LE SMP
authentication handlers.
The stack authentication API methods call based on connection type
the correct internal methods. Currently only LE SMP backend
is implemented.
Make getting local io capa in runtime.

Change-Id: I17459096616a620467b4fa01c53fd4bc0b59af9b
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:09 -05:00
Szymon Janc aff8c2109c Bluetooth: Fix reading remote features after disconnect
If connection was disconnected from connected callback there is
no point in going with reading remote featurea and updating
connection parameters because.

> HCI Event: Command Status (0x0f) plen 4
      LE Create Connection (0x08|0x000d) ncmd 1
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 19
      LE Connection Complete (0x01)
        Status: Success (0x00)
        Handle: 76
        Role: Master (0x00)
        Peer address type: Public (0x00)
        Peer address: 7C:2F:80:94:97:39 (Gigaset Communications GmbH)
        Connection interval: 50.00 msec (0x0028)
        Connection latency: 0.00 msec (0x0000)
        Supervision timeout: 4000 msec (0x0190)
        Master clock accuracy: 0x00
< HCI Command: Disconnect (0x01|0x0006) plen 3
        Handle: 76
        Reason: Remote User Terminated Connection (0x13)
> HCI Event: Command Status (0x0f) plen 4
      Disconnect (0x01|0x0006) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2
        Handle: 76
> HCI Event: Command Status (0x0f) plen 4
      LE Read Remote Used Features (0x08|0x0016) ncmd 0
        Status: Success (0x00)
> HCI Event: Disconnect Complete (0x05) plen 4
        Status: Success (0x00)
        Handle: 76
        Reason: Connection Terminated By Local Host (0x16)
> HCI Event: LE Meta Event (0x3e) plen 12
      LE Read Remote Used Features (0x04)
        Status: Unknown Connection Identifier (0x02)
        Handle: 76
        Features: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00

Change-Id: I1df211d429383406eda2d23eb1e5fec425ba3427
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:09 -05:00
Szymon Janc b6221d4a5c Bluetooth: Fix GATT client build without SMP
If GATT client is enabled but SMP is disabled NULL SMP backend
needs to provide bt_smp_sign stub.

  LD      zephyr.elf
net/built-in.o: In function `bt_att_send':
net/bluetooth/att.c:1747: undefined reference to `bt_smp_sign'
Makefile:757: recipe for target 'zephyr' failed
make[2]: *** [zephyr] Error 1

Change-Id: Ia740d6c7ca7d65b78f7ecb781275d1f4d635baf7
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:09 -05:00
Szymon Janc 89a7aa8d72 Bluetooth: SMP: Fix legacy pairing
This fix a regression where incorrect confirm function was used
for legacy pairing.

Change-Id: Ia39aed6b8e9a3cb24b451cdb0219f41ceb5e6c6e
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:09 -05:00
Johan Hedberg 8ff6884077 Bluetooth: Fix buffer overflow with ACL fragments
The fragments we create should not be greater than the connection ACL
MTU (which the code already does correctly) but they can also not be
greater than the buffer has room for data. Fix this by taking the
minimum of the connection MTU and the buffer tail room.

Change-Id: I27462d7e8752773c632d212b28e53a8cf6519972
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:09 -05:00
Szymon Janc bc18a867b4 Bluetooth: Fix compilation with SMP disabled
This fix SMP dependency checks in connection code.

Change-Id: Ic7e515885381bd243c89f2a6e10c356095e79b55
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:08 -05:00
Szymon Janc 74333b74af Bluetooth: SMP: Fix NULL backend compilation
This was not building due to bt_l2cap_create_pdu API change.

  CC      net/bluetooth/smp_null.o
net/bluetooth/smp_null.c: In function 'bt_smp_recv':
net/bluetooth/smp_null.c:59:2: warning: passing argument 1 of 'bt_l2cap_create_pdu' from incompatible pointer type [enabled by default]
  buf = bt_l2cap_create_pdu(conn);
  ^
In file included from net/bluetooth/smp_null.c:32:0:
net/bluetooth/l2cap_internal.h:136:17: note: expected 'struct nano_fifo *' but argument is of type 'struct bt_conn *'
 struct net_buf *bt_l2cap_create_pdu(struct nano_fifo *fifo);

Change-Id: I5fd8ce63da09af1c123b1092624d48edc009756b
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:08 -05:00
Andrei Emeltchenko 7160c9c95e Bluetooth: Move BT_STACK definitions to log.h
BT_STACK depends on BT_STACK_DEBUG_EXTRA, therefore moving it there.
It also allows to use BT_STACK in drivers, at the moment only
Bluetooth stack uses it.

Change-Id: I41e0e0d49dae6abef2dc3a8d1d109127787d3db0
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:08 -05:00
Szymon Janc 349a5af841 Bluetooth: Refactor le_ltk_request function
This is in preparation for LE SC only mode support where slave LTK
support is not compiled in.

Change-Id: Ia30ca08010f8aa42752c4a422fd0ddc1fbdb4f31
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:08 -05:00
Szymon Janc f0cc127b5f Bluetooth: SMP: Rename gen_method table to gen_method_legacy
Make sure the name reflects that it is used only for legacy pairing.

Change-Id: I757311991e9f879f377978b8adb02c7f9758b6b2
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:08 -05:00
Szymon Janc 7e1e124b8c Bluetooth: SMP: Separate legacy pairing code
All legacy pairing code is now separated in dedicated helper functions
(with 'legacy' prefix). Main code flow is LE SC oriented and legacy
pairing is always handled as exception from LE SC code:

if (!atomic_test_bit(&smp->flags, SMP_FLAG_SC)) {
  return legacy_foo(smp);
}

This is in preparation for enabling LE SC only mode.

Change-Id: I89705e6b780014417adaed41bd3beaf4791d8d3f
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:08 -05:00
Szymon Janc 7f2de1dc7a Bluetooth: SMP: Make bt_smp_create_pdu static
This function is not used outside of smp.c file.

Change-Id: Ib2158330959f2b4b1d63695480e82ac506243ab8
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:08 -05:00
Szymon Janc 68a4aebde4 Bluetooth: SMP: Move some code up in a file
Those will be used in legacy pairing code.

Change-Id: I311e10254a603c2b4cc46c50f6c3d27593a10bd7
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:08 -05:00
Louis Caron 7fdb42a46f Bluetooth: add CPF descriptor support
In order to support more standard descriptors, the PF macro and helper
function are added.

Change-Id: I52db3c32f40f39b9c6bfdb9573d0a614d0f3295e
Signed-off-by: Louis Caron <louis.caron@intel.com>
2016-02-05 20:25:08 -05:00
Louis Caron d566c3314b Bluetooth: add CUD descriptor support
In order to support more standard descriptors, the UD macro and helper
function are added.

Change-Id: Ic9a82658668107b40abc5c98002fe5091dc10f08
Signed-off-by: Louis Caron <louis.caron@intel.com>
2016-02-05 20:25:08 -05:00
Mariusz Skamra b90d2c6dbd Bluetooth: GATT: Pass bt_conn to the discovery function callback
This patch replaces bt_gatt_attr_func_t with bt_gatt_discover_func_t
to be used as a type of discovery callback. The reason is
bt_gatt_attr_func_t don't return bt_conn which could be used
later on to issue other commands and to application to know
from which connection this results come.

Change-Id: I1f26c72ad5c8a0b97485a337c7005d34281586d7
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:08 -05:00
Andrei Emeltchenko 54c0790b1f Bluetooth: Improve error message printed
Include expected opcode to print together with received opcode.

Change-Id: Iacc73c12f22fe0585e2753d709646bacd3e73d32
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:07 -05:00
Andrei Emeltchenko cc7349b2d8 Bluetooth: Replace fiber_fiber_ with fiber_
We use fiber_delayed_start() for starting delayed fiber. Make use of
fiber_delayed_start_cancel() instead of
fiber_fiber_delayed_start_cancel().

Change-Id: I2399290496ed2a2b21b2a780d884881839f36767
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:07 -05:00
Szymon Janc 873cbfb470 Bluetooth: Kconfig: Move SMP related option under BLUETOOTH_SMP
This makes menuconfig easier to navigate.

Change-Id: Ica49bbbde73c785f218846380fd46d5463424890
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:07 -05:00
Szymon Janc 3670e7fcd0 Bluetooth: SMP: Minor codestyle fix
Change-Id: I115fda172698881c69ed301e5f729bb32c1cb978
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:07 -05:00
Szymon Janc 755130ad68 Bluetooth: SMP: Fix setting ediv and rand for LE SC LTK
Change-Id: Ic8867a510864a8cfb30af30c505d25faa91c2fb7
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:07 -05:00
Johan Hedberg 7493cadee7 Bluetooth: Reduce hci_cmd_complete() stack usage
Instead of storing a pointer to the status (4 bytes) we can just copy
its value directly (1 byte). Since the previous variable is a 16-bit
opcode the smaller 1-byte variable should fit within the same 4-byte
word, saving 4 bytes from the stack.

Change-Id: I406c60c7b2563ba6397ab75cf1dbe3d346b6c0ed
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:07 -05:00
Luiz Augusto von Dentz 4a20bc14a7 Bluetooth: Make use of BT_UUID_DECLARE_16 for services
This makes it simpler to add the services directly into GATT services
table.

Change-Id: I090c7f9396329cf524947dd6647230c663a55f60
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:25:07 -05:00
Johan Hedberg 30e0e64407 Bluetooth: Add color logging support
Add basic color logging support. Error logs will be printed in red
whereas warn() logs in yellow. The support is behind a Kconfig option
in case someone needs to build the stack for a terminal that doesn't
support the ANSI color codes.

Change-Id: I080e32db68f87e81f1bb54aa4c634f7cd38f1e33
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:07 -05:00
Anas Nashif f6f81868f8 build: Remove PROJECTINCLUDE from application makefiles
PROJECTINCLUDE is not required in app makefiles.

Change-Id: I3751b7c51c453dfe47d207bb11d171138668c4e7
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:25:04 -05:00
Johan Hedberg c692c1672a Bluetooth: Fix passing bool instead of NULL pointer
Change-Id: I230c7b450587d85ba96cd4c71653eff0d9d56dcc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:03 -05:00
Arkadiusz Lichwa bf8179be9e Bluetooth: BR/EDR: Enforce BLUETOOTH_CONN be set
Whenever selects BR/EDR support in Kconfig, make BLUETOOTH_CONN
option be set as well due to for BR/EDR devices fundamental behaviour
is interact with others by making ACL based connections.

Change-Id: Ieffd2fc6aa47278112be177e5a7e2021e50b0fa3
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:03 -05:00
Arkadiusz Lichwa f0572cfb61 Bluetooth: BR/EDR: Update of hci_disconn_complete
As a cleanup of just made disconnection don't touch LE specific
actions.

Change-Id: I0c7c42f47ac8f6683380124df571fa2b2afbf526
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:03 -05:00
Arkadiusz Lichwa 853ab787e7 Bluetooth: BR/EDR: Initial connection complete handling
Enables getting by host connection complete event and handle
internal state of related to the event connection object.

Change-Id: Ie6252ff33cc2e1fff5a4ce746fda7c3a59bf8aab
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:03 -05:00
Arkadiusz Lichwa 7abddd2bdf Bluetooth: BR/EDR: Look up conn by BT address helper
Defines helper routine to look up conn pool object for existance
of instance matching requested bluetooth address.

Change-Id: I31e05afb2346c7dab14e7ba1bd2f4e1378876ae0
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:03 -05:00
Arkadiusz Lichwa db57e259a7 Bluetooth: BR/EDR: Rename BT_CONN_TYPE_BREDR
To conform to API convention rename BT_CONN_TYPE_BREDR to BT_CONN_TYPE_BR.
Updates stack code so far uses it.

Change-Id: Ia759ef68bbdb232e3b0992740e0536d310e19010
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:02 -05:00
Johan Hedberg ad425d4dae Bluetooth: Fix connection type check in bt_conn_lookup_state
Change-Id: I543b18ecaa714c1c15ed45b5bc911272dd13b49a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:02 -05:00
Johan Hedberg d2f90fad61 Bluetooth: Fix missing conn type check in bt_conn_lookup_addr_le
Change-Id: Ib98b257daf0a64f441e8532f615bbf5c84ee887e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:02 -05:00
Johan Hedberg 719aab5ce3 Bluetooth: BR/EDR: Reject SCO connections until we support them
Change-Id: I73ae6d02a00d06ccfc382c86599df338f68cb6a5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:02 -05:00