If CMUX is not yet connected, or is doing a disconnection,
we should not accept any traffic into pipes.
Block the traffic by replacing the !cmux->attached test with
a runtime test is_connected() that compare states as well.
Rename previous is_connected() to is_active() as it was used
on runtime power management checks.
One exception to rule is pipe->open(), which should be allowed
to be called same time as CMUX connection is initiated.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When the CMUX control channel is closed, CMUX is shut down and
all pipes should be in closed state too.
Notify all modules of this by calling modem_cmux_dlci_pipes_release()
when disconnecting.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
In certain configurations there could be a warning due to potential
use of uninitialized variable. Add initialization.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Avoid accessing the packet after sending it, as the driver may
have already unreferenced or freed it. Use iface argument instead
of calling net_pkt_iface() on a potentially freed packet when
updating packet statistics.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Avoid accessing the packet after sending it, as the driver may
have already unreferenced or freed it. Store the iface before
sending instead of calling net_pkt_iface() on a potentially
freed packet when updating packet statistics.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Avoid accessing the packet after sending it, as the driver may
have already unreferenced or freed it. Store the iface before
sending instead of calling net_pkt_iface() on a potentially
freed packet when updating packet statistics.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Avoid accessing the packet after sending it, as the driver may
have already unreferenced or freed it. Store the iface before
sending instead of calling net_pkt_iface() on a potentially
freed packet when updating packet statistics.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Avoid accessing the packet after sending it, as the driver may
have already unreferenced or freed it. Store the iface before
sending instead of calling net_pkt_iface() on a potentially
freed packet when updating packet statistics.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Fixes an issue whereby a write might have partially been successful
but failed due to insufficient space in the storage device by
re-attempting the write again with the offset, and if it still
fails, return an error
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
If a Remove Source request is received while the IUT is in PA sync
states INFO_REQ or SYNCED, the request is rejected and the source
is not removed.
Signed-off-by: Alex Ciascai <alexandru.ciascai@nordicsemi.no>
Add Kconfig options to control where RTIO SQEs and the RTIO block pool
are allocated: default RAM, DTCM, or a Zephyr nocache region.
This improves robustness and performance for DMA-heavy RTIO users:
- Avoids D-cache coherency pitfalls (especially with tiny DMA buffers).
- Enables using DTCM for lower-latency RTIO queue and pool access.
Signed-off-by: Peter van der Perk <peter.vanderperk@nxp.com>
Comparisons only triggered on comma, leaving the last entry unchecked,
and start_idx was never advanced after each delimiter, making all
subsequent length calculations wrong.
Fix by updating start_idx and uri_scheme_cand on each comma, then
adding a post-loop check for the final entry.
Fixes#105073
Signed-off-by: Hanliang Xu <leonxu2004@outlook.com>
encode_be32() is only used in some configurations.
Let's mark it as possibly unused so the compiler does not warn us about
it
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Commit b9d3344fd4 introduced this static
helper function that is effectively unused and makes clang unhappy.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
On architectures with strict alignment (RISC-V, ARM Cortex-M0),
multi-domain logging can trigger a Load/Store Address Misaligned
exception. This occurs when z_log_msg_enqueue receives a data
pointer from an IPC transport that is not word-aligned.
This commit reorders the operations to perform the memcpy into
the aligned internal buffer before accessing any struct members.
Signed-off-by: Syed Syed <syeds@amd.com>
When credit-based flow control (CFC) is supported, reduce the MTU by
one byte to account for the credits field in RFCOMM frames. This
prevents the SDU length from exceeding the maximum frame size when
the credits field is included in the frame.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Replace custom RFCOMM CRC table and calculation with the generic CRC8
implementation from zephyr/sys/crc.h. This reduces code duplication and
improves maintainability. Also, it will reduce the flash footprint by
about 300 bytes.
The RFCOMM FCS calculation uses CRC-8 with polynomial 0x07, reflected
input/output, and initial value 0xff, which matches the definition of
the specification GSM 07.10.
Also simplify rfcomm_check_fcs() to reuse rfcomm_calc_fcs() and compare
the calculated FCS with the received value directly. It is consistent
with the following logic:
o Calculate the CRC,
o CRC = crctable[CRC^"received FCS"],
o if the CRC equals to 0xcf.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Use atomic_set_bit() instead of atomic_test_bit() in
set_call_incoming_flag().
atomic_test_bit() is read-only, so the previous code did not update
INCOMING_3WAY/OUTGOING_3WAY flags when call_count > 1.
Signed-off-by: Yuheng Li <liyuheng@xiaomi.com>
Turn the hardcoded TLS_SETTINGS_PREFIX into a Kconfig symbol
CONFIG_NET_SOCKETS_TLS_SESSION_CACHE_PERSISTENT_PREFIX so users
can choose a different settings key prefix if needed.
Signed-off-by: Rithic Chellaram Hariharan <gr8rithic@gmail.com>
Add persistent TLS/DTLS session cache support using the settings
subsystem. Sessions are saved after each successful handshake and
restored during tls_init(), enabling session resumption across
device reboots without a full handshake.
Backend-agnostic: works with any settings backend (NVS, ZMS, FCB,
filesystem).
Signed-off-by: Rithic Chellaram Hariharan <gr8rithic@gmail.com>
Support controlling mdm-dtr-gpios in uart_isr, same as it is already
supported in uart_async and uart_async_hwfc.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
Added support for TLSv1.3 to the OCPP subsystem by enabling
TLS secure sockets. This allows secure WebSocket
connections over TLSv1.3 during OCPP communication.
Signed-off-by: Sanjay Vallimanalan <sanjay@linumiz.com>
Convert the RFCOMM DLC (Data Link Connection) management from a manual
linked list implementation using _next pointers to use Zephyr's
sys_slist API. This change improves code maintainability and safety by
using the standard list handling primitives.
Key changes:
- Replace bt_rfcomm_dlc._next with sys_snode_t _node for list handling
- Convert bt_rfcomm_session.dlcs from pointer to sys_slist_t
- Update rfcomm_dlcs_lookup_dlci() to use
SYS_SLIST_FOR_EACH_CONTAINER_SAFE
- Update rfcomm_dlcs_remove_dlci() to use
sys_slist_find_and_remove()
- Replace manual list traversal with sys_slist iterators throughout
- Initialize session DLC list with sys_slist_init() in
rfcomm_session_new()
- Use sys_slist_is_empty() instead of NULL pointer checks
- Use sys_slist_prepend() for adding DLCs to session
The conversion eliminates manual pointer manipulation and reduces the
risk of list corruption while maintaining the same functional behavior.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Instead of waiting the full socket poll period, calculate the next timeout
to resend messages.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Clear the request slot if we cancel them. release_internal_request is
wrong for cancel: Its purpose is to keep token/MID data so late responses
can be matched. But handle_response just silently drops responses for
released slots anyway.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
When address type was not provided calling bt_do_connect_le
leads to crash due to reading argv[2].
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
INSTRUMENTATION_DYNAMIC_TRIGGER currently always defaults to 'y', which
forcefully selects RETAINED_MEM and related drivers. This causes
Kconfig warnings on boards lacking the required `zephyr,retained-ram`
devicetree nodes.
Since this feature relies on specific hardware configurations, it
should be enabled by default only if such configuration is present.
Signed-off-by: Jedrzej Czykier <jczykier@antmicro.com>
Select `UART_CONSOLE` when instrumentation is enabled. Similarly to
`UART_INTERRUPT_DRIVEN`, this option is required for host-device
communication via UART.
Signed-off-by: Andrii Chmutov <achmutov@antmicro.com>
Add support for getting the number of bytes queued for TCP TX
that have not yet been acknowledged. Follows FreeBSD's API.
Signed-off-by: Egill Sigurdur <egill@egill.xyz>
There some more instances of net_pkt_acknowledge_data
API whose return code is not being checked.
Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
In IEEE 1588 standard, there was actually no GRAND_MASTER port state.
We should treat GRAND_MASTER as same as MASTER state (TIME_TRANSMITTER)
in code.
So, added the case PTP_PS_GRAND_MASTER handling same with
PTP_PS_TIME_TRANSMITTER. Otherwise port entering PTP_PS_GRAND_MASTER
won't go out of the state. Also removed switching PTP_PS_TIME_TRANSMITTER
to PTP_PS_GRAND_MASTER which was useless.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
MCUX TRNG triggers hardware errors (TRNG_MCTL_ERR) when used as
continuous random source via HARDWARE_DEVICE_CS_GENERATOR, causing
sys_csrand_get() assertion failures.
On platforms where CONFIG_ENTROPY_NEEDS_PRNG is set 'sys_csprng_get()'
cannot poll directly the entropy device, but it needs to apply some
PRNG on top of it. Therefore enable CONFIG_PSA_CSPRNG_GENERATOR.
Fixes#107087
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
When `h_set` is unset in the handler (which is allowed according to the
docs), then this function causes a nullpointer dereference because
it has no check for this.
This change applies the behavior of `settings_runtime_get` to
`settings_runtime_set` to catch this case as expected.
Signed-off-by: Martin Stumpf <finomnis@gmail.com>
According to the networking documentation:
> The network association status is represented with NET_IF_DORMANT flag
Therefore, the flag should be set at any time that the network is not
associated with. This is achieved by setting the flag at boot, and only
controlling the dormant state at entry/exit from the `REGISTERED` state.
Signed-off-by: Jordan Yates <jordan@embeint.com>
allow for configurable vring alignment for better system
flexibility instead of hard-coded 16 byte alignment
which could be unacceptable for cache-managed systems of different
cache-line sizes
Signed-off-by: Nicholas Lowell <Nicholas.Lowell@lexmark.com>
net_tcp_foreach() drops tcp_lock before the callback and re-acquires
it afterwards. A concurrent tcp_conn_release() can free the next
node cached by SYS_SLIST_FOR_EACH_CONTAINER_SAFE during this window,
causing the iterator to follow a dangling pointer on the next
iteration.
Move context teardown in tcp_conn_release() inside the tcp_lock
critical section and keep tcp_lock held across the callback in
net_tcp_foreach(). No current callback acquires tcp_lock.
Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
One of the branches in the Enhanced Connection Complete HCI event handler
was only partly setting the responder address, i.e. setting the address
value but not the address type. The comment above indicates that the code
expected the Advertising Set Terminated event handler to take care of the
rest, but it's still not ideal that in the intermediate state this field
doesn't contain a valid address (it would indicate a public address type
but with the RPA value).
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Take advantage of the new inline address to string conversion helper,
since it eliminates the need to explicitly declare a buffer variable on
the stack.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Take advantage of the new string conversion helpers to avoid having to
declare explicit on-stack variables.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Take advantage of the new string conversion helpers to avoid having to
declare explicit on-stack variables.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Add a helper API to convert inline (on the stack) the peer address of a
connection to a string.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
The Bluetooth stack has until now had private helpers to return an inline
pointer to a string - something which can be useful e.g. as part of
printk()/printf() call parameters. The reason these were never made public
is that they are not safe when a format string contains more than one
invocation of these.
This commit introduces replacement APIs which allocate an on-stack buffer,
thereby allowing arbitrary number of calls within the parameters of an
output formatting call. The new APIs are defines, since the solution uses
an encapsulating struct to force an on-stack copy, which then requires a
translation to access the struct-internal string member variable.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>