Commit graph

21541 commits

Author SHA1 Message Date
Joakim Andersson
e61d1d0883 Bluetooth: host: Fix compilation error with BR/EDR enabled
Fix compilation error with BR/EDR is enabled but the feature
CONFIG_BT_KEYS_OVERWRITE_OLDEST is disabled.
This caused compilation error because the field aging_counter is not
defined in the keys struct.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-03-15 16:51:51 +02:00
Joakim Andersson
53cea4719d Bluetooth: host: Refactor out advertiser roles from hci_core to adv
Refactor out the advertiser roles handling from hci_core.c to its own
source file in adv.c.
Advertising roles consists of legacy and extended advertiser, and
periodic advertiser.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-03-15 16:51:51 +02:00
Joakim Andersson
be6797ed64 Bluetooth: host: Refactor out scan roles from hci_core to scan
Refactor out the scan roles handling from hci_core.c to its own source
file in scan.c.
Scan roles consists of regular scanning and synchronization to
periodic advertiser.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-03-15 16:51:51 +02:00
Joakim Andersson
c4a9bfbd57 Bluetooth: host: Don't include adv checks when adv is disabled
Don't include checks for advertiser is enabled when the broadcaster role
is not enabled. This makes it possible to have bt_le_ext_adv_foreach
be excluded from the compilation.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-03-15 16:51:51 +02:00
Joakim Andersson
54fe1cd1b3 Bluetooth: host: Refactor out identity handling from hci_core to id
Refactor out the identity handling from hci_core to its own source file
in id.c
Identity consistes of managing the identities of the device, the privacy
feature which hides the identities. And handling of the identity
resolving list in the controller, needed to support privacy-enabled
remote devices.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-03-15 16:51:51 +02:00
Joakim Andersson
517ba3756a Bluetooth: host: Dont include bt_adv_lookup_legacy when adv is disabled
Refactor the code so that bt_adv_lookup_legacy is always called after
the IS_ENABLED(CONFIG_BT_BROADCASTER) configuration has been checked and
the code path will be excluded.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-03-15 16:51:51 +02:00
Joakim Andersson
9ca13ca664 Bluetooth: host: Refactor command state set handling to one function
Refactor command state state handling to one function.
When setting state outside of hci_core the cmd macro is not available,
so in order to assign the buf pointer to state the function is needed.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-03-15 16:51:51 +02:00
Jukka Rissanen
ee2e3dd9fc net: sockets: Provide close method for packet sockets
There was no close method implemented for AF_PACKET type
sockets. This meant that calling close() on packet socket
caused NULL pointer access.

This will allow #32949 issue to work properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-03-15 15:17:52 +02:00
Lukasz Maciejonczyk
1b7755e62a net: openthread: Fix otPlatUartSend
Make sure data for transmission do not overlap each other.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2021-03-15 13:46:36 +02:00
Lukasz Maciejonczyk
4acaae1b1b net: openthread: Fix UART platform callback
OpenThread UART tx callback has been processed even if it was not
triggered by OpenThread otPlatUartSend function.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2021-03-15 13:46:36 +02:00
Martin Jäger
1aaf508bde task_wdt: add task-level watchdog subsystem
This new subsystem can be used to supervise individual threads. It
is based on a regularly updated kernel timer, whose ISR is never
actually called in regular system operation.

An existing hardware watchdog can be used as an optional fallback if
the task watchdog itself gets stuck.

Signed-off-by: Martin Jäger <martin@libre.solar>
2021-03-15 12:24:54 +01:00
Vinayak Kariappa Chettimada
1e79d5b9c6 Bluetooth: host: iso: Fix typo in hci_le_big_terminate
Fix typo in hci_le_big_terminate function name.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-15 10:23:44 +01:00
Krzysztof Chruscinski
1a5fce97b7 logging: swo: Add option to set custom reference frequency
Some devices may use different reference than cpu clock. Add
support for using swo-ref-frequency property when present.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-03-15 10:23:10 +01:00
Marek Pieta
7e469c2f94 log: Fix defining CONFIG_LOG_STRDUP_MAX_STRING
Change fixes an issue related to data access out of array bounds and
suppresses compiler warning.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2021-03-15 10:21:18 +01:00
Robert Lubos
a670c84530 net: sockets: tls: Implement MSG_WAITALL flag
Add MSG_WAITALL flag implmentation for secure sockets.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-03-12 13:57:11 -05:00
Robert Lubos
d47e803976 net: sockets: Implement MSG_WAITALL recv flag
Implement MSG_WAITALL flag for stream sockets. Setting this flag on
`recv()` call will make it wait until the requested amount of data is
received.

