Commit graph

21541 commits

Author SHA1 Message Date
Jonathan Rico
ecae33740d Bluetooth: host: Prevent race condition in pairing procedure
Moving the key check after checking that no pairing or encryption
procedure is started fixes a race condition that is seen in some PTS
tests:

GATT/CL/GAR/BI-04-C
GATT/CL/GAR/BI-16-C
GATT/CL/GAR/BI-21-C
GATT/CL/GAW/BI-05-C
GATT/CL/GAW/BI-12-C

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2021-06-10 17:13:41 -04:00
Pawel Dunaj
1286c8d105 net: depend dns resolver on native net
DNS resolver won't work for offloaded stack.

Signed-off-by: Pawel Dunaj <pawel.dunaj@nordicsemi.no>
2021-06-10 17:44:51 +03:00
Rafał Kuźnia
24b2ef4590 net: openthread: set ieee802154_frame_retry flag
The ieee802154_frame_retry will be set by the OpenThread integration
layer in the event of frame retransmission.

Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
2021-06-10 11:03:40 +03:00
Carles Cufi
d9848b155d Bluetooth: host: Optionally disable GATT sec re-establishment
Some centrals deal poorly with receiving a security request immediately
after reconnection whenever reconnecting with characteristics that are
notifiable or indicatable and requiring security. In particular,
Android 9 and earlier devices may lose bond information when this
happens, some Microsoft Surface devices will enter an invalid state
and, on top of that, Apple's Bluetooth Low Energy guidelines explicitly
discourage this behavior.

In order to allow interoperability with those devices, make the GATT
automatic security request sending as a peripheral optional by
introducing a new Kconfig option, BT_GATT_AUTO_SEC_REQ.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-06-09 21:10:14 +03:00
Eug Krashtan
86fc962a48 net: coap: Keep user data inside message
Keeping user data in the CoAP packet

Signed-off-by: Eug Krashtan <eug.krashtan@gmail.com>
2021-06-09 18:41:42 +03:00
Elliot Revell-Nash
e4507ec6ee logging: dictionary format output to file
Add the option to send logs to fs backend using new dictionary
formatting
This can result in much better use of filesystem space

Signed-off-by: Elliot Revell-Nash <elliot.revell-nash@wdtl.com>
2021-06-09 05:44:03 -05:00
Faisal Saleem
c9fd7a6099 Bluetooth: Keys: Fix BT_KEYS_OVERWRITE_OLDEST logic for BT_MAX_CONN > 1
When the Bluetooth stack is configured for CONFIG_BT_MAX_CONN > 1
the oldest key might currently be in use.  Fix the logic to ensure the
oldest key overwritten is from the set of keys currently not in use.

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/35999

Signed-off-by: Faisal Saleem <faisal.saleem@setec.com.au>
Signed-off-by: Nick Ward <nick.ward@setec.com.au>
2021-06-08 20:18:49 +02:00
Stephanos Ioannidis
f0e3280c61 cpp: Fix C++ exception handling newlib dependency
This commit makes C++ exception handling feature depend on the full
version of newlib (i.e. `CONFIG_NEWLIB_LIBC_NANO=n`).

The `nano.specs`, which selects the nano variant of newlib, libstdc++,
and libsupc++, does not support C++ exception handling because its
lib*c++ is compiled with `-fno-exceptions`.

For more details, refer to the issue #35972.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-06-08 11:45:28 -05:00
Eduardo Montoya
ae44b30b41 drivers: ieee802154: include timestamp in acks
Fill the ACK timestamp field in nRF5 driver. This is required by
OpenThread for the proper CSL transmitter functioning.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-06-08 04:54:38 -05:00
Ievgen Glinchuk
1ce8d6fae4 net: dns: Fix multiple IP DNS resolution
Fixed mutli-IP DNS resolution as previously the same IP address was
used to populate all AI entries and added DNS_RESOLVER_AI_MAX_ENTRIES
config entry to define max number of IP addresses per DNS name to be
handled.

