The current DNS caching logic is not aware of the IP address version.
If there is a cached address for a query, the caller of
dns_get_addr_info() will receive that address, even if it is not the
same version as the caller requested. For example:
- dns_get_addr_info() is called to resolve an IPv4 address
- the DNS client caches the IPv4 address that was received
- dns_get_addr_info() is called to resolve an IPv6 address
- the DNS client sees that there is a cached IPv4 address for the
given query
- the DNS client does not check that the cached address is of the
requested version (IPv6)
- the cached IPv4 address is returned from dns_get_addr_info()
This changes the DNS client to check IP address version when searching
cached addresses.
Signed-off-by: Noah Olson <noah@wavelynx.com>
The offset in post-write callback is incorrect for TLV format as
the first data block contain TLV header. This fix is replacing
reamaning for offset in opaque context struct and passing it to
post-write and validation callback.
The fix also corrects the offset in pull context as it was pointing
at the end of the block processed data and not on the block context
prior to processing.
Signed-off-by: Dave Lacerte <lacerte.dave@hydroquebec.com>
Several advertising data function could return -1 in case of
errors, which could mess up the advertising data since they are
intended to increment a counter.
Instead of returning an error we use bt_shell_error to inform
the user and then just return with no data changes, so that if
any of them fails, the failing data is just omitted rather
than causing major issues.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix incorrect event_count use in CIG events when the next
CIG interval's prepare overlaps with the current CIG event.
Use separate event_count_prepare variable in ULL and copy
the value in LLL event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect elapsed events value when event prepare are
aborted in the pipeline. This can caused premature
supervision timeouts.
Relates to commit 247037bd3e ("Bluetooth: Controller: Fix
incorrect elapsed events value").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add verification of the parameter struct, so that it returns
-EINVAL if the values are invalid.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of using the bt_conn struct directly, only
access the field via the public API. This ensures that
changes to the struct won't affect PACS, unless it also
affects the public API.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds additional documentation to the callbacks of uac2_ops
to describe if/when they are mandatory to register.
Additionally add asserts before calling them to help debugging
if the user did not register the required ones.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Since a separate CONFIG_NET_TC_RX_SKIP_FOR_HIGH_PRIO was introduced for
RX TC queues, CONFIG_NET_TC_SKIP_FOR_HIGH_PRIO became ambiguous,
rename it to CONFIG_NET_TC_TX_SKIP_FOR_HIGH_PRIO and deprecate the old
config.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The family and proto type was not set for the IPv4 autoconf ARP packets.
Since those should be set for all ARP packets, just move the code
outside of the if block.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Workaround HCTO calculation for BabbleSIM due to need of
addition timeout value required to have anchor point sync.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect peripheral drift compensation when connection
events are overlapping and a PHY update causes the currently
used PHY to change.
Incorrect preamble to address that is calculated using
updated PHY was used causing supervision timeout.
Fixed by storing the PHY used in the current connection
event and using that for drift compensation calculation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix connection event busy check when peripheral role is
using minimal time reservation.
Peripheral and Central have a anchor point sync if the
Peripheral has successfully transmitted once to the Central.
Fixes commit cadef5a64f ("Bluetooth: Controller: Introduce
BT_CTLR_PERIPHERAL_RESERVE_MAX")'.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Recently I have had to debug issues with PSA and having
the returns values from PSA is very useful in order to
find the root cause of the issue.
Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
In https://github.com/zephyrproject-rtos/zephyr/pull/84268
the ability to use the controller for ECDH was removed from
the host.
This means that BT_CTLR_ECDH is now only useful when using
BT_HCI_RAW.
Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
For backends that do not autostart themselves, initialize
& enable them on `log backend <log_backend_*> go`, so
that they function properly.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
The `id` is basically a compile-time constant. Setting it every
time the backend is enabled is unnecessary. Instead, set it on
`z_log_init()` regardless of whether or not it requires to be
`autostart`ed.
Fixes an issue where the `filter_get`/`filter_set`
accessed the wrong index and displayed the wrong log level when
user accesses the status of an uninitialized backend via:
`log backend <uninitialized_backend> status`.
Also fixes an issue when user tries to list the backends via:
`log list_backends`, where all uninitialized backends will have
ID = 0.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
This commit extends the shell command functionality by
adding three new operations for thread management.
kernel thread suspend <thread_id>:
Suspends any thread based on its identifier.
kernel thread resume <thread_id>:
Resumes the thread that was previously suspended.
kernel thread kill <thread_id>:
Terminates any thread based on its identifier
These extended commands are useful for controlling
any threads through Zephyr Shell.
Signed-off-by: S Swetha <s.swetha@intel.com>
Add a simpler flash backend, similar to what we have in the legacy USB
DFU implementation. Support slot-0 and slot-1 flash partitions, but
allow them to be enabled/disabled via Kconfig options.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This new implementation is written from scratch and is not tied to the
image manager and MCUboot. It allows the user to define their own
backend and use a simple macro to instantiate an image. On the USB side
this is represented by an interface. The number of possible images is
configurable using the Kconfig option, and is a fairly inexpensive
approach since it only changes the size of the pointer array. The number
of images is only limited by the number of possible interfaces in a
configuration. The class implementation does not support multiple
instances, as there is no real use for it. However, it does provide two
class instances, one for runtime mode and one for DFU mode. The switch
from runtime to DFU mode can only be performed by the user application,
i.e. the application receives a notification when the host wants to
switch to DFU mode, and then the application can disable the runtime
configuration and enable the DFU configuration. This implementation does
not support switching to the DFU mode by bus reset issued by the
host.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
In the usbd_register_all_classes(), we may need to skip some instances
as they may have very specific function like USB DFU "DFU mode" which
should not be available by default.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Allocate only one 'struct sockaddr_storage', instead of two separate
'struct sockaddr_in' and 'struct sockaddr_in6'. This saves some space in
case both IPv4 and IPv6 are used. Additionally it reduced preprocessor
ifdef statements, resulting in more readable code.
This also solves '-Warray-bounds=' GCC warning (reproducible with
'native_sim' and GCC version 14.2.1 on Arch Linux):
In function ‘create_socket’,
inlined from ‘smp_udp_receive_thread’ at \
subsys/mgmt/mcumgr/transport/src/smp_udp.c:242:7:
subsys/mgmt/mcumgr/transport/src/smp_udp.c:205:37: warning: \
array subscript ‘struct sockaddr[0]’ is partly outside array \
bounds of ‘struct sockaddr_in[1]’ [-Warray-bounds=]
205 | tmp_sock = zsock_socket(addr->sa_family, SOCK_DGRAM, \
| ~~~~^~~~~~~~~~~
IPPROTO_UDP);
subsys/mgmt/mcumgr/transport/src/smp_udp.c: In function \
‘smp_udp_receive_thread’:
subsys/mgmt/mcumgr/transport/src/smp_udp.c:170:28: note: \
object ‘addr4’ of size 8
170 | struct sockaddr_in addr4;
| ^~~~~
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
In the function `bt_l2cap_br_server_register()`, the PSM cannot be
dynamic allocated. And only pre-set PSM is supported.
Improve the function `bt_l2cap_br_server_register()` to support the
dynamic PSM allocation if the passed PSM is zero.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
There is no need to if-def away the net-stats function since there is a
shim available now.
Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
Assert that the size provided to `clock_sync_serialize_device_time` is
sufficient, instead of returning an error code. The condition is already
enforced by the calling code, and returning an error code is incorrect
when the return code is unconditionally being used to increment the
buffer offset by callers.
Fixes#84720.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Fixes calling the registered callbacks for image being confirmed
if the confirmation was not successful
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
lwm2m_gw_handle_req() function logic expects that at least one URI
option was found, therefore add an extra check to return the function
early if that isn't the case.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This adds a new USB device class (based on usb/device_next) that implements
revision 2.0 of the MIDIStreaming interface, a sub-class of the USB audio
device class. In practice, the MIDI interface is much more simple and has
little in common with Audio, so it makes sense to have it as a separate
class driver.
MIDI inputs and outputs are configured through the device tree, under a
node `compatible = "zephyr,usb-midi"`. As per the USB-MIDI2.0 spec,
a single usb-midi interface can convey up to 16 Universal MIDI groups,
comprising 16 channels each. Data is carried from/to the host via
so-called Group Terminals, that are organized in Group Terminal Blocks.
They are represented as children of the usb-midi interface in the device
tree.
From the Zephyr application programmer perspective, MIDI data is exchanged
with the host through the device associated with the `zephyr,usb-midi`
interface, using the following API:
* Send a Universal MIDI Packet to the host: `usb_midi_send(device, pkt)`
* Universal MIDI Packets from the host are delivered to the function passed
in `usb_midi_set_ops(device, &{.rx_packet_cb = handler})`
Compliant USB-MIDI 2.0 devices are required to expose a USB-MIDI1.0
interface as alt setting 0, and the 2.0 interface on alt setting 1.
To avoid the extra complexity of generating backward compatible USB
descriptors and translating Universal MIDI Packets from/to the old
USB-MIDI1.0 format, this driver generates an empty MIDI1.0 interface
(without any input/output); and therefore will only be able to exchange
MIDI data when the host has explicitely enabled MIDI2.0 (alt setting 1).
This implementation is based on the following documents, which are referred
to in the inline comments:
* `midi20`:
Universal Serial Bus Device Class Definition for MIDI Devices
Release 2.0
https://www.usb.org/sites/default/files/USB%20MIDI%20v2_0.pdf
* `ump112`:
Universal MIDI Packet (UMP) Format and MIDI 2.0 Protocol
With MIDI 1.0 Protocol in UMP Format
Document Version 1.1.2
https://midi.org/universal-midi-packet-ump-and-midi-2-0-protocol-specification
Signed-off-by: Titouan Christophe <moiandme@gmail.com>
If VLAN count is set to 0, then only priority tagged VLAN frames
that have tag value 0 can be received. Also this means that VLAN
interfaces are not created which can save memory if you do not need
to receive any other VLAN frames than those tagged with value 0.
Fixes#84023
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Ensure that all packets are no longer used by ethernet_recv after it was
consumed by the l3-handler.
Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
`lwm2m_send_message_async` returns critical errors which are not handled in
many cases. The function can return -ENOMEM, -EPERM or other error codes
from functions called.
Signed-off-by: Marc Lasch <marc.lasch@husqvarnagroup.com>
Add a configuration option to skip the rx-queues for high priority packets
analogously to the tx-side.
Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
To avoid starvation of a traffic class by another, limit the maximum amount
of packets, that can sit in a single traffic-class-fifo to a fraction of
the maximum amount of available packets. In the tx-case also reserve
packets for direct sending, in the case, where
CONFIG_NET_TC_SKIP_FOR_HIGH_PRIO is enabled.
Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
The event monitor did not handled IPv4 multicast address
addition or deletion information.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
To simplify debugging what event code is missing from the
events shell module, print also event id for the for unknown
events. This way it is a bit easier to figure out what the
unknown event is.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Print Ethernet carrier on/off and VLAN tag enabled/disabled
status when monitoring events.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
When reprinting the shell command buffer with long user inputs, the
reprinted buffer may cross a line boundary, and require a newline to be
printed. For these cases, print the command buffer character by
character, inserting newlines as appropriate.
Fixes#82155
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Cast sector_count and sector_size to uint64_t to prevent potential
integer overflow when calculating total device size in
disk_access_device_size().
Fixes Coverity issue CID-322647
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Switches flash_sync to use stream_flash_erase_to_append
instead of stream_flash_erase_page in preparation of deprecating
the later and reming control on erase from API user.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
The recvmsg() function should not modify the buffer configuration
provided in struct msghdr, such behavior is not specified in the POSIX
function description, nor is it consistent with well-known behavior of
this function in Linux.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The usbd_uac2_send function sometimes took ownership of the
provided buffer in error cases, and sometimes not.
The commit modifies the function so that ownership is never
taken in case a non-0 return value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>