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>
Add HTTP client shell commands under the 'net http' subcommand group.
Supports GET, POST, PUT, and DELETE methods.
Commands:
net http get <url>
net http post <url> <body>
net http put <url> <body>
net http delete <url>
Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
The usage of CHECKIF has been replaced with a regular
if. The reason for this is that higher layer may depend
on some of the checks defined by the API, and the higher
layers cannot do that properly if the checks can be
removed via a Kconfig option.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a new bt write-eir-name shell command to set the Extended
Inquiry Response (EIR) name for BR/EDR connections.
Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
Add bt_br_write_eir() API to set the extended inquiry response (EIR)
data for BR/EDR device discovery. EIR allows remote devices to
obtain more information during the inquiry process without needing
to establish a connection.
Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
Allow cdc_acm_poll_in() to receive when CDC ACM function gets enabled,
but only when the IRQ API is not already used.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add an initial assign and check for subgroup == NULL before
calling SYS_SLIST_PEEK_NEXT_CONTAINER as some compilers
consider subgroup otherwise considers it uninitialized:
In function ‘z_snode_next_peek’,
inlined from ‘sys_slist_peek_next_no_check’ at
/__w/zephyr/zephyr/include/zephyr/sys/slist.h:281:1,
inlined from ‘sys_slist_peek_next’ at
/__w/zephyr/zephyr/include/zephyr/sys/slist.h:292:1,
inlined from ‘bt_bap_broadcast_source_reconfig’ at
/__w/zephyr/zephyr/subsys/bluetooth/audio/bap_broadcast_source.c:1008:15:
/__w/zephyr/zephyr/include/zephyr/sys/slist.h:213:20: error:
‘subgroup’ may be used uninitialized [-Werror=maybe-uninitialized]
213 | return node->next;
| ~~~~^~~~~~
/__w/zephyr/zephyr/subsys/bluetooth/audio/bap_broadcast_source.c:
In function ‘bt_bap_broadcast_source_reconfig’:
/__w/zephyr/zephyr/subsys/bluetooth/audio/bap_broadcast_source.c:975:43:
note: ‘subgroup’ was declared here
975 | struct bt_bap_broadcast_subgroup *subgroup;
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Make the codec_cfg parameter of the BAP can CAP APIs const,
as they are now only used as one-time parameters, and not stored.
This also means that any uses of this can place the codec_cfg
parameter in the stack, rather than static memory.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The pointer represent the codec configuration
for a stream based on the ASE or broadcast configuration,
and serves as a read-only value. Changing it to `const` makes
this more clear.
Some minor changes were done to existing code to help
support this change.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In some cases the codec_cfg pointer pointed to the
codec_cfg argument, and sometimes it pointed to the ep->codec_cfg.
Now all codec_cfg arguments are copied to ep->codec_cfg, and
stream->codec_cfg always points to stream->ep.codec_cfg.
This also fixes a bug where metadata updates initiated
by the server was not properly stored by the client.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The function name `avdtp_tx_signal` is misleading as it is used to
transmit single-fragment packets, not specifically signal packets.
Rename it to `avdtp_tx_single` to better reflect its actual purpose
and improve code clarity. Rename `avdtp_tx_frags` as `avdtp_tx_multi`
because AVDTP spec use `multi`.
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
Some resources in MCS were accessed (both read and write) by
multiple threads without any thread protection.
This commit adds a mutex to ensure thread safety.
Since the flags were previously using atomic to
prevent race condition between threads, and since there is
now a mutex, those flags have been modified to be simple
boolean values instead.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add CoAP over TCP/TLS framing, parsing, and client support as
specified in RFC 8323. This includes:
- TCP message framing with variable-length header encoding
- CSM (Capabilities and Settings Message) exchange
- Signaling codes: Ping/Pong, Release, Abort
- CoAP TCP client with blockwise transfer support
- New Kconfig options under CONFIG_COAP_OVER_RELIABLE_TRANSPORT
- Documentation update for CoAP client API
Signed-off-by: Marcus Penate <marcus.penate@ellenbytech.com>
Add bt_conn_br_set_supervision_timeout() API to configure the
link supervision timeout for a BR/EDR connection via the HCI
Write Link Supervision Timeout command.
Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
Add bt_conn_br_get_supervision_timeout() API to read the current
link supervision timeout value for a BR/EDR connection via the
HCI Read Link Supervision Timeout command.
Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
Posix is not a library per the definition of libraries in Zephyr. It
always has been a portability layer and shall reside with other
portability layers under subsys/portability.
Addresses #99250
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Expand the ZTEST_BENCHMARK_OUTPUT_CSV Kconfig help text to describe the
two CSV row formats (sampled and timed) so that users don't have to
reverse engineer them by looking at the code.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Fix a scenario where the logging thread can enter an infinite
loop and starve lower-priority threads when encountering an
uncommitted log message.
If a lower-priority thread is preempted before committing a
message, and a higher-priority thread triggers log processing,
the logging thread may repeatedly attempt to claim it. Since the
message is pending but not committed, z_log_msg_claim() returns
NULL while z_log_msg_pending() remains true, resulting in a
livelock.
Update the log processing logic to avoid looping on uncommitted
messages, allowing lower-priority threads to resume and complete
the commit.
Fixes#101401
Signed-off-by: Javier Romera <lromerajdev@gmail.com>
When CONFIG_LOG_MODE_IMMEDIATE and CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT
are enabled, log messages are processed synchronously and serialized
across CPUs using a global spinlock (process_lock).
In this configuration, if a fatal exception (e.g. stack overflow
triggering a PMP fault on RISC-V) occurs while the current context
already holds process_lock, the fatal error handler may attempt to
log diagnostic messages. This leads to a recursive attempt to acquire
the same spinlock from the same CPU, resulting in a self-deadlock.
This issue is not limited to a specific architecture. It can occur on
any platform where logging is invoked from a fatal or exception context
while the lock is already held.
Fix this by introducing a lightweight owner tracking mechanism for
process_lock. The current CPU ID is stored when the lock is acquired,
and if the same CPU attempts to acquire the lock again, the lock
operation is bypassed to avoid self-deadlock.
This preserves strict log ordering across CPUs during normal operation,
while ensuring that logging remains safe and non-blocking in fatal or
exception contexts.
Signed-off-by: Li Jie <lijie.1996@picoheart.com>
sys_clock_set_timeout() and sys_clock_elapsed() are now documented
as requiring the system clock lock to be held by the caller. Wrap
the calls in subsys/pm/pm.c, soc/nxp/rw/power.c and the kernel
shell thread list command with sys_clock_lock()/sys_clock_unlock().
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
In case socket is closed during an async TCP handshake, the TCP context
should be closed immediately, otherwise the connection could be
established after the socket was closed, causing TCP context leak.
To avoid race between socket close and resend timer (i.e. socket being
closed at the same time as the retransmission limit is reached), add
extra state checks before attempting to close the TCP context.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
body_frag_len was computed using a raw buffer offset formula:
body_frag_len = data_len - (body_frag_start - recv_buf)
This is correct for Content-Length responses: the recv buffer contains
only decoded body bytes after the headers, so the offset arithmetic
gives the exact body byte count.
It is broken for Transfer-Encoding: chunked. RFC 7230 §3.3.2 makes
the two mutually exclusive, so chunked TE never comes with a
Content-Length. With chunked TE, the recv buffer contains both the
decoded body bytes and the chunk framing bytes (chunk-size line, CRLF
body-terminator, terminal chunk "0\r\n\r\n") side by side. The
formula counts everything from body_frag_start to the end of the
buffer fill, so it includes the framing bytes that follow the body,
causing body_frag_len to overcount.
http_parser already knows the exact decoded body byte count: it passes
it as the length argument to on_body(). Use that instead.
Add a regression test that sends a single chunked 206 response from a
raw loopback TCP server in one write, so the chunk terminator and
terminal chunk land in the same recv buffer as the body. The test
asserts body_frag_len equals the decoded body size, not body size + 7
framing bytes.
Signed-off-by: Vytautas Virvičius <vytautas@virvicius.dev>
This PR enables the DNS packet forwarding without taking into account
the return value of `dns_validate_msg` function.
This is to accomodate scenarios like where ANCOUNT is set to 0, or other
cases in which internal DNS implementation will not validate the
message.
Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
Fixes the logic in detecting which partition is being executed
from, also fixes a test for this feature
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Add a `LITTLE_ENDIAN` dependency to `LORAWAN_FRAG_TRANSPORT` due to the
use of bitfields and packed structures in decoding on-air payloads.
Signed-off-by: Jordan Yates <jordan@embeint.com>