In case both, MSG_WAITALL all is set and SO_RCVTIMEO option configured
on a socket, follow the Linux behavior, i. e. when the requested amount
of data is not received until the timeout expires, return the data
received so far w/o an error.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-03-12 13:57:11 -05:00
Johan Stridkvist
a81765bbe4 Bluetooth: HCI: Add option CONFIG_BT_HCI_ACL_DATA_SIZE
Add the option CONFIG_BT_HCI_ACL_DATA_SIZE which allows the user
to configure the max HCI ACL data payload. This is needed for platorms
where the BLE LL, HCI uart and host run on three different cores.

Fixes: #30441

Signed-off-by: Johan Stridkvist <johan.stridkvist@nordicsemi.no>
2021-03-12 20:40:21 +02:00
Joakim Andersson
e06bac0e4f Bluetooth: host: Overwrite existing bond when IRK has been updated
Overwrite the existing bond when the IRK of the existing bond could not
resolve the RPA of the peer. This would happen if the peer has deleted
the bond and replaced the IRK that was used.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-03-12 11:27:43 -05:00
Joakim Andersson
7fee6b8ae8 Bluetooth: host: Refactor update_keys_check to operate on keys as input
Refactor update_keys_check helper function to operate on input keys
input. This allows the function to be re-used on a keys structure that
is not the current connection keys.

This also avoids the helper function changing the connection state.
The conn->le.keys pointer should at this point always have been
assigned, as central when sending the pairing request, and as peripheral
when receiving the pairing request at the very latest.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-03-12 11:27:43 -05:00
Jukka Rissanen
8353225ce0 net: dns: Add locking to prevent concurrent access
Add mutex locks to avoid concurrent access to DNS context.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-03-12 11:26:16 -05:00
Aleksandr Khromykh
73e1c6a77d Bluetooth: Mesh: Fix restoring fast period divisor from settings
The Health Fast Period Divisor is stored within
the model publish parameters on the access layer.
The opposite part for divisor restoring has been missed.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2021-03-12 16:58:09 +02:00
Krzysztof Chruscinski
7e125fe7e4 logging: Add backend parameter to the init function
Added backend parameter to the backend init interface function.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-03-12 09:24:54 -05:00
Trond Einar Snekvik
20ce680d79 Bluetooth: Mesh: Make internal virtual addr pointers const
Adds the const qualifier to the internal api for adding and removing
virtual addresses, to allow them to accept const hardcoded values in
tests.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-03-12 16:17:27 +02:00
Trond Einar Snekvik
9b4266b591 Bluetooth: Mesh: Resolve keys before logging subnet
Moves the debug log printing the transport packet metadata to after the
keys are resolved, so that the subnet pointer is valid.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-03-12 16:17:27 +02:00
Trond Einar Snekvik
66699b8170 Bluetooth: Mesh: Add net transmit status rx in config client
Adds an opcode handler for the network transmit status opcode.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-03-12 16:17:27 +02:00
Trond Einar Snekvik
243e29cc29 Bluetooth: Mesh: Add poll callback for friend role
Adds a "polled" function to the friend callback structure, that gets
called every time the friend receives a poll message. The polled
callback is called before the establish callback, to match the LPN
behavior.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-03-12 16:14:58 +02:00
Jukka Rissanen
ac55c63f08 net: tcp2: Add more debugging for connection unref
Print information who is freeing the connection struct,
this is useful for debugging.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-03-12 15:59:30 +02:00
Jukka Rissanen
1269a23e97 net: shell: The tcp connect command must have a timeout
If there is no timeout, the connect will timeout immediately
and the connection is not established.

