Check the size with CHECKIF() and return NULL when the control block is
undersized, which is also what the CMSIS-RTOS2 contract expects.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
Check the size with CHECKIF() and return NULL when the control block is
undersized, which is also what the CMSIS-RTOS2 contract expects.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
Check the size with CHECKIF() and return NULL when the control block is
undersized, which is also what the CMSIS-RTOS2 contract expects.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
The peap implementation in hostap allows to enforce a version, see
https://github.com/zephyrproject-rtos/hostap/blob/main/src/
eap_peer/eap_peap.c#L79.
However, the library can work fine without an enforced version.
This change allows that, when a value of -1 is filled in for eap_ver.
The wifi_shell CLI is also updated.
Signed-off-by: Sebastiaan Merckx <sebastiaan.merckx@verhaert.com>
Remove my email address from copyright notices across
board, fuel-gauge, networking, sample, and test files
Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
Add all the subscribe options contained in chapter 3.8.3.1
All missing flags have been added to the struct (only if v5
is enabled).
Added a function to encode them with qos, as they live in the
same byte.
Added a fallback function which encodes the qos only.
Signed-off-by: Paolo Bazzanella <pbazzanella@qubicaamf.com>
posix_thread_finalize() rescanned each key's entire data list to unlink
one node on every thread exit, i.e. O(keys x threads). Store the
key-side data on a doubly linked list so the node is removed in O(1)
via CONTAINER_OF(), which also drops the stale-predecessor bookkeeping
that sys_slist_remove() required.
Assisted-by: Claude:opus-4.8
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
dns_dispatcher_unregister() clears the dispatch-table slot and returns
immediately, even if a concurrent recv_data() call already holds
ctx->lock and is mid-dispatch. A caller that reuses ctx right after can
race with it.
Take and release ctx->lock after clearing the table, so unregister()
only returns once any in-flight dispatch has finished.
Signed-off-by: Mayur Salve <msalve@qti.qualcomm.com>
When a bonded device reconnects and the receive state has changed
while the bonded device was offline, then per the BASS specification
the Scan Delegator shall send a notification with the receive state.
Previous implementation did this too by simply sending the notification
for all receive states regardless of whether the reconnected device
was bonded or not.
Some minor changes to prevent race conditions were also done.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The sleep trace hooks were attached to k_sleep(), k_msleep() and
k_usleep(). Those are inline wrappers now, and the only function left to
instrument is the k_sleep_ticks() primitive underneath them, so the three
hook families no longer have anything emitting them. The msleep pair had
in fact been unused for some time already.
Replace all three with one k_thread_sleep_ticks pair reporting the timeout
and the time left to sleep in ticks, and drop what is left behind in each
backend: the CTF events and their top level helpers, the entry in
SYSVIEW_Zephyr.txt, and the user and test hooks. The new CTF and
SystemView ids are fresh rather than reused, so a recording made by an
older build cannot be misread by a newer decoder. The retired SystemView
ids stay defined, since out of tree code may refer to them.
The profiling example in the instrumentation documentation named two
symbols that no longer exist, and is updated to the ones that replace
them.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
BAP_UNICAST_CLIENT_ASE counts are per connection, and not reflect
the actual number of streams that may exist in a group. Changed to
use CONFIG_BT_BAP_UNICAST_CLIENT_GROUP_STREAM_COUNT * @ which does
reflect that exactly. The reason why it needs to be multiplied by 2,
is that CONFIG_BT_BAP_UNICAST_CLIENT_GROUP_STREAM_COUNT refers to the
number of CIS, and we may have twice as many BAP streams (as they
unidirection, and CIS may be bidirectional).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
z_vrfy_rtio_cqe_get_mempool_buffer() checked buff and buff_len with
K_SYSCALL_MEMORY_READ, but both are output parameters:
z_impl_rtio_cqe_get_mempool_buffer() stores the mempool buffer address
and its length through them.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
ATT Write commands from change unware client shall be ignored.
Previously ATT request opcode was used for request but 0 for command
when passed to att_write_rsp() which was not updated when refactored
to perform_write() which expects ATT opcode for all operations.
Also rename req to op in struct write_data to better describe what
is being keep there now.
This was affecting GATT/SR/GAS/BV-05-C qualification test case.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Use the autogenerated `DT_COMPAT_ZEPHYR_POWER_STATE` variable in Kconfig
of the PM subsystem instead of declaring a variable manually.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
The CAP unicast audio start and stop procedures consist of several
subprocedures, and applications may need to know when each of these have
completed, e.g. to reconfigure the unicast group after the streams have
been codec configured but before they are QoS configured.
Add new callbacks to bt_cap_initiator_cb for each subprocedure of the
unicast audio start and unicast audio stop procedures. The callbacks are
only called if at least one request was sent to a CAP acceptor as part of
the subprocedure, so that subprocedures that are skipped because all
streams are already in the requested state do not trigger a callback. To
support this a new subproc_initiated field has been added to the common
procedure struct, which is reset whenever a new subprocedure is set.
The unit tests have been extended to verify both that the callbacks are
called when the subprocedures are performed, and that they are not called
when the subprocedures are skipped, and the BSIM CAP initiator unicast
test now waits for the new callbacks as part of the start and stop
procedures.
Assisted-by: Copilot:claude-opus-4.5
Co-authored-by: Thalley <2520413+Thalley@users.noreply.github.com>
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Starting from QoS was not properly tested in the unit tests, and
thus did not catch a bug in the actual procedure.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
It is now needed to have the TF-M Crypto partition enabled, and the
backend needs it in all cases.
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
Add a new shell command `spp rls` to allow testing of the RFCOMM Remote
Line Status (RLS) functionality through the SPP shell interface.
The command accepts optional error type parameters (overrun, parity, or
framing) to simulate serial port errors. When no parameter is provided,
it sends a no-error status.
The implementation uses the newly added `bt_rfcomm_send_rls_cmd()` API
to send RLS commands on the active SPP connection.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Add public API `bt_rfcomm_send_rls_cmd()` to allow applications to send
Remote Line Status (RLS) commands to RFCOMM DLC connections.
The new API validates the DLC connection state and sends RLS commands
with application-specified line status values to report serial port
errors such as overrun, parity, and framing errors.
Add helper macros `BT_RFCOMM_RLS_NO_ERR`, `BT_RFCOMM_RLS_ERR()`,
`BT_RFCOMM_RLS_ERR_OVERRUN_ERROR`, `BT_RFCOMM_RLS_ERR_PARITY_ERROR`,
and `BT_RFCOMM_RLS_ERR_FRAMING_ERROR` to simplify construction of line
status values.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Replace the preprocessor "#if !defined(CONFIG_BT_CTLR_SW_SWITCH_
SINGLE_TIMER)" guards with runtime "if
(!IS_ENABLED(CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER))" checks in
the DPPI and PPI radio HAL helpers. SW_SWITCH_TIMER and the
timer task enums are always defined, so the guarded code compiles
in both configurations and the compiler discards the disabled
branch, preserving behaviour while improving readability.
Assisted-by: CoPilot:Claude Opus 4.8
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix race in software switch timer by starting and stopping
the switch on Radio End and Radio Enable, respectively.
The Radio PHYEND event and the software-switch timer compare
event occurred at the same timer value. This allowed the
next RADIO TXEN/RXEN operation to start while PHYEND was
resetting the timer for the next software-TIFS interval,
leaving the controller in an invalid state.
Relates to commit 5fe53aaa84 ("Bluetooth: Controller: Use
PPI/DPPI to start s/w switch timer").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
A datagram can carry more than one DTLS record. Mbed TLS reads the whole
datagram into its input buffer and processes one record at a time, so
once the application has consumed the first record the socket has no
readiness left to report while a complete record is still held by Mbed
TLS. A poll that waits on that socket alone then sleeps until an
unrelated datagram arrives.
Query mbedtls_ssl_check_pending() during poll prepare and, only when it
reports an unprocessed message, advance it with one nonblocking data
check. Guarding on check_pending() keeps poll free of a recvfrom() on
the underlying socket in the common case, which matters for offloaded
stacks where that is a round trip to the modem.
A data check can also report a peer close or a fatal error. Neither is
visible to the underlying socket, so latch the error and report the
latched state as POLLHUP or POLLERR from poll update instead of
discarding it.
Assisted-by: Claude:Opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Adds support for bridging using this transport
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Signed-off-by: Jamie McCrae <spam@helper3000.net>
Adds support for bridging using this transport
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Signed-off-by: Jamie McCrae <spam@helper3000.net>
Adds a new experimental group which supports transport bridging
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Signed-off-by: Jamie McCrae <spam@helper3000.net>
Changes the priority from positive to negative to make it a
cooperative thread, this prevents issues when using ztest which make
the transport function stop running when a semaphore is given, which
eventually leads to a lack of network buffers
Signed-off-by: Jamie McCrae <spam@helper3000.net>
Adds a function that can be enabled to show how many MCUmgr buffers
are available. Useful for tests, and was used to notice an issue
with ztest and default MCUmgr transport workqueue priority
Signed-off-by: Jamie McCrae <spam@helper3000.net>
l2cap_br_conn_req() ignores the return value of l2cap_br_chan_add(),
unlike both of its other callers. When the dynamic CID allocation
fails, the code continues as if the channel was fully set up: it sends
a connection response whose DCID is the CID that was never allocated
(0), and the channel object that the server just accepted is never
attached to the connection. Since the channel is not on the
connection's channel list, no disconnected or released callback will
ever be called for it, so the server considers the object in use
forever and one of its channels is permanently leaked.
Check the return value, give the channel back to the server through
the normal bt_l2cap_br_chan_del() lifecycle, and reply to the remote
with "no resources available".
Assisted-by: Claude:claude-fable-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
When building with CONFIG_NO_OPTIMIZATIONS=y, GCC reports
-Wmaybe-uninitialized warnings for net_sockaddr_storage variables
that are passed to net_sad() before being explicitly initialized.
With optimizations enabled, the compiler inlines net_sad() (a simple
cast) and can track that the variable is written before being read
(e.g., via zsock_accept or net_ipaddr_parse). At -O0, the cast
indirection prevents this analysis.
Zero-initialize the affected variables to silence the warnings.
The cost is negligible (memset of a small struct) and there is no
behavioral change since the variables are always written before use.
Assisted-by: WChat:Claude
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
There is an issue that the receive buffer was modified while
processing the command to set the RPN.
Remove `default_rpn` to `rsp`. Simplify `rfcomm_handle_rpn()` by
consolidating response handling into a single `rsp` variable.
In the command handler path, copy the received `rpn` structure to
`rsp`, modify the param_mask, and send the response. This replaces the
previous approach of modifying the input received buffer structure
directly.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Add comprehensive error handling and buffer validation to RFCOMM
message handlers to prevent potential buffer underflow and invalid
data processing.
Remove FCS byte from buffer using `net_buf_remove_mem()` in
`rfcomm_recv()` instead of relying on length checks in data handler.
Simplify `rfcomm_handle_data()` by removing redundant FCS length check
since FCS is now removed earlier in the processing chain.
Refactor MCC message handler to properly validate buffer length and
use `net_buf_pull_mem()`/`net_buf_pull_u8()` for safe buffer access.
Add length check in TEST command handler to prevent overflow when
casting to `uint8_t`.
The change addresses a potential out-of-bounds buffer access issue,
preventing potential security issues in RFCOMM operations.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The second argument of bt_l2cap_create_pdu() is the reserve
(headroom), not the payload size. The code passed
sizeof(struct bt_hid_hdr), which consumed the whole buffer as
headroom and left tailroom = 0. The following net_buf_add() then
hits the __ASSERT() and hangs on debug builds, or writes out of
bounds on release builds.
Signed-off-by: Make Shi <make.shi@nxp.com>
Cast cached byte buffers at the log link text API boundary to avoid
pointer-sign warnings.
Part of #8921
Signed-off-by: Daniel Polimac <danielpolimac@gmail.com>
hfp_hf_disconnected() leaves the HF object in a state where reusing it
is unsafe:
- The work items are canceled, but cancellation does not affect a
handler that is already running, and the handlers can block for a
long time in hfp_hf_send_cmd(), which allocates from hf_pool with
K_FOREVER. hfp_hf_create() only checks hf->acl before wiping the
object with memset(), so a new connection on the same index can wipe
the work items, the TX FIFO and the AT client state under a
still-running handler.
- Buffers still queued on tx_pending are never freed. Nothing sends
them once the DLC is gone, and the memset() on reuse then loses them
from hf_pool permanently. A fully parked pool also means a handler
blocked in the hfp_hf_send_cmd() allocation never wakes up.
- The CONNECTED flag is never cleared (only the memset() on reuse
does), so command senders keep queueing buffers for the dead DLC
between disconnection and reuse instead of failing with -ENOTCONN.
Clear the CONNECTED flag and drain tx_pending in
hfp_hf_disconnected(), and make hfp_hf_create() refuse to reuse the
object while any of the work items is still pending or running. The
refusal is a transient condition: once the handlers have finished, the
next connection attempt succeeds.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
DSP0233 (MCTP over I3C) 1.0.0 mandates PEC on MCTP over I3C
(Section 5.2.1.1 and 5.4.2)
Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
Commit 6c461f291f ("Bluetooth: CAP: Handle disconnects during
procedures") added calls to active_proc_is_initiator() and
active_proc_is_commander() in bt_cap_common_disconnected(), but no
such functions exist; the actual helpers are prefixed with
bt_cap_common_. This fails the build with an implicit function
declaration error (-Werror) whenever CONFIG_BT_CAP_INITIATOR_UNICAST
or CONFIG_BT_CAP_COMMANDER is enabled, breaking the bsim audio tests
in push CI on main.
Use the correctly prefixed function names.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
If endpoint did not have any name then 0 was used for hash
which is the default value. Because of that service was
assuming that endpoints are bounded. Use value different
than 0.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Instead of support a `shell_stream` for each supported ASE,
we now just support CONFIG_BT_ISO_MAX_CHAN. Since
CONFIG_BT_ISO_MAX_CHAN is the limiting factor in actually setting
up a stream, this is a significantly better way to control the
number of streams. We could optimize further as
CONFIG_BT_ISO_MAX_CHAN contains both unicast and broadcast
streams, so we may only support fewer unicast streams
than CONFIG_BT_ISO_MAX_CHAN at some points in time.
With the default audio.conf this results in a massive RAM
savings:
Before:
Memory region Used Size Region Size %age Used
FLASH: 890368 B 1 MB 84.91%
RAM: 405410 B 448 KB 88.37%
IDT_LIST: 0 B 32 KB 0.00%
After:
Memory region Used Size Region Size %age Used
FLASH: 890480 B 1 MB 84.92%
RAM: 330674 B 448 KB 72.08%
IDT_LIST: 0 B 32 KB 0.00%
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a new function to specifically cancel handover
procedures, similar to the command and initiator functions.
Additionally adds checks for the procedure type to ensure
that the right cancel function is used, to avoid any
unexpected behavior from CAP.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>