Move code responsible for net context initialization, repeated over
multiple test cases, to a helper function to reduce code duplication.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Modify internal L4 protocols APIs, to allow to enforce checksum
calculation, regardless of the checksum HW offloading capability.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Implement testcases for Information Reporting Interface [300-399]:
* LightweightM2M-1.1-int-301 - Observation and Notification of parameter
values
* LightweightM2M-1.1-int-302 - Cancel Observations using Reset
* LightweightM2M-1.1-int-304 - Observe-Composite Operation
* LightweightM2M-1.1-int-306 – Send Operation
* LightweightM2M-1.1-int-307 – Muting Send
* LightweightM2M-1.1-int-308 - Observe-Composite and Creating
Object Instance
* LightweightM2M-1.1-int-309 - Observe-Composite and Deleting
Object Instance
* LightweightM2M-1.1-int-310 - Observe-Composite and modification of
parameter values
* LightweightM2M-1.1-int-311 - Send command
303 and 305 cannot be implemented using Leshan as it only support
passive cancelling of observation.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When testcases share one DUT per module, we save the time
from running bootstrap on each testcase.
Each testcase start with DUT that is registered.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Implement support for reading stream of events from Leshan.
This allows testing the LwM2M SEND/Notify/Update operations
and reading content of those.
Also convert the whole Leshan class to use requests.session() so
it pools up connections and uses keep-alive.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Add remaining test cases from
Device management & Service Enablement Interface
* LightweightM2M-1.1-int-222 – Read on Object
* LightweightM2M-1.1-int-223 – Read on Object Instance
* LightweightM2M-1.1-int-224 – Read on Resource
* LightweightM2M-1.1-int-225 – Read on Resource Instance
* LightweightM2M-1.1-int-226 – Write (Partial Update) on
Object Instance
* LightweightM2M-1.1-int-227 - Write (replace) on Resource
* LightweightM2M-1.1-int-228 - Write on Resource Instance
* LightweightM2M-1.1-int-229 - Read-Composite Operation
* LightweightM2M-1.1-int-230 - Write-Composite Operation
* LightweightM2M-1.1-int-231 - Querying basic information
in SenML JSON format
* LightweightM2M-1.1-int-232 - Querying basic information
in SenML CBOR format
* LightweightM2M-1.1-int-233 - Setting basic information
in SenML CBOR format
* LightweightM2M-1.1-int-234 - Setting basic information
in SenML JSON format
* LightweightM2M-1.1-int-235 - Read-Composite Operation on root path
* LightweightM2M-1.1-int-236 - Read-Composite - Partial Presence
* LightweightM2M-1.1-int-237 - Read on Object without specifying
Content-Type
* LightweightM2M-1.1-int-241 - Executable Resource: Rebooting the device
* LightweightM2M-1.1-int-256 - Write Operation Failure
* LightweightM2M-1.1-int-257 - Write-Composite Operation
* LightweightM2M-1.1-int-260 - Discover Command
* LightweightM2M-1.1-int-261 - Write-Attribute Operation on a multiple
resource
* LightweightM2M-1.1-int-280 - Successful Read-Composite Operation
* LightweightM2M-1.1-int-281 - Partially Successful Read-Composite
Operation
Modify tests binary
* Allow CoAP payload of 1211 bytes.
* Allow outgoing messages to use block-wise if they are bigger.
* Use 4kB encode buffer for outgoing messages.
* Check configured heap and stack sizes.
* Limit number of interface addresses, sockets and contexts
Qemu-cortex-m3 platform ran out of RAM, so reconfigure it to use
* packet size of 256 bytes.
* encode buffer of 2kB
This exercises the block-transferring on some of the test cases.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
* Add support for running interoperability tests with
Qemu X86.
* Remove some debugging messages to allow binary to
fix Qemu Cortex-M3 board.
* Tune buffer and stack sizes to fit all boards.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Do not include the resource type (rt=) in the registration message when
using the OMA JSON format. This was a workaround specifically for the
Wakaama LwM2M server which is no longer needed since the latest master
branch.
Signed-off-by: Marc Lasch <marc.lasch@husqvarnagroup.com>
When working on new test cases for checksum_offload test suite it turned
out that some existing test cases were already broken and not testing
what expected. This commit fixes the broken functionality:
* Despite having two separate interfaces for offloaded and
non-offloaded checksum scenario, all packets ended up in a single
interface anyway due to src address matching. Therefore use
different destination address, depending on tests.
* Add separate semaphores for offloaded and non-offloaded case, to
ensure that the packet ended up on the correct interface.
* The packet loopback in RX cases was broken, the LL address, IP
address and UDP port swap written data in wrong places.
* The receive path was not tested in the offloaded case.
Additionally, do a small cleanup before adding more tests:
* Fix net_context leak.
* Configure IPv6 neighbor once, during setup.
* Add before function to cleanup the flags before tests execute.
* Split tests into separate test cases, as they're not really
dependent on each other.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The optlen parameter passed to getsockopt() should be of (socklen_t *)
type. Using int produced build errors on 64 bit platforms.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Recently added tests require more stack on certain platforms
(nrf52840dk_nrf52840 in this case), hence increase the ZTEST stack size.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add case 'test_resend_request' to test that coap_client resends
the message if no response received.
Add response code check to case 'test_no_response'.
Initialize messages_needing_response[] in test setup.
Lower CONFIG_COAP_INIT_ACK_TIMEOUT_MS and decrease delays.
Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
Instead of forcing use of NEWLIB_LIBC, select any available complete C
library implementation. Add CONFIG_REQUIRES_FLOAT_PRINTF where needed.
Signed-off-by: Keith Packard <keithp@keithp.com>
This checks that if connect() timeouts, we check TCP pointer
properly in select() and poll() in order to catch the situation.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If the first Ethernet interface is not the first network
interface, then there might be two interfaces with the same name.
The test does not like that.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The sent pkt must be removed after we have cloned it
in the simulated driver otherwise there is a memory leak.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The IPV6_V6ONLY option is only checked if
CONFIG_NET_IPV4_MAPPED_TO_IPV6 option is set.
By default the IPV6_V6ONLY option is set.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
When resource instances are initialized, we must calculate
beginning of the data buffer using the index and maximum
data length. Otherwise buffers would overlap with previous.
Fixes#64011
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Resend the request with Echo option and the received Echo
option value when receiving a 4.01 (Unauthorized) response
with the Echo option.
Add missing header file kernel.h to coap_client.h.
Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
Add new configuration value CONFIG_LWM2M_UPDATE_PERIOD
that allows calculating update period from last update,
instead of calculating it from the lifetime.
In runtime, server is allowed to change the lifetime of the
registration which causes update perdiod to be effected.
When fixed update period is preferred, UPDATE_PERIOD
config is then used.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Split the conversion of the RTR frame flags from the data contents test as
RTR frames do not carry any data.
Replace a couple of direct DLC assignments with proper use of
can_bytes_to_dlc().
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
rand32.h does not make much sense, since the random subsystem
provides more APIs than just getting a random 32 bits value.
Rename it to random.h and get consistently with other
subsystems.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Only confirmable messages need pending tracking. Non-confirmable
messages are released after sending.
Match incoming packets with token, not message ID.
Ignore responses with non-matching tokens.
Remove unused function send_reset().
Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
In case observation token changes (the LwM2M server re-sends
observation request to the client), the LwM2M engine should cancel any
ongoing notifications based on the old token. Otherwise, it will be
impossible to match the pending notification reply (ACK) with the
observer context anymore, causing new notifications for this
observation to stall.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Always clone net_pkt to pass to promiscuous queue.
Previously, net_pkt was passed to L2 before conditionally cloning.
But L2 would in some cases strip ethernet headers, so cloned
net_pkt received through promiscuous interface would be missing headers.
Signed-off-by: Kieran Tyrrell <kieran@sienda.com>
Rearranges the k_mem_slab fields so that information that describes
how much of the memory slab is used is co-located. This will allow
easier of its statistics into the object core statistics reporting
framework.
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
A minor overlook from the recent ICMP rework, the registered handlers
should no longer unref the processed packet as it's now the
responsibility of the ICMP module.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
A little refactoring that simplifies dealing with nanosecond timestamp
values in packets and further decouples calling code from PTP:
Benefits:
- simplifies calling code by removing redundant conversions.
- prepares for removing PTP dependencies from net_pkt.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Added a new event for LWM2M_RD_CLIENT_EVENT_DEREGISTER for
indicate LwM2M client dereistartion.
Updated unit test and sample for new event type
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
net_context_foreach() is not a systemcall, therefore should not be used
from userspace threads. Usage of this API made SO_REUSADDR/SO_REUSEPORT
userspace tests unfunctional (crashing).
Fix this by using CONFIG_NET_TCP_TIME_WAIT_DELAY instead for tests that
involve TCP connections. Other tests don't really need to wait as
there's no teardown delay on UDP or unconnected TCP contexts.
Additionally, remove the platform exclude for qemu_x86 platform, as this
was the sole reason the tests were crashing on that platform.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add tests for the DHCPv6 library. The tests verify that:
* message format is valid for the outgoing messages
* incoming messages are only processed in respective states
* processing through standard DHCPv6 transactions is correct
(Solicit/Confirm/Renew/Rebind)
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Replaces the previous approach to define bands via hardware capabilities
by the standard conforming concept of channel pages.
In the short term this allows us to correctly calculate the PHY specific
symbol rate and several parameters that directly depend from the symbol
rate and were previously not being correctly calculated for some of the
drivers whose channel pages could not be represented previously:
* We now support sub-nanosecond precision symbol rates for UWB. Rounding
errors are being minimized by switching from a divide-then-multiply
approach to a multiply-then-divide approach.
* UWB HRP: symbol rate depends on channel page specific preamble symbol
rate which again requires the pulse repetition value to be known
* Several MAC timings are being corrected based on the now correctly
calculated symbol rates, namely aTurnaroundTime, aUnitBackoffPeriod,
aBaseSuperframeDuration.
In the long term, this change unlocks such highly promising functional
areas as UWB ranging and SUN-PHY channel hopping in the SubG area (plus
of course any other PHY specific feature).
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
lwm2m_udp_receive() is only called with same function
pointer, so there no need to carry that in the parameter.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Use the new Pytest integration to run testcases against Leshan.
Test with:
twister -T tests/net/lib/lwm2m/functional -p native_posix -vv
This requires Leshan running in localhost using following setup:
tcp/8080 Leshan web interface and REST API
tcp/8081 Leshan bootstrap server REST API
udp/5683 Leshan non-secure CoAP
udp/5684 Leshan DTLS CoAP
udp/5783 non-secure Bootstrap CoAP
udp/5684 DTLS Bootstrap CoAP
Leshan and Boostrap server must be reachable from native_posix
run using IP address 192.0.2.2 as in most of the examples.
Tests are written from test spec;
OMA Enabler Test Specification (Interoperability) for
Lightweight M2M
Following tests are implemented in this commit:
* LightweightM2M-1.1-int-0 – Client Initiated Bootstrap
* LightweightM2M-1.1-int-1 – Client Initiated Bootstrap Full (PSK)
* LightweightM2M-1.1-int-101 – Initial Registration
* LightweightM2M-1.1-int-102 – Registration Update
* LightweightM2M-1.1-int-104 – Registration Update Trigge
* LightweightM2M-1.1-int-105 - Discarded Register Update
* LightweightM2M-1.1-int-107 – Extending the lifetime of a registration
* LightweightM2M-1.1-int-108 – Turn on Queue Mode
* LightweightM2M-1.1-int-109 – Behavior in Queue Mode
* LightweightM2M-1.1-int-201 – Querying basic information in Plain Text
* LightweightM2M-1.1-int-203 – Querying basic information in TLV format
* LightweightM2M-1.1-int-204 – Querying basic information in JSON format
* LightweightM2M-1.1-int-205 – Setting basic information in Plain Text
* LightweightM2M-1.1-int-211 – Querying basic information in CBOR format
* LightweightM2M-1.1-int-212 – Setting basic information in CBOR format
* LightweightM2M-1.1-int-215 – Setting basic information in TLV format
* LightweightM2M-1.1-int-220 – Setting basic information in JSON format
* LightweightM2M-1.1-int-221 – Attempt to perform operations on Security
* LightweightM2M-1.1-int-401 – UDP Channel Security – PSK Mode
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
This commit adds unit tests for the SO_REUSEPORT sockets option. It also
fixes some bugs in other tests triggered by the new features.
Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
This commit adds unit tests for the SO_REUSEADDR socket option to test
the different possible scenarios for the option to work correctly.
There is also a fix for the TCP testsuite to make a now failing test
pass again due to a TIME_WAIT socket.
Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
In low memory conditions, its possible for socketpair memory allocation
to fail and then the socketpair is freed but after that the remote
semaphore is released causing a crash.
Fix this by freeing the socketpair after releasing the semaphore. Add a
test case to induce low memory conditions (low HEAP and high socketpair
buffer size), with the fix issue is not seen.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Avoid to use debug log level for all modules and keep it only for MQTT
and NET related modules.
mr_canhubk3 board will fail to initialize the on-board watchdog within
the expected window causing a board reset, due to the amount of log
messages being printed. Other boards may also be affected.
Signed-off-by: Manuel Argüelles <manuel.arguelles@nxp.com>
The tests `content_json` and `content_plain_test` depend on the float
support of libc. After PR##57340, Picolibc would be selected in
these two tests and the `PICOLIBC_IO_FLOAT` won't be selected if
the platform doesn't select `FPU`.
This commit select `CONFIG_PICOLIBC` and `CONFIG_PICOLIBC_IO_FLOAT`
for these two tests.
Signed-off-by: Huifeng Zhang <Huifeng.Zhang@arm.com>
RD client tests work well on emulated (fast) environments
but tend to fail on real HW with real time sleeps.
This change refactors wait_for_service() to be a bit more
syncronous on background service, instead of relying hardcoded
sleeps.
Fixes#61824
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Add TCP test case which verifies that if RST+ACK packet is received
during TCP handshake, the connection is brought down and
net_context_connect() fails.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This test is too dependent on the exact order of events,
and known to fail in most platforms but native_posix.
To mitigate the issue and avoid blocking development
due to failed CI tests, let's only allow the test in
native_posix.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Make sure we use the network interface name (if configured)
instead of device name when binding to certain network
interface.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The connectivity monitoring subfeature of conn_mgr is currently also
named conn_mgr, which is confusing.
This commit renames it to conn_mgr_monitor, or conn_mgr_mon for short,
for clarity.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Splits many definitions from conn_mgr_connectivity.h off into their own
header, conn_mgr_connectivity_impl.h
conn_mgr_connectivity.h now focuses solely on user/application-facing
APIs, and conn_mgr_connectivity_impl now contains all functions, utils,
definitions intended for use by connectivity implementations, including
conn_mgr_if_get_binding, which is now available for use by connectivity
implementations.
This lays the foundation for allowing connectivity implementations
easier and safer access to their internal state through internal APIs.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Add tests which verify that getsockname() function works as expected.
Additionally, add a teardown delay in tests involving TCP, to make sure
all resources are released before the test ends, not to interfere with
other tests.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add test cases which verify that when UDP socket is connected, it only
accepts datagrams from a remote peer it was connected to, and not
others.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add module tests for all data types and most of deprecated
functions as well.
Refactor event wainting to expect_lwm2m_rd_client_event() which
does not care about the index, just the order.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Implemented testcase to check if the retransmitted FIN packet
from the FIN1 state has the correct sequence number.
Also fix the endianness conversion of sequence numbers in the
tests to use 32-bit as it should instead of 16-bit.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
After the TCP socket has been closed, it should not accept any new data
and send a RST packet if it does receive some.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
For some reason, tests/net/socket/tcp/net.socket.tcp.preempt
was failing to link for vmu_rt1170 with these changes, and
for some reason reducing CONFIG_POSIX_MAX_FDS from 20 to 10
resolves that issue.
ld.bfd: scripts/build/gen_kobject_placeholders.py \
did not reserve enough space for kobject rodata.
Memory region Used Size Region Size %age Used
FLASH: 287860 B 64 MB 0.43%
RAM: 86460 B 512 KB 16.49%
OCRAM: 0 GB 256 KB 0.00%
OCRAM1: 0 GB 512 KB 0.00%
OCRAM2: 0 GB 512 KB 0.00%
ITCM: 0 GB 256 KB 0.00%
DTCM: 13908 B 256 KB 5.31%
IDT_LIST: 0 GB 2 KB 0.00%
collect2: error: ld returned 1 exit status
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
The FIONREAD ioctl (or rather ZFD_IOCTL_FIONREAD) returns the
number of bytes available on the socket that can be read
immediately.
Test that the ioctl behaves according to the expectation.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Add an `after()` function that is executed after each test in
the testsuite.
Previously, even if one one test failed, it would calls almost
all subsequent tests to fail. This way, other tests can still
succeed.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Add an `after()` function that is executed after each test in
the testsuite.
Previously, even if one one test failed, it would calls almost
all subsequent tests to fail. This way, other tests can still
succeed.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
The FIONREAD ioctl (or rather ZFD_IOCTL_FIONREAD) returns the
number of bytes available on the socket that can be read
immediately.
Test that the ioctl behaves according to the expectation.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
A fair bit of setup / teardown code was being duplicated in many
test cases in the socketpair testsuite.
Take advantage of the `setup()`, `before()`, and `after()`
functions in the new ZTest API.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
The provided function allows to remove a CoAP option in a
message. This is useful for reusing parts of a message.
Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
RD-client tests should wait longer for expected events.
Also the stubbed service worker should be stopped properly
after tests.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When BOOTSTRAP FINNISH message was received, it caused
engine to immediately switch to BOOTSTRAP_TRANS_DONE state
which then closed the connection.
Ack packet was still on the send-queue so it never got send before close().
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Fixing the bug with shadowed ret variable (and hence not returning
timeout error) reveled another bug in TCP server tests. Here, the
listening context was incorrectly used to receive new data, and since it
never arrived, the function timed out.
This commits fixes that issue, and limits the retransmission timeout to
ensure that Nagle's algorithm impact does not affect test timings.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Accidentally statements to enable logging in the TCP socket test
where pushed. This broke some tests running on real devices due
to the additional code size.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
This has failed in repeated CI runs. Filed an issue
for having it checked. Excluding it until it's
fixed.
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
To avoid a TCP connection from collapsing a link, implement a collision
avoidance algorithm. Initially TCP new Reno is implemented for its
simplicity.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Fix a build warning that is generated by new
enough compilers, when they detect the sprintf()
may overflow the destination buffer lenght.
The code which was generating the warnig was
actually not used, so we just remove it.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
These testcases are not SMP-safe, will fail on all SMP boards. Simply
turning them to 1cpu test can not fix the issue.
So, setting CONFIG_MP_MAX_NUM_CPUS to 1 as a workaround.
Signed-off-by: Jaxson Han <jaxson.han@arm.com>
Allow socket-loop to wake up immediately, if there are changes,
instead of waiting for zsock_poll() to timeout.
This change makes engine more reactive and removes
hard coded timeout from zsock_poll().
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
The IEEE 802.15.4 API and networking subsystem were using several
inconsistent timestamp resolutions and types. This change defines all
timestamps with nanosecond resolution and reduces the number of
available types to represent timestamps to two:
* `struct net_ptp_time` for PTP timestamps
* `net_time_t` for all other high resolution timestamps
All timestamps (including PTP timestamps) are now referred to a
"virtual" local network subsystem clock source based on the well-defined
types above. It is the responsibility of network subsystem L2/driver
implementations (notably Ethernet and IEEE 802.15.4 L2 stacks) to ensure
consistency of all timestamps and radio timer values exposed by the
driver API to such a network subsystem uptime reference clock
independent of internal implementation details.
The "virtual" network clock source may be implemented based on arbitrary
hardware peripherals (e.g. a coarse low power RTC counter during sleep
time plus a high resolution/high precision radio timer while receiving
or sending). Such implementation details must be hidden from API
clients, as if the driver used a single high resolution clock source
instead.
For IEEE 802.15.4, whenever timestamps refer to packet send or receive
times, they are measured when the end of the IEEE 802.15.4 SFD (message
timestamp point) is present at the local antenna (reference plane).
Due to its limited range of ~290 years, net_time_t timestamps (and
therefore net_pkt timestamps and times) must not be used to represent
absolute points in time referred to an external epoch independent of
system uptime (e.g. UTC, TAI, PTP, NTP, ...).
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Add tests cases which verify that net_if_ipv4/6_addr_foreach() executes
callbacks properly on assigned addresses.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Small refactoring that unifies the assertion order for improved
consistency across tests - placing the SUT before the expected value
everywhere.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Introduces an integration test that simulates an incoming disassociaton
notification from a coordinator.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Adds test coverage for the disassociation shell command that
disassociates the enddevice by notifying its coordinator.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This adds Wi-Fi tests for both offloaded and newly introduced network
manager managed interface. Only scan op is used to verify the network
manager code.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
This change introduces test coverage for association request and
response. Based on this coverage, several closely related issues were
found in the association process which cannot be split into separate
changes without breaking the build.
Most notably did the associate and disassociate net_mgmt commands send
already encoded IEEE 802.15.4 MPDUs to L3 rather than L2. L3 treated
them as payload and made L2 wrap them with another LL header/footer
which produced invalid packets.
The tests also enforce better aligment of the association process with
the IEEE 802.15.4-2020 standard:
* Association requests now ask for ACK as required by the standard. The
fake driver was enhanced to produce ACK packages when requested.
* macPanId and macCoordinator* MAC PIB attributes are set in the right
order for improved filtering of association responses.
* The coordinator may decide not to assign a short address to the end
device even when associated. This is now supported.
* The coordinator may or may not use a short address. Coordinators
choosing not to support short addresses are now supported.
* Updating the association will now remove any previously added short
address from the hardware filter.
* The short address may no longer be changed by the user while
associated to a PAN. Only the coordinator is allowed to allocate short
addresses.
* Validation of outgoing and incoming association request/response
packets is improved.
All changes are documented by pointers into the spec.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
To further reduce the need for networking boilerplate in applications,
provide bulk versions of net_if_up, net_if_down, conn_mgr_if_connect,
and conn_mgr_if_disconnect that affect all available / eligible ifaces
at once.
Since it is not intuitive whether these functions should affect ifaces
which conn_mgr is ignoring, these functions take an argument that allows
this to be specified by the application.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
To reduce the amount of boiler-plate needed in applications, this commit
grants conn_mgr the ability to automatically take ifaces that have given
up on connecting into the admin-down state.
Tests adjusted as appropriate.
This behavior can be disabled globally by disabling
NET_CONNECTION_MANAGER_AUTO_IF_DOWN, or disabled per-iface using the
CONN_MGR_IF_NO_AUTO_DOWN flag.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
To reduce the need for boilerplate in application code, conn_mgr now
supports an auto-connect feature on all ifaces with connectivity
bindings.
conn_mgr will automatically call conn_mgr_if_connect on any iface with a
connectivity binding that enters the admin-up state, unless the newly
added CONN_MGR_IF_NO_AUTO_CONNECT flag has been set for that iface.
Also adjust automated tests to account for and take advantage of this
behavior.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
- Add missing event sleep after taking all ifaces up in
test_connect_disconnect.
- Add missing event sleep after resetting ifaces in conn_mgr_conn_before
- Fix typo in comment for internal state flags.
- Add missing NET_MGMT_EVENT_BIT to conn_mgr_connectivity event
definitions.
- Missing net_mgmt.h include in conn_mgr_connectivity.h
- Split conn_mgr_conn iface reset into network and state resets, before
and after event sleep, so that triggered events do not corrupt the
state reset.
- Reduce SIMULATED_EVENT_DELAY to 100ms to avoid timeouts on real-time
targets.
- Use macro for simulated event wait times.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
The signal strength for the connectivity monitor was
defined as int8_t, however this was too small for
LTE RSRP values, which has range [-140,-44].
Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
If two IPv6 addresses have the same solicited-node multicast address
because they derive from the same EUI-64 interface identifier, make sure
that the solicited-node multicast address is not removed when one of the
IPV6 address is removed but only when both addresses are removed.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
The value of in6addr_mcast is overwritten in iface_setup() before being
assigned to the interface. Remove the useless initial value since it is
never used, in order to avoid misleading information.
Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
Lwm2m firmware object have defined a write of zero length
string as a cancel operation.
So allow lwm2m_set_opaque(path, NULL, 0);
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Content-format tests do not require network or
Newlibc, so by removing these filters.
Defined a native_posix as the only integration platform
because all simulated arm-zephyr-eabi platforms are
filtered out by Twister.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
As the lwm2m_reset_message() is stubbed, it does not remove
a message from rettry queue. Therefore depending on the
simulation speed, retries can happen one or many times.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
ZTEST(lwm2m_registry, test_strings) is using opaque resource
0/0/3 to write a test string "coap://127.0.0.1" which
happens to be same length as default key size.
Need more room to add end marker and verify it.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Pause and resume functionality was written into assumption
that sockets are closed before resuming.
With use new options CONFIG_LWM2M_RD_CLIENT_STOP_POLLING_AT_IDLE
or CONFIG_LWM2M_RD_CLIENT_LISTEN_AT_IDLE this is not always true.
Fix the state machine, so that on those cases, sockets are not
closed and resume is always similar like from the QUEUE mode.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Add support for using X509 certificates.
Default settings use ECDSA certificates with SHA256 hash.
When different settings are required clients should overwrite
struct lwm2m_ctx->load_credentials() and
struct lwm2m_ctx->set_socketoptions()
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When writing string data to resources which are string types,
we should count in the terminating character into the data length.
Corner cases exist where LwM2M resource type is opaque but
lwm2m_get_string() or lwm2m_set_string() are used to read/write
the data. We must ensure string termination on those case, but
terminating character must not be stored in the engine buffer
or counted in the data length as this might be considered
as part of the binary data.
Fixes#59196
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
The ACK procedure had the following issues:
- MAC commands were not acknowledged.
- When the package is a broadcast package the package must not be
acknowledged.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Acknowledgment is mandatory if legitimately requested by the package's
"ACK requested" flag. The L2 layer will have to ensure that compliant
ACK packages will always be sent out automatically as required by the
standard.
For IEEE 802.15.4 compliance, the NET_L2_IEEE802154_ACK_REPLY option is
therefore being deprecated.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The existing calls to ieee802154_radio_send() and soft MAC ACK handling
were inconsistent and/or not properly integrated with more recent
radio driver capabilities as CSMA/CA and ACK in hardware.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The method ieee802154_radio_handle_ack() does not belong to the
PHY/radio layer but to the L2 layer. It is a callback called from the
radio layer into the L2 layer and to be implemented by all L2 stacks.
This is the same pattern as is used for ieee802154_init(). The
'_radio_' infix in this function is therefore confusing and
conceptually wrong.
This change fixes the naming inconsistency and extensively documents
its rationale.
It is assumed that the change can be made without prior deprecation of the
existing method as in the rare cases where users have implemented custom
radio drivers these will break in obvious ways and can easily be fixed.
Nevertheless such a rename would not be justified on its own if it were
not for an important conceptual reason:
The renamed function represents a generic "inversion-of-control" pattern
which will become important in the TSCH context: It allows for clean
separation of concerns between the PHY/radio driver layer and the
MAC/L2 layer even in situations where the radio driver needs to be
involved for performance or deterministic timing reasons. This
"inversion-of-control" pattern can be applied to negotiate timing
sensitive reception and transmission windows, it let's the L2 layer
deterministically timestamp information elements just-in-time with
internal radio timer counter values, etc.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The IEEE 802.15.4 standard clearly separates clear channel assessment
from retransmission. This separation of concern was not represented in
the current channel access vs. retransmission implementation which
resulted in considerable duplication of code and logic.
This change removes the duplication of logic and encapsulates the
resulting functions in a private API that may only be used from within
Zephyr's native L2 layer.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This commit replaces the workarounds spread around the
drivers and subsystems with the updated PPP L2
interface.
Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
The RSSI value in net_pkt (net_pkt_cb_ieee802154.rssi) was used
inconsistently across drivers. Some drivers did cast a signed dBm value
directly to net_pkt's unsigned byte value. Others were assigning the
negative value of the signed dBm value and again others were offsetting
and stretching the signed dBm value linearly onto the full unsigned byte
range.
This change standardizes net_pkt's rssi attribute to represent RSSI on
the RX path as an unsigned integer ranging from 0 (–174 dBm) to 254 (80
dBm) and lets 255 represent an "unknown RSSI" (IEEE 802.15.4-2020,
section 6.16.2.8). On the TX path the rssi attribute will always be
zero. Out-of-range values will be truncated to max/min values.
The change also introduces conversion functions to and from signed dBm
values and introduces these consistently to all existing call sites. The
"unknown RSSI" value is represented as INT16_MIN in this case.
In some cases drivers had to be changed to calculate dBm values from
internal hardware specific representations.
The conversion functions are fully covered by unit tests.
Fixes: #58494
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Add similar test as for TCP, that verifies that accept() call is
interrupted correctly when the socket is closed from another thread.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add test that verifies that accept() call is interrupted correctly when
the socket is closed from another thread.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add test that verifies that recv() call is interrupted correctly when
the socket is closed from another thread.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Currently the insertion of an authentication tag requires a memcpy() call
and breaks encapsulation.
This change removes the need for memcpy() and improves the encapsulation
by calculating and reserving the required headspace early on while
keeping insertion where it belongs in the outgoing security procedure.
This is also a preparation for improved standard compliance of the
outgoing security procedure which is scheduled for a later commit.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The naming of variables and arguments containing the authentication
tag length was inconsistent:
* Naming inconsistency between header "length" vs. authtag "size"
in the same API calls
* "Tag" rather than "Auth[orization ]Tag" in external API calls
which is too generic from a compliance and readability viewpoint.
This is in preparation to zero-copy authentication support.
Almost all call sites will be subject to required structural changes
later on so no relevant git blame noise/history loss will be introduced
by this naming change in the long run.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This change introduces test coverage for payload length calculation
to stabilize the change introduced earlier and ensure that future
changes will not cause regressions in that area.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current implicit MAC payload length algorithm (based on
an otherwise irrelevant footer pointer) produces invalid
(non-standard) values for beacon and command frames.
This change produces standard-conforming MAC payload length
values and simplifies access to payload length.
It would have been possible to fix the current footer pointer
based approach but there are arguments in favor of the new
approach:
- The footer pointer is used nowhere in the current code
base and makes length calculations rather non-obvious.
- The new approach does not use more memory and is easier
to understand and use.
- This change is a first step to support of IEEE 802.15.4
information element (IE) support. At a later stage the
distinction between MAC payload length and frame payload
length will be introduced and become relevant to
distinguish between header and payload IEs. At that point
the current implicit length calculation algorithm will
break down anyways.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This change introduces integration test coverage for the
stack's scan shell command including the underlying net
management and command handling methods.
Later changes will build on this test to ensure that
changes to command handling will not break backwards
compatibility
This is also the reason why a separate test suite and
test file are being introduced already as further tests
will be added later on. We avoid having to move code
and thereby loose history.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Add tests for the option callback API. The test uses a previously unused
option already contained in the sample offer.
Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
Until now iterable sections APIs have been part of the toolchain
(common) headers. They are not strictly related to a toolchain, they
just rely on linker providing support for sections. Most files relied on
indirect includes to access the API, now, it is included as needed.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This change splits the IEEE 802.15.4 test into two separate
test profiles, one with and one without sockets enabled to ensure
that both configurations work correctly.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
IEEE 802.15.4-2020 introduces a sequence number suppression feature.
This change covers sequence number handling to ensure that future
changes will not break sequence number handling when introducing
the sequence number suppression feature.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This refactoring dries up duplicate code required to configure
the socket address structure used in tests.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Additional test cases introduced in later commits will re-use
an existing test frame that requests acknowledgement. It is
therefore extracted into a function.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Additional test case that covers reception of AF_SOCKET/SOCK_DGRAM
packages via socket API.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
When changing IEEE 802.15.4 security settings or setting security
to 'none' then the previous session must be cleaned up to avoid
resource leaks.
This change introduces proper clean-up of the security session.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Security set-up and clean-up is extracted into functions
to enable re-use by test cases introduced in later commits.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Improves inline documentation of binary IEEE 802.15.4 frames
to ease future maintenance. In this case the frame required
for testing raw sockets.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This is a purely syntactical change that makes test case
expectations configuration more readable.
This is required as later commits will introduce further
expectations.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
In the FIN_WAIT_1 any incoming data is dropped, but anknowledged. Add a
check to see if the data is already acknowleged to prevent double
acknowledging of the data and bringing the acknowlegde counter out of
sync. When the acknowledge counter gets out of sync, the connection will
never properly terminate any more.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Due to more strict checking of the sequence numbering in the FIN_WAIT_1
state in the tcp stack, the test broke. Fix the sequence numbering
for sending the FIN and FIN ACK messages.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Rather than raise error on connect if iface is down, just take the iface
up.
Rather than raise error on disconnect if iface is down, just ignore the
disconnection request.
Adjust tests and documentation accordingly.
This should make the API easier to use for applications and is more in
line with the original L2 agnostic connectivity RFC.
Also replace some instances of net_if_flag_is_set with
net_if_is_admin_up, which is cleaner and identical in function.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Relocate conn_mgr_if_get_binding to conn_mgr_private.h so that it
can be used by test suites.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Provide an extra struct net_if * iface parameter to
net_if_ipv*_maddr_join/leave functions, so that the corresponding
interface context, the mcast address belong to, can be locked for the
operation.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Twister now supports using YAML lists for all fields that were written
as space-separated lists. Used twister_to_list.py script. Some artifacts
on string length are due to how ruamel dumps content.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The arm-clang compiler/linker does not optimize away unused function
symbols and thus will error if symbols that are referenced are not
defined. To fix this add needed ifdef'ry.
Build various network samples that utilize ethernet but don't have
CONFIG_NET_PROMISCUOUS_MODE will get a link error for:
Error: L6218E: Undefined symbol
net_mgmt_NET_REQUEST_ETHERNET_SET_PROMISC_MODE
(referred from ethernet.o).
Fix by adding ifdef protection around promisc code.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
As the test uses iterable sections, we need to utilize
zephyr_iterable_section for targets that need linker script
generation like arm-clang.
So add zephyr_iterable_section() for the ROM sections that the
testcases utilizes.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
conn_mgr events cannot be used due to mistake in event definitions.
Fix these definitions so that events can be used.
Also patch hole in test coverage that allowed this in the first
place.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Remove all init functions that do nothing, and provide a `NULL` to
*DEVICE*DEFINE* macros.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Set explicit loopback MTU for TCP tests for clarity,
and to avoid breaking tests if changed elsewhere.
Signed-off-by: Kenny Johansson <wirehell@gmail.com>
Some utility functions belong to lwm2m_util.c.
Block contexts belong to lwm2m_message_handling.c
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Many areas of Zephyr divide and round up without using the DIV_ROUND_UP
macro. Make use of it, so that we make use of a tested system macro and
at the same time we make code more readable.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
If server or bootstrap writes a lifetime value less than
configured default lifetime, client will automatically overwrite
the value with default one.
This gives better control for the application where client
behaviour is fine tuned on the Kconfig, but default values
from bootstrap server cannot be fine-tuned.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
This function had only one use in SenML CBOR formatter and it
contained some specific tweaks, so move the function to be a
static member of that module.
Fixes#53674
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Instead of passing the test parameters to the websocket function, by
casting the pointer to integer (which may not work on 64-bit platform
due to int/pointer size mismatch), let the test allocate a file
descriptor, and initialize it with test context. The tested functions
expect a file descriptor as an argument anyway, so it's a more intuitive
approach.
The conditional test code within WS implementation can retrieve the test
context by using FD APIs to obtain the object represented by the FD.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
TC_START is used to evaluate output of tests and is used internally by
ztest when a test starts, no need to call this manually here.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
TC_START is used to evaluate output of tests and is used internally by
ztest when a test starts, no need to call this manually here.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
TC_START is used to evaluate output of tests and is used internally by
ztest when a test starts, no need to call this manually here.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The websocket library uses int for pointers for testing and does not
work reliably on 64 bit architectures.
Exclude the test so it does not block other unrelated PRs.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Add new test cases for SO_RCVBUF/SO_SNDBUF which verify that setting
those options actually affects the RX/TX window sizes at the TCP level.
Existing tests only verified whether the options can be set/read
correctly.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Adds dummy link layer for offloaded ifaces, allowing
ifaces to directly receive l2_enable calls
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Previously, `socketpair()` tests had pulled in the native
`fcntl()` implementation instead of using the Zephyr version
when being run under `native_posix_64`.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
This adds set of unit tests for simple network buffers.
The suite is based of the test cases that are already defined for
network buffers.
Those test_net_buf_byte_order test case have been split to
smaller tests testing one functionality at a time.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This drops using the environmental part when referencing ZEPHYR_BASE
as the environment value does not have to be set and, in most cases,
is no longer set at all.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>