Commit Graph

1412 Commits

Author SHA1 Message Date
Arkadiusz Lichwa af2deb8dea Bluetooth: BR/EDR: Move up code in conn.c
Moves up and consolidate the BREDR specific code to skip certain forward
declaration and to prepare for possibility to initiate authentication
using start_security() routine.

Change-Id: Ic32d7d1376173d47b0eb0481eff37c6e56f995d4
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-04-11 19:15:24 +00:00
Mariusz Skamra 550d031107 Revert "Bluetooth: Fix compare logic in ATT read rsp"
This reverts commit 3d08d16780.

The Read Response only contains a Characteristic Value that is less than or
equal to (ATT_MTU – 1) octets in length so, condition
(length < bt_att_get_mtu(conn)) is always true, and the full Characteristic
Value will not be read.

Change-Id: I63280e65b4ff5b830295aa9aadebe2758b626912
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-04-11 15:24:33 +00:00
Arkadiusz Lichwa 435ccd3e81 Bluetooth: BR/EDR: Refactor internals of 'Cancel' authentication API
For better code readability use 'switch-case' statement selecting valid
authentication cancel method. Adds also legacy pairing (pre-SSP) as first
item in valid paring method set.

Change-Id: I4d9c5178526cd5210b844878360d12b58b99a24f
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-04-11 11:53:31 +00:00
Arkadiusz Lichwa 8f844fac29 Bluetooth: BR/EDR: Rename pair method field
Refines pairing method holder name to be more generic in connection object
representing applied method during authentication process.

Change-Id: Ia6f51788912974fbbda26b760d187c0f7e24bb0b
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-04-11 11:53:10 +00:00
Johan Hedberg 54425117d0 Bluetooth: Export helpers for defining buffer pools
Now that the incoming ACL & HCI event pools can be defined externally
to hci_core.c there should be convenience macros to know what's the
minimum required buffer size for these pools.

Change-Id: I6f2a7322a3d77e1304e9d925767a1fd3471c76c7
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-11 11:52:38 +00:00
Johan Hedberg 30601c09bb Bluetooth: Refactor buffer handling for non-host managed buffers
So far the assumption has been that the host stack manages all
incoming and outgoing buffers. For the incoming buffers (from the
controller) this has required hci_core.c to manage its own pools and
do the host flow control. This setup makes perfect sense for an
architecture where the controller resides remotely on a different CPU
& address space (i.e. the "traditional" HCI transport case).

When the stack runs on a system where the controller resides in the
same address space this setup doesn't work that well. In such a
scenario the incoming buffers are ideally created as low down in the
stack as possible (i.e. below HCI), which means that the current
hci_core.c cannot be responsible for managing their pools.

To allow for both types of architectures this patch introduces a new
BLUETOOTH_HOST_BUFFERS Kconfig option that can be selected to say that
host-side management is desired, or deselected to say that the
controller (residing in the same address space) takes care of managing
the incoming buffers.

So far the incoming buffer types were identified by hci_core.c by
looking at their "free pool" pointers, however as soon as the pools
are allowed to be somewhere else this doesn't work. To solve this we
now require a minimum user data size for all Bluetooth buffers and use
that to store the buffer type.

Change-Id: I14bc32007e3e3f17c654f71f79b520650028d7ce
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-11 11:52:29 +00:00
Jukka Rissanen 14cc0401b4 Revert "net: Use TICKS_UNLIMITED if there are no timers"
This reverts commit 5680396aaa.

The network timers do not trigger with this patch so this needs
to be reverted for time being.

Change-Id: If653e3ecaae1ebddabe26227af876ff6b592675b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-04-11 07:33:17 +00:00
Johan Hedberg 30fcb2fdca Bluetooth: L2CAP: Store BR/EDR fixed channel mask per channel
This information will be used to construct the fixed channel mask in
the L2CAP information response.

Change-Id: I66244ca2d5e40b3d204f5115c4bddad578f3ea64
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-09 20:03:25 +03:00
Johan Hedberg 8a2c7915e3 Bluetooth: L2CAP: Fix logs to account for BR/EDR signaling channel
The same l2cap_recv function is now used for BR/EDR as well so remove
LE references from the logs.