Signed-off-by: Ievgen Glinchuk <john.iceblink@gmail.com>
2021-06-07 23:54:55 -04:00
Pavel Vasilyev
33fafe1e2f Bluetooth: Mesh: Reject identical public keys
This commit address Erratum E10395 and Errata Correction E16350
to ensure that public keys exchanged between Provisioner and
a device aren't identical.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2021-06-07 18:56:26 +03:00
Piotr Pryga
7afc31a834 Bluetooth: host: Unmask CTE report related events for DF connected mode
Unmask events related with CTE report for Direction Finding
working in connected mode.
The feature is enabled conditionally, depending on KConfig
configuration provided.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-06-07 17:09:01 +02:00
Piotr Pryga
a717e8c2a6 Bluetooth: host: Add option to enable connection CTE RX
Add Kconfig option that will enable support for CTE reception
in connected mode. Thanks to that it will be possible to
conditionally enable or disable support of the feature and
decrease code size if the feature is not required.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-06-07 17:09:01 +02:00
Emil Gydesen
f500e0fb9c Bluetooth: Audio: VOCS remove need for bt_conn pointer
Remove the bt_conn pointer from the VOCS API, as the
instance pointer is enough to determine if it is a client
and perform client operations on the cached connection pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-07 12:08:10 +02:00
Emil Gydesen
301cedbad5 Bluetooth: Audio: VOCS use bt_vocs instead of bt_vocs_server
Modify vocs.c to use the bt_vocs struct instead of the
bt_vocs_server struct. This is done so that there is less
difference between the internal struct usage and the struct
type used in the API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-07 12:08:10 +02:00
Kamil Piszczek
eff957b764 Bluetooth: HCI: add api for getting advertising handle
Added an API to the HCI header that can be used to retrieve
advertising handle information from a given advertising set.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2021-06-07 12:08:02 +02:00
Joakim Andersson
3aaf50ae6e Bluetooth: host: Remove unneccesary limit of host to controller packets
Remove unneccesary limit of host to controller packets by the host ISO
buffers and host pending buffers with TX callback.
The host always allocates the buffer before taking the semaphore so this
is already handled by the size of the host buffer pool and the
functionality of the buffer pools to wait for buffers.

In addition the ACL max limit is using the wrong define, as
CONFIG_BT_CONN_TX_MAX is the maximum amount of callback contexts for
transmitting. So the host can have more pending packets than this value.
This is also inconsistent with how the host would handle the V1 reply.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-06-07 12:06:48 +02:00
Emil Gydesen
20f0bff05f Bluetooth: Audio: MICS shell commands
Add the shell commands for both MICS server and client.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-07 12:04:28 +02:00
Emil Gydesen
2c67bafb7b Bluetooth: Audio: Microphone Input Control Service and Client
This commit implements the microphone input  control service
(MICS) and client, The implementation supports and uses the
Audio Input Control Service (AICS) secondary service.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-07 12:04:28 +02:00
Jordan Yates
43b2400688 Bluetooth: gatt: callbacks on ATT MTU update
Adds a new callback structure to `<gatt.h>` for receiving notifications
of ATT MTU updates. This callback is called regardless of whether the
MTU update was initiated locally or remotely.

Fixes #32035.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-06-07 12:03:09 +02:00
Lukasz Maciejonczyk
1f0b783bbb drivers: ieee802154: replace enh ack probing with generic IE conf
Use IE variable of ieee802154 MAC frame instead of Thread specific
configuration call for configuring injection of vendor specific
data into enh ack.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2021-06-07 10:41:07 +03:00
Henning Fleddermann
05b2018ffa lwm2m: keep track of observations per client
this has a number of advantages:
- allows to only create notifications for each client if there are no
  messages already waiting to be send, in practice prioritizing the
  memory for messages for answers, thus staying more "responsive".
- saves a fair bit of memory by eliminationg now redundant client_ctx
  pointer per observer.
- fixes a potential subtle bug: previously, an observer reset would've
  stopped the first observation found with a matching token, which
  might've belonged to a differen client.

Signed-off-by: Henning Fleddermann <henning.fleddermann@grandcentrix.net>
2021-06-07 10:39:37 +03:00
Henning Fleddermann
32989a38f0 lwm2m: use asynchronous socket io
This restructures the lwm2m_engine to use a non-blocking socket access
instead of the previously used blocking style, and eliminates any
socket-access from outside of the main work loop.

The main motivation behind this is an issue within nordics
nrf_modem_lib/modem-fw on nrf9160, that leads to socket send() calls to
block indefinitely when the shared memory used for
rpc-communication with the modem is already exhausted because of
incoming data.

This lead to the lwm2m_engine locking up on send calls when there is
also a large amount of incoming data.

This works around this issue, by only issuing send calls when poll
reports the socket to be ready for sending, and (more importantly) by
always receiving all buffered incoming data before sending anything.

There might still be a (perhaps academic) possibility where this
situation might be triggered, when  the scheduler interrupts the lwm2m
thread in-between receiving and sending, but for now we have not yet
observed this.

Besides working around the aforementioned issue, this also simplifies
the way resends are handled as they are no longer send from the main
system-workqueue, and limits all interaction with the sockets to a
single thread.

