When using the LLEXT buffer loader we now avoid copying extensions
from storage to allocated memory by pointing directly into the stored
image. We then also perform linking and relocation in that memory,
which modifies its contents. However, this is impossible if that
storage is read-only. Add a Kconfig flag to distinguish between
writable and read-only storage types. Also use that flag to decide,
whether the extension image in test_llext_simple.c should be defined
as const or not.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
a new llext object is completely initialised with zeros after
allocation, no need to additionally set members of an embedded into
it array to NULL.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
llext_list() is an exported function that returns a pointer to the
llext internal extension list. That list should only be accessible
directly inside llext, while holding a lock. Remove the function.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
The llext list should be internal to llext.c, remove its scanning
from shell.c, export a function for that instead.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Use an element size explicitly when calculating the array size and
use the calculated size for memset().
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Extensions should be able to selectively export their global symbols.
Add a LL_EXTENSION_SYMBOL() macro for that. Change the present
.sym_tab to be a temporary symbol table of all global symbols in an
extensions, used only during linking for internal purposes. Add a new
.exp_tab symbol table to store symbols, exported by an extension
permanently.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
If a function fails it should release all the resources it has
managed to acquire. Fix llext_load() to free memory that it has
allocated in case of an error.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Extend the llext_load() / llext_unload() API to let it be called
repeatedly for the same extension to increment or decrement its
reference counter respectively. We use a mutex to protect the counter
and make both llext_load() and llext_unload() return the use-count to
let the caller identify when the first loading and the last unloading
took place.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Loadable modules can contain global (not "static") functions, even if
they aren't exported for use by other modules, e.g. when a module is
built from multiple .c files. Such functions are then also included
in link tables and have to be re-linked.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
llext_seek(), llext_read() and llext_peek() are needed outside of the
extension code too, move them to a header.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Some applications can decide to link their loadable objects for
exactly the same addresses, where they will be loaded. In those cases
local relocations aren't needed any more and can in fact break the
object if applied while the object is in a temporary storage. Add a
parameter to skip such local relocations.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Export some symbols for loadable modules. Also add an
EXPORT_SYSCALL() helper macro for exporting system calls by their
official names.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Applications can use custom ELF sections for their own purposes, add
a function for finding them.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Add support for relocating local symbols, as specified in the
.rela.dyn section.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Add support for linking PIC shared object, which only require
linking, using their PLT and GOT lists and don't need any relocation
otherwise.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
While printing SSID in wifi status command, If the
length is maximum(32 character). It leads to buffer
overflow. It required one character for null
terminator ‘\0’. Changing the Format Specifiers to
print proper SSID.
Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
This fix addresses wrong announce message length warning message.
TLV is a variable length (4+8N) based on the 802.1AS-2011 (table 10-8). In
Zephyr TLV is fixed to 12 bytes. TLV type and length are already taken
into account in the announcement message length.
Signed-off-by: Mario Paja <mario.paja@zal.aero>
BAS v1.1, section 3.1.2.1 notes that a CPF should be added if the
device has more that one instance of the Battery Service, so
add one with the `main` description so that apps can add additional
Battery Level services with other descriptions, e.g. `auxiliary`.
Signed-off-by: Peter Johanson <peter@peterjohanson.com>
Set the static initialiser socket file descriptor to -1 to make sure
it is invalid before using coap_service_send.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Add extra checks that make sure that msg_iov is set
as we cannot receive anything if receive buffers are
not set.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
SIG has changed Bluetooth mesh to Bluetooth Mesh
Updating zephyr docs accordingly
Leaving out old release notes
Signed-off-by: Mia Koen <mia.koen@nordicsemi.no>
Even though the ASCS Sink ASE state machine does not enter the disabling
state according to ASCS spec, it still makes sense to do so.
the state transition unit tests are updated to verify calling or not
calling the disable callback, depending on the transition of the state
fixes#63230
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
The BIS_Sync bitfiled received over the air in Add Source and Modify
Source operations uses BIT(0) for BIS Index 1. Shift it when storing
it to match bis_sync bitfield where BIS Index 1 is at BIT(1).
Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
bis_sync contains BIS index bitfield which is shifted by 1 bit relative
to the BIS_Sync parameter of Broadcast Receive State notification.
Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
Fix two issues with sending ICMP Echo Reply for requests sent for
multicast address:
* Use the originator IP address instead of multicast when selecting
source address for the reply
* In case no address match is found, drop the packet, instead of
replying with unspecified address.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The CoAP request handler returns errno codes in the following cases:
* ENOENT if no handler found; respond with 4.04
* ENOTSUP if an unknown request code received; respond with 4.00
* EPERM no handler found for the method; respond with 4.05
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Fix the possible race between TCP work items already scheduled for
execution, and tcp_conn_unref(), by moving the actual TCP context
releasing to the workqueue itself. That way we can be certain, that when
the work items are cancelled, they won't execute. It could be the case,
that the work item was already being processed by the work queue, so
clearing the context could lead to a crash.
Remove the comments around the mutex lock in the work handlers regarding
the race, as it's not the case anymore. I've kept the locks however, as
they do make sense in those places.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
EATT is the only user of `bt_l2cap_chan_send_cb`, and not necessary. We
can maintain the same functionality without it.
Instead of passing and storing the callback into l2cap, we can store it
in a callback queue in the ATT bearer struct.
This will allow us to remove that internal API later, in order to
streamline the l2cap API.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Replace hardcoded value `8` with `CONFIG_BT_CONN_TX_USER_DATA_SIZE`,
that is `8` but is going to change.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
If some specific option is not enabled, then add missing
ARG_UNUSED() calls in relevant functions.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Set separate option setters for bool, uint8_t and uint16_t
values. Use those generic setters when storing the desired
option value.
The uint16_t option setter stores the value to uint16_t variable
and expects that user supplies int value.
For uint8_t value, it is expected that uint8_t value is supplied
instead of int.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Set separate option getters for bool, uint8_t and uint16_t
values. Use those generic getters when fetching the desired
option value.
Noticed mixed usage (bool vs int) for txtime option. Changed
the code to use int type like in other options.
The uint16_t option getter gets the value from uint16_t variable
but returns int value to the caller, and also expects that user
supplies int value.
For uint8_t value, it is expected that uint8_t value is supplied
instead of int.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
slab_buff size is calculated based on size of osdp_ephemeral_data union
so it is safer to use same structure for slab init.
Changes in osdp_event or osd_cmd structures can cause crashes without this.
Signed-off-by: Arkadiusz Wadowski <wadowski.arkadiusz@gmail.com>
This allows external applications wishing to report coverage data over
different interfaces the ability to do so by exposing the gcov list.
Signed-off-by: Joshua Lilly <jgl@meta.com>
This allows HCI drivers to expose vendor-specific functions to set the
public address.
Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
The Zephyr's core ethernet code had to be adjusted to support setting T1S
PLCA parameters from user Zephyr programs.
Such approach allows more flexibility, as T1S network configuration;
especially PLCA node numbers, can be assigned not only via device tree
at compile time. For example user can read them from EEPROM and then
configure the network accordingly.
For now - the union in struct ethernet_t1s_param only consists of plca
structure. This can change in the future, when other T1S OA parameters -
like Receive/Transmit Cut-Through Enable (bits RXCTE/TXCTE in OA_CONFIG0
register) are made adjustable from user program.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
As other helper functions were introduced for the LE Power Control
Request Feature (see CONFIG_BT_TRANSMIT_POWER_CONTROL), it was noticed
that the return statements of switch cases should be on the next line
generally. This will align phy2str with the rest in bt.c.
Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
To use LE commands of Le Power Control Request Feature one must utilize
the BT_TRANSMIT_POWER_CONTROL config.
Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
This commits adds the LE API's for the LE Power Control Request Feature
in Zephyr.
The support of feature is provided with the controller-based feature
selection with BT_CTLR_LE_POWER_CONTROL_SUPPORT and is selectable via
BT_TRANSMIT_POWER_CONTROL.
With the new APIs, the applications will:
get improved reading of local and remote tx power
be aware of changes in remote or local tx power
Defined HCI commands in Core Spec v5.4:
7.8.117 LE Enhanced Read Transmit Power Level command:
improvement to existing local tx power reading.
7.8.118 LE Read Remote Transmit Power Level command:
Remote tx power is read through an event (LE Transmit Power Reporting)
7.8.121 LE Set Transmit Power Reporting Enable command:
Enables local or remote tx power reporting to monitor changes in tx power
7.7.65.33 LE Transmit Power Reporting event
Note: to utilize the Feature fully Nordic-LL-only vendor-specific commands
are needed. These will not be added in RTOS zephyr but instead
implemented in a maintainable way in sdk.
Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
Protected credential storage makes use of the PSA API, therefore it must
be present in the library include path. This was missed during the
recent CMakeLists.txt rework of this library.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Fix l2cap error handling generally not properly disposing of tx buffers for
enhanced channels; Any callbacks have to be called and the
l2cap_tx_meta_data has to be freed
Signed-off-by: Troels Nilsson <trnn@demant.com>
Add a name for the Kconfig choice symbol
indicating the Zbus subscriber buffer allocation
and adjust the name of the existing choices.
Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
atomic_*_bit functions work with atomic_t arg as with array, therefore
the atomic variable should be declared using ATOMIC_DEFINE.
Coverity-CID: 333358
Fixes#65588
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Regular OpenThread upmerge to commit `75694d2`.
Move CONFIG_OPENTHREAD_PLATFORM_KEY_REFERENCES_ENABLE
from header file to Kconfig.
Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
If we for some reason are supplied unsupported socket type in
recvfrom(), then return ENOTSUP error to the caller instead of
silently accept it by returning 0.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If user has set either IP_PKTINFO (for IPv4) or
IPV6_RECVPKTINFO (for IPv6) socket options, then the system
will return relevant information in recvmsg() ancillary data.
Fixes#36415
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add IP_PKTINFO or IPV6_RECVPKTINFO BSD socket options that
can be used to get extra information of received data in
the ancillary data in recvmsg() call.
For IPV6_RECVPKTINFO see RFC 3542 for details.
For IP_PKTINFO see Linux ip(7) manual page for details.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add low level support for setting IP_PKTINFO or IPV6_RECVPKTINFO
socket options. The support is disabled by default.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Using this new library it is now possible to leverage the memory
attribute property 'zephyr,memory-attr' to define and create a set of
memory heaps from which the user can allocate memory from with certain
attributes / capabilities.
When the CONFIG_MEM_ATTR_HEAP option is set, every region marked with
one of the memory attributes listed in
include/zephyr/dt-bindings/memory-attr/memory-attr-sw.h is added to a
pool of memory heaps used for dynamic allocation of memory buffers with
certain attributes.
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
This removes spurious error message printed when CIS has been
disconnected and it was not used by any of the endpoints.
This case is valid and may happen on Connection Timeout when the
controller reports ACL Disconnection first.
When the CIS Disconnection is reported after, the ASE is already in idle
state and the referenece to CIS has been already removed (on ACL
disconnection).
Fixes: #64896
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Revert back to implementation that did early abort of
previous prepare when a short prepare is enqueued.
Adds back implementation deleted in
commit 7f388bb70a ("Bluetooth: Controller: Fix short
prepare when many enqueued in pipeline").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor refactor of Kconfig order such that the advanced
feature Kconfig is just above the enabling/visible of the
advanced features menu.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The original SHI module only has one output FIFO buffer. It costs a lot
when the driver has to send/change the protocol control code because it
must fill out all 128 bytes of output FIFO. In npcx4, we introduce
another output buffer in 1-byte depth. These two buffers can switch back
and forth during the transaction. We can use the single-byte buffer
to send the control code and the 128-byte FIFO to send the data payload.
It helps improve the SHI driver's efficiency.
Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
Implement the pm_policy lock to prevent the chip enters the deep slepp
mode while shi transaction is ongoing.
Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
Changes of call state were not notified. Fixed by calling notify_calls
in respective functions.
Signed-off-by: Lukas Streitenberger <lukas.streitenberger@wsa.com>
Since sending of public key was moved into system
work (https://github.com/zephyrproject-rtos/zephyr/pull/62331)
it uses the same context as a Host Tx buffer
allocator for gatt sending. Host cannot wait for
free buffer anymore. Mesh requires 4 buffers
to send max size frame(public key) during
provisioning.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Logging shall not use character pointers with %p because in
certain configurations it may lead to memory faults. A compile
time detection is added. If faulty usage is detected then
message is replaced with error message which indicates which
message failed and what shall be done (casting to a pointer
of different type).
Validation is enabled only for configurations which remove
strings from binary as otherwise it may impact CI execution
time.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
By making short inputs optional, the user can bypass short-events all
together if necessary (e.g. custom button-press listener).
Signed-off-by: Juliane Schulze <juliane.schulze@deveritec.com>
This moves including of demand_paging.h out of kernel/mm.h,
so that users of demand paging APIs must include the header
explicitly. Since the main user is kernel itself, we can be
more discipline about header inclusion.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Initially, the command/reply ID byte was not part of the data length
macros. But later, when it was changed to include it, the buffer length
checks was not adjusted. Due to this, we were not using the last byte in
the buffer. Fix this issue by correcting the condition.
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
Commit c7fec71193 ("mgmt/osdp: Add length checks for commands and
replies") attempted to remove code duplication by adding a macro to perform
a length check. At the time, a CI linter did not like macros with control
flow so the code was switched to a method which called __ASSERT() on this
condition.
The __ASSERT() macro is a nop if CONFIG_ASSERT=n (which is the default) and
causes the buffer access to be unguarded which may lead to OOB accesses.
This patch fixes the issue by reintroducing the if check.
Fixes: c7fec71193.
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
Zbus uses mutexes internally that are available
only when MULTITHREADING is enabled so add
it to fix the following error:
/opt/zephyr-sdk-0.16.3/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/
12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/subsys/
zbus/libsubsys__zbus.a(zbus.c.obj): in function `k_mutex_init':
/builds/zephyr/mcuboot/zephyr/include/generated/syscalls/kernel.h:969:
undefined reference to `z_impl_k_mutex_init'
Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
Improved the updates to the name ID metadata (NVS_NAMECNT_ID) item
in the Settings NVS backend implementation. The improvements should
make the implementation more robust in handling edge cases such as:
power downs, resets or a case in which the storage partition is
full. In the last case, the NVS backend could return an ENOSPC error
in the context of the settings_delete API. This change also fixes
this issue.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
When a client uses wildcard subscription and a new message is
published to the matching topic for the first time, the gateway
sends REGISTER message to the client, containing the exact
topic name and a new topic ID.
This change fixes adding these topic ID and name to the internal
topics list.
Signed-off-by: Alexander Vasiliev <alexander.vasiliev@siemens.com>
Add a function to MQTT-SN library API to get topic name by ID
from the internal topics list.
Signed-off-by: Alexander Vasiliev <alexander.vasiliev@siemens.com>
This adds non-volatile settings for the HAS Server. Those are needed to
restore the client awareness of preset list entries exposed by the
server. Based on the settings, the implementation determines how to
notify the client about the HAS related characteristic value changes.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Added igmpv3 support based on the already existing structure for igmpv2.
The already existing api is not modified to prevent breaking exisiting
applications.
Signed-off-by: Ibe Van de Veire <ibe.vandeveire@basalte.be>
Added igmpv3 checksum function to make it possible to calculate the
checksum of a complete igmpv3 pkt at once.
Signed-off-by: Ibe Van de Veire <ibe.vandeveire@basalte.be>
Fix the CMakeLists of the tls_credentials and sockets folders
to link/interface to the net library instead of the zephyr library.
This fixes issues where some files are not found in the link interface
when compiling the sources in this folder.
Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Make sure we send the entire packet buffer before bumping the packet
counter, send() does not guarantee that all of the requested data will
be sent at once with STREAM socket.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case underlying socket reported error while waiting for TX, the
errno value was not set accordingly. This commit fixes this.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Otherwise, if the application was for example blocked on poll() pending
POLLOUT, it won't be notified.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Rework how data is queued for the TCP connections:
* net_context no longer allocates net_pkt for TCP connections. This
was not only inefficient (net_context has no knowledge of the TX
window size), but also error-prone in certain configuration (for
example when IP fragmentation was enabled, net_context may attempt
to allocate enormous packet, instead of let the data be fragmented
for the TCP stream.
* Instead, implement already defined `net_tcp_queue()` API, which
takes raw buffer and length. This allows to take TX window into
account and also better manage the allocated net_buf's (like for
example avoid allocation if there's still room in the buffer). In
result, the TCP stack will not only no longer exceed the TX window,
but also prevent empty gaps in allocated net_buf's, which should
lead to less out-of-mem issues with the stack.
* As net_pkt-based `net_tcp_queue_data()` is no longer in use, it was
removed.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add new function to allocate additional buffers for net_pkt, w/o any
additional preconditions/checks. Just allocate what was requested.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The UART flush is not relevant for the async UART implementation.
UART drivers should handle this internally.
Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
Use single ring buffer and protect it with a spinlock as it is
shared between backend and UART thread (ISR). This is simpler
than the double ring buffer setup.
The receive idle timeout has also been made configurable
instead of being a hardcoded value.
Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
The current implementation only waits for the RX disabled event
to determine if the UART is closed. It should wait for all RX
buffers to be released, and the TX to be done as well.
We now also call uart_tx_abort() when closing the pipe.
Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
RSRQ is the ratio between send and received signal strength and usually
understood/expected to be represented as a ratio in dB and as such always
has a negative range. So to allow RSRQ to be represented correctly the
resource must allow negative values, but currently it's limited to unsigned
8bit integers.
Signed-off-by: Henning Fleddermann <henning.fleddermann@grandcentrix.net>
BINDESC can be used with any POSIX arch based target,
not just native_posix.
Fix the kconfig filter and the sample yaml filter.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Possible NULL pointer dereferences where discovered by static
code analysis, they are addressed in this commit.
Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
Network interface numbering starts from 1, therefore when accessing
help/index array, the interface index should not be used directly, but
rather decremented by 1, to avoid out-of-bound access on those arrays.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Make sure that the error message does not overflow the transmit buffer
when copying the error message string.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
There's not really much to do when the transmission of the error reply
fails, but we can at least log the failure.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The result of string to float conversion in LwM2M shell write command
was not verified, which could result in incorrect data being written to
the resource.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Fix potential integer overflow by casting one of operands to int64_t.
Coverity-CID: 329961
Fixes#65356
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The Private Beacon Client API requires a response argument to allow to
call the API in the asynchronous manner
(https://github.com/zephyrproject-rtos/zephyr/pull/56426).
Because the removal of the EXPERIMENTAL tag for this API was not
released yet, it should be OK to change this API.
The EXPERIMENTAL tag has been removed here:
https://github.com/zephyrproject-rtos/zephyr/pull/64866
Coverity-CID: 330039
Coverity-CID: 330029
Coverity-CID: 329977
Fixes#65336Fixes#65338Fixes#65354
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Verify the return value of net_pkt_skip() function, in case the parser
ignores the unrecognized options, so that in case the option was
malformed and the actual provided option length exceeds the packet
length, it is recognize (net_pkt_skip() should fail then).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
As reported by Coverity, cpkt was being used before checking it's not
NULL.
Fixes#65372 / CID: 323075
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
the reason is that the Mesh Profile clearly stipulates that Mesh nodes
cannot change their own element definitions.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Do not enable subsystem/driver shell modules by default and stop abusing
CONFIG_SHELL_MINIMAL, which is internal to the shell subsystem, to decide
when to enable a driver shell.
The list of shell modules has grown considerably through the
years. Enabling CONFIG_SHELL for doing e.g. an interactive debug session
leads to a large number of shell modules also being enabled unless
explicitly disabled, which again leads to non-negligible increases in
RAM/ROM usage.
This commit attempts to establish a policy of subsystem/driver shell
modules being disabled by default, requiring the user/application to
explicitly enable only those needed.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Since lwm2m_load_tls_credentials(ctx) will assume that the ctx has a
valid security object assigned to it, it should not be called at all
when ctx.use_dtls == false.
This solves a major bug where LwM2M comms are DTLS encrypted but FOTA is
allowed to be plain-text.
Signed-off-by: Benjamin Lindqvist <benjamin@eub.se>
No issues with gcc but clang gives this error for
the *v4 variable few lines below.
.../lib/dns/mdns_responder.c:712:2: error: expected expression
struct net_context *v4;
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Instead of just listening first network interface in the system,
install a multicast listener to all available network interfaces.
Fixes#18748
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add a helper macro that can be used at runtime to return
the number of network interfaces in the system.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Allow user to bind to different network interface. This is
useful if binding a multicast address to a certain network
interface.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Symbopl tables of ELF objects of type ET_REL contain offsets instead
of addresses as for ET_DYN.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
A common pattern is used throughout llext.c:
ext->mem[ldr->sect_map[sym.st_shndx]]
where ldr->sect_map[sym.st_shndx] actually contains indices from
enum llext_section but ext->mem[] is indexed, using enum llext_mem
values. Fix this by changing ldr->sect_map[] to actually contain
enum llext_mem values.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
The symbol count in struct llext_loader is redundant, we already have
one in struct llext_symtable, accessible via struct llext. Remove the
redundant copy.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Simplify llext_copy_symbols() by using a local variable to store a
pointer.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Instead, `sc_indicate` is defined as a no-op when if would previously
not be defined.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
For native_sim we need to have the fuse library linked with the
native simulator runner, not with the embedded code.
Let's fix it.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
DTLS Connection Identifier support requires DTLS stack
that supports it. MbedTLS support in Zephyr is already
ported in, also some offloaded sockets support it.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Since model struct most of member should not change at run time,
so mark as const will be suitable and safely.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
LOG_PRINTK needs to run in supervisor mode and since there
is no syscall that allows it to be called from userspace, this
option has to be disabled when userspace is selected.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This syscall is completely problematic in userspace, it does
not check ANY parameter that is given and it uses variadic argument
that are not copied / checked before being used in the implementation,
instead it just pass a pointer to user stack with unknown data is
blindly consumed by the kernel.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Previous implementation didn't work if CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD
was set to 1. Minmimum value that worked was 2. A value of 1 would
just be ignored and act like 0 with threshold triggerring disabled.
Signed-off-by: Mike J. Chen <mjchen@google.com>
`smp_shell_input_timeout_handler`. Create a public function in
the `shell_uart.c` for it to get the pointer to the
`smp_shell_data` and fix the compilation error.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
str_cnt in llext_find_tables() is actually used to count sections,
rename it to better match that usage.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Use .sh_entsize instead of sizeof(elf_rel_t) to make code suitable
for both REL and RELA types.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Several cosmetic changes with no change in functionality:
The pos variable in multiple functions is used as a loop variable -
it's initialised before the loop starts and then it's incremented for
each loop iteration. Move it to the loop header for readability.
"return ret" is clearer than "goto out" where the "out" label does
nothing but "out: return ret" because one sees immediately that the
function is terminated at that location with no further actions
without the need to check the "out" label.
k_heap_free(heap, NULL) is valid, no need to check the address to be
freed for NULL.
Object counters can be simple (unsigned) integers, no need to make
them size_t or elf_word.
"return 0" is simpler than "return ret" because it shows the return
value immediately without the need to check what it can be at that
location.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This adds retry logic for ASE state notifications if failed due to
insufficient number of buffers to send ATT PDU. The state transition is
retried after connection interval delay.
Fixes: #64574
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The use case is to have a netbuf pool that is used exclusively with
net_buf_alloc_with_data() where the destroy callback takes care of
freeing the actual data buffer pointed to by __buf.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Separate queue should also used for lagecy adv, due to
when local queue has adv buf, k_poll will process local queue.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Compile the `uart_dev` pointer only when necessary
(when `zephyr,log-uart` is used), this saves 4 bytes in
32-bit systems and 8 bytes in 64-bit systems.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Rename the `device` variable in the `struct lbu_cb_ctx` to
`uart_dev`, as it is a convention in Zephyr to not have the
struct variable name after the struct.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Updated the `LBU_DEFINE` so that the index is appended only
when given to improve backward compatibility.
When it is depending on the `zephyr,console` node, the backend
is defined as `log_backend_uart`.
When it is depending on the new `zephyr,log-uart` node, the
backend is defined as `log_backend_uart0`,
`log_backend_uart1`, and so on.
Updated the names of the internal variables to follow the same
naming convention.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
When UART asynchronous API support was added to shell it was set up
to be the default one and was turning on asynchronous API if it was
supported. However, it may lead to complation failures if device
requires additional setup for asynchronous UART (e.g DMA in device
tree). Becuase of that, it is reverted back to use interrupt driven
API and use asynchronous API if it is already enabled in the
application.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
SMP shell was looking into internal shell uart structures to get
uart device. This structures are now internal to the shell and
cannot be used. Using device tree chosen instead.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Fixing compilation failure due to treating void pointer as uint8_t
array. Added missing casting.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Adds a shell interface for TLS Credentials, allowing management of
credentials via the Zephyr shell
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Add (internal) support for sectag iterating.
Also officially marks negative sectag values as reserved for internal
use.
This will allow a prospective TLS credentials shell to iterate over all
available credentials.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Adds an internal credential_digest for generating a string digest of
credentials.
Such digests would allow users of a prospective TLS credentials shell to
verify the contents of a given credential without directly accessing
those contents.
Offloading the digest process to the underlying backend allows backends
for which private portions are not directly accessible to be eventually
supported.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Add implementation to reduce CIG's CIS retransmissions so as
to meet the Host requested Maximum Transport Latency.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added a Kconfig option that makes the RPA sharing feature optional. By
default, the Zephyr Bluetooth stack now uses the RPA rotation policy
that was active before the introduction of the RPA sharing functionality
in the following PR:
https://github.com/zephyrproject-rtos/zephyr/pull/55449
The new Kconfig option configures the advertising sets linked with the
same Bluetooth identity to use the same Resolvable Private Address in
a given rotation period. After the RPA timeout, the new RPA is
generated and shared between the advertising sets in the subsequent
rotation period.
When this option is disabled, the generated RPAs of the advertising
sets differ from each other in a given rotation period.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Rework UART backend to clearly use single instance approach as
before it was a bit messy with some parts of implementation indicating
multi-instance approach and some single instance. Backend has been
around for years and multi-instance requirement never came.
Added support for UART asynchronous API which is more efficient
in terms of power consumption and performance. Asynchronous API
support is using uart_async_rx helper module for handling data
received asynchronously.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Statically initialise the callback list so that subscriptions can be
registered before the call to `bt_enable`.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
The icmsg and icmsg_me backends has limitations in context of
concurrent access to single instance. Some limitations are:
* sending by more thread at the same time may cause -EBUSY
* allocating TX buffer will cause errors in other threads that want
to allocate before first thread sent the message,
* during no-copy receive, when RX buffer is on hold receiving is
totally blocked.
This backend resolves those limitations by adding dynamically allocated
buffers on shared memory next to ICmsg circular buffer. The data is
passed using those buffers, so concurrency is not a problem. The ICmsg
is used only to pass short 2-byte messages containing references to
those buffers. The backend also supports multiple endpoint.
The ipc/icmsg_me sample was modified to support this backend.
Signed-off-by: Dominik Kilian <Dominik.Kilian@nordicsemi.no>
This avoids duplication of the function signature in several places and
makes the API documentation more clean.
Signed-off-by: Martin Jäger <martin@libre.solar>
Rename the lorawan_set_battery_level_callback to
lorawan_register_battery_level_callback to make it consistent with other
functions for downlink and data rate changed callbacks.
Also making the function void for consistency. The get_battery_level
already checks if the callback is NULL before invoking it.
Signed-off-by: Martin Jäger <martin@libre.solar>
`bt_mesh_default_key` is declared as const and thus located in flash.
`bt_mesh_cdb_subnet_key_export` tries to copy to that address which
results in a Bus Fault.
Use separate array for storing net_key.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
A CoAP client can re-issue an observe request (same endpoint and token)
to refresh it's subscription. No new observer should be registered in
this case.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Add a function to the public CoAP API to find and return the unique
observer based on the address and token.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
A recent iface lock removal in ed17320c3d
exposed issues with concurrent access on TX to drivers that are not
re-entrant.
Reverting that commit does not really solve the problem, as it would
still exist if multiple Traffic Class queues are in use.
Therefore, introduce a separate mutex for TX data path, protecting the
L2/driver from concurrent transfers from several threads.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Adds datetime set and get functions which allow for setting and
getting the current time to/from the rtc alias device
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Core objects version reporting was broken for LwM2M version 1.1, as the
default object version not necessarily matches the LwM2M version.
Therefore, implement a table with default object versions for particular
LwM2M version, which can be looked up when determining whether it's
needed to include object version or not during Registration/Discovery.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If the conn security elevation is already in progress, retry the ATT
request if failed due to security reasons.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Queue characters in TX ring buffer regardless of interface state. This
allows simple applications that print basic output to CDC ACM port to
not care about connection or DTR state. Note that depending on actual
application requirements it might be still wise to wait for DTR before
trying to send data.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Prevent ECHO on Linux by arming IN endpoint with ZLP when interface is
configured and making sure that actual payload is only sent after
initialization timeout. The ZLP is not visible to host side applications
because the applications are really accessing tty buffer and received
ZLP does not modify tty buffer in any way.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Add set functions for codec capability, to set all
assigned number values in the bt_audio_codec_cap
struct.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a new function, ltv_set_val, that did most of the
data manipulation from codec_cfg_set_val, so that we can
reuse that code for the codec cap and codec meta
functions as well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Sort the Kconfig and CMakeLists include blocks again, and mark the start
and end of the blocks so that the CI can keep them sorted.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
In the PTS BASS/SR/CP/BV-19-C test case a client executes Set
Broadcast Code operation of Broadcast Audio Scan Control Point
characteristic with Broadcast_Code set to an invalid value.
After syncing to an ISO stream there is an expected failed attempt
to decrypt the stream data, but the host does not set BIG_Encryption
value to the expected value 0x03 (BT_BAP_BIG_ENC_STATE_BAD_CODE).
Add missing BIG_Encryption state into the failing check.
Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
Try to use llext_peek() for section pointers. If it's supported and
succeeds we don't need to allocate buffers.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
The only way so far to access extension images is via a memory
buffer. Since this, supposedly, will also be a rather common method,
it makes sense to add a method to access extension data quickly by
obtaining a pointer instead of copying data into local buffers. Add a
llext_peek() method for that.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
elf_rela_t contains elf_rel_t exactly and contains an additional
field at the end. Therefore pointers of that type can be used for
both types, making the code generic.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
The module linking API can be used for shared objects with no
architecture-specific relocation code. Add a weak function for such
cases.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
ret in llext_load() is always assigned before use, remove its
redundant initialisation.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
From BASS spec:
If the PA_Sync parameter value written by the client is set to a value
of 0x00 (Do not synchronize to PA) and the server is synchronized to
the PA, the server shall stop synchronization with the PA and shall
write a value of 0x00 (Not synchronized to PA) to the PA_Sync_State
field of the Broadcast Receive State characteristic .
Fixes BASS/SR/CP/BV-12-C test case.
Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
This commit adds the option to register an event handler to CoAP
resources when observers are added/removed.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>