Not only removes a branch during normal operation, but also ensures
that, by initializing at the PRE_KERNEL_2 stage, and granting
privileges to all threads to the semaphore, this code will work in
early boot situations and in user mode.
This assumes that entropy drivers will all initialize during
PRE_KERNEL_1 stage. All in-tree drivers do that.
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
The code was using MSEC() macro in few places instead of more
proper K_MSEC(). The MSEC() takes seconds as a parameter and
K_MSEC() takes milliseconds.
Fixes#7657
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
sin6_scope_id is not set anywhere and not used. Probably left over
from old ZOAP library. Just address, port and family type are enough
to find registered CoAP observer.
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
The next error check is much more suitable to handle the error due to
the error message which lets the user know that something went wrong.
Fixes#7661.
Signed-off-by: Daniel Egger <daniel@eggers-club.de>
In switch statement break statement was missing causing IPv4 part to
execute even if the packet is IPv6. Also logical negation is wrong in
this context.
Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
Leading/trailing whitespace in prompts requires ugly workarounds in
genrest.py, as e.g. *prompt * is invalid RST. strip() all prompts in
Kconfiglib and get rid of the genrest.py workarounds. Add a warning too.
The Kconfiglib update has some unrelated cleanups and fixes (that won't
affect Zephyr).
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
This was declared but unused. And recent toolchains have apparently
started warning on it leading to sanitycheck failures.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
NET_ASSERT is useless here, as we already know that an error happened.
Use NET_ERR in order to print a more informative message.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
When calling net_frag_read(), frag == NULL is an error only if pos is
not zero. It is thus incorrect to throw an error only if !frag, as
pos must also be checked to be not zero.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
Current implementation hardcoded channel in received frame structure.
With this change channel can be retrieved from a OpenThread platform,
and put in the frame. In result procedures like Discovery can be
executed correctly. Change was tested with OpenThread Border Router.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit contains bugfix for Joiner eui-64 handling and setting radio
in correct mode after calling thread stop.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The Bluetooth core specification splits the valid LE L2CAP PSM range
into two subranges:
- Standard, SIG-assigned fixed PSM values in the range 0x0001-0x007f
- Dynamic, allocated at runtime in the range 0x0080-0x00ff
Previously the bt_l2cap_server_register() API was assuming that the
app would always decide the PSM, which effectively made it impossible
to have collision-free dynamic PSMs. This patch extends the
implementation so that if server->psm is 0, then the stack will look
for a free PSM from the dynamic range and take it into use.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Instead of having an ivu_unknown variable to track when we can ignore
the 96-hour minimum duration requirement, simply set the duration to
the minimum (96 hours) in the places where ivu_unknown would have been
1.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
If a packet with source IP address and port same as the address of echo
server is received, it causes echo server to recursively send the packet
to itself, resulting in a crash and memory depletion. This commit fixes
the crash by dropping the packet.
Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
When designing the registration client for LwM2M, I understood
that the LwM2M Technical Specification allows for a multi-server
connection setup where the client makes several connections
to various LwM2M servers and allows each of them to manage
various aspects of the LwM2M client based on Access Controls.
However, the way I implemented it was not well thought out and
as we look forward to adding Bootstrap support, it needs a
do over.
Let's remove all of the code dedicated to handling multiple LwM2M
client connections. This will simplify and reduce the code size
of the registration client considerably.
Later, once Bootstrap support has been added, we can implement
multi-server connections in a cleaner manner.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
This allows a user to customize the port used for downloading
firmware via the pull method of the LwM2M client. It's default
value of 0 will select a random port during initialization.
NOTE: If set, this value should not be the same port as the
LWM2M_LOCAL_PORT setting.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Due to a bug where LWM2M_LOCAL_PORT was not being honored, all
outgoing traffic from the LwM2M client was coming from a random
port determined during initialization.
Now that this bug bas been fixed, let's default the client to the
behavior that most users are expecting, and let new users customize
the outgoing port if needed (which should be rarely).
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Currently, CONFIG_LWM2M_LOCAL_PORT is never used when setting up
the LwM2M client. Let's set the port of the local address using
CONFIG_LWM2M_LOCAL_PORT, so that the client can bind to it.
NOTE: A setting of 0 will use a random port.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Currently, the client_addr parameter is only used to check the
sa_family at various points during the init process. Both the
IP address and the port are ignored. Let's set the local client's
port based on the port value of the passed in client_addr if one
is supplied.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
The port parameter passed to _net_app_set_local_addr() is converted
from host byte-order to network byte-order. Here we are passing
a port value which has already been translated to network byte-order.
Let's translate the local port to host byte-order when passing it
to _net_app_set_local_addr() to fix this issue.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
There were multiple spots where code was using the _wait_q_t
abstraction as a synonym for a dlist and doing direct list management
on them with the dlist APIs. Refactor _wait_q_t into a proper opaque
struct (not a typedef for sys_dlist_t) and write a simple wrapper API
for the existing usages. Now replacement of wait_q with a different
data structure is much cleaner.
Note that there were some SYS_DLIST_FOR_EACH_SAFE loops in mailbox.c
that got replaced by the normal/non-safe macro. While these loops do
mutate the list in the code body, they always do an early return in
those circumstances instead of returning into the macro'd for() loop,
so the _SAFE usage was needless.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
When the IV Update state enters Normal operation or IV Update in
Progress, we need to keep track of how many hours has passed in the
state, since the specification requires us to remain in the state at
least for 96 hours (Update in Progress has an additional upper limit
of 144 hours).
In order to fulfil the above requirement, even if the node might be
powered off once in a while, we need to store persistently how many
hours the node has been in the state. This doesn't necessarily need to
happen every hour (thanks to the flexible duration range). The exact
cadence will depend a lot on the ways that the node will be used and
what kind of power source it has.
Since there is no single optimal answer, this patch adds a new
configuration option, which allows specifying a divider, i.e. how many
intervals the 96 hour minimum gets split into. After each interval the
duration that the node has been in the current state gets stored to
flash. E.g. the default value of 4 means that the state is saved every
24 hours (96 / 4).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
L2 could take advantage of such hardware capability, when supported by
the device. This is also required for OpenThread.
Fixes#5714
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
The settings_init() API was protected against multiple calls, but the
only function that calls it, settings_subsys_init(), was not. Add the
protection to the higher-level function as well.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
After introducing persistent storage, it's useful for an app to check
if the node has been provisioned or not.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Previously, there was a boolean CONFIG_NET_TCP_TIME_WAIT setting
("master switch") and numeric CONFIG_NET_TCP_2MSL_TIME setting,
both named not ideally (there were both NET_TCP_TIME_WAIT and
CONFIG_NET_TCP_TIME_WAIT symbols in the source, with very different
meaning; "2MSL_TIME" was also a roundabout way to refer to
TIME_WAIT state time). In addition to that, some code was defining
adhoc, hardcoded duplicates for these settings.
CONFIG_NET_TCP_2MSL_TIME was also measured in seconds, giving
poor precision control for this resource-tying setting.
Instead, replace them all with the single
CONFIG_NET_TCP_TIME_WAIT_DELAY setting, measured in milliseconds.
The value of 0 means that TIME_WAIT state is skipped.
Fixes: #7459
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
We only clear 3 of the 6 member variables of the coap_reply structure
in coap_reply_clear().
Let's make sure to reset all of them.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
The base CoAP retry setting is quite fast for network technologies
such as LTE-M and LoRa. Let's add an option to delay retries
a bit longer depending on the need.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Using IPSO Smart Object Guideline: "Smart Objects Starter Pack 1.0"
dated May 27, 2017, let's mark the OPTIONAL resources for an
IPSO Temperature object (Section 10. "IPSO Object: Temperature").
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Using IPSO Smart Object Guideline: "Smart Objects Starter Pack 1.0"
dated May 27, 2017, let's mark the OPTIONAL resources for an
IPSO Light Control object (Section 16. "IPSO Object: Light Control")
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Using OMA Technical Specification LwM2M Enabler 1.0.2 dated
Feb. 9, 2018, let's mark the OPTIONAL resources for an LwM2M
Firmware Update object (Section E.6 "LwM2M Object: Firmware
Update")
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Using OMA Technical Specification LwM2M Enabler 1.0.2 dated
Feb. 9, 2018, let's mark the OPTIONAL resources for an LwM2M
Device object (Section E.4 "LwM2M Object: Device")
As a result, the Device object no longer configures the default
buffers for data storage of several optional resources.
The LwM2M client sample is also changed to to setup these read-only
buffers instead.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Using OMA Technical Specification LwM2M Enabler 1.0.2 dated
Feb. 9, 2018, let's mark the OPTIONAL resources for an LwM2M
Server object (Section E.1 "LwM2M Object: Server")
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Using OMA Technical Specification LwM2M Enabler 1.0.2 dated
Feb. 9, 2018, let's mark the OPTIONAL resources for an LwM2M
Security object (Section E.1 "LwM2M Object: Security")
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
This patch introduces several changes to support OPTIONAL resources.
The primary indicator for this behavior is to assign FLAG_OPTIONAL
to the object field's permission flags.
These resources are not setup by the LwM2M object code. They are
left up to the user-based code for initialization via the following
functions:
lwm2m_engine_set_res_data()
lwm2m_engine_get_res_data()
When assigning const-based data as a data buffer, user-based code can
also specify the following data flag: LWM2M_RES_DATA_FLAG_RO
The FLAG_OPTIONAL flag also affects the LwM2M engine in the following
ways:
- CREATE operations won't generate an error if optional resources are
not included.
- Object instance READ operations won't complain about missing
optional resources.
- In the future, BOOTSTRAP operations can have different handling
based on optional resources.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
In the future, we will have optional resources that may or may
not be assigned a buffer for data storage. When these resources
are queried we need to be able to return an error code if the
buffer isn't set.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Instead of selecting the first IPv4 address from the network
interface, use destination address to select the proper local IPv4
address.
Fixes#7500
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Fix a build warning when compiling a net_app sample with
CONFIG_NET_APP_DTLS enabled by changing the print formatter from %zu
to %d. It references the var hdr_len which is defined as an int:
In file included from include/net/net_core.h:78:0,
from subsys/net/lib/app/net_app.c:27:
subsys/net/lib/app/net_app.c: In function ‘_net_app_ssl_mainloop’:
include/logging/sys_log.h:96:20: warning: format ‘%zu’ expects
...
subsys/net/lib/app/net_app.c:2132:6: note: in expansion of macro
‘NET_ERR’
NET_ERR("could not skip %zu bytes",
^~~~~~~
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Similar to UDP, some drivers can make use of the following functions:
net_tcp_get_hdr()
net_tcp_set_hdr()
Let's expose them as <net/tcp.h> and change all internal references
to "tcp_internal.h".
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Zephyr supports fatfs, nffs and fcb as storage layer. fatfs and nffs
are less suited for application in memory restricted IC's. fcb has a
smaller footprint but has a complex api.
The proposed module is a module with a even smaller footprint compared
to fcb and a simple interface for reading and writing entries. The
module provides wear levelling of flash. This allows the module to be
used not only to store configuration settings but to store device state
(e.g. state of a light switch over reboots) of a zephyr device.
Fixes buffer overflow by introducing maximum read length in nvs_read()
and nvs_read_hist().
Fixes nvs_write() not to reflash the same data. Allows the user to do
call nvs_write() for all defined entries without worries about flash
wear.
Fixes garbage collection error where wrong data could be copied.
Add nvs_delete() to allow deleting a stored entry. A deleted entry will
not be copied to a new flash sector
Include flash wear information in the README.md documentation
0/25 Update module after reviewers remarks, added documentation to
nvs.h, removed README.md by nvs.rst in doc/subsystems folder
04/26 Update module after reviewers remarks, updated nvs.rst, added more
documentation to samples/subsys/nvs/src/main.c, updated doxygen info
in nvs.h (hope this time it works).
04/26 Update subsystems.rst to include nvs.restart
04/27 Updated nvs.c and nvs.h to avoid a possible flash deletion loop
when the file system is full.
04/29 Updated nvs_write to detect and ignore deletes of non-existing
items
05/06 Update NVS module to return standard error codes, removed low
level API, added configuration options. NVS now uses the board dts to
determine the flash storage location (FLASH_AREA_STORAGE_OFFSET).
05/06 Update nvs.rst. Updated intendation and added intermediate
variables in nvs.c to make the code easier to read.
05/06 Update nvs.rst.
05/07 Update nvs.rst
05/08 Changed the API to a more standard file system API.
05/08 Removed cnt_max from nvs_read() as it is not used.
05/08 Removed #ifdef(CONFIG_NVS_LOG) from nvs_priv.h, now the module can
be build with debugging off.
05/09 Removed configuration options for SECTOR_SIZE, SECTOR_COUNT and
MAX_ELEM_SIZE. It is now easy to support multiple NVS filesystems on
one or multiple devices. Changed logging to support newlib systems.
Thanks to Olivier Martin for reporting and proposed changes.
Signed-off-by: Laczen JMS <laczenjms@gmail.com>
Implementation of Get Descriptor Request should not return interface
or endpoint descriptors in a single request without configuration
descriptor, see USB Spec. Revision 2.0, 9.4.3 Get Descriptor
This patch fixes linux kernel usbtest subtest 7 and subtest 11 errors.
Signed-off-by: Johann Fischer <j.fischer@phytec.de>