Signed-off-by: Henning Fleddermann <henning.fleddermann@grandcentrix.net>
2021-06-07 10:39:37 +03:00
Hubert Miś
b39537d151 drivers: ieee802154: make keys management API generic
Keys management API for IEEE 802.15.4 drivers was specific for Thread
protocol. With this change API is more generic and aligned with Thread
needs.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-06-07 10:39:14 +03:00
Robert Lubos
34fb892fb5 net: sockets: tls: Use secure random generator from Zephyr
Zephyr has introduced secure random generator API after the TLS sockets
were implemented. Use this new API in TLS sockets implementation,
instead of implementing secure RNG with mbedTLS in the module itself.
This facilitates integration of the HW RNG accelerators with the TLS
sockets module.

Signed-off-by: Frank Audun Kvamtrø <frank.kvamtro@nordicsemi.no>
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-06-04 16:27:17 -05:00
Maksim Masalski
366de7a890 logging: z_vrfy_log_filter_set: remove extra check
Variable "level" in function z_vrfy_log_filter_set() has type unsigned.
But it is been checked if "level >=LOG_LEVEL_NONE" and
LOG_LEVEL_NONE is 0. It means check if unsigned is ">= 0" in Z_OOPS().
That is logically wrong, because unsigned is ">=0" by default.
Remove that check, to avoid static analysis tool raise
violation

Found as a coding guideline violation (MISRA R14.3) by static
coding scanning tool.

Signed-off-by: Maksim Masalski <maksim.masalski@intel.com>
2021-06-04 16:19:49 -05:00
Lukasz Maciejonczyk
8b12311bdf net: openthread: add option to configure software transmission security
If radio driver supports transmission security we need an option
to disable transmission security which by default is done by OT stack
for Thread v1.2

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2021-06-04 16:19:16 -05:00
Jakub Rzeszutko
4a85ecacda shell: fix tab for dynamic commands
The tabulator handler creates a single structure if it is handling
dynamic commands. If the currently processed dynamic command has a
dynamic subcommand they both share the same structure.
As a result tabulation operation may result in undefined behaviour.

As a solution, a new structure was introduced to keep subcommand
information.

Fixes #35926.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2021-06-04 12:23:15 -05:00
Vinayak Kariappa Chettimada
adae515d8d Bluetooth: controller: Fix conn setup regression
Fix incorrect and redundant use of ticker user id ULL_LOW
instead of ULL_HIGH when setting up a connection using a
mayfly to disable LLL context. Also, the LLL context pointer
is invalid, where node rx is passed instead of LLL context.

Use the ULL disabled callback when done event has not yet
been processed, or a direct connection setup in ULL_HIGH
context when ULL is already disabled (reference count is
zero) is sufficient.