Change-Id: I841ceea2eee72ee099be922eb00c1f6a3a16a787
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-09 20:03:25 +03:00
Johan Hedberg 52401300f3 Bluetooth: L2CAP: Fix missing line termination
Change-Id: I28f18c1afbb168ed021bd15962b2087066eed341
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-09 20:03:24 +03:00
Arkadiusz Lichwa a5d264774e Bluetooth: BR/EDR: Make available L2CAP signal channel
Makes room for L2CAP signal channel transport and start listening
on signalling CID.

Change-Id: I152973a9a9e672f0b4f66b06055e305561123f34
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-04-09 16:24:01 +00:00
Arkadiusz Lichwa 83674b1d52 Bluetooth: BR/EDR: Get proper L2CAP CID limits
Applies L2CAP CID valid values based on link type and proper limitations
according to BT Core L2CAP spec principles.

Change-Id: Ifa0719cf593d1d22977da59fb8a6c0ed9c3a176b
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-04-09 16:20:58 +00:00
Arkadiusz Lichwa f6cdc3f3ab Bluetooth: BR/EDR: Refactor bt_l2cap_connected handler
Makes possible to initiate L2CAP signalling handling on set connection
based on connection transport type.

Change-Id: I114dc3e4408f428301628520a569a2b087c325b8
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-04-09 16:19:23 +00:00
Arkadiusz Lichwa d719c362f1 Bluetooth: BR/EDR: Add register routine for L2CAP fixed channel
Makes available to register fixed L2CAP signalling channel on
dedicated channels list.

Change-Id: I9a90a64dac40b34799353ff261ba570541347084
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-04-09 16:18:54 +00:00
Arkadiusz Lichwa 740bd96abc Bluetooth: Rename bt_l2cap_fixed_chan_register()
Renames routine to be clear to be used to register LE L2CAP fixed
channel only. The routine operates on le_channels list object that also
was renamed to reflect the connection type. Updates all calls to
the procedure in the stack.

Change-Id: I01348b8186a0f537532f6a7b9dc59586827b204b
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-04-09 16:18:26 +00:00
Ravi kumar Veeramally 79bf4a0e5a net: coap: Create buffer while generating observe notification
CoAP observe notifications are originated from server, those
are not replies. So create a new buffer and copy remote address
and port number from obs list. Set udp_conn to null as this is
new buffer. Reason for setting the udp_conn to null is that there
is a chance that buffer might already have udp_conn set due to
reusing same buffers.

Change-Id: I3c7eada987cf539d77ea162b6f5901791cfa6ee0
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-04-08 13:38:07 +00:00
Ravi kumar Veeramally db247d0fa1 net: coap: Use correct network buffer in serialization
Need to use the network buffer when sending CoAP serial message
because the message was constructed to net_buf

Change-Id: I74c54178707edf2d8451ce5ac719d63f99661332
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-04-08 13:38:07 +00:00
Ravi kumar Veeramally ee858020dc net: Fix ip_buf_len after removing extra header
After removing extra header from IP packet, only uip_len is
updated not ip_buf_len. uip_len parameter is set to zero
at some point after handover to net_core. From net_core
only ip_buf_len holds the actual length. So update ip_buf_len
after removing extra header.

Change-Id: I2cc03ed1125df5216a0fa6e94eebfeee0a343481
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-04-08 13:38:07 +00:00
Ravi kumar Veeramally e37dd00f6b net: Add Kconfig debug option for coap observe and well-known
User can activate debugging in coap observe and well-known by
setting CONFIG_NETWORK_IP_STACK_DEBUG_COAP_OBSERVE and
CONFIG_NETWORK_IP_STACK_DEBUG_COAP_WELL_KNOWN option in config file.

Change-Id: Id63824c88df1a84586518eaec8a8a929ae04b717
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-04-08 13:38:07 +00:00
Ravi kumar Veeramally f27af5afb7 net: Add Kconfig debug option for simple udp and udp packet
User can activate debugging in simple UDP and UDP packet by
setting CONFIG_NETWORK_IP_STACK_DEBUG_SIMPLE_UDP and
CONFIG_NETWORK_IP_STACK_DEBUG_UDP_PACKET option in config file.

