Re-run with updated script to convert integer literal delay arguments to
k_sleep to use the standard timeout macros.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Fix ticker previous slot value with elapsed ticks value from
the time stopped ticker has expired. When a ticker is
stopped, if it was in its reserved time space, then the
currently occupied slot (was set to 0) should be the amount
of time that has elapsed in the expired and stopped ticker's
reserved time space and beyond until the stop.
This is required to ensure that any other new ticker does
not get scheduled over the stopped ticker's reserved time
space.
Fixes#19515.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add support for Zero Latency IRQs, which avoids any Zephyr
OS or application influenced ISR latencies on the
controller's ISRs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add support for Zero Latency IRQs, which avoids any Zephyr
OS or application influenced ISR latencies on the
controller's ISRs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Creates macros for determining model message lengths based on opcode,
payload length and MIC size. Also adds macro wrapping
NET_BUF_SIMPLE_DEFINE to serve the most common use case.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
When running a ticker node as "must expire", the node would invoke the
ticker callback even when programmed with latency. As "must expire" is
intended for scheduled events which are skipped due to collision, and as
such expected by LLL, purposefully skipped events should not generate
"must expire" callbacks.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Try to figure out where the ping reply should be sent if there
are multiple network interfaces in the system.
Fixes#19612
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The MQTT transport API functions are already documented in
mqtt_transport.h so need to duplicate them in individual
transport .c file.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Fix ULL implementation that uses conditional compilation by
replacing back to use of #if defined(...) in code accessing
compiled out struct members.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix for possible Tx Buffer leak during disconnection when
the buffers are in ULL context and not yet enqueued towards
LLL context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When more than one simultaneous connections are active,
transmitting data packets to peer, a termination causes
host to use the flushed pending number of completed packets
count for other active connections. This is on reception
of HCI disconnection complete event. But the controller has
not yet released any of the pending enqueued Tx buffers
which was happening after the disconnection event was
dispatched to HCI layer.
The fix here is to dispatch the disconnection complete event
from the LLL context after pending Tx buffers have been
flushed and the buffers get returned to Tx pool in the ULL
context. This way buffers are in the Tx pool before host
get to process the disconnection complete event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix for possible Tx Buffer leak during disconnection when
the buffers are in HCI thread context and not yet demux-ed
and enqueued towards LLL context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the mayfly scheduling of the Tx buffer flushing on
connection termination to be immediate (not to tailchain).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Randomly generating ID the first time coap_next_id() is called is more
in accordance with CoAP recommendations (see
https://tools.ietf.org/html/draft-ietf-core-coap-18, section 4.4)
"It is strongly recommended that the initial value of the
variable (e.g., on startup) be randomized, in order to make successful
off-path attacks on the protocol less likely."
Doing this in a dedicated init function is the cleanest and most
idiomatic approach. This init function is not exposed publically which
means it will be called only once, by the network stack init procedure.
Signed-off-by: Benjamin Lindqvist <benjamin.lindqvist@endian.se>
Uses net_buf_simple_clone to access the sdu of an unsegmented app packet
for re-encryption.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Provides a way to clone a net_buf_simple without altering the state of
the original buffer. The primary usage scenario is for manipulating a
previously allocated PDU inside a buffer without altering the length and
offset of the buffer.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Local messages are already enqueued for the LPN in the tx path, and
don't have to be added again in the rx path.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Re-encrypts single-segment application messages when the network seqnum
has changed, to avoid encrypting messages with different seqnums in
network and transport. This operation is only required for unsegmented
messages, as segmented messages don't need to use the same seqnum in
network.
Reinstates the special adv data for friend messages to store the app key
index.
Fixes#19265.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Provides a utility function for getting an application key given a
subnet and an app ID. Primary use-case in friendship re-encryption.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Provides utility function for parsing network headers outside of the
network layer. The primary intended use-case is friendship.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Check if the encryption procedure is in progress when receiving
rejection for the procedure.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix issue in the handling of LL_REJECT_EXT_IND packets, this would look
at the procedures that are enqueued, and not the procedure that was
being rejected. This meant that although a reject was received for the
encryption procedure, the handling for a different control procedure was
run.
This would result in the link being terminated as control procedure
timer would time out for the encryption procedure.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Static variables and functions don't need #ifdefs if the code calling
them is using IS_ENABLED(). If IS_ENABLED() evaluates to false the
compiler will strip out all the static entities.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Static variables and functions don't need #ifdefs if the code calling
them is using IS_ENABLED(). If IS_ENABLED() evaluates to false the
compiler will strip out all the static entities.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Static variables and functions don't need #ifdefs if the code calling
them is using IS_ENABLED(). If IS_ENABLED() evaluates to false the
compiler will strip out all the static entities.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When aborting radio event, there is a possibility that the
packet timer would start the radio while the packet timer
is being reset. Hence, perform a second radio state disable
with packet timers uninitialised.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing radio status and configurations reset on radio
event abort. This caused under race conditions the radio
being put into active state after being aborted.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect ticker/mayfly user id used in scheduling the
abort of a radio event. Incorrect use of thread context as
the caller caused the abort function to be scheduled from
thread context while being called from ULL high context
level in reality. This could cause corruption of mayfly
scheduling.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When flash driver requests abort of radio event in unreserved
time space, resume radio events in the pipeline were not
flushed. These resumed events caused flash driver to assert
on the check whether radio was in use.
Fixed by flushing the pipeline of all radio events, resume
and also those events in pipeline with pre-empt timeout
being setup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When multiple simultaneous peripheral connections are
supported, restarting connectable advertising by host on
peripheral connection establishment failed in controller.
This prevented establishing new connections while first
connection was active.
The failure was caused by a bug in the way controller was
using quota for Rx PDU buffers. As the quota count was
release before the connection complete event rx PDU buffer
being released, the Rx PDUs needed to reserve for
connection complete event for new connectable advertising
was not available. This caused the connectable advertising
enable to fail.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix bug in ATT reset handling, not releasing queued notification
buffers when the connection is terminated.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
create_ipv6_answer() function is behind #define's but get used behind
IS_ENABLED(CONFIG_NET_IPV6), which is not allowed.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Use the int_literal_to_timeout Coccinelle script to convert literal
integer arguments for kernel API timeout parameters to the standard
timeout value representations.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Periodically wake up log process thread consume more power if system
already in sleep or deep sleep state. With the help of added logging
timer and semaphore, log process thread is woken up only when there
is logging message.
Signed-off-by: Wentong Wu <wentong.wu@intel.com>
Use entropy driver directly in bt_rand instead of stitching together
calls to sys_rand32_get to improve efficiency. The use of
sys_rand32_get could also leak timestamps into keys.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Added support for vendor specific meta data in LLL node_rx_hdr. This
enables vendors to add "footer" data to the RX PDU, for supporting
specialized BLE features.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Even though interrupts are locked before processing in synchronous
call, it is still possible that they will be interrupted by NMI.
In that case log_output module may assert because of buffer
overwritting.
Added flushing of log_output buffer before starting the process to
ensure that output buffer is always in reset state at the beginning.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Several C++ std library headers use __str as internal
variable names. If those headers are included after
tc_util.h is included those headers fail to compile
because tc_util.h defined __str to be a macro.
Fixed by renaming the __str macro to TC_STR.
Signed-off-by: Erwin Rol <erwin@erwinrol.com>
Move tinycrypt related header into test and make those tests only build
on native_posix. The tests are unit tests, ie. testing tinycrypt
functionality only without any dependency on the underlying system.
Long term we should move those to be true unit tests and create
functional and integration tests that use tinycrypt in the context of
Zephyr and for real use-cases.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
There are two problems with how zephyr/subsys/usb is being added to
the include path. Firstly it is using the zephyr_library_ API to
modify the zephyr library, when the zephyr_ API should have been used.
Secondly the code is located in the class directory even though it
affects the more general usb directory.
This patch fixes these issues. Using zephyr_library_ in this instance
works by accident when 'zephyr' is the current library but has not
guarantees of working in the future.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Immediate logging is not compatible with the software-based controller
due to the additional ISR latency that it introduces. Ensure that
deferred logging is in use whenever using the software-based LL.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The log mechanism, even in immediate mode, adds somewhere
between 1K-2K of footprint to applications that use it.
We want to standardize the logging APIs for all logging
within the kernel, but need to not let platforms with
very constrained RAM/ROM in the dust.
This patch introduces CONFIG_LOG_MINIMAL, which is a very
thin wrapper to printk(). It supports the APIs expressed
in logging/log.h.
This will be the new default for test cases.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
These checks should be against CONFIG_SHELL_LOG_BACKEND,
and not against CONFIG_LOG, since it's possible to enable
logging without building this particular backend.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
usb_handle_bos() and usb_handle_os_desc() are got invoked from
usb_handle_standard_request(), remove those unneeded logs.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Kconfig does not set SETTINGS_NONE as default backend (meaning no
backend) because SETTINGS_NONE is optional. There is no difference
between SETTINGS_NONE and SETTINGS_CUSTOM. By removing the optional line
SETTINGS_NONE is selected as default, to use a custom backend
SETTINGS_CUSTOM=y must be set.
Signed-off-by: Laczen JMS <laczenjms@gmail.com>
We now define z_is_idle_thread_object() in ksched.h,
and the repeated definitions of a function that does
the same thing now changed to just use the common
definition.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
The main and idle threads, and their associated stacks,
were being referenced in various parts of the kernel
with no central definition. Expose these in kernel_internal.h
and namespace with z_ appropriately.
The main and idle threads were being defined statically,
with another variable exposed to contain their pointer
value. This wastes a bit of memory and isn't accessible
to user threads anyway, just expose the actual thread
objects.
Redundance MAIN_STACK_SIZE and IDLE_STACK_SIZE defines
in init.c removed, just use the Kconfigs they derive
from.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Handle case where:
- Peripheral sends security request after master has sent pairing
request or started encryption procedure.
This packet can be ignored, as long as the slave has not already
responded with pairing response.
- Central wants to start security after peripheral initiated security
request, return error code busy in this case
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Move initiating security functionality and LTK requesting into the SMP
module so that SMP can track when the connection is in the encryption
process
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Move the bt_smp_keys_check function above all usage of the function
in order to avoid prototype declaration when making the function static.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix calling bt_hex and bt_addr_le_str multiple times in the same logging
call could result in string overwritten since log_strdup is not
guaranteed to duplicate the string buffer in all logging configurations.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Added to allow vendor specific increase of user operation capacity for
ULL_HIGH, to support queuing additional ticker operations.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Enabled use of ticker must_expire feature for ensuring ADV timing
randomization, even when ADV doesn't get air-time. This reduces ADV
collisions. Not active for nRF51 platform for now.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Added support for vendor specific meta data in LLL conn object. This
enables vendors to add state data to connection, for supporting
specialized BLE slave features.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix regression introduced in refactoring of use of SWI.
Reduced use of SWI cannot be used in combination with
CONFIG_BT_CTLR_LOW_LAT as additional SWI is required
to split ticker WORKER and JOB contexts in order to
disable JOB but keep WORKER enabled.
Regression introduced in commit 78b461ae3e ("Bluetooth:
controller: Refactor use of SWI").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The callback function has been ignored in z_timeout_init() since the
timer rework in fall 2018. Passing real handlers to it in code is
distracting when they will be overridden by whatever callback is
provided in z_add_timeout().
As this function is an internal API deprecation is not necessary.
Remove the parameter and change all call sites to drop the argument.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Calling indicate or notify on a disconnected connection object would
result in the error code ENOMEM when failing to acquire buffers instead
of the expected return code ENOTCONN.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The test suite is filled with tests that make assumptions (e.g. about
exactly when other threads will be scheduled) that don't work when
there is another CPU available to handle the load.
Add a feature to the test suite that can "hold" all but one CPU while
the test executes, leveraging the very nice setup/teardown callbacks
to do it. When there is only one CPU, this becomes a very fast noop
of course.
Note that the hold is done by disabling interrupts and spinning, so it
comes with significant CPU cost and tends to drive up the load on the
CI system (and cause other spurious failures on unrelated tests!), so
this can't be used for long-running test cases.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Stop linking interface libraries against zephyr_interface. This is
cargo cult code that in practice does nothing.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
The start timestamp was supposed to signify the starting point of the
clear procedure. The code was incorrectly initializing it to the *end*
point of the procedure.
Fixes#19263
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Do not check size of REQUEST_BUFFER for Data stage IN
transactions. The check can not be done effectively because
the pointer (usb_dev.data_buf) can be changed and the actual
size of the buffer used is unknown at this point.
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Various C and Assembly modules
make function calls to z_sys_trace_*. These merely call
corresponding functions sys_trace_*. This commit
is to simplify these by making direct function calls
to the sys_trace_* functions from these modules.
Subsequently, the z_sys_trace_* functions are removed.
Signed-off-by: Mrinal Sen <msen@oticon.com>
Some modules use snprintk to format the settings keys. Unfortunately
snprintk is tied with printk which is very large for some embedded
systems.
To be able to have settings enabled without also enabling printk
support, change creation of settings key strings to use bin2hex, strlen
and strcpy instead.
A utility function to make decimal presentation of a byte value is
added as u8_to_dec in lib/os/dec.c
Add new Kconfig setting BT_SETTINGS_USE_PRINTK
Signed-off-by: Kim Sekkelund <ksek@oticon.com>
When not using ticker compatibility mode in legacy
controller, ticker job should not be disabled inside radio
events.
Ticker compatibility mode was introduced in
commit 3a9173afe1 ("bluetooth: controller: Revised ticker
for improved conflict resolution").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This file contains redundant definitions of a bunch of nRF IRQ numbers
(not all, however) that only generates confusion, as enumeration values
provided by MDK can be used instead.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Header files of nrfx HALs are not supposed to be included directly
but only with their names prepended with the hal/ directory (so that
an inclusion of an nrfx HAL header clearly differs from an inclusion
of an nrfx driver header).
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
This commit implements generic function to decide
witch functions to call for selected value name with given
loading parameters.
Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
This commit allows loading data from settings permanent storage
directly to the given callback function.
Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
The nRF52811 Radio is similar to nRF52840 and exhibits
similar Radio Timings constants. We align the LE Coded
PHY (S2) RX chain delay with that of nRF52840, which,
eventually fixes the TIFS for nRF52811. In nRF52840 we
correct the inline comment only.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Added CONIFG_LOG_BLOCK_IN_THREAD option to block until buffer for
log message is available. When log message is called in the thread
and there is no buffer available in the pool, thread will block with
configurable timeout (CONFIG_LOG_BLOCK_IN_THREAD_TIMEOUT_MS). If
buffer cannot be allocated by that time, message will be dropped.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
We don't really have docs on how fatal errors are induced
or handled. Provide some documentation that covers:
- Assertions (runtime and build)
- Kernel panic and oops conditions
- Stack overflows
- Other exceptions
- Exception handling policy
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Cast a %lld argument to long long int. This is causing warnings on
recent GNU Arm Embedded toolchains, which fail the build with
-Werror=format=.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
We have introduced option HAS_HW_NRF_RADIO_BLE_CODED, which
reflects that an nRF SoC has a Radio with LE Coded PHY
capabilities. We now modify all #ifdef expressions for
Coded PHY in the nRF controller port, removing SOC_NRF52840
and adding this new option instead. This allows to build
an nRF controller with Coded PHY support for SOCs other
than nRF52840.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Nordic nRF52811 SoC has a 2.4GHx Radio which supports
LE Coded PHY, so we add the option to build a BLE
Controller for nRF52811 platforms with LE Coded PHY
support.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Enable possibility to configure time a slave will wait until
start of connection parameters update procedure after BT connection
is established.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
* The issue is found in supporting offload module esp8266
* For device like esp8266, it's responsible for tcp/udp handling,
no need of net_tcp related functions
* This commit is only tested for esp8266, no gurantee for other
modules
Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
Currently the CONFIG_NET_ROUTING option has limited use as there
would be some entity that populates routing table. Previously it
was RPL that did it but RPL support was removed some time ago.
Fixes#16320
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The boot time measurement sample was giving bogus values on x86: an
assumption was made that the system timer is in sync with the CPU TSC,
which is not the case on most x86 boards.
Boot time measurements are no longer permitted unless the timer source
is the local APIC. To avoid issues of TSC scaling, the startup datum
has been forced to 0, which is in line with the ARM implementation
(which is the only other platform which supports this feature).
Cleanups along the way:
As the datum is now assumed zero, some variables are removed and
calculations simplified. The global variables involved in boot time
measurements are moved to the kernel.h header rather than being
redeclared in every place they are referenced. Since none of the
measurements actually use 64-bit precision, the samples are reduced
to 32-bit quantities.
In addition, this feature has been enabled in long mode.
Fixes: #19144
Signed-off-by: Charles E. Youse <charles.youse@intel.com>
Neither of these options is actually used; CPU_CLOCK_FREQ_MHZ appears
to have been part of x86 BOOT_TIME_MEASUREMENT at some point, and
PERFORMANCE_METRICS is the stillborn cousin of EXECUTION_BENCHMARKS.
Signed-off-by: Charles E. Youse <charles.youse@intel.com>
Remove ctf_middle layer and have only ctf_top and ctf_bottom.
Port functionality from ctf_middle to ctf_top and remove
ctf_middle.h file. Update associated documentation.
Signed-off-by: Mrinal Sen <msen@oticon.com>
This moves check_perm code under GAT and make use of it to check if CCC
write permission can be attended by the connection security level or if
it needs to be increased.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds support to set different permissions to CCCD so security can
be checked when enabling notification which conforms to:
BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part G page 2360:
'3.3.3.3 Client Characteristic Configuration
Authentication and authorization may be required by the server to
write the configuration descriptor.'
In addition to that also ensure that notification are not re-enabled
until the proper security level is reached to conform to the following
statement:
'10.3.1.1 Handling of GATT indications and notifications
A client “requests” a server to send indications and notifications
by appropriately configuring the server via a Client Characteristic
Configuration Descriptor. Since the configuration is persistent
across a disconnection and reconnection, security requirements must
be checked against the configuration upon a reconnection before
sending indications or notifications. When a server reconnects to a
client to send an indication or notification for which security is
required, the server shall initiate or request encryption with the
client prior to sending an indication or notification. If the client
does not have an LTK indicating that the client has lost the bond,
enabling encryption will fail.'
Fixes#17983
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This patch adds support for SDSCv1 and SDSCv2 cards. It has been tested
with 2 GiB SDSC and 4 GiB to 32 GiB SDHC cards from SanDisk.
Signed-off-by: Markus Fuchs <markus.fuchs@de.sauter-bc.com>
Remove logging helper variable `trace_dir` from device configuration
data when it is not needed.
Signed-off-by: Markus Fuchs <markus.fuchs@de.sauter-bc.com>
When a test fails intermittently there is currently no alternative to
looking at logs and pressing a hardware reset button. This commit
adds a Kconfig option that can be set when diagnosing an intermittent
failure. The behavior is to do a cold reset of the board when the
test passes. A counter is maintained in noinit memory to track the
number of times it takes to reproduce a failure.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Add GATT initializer macro for GATT CCC and allow the
BT_GATT_CCC_MANAGED to accept an already initialized CCC user data.
This allows the application to specify the storage location of the CCC
user data.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
CCC storaged is no longer declared separetly so check if ccc->cfg
matches with sc_ccc_cfg no longer works so instead use the cfg_changed
callback and match against sc_ccc_cfg_changed.
Fixes#19267
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Initial thread creation and tracing information
occurs with empty thread names. For better tracing information,
we need to a way to get actual thread names if they are set
in order to better track thread names and their IDs.
Signed-off-by: Nicholas Lowell <nlowell@lexmark.com>
When overwriting an NVS item with data that was a truncated version of
the existing data, the "is this already saved" logic was ignoring the
differing lengths and not saving the new item because the data matched.
Fixes#19250
Signed-off-by: Justin Brzozoski <justin.brzozoski@signal-fire.com>
console_register_line_input has been deprecated for at least 2 releases
so we can now remove it. Remove native_stdin_register_input that is
associated with console_register_line_input.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
If we are getting an old net_context, clear the content of it
in order to make sure we do not have old data in it.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Do not try to re-use net_context.user_data field as in many places
(like in accept) it is expected to contain pointer to net_context.
Storing the socket flags will corrupt the value. To simplify and
make things less error prone, use socket specific field in net_context
to store the socket flags.
Fixes#19191
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
When compiling a sample like a beacon, none of the `if defined()`
statements in the switch case are actually compiled in, so the compiler
complains of an orphan mem_release();break; sequence.
Add a type that we know will always be compiled in in order to avoid
this issue.
Relates to commit 76bfea7cf9 ("Bluetooth: controller: Ensure that a
`case` statement is present").
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
So far OpenThread compiled it's own, internal copy of mbedTLS library.
This commit changes this behavior by using Zephyr's mbedTLS instance
appropriately configured for OpenThread needs.
Generic mbedTLS config file was used in this case, so that application
can still configure remaining parts of mbedTLS for it's own needs.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This makes the identity initialization consistent and actually catches
a few branches where it may not have properly happened.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Make it possible to initiate new connections from within the
disconnect callback. This wasn't completely trivial since there was
connection cleanup done through deferred action using the CONN_CLEANUP
flag.
This patch moves the disconnected callbacks to be run after all
cleanup is done. We can't directly do this in the TX thread, since
that's internal, so we instead take advantage of the deferred work
support and do it using the update_work callback. Since the same
cleanup is needed also for BR/EDR connections the work definition is
moved from the LE-specific struct to the generic struct bt_conn.
A valid bt_conn object in disconnected state is a likely indication of
a connection reference leak, so there's a new BT_WARN() for this case
in bt_conn_create_le().
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
A Kconfig boolean is added to allow users to provide their own
output strings when running tests via ztest.
This allows changing e.g. the PASS/FAIL/SKIPPED strings,
add counters, change separators, and similar.
A test using the feature and relevant documentation is added.
Signed-off-by: Torstein Grindvik <torstein.grindvik@nordicsemi.no>
Adds additional model callback that gets called on node_reset. Will also
erase any user data when this happens.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Adds user data file in the model settings, allowing each model instance
to store some application specific data without having to reinvent the
settings path encoding for model element/ID combinations. Exposes the
settings_handler interface in the model callback structure and adds a
data store function.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Adds a structure of callbacks for each model instance. This allows for
more flexible model implementations, that can interact with the Mesh
stack without going through the application.
For now, only an init callback is added, replacing the init mechanism in
the foundation models. The init callback does not provide the primary
flag that used to be in the foundation model callbacks, but replaces
this with an inline function in access.h.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
When both central and peripheral are supported, one each Rx
node will be needed by connectable advertising and the
initiator to generate connection complete, hence
conditionally set the count.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The socket flags are stored in void* so we need to use uintptr_t
instead of u32_t when manipulating the flag variable.
Fixes#19181
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The $(dt_chosen_label) preprocessor function should be passed
$(DT_CHOSEN_Z_SHELL_UART), not $(UART_SHELL_ON_DEV_NAME).
DT_CHOSEN_Z_SHELL_UART is set right before the Kconfig symbol
definition, to work around the comma in 'zephyr,shell-uart'.
The Kconfig preprocessor functions are defined in
scripts/kconfig/kconfigfunctions.py.
Fixes: #19178
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Refactor to abstract the use of software interrupts in nRF5
Series.
Also, reduce the number of SWI used when interrupt priority
level configured is same for ULL High and ULL Low contexts.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit completes the refactoring of radio.c, so it
calls abstract functions for PPI handling for LE Coded
PHY (e.g. enable, disable channels, or configure endpoints),
which, then, call the platform-specific functions for PPI
handling. The abstract functions are simple wrappers,
implemented in radio_nrf5_ppi.h, conditionally, if we
build the controller with support for LE Coded PHY.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Make the definitions of LE Coded PHY-specific macros
and inline functions conditional, i.e. only if we
actually build the controller with support for LE
Coded PHY.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit refactors radio.c, so it calls abstract functions
for PPI handling (e.g. enable, disable channels, or configure
endpoints), which, then, call the platform-specific functions
for PPI handling. The abstract functions are simple wrappers,
implemented in radio_nrf5_ppi.h.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit defines generic macros for the software interrupt
(SWI) IRQ lines that are used for LLL and ULL LOW interrupts.
This is done for both the cases of the legacy and new (split)
controller architectures. In addition, it abstracts some of
the functionality around software-IRQ signals, to generic
functions, which have platform-specific implementations.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Stores friend queue packets unencrypted, removing any out-of-order
issues caused by seqnum allocation. Also moves as much of the metadata
storage as possible into the packet, allowing us to free up some bytes
of net_buf user data for friend packets.
Fixes#18488
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Makes a define for the seqzero 13-bit mask in transport, and exposes it
in the header for use in the friend module.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Convert how we get the various chosen properties like "zephyr,console"
to use the new kconfig functions like dt_chosen_to_label.
Because of how kconfig parses things we define a set of variables of the
form DT_CHOSEN_Z_<PROP> since comma's are parsed as field seperators in
macros.
This conversion allows us to remove code in gen_defines.py for the
following chosen properties:
zephyr,console
zephyr,shell-uart
zephyr,bt-uart
zephyr,uart-pipe
zephyr,bt-mon-uart
zephyr,uart-mcumgr
zephyr,bt-c2h-uart
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
We need to make sure that net_pkt_clone() sets cursor correctly.
This cursor position is needed so that we can skip IP header
for incoming packet properly. Not all applications need to know
the cursor position of the cloned packet. Unfortunately we cannot
know that in advance so just set the cursor to correct position in
the cloned packet.
Fixes#19135
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If socket is marked non-blocking, then accept() will return immediately
if there is no one connecting.
Fixes#19103
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
SNTP is UDP-based protocol, and thus not reliable. Previously,
high-level aka "simple" SNTP just issues a single request via
the low-level SNTP API. Instead, send multiple requests, starting
with a small timeout, and exponential backoff, repeated within
timeout specified by user in call to sntp_simple().
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
CONFIG_COVERAGE is also supported in some real targets now
as described in the doc
https://docs.zephyrproject.org/latest/guides/coverage.html
So let's remove that missleading sentence
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
If we receive a multicast IPv4 or IPv6 packet, then we need to
deliver it to all sockets that have installed a handler for it.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Previously, they were tested only with CONFIG_NET_SOCKETS_POSIX_NAMES,
but should also work with POSIX subsys. Achieve this by including POSIX
headers in this case.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Fatal error reporting now only dumps to the log mechanism,
so enable it in immediate mode for all tests to ensure
that fatal errors are visible and no messages are lost.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
These functions get called from various places and
we were observing linker errors. Always build the stubs
when userspace is disabled, gc-sections will discard them
if unused anyway.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
If proto field in socket() call is set to 0, then we should have
a sane default for it that depends on the type of the socket.
Fixes#18873
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The semi-automated API changes weren't checkpatch aware. Fix up
whitespace warnings that snuck into the previous patches. Really this
should be squashed, but that's somewhat difficult given the structure
of the series.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
These calls are buildable on common sanitycheck platforms, but are not
invoked at runtime in any tests accessible to CI. The changes are
mostly mechanical, so the risk is low, but this commit is separated
from the main API change to allow for more careful review.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
System call arguments, at the arch layer, are single words. So
passing wider values requires splitting them into two registers at
call time. This gets even more complicated for values (e.g
k_timeout_t) that may have different sizes depending on configuration.
This patch adds a feature to gen_syscalls.py to detect functions with
wide arguments and automatically generates code to split/unsplit them.
Unfortunately the current scheme of Z_SYSCALL_DECLARE_* macros won't
work with functions like this, because for N arguments (our current
maximum N is 10) there are 2^N possible configurations of argument
widths. So this generates the complete functions for each handler and
wrapper, effectively doing in python what was originally done in the
preprocessor.
Another complexity is that traditional the z_hdlr_*() function for a
system call has taken the raw list of word arguments, which does not
work when some of those arguments must be 64 bit types. So instead of
using a single Z_SYSCALL_HANDLER macro, this splits the job of
z_hdlr_*() into two steps: An automatically-generated unmarshalling
function, z_mrsh_*(), which then calls a user-supplied verification
function z_vrfy_*(). The verification function is typesafe, and is a
simple C function with exactly the same argument and return signature
as the syscall impl function. It is also not responsible for
validating the pointers to the extra parameter array or a wide return
value, that code gets automatically generated.
This commit includes new vrfy/msrh handling for all syscalls invoked
during CI runs. Future commits will port the less testable code.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
The .init_array vector is, in fact, read-only data, so put it there.
Previously it was placed at the end of the ROM, but was unknown to
the x86 memory protection code with XIP enabled (because it was not
part of the text, rodata, or kernel RAM). Until recently, the XIP
implementation artificially bloated _image_rodata_size to cover the
entire ROM, so the (mis)placement of .init_array went unnoticed.
Signed-off-by: Charles E. Youse <charles.youse@intel.com>
If we are returned IPv4 address but the hints says IPv6, then
return error as currently we do not support AI_V4MAPPED addresses.
Same check for IPv6 if we want only IPv4 address.
Fixes#18870
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Issue noticed with following scenario.
1) TCP server is listening for connections but will handle
only one connection at a time (e.g. echo-server sample)
2) Client A connects, and the connection is accepted.
3) Client B connects, instead of denying a connection,
it is "auto" accepted (this is the actual bug) even
if the application has not called accept().
4) After the connection A is closed, the connection B
gets accepted by application but now the closed
connection A will cause confusion in the net-stack
5) This confusion can cause memory leak or double free
in the TCP core.
It is not easy to trigger this issue because it depends
on timing of the connections A & B.
Fixes: #18308
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
If we are closing connection before the connection was established,
then unref the context so that the cleanup is done properly.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Changed documentation in Bluetooth Controller
Kconfig for BT_CTLR_ASSERT_HANDLER
Signed-off-by: Kristoffer Rist Skøien <kristoffer.skoien@nordicsemi.no>
Allow user to disable native IP stack and use offloaded IP
stack instead. It is also possible to enable both at the same
time if needed.
Fixes#18105
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Host shall ignore the unknown ATT PDU that has Command Flag set.
Fixes regression introduced in 3b271b8455.
Fixes: GATT/SR/UNS/BI-02-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This commit adds an explicit inclusion of toolchain.h from
ieee802154_frame.h.
The endianness preprocessor definitions (__BYTE_ORDER__,
__ORDER_LITTLE_ENDIAN__, __ORDER_BIG_ENDIAN__) are used by
ieee802154_frame.h; these being not defined can easily go unnoticed and
cause unexpected behaviours, as detailed in PR #18922.
toolchain.h ensures that these preprocessor definitions are defined and
*must* be included in a file that uses these definitions.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit adds an explicit inclusion of toolchain.h from pdu.h.
The endianness preprocessor definitions (__BYTE_ORDER__,
__ORDER_LITTLE_ENDIAN__, __ORDER_BIG_ENDIAN__) are used by pdu.h;
these being not defined can easily go unnoticed and cause unexpected
behaviours, as detailed in PR #18922.
toolchain.h ensures that these preprocessor definitions are defined and
*must* be included in a file that uses these definitions.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
The bt_mesh_fixed_group_match() function is intended to match the
various well-known group addresses, however it was never updated when
Proxy support was added.
Fixes#19015
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
As element addresses are sequential, there's no need for iterating
through the elements to find the one matching a unicast address.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
This has been subsumed by the new implementation in drivers/pcie.
We remove the legacy subsystem, related tests, shell module, and
outdated documentation/config references.
Signed-off-by: Charles E. Youse <charles.youse@intel.com>
When using offloaded network, an L2 is never assigned to the net_if.
Only certain portions of the net_if code are referenced such as:
net_if_up()
net_if_down()
And these functions make use of several L2 references:
get_flags()
enable()
Let's add checks to make sure we don't deref a NULL when using these
functions.
Fixes the following exception on K64F and other HW which can make
use of offloaded network HW:
FATAL: ***** Reserved Exception ( -16) *****
FATAL: r0/a1: 0x00000010 r1/a2: 0x0000644f r2/a3: 0x00000000
FATAL: r3/a4: 0x00000000 r12/ip: 0x2000474c r14/lr: 0x0001475b
FATAL: xpsr: 0x00000000
FATAL: Faulting instruction address (r15/pc): 0x0001b1cd
FATAL: >>> ZEPHYR FATAL ERROR 0: CPU exception
FATAL: Current thread: 0x20004c4c (unknown)
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/18957
Signed-off-by: Michael Scott <mike@foundries.io>
ZLP flag should only be set if less data is sent
than requested by host and the length is a multiple
of wMaxPacketSize. Current implementation does not
check it correctly.
For some platforms like nRF52, this patch will not
be enough to fix the problem. The driver must be informed
about the transfer type before sending the last packet,
without changing the API, it is not possible.
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Don't send zlp immediately after last packet for EP0.
Wait for write done event (in) before sending zlp.
Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
Set limited amount of tries to write to USB control endpoint EP0.
Fixes#16223
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
This patch add tty runtime initialization check for console support
routines. Without it callers of routines API are not aware that
initialization of tty was failed. This patch basically checks
availability of console device and also its support for
interrupt driven transfers if routines are configured to use it.
Signed-off-by: Pavel Kral <pavel.kral@omsquare.com>
Switch form using privater FCB error codes to
errno codes. FCB private codes convention were compatible
with <errno.h> codes:
- 0 mean success
- negative values mean errors
- similar error types.
There was no sense to kept private FCB error codes.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
1) Dump time sinse last scheduler call
Could be handy for tickless kernel debug.
Will indicate that no rtc irq is called
2) Dump current timeout of each thread
Could be used to find yout when thread will wake up
3) Dump human friendly thread state
4) Use shell_prin instead shell_fprintf
Signed-off-by: Pavlo Hamov <pavlo_hamov@jabil.com>
Added ll_rx_link_inc_quota to allow vendor to manipulate
mem_link_rx.quota_pdu when cleaning up nodes via ull_vendor.h.
Signed-off-by: Morten Priess <mtpr@oticon.com>
In setup messages addressing classes, USB standard defines that wIndex
constains interface number encoded in bits 0..7. Bits 8..15
are reserved and normally set to 0. However, in Audio Class they contain
entity number. Hence the need to filter 8 bits for getting interface
number.
Signed-off-by: Bartosz Sokolski <bartosz.sokolski@nordicsemi.no>
Corrected the amount of bytes copied for port handling in parse_ipv6
to prevent reading past the boundaries of the input string.
Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
Add new RD Client API of lwm2m_rd_client_stop() for this
Fix issues of de-register and event reporting in RD Client
Signed-off-by: Jun Qing Zou <jun.qing.zou@nordicsemi.no>
Fix a bug where in tx data PDU enqueued, while a ctrl PDU is
deferred due to Encryption setup being in progress, is
leaked causing HCI Tx Buffer Overflow crash.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix check in start encryption to disallow new encryption
setup while there is one already in progress.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix MIC failure on re-encryption procedure when responding
at the same time to peer initiated feature request.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix control tx queue handling to correctly pause control PDU
responses during encryption setup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to cache Data Length Procedure when
another control procedure is in progress.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Workaround, defer peer initiated encryption while local
initiated procedure with instant is not complete. Peer
master has sent CONN_UPDATE_IND in response to
CONN_PARAM_REQ, and also has initiated a Encryption Setup
thereafter. In this case, avoid corruption of the connection
update context by deferring the Encryption Setup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix implementation to correctly cache the control procedures
initiatable by local and peer. And, fix feature exchange and
version information procedures from being disallowed by
having then as cached requests to the controller.
Relates to #15256.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the inclusion of the littefs Kconfig options inside the
'if FILESYSTEM' block so we don't leak Kconfig symbols if FILESYSTEM
support isn't enabled.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add iterator function to iterate over all connection objects.
Make type a bitmap so that it can be used as a bitmask to select which
conns to receive foreach callback.
Use foreach function internally where possible.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Allows the user to pass a provisioning input complete callback to the
provisioning module, letting the application stop displaying its output
OOB value when the other party finishes their OOB input.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Made BT_HCI_TX_STACK_SIZE configurable and added BT_HCI_ECC_STACK_SIZE.
These changes are necessary to allow vendors to adjust for other
achitectures.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Rework the BT_ASSERT infrastructure with the following changes:
- Transition from LOG() macros to printk()
- Allow the BT_ASSERT() macro to map directly to stancard __ASSERT()
- Allow printing of the assert reason to be disabled
- Switch from k_oops() to k_panic() configurable
There are 2 reasons for using printk() instead of LOG():
- BT_ERR uses deferred logging by default, which is problematic with
ASSERTs
- The __ASSERT() macro in Zephyr uses printk()
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix issue when checking if SMP pairing procedure is allowed to use the
SMP debug keys. This check did not consider the case where the keys
pointer was assigned, but did not contain a valid LTK key.
This resulted in being unable to pair with debug keys without an
existing bond.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix shell build dependencies, subsys/bluetooth/controller is only added
for CONFIG_BT_LL_SW_SPLIT or CONFIG_BT_LL_SW_LEGACY.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The return code of set_random_address is not always handled. This could
lead to connection using the wrong Identity address.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
nrf_timer.h and nrf_ppi.h are included by including
radio_nrf5.h, so we do not need to include them in
radio.c.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit enabled TEST_USERSPACE_WITHOUT_HW_STACK_PROTECTION
Kconfig option by default for ke1xf SoC Series, which instructs
the build to disable HW stack protection from tests that are to
run with User Mode enabled. This is done because this platform
does not have a sufficient number of MPU regions to support HW
stack protection (Stack Guards) and User Mode simultaneously.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit introduces a new Kconfig option in the testsuite
sub-system, which allows us to disable HW stack protection from
tests that run with user mode enabled.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Remove incorrect LL_ASSERT check in Lower Link Layer that
checked for invalid connection handle on reception of PDU.
The assert is not needed as PDUs can be received until the
Upper Link Layer is aware of the acknowledgement of the
terminate ind PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add workaround for advertising data issue in the internal bluetooth
controller. The advertising data must be set after advertising
parameters in order to successfully update the advertising data after
an directed advertiser has been active.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Make sure that the last entry added is deleted correctly by storing the
fact that one was found in a local variable.
Fix by Laczen JMS <laczenjms@gmail.com>
Fixes#18813.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix handling of Rx-ed PDU on termination, do not process
Rx-ed control PDUs and release the PDU buffer back to the
free pool.
Without this fix, Rx-ed control PDU was responded with a
Tx PDU, which did not get acknowledged or released.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The usdhc driver was incorrectly post-decrementing a do/while loop
iterator, causing an extra iteration of the loop and an out-of-bounds
array access. Change the iterator to decrement within the loop instead.
Tested samples/subsys/fs/fat_fs on the mimxrt1050_evk board.
Coverity-CID: 203403
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
Endianness bug fix in bt_uuid_create function.
Replaced bt_uuid_create_le with bt_uuid_create which
handles both UUID from air and internal varaiable.
Fixed bug with endianess in case of big endian targets.
Signed-off-by: Akshatha Harishchandra <akhr@oticon.com>
The LwM2M implementation for DNS resolving has checks which
configure hints based on whether IPv4 or IPv6 are enabled.
Neither of them need enabled if using NET_SOCKETS_OFFLOAD,
which then causes an error to be returned to due to
"hints.ai_family" not being set.
Also the offload API need to know when to free the allocated
"struct addrinfo" instead of calling free() generically,
thus let's use the freeaddrinfo() API for sockets which will
call into the offload API if needed.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/18765
Signed-off-by: Jun Qing Zou <jun.qing.zou@nordicsemi.no>
When an opcode doesn't have a handle that doesn't mean it is unknown
just that it will not be handle as it could have been disabled.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
SMP shall be considered internal TX notify callbacks so they are
allowed to be run from TX thread context like the others.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When CONFIG_BT_GATT_CLIENT is not set att_op_get_type would return
unkown operation instead of properly return the opcode.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Since bt_l2cap_create_pdu can return NULL when used under syswq context
the code should always check its result, this also changes the timeout
to have a specific value (RTX maximum timeout) so signalling PDUs still
wait for a buffer to become available.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
In certain cases there could be no buffer available which may lead to
NULL being returned by bt_l2cap_create_pdu so instead use
bt_l2cap_create_pdu_timeout to wait with a specific timeout.
Note that this should also ensure the SMP will not be waiting for a
buffer when the remote might have timed out already.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds bt_conn_create_pdu_timeout function which can be used
to provide a timeout when allocating a buffer.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When the firmware_pull mechansim sends the callback to notify the
sample of a new firmware block, the user supplied buffer can be
smaller than the CoAP BLOCK_SIZE setting. To handle this case,
we loop through the payload and fill the user supplied buffer with
smaller chunks.
Unfortunately, the last_block calculation is done outside this loop
which causes several callbacks (while in this loop) to have
last_block true. Let's fix this by adding a small check to make
sure we're at the end of the current payload block before notifying
the user of a last_block.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/16158
Signed-off-by: Michael Scott <mike@foundries.io>
The mDNS packet receive had issues:
* The DNS id needs to be 0 for both sending and receiving, we did
not accepted 0 incoming id.
* The mDNS response does not have any questions in it so we just
need to skip the question count checks in response.
* Skip the Cache-Flush bit in Class field so that we can properly
parse CLASS_IN value.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
In DNS server init, print information whether the DNS server
is mDNS or LLMNR one. This way we do not need to remember what
IP addresses are used either of them.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The source UDP port in all Multicast DNS responses MUST be 5353
as described in RFC 6762 chapter 6.
Fixes#18732
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Increase the length of the request buffer.
Current value is not enough for an average
device descriptor.
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Mitigate the check of the request buffer length because
the host may not know the real length for some responds.
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Make sure we use the IPv4 event command when checking IPv4 address
add or delete instead of event mask.
Coverity-CID: 203483
Fixes#18400
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Fix reset of Encryption Procedure state on reception of
REJECT_IND and REJECT_EXT_IND.
This is a regression in commit 79cb615770 ("Bluetooth:
controller: split: Port Enc setup to be queueable")
Relates to #18578.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When val1 is 0, we need to handle a negative val2 value so that we
generate correct TLV value.
Example: val1 = 0, val2 = -500000 is equivalent to -0.5 decimal.
Currently we generate: 0.5 (losing the sign).
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/16154
Signed-off-by: Michael Scott <mike@foundries.io>
Current JSON formatting for float32/64 is broken in a similar way as
plain text. Let's use the newly fixed logic for plain text to
generate the float32/64 values in the JSON string.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/16154
Signed-off-by: Michael Scott <mike@foundries.io>
We can use the plain text float32/64 formatter for JSON as well, so
let's expose the put_float32/64 functions.
Signed-off-by: Michael Scott <mike@foundries.io>
Formatting a float32/64 value for plain text is broken.
Example for 32bit: val1=0 and val2=500000 is equivalent to 0.5
Current formatter was using %d.%d (%lld.%lld for 64bit) so
exported value was 0.500000 (or 0.5)
To fix this, for val2 use a zero-padded formatter for the maximum
length of each bit length (6 for 32bit and 9 for 64bit), and then
remove the zero characters at the end of the string.
Notes re: handling of val1/val2 signs:
- eliminate potential negative sign when converting val2 to avoid:
a value like: 0.-5
- use negative val2 when val1 is 0 to fix small negative handling
such as -0.5
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/16154
Signed-off-by: Michael Scott <mike@foundries.io>
This commit adds basic userspace support to the logging subsystem.
With this change, the following API could be called from user mode:
- LOG_*()
- LOG_INST_*(),
- LOG_HEXDUMP_*(),
- LOG_HEXDUMP_INST_*(),
- LOG_PANIC(), LOG_PROCESS(),
- log_printk(), log_generic(), log_buffrered_cnt(),
- log_filter_set(NULL, ...)
With userspace disabled, the logger behavior and performance
is not affected. With userspace enabled, the calls from kernel
space have an additional overhead introduced by _is_user_context().
The logger behavior changes when it is called from the user context.
All strings logged using LOG_*() and LOG_INST_*() API from userspace
are rendered in place for security reasons and then placed in
log_strdup() memory pool, which should be large enough to hold bursts
of log messages.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
if base64_decode function returns error, function can't continue
otherwise a fatal error will cause the thread to spin, putting the
system into an unrecoverable state
Signed-off-by: Faisal Saleem <faisal.saleem@setec.com.au>
Do not try to memcpy() the same buffer to itself.
This one also reverts commit 112ecb7290
("net: gptp: Fix for coverity CIDs 203471 and 203464") as that
did not fully fix the issue.
Coverity-CID: 203464
Coverity-CID: 203471
Fixes#18394
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Fix the controller implementation to handle data packet
enqueue being pause on Encryption Request be done early in
the ULL when enqueueing packets towards LLL.
Fixes#18645.
Signed-off-by: Vinayak Kariappa Chettimada <vinayak.chettimada@gmail.com>
Rename AUTHENTICATION, to AUTH, since this is a well established short
form of the word.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Rename bt_conn_security to bt_conn_set_security, this makes the API
naming more consistent.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Rename security level enum, using level and number instead of low,
medium, high and fips.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Make sure that the extension, like HBHO, sub-option length is
not too large.
Fixes#16323
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
A security vulnerability in the Bluetooth BR/EDR Bluetooth Core
specification versions 1.0 through 5.1 has been identified as
CVE-2019-9506. The Bluetooth BR/EDR encryption key negotiation
protocol is vulnerable to packet injection that could allow an
unauthenticated user to decrease the size of the entropy of the
encryption key, potentially causing information disclosure and/or
escalation of privileges via adjacent access. There is not currently
any knowledge of this being exploited.
From Core spec erratum 11838:
A device shall enforce an encryption key with at least 128-bit
equivalent strength for all services that require Security Mode 4,
Level 4. For all other services that require encryption, a device
should enforce an encryption key with at least 56-bit equivalent
strength, irrespective of whether the remote device supports Secure
Simple Pairing.
After encryption has been enabled, the Host should check the
encryption key size using either the HCI_Read_Encryption_Key_Size
command (see [Vol 2] Part E, Section 7.5.7) or a vendor-specific
method.
Fixes#18658
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In case sufficient security level wasn't reached the error propagation
was missing, which could lead to incorrect state transitions when
update_sec_level_br() returns. Return true/false and make sure to
abort any further operations in case the update fails.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The storage for the public key is pub_key in hci_core.c.
When the public key event is generated the public key is copied into
this buffer, but the pointer to the event storage of the key is given
in the public key ready callback (bt_smp_pkey_ready).
SMP expects that it is safe to assign a global pointer to this variable.
In smp_init bt_pub_key_get is used to get the pointer to the public key.
In both cases SMP assigns the le_sc_pub_key to the pointer given.
This creates an issue when bt_smp_pkey_ready callback occurs after
smp_init during pairing procedure, SMP will then have a pointer to an
event buffer that has been released and contains invalid data.
Fixes: #18580
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Increase temporary buffer size to 8 bytes in fcb_append to prevent
stack overflow in case flash alignment is bigger then 2 bytes.
Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
The size of the request buffer (USB_REQUEST_BUFFER_SIZE)
is configurable and depends on the needs of an application.
Check if the request buffer is not too small.
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Give the security changed callback when the peripheral initiated
security request and peer attempted to encrypt the connection but no LTK
match was found.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Make sure that a new pairing procedure with an existing bond does not
result in a security with weaker security properties.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add option to force the host to initiate pairing procedure even if the
host has encryption keys for the peer.
This option can be used to pair with a bonded peer that has deleted its
bonding information without deleting the keys. If new pairing results
in weaker keys the pairing will be aborted.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add security error to security_changed callback. Call this callback when
security has failed and provide current security level and error.
Reason for failure can be.
- Pairing procedure failed, pairing aborted before link encryption.
- Link encrypt procedure failed
- Link key refresh procedure failed.
Fix missing bt_conn_unref on encryption key refresh with error status.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Stop the pairing procedure in the request phase if no storage is
available for the keys. This avoids the pairing procedure from failing
during the key distribution phase.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Proved the Authentication callback for pairing failed and pairing
complete when BR/EDR SSP is complete.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Allow SMP debug keys to behave in the same way as normal keys, in order
to debug with encryption and Bluetooth sniffer the exact way it behaves
when not using debug keys.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When the bootstrap support was added, it looks like I somehow missed
the handling block in the engine.
Let's add it now to fix boostrap support.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/18080
Signed-off-by: Michael Scott <mike@foundries.io>
- LWM2M_SECURITY_INSTANCE_COUNT wasn't following the standard of
having the unconditional default in the last position
- LWM2M_SERVER_INSTANCE_COUNT needs another instance when
bootstrap is enabled.
Signed-off-by: Michael Scott <mike@foundries.io>
LwM2M boostrap support is enabled via the config option:
LWM2M_RD_CLIENT_SUPPORT_BOOTSTRAP. If enabled, this config sets
the default # of server and security instances. However, this is
not working correctly because LWM2M_RD_CLIENT_SUPPORT_BOOTSTRAP
is defined below it's uses in the Kconfig file.
Let's move the RD_CLIENT configs higher in the Kconfig to fix this
behavior.
Signed-off-by: Michael Scott <mike@foundries.io>
Update state after RESUME event.
Use LOG_INF for important events and log a
warning if the data is discarded.
Fixes#17488
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
If no challenger went to replace the best port/vector, then the best
port is still the global_ds and thus point to the same memory: no need
to update the global_ds then.
Coverity-CID: 203471
Coverity-CID: 203464
Fixes#18395
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Looks like the logic to count rejection is missing. Removing count_rej
variable, and set a comment about initializing the code to the right
value once this logic will be in.
Coverity-CID: 203514
Fixes#18398
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Fix reset of Encryption Procedure state on reception of
REJECT_IND and REJECT_EXT_IND.
This is a regression in commit 79cb615770 ("Bluetooth:
controller: split: Port Enc setup to be queueable")
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The period_start timestamp wasn't getting properly initialized in the
case that retransmission was not being used. In the case of
retransmission the timestamp was getting updated in the mod_publish()
delayed work callback. Add a send_start callback and do the
initialization there, since this covers both the retransmission as
well as the no-retransmission cases.
Fixes#17820
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Post Tx pool corruption fix, clean up code and add comments
explaining the use of Tx node next field used to indicate
the Tx node's allocation from Control or Data pool.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the Tx FIFO, queue and pool corruption due to missing
release of link object to Tx link pool and hence missing
reset of the per connection initially allocated Tx link
free pointer.
The bug caused Tx PDUs and associated memory to be lost
leading to missing L2CAP segment transmissions. With lost
control PDU buffers, ULL would stall processing Done events
also leading to controller asserts.
Fixes#18546.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Check if usb_cfg_data pointer was initialized
before endpoint descriptor section is processed.
Coverity-CID: 203473
Fixes: #18423
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
This removes the necessity of registering the storage for CCC and make
it part of the declaration itself.
Fixes#18547
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds support to provide an UUID to bt_gatt_indicate so API user
don't need to hardcode the attribute offset by hand.
Fixes#18572
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The code for checking space in the Friend queue was faulty in the case
that we receive a message with more segments than the configured Friend
Queue size. This is not an issue for the default configuration but
still a possible one. Move the check for exceeding Friend Queue Size
to the per-LPN function, so that bt_mesh_friend_queue_has_space()
iterates all LPNs before delivering its verdict. This allows us to
return success in case no LPN matched (which is how the code was
intended to work).
Fixes#18522
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Simplify algorithm to skip (aka calculate length) of encoded domain
name in a DNS answer. Now it's fully compliant to RFC 1035 regarding
handling of compressed FQDNs. Additionally, bounds checking is now
performed by the parsing code.
Fixes: #18334
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Fix for Zephyr bug #17415
For settings_line_val_read function with following .conf setting:
CONFIG_SETTINGS_USE_BASE64=y
Signed-off-by: Declan Traill <declan.traill@setec.com.au>
Consistently place C++ use of extern "C" after all include directives,
within the negative branch of _ASMLANGUAGE if used.
Background from issue #17997:
Declarations that use C linkage should be placed within extern "C"
so the language linkage is correct when the header is included by
a C++ compiler.
Similarly #include directives should be outside the extern "C" to
ensure the language-specific default linkage is applied to any
declarations provided by the included header.
See: https://en.cppreference.com/w/cpp/language/language_linkage
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Consistently place C++ use of extern "C" after all include directives,
within the negative branch of _ASMLANGUAGE if used.
Background from issue #17997:
Declarations that use C linkage should be placed within extern "C"
so the language linkage is correct when the header is included by
a C++ compiler.
Similarly #include directives should be outside the extern "C" to
ensure the language-specific default linkage is applied to any
declarations provided by the included header.
See: https://en.cppreference.com/w/cpp/language/language_linkage
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
According to Mesh Profile Specification 1.0.1 Figure 5.17, the
unprovisioned device should send its confirmation value after the
provisioner sends theirs. Previously, the confirmation value would be
sent immediately after OOB input complete. Now it first waits for the
input data, then from confirmation from the provisioner before sending
the confirmation.
Fixes: #18178.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Let's use IS_ENABLED() instead of the #ifdef to get clearer code. ret
variable is used only at one place, no need for the ARG_UNUSED()
Coverity-CID: 203397
Fixes#18419
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Let's use IS_ENABLED() instead of the #ifdef to get clearer code. ret
variable is used only at one place, no need for the ARG_UNUSED()
Coverity-CID: 203468
Fixes#18420
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Qualification test case MESH/NODE/FRND/FN/BV-08-C requires that we do
not store more messages than the reported Friend Queue size. The
implementation was so far opportunistic and stored more if it could
(it would later discard if necessary to make sure all queues can store
the required amount). The spec also requires the queues to have new
messages overwrite old ones (in the style of a circular buffer), so we
have to keep track of which buffers are part of the same segmented
message (so we discard all buffers belonging to the same message).
To pass the test case, add APIs to check for space in the Friend
queue, and track the number of buffers for each incoming segmented
message.
Fixes#18090
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The bt_mesh_trans_resend() function had no users, and had in fact not
even a prototype in a header file. Just remove it.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When sent solely to the Friend Queue the send callbacks were not
getting called for unsegmented messages.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This fixes the dead code when parsing Find Information response since
the index counter can never be zero, instead it checks there are any
attributes found and if there nothing don't proceed with discovering
which was the original intent of the now dead code.
Fixes#18384
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Due to conditional compile path ending in LL_ASSERT(0), the compiler
sees code following the assert as using uninitialized variables.
Signed-off-by: Morten Priess <mtpr@oticon.com>
The number of arguments for a format string is approximated by the
number of conversion specifications. This count may exceed the maximum
supported argument count. Limit the extraction to the available space.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Closes#18392 by asserting and returning an error if the block size is
not positive.
Closes#18458. The diagnosis here was not relevant as an in-range EOS
is written before the buffer is used, but using the non-terminated
length is slightly more clear about intent and may avoid a read overrun
of the mount point.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit fixes following issues in printf formatting
- cast values of type off_t to long to remove warnings generated when
compiling with Newlib and CONFIG_IMG_ERASE_PROGRESSIVELY is enabled
- cast values of type off_t always to long and not u32_t
- use 'z' modifier (as in "%zu") to print values of type size_t
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
When the database changes and a client becomes change unware it should
also clear the out of sync flag as the following request should return
an error:
Core Spec 5.1 | Vol 3, Part G, 2.5.2.1 Robust Caching:
'The error response is sent only once after the client becomes
change-unaware, unless the client disconnects or the database changes
again before the client becomes change-aware in which case the error
response shall be sent again.'
Fixes: #18183
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes the following crash:
ASSERTION FAIL [0] @ ZEPHYR_BASE/subsys/logging/log_core.c:180
argument 2 in log message "%s: Stored CCCs for %s (%s)"
missing log_strdup().
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fix issue unable to connect to bonded peer when host resolution is used
either because the controller does not support privacy, or the
controller resolving list was exceeded.
In this case we need to use the RPA from the advertising report
directly, there is a small chance of the peer cycling the RPA here, in
which case the connection might be unsuccessful.
Bug introduced here: 45da629b24Fixes: #18306
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Disable Advertising Extensions by default, since they are not really
operational and they take RAM.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When compiling a sample like a beacon, none of the `if defined()`
statements in the switch case are actually compiled in, so the compiler
complains of an orphan mem_release();break; sequence.
Add a type that we know will always be compiled in in order to avoid
this issue.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When in Low Power mode an LPN may receive messages sent by nodes other
than its friend during its brief receive window. These messages get
rejected by the transport layer. At some point in the future the LPN
will receive these messages from its friend, however they will have
already been added to the network message cache earlier.
When the transport layer rejects a message due to it being received from
a non-friend node while in Low Power mode it must be removed from the
network message cache so that it can be correctly received from its
friend in the future.
Fixes#17809
Signed-off-by: Rich Barlow <rich@bennellick.com>
The commit 1c7b668804 tried to fix
resending segments to the GATT bearer, however it got the buffer
refernce counting wrong. The bt_mesh_net_resend() function doesn't
own a reference to the buffer, i.e. it's not responsible for unrefing
it. E.g. bt_mesh_adv_send() takes its own reference.
What was missing however was the handling of the callbacks. Use the
recently introduced send_cb_finalize() helper to make sure they're
called.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There are several places that require the send callbacks to be called
immediately. Reduce the code a bit by introducing a helper for this.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The RPA timer should always be running, even with privacy supported by
the controller. In order to select an IRK to generate the private
the controller is instructed by provided an identity address.
If we want to advertise privately without providing an identity address
the host has to set the private address.
Fixes: #18150
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The Mesh Profile Specification states in section 3.10.5 IV Update
procedure: "The IV Update procedure is initiated by any node that is a
member of a primary subnet", meaning if we're not on the primary
subnet we should not try to initiate the procedure.
Additionally this fixes initiating IV Update in all cases where the
sequence is updated, by putting the code into bt_mesh_next_seq().
Fixes#17977
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This branch is inherited from old code that used to start the timer as
soon as a message was queued for transmission rather than when it was
actually transmitted (the case today). It'll also cause a race in case
the publication goes over the GATT layer since the "sent" callback
happens synchronously in that case.
Fixes#17821
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The GATT bearer is a reliable one so there should theoretically never
be a need to resend segments. If however for some strange reason the
proxy client doesn't immediately ack all segments we should do the
resending on the GATT bearer, rather than sending them over
advertising.
Fixes#17907
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The code was incorrectly bailing out with "return 0" rather than
continue. Also, it was incorrectly making a reference to
tx->seg[seg_o] since when a PDU goes through the friend queue we don't
use the usual retransmission mechanism.
Fixes: #17932
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In case a queued buffer is canceled before sending we have to unref
it, since that's what adv_send() would do as well.
Fixes#17936Fixes#18013
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Mesh Profile 3.6.7.2 Publishing Heartbeat messages:
"
Triggered publishing of Heartbeat messages is enabled by
the Heartbeat Publication Features state (see Section 4.2.17.5):
...
- If the Low Power bit is set to 1, a Heartbeat message shall be
published when the node establishes or loses Friendship (see Section
3.6.6.1).
"
Fixes#18194
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When sending heartbeat messages triggered by feature changes the code
was trying to look up the configured publication subnet, in an
apparent attempt to figure out if publication is enabled or not. A
more appropriate way is to check for the heartbeat publication
destination address, and since we have a helper function this can be
done in a single place.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The heartbeat is a transport layer feature, so move it to transport.c.
This also opens the way to properly fix Friendship-established/lost
triggering for LPN role.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
With CONFIG_LOG_IMMEDIATE, log output is printed immediately. If a
shell command is in progress, there's no prompt to erase, nor should
we print a new prompt after the log message is output.
Before this patch, a simple shell command like:
int cmd_log_erase(const struct shell *shell, size_t argc, char **argv)
{
LOG_INF("hello world");
return 0;
}
would output something like:
uart:~$ log erase
[00:00:02.623,718] <inf> cmd_log: hello world
uart:~$ loguart:~$
This patch fixes prompt handling while a command is active, and fixes
put_sync_hexdump to behave like put_sync_string.
Signed-off-by: Jim Paris <jim@jtan.com>
IPv4 connection management status is stored in wrong
variable. ip_state should hold the status and then
it should be stored in state variable.
Fixes#18253
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Fix missing interval min copy in bt_conn_set_param_le. Application is
unable to override BT_GAP_INIT_CONN_INT_MIN for interval_min.
Fixes: #17789
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Consistently place C++ use of extern "C" after all include directives,
within the negative branch of _ASMLANGUAGE if used.
Background from issue #17997:
Declarations that use C linkage should be placed within extern "C"
so the language linkage is correct when the header is included by
a C++ compiler.
Similarly #include directives should be outside the extern "C" to
ensure the language-specific default linkage is applied to any
declarations provided by the included header.
See: https://en.cppreference.com/w/cpp/language/language_linkage
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The callback might return more than length of data read.
It should return nothing more than read length requested.
Patch fixes this behavior.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Fix the pipeline prepare-resume implementation to correctly
handle multiple continuous events that request resume on
being pre-empted.
Symptoms of the bug being, when having continuous scanning,
and an active peripheral if a directed advertising is
started the peripheral event are not scheduled causing link
supervision timeout.
This is fixed by not having an enqueued resume event
prepared if there is an enqueued new non-resume event in the
pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Increase pipeline size to accommodate probable multiple
prepare for directed advertising events, with reserved time
which are shorter than prepare duration, being enqueued.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Increase the event start overhead time to accommodate for
processing time for dequeueing pipeline in Upper Link Layer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reduce the maximum number of pending event done elements by
decoupling it from the maximum pipeline elements.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When checking for total IP address counts, don't check
CONFIG_NET_IF_MAX_IPV6_COUNT twice. This was a typo for
CONFIG_NET_IF_MAX_IPV4_COUNT.
This was reported by IRC user: retfie
Signed-off-by: Michael Scott <mike@foundries.io>
This is safer now that bt_conn_create_pdu can return NULL when using
syswq which can prevent things like signalling of L2CAP and ATT layers.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Since TX complete notification are dispatched with syswq blocking on it
can completely deadlock Bluetooth so this attempt to make it safe by
return -ENOMEM if that the current thread happens to be the syswq
thread.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add shell commands to add and remove devices from the shell.
Add commands and options to use whitelist for advertising, scanning,
and creating connections.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add whitelist support in the bluetooth host.
Supported features:
- Advertising with whitelist on scan requests, connect request ,or both
- Scanning with whitelist
- Creating connections using a whitelist (Auto connection procedure).
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit enables the option to route the BusFault,
HardFault, and NMI exceptions in Secure state, when
building for Cortex-M CPUs with ARM_SECURE_FIRMWARE=y.
This allows the various test to utilize BusFault,
HardFault and NMI exceptions during testing.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit changes the Link-Layer Address Option length calculation
from hardcoded values to a numerical rounding up to full 8.
The length is calculated according to rfc4861 section 4.6.1.
Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
Allow Security level HIGH and FIPS to be initiated when we have received
OOB data for the remote device. The security property of MITM is allowed
if out of band authentication data is available.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update bluetooth help text to include FIPS level in help text.
Also validate input range for the different connection types
Bluetooth security level for LE is from 1-4, while BR/EDR is 0-3
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
If the UDP socket is connected, then allow the user to leave
out the remote address in msghdr struct.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Authentication using OOB data uses the on-air device addresses used
during connection setup. So we need to check against the on-air
addresses in the info object to see if we have correct OOB data.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix issue with registering authentication callback handlers failing
without notifying the user of the shell.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use the src and dst naming to refer to the identity addresses of the
connection. Keep the device addresses used during connections but rename
them to local and remote instead.
Update documentation to be more descriptive.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
- Commands were not gathered with the right macro
- bus fault access due to wrong declaration of iface_states external
variable.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
The network to host byte order conversion is actually in place
on the network buffer. This prevents the reuse and forwarding of
RA packets. This commit uses temporary variables instead.
Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
This commit adds support for a 6LoCAN Ethernet border translator.
CAN frames with the translator CAN address are translated and forwarded
to Ethernet. Ethernet frames with the first 34 bits matching the MAC
address of the translator are translated and forwarded to 6LoCAN.
Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
Take the targer link layer address option link laxer addres lenght
from net packets source addres instead if the interface.
This is usefull for 6LoCAN border translator (6LoCAN to Ethernet).
Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
This commit implements net_pkt_shallow_clone. A shallow clone clones
the net_pkt but not the buffers. The buffers are only referenced and
therefor only freed when both copies of the net_pkt are freed.
Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
This commits adds support for reception of packets thats comes from
a Ethernet to 6LoCAN translator. This packets carry the Ethernet
MAC address (6 bytes) inline in the FF (First Frame).
Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
This commit is an implementation of 6LoCAN, a 6Lo adaption layer for
Controller Area Networks. 6LoCAN is not yet standardised.
Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
Rename the socket_can implementation from CANBUS to CANBUS_RAW.
This is a preperation for 6LoCAN which is a CANBUS L2 for IPv6.
Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
subsys/bluetooth/host/Kconfig.gatt is already sourced within an
'if BT_CONN' in subsys/bluetooth/host/Kconfig.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Fix the mandatory and optional parameter counts for the
directed adv shell command definition. Also, refactor the
command for consistency.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
No need to write deletion entry for non-existing entry.
Furthermore such a write to filled up storage will make another
writes impossible as it occupied delete nvs_ate space, but it
does not remove anything.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
During initialization NVS analyzes open sector for
find write addresses. It was possible to infinite loop
in case when there was no space for any new ATE in the sector.
This patch introduce check for space available in the sector which
fix the issue.
fixes#17891
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
NVS always leave space for deletion ate in a full sector.
Even that it was not possible to write delete nvs_ate to the
full sector. Because of that it was possible to fill up NVS,
and be able to delete nothing.
This patch introduce recognition of case
the delete ate is writing, and allow to write such nvs_ate to
opened full sector.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
If sendmsg() is used for TCP sockets, the msghdr->msg_name is not
really used as the socket must already have been connected.
In that case just get the destination address directly from
net_context remote address field.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Fix assert in the RPA timeout when no resolving entry exists in the
resolving list, and the advertiser was requested to use a local IRK
to generate it's own address.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
If no callback for oob data request is registered, or the user decided
to abort authentication during OOB data request, we should return the
error code for no OOB data available to indicate that the user does not
have the correct OOB, or no OOB interface at all.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix kernel crash if bluetooth authentication handlers has not been
registered. The bt_auth object is then NULL, this dereference caused a
call to an invalid function pointer.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Previous ATE searching is accelerate by reading sector
close ate, which allow to skip reading whole storage.
ATE is already covered by crc8. That patch introduce
check on correctness offset read form close ate. This
increases meta-data integrity check level.
This also preserves against possible looping when read
incorrect or not a NVS storage image.
fixes#16899
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
The code was already rejecting the key, however that rejection
happened only after we had already sent our public key as response,
which got interpreted as acceptance by the tester (PTS).
This fixes issue that d4fd267086a56c270a793114e7575afae9a9befa
supposed to fix. The problem is bt_dh_key_gen is async.
Local public key cannot be sent from the same context
the bt_dh_key_gen is called because we don't know yet
if remote key is valid.
Fixes MESH/NODE/PROV/BI-13-C.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Fixed error 'The int symbol BT_DISCARDABLE_BUF_COUNT is being evaluated
in a logical context somewhere'.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
subsys/bluetooth/host/Kconfig.l2cap is already sourced within an
'if BT_CONN' in subsys/bluetooth/host/Kconfig, so BT_DEBUG_L2CAP does
not need a 'depends on BT_CONN'.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Find by type does only accept a UUID with the same length as the UUID
which is stored in the internal list. If a UUID is stored in the short
16 bit format then a request with 128 bit UUID will fail.
Add support for the missing formats.
Signed-off-by: Kim Sekkelund <ksek@oticon.com>
Changed ticker behavior to resolve conflicts in ticker_worker instead of
in ticker_job. This allows better real-time slot allocation, as well as
allowing callbacks even if ticker node doesn't get air-time (for audio
stream housekeeping). A priority property now also allows prioritizing
one ticker node over others.
Compatibility mode enables lagacy ticker behavior if needed.
Signed-off-by: Morten Priess <mtpr@oticon.com>
DISK_SDHC_VOLUME_NAME is already defined within an 'if DISK_ACCESS_SDHC'
block, so the 'depends on DISK_ACCESS' is redundant.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Fix an issue in the SMP identity distribution where the IRK for the
default identity was always distributed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
There's desire to be able to customize parameters on a per-filesystem
basis, which means we need a way to override the Kconfig defaults which
are global. This also means the littlefs data structure cannot own the
cache and lookahead buffers.
Switch to using a macro to define the littlefs data structure. The
default version uses the Kconfig constants. A custom one takes
arguments providing the most likely partition-specific parameters.
Finally the user is free to bypass the helper macros and set any
parameters desired, though validation is limited and only present when
CONFIG_DEBUG is enabled.
Extend the test suite with a performance module, which confirms that
these settings have an impact proportional to the log of changes to the
cache or IO sizes.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Existing file system implementations do not provide the special "."
(current) and ".." (parent) directory entries in the readdir results.
littlefs does.
Remove these entries in the abstraction layer. This simplifies code in
higher level consumers that aren't prepared to see them. Consumers like
FUSE that need them can put them back without having to worry about
conflicts.
Closes issue #17951
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
The previous way of creating an absolute path relied on snprintf(), and
when used with newlib gcc warned that the output could be truncated
before the last format character. Rework to use code that doesn't rely
on snprintf.
See discussion at https://bugzilla.redhat.com/show_bug.cgi?id=1431678
Also ensure that cwd is always NUL-terminated, and use the utility
function to create the absolute path in cmd_trunc.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Add support for the littlefs file system in the fs shell. Update
the sample to use the same partition configuration as the littlefs
example for the SPI NOR test platform.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
littlefs is a fail-safe filesystem from ARM Mbed that has wear-leveling
capabilities.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Signed-off-by: Jim Paris <jim@bolt.io>
Before calling socket callback function, make sure the callback
function exists so that we do not get NULL pointer reference.
Fixes#18021
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Fix an issue with enhanced connection complete event raised by the
advertiser role. The advertiser reported that it has resolved the
the identity address of the peer, even when the peer is connecting
using it's identity address.
The host will not have the correct on-air address type i.e public.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix bug introduced by: 45da629b24
Mistakenly set the own address type to the destination address type.
Also this uses the RPA_OR_RANDOM in case local IRKs exists in the
controller.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This is related to findings in #17997 and changes network related
header files to have include files outside of extern "C" { } block.
Declarations that use C linkage should be placed within extern "C"
so the language linkage is correct when the header is included by
a C++ compiler.
Similarly #include directives should be outside the extern "C" to
ensure the language-specific default linkage is applied to any
declarations provided by the included header.
See: https://en.cppreference.com/w/cpp/language/language_linkage
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The 'registered' flag was not cleared when 'gatt metrics off'
was called so that one was unable to register the service again.
Remove 'registered' variable that is actually not needed as there
is no tracking if service is already registered in similar
cmd_register_test_svc command. If the service is already registered,
the host will log an error.
Fixes: #17882
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The sector size is 0 will pass "fs->sector_size % info.size" then start
a loop in nvs_startup() and never return. So retrun an error if the
sector size is 0.
Signed-off-by: Harry Jiang <explora26@gmail.com>
Current SOCKS5 based connections in mqtt are only
TCP (nonsecure) based. To support TLS based SOCKS5
connections, new methods needs to be introduced.
Instead, removed CONFIG_MQTT_LIB_SOCKS based implementation.
And now mqtt provides an api to set proxy
(mqtt_client_set_proxy()) details. That's enough,
socket layer will take care of making connections through
proxy server.
Fixes: #17037
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Current SOCKS5 implementation is above socket level and every
higher layer protocol or application level needs to have
SOCKS5 related changes. This solution is based on socket
setsockopt(). Application caller has to set proxy details
through setsockopt() and socket:connect() will take care
creating connection.
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
The SO_SOCKS5 socket option can be used by the application to
set the SOCKS5 proxy details. These details will be used when
connecting to peer.
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
The init addr should contain the on-air address used to establish the
connection. The dst address contains either the current RPA of the
unknown peer, or the identity address after identity information has
been exchanged.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Error codes are listed in header files and in the core spec as hex
values. Always print them in hex in debug for easier error code
checking.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix an issue where the generated identity was not permanently stored.
This resulted in being unable to reconnect after bonding when using
privacy, since a new local IRK was generated on reboot.
When settings is enabled the application is responsible for loading
identities and possible creating its own identities.
When settings_load is called and no identities has been created or found
in persistent storage a new identity will be created.
Since bt init has not been finalized bt_id_create will not make a call
to bt_settings_save_id. So we need to make sure that this identity will
be stored.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
With the upcoming riscv64 support, it is best to use "riscv" as the
subdirectory name and common symbols as riscv32 and riscv64 support
code is almost identical. Then later decide whether 32-bit or 64-bit
compilation is wanted.
Redirects for the web documentation are also included.
Then zephyrbot complained about this:
"
New files added that are not covered in CODEOWNERS:
dts/riscv/microsemi-miv.dtsi
dts/riscv/riscv32-fe310.dtsi
Please add one or more entries in the CODEOWNERS file to cover
those files
"
So I assigned them to those who created them. Feel free to readjust
as necessary.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Several problems with memset usage in the LwM2M subsystem were
identified:
- Every single object that can have multiple instances is using
memset to initialize static resource data during init. This data
will already be set to 0 because it is static, so the memset
statements are unneeded.
- Instead of using memset during object init which is only called
one time during kernel startup, let's add a memset to the
object create function to ensure the resource data is cleared out.
It could have been used prior and then released via a DELETE op.
- the IPSO Timer object was setting a lot of data structure members
to 0 in the create function. Let's do 1 memset on the entire
structure and then only the non-zero values afterward.
Signed-off-by: Michael Scott <mike@foundries.io>
When presenting errors in lwm2m_engine_set() let's include the related
LwM2M path for easier debugging.
Signed-off-by: Michael Scott <mike@foundries.io>
This core LwM2M Object enables monitoring of parameters related to
network connectivity.
This is only the basic object structure. More work will be needed
to set the various resources based on connectivity.
Signed-off-by: Michael Scott <mike@foundries.io>
This Object is used to report the state of a momentary action push
button control and to count the number of times the control has
been operated since the last observation.
Signed-off-by: Michael Scott <mike@foundries.io>
LwM2M allows for multiple instance resources such the power source
resources in the device object. These types of resources have
always been very hard to work with, and frankly were poorly
implemented.
This led to other issues where it was very hard to have
non-sequential resource instances, and each resource of this type
needed special getter / setter methods such as:
lwm2m_device_add_pwrsrc()
lwm2m_device_set_pwrsrc_voltage_mv()
Going forward, as more LwM2M objects are implemented this just
doesn't scale well.
To fix this:
- split the resource instance data out from the resource data.
This includes the data pointer information and resource
instance id.
- add resource id and resource instance id to the event callback
functions so user's can see in more detail what resources and
resource instances are being handled.
- allow generic functions like lwm2m_engine_get_*() and
lwm2m_engine_set_*() to access resource instance data.
- adjust object resource initialization macros to map resource
instances to resources at the time of object instance
creation.
- fix up the lwm2m_client as a reflection of all of these changes.
Signed-off-by: Michael Scott <mike@foundries.io>
Due to work combining data into the lwm2m_message structure, we no
longer need to pass the lwm2m_engine_obj parameter between
formatters and most of the operation handlers.
So, let's remove it.
Signed-off-by: Michael Scott <mike@foundries.io>
The multi_max_count is no longer used and can be removed from the
obj_field structure if we change all of the OBJ_FIELD() macros to
use OBJ_FIELD_DATA() instead.
Technically, OBJ_FIELD() and OBJ_FIELD_DATA() are now the same, but
we're keeping them both for the time being. In the future, more
fields may be added to the obj_field structure and we can use the
OBJ_FIELD() macro again if that's the case.
Signed-off-by: Michael Scott <mike@foundries.io>
- Several of the functions use "path" as the parameter name for the
string-based LwM2M path. Let's clarify by using "pathstr".
- Recent updates to the LwM2M engine now support resource instances
when parsing the LwM2M path. Let's update descriptions accordingly.
Signed-off-by: Michael Scott <mike@foundries.io>
Per IPSO Light Control definition from the OMA LwM2M registry:
http://www.openmobilealliance.org/tech/profiles/lwm2m/3311.xml
There is an optional "Application Type" string resource (5750) in the
Light Control object. This was missed in the initial implementation.
NOTE: sample will assign reference if needed.
Signed-off-by: Michael Scott <mike@foundries.io>
We are pre-allocating a storage variable for the application type
resource in the IPSO Timer object. This is an optional resource
which won't always be set by samples.
Let's leave out the pre-allocated variable and let the sample set
this reference if needed (it's optional).
Signed-off-by: Michael Scott <mike@foundries.io>
Server records contain the default PMIN and PMAX settings for how
often we can send observe notifications. We are currently using
arbitrary defaults which cannot be changed when compiled or
during runtime.
Let's add Kconfig settings for the default settings to use and
also lookup the current values in the active server record when
an observe is added.
The actual PMIN/PMAX values can still be set via WRITE_ATTRIBUTE
operation.
Signed-off-by: Michael Scott <mike@foundries.io>
The sdhc_cmd_r1_raw() function doesn't take into account the existence
of commands with data response. Because of this, some datas were being
lost.
The commands that return a r1 response and a data are: SDHC_SEND_CSD,
SDHC_SEND_CID, SDHC_READ_SINGLE_BLOCK, SDHC_READ_MULTIPLE_BLOCK,
SDHC_WRITE_BLOCK, SDHC_WRITE_MULTIPLE_BLOCK.
In order to solve this, was juts necessary skip the byte discard when
the command is one of these.
This problem was affecting, for example, the sdhc initialization. The
token returned from SDHC_SEND_CSD was being lost and the initialization
was broken.
Fixes#15444.
Signed-off-by: Lucas Peixoto <lucaspeixotoac@gmail.com>
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Apparently, settings were relying on other headers
including kernel.h, once that include got removed from the
logger header samples fail to compile.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Cleaning up log.h include dependencies to allow log.h including in base
headers (e.g. kernel.h).
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Logging module requires strings to be duplicated using log_strdup.
Enabling CONFIG_BT_DEBUG_KEYS caused runtime assertions in the logging
module.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Core 5.1, Vol 3, Part F, 3.3.1
"Multi-octet fields within the GATT profile shall be sent least
significant octet first (little-endian) with the exception of the
Characteristic Value field. The Characteristic Value and any fields
within it shall be little-endian unless otherwise defined in the
specification which defines the characteristic."
Fixes: GATT/SR/GAS/BV-02-C
Fixes: #17857
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Changes related to Bluetooth TSE 11068.
This is done because the current test suite does not issue
an LE Enable Address Resolution command anymore in RPA
generation tests. Makes sense now that the Bluetooth SIG has
agreed to completely decouple address resolution from
generation.
Fixes BT LL TS 5.1.0 test:
LL/SEC/ADV/BV-03-C [Privacy - Non-connectable Undirected
Advertising, Resolvable Private Address]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The call to bt_conn_security will send a SMP security request for
peripheral, and for central it will initiate LL encryption.
A call to bt_conn_security with no IO capabilities but authenticated
keys has been distributed, would succeed on central side, but fail on
peripheral side with error code -22.
The keys could have been either:
- Preprogrammed
- IO capabilities may have changed.
- OOB bonding may been used.
Fix so that Peripheral can send a security request if the bond
information is already established.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The content of subsys/fb/cfb_fonts cannot be replicated by the existing
script due to lack of positioning options and use of a full-color frame
buffer, which affects the generated bitmap. Switch to the solution used
in the original script, add the required options, and document the
process of regenerating the fonts.
This commit also determines the required bounding box for the glyphs to
be sure that the user-provided value is sufficient to avoid partial
characters. Ideally the calculated width and height would be used for
font characters, but this would require significant restructuring of the
script to make calculated values available at the point where the
arguments are used to produce output.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
The specified order of fields wastes space when the cfb_font_caps enum
isn't packed. Reorder to avoid this behavior.
Also remove the unnecessary array size on the extern symbol declaration,
lest the compiler misinterpret the properties as being zero-length
arrays rather than pointers. (The idiom is already technically
using undefined behavior since we're relying on the linker rather than
the language to produce an array from the individual declarations.)
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
The original creates a pointer to a compiler-generated temporary that is
destroyed when the scope is exited. The pointer is stored in a structure
defined in an enclosing scope and is invalid by the point it's used.
The fix holds the structure in a variable with the same lifetime as
the pointer.
Signed-off-by: Findlay Feng <i@fengch.me>
Fix the pipeline prepare or resume dequeue loop from
overflow. Fixes premature exit of dequeue of done FIFO
which caused the pipeline to overflow due to previously
placed done is not dequeued correctly and next event not
being put back into the pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Currently the retransmit_work is not cancelled when closing a context,
making it operate on an invalid context.
LwM2M RD client also closes the context and initializes it again when
registration with the server fails, overwriting the active timeout and
breaking the timeout dlist.
Signed-off-by: Pieterjan Camerlynck <pieterjan.camerlynck@gmail.com>
This introduces a new flag (BT_GATT_SUBSCRIBE_WRITE_PENDING) which is
set when a write operation requires canceling before the parameters can
be reused.
Fixes#17534
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds a dummy cancel request which is used instead of NULL when
clearing and outstanding request thus prevent new request to take
place before a response is received while allowing the original request
to be reused.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
mcumgr is missing dependency on net_buf, which is used for SMP protocol
implementation. This causes build failure in case when only SMP over
shell is selected (CONFIG_MCUMGR_SMP_SHELL=y).
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
flash_img subsystem writes data to flash only when the amount of data to
be written is larger than available buffer space. This commit modifies
this behavior to write data to flash as soon as the buffer is full.
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
base64_decode requires 'size_t *olen', but '*int' was passed
instead. This caused a -Wincompatible-pointer-types "note: expected
'size_t *' {aka 'long unsigned int *'} but argument is of type 'int *'"
warning in qemu_x86 build. Fix that by using correct variable type.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
We must discard the received Discard-Request silently.
See RFC 1661 chapter 5.9 for details.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Currently only net-shell calls net_ppp_ping() command, so make
it return the amount of time that it took to receive Echo-Reply
so the net-shell can print the round trip time value.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If the network interface is point-to-point one which does
not need IP address etc, then no need to start DAD etc for
those interfaces.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If we receive a protocol that we do not currently handle, then
return Protocol-Reject to peer.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
By default PPP is started immediately when the network interface
goes up. This can be problematic especially when debugging the beast
so allow user to delay the startup.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This will list all mount points in response to opendir("/").
This isn't perfect; mount points in subdirectories will show up as
their full path in this listing. But it's better than just returning
-EINVAL.
Signed-off-by: Jim Paris <jim@jtan.com>
This is now called z_arch_esf_t, conforming to our naming
convention.
This needs to remain a typedef due to how our offset generation
header mechanism works.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
* z_NanoFatalErrorHandler() is now moved to common kernel code
and renamed z_fatal_error(). Arches dump arch-specific info
before calling.
* z_SysFatalErrorHandler() is now moved to common kernel code
and renamed k_sys_fatal_error_handler(). It is now much simpler;
the default policy is simply to lock interrupts and halt the system.
If an implementation of this function returns, then the currently
running thread is aborted.
* New arch-specific APIs introduced:
- z_arch_system_halt() simply powers off or halts the system.
* We now have a standard set of fatal exception reason codes,
namespaced under K_ERR_*
* CONFIG_SIMPLE_FATAL_ERROR_HANDLER deleted
* LOG_PANIC() calls moved to k_sys_fatal_error_handler()
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This patch tries to avoid memmoves and buffer allocations when there
is enough space in the original buffer. Headers are still contiguous
but not in the same buffer.
Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
This is a rework of the 6lo IPHC uncompression.
The uncompression now tries to work in place on the original buffer
instead of allocation a new one. If there is not enough tail-room,
a new buffer is allocated and filled with the IP and maybe UDP header.
The compressed header is pulled from the original buffer and the
buffer is preserved.
Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
When net_pkt_skip skips the entire data in a net buffer, the cursor
still points to this buffer on data that is off by one.
Calling pkt_cursor_advance in net_pkt_is_contiguous fixes this and
moves the cursor to the next buffer.
Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
This is a rework of the 6lo IPHC. The compression now works inline
on the original buffer instead of allocation a new one.
Additionally DAM_11 (Destination address fully elided) has precedence
over DAM_10 (16 bit compressible) now.
Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
Move CMake ExternalProject integration of OpenThread to the
CMakeLists.txt file within the OpenThread fork.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If the flash device is not configured, return an error rather than
dereferencing a null device pointer.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
This commit adds the kernel.h include in order to provide
sys_clock_hw_cycles_per_sec() declaration.
Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
The log_backend_swo used system clock frequency
as a base for SWO clock calculation. This commit
corrects that by obtaining the needed value from DTS.
Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
On some SoCs the frequency of the system clock is obtained at run time
as the exact configuration of the hardware is not known at compile time.
On such platforms using CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC define
directly introduces timing errors.
This commit replaces CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC by the call
to inline function sys_clock_hw_cycles_per_sec() which always returns
correct frequency of the system clock.
Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
On some SoCs the frequency of the system clock is obtained at run time
as the exact configuration of the hardware is not known at compile time.
On such platforms using CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC define
directly introduces timing errors.
This commit replaces CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC by the call
to inline function sys_clock_hw_cycles_per_sec() which always returns
correct frequency of the system clock.
Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
The SO_TXTIME socket option can be used by the application to
tell the network device driver the exact moment when the
network packet should be sent.
This feature is also implemented in Linux.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Add BSD socket sendmsg() API that can be used to send data to peer
and also pass ancillary data to lower level of the network stack.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
User could have set something to optval in getsockopt() and we
need to copy the data to kernel optval so that the socket family
code can use the value for something.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If the allocated net_pkt is larger than the network interface MTU,
then check if the IPv6 fragmentation is enabled and allow larger
net_pkt length as the IPv6 fragmentation will split the packet into
suitable parts.
Fixes#16354
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The net_pkt_pull() needs to move all the remaining data in the
net_buf instead of just the pull amount.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Set advertisers state flags so that previous advertise params does not
affect the current advertiser state.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Enable use of settings system in controller and introduce settings for
company_id and subversion_number.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Make the Upper and Lower Link Layer split architecture
implementation of the controller as the default when
building Zephyr Bluetooth Low Energy controller support
in applications.
Noticeable missing feature (porting) in comparison to old
architecture implementation is, Advanced scheduling of
connection events.
The missing features will subsequently be submitted
upstream.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Rename the controller Kconfig option BT_LL_SW to
BT_LL_SW_LEGACY in preparation towards switch to new Link
Layer implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
File system API functions that operate on paths are passed both the
absolute path including the mount point prefix, and the mount point
within which the path lies.
Unfortunately it's not entirely trivial to convert an arbitrary path
within the file system space to an absolute path within its mount point,
because the path may be to the mount point itself and not end with a
directory separator. The effect is that a file system implementation
like nffs may be given an empty path when "/" is required.
Add an implementation module that does this transformation and use it to
transform paths within each filesystem wrapper.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Conditional compile the use of Rx Pool used to dispatch ULL
context generated messages towards LL thread context, which
is presently only used in connections.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Certain Thread implementations (notably ARMs) require a DHCPv6
implementation.
Allow the usage of the relevant OpenThread configuration parameters in
Zephyr.
Signed-off-by: Markus Becker <markus.becker@tridonic.com>
Simple backends, like UART or RTT, implementation is very similar.
Header has functions which can be reused by simple backends and
remove redundant code.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Fix the conditional compile of Data Length Update event
generation on PHY Update Procedure when Data Length
Extensions are not supported.
The regression was introduced in
commit 70a89876d0 ("Bluetooth: controller: Fix missing
data length update event")
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added a fix to handle L2CAP start frame with payload length
of zero which otherwise sent zero length data start PDU on
air.
Relates to #17046.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixed a bug related to missing reset of packet timing
restriction variable.
Fixes BT LL TS 5.1.0 test:
LL/CON/SLA/BV-55-C [Initiating PHY Update Procedure - Packet
Time Restrictions, LE Coded]
Related to #17097.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix bug in Data Length Update procedure that caused the
connection to drop due to the implementation sending bigger
PDU before the peer has acknowledged the receipt of Length
Response PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Enable the Fast Encryption design and connection RSSI
measurement when CONFIG_BT_HCI_RAW is selected.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the controller implementation to perform connection
event length reservation based on the completed Data Length
Update and/or PHY Update Procedure.
This fix with avoid states/roles from stepping on each
others event length. Connection would have supervision timed
out or have stalled data transmissions due to insufficient
reserved air time.
Relates to #15171.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing generation of data length update HCI event when
effective tx and rx timings change due to PHY update
procedure.
Fixes BT LL TS 5.1.0 test:
LL/CON/MAS/BV-52-C [Master Receiving Data, LE Coded, CI
Change]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Bluetooth address parsing has been duplicated across the different
sub-shell files. Also missing parsing of identity/resolved addresses.
Move parsing of string close to parsing to string for a symmetrical API
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Move duplicate hex2bin and add bin2hex function so that application can
use the functions and avoid code duplication.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the implementation of initiator to use correct anchor
tick and remainder microseconds when sending out CONNECT_REQ
PDU and then to scheduling the first connection event. This
is a fix when initiator is in continuous scan.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The bt clear command accepts either 'all' or a bluetooth address.
If it is an LE address then type is also needed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix bug in the ported code of the connection update, when
the slave events are skipped due to other overlapping state
or role the connection update at the instant used wrong
latency calculations. This lead to connection disconnection.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Submit GATT database hash as a delayed work to prevent it being run
twice if we register dynamic services.
Signed-off-by: François Delawarde <fnde@oticon.com>
It currently only listens to relevant events about network interface to
decide whether raising connected or disconnected event.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
The size_t type is either compatible with an int on 32-bit target, or
a long on 64-bit targets. It could even be a long even on some 32-bit
targets. Let's use the z qualifier in the printf format to be compatible
with whatever flavor in use.
In case of pointers, let's just use %p with pointers directly and
avoid casts altogether.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Having this option disabled, MITM flag state can be controlled by
bt_conn_security state. This option is enabled by default to not
change the current implementation behavior.
Related to SM/MAS/SCPK/BV-01-C.
Fixes#17463
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This commit moves the BLE GATT heart rate service from
samples/bluetooth/gatt to subsys/bluetooth/services and adds a Kconfig
entry to enable and configure the service.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit moves the BLE GATT Battery service
from /samples/bluetooth/gatt to /subsys/bluetooth/services and
adds a Kconfig entry to enable and configure the service;
when enabled, it will register itself automatically.
Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Current implementation of LwM2M engine doesn't allow users a way
of overriding TLS credential load with custom function. This
would be needed by an offloaded TLS stack where we don't want
to use standard Zephyr functions.
Let's add a load_credential function pointer to the LwM2M client
context which will be called when it's available.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/17408
Signed-off-by: Michael Scott <mike@foundries.io>
The name disk_access_sdhc.c is ambiguous,
actually this driver depends on SPI,
rename this file.
In addition, move the generic sdhc stuff from C file
to head file for other sdhc drivers to use.
1) disk_access_sdhc.c->disk_access_spi_sdhc.c.
2) create .h and move sdhc specifications from .c to .h.
Signed-off-by: Jun Yang <jun.yang@nxp.com>
Handle optional argument UUID in bt_gatt_discover with type
DISCOVER_DESCRIPTOR, bt_uuid_cmp doesn't check for NULL pointer.
On system with MMU (nrf52_bsim) this can result in segfault.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Let's remove depends on NET_LLDP from all the options. It avoids this:
# CONFIG_NET_LLDP is not set
# CONFIG_NET_LLDP_LOG_LEVEL_OFF is not set
# CONFIG_NET_LLDP_LOG_LEVEL_ERR is not set
# CONFIG_NET_LLDP_LOG_LEVEL_WRN is not set
# CONFIG_NET_LLDP_LOG_LEVEL_INF is not set
# CONFIG_NET_LLDP_LOG_LEVEL_DBG is not set
CONFIG_NET_LLDP_LOG_LEVEL_DEFAULT=y
CONFIG_NET_LLDP_LOG_LEVEL=3
CONFIG_NET_LLDP_CHASSIS_ID="CHASSIS_ID_PLACEHOLDER"
CONFIG_NET_LLDP_PORT_ID="PORT_ID_PLACEHOLDER"
And instead it will generate this:
# CONFIG_NET_LLDP is not set
Make the menu as an enablement config option as well.
Adapting lldp header file relevantly.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
ARP, LLDP and GPTP functions have dummies in case of being disabled so
let's use IS_ENABLED() accordingly.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Fix assert in controller checking ticker_id_prepare = 0 when
a scanner and connection are active, and the connection is
skipping events in order to resize Rx buffers.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the reset of ticker_id_prepare variable to the early
return in event_connection_prepare function.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If we receive IPv6 packet where source address is unspecified
(all zeros), then we need to drop it.
Fixes#17450
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
We've already got GATT services in subsys/bluetooth/services so
subsys/bluetooth/mesh is a more natural place. Aditionally this aims
to fix the Kconfig dependencies to be able to use mesh together with
BT_CUSTOM (i.e. a custom, potentially non-HCI, host stack).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When performing OTA using the LwM2M subsys, several logging errors
regarding log_strdup were noted. Let's fix these.
Signed-off-by: Michael Scott <mike@foundries.io>
If a sample wants to use the Zephyr implementation of mbedtls, it
enables CONFIG_MBEDTLS and sets any needed Zephyr-specific mbedtls
options.
Currently, the LwM2M subsystem selects MBEDTLS automatically when
LWM2M_DTLS_SUPPORT is enabled. Let's remove this and let the
LwM2M client sample enable mbedtls and it's options.
This mimics the behavior of several other network-related samples
and removes conflicts when selecting alternate implementations of
MBEDTLS.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/17399
Signed-off-by: Michael Scott <mike@foundries.io>
CONFIG_NET_IPV* checks are not needed in lwm2m_parse_peerinfo().
The functions used are always available. Worse, having these checks
forces the need to enable CONFIG_NET_IPV4 or IPV6 when it's not really
needed (LwM2M could be using an offloaded IP stack).
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/17401
Signed-off-by: Michael Scott <mike@foundries.io>
CONFIG_NET_IPV* checks are not needed in lwm2m_sprint_ip_addr(). The
functions used are always available. Worse, having these checks
forces the need to enable CONFIG_NET_IPV4 or IPV6 when it's not really
needed (LwM2M could be using an offloaded IP stack).
NOTE: Also fixes an issue where a NULL is returned when the IP address
is unknown. This usually ends up with a crash/abort in the logging
code.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/17401
Signed-off-by: Michael Scott <mike@foundries.io>
If we receive IPv4 packet where source address is unspecified
(all zeros), then we need to drop it.
Fixes#17427
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If DNS server(s) are added or removed e.g., as part of DHCP
processing, send newly defined net-mgmt events so that
a user application may get this information.
Fixes#16924
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Removing an IPv4 router was missing, as well as finding the default
router for an IPv4 address.
Note howevere that IPv4 router features are not used anywhere yet. But
at least the API is there and is a 1:1 to IPv6, if that matters.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
- router lifetime is always a u16_t so fixing
net_if_ipv6_router_update_lifetime() signature.
- Coalescing router timers into one: this reduces the net_if_router
structure by 22 bytes
- refactor IPv6 and IPv4 router code so it's handled in generic
functions, to avoid duplicating 90% of the code for each family. This
also fixes the lifetime support for IPv4 which was missing.
Note however that IPv4 routing support seems to be missing as none of
the relevant functions are used anywhere yet.
Fixes#8728
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This reduces the size of struct net_if_ipv6 by 24 bytes by moving
the k_delayed_work attribute into net_if core code.
Then each net_if_ipv6 can be added to the timer handler via a slist.
This does not make much gain if the system has only 1 network interface
It starts to be interesting if it has 2+ network interfaces then.
Fixes#8728
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This reduces the size of struct net_if_addr by 24 bytes by moving
the k_delayed_work attribute into net_if core code.
Then each net_if_addr can be added to the timer handler via a slist.
This does not make much gain if the system has only 1 unicast IPv6
address. It's a nice memory improvment once it has 2+ unicast IPv6
address. Note that having IPv4 enabled along with IPv6 will also see
memory improvements since both IPv6 and IPv4 use the same struct
net_if_addr.
Fixes#8728
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Let's regroup all the IPv4 related function into one ifdef. There is no
need to implement a dummy function for each: if IPv4 is not enabled,
these functions are unused in the core.
Fixes#8728
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Let's regroup all the IPv6 related function into one ifdef. There is no
need to implement a dummy function for each: if IPv6 is not enabled,
these functions are unused in the core.
Fixes#8728
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Logger had false assumption that once log_panic is called then
context switch will never occur and was not protecting against
reentrancy in panic mode. Added interrupt locking when accessing
unprotected part.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The function sys_trace_thread_switched_out asserts in case
sys_trace_thread_switched_in was not called first. This is unintended
as tracing.h describes that out should be called before in, thus the
reverse of what the assert expects.
Fix assert on initial thread switch in, where out is called with
current_thread being NULL.
Signed-off-by: Danny Oerndrup <daor@demant.com>
The hostname needs to have log_strdup() when printing it.
Also it is useful to print information if the sending fails.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
- answer offset was 1 byte off.
- request offset, when copied into the answer, was off as well.
Fixes#16142
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Skip the TCP options before giving the data to application.
Without this, the TCP options would be passed to the application.
Fixes#17055
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Fixes -Werror=format: '%x' expects argument of type 'unsigned int', but
argument N has type 'long unsigned int'
Reproduced with sanitycheck -p bl652_dvk (or -p any other
HAS_SEGGER_RTT) and by adding CONFIG_SEGGER_SYSTEMVIEW=y to
samples/philosophers/prj.conf. sanitycheck adds -Werror.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Two sections are needed: bt_l2cap_fixed_chan and bt_l2cap_br_fixed_chan.
However the second one cannot be created using #define as the
preprocessor will expand it to the first before compilation happens,
sending bt_l2cap_br_fixed_chan instances in the wrong section.
This fixes commit 4e8ddfd640 ("Bluetooth: L2CAP: Make use of
Z_STRUCT_SECTION_ITERABLE").
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
The handcrafted allocation falls victim of misaligned structures due to
toolchain padding which crashes the socket test code on 64-bit targets.
Let's move it to the iterable section utility where those issues are
already taken care of.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Port the implementation that does radio event abort due to
ISR latencies. The implementation measures if the ISR could
not meet the hard real time deadline and closes the event
early.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added interface to get Advertiser and Scanner instance
handle for use in Lower Link Layer module.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
OpenThread did not verify if the interface provided in the net_mgmt
handler is actually an OpenThread interface. In result, when multiple
network interfaces were used, different interfaces were processed by the
OpenThread handler, ending up in a crash.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Make sure the IPv4 and IPv6 socket addresses are initialized before
copying them. This avoids uninitialized memory access.
Coverity-CID: 199436
Fixes#17202
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This can be used to activate the network packet statistics
collection. Note that we do not have resources to calculate
each network packet transit times but we collect average times
instead.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Finalize the CONFIG_NET_CONTEXT_TIMESTAMP support that was started
earlier but never properly finished. We collect network statistics for
TX packet network stack throughput time from when the net_context_send
is called and when the net_pkt was sent out successfully by the network
device driver.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Fix an issue in the gatt_register routine where removing a service and
adding it again would cause the database to have non-ascending
orderdered handles numbers and lead to an incomplete service discovery.
Fix: Go through the database and look for a place where to insert
the new service.
Signed-off-by: Arthur Crepin-Leblond <arthur.crepin@proglove.de>
Renames the "Blueooth Controller Assertion Handler" to "Application
Defined Assertion Handler" to better fit the purpose of the Kconfig
option.
Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
Currently only setting and getting of Ethernet Qav options are
supported via this interface.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If the net_mgmt event has some info, like IP address, that
could be sent, then send it the same time. This is very useful
for the receiver of the event in order to know that is happening
in the system.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Allow application to listen network management events using
BSD socket API. Application needs to create the socket using
AF_NET_MGMT address family. At this point we only support
receiving network management events that the network subsystem
is sending.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The info parameter is difficult to use if the caller does not
get information how long the info struct is. So add info_length
parameter to net_mgmt_event_wait_on_iface() and
net_mgmt_event_wait() APIs.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Introduce a separate buffer pool for events which the HCI driver
considers discardable. Examples of such events could be e.g.
Advertising Reports. The benefit of having such a pool means that the
if there is a heavy inflow of such events it will not cause the
allocation for other critical events to block and may even eliminate
deadlocks in some cases.
Also update all mesh samples not to specify explicit RX buffer counts
anymore. Instead, create appropriate defaults in Kconfig so that we
only need to override this in the app for cases like the bbc:microbit
with limited memory.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This event is a priority one, so it's not safe to have it use the RX
buffer pool which may be depleted due to non-priority events (e.g.
advertising events). Since the event is consumed synchronously it's
safe to have a single-buffer pool for it. Also introduce a new
bt_buf_get_evt() API for HCI drivers to simplify the driver-side code,
this effectively also deprecates bt_buf_get_cmd_complete() which now
has no in-tree HCI driver users anymore.
Fixes#16864
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Allow application to call net_if_ipv4_set_gw_by_index()
and set the gateway if enabled by configuration.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Allow application to call net_if_ipv4_set_netmask_by_index()
and set the netmask if enabled by configuration.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Make IPv4 and IPv6 address addition and removal possible from
userspace app. But allow this only if CONFIG_NET_IF_USERSPACE_ACCESS
By default these operations are not allowed from userspace app.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This fixes the issue where observations are automatically reported using
the minimum period instead of the maximum. This causes notifications to
be sent more frequently than configured when the resource does not
change.
Signed-off-by: Pieterjan Camerlynck <pieterjan.camerlynck@gmail.com>
Current socket connect call implementation always takes
K_FOREVER timeout value, which blocks TCP connections
in case failure. TCP connections waits until it receives
SYN ACK. If there is no SYC ACK means, connect call is
blocked forever.
Added a Kconfig option to define timeout value. Default
value is 3000 milliseconds. User can modify it.
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Modify dns_unpack_answer() function to check if the answer is
compressed or not, and return correct values regardless.
Fixes#16594
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This change will allow an MQTT client to override the compile-time
keepalive if desired. The change is structured such that the
compile-time default will still be setup by calling mqtt_client_init,
but can be changed by the application before calling mqtt_connect if
desired.
Signed-off-by: Justin Brzozoski <justin.brzozoski@signal-fire.com>
move misc/reboot.h to power/reboot.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/stack.h to debug/stack.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/util.h to sys/util.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/slist.h to sys/slist.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/printk.h to sys/printk.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/mutex.h to sys/mutex.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/mempool_base.h to sys/mempool_base.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/math_extras.h to sys/math_extras.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/libc-hooks.h to sys/libc-hooks.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/fdtable.h to sys/fdtable.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/dlist.h to sys/dlist.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/byteorder.h to sys/byteorder.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/__assert.h to sys/__assert.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move ring_buffer.h to sys/ring_buffer.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move uart.h to drivers/uart.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move spi.h to drivers/spi.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move gpio.h to drivers/gpio.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move flash.h to drivers/flash.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move entropy.h to drivers/entropy.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move clock_control.h to drivers/clock_control.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move zephyr/jwt.h to data/jwt.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move json.h to data/json.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move power.h to power/power.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move disk_access.h to disk/disk_access.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move crc.h to sys/crc.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move base64.h to sys/base64.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move atomic.h to sys/atomic.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move stats.h to stats/stats.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move nvs/nvs.h to fs/nvs.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move fcb.h to fs/fcb.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move fs.h to fs/fs.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move tty.h to console/tty.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move console.h to console/console.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move flash_map.h to storage/flash_map.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Return value from close() can be ignored in sntp_close()
as it is not returning value to caller anyway.
Coverity-CID: 198863
Fixes#16584
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Convert DT_.*_GPIO_{CONTROLLER,PIN,FLAGS} ->
DT_.*_GPIOS_{CONTROLLER,PIN,FLAGS)
Used the following commands to make these conversions:
git grep -l DT_.*_GPIO_CONTROLLER | xargs sed -i 's/DT_\(.*\)_GPIO_CONTROLLER/DT_\1_GPIOS_CONTROLLER/g'
git grep -l DT_.*_GPIO_PIN | xargs sed -i 's/DT_\(.*\)_GPIO_PIN/DT_\1_GPIOS_PIN/g'
git grep -l DT_.*_GPIO_FLAGS | xargs sed -i 's/DT_\(.*\)_GPIO_FLAGS/DT_\1_GPIOS_FLAGS/g'
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Log all send errors, but don't try to call e.g. prov_send_fail_msg()
since that'll almost certainly fail as well.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Mesh Profile Spec v1.0.1 | Section 5.4.2.3:
"The Provisioner and the device shall check whether the public key
provided by the peer device or obtained OOB is valid (see Section
5.4.3.1).
When the Provisioner receives an invalid public key, then provisioning
fails, and the Provisioner shall act as described in Section 5.4.4.
When the device receives an invalid public key, then provisioning
fails, and the device shall act as described in Section 5.4.4."
This is also in Erratum 10395 which is Mandatory for Mesh v1.0.
The code was already rejecting the key, however that rejection
happened only after we had already sent our public key as response,
which got interpreted as acceptance by the tester (PTS).
Fixes MESH/NODE/PROV/BI-13-C.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Mesh Profile Spec v1.0.1 Section 5.4.2.3: "If the public key was not
available using an OOB technology, then the public keys are exchanged
between the Provisioner and the unprovisioned device. For each
exchange, a new key pair shall be generated by the Provisioner and the
unprovisioned device."
This allows passing MESH/NODE/PROV/BV-12-C.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Clear the callback list once generation is complete and we've done
calling all callbacks. This lets us use bt_pub_key_gen() multiple
times, which before this patch could have resulted in a corrupt linked
list.
Also remove redundant callback dispatching from bt_pub_key_gen() since
the function checks for the PUB_KEY_BUSY flag in the beginning, i.e.
there cannot be other pending generation actions at this point in the
code.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Update code to handle other users of the public key generation APIs
by fetching the current public key at the beginning of each SMP
session. This is particularly important if someone creates the (rather
odd) combination of Mesh and SMP where Mesh will regenerate a new
key pair after provisioning.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Mismatch in Public Key type will cause device to send Invalid Format
error, and treat any further PDU's as unexpected.
This affects MESH/NODE/PROV/BI-03-C test case.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Provisioning errors shouldn't cause device to close link. Upon error,
device will send Provisioning Failed PDU, and any further PDU's will
be considered as unexpected as per Mesh Profile section 5.4.4.
Also a timer is started every time device sends or receives a PDU.
This affects MESH/NODE/PROV/BV-10-C test case.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
USBD_CFG_DATA_DEFINE macro has not consider that a class
could have more than one set of usb_cfg_data struct.
If a class has more than one set of usb_cfg_data
then they should be sorted the same way like by
USBD_DEVICE_DESCR_DEFINE macro.
Fixes: #16240
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Added a fix handling L2CAP start frame with payload length
of zero which otherwise sent zero length data start PDU on
air.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Updated the bluetooth module to use static handlers. Removed the
old bt specific static registration.
The routine bt_settings_init() is still calling settings_init() which
IMO is not needed anymore.
Updates:
changed SETTINGS_REGISTER_STATIC() to SETTINGS_STATIC_HANDLER_DEFINE()
changed settings_handler_stat type to settings_handler_static type
removed NULL declarations
renamed bt_handler to bt_settingshandler, as bt_handler already exists.
renamed all bt_XXX_handler to bt_xxx_settingshandler to avoid any
overlap.
changed SETTINGS_STATIC_HANDLER_DEFINE() to create variable names from
_hname by just prepending them with settings_handler_.
updated all bt_xxx_settings_handler to just bt_xxx.
Signed-off-by: Laczen JMS <laczenjms@gmail.com>
Add the possibility to register handles to ROM using a new macro
SETTINGS_REGISTER_STATIC(handler), the handler is of type
settings_handler_stat and has to be declared as const:
```
const struct settings_handler_stat test_handler = {
.name = "test", /* this can also be "ps/data"
.h_get = get,
.h_set = set,
.h_commit = NULL, /* NULL defines can be ommited */
.h_export = NULL /* NULL defines can be ommited */
};
SETTINGS_REGISTER_STATIC(test_handler);
```
To maintain support for handlers stored in RAM (dynamic handlers)
`CONFIG_SETTINGS_DYNAMIC_HANDLERS`must be enabled, which is by default.
When registering static handlers there is no check if this handler has
been registered earlier, the latest registered static handler will be
considered valid for any set/get routine, while the commit and export
routines will be executed for both registered handlers.
When a dynamic handler is registered a check is done to see if there was
an earlier registration of the name as a static or dynamic handler
registration will fail.
To get to the lowest possible RAM usage it is advised to set
`CONFIG_SETTINGS_DYNAMIC_HANDLERS=n`.
Updates:
a. Changed usage of RAM to DYNAMIC/dynamic, ROM to STATIC/static
b. Updated settings.h to remove added #if defined()
c. Make static handlers always enabled
d. Corrected error introduced in common-rom.ld.
e. Changed return value of settings_parse_and_lookup to
settings_handler_stat type to reduce stack usage.
f. Updated the name generated to store a handler item in ROM. It now
uses the name used to register in combination with the line where
SETTINGS_REGISTER_STATIC() is called.
g. renamed settings_handler_stat type to settings_handler_static
h. renamed SETTINGS_REGISTER_STATIC to SETTINGS_STATIC_HANDLER_DEFINE()
Signed-off-by: Laczen JMS <laczenjms@gmail.com>
The conditional CONFIG_RISCV32 was misspelled in is_rodata() resulting
in the test failing all strings that are in RODATA section.
Additionally, it was using wrong section names for riscv.
Fixes#17065
Signed-off-by: David Leach <david.leach@nxp.com>
The string returned by bt_uuid_str() is not in ROM so log_strdup()
must be used on it. This also eliminates the following kind of warning
messages: "<err> log: argument 3 in log message "%s: start_handle
0x%04x end_handle 0x%04x type %s" missing log_strdup()."
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Use Device Tree,and in particular a new 'bt-c2h-uart' to select which
UART is being used to communicate with an external BLE Host when acting
as a Controller.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Move internal and architecture specific headers from include/drivers to
subfolder for timer:
include/drivers/timer
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Although the Characteristic Value descriptor is required to be
immediately after the characteristic descriptor, the specification
allows for gaps in the corresponding Attribute handles. Use the value
handle from the characteristic descriptor for value reads.
See BLUETOOTH CORE SPECIFICATION Version 5.1 Vol 3, Part G section 2.5.1
(p. 2345), first paragraph.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Make net_eth_get_ptp_clock_by_index() clock API to work with user space.
Create also unit test for testing this user mode support.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Update the Replay Protection List handling for segmented messages to
be more in line with Figure 3.43 in Mesh Profile Specification 1.0.
This means that the RPL check and update need to be split into two
independent steps rather than always doing these together.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
If immediate logging is disabled, then we must use log_strdup()
when printing log string allocated from stack.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Ctrl+N - moves in history to next entry
Ctrl+P - moves in history to previous entry
Behavior of those meta-keys is the same as in bash and emacs, which
makes Zephyr shell even more familiar to play with.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Fix iterating past the response which causes an invalid memory to be
accessed and passed over to the callback as if there were more
attributes found.
Fixes#16602
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Log records may store either data or pointers to more records. In both
cases they must have the same size. With 64-bit pointers, the amount
of data that can occupy the same space as a pointer has to be adjusted.
And storage alignment has to accommodate actual pointers not u32_t.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Log arguments were hardcoded to u32_t values. On 64-bit systems, this
is rather restrictive. To make things clear, arguments now have their
own type, log_arg_t, which now can be adjusted in only one location
if need be. It is currently defined as unsigned long whose effective
width is equivalent to u32_t on 32-bit systems, and u64_t on 64-bit
systems.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
We must query both IPv4 and IPv6 addresses if the hints parameter
is NULL i.e., user does not supply hints or if family is set to
AF_UNSPEC.
Fixes#16453
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This function uses mqtt_read_publish_payload_blocking to perform a
blocking read of the specified number of bytes.
When reading out a payload, the normal use case is to read the
entire payload. This function facilitates that use case.
Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
Moved and renamed ull_entropy_get to lll_entropy_get, placed under
vendor specific ll_sw. This is needed for SW implemented entropy,
to allow vendor implementation of faster, less secure random number
generator for randomizing ADV timing.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
When advertising with different identities we need to flag any
programmed RPA as invalid if it was generated using a different
identity.
Fixes#16893
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This array was created because more than 4 bytes were needed, however
now the minimum is 8 bytes, so we can use the net_buf user data
directly.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This updates all client modules to const char processing of
setting names.
Update of peripheral_dis sample
Signed-off-by: Laczen JMS <laczenjms@gmail.com>
The settings module processes the variable name by splitting it up in
a set of variables. This PR removes the splitting up and keeps the
variable name as one string.
It is an alternative to #16609
The possibility is introduced to register handler including a
separator, or to register a handler for each variable.
The ability is introduced to load a subtree from flash or even to load
a single item.
Two ways to operate on variable and settings_handler names are provided:
settings_name_steq(const char *name, const char *key, const char **next)
which checks if name starts with key, returns 1/0 if it does/does not
the remaining part of name is in next.
settings_name_split(const char *name, char *argv, const char **next)
which splits up name in a part before "/"" that is found in argv and
the remaining part that is in next.
A mutex is added to make settings thread-safe
The settings_handlers list is stored in reverse alphabetical order, this
allows registration of e.g. bt and bt/mesh in separate handlers, the bt
handler itself should not contain any handling of bt/mesh.
A settings_deregister() method is added. Settings_handlers can now be
added/removed when required. This saves RAM when settings_handlers are
not needed.
Tests have been updated to reflect changes in the settings api.
Updates after meeting:
1. Removed settings_deregister
2. Changed settings_name_split() in settings_name_next:
int settings_name_next(const char *name, const char **next): returns
the number of characters before the first separator. This can then be
used to read the correct number of characters from name using strncpy
for processing.
3. New functional test added
Update in settings.h: settings_name_next() changed position -> index
Added some comments in settings.h (settings_name_steq())
Updated tests to reflect change to settings_name_next() and pointer
value comparison. The functional test can now also run on qemu_x86.
Corrected some documentation in header.
Changed registration of handlers to be non ordered.
Changed handler lookup to handle non ordered list of handlers, this
improves handler matching in case different length names are compared
and also makes it easier to add rom based handlers as they will not be
ordered.
Signed-off-by: Laczen JMS <laczenjms@gmail.com>
If the socket is closed, then do CAN detach if that is needed.
This way the CAN interrupts are not received if there are no
CAN sockets listening the data.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
At the moment there is no real address for local CANBUS socket,
but we can still set protocol family of local socket to AF_CAN
so that for example net-shell "net conn" command can show
information about it.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
We need to dispatch the received CAN frame if there are multiple
sockets interested in the same CAN-IDs.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Reversed revised ticker implementation pending new design which resolves
the issues described in GH issues #16830.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Swap_type field implementation is the new mcuboot's trailer field.
This patch makes using of it optional which keeps possibility of being
compatible with older versions of MCUBoot.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Mcuboot changed TLV in PR: Fix double swap on interrupted revert
(https://github.com/JuulLabs-OSS/mcuboot/pull/485)
Above bugfix changes a little way for upgrade request.
This path introduces re-formatted original mcuboot bootutil_misc.c
code as much as it was reasonable which includes the bugfix
adaptation and support for devices witch have bite erased sate different
than 1 as well.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Parameter of set_interface_status is no more the interface index
but a pointer to interface descriptor.
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Fix pending Tx control buffer leak on supervision timeout.
Queued tx buffers in LLL consists of both data and control
PDUs but only data buffers got correctly released.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This makes it safe to allocate buffer from the TX callback by freeing
the context before calling the callback which should wake up the TX
thread had it be pending on add_pending_tx.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This API had several issues:
- The parameter types and order were inconsistent with e.g.
bt_le_adv_start()
- There were no real users of num_params, which just caused increased
code size and memory consumption for no good reason.
- The error handling policy was arbitrary: if one of the
notifications would fail it would be impossible for the caller to
know if some notifications succeeded, i.e. at what point the
failure happened. Some callers might also want to make note of the
failure but continue trying to notify for the remaining parameters.
The first issue is easily fixable, but because of the other two I
think it's best we don't have this code as part of the stack, rather
require whoever needs it to do the for loop themselves. It's just a
few lines of code, so the benefit of having this in the stack was
anyway quite minimal.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Change code from using now deprecated DT_<COMPAT>_<INSTANCE>_<PROP>
defines to using DT_INST_<INSTANCE>_<COMPAT>_<PROP>.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
k_sem_give shall only be used if no callback has been set otherwise
k_sem_take was not called which can break the flow control.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Detection of missing log_strdup call was applied to every message
while it applies only to standard messages (string + arguments).
Appling it to hexdump messages could lead to fault as seen on
nrf9160_pca10090ns board.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The neighbor cache did not contain link address type. This is not
causing problems atm but good to fix anyway.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Port the implementation that performed random backoff of
forced slave event scheduling.
When peer master implementation skips events, multiple
local overlapping slaves will randomize their forced
scheduling to break out of a round robin pattern increasing
the chance of synchronizing with their masters again.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
For the request:
DCID shall map to rx.cid:
'This field specifies the endpoint of the channel to be disconnected
on the device receiving this request.'
SCID shall map to tx.cid:
'This field specifies the endpoint of the channel to be disconnected
on the device sending this request.'
For the response when receiving the roles are inverted.
Fixes#16799
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Changed ticker behavior to resolve conflicts in ticker_worker instead of
in ticker_job. This allows better real-time slot allocation, as well as
allowing callbacks even if ticker node doesn't get air-time (for audio
stream housekeeping). A priority property now also allows prioritizing
one ticker node over others.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix scan requests being processed during directed advertisiments.
Directed advertise packets are not scannable
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
It is possible that iface is NULL when selecting IPv4 destination
address for a sent packet.
Coverity-CID: 198877
Fixes#16570
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This adds number of matches as optional parameter to gatt show-db:
> gatt show-db 2803 1
attr 0x005065f0 handle 0x0002 uuid 2803 perm 0x01
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Number of matches was not being properly handled causing the callback to
be called more than specified by the caller.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Using void pointers as universal arguments is widely used. However, when
compiling a 64-bit target, the compiler doesn't like when an int is
converted to a pointer and vice versa despite the presence of a cast.
This is due to a width mismatch between ints (32 bits) and pointers
(64 bits). The trick is to cast to a widening integer type such as
intptr_t and then cast to
void*.
When appropriate, the INT_TO_POINTER macro is used instead of this
double cast to make things clearer. The converse with POINTER_TO_INT
is also done which also serves as good code annotations.
While at it, remove unneeded casts to specific pointer types from void*
in the vicinity, and move to typed variable upon function entry to make
the code cleaner.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Since the bt_mesh_msg_ctx struct no longer has a size that is a
multiple of 2, the bitfields might as well be made to normal types
as this will minimize the code generated to access them.
Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
By moving the rssi value from the bt_mesh_net_rx struct to the
bt_mesh_msg_ctx struct, it will be available to applications via
the mesh op callbacks.
Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
The query->len does not take 'Terminator' into account, shift over
one byte to prevent overwriting it with next field (Type).
This fixes mdns_resolver sample.
Fixes: 87eb552dd2 (net/dns: Switch mdns responder to new net_pkt API)
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
The attribute handle used to read next attribute has to be incremented
to not loop reading the same attribute.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
When trying to establish friendship the Friend must respond to the
initial Friend Poll with a Friend Update. If this initial Friend Update
response is not received the Friendship establishment process must start
again.
When starting a second Friendship establishment processes the `sent_req`
field of the `lpn` struct was left set to `TRANS_CTL_OP_FRIEND_POLL`.
This prevented the initial Friend Poll being sent out on the second
attempt. Since the Friend Poll was not sent, no timeout is set and
nothing happens ever again. No more Friendship Requests are sent.
This commit clears `sent_req` back to zero when no Friend Update
response has been received after the initial Friend Poll.
Fixes#16678
Signed-off-by: Rich Barlow <rich@bennellick.com>
Add some missing fatal asserts that need to be caught to
avoid unexpected failures in the implementation of the
architecture.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Although unlikely it is possible that a remote may attempt to send just
1 byte as the write request allows to do that:
BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part F
page 2320:
'If the attribute value has a fixed length and the Attribute Value
parameter length is less than or equal to the length of the attribute
value, the octets of the attribute value parameter length shall be
written; all other octets in this attribute value shall be
unchanged.'
Fixes#16734
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fix the tx_ack mfifo count to accomodate both data and
control PDUs being acknowledged.
With out this fix, pending maximum number of data plus
control PDUs in LLL on supervision timeout asserted due to
tx_ack mfifo overflow.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Explicitly track the connection update related ticker stop
and start to avoid asserting due to ticker update being done
at the same time for compensating the master clock drift.
Relates to #11764.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added an internal ull_update_mark function to detect race
conditions while stopping ticker instances during slave
drift, disconnection and connection update.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Allow user to set the socket priority using setsockopt() call.
The priority value is used to order the networking queues so
that packets with a higher priority may be processed first.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
It is possible that UDP header cannot be accessed so we need
to check that we do not do null pointer dereference.
Coverity-CID: 198866
Fixes#16581
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If argument for log_strdup is from ro memory then there is
no point to duplicate it. This may happen if function logs
variables coming from outside, e.g. function argument.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Issue was caused by pointer arithmetic.
This commit cast pointer of struct data to u8_t pointer
and makes arithmetic explicitly by adding the exact value.
fixes#16572
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
The structure of the va_list type is architecture-dependent, and it
doesn't seem possible to initialize va_list variables in a portable way
(except by using va_start()). In particular, the x86_64 ABI defines the
type like this:
typedef struct {
unsigned int gp_offset;
unsigned int fp_offset;
void *overflow_arg_area;
void *reg_save_area;
} va_list[1];
Fortunately, the va_start() macro expects an uninitialized va_list
variable, so we can simply remove the initializers to make the code
portable.
Signed-off-by: Jakob Olesen <jolesen@fb.com>
This convenience macro wraps Z_DECL_ALIGN() and __in_section() to
simplify static definitions of structure instances gathered in dedicated
sections. Most of the time those go together, and the section name is
already closely related to the struct type, so abstracting things behind
a simpler interface reduces probability of mistakes and makes the code
clearer. A few input section names have been adjusted accordingly.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
The alignment fix on struct device definitions should be done to all
such linker list tricks. Let's abstract the declaration plus alignment
with a macro and apply it to all concerned cases.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Per guidelines, all statements should have braces around them. We do not
have a CI check for this, so a few went in unnoticed.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
When reading attributes from static services their handles will not be
set and must be resolved at runtime.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Port the fix for the controller implementation to make start
encryption queueable if there is any control procedure in
progress.
Refer to #15335.
Relates to #15335, #15186, #15958 and #14636.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix disconnect command optional argument count to permit the
supply of Bluetooth Address so as to be able to cancel a
pending central initiated connection creation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix gatt indicate when conn is NULL and called with characteristic
declaration as the attribute argument. In this case the handle was not
advanced to the characteristic value. This is inconsistent with the rest
of the notify and indicate API
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Mesh Profile 1.0 Section 6.6:
"The timeout for the SAR transfer is 20 seconds. When the timeout
expires, the Proxy Server shall disconnect."
This will let qualification test case MESH/SR/PROX/BV-05-C pass
without requiring an explicit disconnect.
Fixes#16600
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This moves the processing packets of upper layers from RX thread to the
system workqueue so they have the same priority as the TX callbacks
which has the added benefit of making any protocol on top of L2CAP to
be executed using system wq stack.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
These options are mutually exclusive, or more specifically,
CONFIG_POSIX_API has wider scope and supersedes
CONFIG_NET_SOCKETS_POSIX_NAMES. Implementation-wise, the two
options should not be defined at the same time, as that may
lead to declaration conflicts.
Fixes: #16141
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This commit fixes the zassert_mem_equal macro to properly print
the formatting string is given as a parameter by the user.
There is an error that is an effect of directly copying the
previous implementation that was using the inline function.
Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
These events aren't errors at all, but rather part of normal operation.
They shouldn't trigger error messages, especially given that the console
gets absolutely flooded with them if power management is activated.
Signed-off-by: Benjamin Lindqvist <benjamin.lindqvist@endian.se>
When mcumgr smp data was received over shell uart transport
it was not waking up shell thread and thus request was not
processed. Shell thread must be waken up on any incoming
data, even data which is only dedicated for mcumgr smp.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Disable flow control with POSIX_ARCH since these boards tend to run
faster than normal defering the TX callback to system wq may not be
able to run before another packet is received.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes the transmission complete callbacks to run on system wq
context so they are not executed in TX thread which usually has a much
smaller, and non-configurable, stack size.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This reworks bt_gatt_notify_cb to allow passing an UUID, in addition to
that it can now accept multiple notification at once as there could be
multiple instance of the same UUID the user can set multiple set of
parameters.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This make use of bt_gatt_foreach_attr_type in gatt show-db to match
attributes by UUID.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This make use of bt_gatt_foreach_attr_type to match the CCC UUID which
previously was not possible with bt_gatt_foreach_attr.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds bt_gatt_foreach_attr_type which can match attribute by UUID
and/or attribute user_data, in addition of that the user can also limit
the number of matches.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit changes zassert_mem_equal as a macro instead
of a function implementation.
In the previous implementation when an assertion fails
the location inside ztest_assert.h file was displayed.
This modification displays the location where zassert_mem_equal
was used.
Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
Implement HCI driver for STM32WB. It allows host to controller.
It is based on ST library allowing communication over RAM shared
bewteen chip's C-M4 and C-M0 cores.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit removes redundant checks if the module
was already initialized.
The variable to mark the fact of initialization is
moved as a global module variable.
This allows creating more sophisticated unit tests
of the settings subsystem by giving a possibility to modify
the internal mark of the fact the system was initialized.
Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
Offloaded `fcntl` implementation should be available for all offloaded
implementations, not specific for TI. `socket_offload.c` is already
conditionally compiled based on `CONFIG_NET_SOCKETS_OFFLOAD` option, so
there should not be conflicts for non-offloaded interfaces.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When removing a service using bt_gatt_service_unregister, its attributes
handles will keep their value which can cause a problem when adding the
service again to the GATT database.
When re-adding, the gatt_register routine is taking the last handle of
the GATT database to compare it with the handles of the service to be
added.
If a service has handles with a lower value than the last handle of
the database an error will occur.
If we add/remove/add the last service, no error will occur as its
handles are always greater than the last one of the database.
Instead of resetting the handles when unregistering a service and
reassign new ones we make sure that the handles of the services are
not in use in the GATT database in order to place the service back
where it used to be.
Signed-off-by: Arthur Crepin-Leblond <arthur.crepin@proglove.de>
Implements hooks to implement user protocols in ull.c
A user defined init function can now be called, this code is gated by
the CONFIG_BT_CTLR_USER_EXT define.
A user defined PDU length can now also be defined using the Kconfig
CONFIG_BT_RX_USER_PDU_LEN
Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
There isn't a function to handle the unmount, so I implemented based
in f_mount comments. In the comments of f_mount we actually have
that f_mount is used to mount/unmount logic, is just necessary use
NULL pointer to fs argument.
Signed-off-by: Lucas Peixoto <lucaspeixotoac@gmail.com>
Shell history module reworked to use ring buffer for storing
commands. Dedicated buffer is used to story all command lineary.
History capacity is in bytes not in number of entries, e.g.
many short commands can be stored or few long (depending on
CONFIG_SHELL_HISTORY_BUFFER).
Removed implicit command null termination from shell_history and
added it to shell after fetching command line from the history.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
There is no reason for storing a pointer into an atomic_t variable here.
Not only because this requires a dubious double cast that breaks on
64-bit builds as atomic_t is a 32-bit type, but also because the comment
in the code already admits that the whole operation isn't atomic anyway
and that it is fine. So let's keep things simple.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
- Delete CONFIG_TEST_USERSPACE=n no-ops because it's the default
since commit 7b1ee5cf13
- Some tests have a "userspace" tag pretending to TEST_USERSPACE but
don't and vice versa: fix missing or spurious "userspace" tags in
testcase.yaml files.
Tests have a _spurious_ "userspace" tag when they PASS this command
cause none should pass:
./scripts/sanitycheck --tag=userspace -p qemu_x86 \
--extra-args=CONFIG_TEST_USERSPACE=n \
--extra-args=CONFIG_USERSPACE=n | tee userspace.log
All tests run by this command must either fail to build or fail to run
with some userspace related error. Shortcut to look at all test
failures:
zephyr_failure_logs() {
awk '/see.*log/ {print $2}' "$@"
}
Tests _missing_ "userspace" tag FAIL to either build or to run with some
userspace related error when running this:
./scripts/sanitycheck --exclude=userspace -p qemu_x86 \
--extra-args=CONFIG_TEST_USERSPACE=n \
--extra-args=CONFIG_USERSPACE=n | tee excludeuserspace.log
Note the detection methods above are not 100% perfect because some
flexible tests like tests/kernel/queue/src/main.c evade them with #ifdef
CONFIG_USERSPACE smarts. Considering they never break, it is purely the
test author's decision to include or not such flexible tests in the
"userspace" subset.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Length should be at least of UDP header size but not bigger than actual
payload size.
Reported-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Due to commit a211afb0 ("logging: Add option to detect missed
transient string duplication"), the logs for LwM2M subsystem
is now spamming missing log_strdup() calls.
Let's add log_strdup() where needed.
Signed-off-by: Michael Scott <mike@foundries.io>
This adds a new callback for L2CAP channels which notities whenever
status has changed so the channel user can can for example resume or
suspend sending depending on the status.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The Bluetooth menu has way too many option so this move the L2CAP
specific option to its own menu.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This prints to the output when a packet finishes transmitting:
uart:~$ l2cap send 2
Outgoing data channel 0x005166a0 transmitted
Outgoing data channel 0x005166a0 transmitted
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds a new callback to bt_l2cap_chan_ops which is called whenever a
SDU is completely sent.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This allows setting a custom pointer to be passed back to the complete
callback at expense of increasing the buffers in 4 bytes.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This changes the declaration of fixed channels to be statically defined
with use of BT_L2CAP_CHANNEL_DEFINE since fixed channels are never
unregistered.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Added CONFIG_LOG_DETECT_MISSED_STRDUP (by default on) which enables
scanning of log message strings in search for %s and reports if
string address is not from strdup buffer pool and outside read only
memory section which indicates that log_strdup() wrapping is missing
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
If a valid numeric IP address is provided as argument, it should
be resolved without contacting DNS server.
Also, implement handling of AI_NUMERICHOST.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Fix shell app regression due to stale tmp role implementation
not fully being removed in commit 4c77bf6194 ("Bluetooth:
controller: Remove redundant tmp role implementation").
The regression caused ticker indexes outside of allocations to
be accessed causing application faults and memory corruptions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fedora 30 uses GCC 9.1 which fails to build when loggin is enabled:
zephyr/subsys/logging/log_core.c: In function ‘log_is_strdup’:
zephyr/subsys/logging/log_core.c:665:22:
warning: array subscript -1 is outside array bounds of
‘u8_t[]’ [-Warray-bounds]
665 | ((char *)buf <= pool_last->buf);
| ^~
zephyr/subsys/logging/log_core.c:52:3:
note: while referencing ‘log_strdup_pool_buf’
52 | log_strdup_pool_buf[LOG_STRDUP_POOL_BUFFER_SIZE];
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fix handlers call for secondary descriptor.
USB class like DFU has two sets of descriptors. In the handler
look up function, wind the pointer forward to the range
of the current descriptor.
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Remove duplicated execution path for composite configuration, USB
device stack initialization is done inside stack for both cases.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Now that Standard, Class and Vendor request handlers are using the same
buffer, we do not need to keep and array installed request data pointer.
This simplifies the code.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Now that we have merged the class and vendor request buffers into the
USB device code, we can also merge the standard request buffer. We just
need to ensure it is at least 8 bytes, by using the range option in
Kconfig. The 64KiB limit is arbitrary.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
In order to unify the legacy and composite code, move the class and
vendor request handler buffer into the USB device code, just like in
composite mode. The option is renamed from USB_COMPOSITE_BUFFER_SIZE
into USB_REQUEST_BUFFER_SIZE and also replaces the USB_DFU_MAX_XFER_SIZE
and USB_HID_MAX_PAYLOAD_SIZE options.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Having a checksum of zeros in UDP means "missing checksum" and is a
valid case as per RFC 768:
"An all zero transmitted checksum value means that the transmitter
generated no checksum (for debugging or for higher level protocols
that don't care)."
Such support is made possible by adding a new Kconfig option named
CONFIG_NET_UDP_MISSING_CHECKSUM.
However, that is valid only for IPv4. For IPv6, see the RFC 2460
section 8.1:
"Unlike IPv4, when UDP packets are originated by an IPv6 node, the UDP
checksum is not optional."
So the UDP checksum will always be verified in IPv6.
Fixes#16375
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
From RFC 768, in "Fields":
"If the computed checksum is zero, it is transmitted as all ones"
Fixes#16379
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Added support for the LE SC pairing with the OOB data. The peripheral
side is only supported for now.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
The the footer structure and extra bytes (rssi, resolving index etc.)
were overlapping in memory, rx_ftr was moved into the header, but the
extra and footer are still being read from the same place, extra was
written to the end. So this avoided memory corruption, but reading extra
reads wrong information.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added option profiling instrumentation which can help determine
string duplicates pool configuration. Added shell command to
read current peak utilization of the pool.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Fix compilation issues in central_hr or peripheral_hr sample when using
split LL and privacy is enabled.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The node_rx buffer does not contain the data from the connect ind, so
copy it over.
Also back up the adv pdu chan_sel bit so that it can be used to properly
select the correct channel selection algorithm
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The node_rx buffer for the connect ind buffer is being reused to send
connection complete event, make sure all data is backed up before
reusing the buffer.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The privacy state variables rl_idx and rpa_gen was not initialized
properly, which results in connection failing to be established.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix that removes magic numbers from the code that
leaded to the error codes that was hard to explain.
Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
The "select" command has been implemented, which allows user to
narrow down the command tree.
This implementation differs from the "select" command available
in the legacy shell. In a new implementation, if the selected
command has a handler and if the user has not entered the
registered subcommand, the shell will call the handler of selected
command and pass the text as arguments.
This may be useful, for example, if someone wants to use the
shell as an interface to a modem that supports AT commands.
Instead of each time you write e.g:
at at+command1
at at+command2
at at+command3
user can execute following commands:
select at
at+command1
at+command2
at+command3
where:
at - root command for passing at commands to the modem
at+commandX - at command passed to the modem.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
The 32bits one can hold up to about 50 days, this is more than enough
knowing that ARP request timeout is 2 seconds.
So reducing the request start time to 32bits.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Do not always print general help for ping cmd. Only if user supplies
'-h' or '--help' command, print information about the parameters.
After this the generated HTML documentation looks better for the
ping command.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Documentation moved to the right place.
The argument name of the macro is aligned between the macros.
Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
OpenThread uses CONFIG_OT_PLAT_FLASH_PAGES_COUNT to calculate the # of
pages at the end of flash to use for storing OpenThread settings.
This calculation has an off-by-one error which sets the offset for
the storage area as 1 page of flash too low.
For example, on nRF52840:
- default setting for CONFIG_OT_PLAT_FLASH_PAGES_COUNT is 4
- flash size is 1MB (0x100000)
- flash page size is 4096 (0x1000)
- expected offset is 0xfc000
Using the current logic we get an offset of: 0xfb000
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/16339
Signed-off-by: Michael Scott <mike@foundries.io>
If the system sets its clock frequency at runtime, this is
stored in a variable that can't be directly read by user
mode. For this case only, add a system call to fetch its
value and modify the definition of
sys_clock_hw_cycles_per_sec() to use it.
Since this is now a system call, store in a temporary variable
inside z_ms_to_ticks(). The syscall overhead only applies
when called from user mode, other contexts are completely
inlined.
Added stub syscall header for mocking framework, to get rid
of inclusion errors.
Fixes: #16238
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Code refactored to allow calling of a proprietary rx demux function.
This will enable implementation of proprietary protocols and
functionality that is not yet public, while keeping a common zephyr
code base.
Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
Fixes USB3CV Tool tests. One case is enabling endpoints with Set
Interface after Set Configuration. In this case we report warning and
continue without returning error.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This patch fixes following bug:
After first GC operation the 1st sector had become scratch
and the 2nd sector had became write sector. After that NVS
was initialize (via reboot) again - it recognized the 1st
sector as write sector and 2nd as undone GC destination sector,
therefore it cleared 2nd sector and re-run GC, which implied data loss.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
A conditional block to save a directed advertising report flag was
present three times. Remove two of the blocks.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Drop packet if it has broadcast destination MAC address but the IPv4
destination address is not multicast or broadcast address.
See RFC 1122 ch 3.3.6 for details.
Fixes#16276
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The net_if_ipv4_select_src_addr() should return global address
in the interface if nothing else is being found.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Let's filter out on a state parameter.
There is no impact as this function is not used anywhere yet.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
If we receive a multicast ICMPv4 packet, then send the reply back
with correct source address and not with multicast address.
Fixes#16257
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Put the symbols that depend on DISK_ACCESS_{RAM,FLASH,SDHC} directly
after the symbol they depend on, so that they end up in an implicit
indented menu. That makes it easier to see which symbols are related.
It also indirectly makes all symbols children of DISK_ACCESS. To save a
menu level, turn DISK_ACCESS into a 'menuconfig' symbol and put it in
the top-level menu. Change its prompt from "Enable Disk Interface" to
"Disk Interface", to be consistent with e.g. "Logging".
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Add an event handler for HCI vendor-specific events with the
event code BT_HCI_EVT_VENDOR.
A vendor defined callback can be registered to be called when
vendor-Specific events are received in the stack. The callback can then
decode and handle the event; if not the stack will decode and handle
the event.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Make sure we are able to receive UDP packets with broadcast
destination address. If CONFIG_NET_IPV4_ACCEPT_ZERO_BROADCAST
is set, then check here also non-standard broadcast address
that is described in RFC 1122 chapter 3.3.6.
Fixes#11617
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
From POSIX.1-2017:
The getsockname() function shall retrieve the locally-bound name of the
specified socket, store this address in the sockaddr structure pointed
to by the address argument, and store the length of this address in the
object pointed to by the address_len argument.
The address_len argument points to a socklen_t object which on input
specifies the length of the supplied sockaddr structure, and on output
specifies the length of the stored address. If the actual length of the
address is greater than the length of the supplied sockaddr structure,
the stored address shall be truncated.
If the socket has not been bound to a local name, the value stored in
the object pointed to by address is unspecified.
Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
When using the procedure Read By Type the response may contain multiple
instances so it needs to be parsed properly. When dealing with long
values only the beggining will be read, for the remaining bytes the
application should issue another bt_gatt_read with offset so Read Blob
procedure is used as recommended by the spec:
BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part F page 2312:
The Read Blob Request would be used to read the remaining octets of a
long attribute value.
Fixes#16107
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If host is NULL and ai_flags are AI_PASSIVE in a call to
getaddrinfo(), need to return "any" address.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
- Make the 'C++ Standard' choice depend on CPLUSPLUS, so that it only
shows up when C++ support is enabled.
Also check that CPLUSPLUS is enabled before checking the standard in
the top-level CMakeLists.txt, to avoid triggering an assert.
- The 'C++ Options' menu now contains just CPLUSPLUS and its indented
children. Remove one menu level by removing the menu and turning
CPLUSPLUS into a 'menuconfig' symbol. Also change the prompt from
"Enable C++ support for the application" to just "C++ support for the
application", to make it consistent with e.g. "Logging".
- Factor out the common CPLUSPLUS dependency with an 'if CPLUSPLUS'.
- Order symbol properties more consistently with other Kconfig files,
with the prompt at the top, etc.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
The 'Console' menu contains just 'config CONSOLE_SUBSYS' and its
indented children.
Remove one menu level by removing the 'Console' menu and turning
CONSOLE_SUBSYS into a 'menuconfig' symbol.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
This menu contains just the IMG_MANAGER symbol and its children. Remove
one menu level by making IMG_MANAGER a top-level 'menuconfig' symbol
instead.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
When compiling the kernel with CONFIG_SYS_CLOCK_TICKS_PER_SEC=0,
the CONFIG_SYS_CLOCK_EXISTS internal variable is unset.
This completely disables timer handling in the kernel, but a couple of
spots missed the required conditional compilation.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Port fix for #14044 from legacy LL to split LL.
The master is using unknown rsp to terminate slave side initiated
procedures that has collided with the encryption procedure initiated by
the master.
We need to handle an unknown response that is sent in unencrypted during
the encryption procedure, even though we have already set up to receive
encrypted packets.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Remove comment stating that UNKNOWN_RSP during encryption procedure
is a workaround.
The core spec mandates that connections should not be dropped if
receiving this control packet during encryption procedure.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use the new math_extras functions instead of calling builtins directly.
Change a few local variables to size_t after checking that all uses of
the variable actually expects a size_t.
Signed-off-by: Jakob Olesen <jolesen@fb.com>
This is a pure refactoring of the k32src_wait function. It used the
following rules when refactoring:
Don't use the preprocessor when unprocessed C language suffices.
Don't undefine macro's.
Avoid global variables when possible.
Use consistent names for similiar things (hf_clock, lf_clock).
Signed-off-by: Alexander Svensen <alsv@nordicsemi.no>
Fix broken master role RSSI measurement. Since the original
contribution clean up into Zephyr, the radio shorts that was
set for measuring the RSSI for master role has been broken,
as it was cleared by the radio switching code further in the
Tx ISR.
Signed-off-by: Alexander Svensen <alsv@nordicsemi.no>
We replied to an ARP request that has the same Sender Hardware Address
than that of ours. Such an ARP request must be discarded, no reply
should be sent and translation table should not be updated.
Fixes#16110
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If a packet is received with Ethernet source address different
from ARP's sender hardware address field, then DUT must use the
latter address in response packets.
Fixes#16098
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The old footer was appended after PDU using pointer arithmetic. Now
the footer fields have been moved to the header struct, the
footer fields are now statically located in the data structure,
this is type safe and fields can be referred to by their actual
names rather than indirectly through reference to other members,
thus avoiding pointer arithmetic. Secondly, this change will pave
the way for adding other meta data in the future.
Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
The 'Bluetooth' menu contains just 'config BT' and its indented
children.
Remove one menu level by removing the 'Bluetooth' menu and turning BT
into a 'menuconfig' symbol. Also change the prompt from "Bluetooth
support" to just "Bluetooth", to make it consistent with e.g. "Logging".
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
This commit adds support for board: nrf52811_PCA10056.
The nRF52840 DK: PCA10056 is the recommend development kit, it emulates
the nRF52811, and can be used as a starting point for development
before moving over to a custom board.
Please note that this development kit does not support Bluetooth
Direction Finding. What is more it cannot be used with most of Arduino
shields because of PCA10056 PIN layout.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Aligned format specifiers for the NVS FS. Now, the format specifier
matches the variable type for qemu_x86 types.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
By moving signals initialization to shell instance init function,
shell instance is ready to receive RX signals from backend before
thread is ready to handle them.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Send ZLP when host asks for a bigger length and the last chunk
is wMaxPacketSize long, to indicate the last packet.
Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
Libraries that use mbedTLS have been invoking
zephyr_link_interface(mbedTLS). It is not clear what the intent of
this code has been, but it is redundant with the mbedTLS build
scripts, so it can be safely removed.
In addition to being redundant, it causes problems as it introduces an
ordering dependency, with this code mbedTLS must be declared before
users of mbedTLS are declared. Since this code is redundant, this
ordering dependency is also unnecessary.
This code is believed to have been added early on by accident and
copied through cargo-cult programming since.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
sntp_simple() function queries the server (passed as "addr[:port]"
string). It wraps calls to a number of other functions, and may be
useful to write simple, concise apps needing the absolute time.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Two utils to manipulate addresses in format "addr[:port]". I.e.,
network address (domain name or numeric), optionally followed by
port number:
* net_addr_str_find_port(), to return pointer to port number
substring (or NULL if not present).
* net_getaddrinfo_addr_str(), which is effectively getaddrinfo()
wrapper taking a "addr[:port]" string as a parameter.
The header file is named socketutils.h to emphasize that these
utility functions are implemented on top of BSD Sockets API
(and other POSIX/ANSI C functions), and thus portable to other
POSIX systems (e.g., Linux), so can be used in apps testing
POSIX compatibility. More utility functions (beyond address
manipulation) can be added later.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Calling functions like `net_if_start_dad`, `join_mcast_nodes` or
`net_if_start_rs` lead to L2 API function calls, which is not correct
for offloaded interfaces and leads to a crash. This is especially
problematic, as they are called in the default configuration.
Avoid calling these functions while an offloaded interface is brought up
by adding extra jump label.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case socket offloading is used, one might want to disable native IP
stack, both IPv4 and IPv6, to save memory. Currently it is not possible
due to preprocessor check. Prevent that by adding additional exception
for socket offloading.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Interface Association descriptor has to be used with Windows 7.
Add CONFIG_CDC_ACM_IAD option to force its usage, disabled by default.
Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
Unique PID is required for each sample in order
to be recognized by host.
When creating a new sample:
- Add USB_PID_<SAMPLE_NAME>_SAMPLE
in samples/subsys/usb/usb_pid.Kconfig
- Create Kconfig file in your sample's subdirectory, containing:
config USB_DEVICE_PID
default USB_PID_<SAMPLE_NAME>_SAMPLE
source "Kconfig.zephyr"
Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
In non-secure Trustzone application dedicated flash non-secure
partition are used instead of regular one, which become secure
partition in Trustzone collaboration model.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Fix an issue wherein local or remote initiated Connection
Parameter Request procedure would stall without generation
of LE Connection Update Complete HCI event because a local
or remote initiated PHY Update procedure has overwritten the
currently active Link Layer Control Procedure type.
Signed-off-by: Alexander Svensen <alsv@nordicsemi.no>
This is a workaround for IOP issue, where peer rejects LLCP Slave
Connection Parameter Request with LMP Error Transaction Collision
error code even if previous request is complete at the instant.
Relates to #15366.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the encryption setup queueing implementation to avoid
overlapping with local initiated Length Update Procedure.
Fixes#15733.
Relates to #15335, and #15186.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
It is convenient to have a blocking version of
`mqtt_read_publish_payload` function, for cases when it is called from
the event handler. Therefore, extend the 'mqtt_read_publish_payload'
argument list with information whether the call should block or not.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If the local node keeps getting bombarded with messages, it's possible
that the storage timer gets rescheduled over and over again and never
expires. Add the necessary code to only reschedule the timer if the
new deadline is earlier than an existing one.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The default values for the timeouts, as well as non-defaults in most
Mesh samples, use a higher value for the RPL than then generic mesh
storage timeout. This hasn't had any effect in practice since the code
only uses the RPL timeout if it is *smaller* than the generic one.
The original intention of the code was to use the RPL timeout,
regardless of what the generic one is, whenever the RPL is the only
thing that needs updating. Add some helper macros to track the various
groups of pending flags, and perform the appropriate checks to apply
the RPL timeout whenever it's smaller than the generic timeout, or if
there are no other items to store besides the RPL.
Fixes#15904
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fixed format error when compiling with gcc and newlib.
Used standard formats (%u) instead of inttypes formats (PRIxxx)
since Zephyr redefines the standard formats, that way it should always
be in line with the Zephyr types.
Compiled with and without newlib using gcc.
Signed-off-by: Dennis Wildmark <dennis.wildmark@assaabloy.com>
It is possible that the device driver API pointer is null.
For example if the device driver returns an error, the device
code will make the API pointer NULL so that the API would not
be used. This can cause errors in networking code where we
typically do not check the NULL value.
Fixes#15003
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
- renaming functions to better names
- reordering functions place (register, then unregister for instance)
- centralizing logs to relevant place
Fixes#8722
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Also, there is no need for unspecified address bit. If specified address
bit is not set, then it will be obvious address is unspecified. Reducing
the amount of bits from 6 to 4.
This permits to reduce net_conn structure of 4 bytes. Its size is as
before indroducing node attribute.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This will optimize path when unused an connection is required or when
looking up a used one.
That said, at this stage, it bloats up the net_conn structure with 4
added bytes. More optimization will overcome this drawback.
Fixes#8722
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Most of present #ifdef can be removed via using IS_ENABLED() macro.
Only small part of cache related logic still require #ifdef.
Fixes#8722
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
There were various flaws in it that motivated its removal:
- No hash collision handling mechanism. In case that would happen, the
behavior of the network connection would be unknown. This is the main
drawback
- The lookup is not that much more efficient than the default one. The
only difference of gain is in connection comparison (a u32t comparison
vs a full connection compare). But the list handling is the same. It's
made worse by the presence of a negatives match array which can be
easily filled in and becomes then fully usless, appart from consuming
CPU. As well as adding a new connection: it requires the whole cache
to be cleared which is unefficient.
- Not memory efficient, even compared to a proper hash table.
Two arrays instead of one etc...
All of this could be fixed by using a proper hash table, though it
remains to be seen if such object could fit in Zephyr core.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
During net_pkt/net_context API changes, some ip handling blocks were
ordered ipv4 first, ipv6 second. While it is the contrary everywhere
else. So reordering to get things consistent.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
- Not all #ifdef can be removed: those which have a dedicated attribute
in struct net_context.
- For CONFIG_NET_CONTEXT_CHECK: switching the NET_ASSERT_INFO to
NET_DBG (simpler to read and anyway an error code is returned)
Fixes#8725
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Partially revert commit ea177e785ca3
("usb: dfu: set bwPollTimeout dynamically")
Introduced fix does not work proper because there is no way to be
sure that a control stage had success before start erase process.
Instead IMG_ERASE_PROGRESSIVELY configuration should be used
if the erase of the flash takes longer time.
resolves: #15497
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Zephyr implementation of OpenThreads utilsFlashErasePage platform
function did not disable flash protection before calling `flash_erase`
function. This resulted in an error instead of actual flash erase on
platforms that properly implement flash write protection.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This is a follow up to commit 0eaa5e53a36af498115b4e56b1ea68cc89fc29ee.
`HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE` is a base number for two PPI
channels, so two bits need to be marked in the used channel bit mask.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
This make use of NET_IF_NO_AUTO_START flag so Bluetooth interfaces are
not automatically enabled after initialized.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fix calling bt_gatt_foreach_attr with start handle parameter set
to last static attribute handle.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The approved trademark name is Wi-Fi so update references to WiFi and
other spellings to Wi-Fi in documentation and Kconfig help strings.
(Note that use of spelling variatios of "wifi" in module names, CONFIG
names, link names and such are untouched.)
https://www.wi-fi.org/
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Due to a protracted merge of:
5e38ed9320
the naming for the HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI changed
semnatics, now requiring use of
HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Implement OpenThreads frame pending bit management on top of the Zephyrs
radio driver API. This allows for proper Sleepy End Devices handling
from the parent side.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Mark the PPI channels and groups used by the Bluetooth controller
as occupied and thus unavailable for allocation through nrfx_ppi.
Add also a build time assertion that checks if these PPI channels
do not overlap with those assigned to the pwm_nrf5_sw driver
(to replace the comments in this driver that were supposed to warn
about this threat but had in fact little chance to be read by users).
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Updated the controller implementation to not feature
exchange if already done once either by local or remote peer
device in an active connection session.
Signed-off-by: Alexander Svensen <alsv@nordicsemi.no>
Disable the unsupported controller privacy feature in the
ULL/LLL split architecture implementation.
This feature will be enabled in the future when it has been
ported to support multiple vendor SoCs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Enable the support for Zephyr HCI Vendor-Specific Commands
and Event in the ULL/LLL split architecture implementation
of the controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrectly defined Rx and Tx buffer sizes. Wrong
calculation allocated more memory than necessary.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Kconfig default values for ULL and LLL execution
priorities that caused build warnings when ranges changes
based on other priority values being selected.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect data type used in calculation of slot_us
detected by compiler, and reported as possible integer
overflow.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect conditional compilation that caused compile
error when lll_scan structure did not contain connection
context included which is needed only for central role.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix set configuration request for a configuration without
specific endpoint like USB DFU class.
The changes introduced in commit 2b58594e90
("usb: device: Use set_endpoint helper for set_config")
does not take into account that a configuration could only
contain control endpoint.
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Fix the missing reset of Encryption Procedure state when the
peripheral responded with error reason as pin or key missing
which otherwise caused connection disconnection on next
reception of data or control packet.
Relates to #15570, and #15727.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Under Unshared FP register mode we are not sharing the
FP context among different threads, so we do not need to
include the FP high registers bank in the thread.arch
container.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This is a workaround for IOP issue, where peer rejects LLCP Slave
Connection Parameter Request with LMP Error Transaction Collision
error code even if previous request is complete at the instant.
Signed-off-by: Alexander Svensen <alsv@nordicsemi.no>
Increase the resolution of advertising random delay from
1 ms unit to 1 ticker unit.
Relates to #10289, #10391, and #10398.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added prompt to BT_CTLR_RX_PRIO_STACK_SIZE, allowing vendor specific
configuration of high priority Rx thread stack size for
!SOC_COMPATIBLE_NRF.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix XTAL advanced feature by adding the missing
implementation to calculate and, retain or release the XTAL
clock source after a Bluetooth state or role is stopped.
Fixes#15817.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to toggle GPIO Debug pins on HFCLK
request and release by the controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement a lower ISR latency ULL processing design. Instead
of looping use ISR/mayfly tail-chaining to process
successive ULL messages.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implemented ULL to yield from processing in an infinite loop
if current PDU being handled is deferred.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing BT_CTLR_FILTER conditional compilations that
cause compile errors when device whitelisting feature is
disabled in builds.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Depending on optimization level, the TC_RESULT_STR[]
array could actually be placed in memory instead of
being expanded at compile time, resulting in memory
access errors from user mode.
Just replace TC_RESULT_TO_STR() with an inline function
containing a switch statement instead.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Renamed function vendor_cmd_handle to vendor_cmd_handle_common for
shared vendor commands. This allows vendor to implement
vendor_cmd_handle, containing both common and specific handling.
Signed-off-by: Morten Priess <mtpr@oticon.com>
The pkt variable cannot be NULL at this point so the check for
nullness is not needed.
Coverity-CID: 198002
Fixes#15777
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
* Rename the stack local 'done' to 'evdone' so as to disambiguate from
MFIFO_DEQUEUE_PEEK(done) which is actually 'mfifo_done'.
* add comment on ull_slave_done
* add comments to addr_us_get
* add comments to HCI_CLASS
Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
Fix the missing reset of Encryption Procedure state when the
peripheral responded with error reason as pin or key missing
which otherwise caused connection disconnection on next
reception of data or control packet.
Relates to #15570.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
settings_read_cb is defined to return ssize_t and not size_t. This
also eliminates several Coverity warnings.
Fixes#15765Fixes#15768Fixes#15771Fixes#15774Fixes#15778
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This makes use of BT_GATT_SERVICE_DEFINE to statically define services
for services that are not required to be dynamically registered.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This reintroduces support for static service in the form of a new API,
BT_GATT_SERVICE_DEFINE, and changes the internal services (GAP/GATT)
to be defined as const as they are never register/unregistered.
Internal service needed to be renamed in order to keep the same order
as before since the section elements are sorted by name.
The result is the following (make ram_report):
before:
gatt.c 572 0.66%
cf_cfg 32 0.04%
db 8 0.01%
db_hash 16 0.02%
db_hash_work 32 0.04%
gap_attrs 180 0.21%
gap_svc 12 0.01%
gatt_attrs 160 0.18%
gatt_sc 80 0.09%
gatt_svc 12 0.01%
sc_ccc_cfg 32 0.04%
subscriptions 8 0.01%
after:
gatt.c 210 0.24%
cf_cfg 32 0.04%
db 8 0.01%
db_hash 16 0.02%
db_hash_work 32 0.04%
gatt_sc 80 0.09%
last_static_handle 2 0.00%
sc_ccc_cfg 32 0.04%
subscriptions 8 0.01%
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Changed type of the paramater that determines the number of elements in
the stats group. Now it is possible to declared more than 256 elements.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Fix the nRF52840 Coded PHY radio timings based on testing
with conformance tester.
Fixes the following conformance tests:
LL/CON/MAS/BV-52-C [Master Receiving Data, LE Coded, CI Change]
LL/CON/MAS/BV-54-C [Slave Receiving Data, LE Coded, CI Change]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the regression in Coded PHY CI change implementation
introduced by reverting the commit 9d1ca9c390 ("Bluetooth:
controller: remove redundant PPI channel and TIMER CC").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
If the loopback driver is enabled, then the packet might come
from localhost in which case mark it properly. Without this marking
the packet from/to 127.0.0.1 or ::1 would be dropped in later checks.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Adding possibility to modify shell prompt in Kconfig and in prj.config
file.
Fixes#14547.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
When importing a pre compiled imported library it is currently
required to perform three steps.
This commit introduces a helper function which allows the
user to import a library with a single function call.
Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
Added Kconfig BT_MAYFLY_YIELD_AFTER_CALL to support vendor requirement
of invoking all outstanding mayflies for a given callee in
mayfly_run().
Signed-off-by: Morten Priess <mtpr@oticon.com>
In ull.c ll_rx_get, a configuration without CONFIG_BT_CONN would
sometimes return an uninitialized node_rx.
In ull_scan.c, the scanning channel was not initialized to 0 (37). This
would cause new scanning to start at random index (0,1,2).
Signed-off-by: Morten Priess <mtpr@oticon.com>
Add defines to support updated slot reservation calculation in advertise
Note: Numbers used in added defines are subject to HW specific tuning
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Added a new define (EVENT_IFS_US) to pdu.h - this is now used instead of
previous TIFS_US from vendor specific header
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Correct slot reservation time calc for legacy advertise
Add dependency on data lengths for advertise and scan response
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Fix regression by the addition of CONFIG_BT_CONN conditional
compilation that disabled the advanced clock (crystal)
oscillator management when only observer and/or advertiser
states supported in the controller build.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added check to see if CONFIG_BT_CTLR_TX_BUFFER_SIZE is defined,
and use that as the BT_L2CAP_MTU if that is the case. Otherwise,
use the previously hard coded MTU size (64). This enables users
to configure the MTU, enabling longer transfers.
The fix was inspired by how this is solved in
samples/bluetooth/hci_uart/src/main.c
Tested on nrf52840_pca10056.
Signed-off-by: Dennis Wildmark <dennis.wildmark@assaabloy.com>
Modified commands which depends on compile time flags to
use conditional macros.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added macros which can be used to create a command which depends
on compilation flag. Macros are a cleaner alternative to #ifdefs
around command registration and command handler.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Use new method for defining USB CDC ACM devices using UTIL_LISTIFY and
device count from menuconfig.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
DEVICE_COUNT for some USB classes means how many instances of the
class can be supported by USB stack.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Disable bulk slot image erase when progressive erase is on.
Erase of image bank is performed by image collection procedure
progressively.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Patch adds option for progressive erase of firmware image.
When using this, flash is erased as necessary when receiving
new firmware, instead of erasing the whole image slot at once.
This is useful on some hardware (like nRF52840) that has
long erase times, to prevent long wait times at the beginning
of the DFU process.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Refactor code making set_endpoint() helper which check validity of
input parameters.
Fix bug with usb_set_configuration() always returning true.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Major changes are:
- Expose settings backend API to enable custom backend support.
- Add a new CONFIG_SETTINGS_CUSTOM backend to allow registering a custom
backend.
- Change api of the handlers h_set() routines to allow for
backend-specific read callbacks.
- Provide a customizable settings_backend_init() routine for custom
backends.
- Move runtime settings support to be its own backend.
Signed-off-by: François Delawarde <fnde@oticon.com>
If ethernet controller has VLAN tag strip flag enabled
(ETHERNET_HW_VLAN_TAG_STRIP), L2 etherent will not read tag from
the Rx etherent header. Instead it will fetch VLAN tag from
net packet metadata.
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Allow for including arbitrary data in net_icmpv6_send_echo_request()
that will be echoed verbatim by the receiver.
This allows to use ICMP echo for diagnostic use cases, e.g. by testing
packet framentation (large payload) or measuring round-trip-time.
Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
Allow for including arbitrary data in net_icmpv4_send_echo_request()
that will be echoed verbatim by the receiver.
This allows to use ICMP echo for diagnostic use cases, e.g. by testing
packet framentation (large payload) or measuring round-trip-time.
Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
Allow accessing already parsed information from the ICMP header
that callbacks might be interested in.
This makes the callback signature and behaviour match that of
the ICMPv6 implementation.
Signed-off-by: Benjamin Valentin <benpicco@googlemail.com>
Aligned format specifiers for the Bluetooth Host. Now, the format
specifier matches the variable type.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
This patch adds support for Read Using Characteristic UUID which is one
of the procedure to read the characteristic value especially when the
client only knows the characteristic UUID and does not know the handle
of the characteristic.
Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
By selecting CONFIG_THREAD_NAME. It makes sense to have this enabled
by default for tests, to easy debugging in a case of crash.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
We need to re-initialize the trickle->timer delayed work to use
trickle_timeout() if there are multiple triggerings.
Fixes#15606
Signed-off-by: ling wei <lingwei@cisco.com>
Existing sntp_request() function has a coarse integer seconds
precision, discarding fractional part as returned by SNTP.
Deprecate it, and instead introduce sntp_query() function which
returns both integer and fractional seconds as a newly introduced
structure sntp_tstamp.
Fixes: #15596
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Previously, a case when poll() call timed out wasn't handled, and
recv() was called unconditionally. In the case of timeout, recv()
itself would hang indefinitely.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Added implementation to pause data PDU transmission during
PHY update procedure in order to comply to BT Spec. v5.1
Vol.6, Part B, Section 5.1.10.1 Packet transmit time
restrictions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor refactoring to move PKT_US into ULL internal header,
and rename ull_conn_allowed_check to ull_conn_llcp_req.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Ported implementation of Data Length Update Procedure to
ULL/LLL architecture of the Link Layer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit prevents a situation when stored and possibly modified
commissioner dataset is overwritten with default configuration during
OpenThread initialization.
It introduces a new function, openthread_start, which verifies if the
dataset is already stored, and if not, depending on configuration,
preloads the default configuration or initiates the join procedure.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If the NET_IF_NO_AUTO_START network interface flag is set, then
do not take network interface up during the initialization of the
network interface. The network device driver can set the flag in its
network interface initialization function if needed.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Provide access functions for manipulating network interface flags.
There is no need for the caller of this API to know about the inner
details of the flags.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Added bBreak, bRingSignal, bFraming, bParity and bOverRun
handling in cdc_acm_line_ctrl_set.
Reference: Chapter 6.5.4 of Universal Serial Bus Communications Class
Subclass Specification for PSTN Devices rev 1.2
Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
This introduces set command to GATT which can be used to write local
attributes:
uart:~$ gatt set 0x000b 62 6c 61 68
attr 0x004235a8 uuid 2a00 perm 0x09
00000000: 62 6C 61 68
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This introduces get command to GATT which can be used to read the
local attributes:
uart:~$ gatt get 0x000b
attr 0x004235a8 uuid 2a00 perm 0x09
00000000: 74 65 73 74 20 73 68 65 6C 6C
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This enables locating specific attribute in the database:
uart:~$ gatt show-db 0x2a00
attr 0x004235a8 handle 0x000b uuid 2a00 perm 0x09
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This introduces shell_hexdump API which can be used to print an array
such as a network buffer.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The struct _caller_saved is not used. Most architectures put
automatically the registers onto stack, in others architectures the
exception code does it.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
In non-secure Trustzone application dedicated flash non-secure
partition are used instead of regular one, which become secure
partition in Trustzone collaboration model.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
The 'Shell Options' menu contains just the 'menuconfig SHELL' menu in
the menuconfig interface.
Remove the 'Shell Options' menu and put 'menuconfig SHELL' directly in
the top-level menu instead. Also change the prompt from "Enable shell"
to just "Shell", to make it consistent with "Logging".
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Missing quotes are accepted in some places for compatibility with the C
tools, e.g.
source no/quotes/Kconfig
menu Title
It looks broken though. Fix the two places in Zephyr that skip the
quotes. A style warning will be added.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
In addition to checking that the ARP entry does not exist as the
implementation is done currently, also check if the ARP packet
is due to IPv4 link local address configuration. In both cases
use the provided IPv4 address instead of the one set for the
interface.
Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
IPv4 link local uses ARP to detect conflicting addresses. Properly
set the ethernet packet type to NET_ETH_PTYPE_ARP when probing
for address duplicates.
Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
The source address in unicast DHCPv4 Request packets was found out
to be all zeros address 0.0.0.0. This address is only acceptable if
the destination is a multicast one, where the host in question is
acquiring a DHCP address lease. This is true for the DHCP Discover
and the initial DHCP Request message from the client towards the
server. As subsequent DHCP Request renewal messages are sent as
unicast to the server, the server will drop such packets.
Fix this issue by explicitely specifying what source IP address is
to be used, if none is specified, the all zeros address 0.0.0.0 is
used in multicast addresses. The source address in the other
unicast cases is identical to the 'ciaddr' in the DHCP message.
Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
General MIC fix for AAD lengths up to 14 bytes.
This case doesn't concern the mesh stack because it uses 16 bytes.
Signed-off-by: Reham Tarek <reham.tarek@si-vision.com>
This stores the database hash and check if it has changed on commit
skipping service changed if hash matches.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Custom handlers without any arguments don't since there is a check for
argc > 1, to fix this behavior removing the check.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If handle is over the range end return since handles are always placed
in ascending order.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This reduces bt_gatt_foreach_attr complexity (O(n)) so it can skip
ahead when the start handle is not within its service handles.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
It may be very important information for the developer if scanning
fails to start or stop, so add proper logs. There's no need to log
EALREADY errors, since the mesh stack doesn't track the current scan
state and simply relies on the under lying GAP layer to return this
error if the desired state is already set.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
bt_gatt_connected should be only called, when there is no
connection error. Change fixes problem with receiving notifications
before connection.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Set bwPollTimeout for DFU_GETSTATUS request dynamically.
For now, adjust bwPollTimeout only during DNLOAD stage.
Fixes: #8734
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Drop mode in RTT backend was broken. It is not the default
one so most likely it was unnoticed for a long time. Fixed
to report drop message when logs are lost.
Additionally, added assert to ensure that memmove does not
do memory overwrite.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
If for some reason the DNS resolver callback is not called properly
then make sure that semaphore will not block forever.
Fixes#15197
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The commit 8d0ef1eb85 attempted to fix
test case MESH/SR/HM/CFS/BV-02-C, however inadvertently ended up
introducing a hidden bug. This bug was unearthed thanks to commit
686f5c79cf. We have to keep always track
of the FastPeriodDivisor state whether we're using it (faults > 0) or
not (faults == 0). Introduce a boolean field to the model publication
that's used to indicate whether the FastPeriodDivisor should be
applied or not, instead of zeroing the divisor when there are no
faults (this would cause wrong behavior when faults appear again).
Additionally, the PTS seems to require that we wait until the end of
the existing period before sending the next Health Current Status,
rather than sending it immediately when the fault count changes.
Fixes#15365
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Only enable netusb for the right configuration of interface and
alt_setting.
Fixes#13560
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Include to the callback parameters also alt_setting to be able to make
right choice for ECM.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Fix the controller implementation to make start encryption
queueable if there is any control procedure in progress.
The context related to encryption procedure is now shared so
that it will be used after the ongoing procedure completes.
The fix here maintains the old functionality of serializing
the queued data and LL Encryption Request PDU, so that data
queued before start encryption is acknowledged.
Fixes#15012.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When VLAN is enabled, ethernet l2 layer fills ethernet header
but not added to the network buffer.
Fixes#15346
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Implement the Controller counterpart to CONFIG_BT_WAIT_NOP so that it
issues a NOP Command Complete event after booting up, to signal to the
Host that it is ready to receive HCI traffic.
Fixes#15333
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When a device is considered unpaired any configuration set in Client
Features shall also be removed.
Fixes#15329
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes an issue where if timestamp == service_due_timestamp,
we don't call the periodic service. Then the following call to
engine_next_service_timeout_ms() returns 0 because the service
is still due and lwm2m_engine_service() is called again.
This process repeats several times until the value of
k_uptime_get() changes and then the work is finally handled.
Previously, the resolution of k_uptime_get() was in ms. A recent
change to this API defaults Zephyr so that the resolution is
set via CONFIG_SYS_CLOCK_TICKS_PER_SEC (default 100).
This means the value of k_uptime_get() only changes every 10ms.
Reported-by: Github User pieterjanc
Signed-off-by: Michael Scott <mike@foundries.io>
"It's a Trap!" -- Admiral Ackbar
When moving to the BSD-socket APIs, the original thread running LwM2M
periodic services such as observes and lifetime updates, was replaced
with a re-occuring workqueue job. To save the overhead of creating a
new thread, I used the system workqueue for these jobs.
This was a mistake. If these jobs hit a semaphore or wait for some
reason, it cannot be prempted due to the priority of the system work
queue.
Let's instead add this service handling to the thread that we already
use for polling sockets. This also removes a configuration issue where
the system workqueue stack size needed to be increased. This can now
be adjusted via the LWM2M_ENGINE_STACK_SIZE knob.
Directly fixes semaphore usage in the socket-based DNS code.
This was introduced as a bugfix for non-responsive DNS server hanging
the Zephyr device forever. However, this probably fixes randomly
seeming hangs on the device.
Signed-off-by: Michael Scott <mike@foundries.io>
Send unknown rsp instead of asserting when encryption related control
PDUs are received in the wrong state.
This would allow an attacker to intentionally crash the device.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Stop the Length request procedure from initiating during the encryption
procedue. This would cause the peer to disconnect the link with error
code LMP_TRANSACTION_COLLISION
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Set the encryption procedure pending and start it as soon as
there are no other procedures running.
This allows the Host to enqueue the encryption procedure, and not
get disallowed command because a different LL procedure is active.
Fixes#15012
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When calling bt_unpair() the keys were removed from flash, however a
pointer was left to the invalidated keys in case there was an existing
connection. This would then lead to a bogus entry being stored in
flash for a zero-address peer device. Fix this issue by clearing the
conn->le.keys pointer in the bt_unpair() function.
Fixes#15325
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The bt_mesh_fault_update() API is meant for updating the publication
message and sending it out to the network, however it was missing the
necessary call to health_pub_update() which is responsible for
updating the publication message.
Fixes#15300
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Increase the default mgmt event stack size from 512 to 768 because of
stack overflows.
Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
A transport may receive multiple bytes of data between shell_thread
wakeups, but state_collect is only called once per wakeup. So it must
process all data, and only return when all data from the transport has
been consumed. This is mostly handled correctly, but there were two
places where state_collect would return early instead.
Signed-off-by: Jim Paris <jim@jtan.com>
Fixes:
.../zephyr/subsys/bluetooth/shell/bt.c:906:12:
warning: 'cmd_chan_map' defined but not used [-Wunused-function]
Signed-off-by: Jim Paris <jim@jtan.com>
Persistent storage is done. So are the configuration and health
clients. We're also not actively looking to optimize the provisioning
protocol & mesh networking memory usage anymore.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier. Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.
By default all files without license information are under the default
license of Zephyr, which is Apache version 2.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Unlike CONFIG_HW_STACK_PROTECTION, which greatly helps
expose stack overflows in test code, activating
userspace without putting threads in user mode is of
very limited value.
Now CONFIG_TEST_USERSPACE is off by default. Any test
which puts threads in user mode will need to set
CONFIG_TEST_USERSPACE.
This should greatly increase sanitycheck build times
as there is non-trivial build time overhead to
enabling this feature. This also allows some tests
which failed the build on RAM-constrained platforms
to compile properly.
tests/drivers/build_all is a special case; it doesn't
put threads in user mode, but we want to ensure all
the syscall handlers compile properly.
Fixes: #15103 (and probably others)
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
We need all the socket APIs to work from user mode.
tests/net/socket/misc now runs in userspace.
Fixes: #15227
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This macro is slated for complete removal, as it's not possible
on arches with an MPU stack guard to know the true buffer bounds
without also knowing the runtime state of its associated thread.
As removing this completely would be invasive to where we are
in the 1.14 release, demote to a private kernel Z_ API instead.
The current way that the macro is being used internally will
not cause any undue harm, we just don't want any external code
depending on it.
The final work to remove this (and overhaul stack specification in
general) will take place in 1.15 in the context of #14269Fixes: #14766
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
The fix done in #14938 introduced a later assert when raising an HCI
event for the procedure that was terminated during the procedure
collision handling. This assert happens because the unknown rsp
has information that is needed when raising the event.
Solve this by copying the scratch packet into the node buffer so that
we keep the data.
Fixes#15183
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Merge cb_usb_status_composite and cb_usb_status and use common
forward_status_cb for both composite and normal devices.
Fixes#14882
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
We renamed _sys_trace_thread_switched_in to
z_sys_trace_thread_switched_in, however we already had a function
named z_sys_trace_thread_switched_in. So rename z_sys_trace... to
z__sys_trace...
Fixes: #15184
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
for SDK 0.10.0, it consumes more stack size when coverage enabled
on qemu_x86 and mps2_an385 platform, adjust stack size for most of
the test cases, otherwise there will be stack overflow.
Fixes: #14500.
Signed-off-by: Wentong Wu <wentong.wu@intel.com>
Rename reserved function names in the subsys/ subdirectory except
for static _mod_pub_set and _mod_unbind functions in bluetooth mesh
cfg_srv.c which clash with the similarly named global functions.
Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
Rename reserved function names in drivers/ subdirectory. Update
function macros concatenatenating function names with '##'. As
there is a conflict between the existing gpio_sch_manage_callback()
and _gpio_sch_manage_callback() names, leave the latter unmodified.
Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
The legacy struct s_coopFloatReg was never being used, though it was
an empty struct (not wasting space), some symbols were being generate
for it.
Nevertheless, neither C99 nor C11 allow empty structs, so this
was also a violation to the C standards.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
DNS is not part of L3, but as dhcpv4 or the net shell, it is a services
on top of the network stack. So let's gather all in a dedicated
function.
This also rework the order when starting the DNS service. There was an
issue for offload device: these would be fully initialized in
init_rx_queues() which was called after l3_init. l3_init had already
started dns: which would not be able to bind correctly, proving to be
fully dead afterwards. Instead, starting the dns at the very end
ensures that all is initialized properly from devices to stack.
Fixes#15124
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
With or without options headers it has to work. Currently it was
setting always hop-by-hop next header which is obviously wrong but
worked on ipv6_fragment test since that one has only packets with
optional headers (hop-by-hop in that case has to be the first optional
header).
Fixes#14622
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
The spec allows to set to no specific value with use of 0xffff.
As this still enables entering values in the invalid range, 3200-65535
for min/max interval, this adds the necessary build checks to prevent
values within this range to be used and at same time check if min
interval is not bigger that max interval.
Fixes#15017
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This is to fix build errors complaining about undefined reference
to __gcov_exit(). There is no special processing required here
so leave the function empty.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
In order to advertise directed to a privacy enabled central the
initiator field of the directed adv packet needs to set to an RPA.
To instruct the controller to use an RPA in the initiator field own
address type should be set to either 0x02 or 0x03.
Since it is not certain that a remote device supports address resolution
of the initiator address we add an option to turn this on and give the
application the responsibility to check if peer supports this.
Fixes#14743
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
If the TCP segment is not sent properly by L2, then do not mark
it "not sent" in net_if.c:net_if_tx(). That "not sent" marking
confused TCP ref counting in tcp.c:tcp_retry_expired() and caused
the packet to be freed too early which then caused free net_buf
access issue during packet resend. This free memory access was
seen with zperf sample application.
From TCP point of view, the packet can be considered sent when
it is given to L2. The TCP timer will resend the packet if needed.
Fixes#15050
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This reverts commit 9cd547f53b.
The commit we are reverting, fixed originally the issue that was
seen with zperf. There we freed the net_pkt too early while it was
still waiting for a TCP ACK. The commit 9cd547f5 seemd to fix that
issue but it was causing issues in dump_http_server sample app which
then started to leak memory. No issues were seen with echo-server
with or without the commit 9cd547f5.
So the lessons learned here is that one needs to test with multiple
network sample apps like dump_http_server, echo_server and zperf
before considering TCP fixes valid, especially fixes that touch
ref counting issues.
Fixes#15031
The next commit will fix the zperf free memory access patch.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
In order to accept string of the same size entered in
CONFIG_BT_DEVICE_NAME_MAX an extra byte must be allocated to guarantee
it will always be NULL terminated.
Fixes#15067
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add TELNET backed for shell module. The TELNET implementation is based
on the telnet_console driver.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
There's no need to track this info in prov.c since hci_core.c is
already doing it. Just query hci_core.c always using the
bt_pub_key_get() API.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
If PB-GATT is disabled while there are connected clients, those
clients must be disconnected. Add a 'disconnect` parameter to
bt_mesh_proxy_prov_disable() to handle scenarios when we don't want to
disconnect (e.g. right after successfully finishing provisioning) and
tose where we do want to disconnect (e.g. user requesting to disable
the provisioning bearer).
Also make sure that we always update advertising, so that a stale
advertising set isn't left in the controller.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
If both PB-ADV and PB-GATT are supported, we need to properly
re-initialize variables such as link.rx.prev_id and (particularly
importantly) link.rx.buf. If we don't do this it may lead to the
following fault when trying to reprovision again:
***** USAGE FAULT *****
Illegal use of the EPSR
***** Hardware exception *****
Current thread ID = 0x20001f10
Faulting instruction address = 0x0
Fatal fault in thread 0x20001f10! Aborting.
Fixes#14928
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Remove unnecessary const keywords (the entire struct is const) and use
bool instead of u8_t for the require_link member.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Using settings_delete() makes it much easier to understand what the
code is doing, and actually also reduces the amount of code.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add error checking, remove redundant code, and improve the logging for
settings related functionality.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The read() callback of attributes returns ssize_t and not size_t. Fix
this, which also fixes a Coverity warning.
Fixes Coverity CID 197457
Fixes#14958
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The convention in the code is to use the appropriate address copying
functions instead of direct assignments. Even when a specific copying
function doesn't exist the convention is to use memcpy.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The master is using unknown rsp to terminate slave side initiated
procedures that has collided with the encryption procedure initiated by
the master.
We need to handle an unknown response that is sent in unencrypted during
the encryption procedure, even though we have already set up to receive
encrypted packets.
Fixes#14044
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Updating the Resolvable Private Address when advertising and
active scanning in progress fails and clears the RPA_VALID
flag; making the next bt_le_scan_start while continuing to
advertise to fail.
This is fixed by keeping the RPA_VALID flag remain set.
Stopping and starting active scanning to update RPA can be
implemented in a separate commit.
Fixes#9463.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Replaced by the new CONFIG_LOG system.
Also remove the "Logging Options" menu and turn the LOG symbol into a
'menuconfig', with prompt "Logging", which appears in the top menu. LOG
and its dependent symbols make up all of the logging Kconfig symbols
now.
Piggyback some minor cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
This patch increases size of acl_tx_pool and makes sure that acl_read_cb
waits for available buffers.
Size of acl_tx_pool is now configurable with CONFIG_BT_CTLR_TX_BUFFERS.
Previously it was possible to run out of buffers and in that case
acl_read_cb returned. This caused ACL data TX to stall because device
did not read data from HCI out endpoint.
Fixes#14899
Signed-off-by: Matias Karhumaa <matias.karhumaa@gmail.com>
RTT backend supports two modes blocking and drop. Apparently,
defines used lead to warning while clang compilation. Define
that caused warning has been changed together with clean up
which removed #ifdefs for definitions.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Rename power managment subsystem Kconfig options describing minimum
residency to make them easier to identify with respective policy.
Following is a detailed list of string replacements used:
s/SYS_PM_SLEEP_(\d)_MIN_RES/SYS_PM_MIN_RESIDENCY_SLEEP_$1/
s/SYS_PM_DEEP_SLEEP_(\d)_MIN_RES/SYS_PM_MIN_RESIDENCY_DEEP_SLEEP_$1/
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
Add SYS_POWER_ prefix to HAS_STATE_SLEEP_, HAS_STATE_DEEP_SLEEP_
options to align them with names of power states they control.
Following is a detailed list of string replacements used:
s/HAS_STATE_SLEEP_(\d)/HAS_SYS_POWER_STATE_SLEEP_$1/
s/HAS_STATE_DEEP_SLEEP_(\d)/HAS_SYS_POWER_STATE_DEEP_SLEEP_$1/
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
This commit cleans up names of system power management functions by
assuring that:
- all functions start with 'sys_pm_' prefix
- API functions which should not be exposed to the user start with '_'
- name of the function hints at its purpose
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
There exists SoCs, e.g. STM32L4, where one of the low power modes
reduces CPU frequency and supply voltage but does not stop the CPU. Such
power modes are currently not supported by Zephyr.
To facilitate adding support for such class of power modes in the future
and to ensure the naming convention makes it clear that the currently
supported power modes stop the CPU this commit renames Low Power States
to Slep States and updates the documentation.
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
When building ticker.c from the shell, it requires include access to the
Nordic HAL, so add the relevant folder to the include path.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
CONFIG_PM_LOG_LEVEL was renamed to CONFIG_SYS_PM_LOG_LEVEL in commit
c45961daae ("power: Rework OS <-> Application interface"), but the old
name is still used here. Fix the name.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
The network packet ref count was not properly increased when
the TCP was retried. This meant that the second time the packet
was sent, the device driver managed to release the TCP frame even
if we had not got ACK to it.
Somewhat long debug log follows:
The net_pkt 0x08072d5c is created, we write 1K data into it, initial ref
count is 1.
net_pkt_write: pkt 0x08072d5c data 0x08075d40 length 1024
net_tcp_queue_data: Queue 0x08072d5c len 1024
net_tcp_trace: pkt 0x08072d5c src 5001 dst 5001
net_tcp_trace: seq 0x15d2aa09 (366127625) ack 0x7f67d918
net_tcp_trace: flags uAPrsf
net_tcp_trace: win 1280 chk 0x0bea
net_tcp_queue_pkt: pkt 0x08072d5c new ref 2 (net_tcp_queue_pkt:850)
At this point, the ref is 2. Then the packet is sent as you see below.
net_pkt_ref_debug: TX [13] pkt 0x08072d5c ref 2 net_tcp_queue_pkt():850
net_tcp_send_data: Sending pkt 0x08072d5c (1084 bytes)
net_pkt_unref_debug: TX [13] pkt 0x08072d5c ref 1 (ethernet_send():597)
Ref is still correct, packet is still alive. We have not received ACK,
so the packet is resent.
tcp_retry_expired: ref pkt 0x08072d5c new ref 2 (tcp_retry_expired:233)
net_pkt_ref_debug: TX [10] pkt 0x08072d5c ref 2 tcp_retry_expired():233
net_pkt_unref_debug: TX [10] pkt 0x08072d5c ref 1 ... (net_if_tx():173)
net_pkt_unref_debug: TX [10] pkt 0x08072d5c ref 0 ... (net_if_tx():173)
Reference count is now wrong, it should have been 1. This is because we
did not increase the ref count when packet was placed first time into
sent list in tcp.c:tcp_retry_expired().
The fix is quite simple as you can see from this commit.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
With BT_HOST_CRYPTO, advertising stack size could be overflowed,
increase size to 1024 when BT_HOST_CRYPTO is enabled.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This patch fixes following issues.
* If IPv6 neighbor table is full, stack can not add any new
neighbors. So stale counter is introduced. Whenever neighbor
enters into STALE state, stale counter will be incremented
by one. When table is full and if stack wants to add new
neighbor, oldest neighbor in STALE state will be removed
and new neighbor will be added.
* When neighbor is in PROBE state and when it exceeds max
number of PROBEs, only neighbor with router is removed.
As per RFC 4861 Appendix C, entry can be discarded. Now
neighbor will be removed from the table.
* Reachability timer has an issue. e.g. if a first entry timer
is 10 seconds, after 3 seconds, a new entry added with
only 3 seconds. But current implementation does not check
whether remaining time of current left over timeout is more
than new entry timeout or not. In this example, when new entry
timeout is 3 seconds, left over timeout from first etnry is
still 7 seconds. If k_delayed_work_remaining_get() returns
some value then new entry time out was not considered.
Which is bad. It fixed now.
* nbr_free is used sometimes to remove the neighbor. Which does
not remove route if that particulat neighbor is route to some
other neighbor. net_ipv6_nbr_rm() should be used in such places.
* Trivial changes which does not affect functionality.
Fixes#14063
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Shell was selecting logger option which lead to define
CONFIG_LOG_RUNTIME_FILTERING generation even though log
was disabled. That messed up logger and lead to compilation
failure.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Fix regression and allow incoming packet when source and
destination port numbers are the same.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
In case of Ethernet for instance, the MTU is larger than the minimal
IPv6 MTU, so it is not required to fragment a packet that fits in
Ethernet MTU.
Fixes#14659
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Command scan fixed in the way that it can take one mandatory parameter
and one optional. Previously it accepted only 2 mandatory parameters.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Removed automatic argument count checking in bt command. Now
it is possible to print a message that extra argument is not
recognized.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
It is invalid to try to bit shift the same amount of bits as
what is the number of bits in the left expression’s type.
Coverity-CID: 187079
Fixes#8988
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Use ringbuf library for handling RX CDC ACM path. Remove old code
artifacts handling specific hardware.
Fixes#14288
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Several public APIs were not checking the BT_DEV_READY flag, which
could lead to hard-to-debug behavior, particularly when the stack
lacks an identity address. Add the appropriate checks to these APIs.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The treatment of the BT_DEV_READY flag was broken when used together
with BT_SETTINGS. The flag would get set even though the stack was
still in a partially initialized state. Even worse, for central role
the stack would potentially try to initiate passive scanning without
having an identity address.
Refactor the code that sets the BT_DEV_READY flag (among other
initialization) into a separate bt_finalize_init() helper function and
call it when the settings have been loaded. Also clarify the warning
message given to the user in case settings_load() needs to be called.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The code for checking duplicates in the existing settings store was
incorrectly identifying a new value with the same initial content but
shorter length as a duplicate. Fix this by doing an early check on a
new vs old length mismatch, and immediately flag this as not a
duplicate.
Fixes#14840
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Enforce that NULL value is never given with a non-zero length. This
way we don't need to check this over and over again further down the
call path.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix a bug where the controller would use the length
field of the advertisement packet before checking
if the length field was valid.
It is possible that the controller has received a packet
that passes CRC check but has a length field that is invalid.
This would cause the scanner to overwrite the scan report
buffer
Fixes: #14741
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Remove old unused code sending media status, sending this packet
causes Windows problems although Linux works with it. Removing this
code does not affect RNDIS functionality.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Use standard NET_ETH_MAX_FRAME_SIZE for frame size calculation. This
changes buffer from 1522 to 1514 + 2 + 4. Remove also magic numbers.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Use standard defined frame size for buffer and wMaxSegmentSize
parameter. Changes frame size from 1522 to 1514.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
The code for clearing model bindings and subscriptions was flawed in
that proper "cleared" entries were never stored in settings. The code
must pass 0 and NULL to settings_save_one() in case the entry is
desired to be cleared.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The code was storing a "cleared" entry in storage for every model,
regardless of them having any subscriptions or not. Update hte
mod_sub_list_clear() function to return a "cleared entries" count so
that the calling code can decide whether any action is needed or not.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Remove redundant "val (null)" logs and add a few missing BT_DBG()
calls to make the tracing of storage handling easier.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The le_conn_param_req() function was missing a return statement in
case of a failed connection lookup. This could lead to replying to the
connection parameter request twice as well as passing NULL to
bt_conn_unref(). The latter issue also triggered a Coverity warning.
Fixes CID 196638
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The "is this packet for us?" filter in net_ipv4_input() has a minor
logic error which fails to discard many packets which are.. not for us.
Fixes: #14647
Signed-off-by: Charles E. Youse <charles.youse@intel.com>
Patch removes dead, replaced code which was accidentally not
removed within the stream-codec PR #9521.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
The context_alloc_pkt() might run out of memory, and if that
happens we must not try to set the context pointer in it.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If CONFIG_LOG_IMMEDIATE is enabled, then we need to handle
the output strings using a different output function.
The issue was noticed with native_posix board where no syslog
output strings were sent to network.
Fixes#14661
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
We are reverting the changes in commit
55b3f05932 given build errors are seen
when fcntl.h is included, as it declares fcntl() as a non-static
function. The same function cannot be declared as both static and
non-static.
Instead, we avoid redefining fcntl() in lib/os/fdtable.c specifically
for case of the SimpleLink family, til we have support for the new
socket_op_vtable.
Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
Since the new packet flow came in, payload comes at the end so udp
length for instance is known only when we "finalize" the packet.
However such finalization was still under the condition of chksum
offload, like it used to be in the former flow (udp headers were
inserted). This is obviously wrong but that was not caught with
existing driver in master as none of these drivers offloading
chksum calculation.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Commit fc27a81ed2 ("net: context: Select proper network interface
when binding") moved the bind_default() call to after the remote
address was set for the net_context.
This and a later net_pkt API refactor broke net_offload() handling
so that context->iface wasn't set and context->flags didn't have
NET_CONTEXT_REMOTE_ADDR_SET correctly.
Let's fix this by relocating the net_offload handling to after
these have happened.
Signed-off-by: Michael Scott <mike@foundries.io>
Some places were still using the old allocator. Using the new one does
not change any behavior. This will help to remove the useless data_len
attribute in net_pkt which legacy allocator was still setting.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
net_offload API is left untouched, so it still takes a net_pkt as input
for the buffer. This is under-optimized since offload drivers will copy
the data from that net_pkt back into contiguous buffer again.
Let's tackle this issue another time.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This attribute, in case CONFIG_NET_STATISTICS is enabled, made sense
when L2's send() function did not return the length of the sent packet.
But now, it's a superflous optimization as is it used only to set the
stats on recv or send, where net_pkt_get_len() can be used directly.
This helps to save 2 bytes from struct net_pkt.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
And also to the relevant callbacks.
That parameter is not used anywhere so it is useless.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Seems like a useless attribute. Since net_context is not being used by
the user directly (socket is the unique interface now) and since no core
parts uses the token parameter of net_context API: let's remove the
attribute.
This helps to save 4 bytes from struct net_pkt.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Now that legacy - and unrelated - function named net_pkt_get_data has
been removed, we can rename net_pkt_get_data_new relevantly.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
That function was responsible for allocating new buffer element, but it
is now unused and can be removed safely. Buffer allocation is now done
via net_pkt_alloc_buffer().
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Now that legacy functions are removew, let's rename the new functions by
removing the _new suffix.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
There is no need for these anymore: all is dictated by the position of
the net_pkt's cursor now
- actual cursor position is like the former appdata attribute
- net_pkt_remaining_data() is like the former appdatalen attribute
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Former net_context_send/sendto and net_context_create_ipv4/ipv6 are now
unused and can be removed.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
In case of corrupted key in settings, error message is shown. However,
the key name is lost by logger if it is not explicitly copied.
Signed-off-by: Filip Kubicz <filip.kubicz@nordicsemi.no>
Log RTT backed is using mutex for locking access to RTT data.
RTT console (which by default is used by printk) writes to
RTT data directly and it cannot use mutex because it can be
called from any context (including interrupt). If both
modules access RTT buffer 0, data can be corrupted.
This patch forces LOG_PRINTK option if RTT backend is used to
ensure single point of access to RTT buffer 0 data.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
BT_WARN() should only be used for log messages that may indicate a
problem. However, the controller HCI code was using it for messages
that were of a pure debugging/informational nature. Convert these to
BT_DBG() instead - this should hopefully also help avoid unnecessary
user questions of seemingly alarming log messages.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Introduce API for get driver structure belongs to the flash_area.
Some more complex operation on flash areas might want to be done using
driver directly. It not make sense to wrap every possible flash related
operation by flash_map API.
For instance mcuboot will require this patch.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
The 2M and Coded PHY bit should not be set when the
PHY update procedure is not supported.
Fixes#14658
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
IPv6 next header might be something else (here NET_IPV6_NEXTHDR_HBHO)
but when finalizing it is mandatory to give the actual last header
protocol type. In this case IPPROTO_ICMPV6, so the checksum can be
computed properly then by net_icmpv6_finalize() called from
net_ipv6_finalize().
Fixes#14663
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Peer side will disconnect if controller initiates
Encryption procedure before PHY update procedure
has finished.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
As the L2 layer might have modified the cursor, reset it here
before giving the packet to promiscuous mode API. This way
the application will get a fresh copy of the buffer.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Backend was not initialized to work in synchronous mode if LOG_IMMEDIATE
was enabled. That causes use of rtt_lock which uses mutex. That lead to
assert in application.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
TCP context is now created with refcount of 2, signifying that it's
jointly owned by an app and stack. Thus, net_context_put()
unconditionally calls net_context_unref() to decrement refcount on
app's behalf, and leaves stack's refcount to internal routines
which handle sending/receiving/timing out FINs, etc.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
TCP context is effectively owned by both application and the stack:
stack may detect that peer closed/aborted connection, but it must
not dispose of the context behind the application back. Likewise,
when application "closes" context, it's not disposed of immediately,
there's yet closing handshake for stack to perform.
This effectively means that TCP contexts have refcount of 2 when
they're created. Without this change, following situation is
possible: peer opens connection, an app get a context (or socket)
via accept, peer sends data, closes connection. An app still holds
a reference to connection, but stack may dispose of context, and
even reuse it for a new connection. Then application holds a reference
to either free, or completely different context.
This situation was very clearly and 100% reproducible when making
Zephyr port of open62541 library, which works in async manner using
select().
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Fix bug in LL encryption procedure, controller was
using the wrong pointer to connection state.
Function event_enc_prep is called from
slave_event_prepare, where _radio.curr_conn has not
been assigned yet.
The connection ended up sending LL_START_ENC_RSP
unencrypted, resulting in disconnect on the peer
side with reason MIC failure.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
To save binary size, currently just returns textual name of error
code, e.g. EAI_FAIL -> "EAI_FAIL". Based on real usecases, can be
replaced with user-friendly message later. (Current usecase is to
allow/help to elaborate sockets API by proof-of-concept porting
existing socket apps).
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Normally, this bug wasn't apparent as the value is type-casted
to a float32/64 type. However, once we start persisting these
values they need the correct length.
Signed-off-by: Michael Scott <mike@foundries.io>
Let's avoid future compile issues with this macro when passing
in a type-casted value that isn't surrounded by parenthesis.
Signed-off-by: Michael Scott <mike@foundries.io>
Occasionally we see a stack crash in LwM2M. This may have been
due to the swap from net_app APIs to socket-based APIs.
Let's raise the default stack by 1k.
Signed-off-by: Michael Scott <mike@foundries.io>
When a context is closed to a server, we should clean up any
existing observes along with it. Otherwise these will try to fire
afterward.
Signed-off-by: Michael Scott <mike@foundries.io>
We are already in sm_do_registration(), there's no need to check
!sm_is_registered(). Either we are performing a full registration
or a registration update. In both cases, sm_send_registration()
is called.
Signed-off-by: Michael Scott <mike@foundries.io>
If an error is received during registration update, we need to reset
the status so that a full registration is performed. This was
incorrectly being set to ENGINE_REGISTRATION_SENT.
The correct status should be: ENGINE_DO_REGISTRATION
Signed-off-by: Michael Scott <mike@foundries.io>
send() returns -1 upon error and sets errno appropriately. Let's
not bother saving the return code and instead share errno back
to the user.
Signed-off-by: Michael Scott <mike@foundries.io>
This didn't compile if CONFIG_SHALL_ECHO_STATUS wasn't
enabled.
Based on a fix by Rodrigo Peixoto.
Fixes: #14546
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
when building with clang we get the following warning:
log_core.c:358:40: error: use of logical '&&' with constant operand
[-Werror,-Wconstant-logical-operand]
This is because we are mix a constant IS_ENABLED(CONFIG_LOG_IMMEDIATE)
with non-constants.
Split out the check into its own statement to workaround the warning.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Fix implementation to correctly return the configured
default Tx Power Level.
Also, fix the missing use of RADIO_TXP_DEFAULT in the new
ULL/LLL implementation of Advertiser and Observer states.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation in controller to use range delay
alongwith the active clock accuracy jitter.
Range has been hard coded to 1000 meters, suffices
modules out in the market.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Due to regression the option to enable PHY Update Procedure
on proprietary 2M PHY for nRF51 series was disable.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Workaround from asserting when Rx PDU buffers from pool
needing resize is acquired by another connection. By
skipping the connection events to give some headroom for
the host to process the Rx packets and eventually make the
pool available for resize.
Fixes#11841.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Linking to API material requires knowing the pecularities of how
doxygen, sphinx, and breathe work. In an attempt to hide some of this
we're preparing the current docs to allow use of configuration defaults
that will let us more simply use a default role that will hunt for a
reference target in the various domains that are available by using a
default "role" of "all". This will let us use the simple notation
`functionname` or `typename` without fully specifying the reference as
:c:func:`functionname`.
This patch cleans up exising docs that were (incorrectly) using single
backtics where double backtics should have been used, and also found
some typos (such as a space between the role name and the reference,
such as :file: `filename`, and a missing colon such as
c:func:`functionname`)
This is a start to address issue #14313
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
There's a BT_DBG that will output the value of pub_addr before its ever
set to anything. Remove output of pub_addr from BT_DBG().
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add framework for device Idle Power Management(IPM)
for suspending devices based on device idle. This will
help in saving power even while system(CPU) is active.
The framework uses device_set_power_state() API set the
device power state accordingly based on the usage count.
Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
The existing device_set_power_state() API works only in synchronous
mode and this is not desirable for devices(ex: Gyro) which take
longer time (few 100 mSec) to suspend/resume.
To support async mode, a new callback argument is added to the API.
The device drivers can asynchronously suspend/resume and call the
callback function upon completion of the async request.
This commit adds the missing callback parameter to all the drivers
to make it compliant with the new API.
Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
This adds BT_GATT_DISCOVER_ATTRIBUTE which can be used to discover any
type of attribute in a given range.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Those are not considered Descriptors and shall be discovered with
use of BT_GATT_DISCOVER_CHARACTERISTIC.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When discovering descriptor Find Information procedure is used which
does not allow any filtering by the server so it will return all
attributes in the given range including services and characteristics.
Fixes#14265
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Maybe this is some "just in case" thing that got copied around. There's
no need to have a blank line at the beginning or end of Kconfig files.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
The socket-can code expects to have "struct can_frame" from
application when it calls send(). We then have to convert to
"struct zcan_frame" as that is what the driver expects.
Same thing when receiving data. We just convert to
"struct can_frame" and pass that to application.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Use USB transfer API for data transfer. Simplify notification count,
removing delayed work, use usb_transfer() logic instead.
Fixes#14127
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Use reverse order for bitfields on big-endian architectures. Treat
all PDU data as little-endian and add conversions as needed. Treat
access address as 4-byte value instead of u32_t to avoid flipping
endianness.
Signed-off-by: Wolfgang Puffitsch <wopu@oticon.com>
By specifying the controller directly when selecting the default
BT_HCI_TX_STACK_SIZE, an external controller may rely on the final
default value when none of the in-tree controllers are used.
The value is increased to 1024 to accomodate the current worst-case
stack size.
Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
This moves the vendor-specific HCI command/event configuration
definitions out of bluetooth/common into bluetooth. This allows
the controller itself to indicate its support for vendor-specific
commands/events.
Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
Remove use of select to "force" enabling other configs in subsys/fs
and subsys/net/l2. The forcing will cause infinite kconfig recursion.
Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
Now that IPv4 options are handled, ICMPv4 echo reply must be created
taking into account that IPv4 header length can be variable. So instead
of cloning and rewriting (that would copy the useless options), let's
allocate and copy only the payload.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
IPv4 header length might be bigger than struct net_ipv4_hdr if there are
options appended to it.
Fixes#11618
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
IPv4 header might come with options, unlike IPv6, these are not
encapsulated in option header but are fully part of the IPv4 header.
Zephyr must handles these. Now silently ignoring their content and
setting the cursor to the payload properly.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This is probably the only place where net_pkt_alloc_from_slab() is going
to be used.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This is meant for very particular use case as only logging uses that.
Where it makes entirely sense for it to send the logs through its own
slab/pool in order to not drain the core slabs/pools.
So enabling the new API to manage that. That has to be used with
net_context for the buffer pool. So one has to first allocate the
net_pkt from external slab, set the context and then (and only then)
allocate buffer. Basically, only net_context will uses that scheme
anyway.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Update reserved function names starting with one underscore, replacing
them as follows:
'_k_' with 'z_'
'_K_' with 'Z_'
'_handler_' with 'z_handl_'
'_Cstart' with 'z_cstart'
'_Swap' with 'z_swap'
This renaming is done on both global and those static function names
in kernel/include and include/. Other static function names in kernel/
are renamed by removing the leading underscore. Other function names
not starting with any prefix listed above are renamed starting with
a 'z_' or 'Z_' prefix.
Function names starting with two or three leading underscores are not
automatcally renamed since these names will collide with the variants
with two or three leading underscores.
Various generator scripts have also been updated as well as perf,
linker and usb files. These are
drivers/serial/uart_handlers.c
include/linker/kobject-text.ld
kernel/include/syscall_handler.h
scripts/gen_kobject_list.py
scripts/gen_syscall_header.py
Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
This patch introduce logging to settings.
Error in stored data record might occurred in runtime, so
better to switch assertion to error logging.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Though core system is able to manage packet timestamping internaly (gptp
requires it for instance), it might be necessary to enable/disable
packet timestamping from net context directly.
Currently this will be only used by the tx timestamp test. So this
support is disabled by default. (And gptp does not require it anyway).
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This is required if traffic class is enabled, so allocated packets from
net_context do get the right priority set.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
That can be useful on some tests which will not have any interface but
still allocate net_pkt. Also, one may allocate a packet with buffer not
knowing yet the interface it will be send through.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Appears within an 'if IMG_MANAGER'.
'if FOO' is just shorthand for adding 'depends on FOO' to each item
within the 'if'. Dependencies on menus work similarly. There are no
"conditional includes" in Kconfig, so 'if FOO' has no special meaning
around a source. Conditional includes wouldn't be possible, because an
if condition could include (directly or indirectly) forward references
to symbols not defined yet.
Tip: When adding a symbol, check its dependencies in the menuconfig
('ninja menuconfig', then / to jump to the symbol). The menuconfig also
shows how the file with the symbol got included, so if you see
duplicated dependencies, it's easy to hunt down where they come from.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
subsys/usb/Kconfig 'source's subsys/usb/class/Kconfig (which in turn
'source's subsys/usb/class/netusb/Kconfig) within an
'if USB_DEVICE_STACK', so the dependencies on USB_DEVICE_STACK added
within those files are redundant.
'if FOO' is just shorthand for adding 'depends on FOO' to each item
within the 'if'. Dependencies on menus work similarly. There are no
"conditional includes" in Kconfig, so 'if FOO' has no special meaning
around a source. Conditional includes wouldn't be possible, because an
if condition could include (directly or indirectly) forward references
to symbols not defined yet.
Tip: When adding a symbol, check its dependencies in the menuconfig
('ninja menuconfig', then / to jump to the symbol). The menuconfig also
shows how the file with the symbol got included, so if you see
duplicated dependencies, it's easy to hunt down where they come from.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
subsys/bluetooth/common/Kconfig and subsys/bluetooth/host/Kconfig are
'source'd within 'if BT' and 'if BT_HCI', in subsys/bluetooth/Kconfig,
so there's no need to add those dependencies within them.
'if FOO' is just shorthand for adding 'depends on FOO' to each item
within the 'if'. Dependencies on menus work similarly. There are no
"conditional includes" in Kconfig, so 'if FOO' has no special meaning
around a source. Conditional includes wouldn't be possible, because an
if condition could include (directly or indirectly) forward references
to symbols not defined yet.
Tip: When adding a symbol, check its dependencies in the menuconfig
('ninja menuconfig', then / to jump to the symbol). The menuconfig also
shows how the file with the symbol got included, so if you see
duplicated dependencies, it's easy to hunt down where they come from.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
subsys/net/lib/lwm2m/Kconfig.ipso is 'source'd within an 'if LWM2M', in
subsys/net/lib/lwm2m/Kconfig, so the 'depends on LWM2M' is redundant.
The 'depends on NET_IPV4' and 'depends on NET_L2_OPENTHREAD' are within
corresponding 'if's in the same file.
'if FOO' is just shorthand for adding 'depends on FOO' to each item
within the 'if'. Dependencies on menus work similarly. There are no
"conditional includes" in Kconfig, so 'if FOO' has no special meaning
around a source. Conditional includes wouldn't be possible, because an
if condition could include (directly or indirectly) forward references
to symbols not defined yet.
Tip: When adding a symbol, check its dependencies in the menuconfig
('ninja menuconfig', then / to jump to the symbol). The menuconfig also
shows how the file with the symbol got included, so if you see
duplicated dependencies, it's easy to hunt down where they come from.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Generally when DFU is in progress, the system is not expected to
be doing anything else in addition. Hence, a completion signal
would help the system to know that DFU is over and it can proceed
towards next tasks.
Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
Some of these are from 'source'ing a file within a menu that has a
'depends on NET_L2_ETHERNET' (in drivers/ethernet/Kconfig) and then
adding another 'depends on NET_L2_ETHERNET' within it.
Similarly, subsys/net/l2/ethernet/Kconfig sources files within an
'if NET_L2_ETHERNET'.
'if FOO' is just shorthand for adding 'depends on FOO' to each item
within the 'if'. Dependencies on menus work similarly. There are no
"conditional includes" in Kconfig, so 'if FOO' has no special meaning
around a source. Conditional includes wouldn't be possible, because an
if condition could include (directly or indirectly) forward references
to symbols not defined yet.
Tip: When adding a symbol, check its dependencies in the menuconfig
('ninja menuconfig', then / to jump to the symbol). The menuconfig also
shows how the file with the symbol got included, so if you see
duplicated dependencies, it's easy to hunt down where they come from.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Disable low power/deep sleep modes when they are not enabled in Kconfig.
Otherwise if only low power modes are enabled (but no deep sleep),
Zephyr will try to swich to the lowest power mode (deep sleep) anyway,
only to discover that it's not availiable, resulting in no low power
mode at all being used.
By disabling the modes here if they are not enabled in Kconfig,
policy_residency will switch to the lowest low power mode instead.
Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
In case it was detected that RTT host was not present
backend was still performing single sleep or busy wait
round before dropping data. That was degrading log
processing performance.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Commit 766101c was a wrong fix as NETUSB_MTU is the actual network MTU.
Instead of using this value in EEM/ECM drivers, a relevant value should
be set for each there.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This reverts commit 8cb5d083cb53627964ed72fb9fa3fb7a5219739f.
This was breaking tests on master due to missing dependency that is
still being reviewed.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
If system clock runs fast k_cycle_get_32(), which is the timestamp
source, wraps often (few minutes). This patch changes default
timestamp function to use k_uptime_get_32() if system clock
frequency is higher than 1 MHz and k_cycle_get_32() otherwise.
If system clock runs at 1 MHz, counter will wrap every 71.5 minutes.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This is done to conform with how the rest of the socket APIs are
implemented during socket offload. Otherwise link error would
result due to the symbol being redefined in lib/os/fdtable.c.
Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
As per RFC2131 4.1.1 requires we wait a random period
between 1 and 10 seconds before sending the initial
discover. But tests can not wait that longer. So this
option helps test to configure the value to minimum.
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Previously, _prf function was used when present and _vprintk
was used otherwise. _prf supports reacher formatting but at
cost of 3k flash and >250 bytes on stack. Stack usage then
depended on which function was used and that was causing
troubles when trimming stack sizes.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
No Kconfig symbol called NET_GPTP_STACK_SIZE has ever been defined in
the Zephyr repo. Drop the CONFIG_* prefix from the #define.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Check the return value of mayfly_enqueue() and assert if not successful.
Coverity ID: CID 190991
Fixes#13833.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Inside ll_test_end(), result of lll_clk_off() is not checked
which might result in releasing resources acquired for radio.
Coverity-CID: 190954
Fixes: #13861
Signed-off-by: Maksim Masalski <maxxliferobot@gmail.com>
To match the signature of k_thread_name_get(), add a const modifier to
the local variable definition.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
We sometimes want to join a device to OpenThread mesh automatically.
This commit adds supports to do by Kconfig.
The default of CONFIG_OPENTHREAD_JOINER_PSKD is based on this page:
https://codelabs.developers.google.com/codelabs/openthread-hardware/
Signed-off-by: Takumi Ando <takumi.ando@atmark-techno.com>
Added an assert in the logger thread in case there
is no backends, instead of having that thread spinning
forever. Disabled log in qemu_xtensa board due to lack
of backends.
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
We used to leave byte-long placeholder symbols to ensure
that empty application memory sections did not cause
build errors that were very difficult to understand.
Now we use some relatively portable inline assembly to
generate a symbol, but don't take up any extra space.
The malloc and libc partitions are now only instantiated
if there is some data to put in them.
Fixes: #13923
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
It was possible via Kconfig to assign any partition for FCB using
its number. Partitions flash_area_id becomes non predefined
(are auto-generated). So it is possible only to guess which
number will be signed to certain area.
Unfortunately it is not possible to transfer FLASH_AREA_XXX_ID
label via Kconfig.
Patch assigns settings to the storage partition and remove
SETTINGS_FCB_FLASH_AREA property from settings Kconfig.
fixes#13388
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
This part of tests was forgotten when we move to subsys/
Fixes#13729
Signed-off-by: Wentong Wu <wentong.wu@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Trivial patch to recover the task name from the task structure when it
is present and include it in the information returned to SystemView.
When these data are not present patch will revert to old behaviour.
Signed-off-by: Dave Marples <dave@marples.net>
Due to regression the option to enable Data Length Update
Procedure for nRF51 series was disable.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Inside cmd_read(), result of fs_seek() is not checked which might
result in reading the wrong part of file. So fails the read if
fs_seek() fails.
Fixes#13862
Fixes CID-190953
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
If we receive the ARP request, then check if the ARP cache
contains an entry for this IP address already. If it does,
then update the MAC address in the cache.
Fixes#10188
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Some old peer central controllers respond with Unknown
Response PDU to our local Slave Initiated Feature Request
after the peer initiated the Encryption Setup Procedure.
The peer has voilated the Bluetooth Specification by sending
the Unknown Response during the Encryption Setup Procedure,
but as a workaround to IOP with such controller our local
implementation is updated to not disconnect the connection
but accept the voilating Unknown Response PDU.
Relates to #12362.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
CCC cfg value was not being cleared on disconnection of a non bonded
peer if another peer was connected, had non zero value and occurred
earlier in the ccc cfg array.
Signed-off-by: Nick Ward <nick.ward@setec.com.au>
These options are oftentimes used when implementing servers, and
thus required to port existing socket apps. These options are also
safe to just ignore, e.g. SO_REUSEADDR has effect only for repeated
recreation of server socket (not an expected usecase for a Zephyr
app), while TCP_NODELAY is effectively the default for Zephyr, as we
don't implement TCP buffering (aka Nagle algorithm).
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Multiple flag bits were set so the ACK flag set was not checked
properly which meant that connection establishment was not
successfull.
Fixes#13943
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
No need to hide the symbols in the header file if CONFIG_NET_LLDP
is not enabled. This also allows the documentation to be generated
properly.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Variable evt_prop could be used without being initialized. This problem
was spotted by coverity.
CID 190970
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Console subsystem doesn't depend on older consoles-in-drivers, the
only common thing between them is CONFIG_UART_CONSOLE_ON_DEV_NAME
setting, so make it so (by depending on either UART_CONSOLE or
CONSOLE_SUBSYS.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
The ipv6_handle_ext_hdr_options() can return negative value
but we stored it into unsigned variable and then checked < 0.
Coverity-CID: 190995
Fixes#13830
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The LI bits checks is useless as the bitshifted value cannot be
larger than SNTP_LI_MAX (3).
Coverity-CID: 190924
Fixes#13888
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Every time the array of offsets was changed, it was changed in a
backward compatible way by appending elements to the end. The version
number was incremented to inform OpenOCD about the existence of the new
elements. But the patch for OpenOCD to support Zephyr has never been
updated to support anything else than version 0, causing OpenOCD to
reject recent Zephyr versions. So the idea of using a version number to
track compatible changes didn't work out.
Therefore add another symbol that can be read by OpenOCD to get the
number of elements in the array. This value is automatically calculated
during compilation. The version number element should from now on be
incremented only for incompatible changes.
Fixes: #13448
Signed-off-by: Daniel Glöckner <dg@emlix.com>
Found via Coverity CID 191001: Control flow issues (NO_EFFECT)
This less-than-zero comparison of an unsigned value is never true:
"put_char(out, '}') < 0U".
Let's fix this check to be less than 1 instead as it should have
been originally.
Signed-off-by: Michael Scott <mike@foundries.io>
There was no notification about dropped logs When logger operated
in the mode where message is dropped when logger has no space to
store the message. Notification was printed only if logger operated
in the mode which overwrites oldest log.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit adds support for remote wakeup and extends USB api
with a wakeup request call. Remote wakeup can be dsabled in kconfig
when a specific driver does not support this feature.
Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
To get u8_t value, just right shift the operands are enough.
Fixes#12298
Coverity-CID: 190635
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
This makes use of BT_GATT_CCC_MANAGED so instead of having a custom
attribute which is not managed by stack.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This consolidates code for finding a CCC config in a helper function
thus reducing the amount of duplicated code.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds another helper macro called BT_GATT_CCC_MANAGED which can be
used to set 2 new callbacks:
- cfg_write: Which application can set if it wants to manage writes to
CCC configuration.
- cfg_match: Which application can set if it wants to manage matching
CCC configuration when notifying/indicating.
BT_GATT_CCC_MANAGED retains the ability of saving peer configuration
on storage making it useful for clients which are only interrested in
managing the CCC configuration but not the storage itself.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Some more were added since the cleanup pass in June 2018. See e.g.
commit 2d50da70a1 ("drivers: ipm: Kconfig: Remove redundant 'default n'
properties") for a motivation. It also avoids people wondering whether
or not they need to put in 'default n'.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Same change as in commit 8cf8db3a73 ("Kconfig: Use a short, consistent
style for prompts"), fixing stuff that got introduced since then.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
The intent of this Kconfig is to allow libc stdout
functions like printf() to send their output to the
active console driver instead of discarding it.
This somehow evolved into preferring to use
printf() instead of printk() for all test case output
if enabled. Libc printf() implementation for both
minimal libc and newlib use considerably more stack
space than printk(), with nothing gained by using
them.
Remove all instances where we are conditionally
sending test case output based on this config, enable
it by default, and adjust a few tests that disabled
this because they were blowing stack.
printk() and vprintk() now work as expected for
unit_testing targets, they are just wrappers for
host printf().
Fixes: #13701
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
CPU_LPS_n name used to indicate a low power state is cryptic and
incorrect. The low power states act on the whole SoC and not exclusively
on the CPU. This patch renames CPU_LPS_n states to LOW_POWER_n. Also
HAS_ pattern for Kconfig options is used in favor of a non standard
_SUPPORTED. Naming of deep sleep states was adjusted accordingly.
Following is a detailed list of string replacements used:
s/SYS_POWER_STATE_CPU_LPS_(\d)_SUPPORTED/HAS_STATE_LOW_POWER_$1/
s/SYS_POWER_STATE_CPU_LPS_(\d)/SYS_POWER_STATE_LOW_POWER_$1/
s/SYS_POWER_STATE_DEEP_SLEEP_(\d)_SUPPORTED/HAS_STATE_DEEP_SLEEP_$1/
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
According to the Coverity issue 190614 (github issue #12319)
Fix for logically dead code in function buffer_trim
Before while execution cannot reach this statement: buff[0] = '\0';
Tested and noticed that part of code is unnecessary inside of while
For the test, I made the same function in CodeBlocks and send to it
string to detect and delete whitespaces. After deletion of dead code
part, I tested function again, it works.
Function buffer_trim first detects whitespace characters in the end
of the string using first while, then it adds '\0' to the end
of the string to mark that string has new end after all whitespace
characters. Second while finds whitespaces at the beginning
of the string and counts how many whitespaces it found.
In the end using if counted whitespaces are removing from the
string.
Signed-off-by: Maksim Masalski <maxxliferobot@gmail.com>
The net-shell was using wrong config options for statistics
support. Also net_stats.h had wrong config used for IPv6 MLD
statistics.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Poll descriptor was not incremented in poll update function in case it
was reported as not ready. In result, poll could end up processing the
same poll descriptor for every fd requested to monitor.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Rework detection of EOF on a socket, so that it can be detected in a
poll prepare that socket is in in a EOF state and poll can return
immediately.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Unfortunately, most of the dns pack/unpack code is not factorized, and
mdns responder rewrites its own functions to write dns hdr, query,
answer.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Unfortunately, most of the dns pack/unpack code is not factorized, and
llmnr responder rewrites its own functions to write dns hdr, query,
answer.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
So instead of building the net_pkt by itself, dns will pass its message
buffer to net_context_sendto_new(), which in turn will build the net_pkt
relevantly.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Since net_context_sendto_new() does not take a net_pkt anymore, the only
way to set net_pkt's ttl/hop_limit is to pass it through net_context.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
dns_write was in the middle of this, let's just move it to a more
relevant place so we logically have macros, then local variables then
functions.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Some of dns_pack.c macros are also used in resolve.c, so let's just put
the macros in dns_pack.h
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Once the fraction value has been assigned a value, we can't move
the exponent any more.
Fixes erroneous values the binary32/64 formats.
Signed-off-by: Michael Scott <mike@foundries.io>
- differentiating actual "fragment" to buffer element from a net_pkt
- instead of copying data (and thus allocating buffer) let's just take
the fragment buffer and put it into result packet.
- fixing compilation issue in relevant test
It's more efficient that way, as we use already allocated fragment
buffer instead of reallocating/deallocating after each fragment
reception.
A possible optimization would be to calculate the actual size + header
difference if only the actual size is close to the target size.
It would avoid to get a dry run of the header decompression for each
fragment received. The difficulty being in finding the sweet spot when
it is relevant to calculate the header difference.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Since we don't want to redo the complex calculation, let's reuse the
uncompress functions, adding a dry_run possibility to those.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This is an integral part of userspace and cannot be used
on its own. Fold into the main userspace configuration.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
When DTLS client was added to `poll` before/during the handshake, it
could throw errors and in some circumstances (when polling thread was
cooperative and had higher or equal priority to the handshake thread)
could lead to a deadlock in the application.
Prevent that, by blocking on handshake semaphore instead of fifo. Poll
will start using fifo for data poll only after handshake is complete.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Instead of simple bool value, use a semaphore to notify that TLS
handshake is complete. This way, we can monitor this value with k_poll.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Errno value is only significant when `recvfrom` function indicated an
error (by returning -1). We should not depend on it's value if no error
is notified.
As the return value of `recvfrom` is already checked, misused errno
verification can simply be removed.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
We need a generic name for the partition containing
essential C library globals. We're going to need to
add the stack canary guard to this area so user mode
can read it.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Move test related code and the testsuite away from tests/ and make it a
proper subsystem.
The way tests were integrate in the tree was not obvious and actual
tests were intermixed with the testsuite code.
This will allow us to have trees with the testcode and without the
samples by just remove the folders tests/ and samples, needed for
isolating actual code from test/sample code.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
settings_line_len_calc() is used to determine key-value record size.
It unnecessary aligned this size to write-block-size.
Record size in flash layout is actually adjusted independently by
fcb itself and setting settings_line_write().
Patch fixes this behavior.
fixes#12967
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Patch remove unnecessary call chain which fetched flash write-block-size
already available in fcb instance.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
It simplifies things again, as it does not need to create the net_pkt by
itself anymore.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
When closing the socket, zsock_close_ctx() would call
net_context_accept() when the socket was in "LISTEN" state.
This would result in an error log message for "Identical
connection handler already found" because the connection
context was already created because the initial
zsock_listen_ctx() called net_context_accept() to set up
the socket at the beginning. This change adds a test to
check if the callback is NULL which indicates this
close state and avoids the error message.
Signed-off-by: david leach <david.leach@nxp.com>
The sending of the final FIN message was being put on the sent_list
to be handled by the retry logic and being sent directly. But in
the case of a socket that never had a connection, the logic after
the direct send would decrement the reference on the packet which
would cause the retry logic to eventually have a situation where
the pkt is on the sent_list queue but the buffer associated with
the packet is freed back to slab. The code would then get a null
pointer to the tcp header and would fault when setting the crc to
zero on frdm-k64f platform.
Fixes#13489, #13301
Signed-off-by: david leach <david.leach@nxp.com>
The TODO file contained some random nice to have features.
The file does not mention use cases for these and also currently
the new features are managed and discussed in github.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This patch removes the free space calculation from nvs initialization.
The available space can be calculated if required using the routine
nvs_calc_free_space.
This patch also removes the locked state of nvs, it is not possible to
get in a locked state.
This patch adds an extra check on the sector_size configuration and only
allows operation on nvs when nvs has been initialized.
This patch also solves issue #13369, the usage of FLASH_ERASE_BLOCK_SIZE
has been replaced with the flash page api.
Changes:
Removed locked state and free_space from the nvs structure.
nvs_reinit(): has been replaced with by an internal only function
_nvs_startup().
nvs_write(): removed the possibility to place the file system in a
locked state, if to many gc operations are required it will return
-ENOSPC.
ssize_t nvs_calc_free_space(): introduced, calculates the free space
that is available in the nvs file system.
Removed define LOG_LEVEL.
Rebased to current master.
Signed-off-by: Laczen JMS <laczenjms@gmail.com>
This patch removes the free space calculation from nvs initialization.
The available space can be calculated if required using the routine
nvs_calc_free_space.
This patch also removes the locked state of nvs, it is not possible to
get in a locked state.
Changes:
Removed locked state and free_space from the nvs structure.
nvs_reinit(): has been replaced with by an internal only function
_nvs_startup().
nvs_write(): removed the possibility to place the file system in a
locked state, if to many gc operations are required it will return
-ENOSPC.
ssize_t nvs_calc_free_space(): introduced, calculates the free space
that is available in the nvs file system.
Signed-off-by: Laczen JMS <laczenjms@gmail.com>
Maybe there is an easier way to fill in the buffer in one call from an
otMessage.
Switch "frag" keyword to "buf", as "frag" is now reserved for actual
packet fragmentation and not buffer.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Prevent temporary strings from being printed incorrectly if they go out
of scope before being processed by logger.
Signed-off-by: Filip Kubicz <filip.kubicz@nordicsemi.no>
Possible null pointer dereference when looking up the nexthop
neighbor.
Coverity-CID: 190639
Fixes#12294
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The bt_settings_encode_key() cannot know if the given path pointer is
on the stack or not, so the only safe way to pass it to the logger is
by using a log_strdup() call. Not doing this will likely cause
corrupted strings to show up in the log output.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
ICMPv6 network packets are processed and consumed (if not dropped)
within `net_icmpv6_input` function. Therefore they shoud not be
passed to the `net_conn_input` function.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Macros are replaced by C++ friendly versions:
- SHELL_CREATE_STATIC_SUBCMD_SET by SHELL_STATIC_SUBCMD_SET_CREATE
- SHELL_CREATE_DYNAMIC_CMD by SHELL_DYNAMIC_CMD_CREATE
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
It is planned to deprecate SHELL_CREATE_STATIC_SUBCMD_SET macro
which is replaced by SHELL_STATIC_SUBCMD_SET_CREATE.
Additionally, removed irrelevant comments about alphabetical
ordering which is no longer needed.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Shell arguments structure was stored as a pointer in shell structure
and NULL pointer indicated that argument count checking is skipped.
It has been reworked to hold the structure (2 bytes) in the shell
structure with mandatory=0 skipping the check. This approach is cpp
friendly, contrary to the legacy one.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This function is the opposite of getaddrinfo(), i.e. converts
struct sockaddr into a textual address. Normally (or more
specifically, based on the flags) it would perform reverse DNS
lookup, but current implementation implements only subset of
functionality, by converting to numeric textual address.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
`net_ipv6_finalize` expects packet cursor to be reinitialized in order
to finalize packet correctly. This commits adds missing cursor
initialization.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
A debug message told "Set EOF flag on pkt %p", but actually printed
net_context instead of net_pkt.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This commit adds better description to the Kconfig options
configuring residency-based power policy.
Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>