Fixes #33185

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-03-12 15:59:30 +02:00
Peter Bigot
52567cf7ce shell: use visitor to get required devices
Update to use the API that will be aware of runtime-added
dependencies.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-03-11 08:53:18 -05:00
Enjia Mai
2c5e2c2394 tests: ztest: provide test execution times per ztest testcase
Add execution time for testing result of each ztest testcase as:

START - test_sem_multi_take_timeout_diff_sem
PASS - test_sem_multi_take_timeout_diff_sem in 2.54 seconds

Fix #32137.

Signed-off-by: Enjia Mai <enjiax.mai@intel.com>
2021-03-11 07:52:17 -05:00
Emil Gydesen
d48b040a78 Bluetooth: Host: Updated ISO SCA description
The SCA (sca) field of bt_iso_chan_qos did not give much
information about the expected values or what they meant,
nor any information about what the value perhaps should be.

Updated the description and the ISO shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-03-11 06:38:08 -05:00
Trond Einar Snekvik
4fbd0cb0ca Bluetooth: Mesh: Perform replay check on SeqAuth
To prevent the transport layer from accepting duplicate or out of order
segmented messages, add an RPL-like check for the SeqAuth of the
segmented messages when their context is allocated. This prevents
duplicate receives of the same segmented messages in the case where a
single source address sends two segmented messages in parallel (to two
different addresses):

Previously, when receiving two segmented messages, the first message
would go through to the access layer, then the second. Then, if the
transport layer received any repeated segments for the first message, it
would fail to identify the SeqAuth as old, as all its segments were of
new sequence numbers, and the "already complete SDU" check would only
look at the second message. Thus, the segmented message got processed
again and passed to the access layer, even though it was a duplicate.

To solve this, we need a mechanism like RPL, but only for the segmented
messages' SeqAuth. We cannot re-use the actual RPL mechanism, as it
can't support the scenario provoked by the "blocking tx" mechanism in
transport. This mechanism allocates the SeqAuth when the message is
first passed to the transport layer. The ongoing message that caused the
block would keep sending segments with higher sequence numbers than
the blocked message got, which will cause the blocked message to fail
the RPL check.

This patch adds a parallel SeqAuth mechanism to the RPL module, which
only deals with the SeqAuth of the segmented messages. This list gets
checked when the segmented message is first allocated, in the same
manner as the general RPL mechanism. The storage gets hooked into the
RPL mechanism, by adding a separate seg field to each RPL entry.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-03-11 12:36:04 +02:00
Jukka Rissanen
b8d4d9bcec net: dhcpv4: The client needs info about network interfaces
DHCPv4 client code needs to know information when network
interfaces are going down and up. So make sure that network
management config options are enabled in that case.

Fixes #33137

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-03-11 12:24:10 +02:00
Vinayak Kariappa Chettimada
0fbf31a147 Bluetooth: controller: Fix auxiliary PDU disable
When Extended Advertising terminated due to duration or
maximum number of events, the auxiliary PDU scheduling
is now correctly stopped.

Fixes #31254.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-10 15:08:47 -05:00
Vinayak Kariappa Chettimada
5b7f4d19bb Bluetooth: controller: nRF5: Move HAL_RADIO_PDU_LEN_MAX into radio_nrf5
Move the define HAL_RADIO_PDU_LEN_MAX into radio_nrf5.h in
the HAL folders.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-10 15:08:31 -05:00
Vinayak Kariappa Chettimada
1643b9453b Bluetooth: controller: nRF: Ensure HAL_RADIO_PDU_LEN_MAX is defined
Add compiler error if HAL_RADIO_PDU_LEN_MAX is not defined.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-03-10 15:08:31 -05:00
Robert Lubos
6a90baa21a net: lwm2m: Make validation cb support optional
Add option to disable validation callback support by setting the
validation buffer size to 0, which allows to save some memory in case
it's not needed.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-03-10 14:55:22 -05:00
Robert Lubos
31e5ec79b8 net: lwm2m: Add data validation callback
Add a data validation callback to the resource structure, which can be
registered by an application. It allows to verify the data before
actually modifying the resource data.