Change-Id: I581d4b33204f26119c5b194cb367adad8c6505c2
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-04-08 13:38:06 +00:00
Jukka Rissanen 01771500ee net: contiki: Fix the timer expiration check
We need to check the timer expiration properly. The nano_timer_test()
will return user data to caller if the timer is expired.

The issue that is fixed by this commit started to appear after
the commit 9b2452047d which combined
nano_timers and nano_timeouts.

Change-Id: I9cf10e605f1c4767caa1aad9dcf29a159af55e28
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-04-08 11:33:19 +00:00
Jukka Rissanen 0be1fa53b4 net: Add Kconfig debug option for REST API
User can activate debugging in REST by setting
CONFIG_NETWORK_IP_STACK_DEBUG_REST_ENGINE option in config file.

Change-Id: I1c1c62803c0fcc5fb3a37d3d76de94754b33506a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-04-08 11:33:19 +00:00
Jukka Rissanen 6c703542d5 net: coap: Make sure that local endpoint IP address is set
When initializing the CoAP engine, make sure that we
initialize the local IP address properly.

Change-Id: I8ddc670371c3a58095cd5db6b435c5b1793c268b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-04-08 11:33:19 +00:00
Jukka Rissanen 21161a39fe net: coap: Delete network context when CoAP context is deleted
Network context must be cleared when CoAP context using that
is removed.

Change-Id: Id8deb798919fccf025af67c18f3a246cfa46598f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-04-08 11:33:18 +00:00
Jukka Rissanen 70ffc56a95 net: coap: Add debugging support for CoAP internals
Print info about packet serialization if debugging is turned on.

Change-Id: I578ecb4e85ab34c74a960cbce9aa4f9bf5b9473d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-04-08 11:33:18 +00:00
Jukka Rissanen 24911b81bd net: contiki: Enhance the IPv6 prefix calculation routine
The routine does not check prefixes properly which are not
multiple of 8.

Change-Id: I421456720541894eb4d9a2839361095a50587513
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-04-08 11:33:18 +00:00
Jukka Rissanen 7eb15eeb56 net: coap: Add debug activation support to Kconfig
User can select various coap debugging options from Kconfig.

Change-Id: I97cc82278c230b9678f506063fed5683dc271c8a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-04-08 11:33:18 +00:00
Luiz Augusto von Dentz 5680396aaa net: Use TICKS_UNLIMITED if there are no timers
This makes the fiber_sleep sleep indefinitely until fiber_wakeup is
called.

Change-Id: Id674c1f689376784599fc79c86d1c406474bb48f
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-04-08 13:09:52 +03:00
Arkadiusz Lichwa 9385a47e53 Bluetooth: Fix not using endianess helper in LE L2CAP conn req
Corrects response 'result' protocol field to right endianess when
responding to LE L2CAP connection request on error case.

Change-Id: I066bad2f0f3173739676e918f42d425581084dbe
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-04-07 09:20:17 +00:00
Johan Hedberg bc706e2a88 Bluetooth: Add stub for bt_storage_clear()
Change-Id: I7ab9ee4ca1d9702e7aef23aadfa627554907d145
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-05 12:29:14 +03:00
Johan Hedberg d0e4e0183e Bluetooth: Rename bt_register_storage to bt_storage_register
Keep a single bt_storage_* name space for current and future storage
APIs.

Change-Id: If158eb7408cce7c06cd8f98d78a061b9f9585265
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-05 12:29:14 +03:00
Johan Hedberg e70771d3c8 Bluetooth: Export bt_storage inside the stack
It's likely that other files besides hci_core.c will be needing to
read/write the storage. Export it therefore through hci_core.h (same
time adding a missing 'const' to the declaration).

Change-Id: I7c08bc0d69c752bef68f9da9e4aee1acfa00de72
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-05 12:29:14 +03:00
Johan Hedberg 499b44201b Bluetooth: Don't update random address unnecessarily
If the wanted address is already programmed to the controller there's
no need to send a HCI command to change it.

Change-Id: Ib73d09cc5b20cd6820e603f0828f000f8310a89e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-05 12:29:14 +03:00
Johan Hedberg 5ccb20c591 Bluetooth: Use bt_addr_t inside bt_addr_le_t
In many cases when we want to access the 'val' member of bt_addr_le_t
it's in situations where the type needed is actually bt_addr_t. To
avoid unnecessary typecasts in these places simply embed bt_addr_t
inside bt_addr_le_t.

