Commit graph

21541 commits

Author SHA1 Message Date
Robert Lubos
4a85e47061 net: http: client: Notify application about unprocessed data
The HTTP client would read data from a socket up to the size of the
receiving buffer, however it may not process them all. This is usually
only the case if protocol switching takes place, where the data read may
belong to another protocol. Therefore we need a way to notify the caller
about any potential data that is already present in the buffer and needs
to be processed.

Introduce an new data_len member in struct http_request to provide the
information about the data already available in the receive buffer. If,
after HTTP response processing, the value is non-zero, the data will be
available in the beginning of the user provided receive buffer.

To make this possible however, we need to track how many bytes were
actually processed by the http_parser, therefore the code will no longer
ignore the http_parser_execute() return value. To simplify processing,
it's also been changed how the receive buffer is used. Instead of using
it in a ring-buffer-like way, the offset variable will track how many
bytes are available in the buffer, and in the rare occasions when not
all data from the buffer was processed by the HTTP parser, we'll
memmomve the remaining data to the beginning of the buffer.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-05-05 10:57:43 +02:00
Johan Hedberg
ed9bed110d Bluetooth: Controller: Be more explicit with thread names
The "BT RX pri" and "BT RX" are too easily confused with host-side threads,
e.g. the host RX thread is called "BT RX WQ". Add "CTLR" to the Controller
side thread names to make it clear that they're managed by the controller.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-05-02 15:21:52 +02:00
Vinayak Kariappa Chettimada
590b86039b Bluetooth: Controller: Fix Extended connection initiation assertion
Fix assertion on aux context release during extended
connection initiation when supporting multiple simultaneous
interleaved Extended scanning support.