Regression introduced in commit 30f260dfaa ("Bluetooth:
controller: Fix adv/scan context access post release").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-04 12:13:34 -05:00
Krzysztof Chruscinski
f8e7ecfb56 shell: Add missing dependency to shell log backend
Shell log backend depends on logging being enabled. Lack of this
dependency leads to compilation failure when logging is disabled.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-06-04 08:20:21 -05:00
Joakim Andersson
95e359d658 Bluetooth: controller: Check length field of scan response data
Check the length field of the scan response data.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-06-04 12:51:27 +02:00
Jennifer Williams
d6a3679c97 logging: log_msg.c: fix coding guideline 15.7 missing comment
The final else {} in the if...else if is missing required
comment (non-empty, ';' is not sufficient). This adds a comment
to comply with CG 15.7.

Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
2021-06-03 20:07:16 -05:00
Jennifer Williams
09ee9d6e29 logging: log_core.c: fix coding guideline 15.7 missing comment
The final else {} in the if...else if is missing required
comment (non-empty, ';' is not sufficient). This adds a comment
to comply with CG 15.7.

Signed-off-by: Jennifer Williams <jennifer.m.williams@intel.com>
2021-06-03 20:07:16 -05:00
Joakim Andersson
4dd49ac746 Bluetooth: host: Fix CCC store on write for multiple connections
Fix CCC store on write feature for multiple connections. CCCs are only
enqueued for storing when going from no connections subscribed to any
connection subscribed.
The CCC should be stored when its value is changed for the specific
connection.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-06-03 11:36:22 +02:00
Anas Nashif
20896ba1e0 thread analyzer: fix formatting for unsigned int
On 64bit systems, this was issuing warnings due to wrong formatting.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-06-01 12:42:38 -05:00
Vinayak Kariappa Chettimada
12ba459c92 Bluetooth: controller: Minor improvements to ext header population
Minor refactor and improvement to common extended header
population.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-01 16:50:41 +02:00
Vinayak Kariappa Chettimada
0de4c30b0f Bluetooth: controller: Fix incorrect prev aux header flag access
Fix Extended Advertising PDU population from incorrectly
populating new PDU when there is no common extended header
flags being set in the previous PDU and or the new PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-01 16:50:41 +02:00
Vinayak Kariappa Chettimada
cabcae2413 Bluetooth: controller: Fix incorrect prev periodic header flag access
Fix Periodic Advertising PDU population from incorrectly
populating new PDU when there is no common extended header
flags being set in the previous PDU and or the new PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-01 16:50:41 +02:00
Vinayak Kariappa Chettimada
c877385adb Bluetooth: controller: Fix incorrect ext header flag access
Fix Periodic Advertising data population from corrupting
the PDU by populating fields when there is no flags in the
common extended advertising header.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-06-01 16:50:41 +02:00
Emil Gydesen
fe1de126fe Bluetooth: Host: Add status check BIG sync/create events
Add a status check for the BIG sync established and
BIG sync created events such that we don't log a warning
of invalid BIS count when it is an error event.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-01 07:31:51 -05:00
Emil Gydesen
4bc5a02d51 Bluetooth: ISO: Fix BIG cleanup
Fix a regression for cleaning up BIGs added by
80c824f18ee80caa5bd162b9d2957dde1639add6 where the way
ISO connections were unref'ed was changed.

bt_iso_cleanup has been changed to only effect CIS
(as the unref from that has been removed), so instead
of calling bt_iso_cleanup we just call
bt_conn_unref directly.

This also removes some unref's from the BIG complete
and BIG Sync complete event handlers as the BIS bt_conns as
they don't increase the ref counter before anymore.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-06-01 14:03:48 +02:00
Krzysztof Kopyściński
9c4dba12aa Bluetooth: Host: change error returned when ecred_conn_req
BT_L2CAP_LE_ERR_INVALID_PARAMS shall be returned instead of
BT_L2CAP_LE_ERR_UNACCEPT_PARAMS.

This was affecting test case L2CAP/ECFC/BV-26-C

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2021-06-01 14:03:28 +02:00
Krzysztof Kopyściński
975ed76d78 Bluetooth: Host: do not overwrite result in le_ecred_conn_req
For more than one requested channels in le_ecred_conn_req only result is
overwritten in every iteration. This causes an issues if after failed
l2cap_chan_accept occures successful one: returned result will be
BT_L2CAP_LE_SUCCESS, where in reality should be returned error
and non-zero Destination CIDs will signal "Some connections refused".
Now, overwrite error only if the last one failed. If no errors occur,
result will remain BT_L2CAP_LE_SUCCESS.

This was affecting test cases L2CAP/ECFC/BV-20-C

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2021-06-01 14:03:28 +02:00
Krzysztof Kopyściński
3e66dd2054 Bluetooth: Host: add missing zero CIDs in ecred_conn_req
Fix missing 0x0000 CIDs in response for ecred_conn_req. Previously,
when one of "All connections refused" error i variable was set to 0,
thus no CIDs were copied to response.

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2021-06-01 14:03:28 +02:00
Piotr Pryga
1d0de7afc1 Bluetooth: host: Check sync_handle return value when CTE sampl enable
Check correctness of returned sync_handle value while requesting
HCI_LE_Set_Connectionless_IQ_Sampling_Enable in controller.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-05-31 17:44:29 +02:00
Piotr Pryga
725ceb69b3 Bluetooth: controller: hci: Set correct return params for CTE sampl enable
Fix bug of missing sync_handle parameter in return data in
HCI_LE_Set_Connectionless_IQ_Sampling_Enable commnad
handling function.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-05-31 17:44:29 +02:00
Joakim Andersson
b9a586821e Bluetooth: host: Log failure to initiatie security for bonded peer
Log failure to initiatet security for bonded peer when GATT wants to
initiate security for CCCs for the remote.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-31 17:40:36 +02:00
Joakim Andersson
8d53def576 Bluetooth: host: Reject remote public key on same X coordinate.
Reject remote public key when this has the same X coordinate.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-31 17:40:27 +02:00
Joakim Andersson
f5f8eb7263 Bluetooth: host: Notify application about prepare write error
Notify application about prepare write error when continueing the write
procedure fails when RX thread is processing responses. It is possible
that this operation fails, either because of disconnection or ATT
timeout on the ATT bearer. Notify the application in case it needs to
clear up resources, e.g. the write parameters.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-31 17:39:27 +02:00
Gerard Marull-Paretas
c708a17b8e pm: device: remove CONFIG_PM_MAX_DEVICES
When a device is defined a new pointer to a device will be created in
the "z_pm_device_slots" region, effectively creating a device array with
the same size as the number of system devices. This array is then used
by the device PM subsystem to keep track of suspended devices during
power transitions.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-29 07:38:06 -04:00