Change-Id: I7eecf129bee1dcf085abc83ec2f32e1a10b0b5aa
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-05 12:29:14 +03:00
Johan Hedberg 13be3947ab Bluetooth: Add Privacy Feature support
Add initial support for the Privacy Feature, including the ability to
manage a local IRK and to use Resolvable Random Addresses.

Change-Id: I1c70aea67078dd2a5d07f3b797c37746ebe9ab61
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-05 12:29:14 +03:00
Johan Hedberg ad7912422f Bluetooth: Introduce SMP helper to generate RPAs
This will be needed to implement local privacy support.

Change-Id: I6222a7d396d47929d6f8946793bbf3f49eaae179
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-04 17:35:02 +03:00
Johan Hedberg 5c45a3bce1 Bluetooth: Export is_bonded through hci_core.c
There will be other uses, so rename this to bt_addr_le_is_bonded and
export it through hci_core.h.

Change-Id: Ia033a215255f2ec2e513c785dd1b9862faaf5ac8
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-04 17:35:02 +03:00
Johan Hedberg 0537c2c579 Bluetooth: Add support for reading local address from storage
If the local controller doesn't have a public address we need to
generate a static random address and use that as our Identity Address.

Change-Id: I3db261b630c670d285c6bfacbe090184cccb5e8c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-04 14:01:59 +03:00
Johan Hedberg 7e7eee0fb4 Bluetooth: Add skeleton for persistent storage API
Add initial skeleton for the persistent storage API.

Change-Id: I7a6cc283aa88e7d861af18a6f0db2ed8c71e44a0
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-04 14:01:59 +03:00
Johan Hedberg 03ea90db8f Bluetooth: Rework local address tracking
Store the Identity Address and Random Address in their own variables.
If the controller doesn't have a public address a static random
address is set as the Identity Address. Also keep properly track of
which address was used for advertising and initiating connections so
that the connection object contains the right information.

Change-Id: I3e9dc2036b330c19c2725b180fd061da2df8a0fa
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-04 13:56:55 +03:00
Johan Hedberg 9eec87a0ef Bluetooth: Remove unnecessary double check for CONFIG_BLUETOOTH_CONN
Change-Id: I3329cf1314cbcd4e6bb7015b9b52fd6c52526567
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-02 20:59:09 +03:00
Johan Hedberg a85b1f7752 Bluetooth: Shorten set_adv_parameters to set_adv_param
The shorter form "param" is used elsewhere and this helps avoid overly
long lines.

Change-Id: Ie76497b5bf30e72099d13a26db9cacb8cd2c9c79
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-02 20:59:09 +03:00
Arkadiusz Lichwa 7420276282 Bluetooth: BR/EDR: Enable cancel Passkey Notify authentication
From now on user/app has possibility to dismiss Passkey Notify authentication
on acceptor side even with DisplayOnly interface. The action on 'Cancel' API
in this case is disconnection.

Change-Id: I4be198482c23c0ccaeb0112b72ff269037e03583
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-04-01 09:26:24 +00:00
Luiz Augusto von Dentz 7b4ddaf73d Bluetooth: GATT: Force write to CCC when reconnecting
Some devices may actually lose track of CCC setting so this is required
to work around the problem, in case the device does work track CCC
properly the extra write shall not cause anything more than one extra
round trip thus it is probably work doing it anyway.

Change-Id: I9e5ed3fa459e4617c6fae094d0ce0f80cb2682e4
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-04-01 09:24:02 +00:00
Johan Hedberg 74dbbcac61 Bluetooth: Make controller to host flow control conditional
Deal with controllers that don't support controller to host control.
This may potentially lead to dropped packets so make a clear warning
log of the issue.

Change-Id: Ie8fdaed826a072fd157343721222f618328d59a3
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-01 08:41:39 +03:00
Johan Hedberg 4763bb9c86 Bluetooth: Move supported commands reading to common_init()
Reading supported commands isn't an LE-specific feature, so the
command should be in common_init() rather than le_init().