Relates to commit a8065926ac ("Bluetooth: Controller: Fix
to release aux context stored in node rx").

Relates to commit 193ce73109 ("Bluetooth: Controller: Fix
missing resume of primary channel scanning").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-05-02 15:20:30 +02:00
Duy Nguyen
2e92209726 test: interrupt_utils: Add method to trigger interrupt on RX
Add trigger_irq() function support for RX
This function will set corresponding IR bit to 1 on RX ICU to
trigger interrupt

Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
2025-05-02 09:18:16 +02:00
Yangbo Lu
f8b450d6a5 net: gptp: adjust only frequency for continuous synchronization
Current clock synchronization was always stepping clock. This was
causing large offset, and discontiguous ptp hardware clock time.
For TSN hardware, discontiguous ptp hardware clock time was not
able to be used for other TSN protocols.

This patch is to convert to frequency adjustment with a basic
PI control algorithm.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-05-02 09:17:12 +02:00
Troels Nilsson
6a5fa60ad4 Bluetooth: Controller: Fix missing window widening in ull_periph_setup
No window widening was applied to conn_offset_us causing the initial
ticker_cb to get called slightly too late

Apply window_widening_periodic_us to conn_offset_us, since this is the
worst-case window widening (win_offset is not allowed to be larger than
a connection interval) and is applied in the LLL window size already

Fixes EBQ failure in LL/TIM/PER/BV-02-C

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-05-02 07:20:03 +02:00
Keith Packard
2d64237f44 cmake: Enable undefined behavior sanitizer on all targets
GCC and Clang support the undefined behavior sanitizer in any
configuration, the only restriction is that if you want to get nice
messages printed, then you need the ubsan library routines which are only
present for posix architecture or when using picolibc.

This patch adds three new compiler properties:

 * sanitizer_undefined. Enables the undefined behavior sanitizer.
 * sanitizer_undefined_library. Calls ubsan library routines on fault.
 * sanitizer_undefined_trap. Invokes __builtin_trap() on fault.

Overhead for using the trapping sanitizer is fairly low and should be
considered for use in CI once all of the undefined behavior faults in
Zephyr are fixed.

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-05-02 01:16:18 +02:00
Vijayakannan Ayyathurai
32253c6159 net: ip: resolve NET_IPV4_FRAGMENT build warning
warning: format '%d' expects argument of type 'int', but argument 3 has
type 'size_t' {aka 'long unsigned int'} [-Wformat=]

Change the printf modifier to %zd for size_t variable will resolve the
warning.

Signed-off-by: Vijayakannan Ayyathurai <vijayakannan.ayyathurai@intel.com>
2025-05-01 18:17:46 +02:00
Lauren Murphy
e0a54835c2 llext: support ARC MPU
Make it so LLEXT allocates a memory region equal or greater
to the minimum size supported by the MPU, to ensure no region
overlap.

Signed-off-by: Lauren Murphy <lauren.murphy@intel.com>
2025-05-01 18:16:30 +02:00
Daniel Leung
5682a7f09e logging: backend/xtensa_sim: more generic enabling condition
Instead of using individual SoC kconfigs to determine whether
to enable the Xtensa simulator logging backend, simply use
CONFIG_SIMULATOR_XTENSA.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2025-05-01 18:16:20 +02:00
Emil Gydesen
6abdc389d4 Bluetooth: CSIP: Remove bt_csip_set_member_get_sirk
The bt_csip_set_member_get_sirk function is superseded by
bt_csip_set_member_get_info and uses of it has been replaced.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-05-01 18:15:56 +02:00
Pieter De Gendt
857abda15e net: lib: coap: coap_server: Change error print to debug
The POLLHUP is expected with, for example DTLS UDP sockets.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-05-01 08:53:32 -04:00
Pieter De Gendt
470b582e04 net: lib: coap: Add CoAP secure support
Add optional TLS secure tag lists for CoAP services to enable DTLS
sockets.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-05-01 08:53:32 -04:00
Emil Gydesen
b04d6386db Bluetooth: Audio: Fix includes
Updates the includes in a a few files to
avoid including unused header files and include the
ones that are used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-05-01 13:42:37 +02:00
Emil Gydesen
b9ddaf7a5f Bluetooth: Audio: Shell: Fix includes
Updates the includes in a a few files to
avoid including unused header files and include the
ones that are used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-05-01 13:42:37 +02:00
Fredrik Danebjer
379eb7a0ff bluetooth: host: Fix premature semaphore giving
There was a semaphore in hci_core which was given to early when
receiving the BT_HCI_EVT_NUM_COMPLETED_PACKETS message from the
controller. This would sometimes cause an assert to happen in
function hci_num_completed_packets, where there would arise a
mismatch in the bookkept count, and actually stored nodes. More
concretely, due to premature semaphore giveing, the tx_pending node
would be have been removed in another context before it could be
fetched and moved to complete list in this function.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2025-05-01 09:34:28 +02:00
Dmitrii Sharshakov
114bc8086d Bluetooth: ISO: fix hci_le_set_cig_params validation
Sizeof of a pointer doesn't make sense here, and
e.g. on native_sim/native/64 this would fail.

Signed-off-by: Dmitrii Sharshakov <d3dx12.xx@gmail.com>
2025-04-30 23:03:07 +02:00
Keith Short
5615e466c9 pm: Cleanup PM stats
Convert PM stats code to use IS_ENABLED in place of #ifdefs.

Signed-off-by: Keith Short <keithshort@google.com>
2025-04-30 18:44:32 +02:00
Vinayak Kariappa Chettimada
5b17b5b44f Bluetooth: Controller: Fix adv aux release on insufficient resources
Fix missing adv aux release on insufficient adv data buffers
configured when starting multiple extended advertising sets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-04-30 16:26:48 +02:00
Robert Lubos
29a2b5c8c6 net: sockets: packet: Fix default binding order
Default binding should take place before we actually make use of the
local address when registering packet socket "connection".
Also, instead of hard coding the protocol for default binding to
ETH_P_ALL, use the protocol that the socket was created with.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-30 16:26:16 +02:00
Robert Lubos
c8798d017f net: sockets: packet: Make it possible to receive packets when unbound
In order to be able to receive packets on unbound packet sockets (which
should collect packet from all interfaces in such case), it's needed to
register receive callback at the socket layer as soon as the socket is
created.

In additional to that, the default binding for packet sockets need to be
revisited. Packet socket should not be bound to the default interface,
as this way the socket would only be receiving packets from that
particular interface. Instead, leave the interface unspecified in such
case.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-30 16:26:16 +02:00
Robert Lubos
cd0b195b00 net: connection: Make it possible to update local address
Allow to update the local address on a registered connection when
rebinding.

This is needed for packet sockets, as by default packet socket
will be bound to "any" interface (interface index 0), and interface
index is part of the local address registered for packet socket.
In order to be able to explicitly bind to a specific interface later, it
needs to be possible to update the local address registered for the
connection, as we need to update the interface index, which is used
by net_conn_packet_input() for packet filtering.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-30 16:26:16 +02:00
Lyle Zhu
cd43e03bbe Bluetooth: classic: shell: Support L2CAP channel seg_recv
Add the callback function `seg_recv` if the configuration
`CONFIG_BT_L2CAP_SEG_RECV` is enabled.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-30 14:00:06 +02:00
Lyle Zhu
df1e2264ff Bluetooth: Classic: L2CAP: Fix seg_recv cannot work issue
When the L2CAP channel connection is in none basic mode, the
`seg_recv` cannot work properly if the configuration
`CONFIG_BT_L2CAP_SEG_RECV` is enabled. And the L2CAP channel
connection will be broken incorrectly.

Check whether the received data len exceeds the SDU length if the
`SAR` is `BT_L2CAP_CONTROL_SAR_END` or `BT_L2CAP_CONTROL_SAR_CONTI`.

And check whether the SDU length is valid if the `SAR` is
`BT_L2CAP_CONTROL_SAR_UNSEG` or `BT_L2CAP_CONTROL_SAR_START`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-30 14:00:06 +02:00
Emil Gydesen
24037ef20a Bluetooth: CAP: Broadcast: Add missing ISO test parameters
The cap_initiator_broadcast_to_bap_broadcast_param function
did not properly relay the ISO test parameters from the CAP
parameters to the BAP parameters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-04-30 10:54:56 +01:00
Troels Nilsson
9fbfa1f626 Bluetooth: Controller: Only validate CIS SDU interval for BN > 0
Some in-the-wild devices use SDU interval of 0 when BN == 0; This
is not allowed by BT Core Spec v6.0, but is not specifically
mentioned in v5.4 and earlier. To allow connecting a CIS to these
devices, relax the check on SDU interval

Note: LL/CIS/PER/BI-07-C only checks rejection of invalid SDU interval
with BN > 0, so it still passes with this change

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-04-30 09:48:24 +02:00
Luis Ubieda
3d4bd5de86 rtio: Introduce OP_DELAY as a valid SQE operation
SQE items with this OP will take the specified amount of time
(asynchronously) before completing. This allows to serve as an
asynchronous delay in between SQE items (e.g: A sensor measurement
requested, which requires 50-ms before having the result available).

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-04-30 09:48:16 +02:00
Shrek Wang
adaec1c7ed net: tcp: start keepalive timer at the right time
keep_alive_timer_restart() only works in ESTABLISHED state. In
tcp_in() SYN_SENT and SYN_RECEIVED state, it won't work by calling
this function. So remove the call in that 2 states while adding it
in the bottom after changing the conn->state to ESTABLISHED.

Signed-off-by: Shrek Wang <inet_eman@outlook.com>
2025-04-30 07:52:14 +02:00
Lyle Zhu
e1d9db8b6e Bluetooth: Classic: L2CAP: Handle shorter data length of the request
The response L2CAP_COMMAND_REJECT_RSP(BT_L2CAP_REJ_NOT_UNDERSTOOD)
should be replied if the received L2CAP command is a invalid L2CAP
signaling command packets with extra data in the Information Payload.

Send L2CAP_COMMAND_REJECT_RSP(BT_L2CAP_REJ_NOT_UNDERSTOOD) if it a
small L2CAP signaling PDU or it has short length.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-30 07:52:03 +02:00
Jordan Yates
7087eb49ef net: zperf: increase default max packet size
Slightly increase the default maximum size for zperf uploads to support
1kB of data payload together with the 40 bytes UDP client header.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-04-29 20:08:32 -04:00
Jordan Yates
d6cb7f4eea net: zperf: custom data upload support
Add support for uploading custom data, instead of a static packet of
'z'. This can be used for more accurate profiling of uplink throughput
for a given application. For example, reading data from flash, or
application level encryption.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-04-29 20:08:32 -04:00
Jordan Yates
bbaf4a7947 net: zperf: specify Unix time offset
The timestamp in the UDP header is expected to be a Unix timestamp, not
an application uptime. Add the option to specify the Unix time at
function entry so that the reported timestamps are accurate.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-04-29 20:08:32 -04:00
Jordan Yates
2f091ad800 net: zperf: fix minimum UDP packet size
The minimum packet size is the combination of the datagram and client
headers, not just the datagram header.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-04-29 20:08:32 -04:00
Adrian Friedli
89f8f5bb07 net: lib: coap: fix division by zero
Prevent the modulo operation causing a division by zero error by falling
back to the minimal ACK timeout value if the random factor is 1.0. Also
fall back to the same value if the random factor is erroneously smaller
than 1.0. Additionally make the upper bound of the random range
reachable.

Signed-off-by: Adrian Friedli <adrian.friedli@husqvarnagroup.com>
2025-04-29 19:04:16 +02:00
Johan Hedberg
fd037c7990 Bluetooth: Kconfig: Remove outdated references to bt_recv_prio()
The bt_recv() and bt_recv_prio() APIs don't exist anymore, so remove any
references to them from the Kconfig help texts.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-04-29 16:51:04 +02:00
Olivier Lesage
f4aa29d849 bluetooth: host: Fix param_len for LE CS Test command
The parameter length for this command was missing the additional
length from the arrayed parameters.

Signed-off-by: Olivier Lesage <olivier.lesage@nordicsemi.no>
2025-04-29 16:49:10 +02:00
Jukka Rissanen
702776bd1f net: mgmt: Remove the _ from symbols
The _ is a reserved character in front of the symbols so remove
it from network management event macros. The remaining string
without the _ will identify the network API anyway so having
underscore there is not needed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-04-29 13:01:01 +02:00
Johan Hedberg
f85d63a6cc Bluetooth: Remove USB H4 mode support
This non-standard feature never had any proper host side implementation
(e.g. it was never upstreamed to BlueZ), and since it comes with notable
maintenance overhead it's fair to just remove it.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-04-29 13:00:33 +02:00
Johan Hedberg
6113230ce3 Bluetooth: drivers: Update to use new H:4 buffer encoding
Update all HCI drivers to use the new H:4 encoding for buffers passing
to/from drivers.

One behavioral change that's done in favor of simplicity, is that where
there's previously been switch statements that could return an error for
unsupported packet types now simply pass any received packet unchanged to
lower layers of the controller (or the HCI transport). Handling this is
now the responsibility of the lower layers, however in practice hitting
such scenarios means that there's a mismatch between configured host and
controller features.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-04-29 13:00:33 +02:00
Johan Hedberg
26d97164be Bluetooth: HCI: Use H:4 encoding for buffers
Encode the packet type as a H:4 payload prefix for buffers passing to &
from HCI drivers. The existing bt_buf_set/get_type functions are
deprecated, but kept compatible with the change, except that they can only
be called once, since they modify the buffer payload.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-04-29 13:00:33 +02:00
Emil Gydesen
54df371740 Bluetooth: TBS: Add support for long read with dirty bit
The TBS spec states that if a value is changed during a
long read procedure, then the server shall reject
read requests with offset != 0 with a specific TBS GATT
error until the value has been read from the beginning again
(i.e. with offset = 0).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-04-29 13:00:07 +02:00
Jiawei Yang
8b3eb368c6 Bluetooth: RFCOMM: Add RPN command sending support
Add support for Remote Port Negotiation (RPN) commands in the RFCOMM.
This allows applications to configure the serial port parameters
over RFCOMM connections, such as baud rate, data bits, stop bits, parity
and flow control.

Changes include:
- Add enumerations for RPN parameters (baud rate, data bits, stop bits,
  parity)
- Add a public API function bt_rfcomm_send_rpn_cmd() to send RPN
  commands
- Add shell command to test RPN with default parameters

This functionality is required by certain Bluetooth profiles that use
RFCOMM and need to configure serial port parameters.

Signed-off-by: Jiawei Yang <jiawei.yang_1@nxp.com>
2025-04-29 08:17:49 +01:00
Lyle Zhu
597d76ce7d Bluetooth: Classic: HFP_HF: Fix out of bounds issue
Check whether the conn index is out of bounds.

CID 520290

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-29 08:17:28 +01:00
Lyle Zhu
be11f6fb0b Bluetooth: Classic: HFP_AG: Fix out of bounds issue
Check whether the conn index is out of bounds.

CID 520297
CID 520296

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-29 08:17:28 +01:00
Lyle Zhu
a1dce20e04 Bluetooth: Classic: L2CAP: Make TxWindow size on both sides the same
In retransmission mode and flow control mode, the TxWindow size should
be same on both sides.

When one side is updated, also update the other side.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-29 08:17:06 +01:00
Mathieu Choplain
abc8cb3bd9 llext: warn when devices aren't exported and extension tries to use them
Kconfig option LLEXT_EXPORT_DEVICES can be enabled to make all device
objects of an image available to LLEXTs, but it is disabled by default.
If an extension tries to import devices when the base image was not built
with this option, the dynamic linking equivalent of the much beloved error
"Undefined symbol __device_dts_ord_XXX" is logged, but this can be quite
cryptic to understand since user may be unaware of LLEXT_EXPORT_DEVICES.

Detect such invalid imports and print a special message that directs users
towards the appropriate Kconfig option, which should reduce the confusion.

Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
2025-04-28 12:53:26 -05:00
Emil Gydesen
68652a6682 Bluetooth: CAP: Broadcast: Add check for memory allocation for create
When creating a broadcast source with
bt_cap_initiator_broadcast_audio_create there was no check if
all broadcast sources were already allocated, which could cause
a NULL pointer dereference.

Add a check, a test and documentation about possibly
error codes of the function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-04-28 16:41:06 +02:00
Krzysztof Chruściński
216476caaa pm: Fix case when forced state is not set
pm_suspend is returning early if there are no states
available (due to locking or latency policy). However,
if state is forced it should not return but rather enter
forced power state.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-04-28 16:40:41 +02:00
Lyle Zhu
6661952dd4 Bluetooth: Classic: SSP: Fix bonding flag mismatch issue
A bonding issue is found with following conditions,
a. Local is a SSP initiator and it is in non-bondable mode,
b. Peer is in bondable mode,
c. The bonding flag in Authentication_Requirements of local IOCAP is
`No Bonding`,
d. the bonding flag in Authentication_Requirements of peer IOCAP is
`Bonding`.

The bonding information will be exchanged and stored. It is incorrect
behavior.

Fix the issue by reporting a pairing failure and disconnecting the ACL
connection with error `BT_HCI_ERR_AUTH_FAIL`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-04-28 13:41:25 +01:00
Fin Maaß
3a195a08da drivers: net: ethernet: change ETHERNET_LINK_*BASE_T
change ETHERNET_LINK_*BASE_T to ETHERNET_LINK_*BASE.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-04-28 09:22:09 +01:00