Prevents this module from just trampling over your logging with
debug logs no matter the configuration
Signed-off-by: Jamie McCrae <spam@helper3000.net>
It's been periodically reported that the default connect timeout shared
with regular TCP sockets (3 seconds) is not enough for the TLS handshake
to complete. Therefore, it'd make sense to increase the default value
for TLS sockets specifically. However currently the option is used by
both TCP and TLS connections, which makes this impractical.
Therefore, introduce a separate CONFIG_NET_SOCKETS_TLS_CONNECT_TIMEOUT
Kconfig option for TLS sockets specifically, and set the default to 10
seconds. For samples/tests that modified the old option for TLS-specific
purpose, update the new option value as well.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case a handshake timed out on a blocking accept() call, the TLS
socket would return EAGAIN error which is ambiguous and not intuitive.
Report ETIMEDOUT instead.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
New nrfx release contains major rework of nrfx drivers
instantiation making it easier to integrate with dts nodes.
Now, nrfx driver instances can no longer be `const`
because they contain driver runtime state.
Additionally, all nrfx drivers return `errno` error codes
instead of deprecated `nrfx_err_t`.
Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
On IPv6, IPPROTO_IPV6 needs to be replaced by IPPROTO_IP and
IP_MULTICAST_TTL by IPV6_MULTICAST_HOPS.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
On IPv6, the host is subscribed to a few multicast addresses by default.
Reusing such an address for MQTT-SN leads to an EALREADY error. Ignore
this error instead of returning. Do the same for IPv4 for consistency,
and because it could happen if the multicast address has already been
added manually from another part of the code, although this is really a
corner case.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
The current allocated buffer for storing the IP address is not always
large enough to hold an IPv6 address. Instead of using a hard-coded
value, use NET_INET6_ADDRSTRLEN, which covers all cases, including
possible mapped IPv4 addresses.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
errno returns a positive value, while the API specifies that a negative
value is returned in case of error. Therefore replaces "return errno" by
"return -errno".
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
There is an issue with AF_PACKET sockets bound to ieee802154 l2 iface.
The socket keeps track of the iface link_addr with a sockaddr_ll_ptr
structure, with sll_addr pointing to the iface link_addr address, and
sll_halen being a copy of the iface link_addr length.
The iface link address for ieee802154 can change during association
between extended address (8 bytes) and short address (2 bytes). The
iface link_addr s correctly updated, but the sll_halen of already bound
sockets is not, as it's a out of sync local copy.
This commit fixes#99711 by replacing all the sll_halen usage for
AF_PACKET socket with the iface link_addr length directly on recv and
send paths.
Signed-off-by: Simon Piriou <spiriou31@gmail.com>
If the connect type is not `LE`, the return value of function
`bt_conn_get_dst()` is a NULL pointer. In function `bt_addr_le_str()`,
the NULL pointer will be accessed without any checking. It will cause
the issue `Segmentation fault` in the platform `native_sim`.
Fix the issue by checking the conn type at the beginning of the
function `eatt_auto_connect()`.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
In current implementation, the call will be terminated, or rejected if
the audio connect cannot be established. But from the application
view, if the sco connect cannot be established, the audio paths can be
routed towards the AG. So force routeing the audio towards the HF is
not reasonable and it is not the mandatory.
The changes aim to keep the sequence that creating SCO connect in the
right time. And ignore the result whether the SCO connect has been
created or can be established.
If the audio connect cannot be established, the application can try to
change the audio route paths according to the audio connection
procedure.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The workaround in bt_cmd_send_sync should no longer by needed when
tx_processor is not on the system work queue.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
When thread that TX processor is used to send commands and data to
Controller is also used for sync commands sending and command buffer
allocation, a deadlock happens.
This thread is used to avoid such deadlocks by moving TX processor to
its own dedicated thread exclusively used by tx processor only.
Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
ATT is invoking user callbacks in its net_buf destroy function. It is
common practice that these callbacks can block on bt_hci_cmd_alloc().
This is a deadlock when the net_buf_unref() happens inside the HCI
driver, invoked from tx_processor.
Blocking callbacks like this appear in our own samples. See further down
about how this problem was detected.
tx_processor not protect against blocking callbacks so it is de-facto
forbidden. The Host should not equip net_bufs with dangerous destroy
callbacks.
This commit makes ATT defer its net_buf destruction and user callback
invocation to the system workqueue, so that net_buf_unref is safe to
call from non-blocking threads. In the case of the deadlock, the
net_buf_unref() was below the tx_processor in the call stack, which (at
the time of this commit) is on the system work queue, so defering it to
the system work queue is preserving the existing behavior.
Future improvement may be to allow the user to provide their own
workqueue for ATT callbacks.
This deadlock was detected because the following test was failing while
moving tx_processor to the bt_taskq:
tests/bsim/bluetooth/ll/throughput/tests_scripts/gatt_write.sh
The above test has an ATT callback `write_cmd_cb` invokes
`bt_conn_le_param_update` can block waiting for `tx_processor`.
The reason it was not failing while tx_processor was on the system work
queue is that the GATT API has a special non-blocking behavior when
called from the system work queue.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Allow flash devices to be accessed using the NVMEM API. Note that it simply
uses the read/write API functions. Erasing should be handled by the
application.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Multiple submitted requests are getting merged to single cancelled
net_buf on endpoint dequeue. While MSC class was correctly decrementing
the usage counters, it was not freeing SCSI buffer pointed to by frags.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
When calling net_hostname_set() from C++, you will hit compile
errors if you attempt to use a const char *. Since the internals
of net_hostname_set() just uses memcpy(), we should pass in the
new hostname as a const char * to better support C++.
Tested using samples/cpp/hello_world, with an added call to
net_hostname_set().
Signed-off-by: Andrew Kontra <andrew@legatoxp.com>
In current implementation, there are two issues found,
Issue 1, the feature defined in the SDP HFP HF record are used in
combination as HFP HF supported features reported via `+BRSF`.
Issue 2, the macro `BT_HFP_HF_FEATURE_CODEC_NEG_ENABLE` is not
aligned with macro name of other features. The other macros are named
with prefix `BT_HFP_HF_FEATURE_`.
Use `BT_HFP_HF_FEATURE_VOLUME_ENABLE` to set the volume feature
instead of `BT_HFP_HF_SDP_FEATURE_VOLUME_ENABLE`.
Rename `BT_HFP_HF_CODEC_NEG_ENABLE` with new name
`BT_HFP_HF_FEATURE_CODEC_NEG_ENABLE`.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Set Log Level to Info when the Telnet socket reports ENETDOWN,
instead of logging an error each time the network is down.
Signed-off-by: Joel Schaller <joel.schaller16@gmail.com>
VIM is a vector interrupt manager that TI devices have and is used a
interrupt controller. the driver's Kconfig selection is created as "VIM"
and is resulting in the confusion with a Text Editor name.
Make the VIM Kconfig option to indicate the vendor TI name in it.
Signed-off-by: Mihira Madhava Bollapragada <madhava@ti.com>
This private header can be used by tests for information on UID ranges
that should be cleaned for testing.
Signed-off-by: Dmitrii Sharshakov <d3dx12.xx@gmail.com>
This updates the thread analyzer to optionally leverage the kernel's
thread runtime stack safety infrastructure to act upon threads whose
unused stack space has fallen below their configured thresholds.
By default, the thread analyzer merely reports what it has found.
However, a developer can override this behavior with a custom handler
using thread_analyzer_stack_safety_handler_set().
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
A few debug logs in TCP code relied on a fact that IP address offset is
the same in struct sockaddr_in and sockaddr_in6. However, the logs
casted the address to struct sockaddr_in, which is smaller than
sockaddr_in6, causing theoretical out-of-bounds access warnings in IPv6
case. Fix this by casting to struct sockaddr_in6 instead.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Fixes an issue introduced in commit
32615695ad which wrongly did not
check what the residing device was on before determining if a
slot was part of a partition area
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Make SNTP resynchronization asynchronous, so that it doesn't block the
system work queue while waiting for response.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Move the code responsible for setting clocks into a helper function,
as it'll be reused with asynchronous resynchronization.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Previously, the LCP MRU option sent by the peer was ignored.
This could result in the interface MTU remaining at the default (1500),
even if the peer requested a smaller MRU, potentially leading to packet
loss. This commit adds parsing for the peer's MRU option and updates the
network interface MTU accordingly.
Signed-off-by: Nik Schewtschuk <nik@schew.dev>
Adds the `CONFIG_BT_SMP_LEGACY_PAIR_ONLY` Kconfig option to force
devices to use legacy pairing. This has a dependency on
`CONFIG_BT_TESTING` as it is only intended for testing purposes, and use
of legacy pairing is discouraged.
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
WS_MAGIC is a constant string and when calculating lengths for copying
we always exclude the NULL terminator. In result, using strncpy() for
copying can generate a warning about truncated string, as WS_MAGIC will
always be truncated from the NULL terminator. Therefore replace
strncpy() with memcpy() as it seems more appropriate for this case.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
A CIS may be connected in either the QoS Configured state
or the enabling state. The QoS Configured state is the
earliest state it is allowed, due to it being the first
state where the CIS_ID and ASE_ID are paired.
The enabling state is the "last" state it is allowed,
as if the ASE is in the streaming, disabling or releasing
state we should not allow/expect a CIS connection to happen.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This change implements full AVRCP Browsing support on both CT/TG,
and included all public APIs and callbacks, and add shell commands
for testing.
Signed-off-by: Make Shi <make.shi@nxp.com>
Introduce an optional alloc_buf() callback into AVCTP so that each
session can decide which RX buffer pool to use. Provided a dedicated
RX pool for the AVRCP browsing channel.
Also provided BT_AVRCP_BROWSING_L2CAP_MTU for configure.
Signed-off-by: Make Shi <make.shi@nxp.com>
Drop the 'U' suffix from enum hex literals keep style consistent
and rename `bt_avrcp_list_app_setting_attr_rsp` to the clearer.
Signed-off-by: Make Shi <make.shi@nxp.com>
As of Core v6.2, the passkey entry pairing method for legacy pairing
does no longer grant authenticated MITM protection. This commit
updates `smp.c` accordingly to not grant the authenticated states when
using legacy passkey entry pairing.
Adds a check to make sure that bonds that have been stored persistently
adheres to these changes. Bonds that have been generated using the
legacy passkey entry pairing method will thus be downgraded from
authenticated to unauthenticated when restored from storage.
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
If both the TX and RX SDUs are 0, then we reject
the call as that is an invalid configuration
(minimum SDU size is 1, and 0 indicates that
no data in that direction is being configured).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a new type of observer: Async Listeners. They are executed within the
system work queue context, offering distinct advantages:
- Asychrouness: obviously it gains the ability of run some urgent/light
work load in a separate context.
- Prioritization: Async Listeners typically execute before other
application observers, as they run within the system work queue context
which is cooperative.
- Reliability: Ensures no message loss during execution. They use the same
mechanism as Message Subscribers.
Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
This commit deinitializes platform modules when external network
interface is brought down. It also delets the multicast routes that are
added for OpenThread interface.
Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
Zephyr subsystems' headers should not duplicate C library prototypes
(in this case strdup(), which is either ISO C23 or a POSIX extension to
the C library <string.h>).
Instead they should request those prototypes from the C library.
By now Zephyr only requires ISO C17, but many C libraries will have
strdup() and expose it also when the POSIX extensions prototypes are
requested, so let's request these prototype from the C library by
setting the feature test macro _POSIX_C_SOURCE to version 2008.09
which includes it.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Fix a missing unref of a bt_conn reference, leading to a ref count
mismatch, and causing the following warning to be printed:
bt_conn: Found valid connection ... in disconnected state.
Signed-off-by: Aleksandar Stanoev <aleksandar.stanoev@nordicsemi.no>
USBD_MAX_UDC_MSG configures the number of events coming from the UDC
driver that the stack can keep. This can be filled very quickly if there
would be multiple bus events for some reason, or function handlers of
those events are blocked for long time. As a consequence, subsequent
events could be dropped, and completed transfers not handled. To avoid
it, we can store completed transfer requests in a slist and check it on
every event.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>