If the callback is registered for a resource, the data is decoded into a
temporary buffer first, and only copied into the actual resource buffer
if the validation is successfull. If no validation is required (and thus
no callback registered) the resource value is decoded directly into the
resource buffer, as it used to be.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-03-10 14:55:22 -05:00
Paul Sokolovsky
e031693e37 net/ip/tcp2_priv.h: th_off: More detailed docstring
Mention that it's "data offset" in 32-bit words. Helpful when doing
code review and using search for "th_off".

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2021-03-10 14:53:28 -05:00
Peter Bigot
5506727bde bluetooth: mesh: update heartbeat subscription work API
Replace the legacy delayed work API with the new delayable work API.
Avoid cancelling work and manually notifying when the subscription is
disabled; instead allow the work item to do this.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-03-10 20:47:02 +02:00
Peter Bigot
6a097caa22 bluetooth: mesh: update heartbeat publish work API
Replace the legacy delayed work API with the new delayable work API.
Use a zero period as a flag value to ensure that the work handler is a
no-op of the publish operation is disabled.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-03-10 20:47:02 +02:00
Peter Bigot
17831b045f bluetooth: mesh: settings: update k_work API
Switch to new work API, taking advantage of the difference between
schedule and reschedule to force an update if the new deadline is
sooner, and retain any previous deadline (or use the new deadline) if
it isn't.  Do not leave a path out that could, due to races, fail to
schedule necessary work.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-03-10 20:45:13 +02:00
Siddharth Chandrasekaran
28c823b16e mgmt/osdp: Fix coverity identified logical dead-code
A previous check and return for (maxlen <= 0) makes manlen at least 1 so
checks for (maxlen < 1) would never evaluate to true. Remove these
checks and merge those cases into one.

CID: 215392
Fixes: #33092
Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2021-03-10 10:15:48 -05:00
Siddharth Chandrasekaran
a871f00726 mgmt/osdp: Fix coverity identified off-by-one
Fix a coverity identified, off-by-one, out-of-bound array access at
pd->cap[].

CID: 215379
Fixes: #33095
Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2021-03-10 10:15:48 -05:00
Jukka Rissanen
d8d5179c00 net: tcp2: Fix mbedtls missing warnings
If CONFIG_NET_TCP_ISN_RFC6528 is disabled, then mbedtls include
files are not available so check this.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-03-10 16:08:46 +01:00
Peter Bigot
81b9ba3a9b bluetooth: mesh: health_srv: update k_work API
Switch to new work API.  Avoid a racy cancel by allowing the work
handler to deal with an immediate off when the time remaining changes
to zero.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-03-10 15:18:10 +02:00
James Harris
97b5741ade logging: fix TOCTTOU issue in z_log_hexdump_from_user
Previously, a racing write to the provided metadata could result
in up to CONFIG_LOG_STRDUP_MAX_STRING-2 bytes after the
end of user-accessible memory being leaked into the strdup pool
or the resulting log.

For now, explicitly copy the metadata string. In an ideal world
this could directly copy from userspace into the strdup buffer, but
this obviously only works if strdup is enabled.

Signed-off-by: James Harris <james.harris@intel.com>
2021-03-10 06:09:38 -05:00
Robert Lubos
64c836d5e2 net: lwm2m: Check return value of option encoding on deregistration
Verify the result of option encoding while forming Deregister message
instead of silently ignoring it.

Coverity ID: 215373
Fixes #33096

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-03-09 09:23:48 -05:00
Emil Gydesen
a264efbcbc Bluetooth: host: Initial support for BIS
Added initial support for BIS (broadcast ISO stream), which
adds support for creating BISes as both broadcaster and receiver,
as well as managing and creating BIGs.

Extends PA sync to handle BIGInfo adveritising reports.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-03-09 08:06:02 -05:00
Emil Gydesen
3fbff9ab77 Bluetooth: shell: Adds BT_INTERVAL_TO_MS macro
Added a simple macro for the BT shell that transforms the
interval unit (N * 1.25ms) to ms.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-03-09 08:06:02 -05:00