Change-Id: I613bbe8d39b4c2b6dadc45a710bc59568ec9b488
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-01 08:37:18 +03:00
Daniel Leung 8df10d4584 kconfig: untangle ordering and dependencies
There are two major issues with the kconfig:

() Some of the config options have incorrect dependencies inside help
   under menuconfig. For example, CONFIG_GPIO depends on BOARD_GALILEO.

() Since the SoC and board specific kconfig files are parsed first,
   the help screen would say, for example, CONFIG_SPI is defined at
   arch/arm/soc/fsl_frdm_k64f/Kconfig. This is incorrect because
   the actual config is defined in drivers/spi/Kconfig.

These cause great confusion to users of menuconfig/xconfig.

To fix these, the SoC and board defaults are now to be parsed last.

Note that the position swapping of defaults in this patch is due to
the fact the the default parsed last will be used.

And, spi_test is broken due to the fact that it requires
CONFIG_SPI_INTEL_PORT_1, but never enables it anywhere. This is
bypassed for now.

Origin: refactored and edited from existing files
Change-Id: I2a4b1ae5be4d27e68c960aa47d91ef350f2d500f
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-26 20:36:32 -04:00
Dmitriy Korovkin 9b2452047d kernel: Combine nano_timers and nano_timeouts
To avoid code duplication nano_timers use nano_timeout
mechanism.

Change-Id: I916bffd2b86e29ee7b7ff7bbb009cd4c844e2a44
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
2016-03-26 09:20:10 +00:00
Szymon Janc e23e4c76e2 Bluetooth: Add support for resolving BR/EDR names
If BR/EDR device didn't provide name in EIR (or no EIR at all) names
are resolved after discovery is completed. Resolved names are put into
EIR block.

> HCI Event: Extended Inquiry Result (0x2f) plen 255
        Num responses: 1
        Address: F0:79:59:03:6B:30 (ASUSTek COMPUTER INC.)
        Page scan repetition mode: R1 (0x01)
        Page period mode: P0 (0x00)
        Class: 0x280424
          Major class: Audio/Video (headset, speaker, stereo, video, vcr)
          Minor class: Set-top box
          Capturing (Scanner, Microphone)
          Audio (Speaker, Microphone, Headset)
        Clock offset: 0x47d5
        RSSI: -88 dBm (0xa8)
> HCI Event: Inquiry Complete (0x01) plen 1
        Status: Success (0x00)
< HCI Command: Remote Name Request (0x01|0x0019) plen 10
        Address: F0:79:59:03:6B:30 (ASUSTek COMPUTER INC.)
        Page scan repetition mode: R1 (0x01)
        Page scan mode: Mandatory (0x00)
        Clock offset: 0x47d5
> HCI Event: Command Status (0x0f) plen 4
      Remote Name Request (0x01|0x0019) ncmd 1
        Status: Success (0x00)
> HCI Event: Remote Name Req Complete (0x07) plen 255
        Status: Success (0x00)
        Address: F0:79:59:03:6B:30 (ASUSTek COMPUTER INC.)
        Name: Nexus Player

Change-Id: Ica5f6cc8a7d9dc7a925025bc62faab2caec47dbb
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-03-26 05:57:34 +00:00
Szymon Janc 067d5cfb63 Bluetooth: Add support for notifying of BR/EDR inquiry results
This allows to notify application of inquiry results.

> HCI Event: Extended Inquiry Result (0x2f) plen 255
        Num responses: 1
        Address: C4:43:8F:A3:4D:83 (LG Electronics)
        Page scan repetition mode: R1 (0x01)
        Page period mode: P0 (0x00)
        Class: 0x5a020c
        ...
        Clock offset: 0x73e8
        RSSI: -66 dBm (0xbe)
        Name (complete): Nexus 5

> HCI Event: Extended Inquiry Result (0x2f) plen 255
        Num responses: 1
        Address: F0:79:59:03:6B:30 (ASUSTek COMPUTER INC.)
        Page scan repetition mode: R1 (0x01)
        Page period mode: P0 (0x00)
        Class: 0x280424
        ....
        Clock offset: 0x47d5
        RSSI: -88 dBm (0xa8)

Change-Id: I36215a7139ae49c50ef71a8b647204bf5063cd13
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-03-25 19:28:24 +00:00