Commit graph

1722 commits

Author SHA1 Message Date
Robert Lubos be4400e80d tests: net: socket: tls: Add helper for TLS connection establishment
Move the code responsible for TLS connection establishment to a helper
function, as it'll be needed as well in other test cases.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-20 11:10:57 +01:00
Robert Lubos 833d565c36 tests: net: socket: tls: Remove unnecessary delay from test cases
SO_TYPE and SO_PROTOCOL test cases does not really establish connection,
so teardown delay at the end is not needed.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-20 11:10:57 +01:00
Joakim Andersson cb13e21eae tests: net: socket: tcp: Fix build for nrf5340dk_nrf5340_cpuapp_ns
Fix build for nrf5340dk_nrf5340_cpuapp_ns.
Test takes up almost all of the flash, leaving no room for the image
to be signed. Disable the bootloader to free up flash-usage.

Fixes: #66469

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2023-12-15 14:05:55 +01:00
Juha Ylinen f9fa2ae77c tests: net: coap: Add test case for transmission parameters
Add new test case.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-12-15 11:41:27 +00:00
Juha Ylinen d09d3d82ef net: lib: coap: Change coap_pending_init()
Replace function parameter 'retries' with pointer to structure
holding coap transmission parameters. This allows setting the
retransmission parameters individually for each pending request.

Add coap transmission parameters to coap_pending structure.

Update migration guide and release notes.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-12-15 11:41:27 +00:00
Jukka Rissanen 67d21c8b1d tests: net: if: Add test to check device readiness
Add tests that check if device is ready or not, and
then verify the functionality of net_if_up() in that case.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-14 14:21:31 +01:00
Juha Ylinen 69e28939dd net: lib: coap: Add new API to configure retransmission settings
Add new functions to the public CoAP API to configure CoAP packet
retransmission settings. Application may need to re-configure the
settings for example when cellular modem changes connection from
LTE-M to NB-IoT or vice versa.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-12-12 10:56:29 +01:00
Robert Lubos 504d927483 tests: net: socket: tcp: Add tests for TCP keep alive feature
Verify that TCP keep alive options can be set properly and that TCP
connections time out correctly when keep-alive probes fail to get
replies.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-11 10:11:10 +01:00
Seppo Takalo b4bdbfd76b test: lwm2m: Run interop tests in tickless mode
Tickless mode is important to be tested against real server.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-11 09:57:09 +01:00
Seppo Takalo 725ceb72b7 test: lwm2m: Implement missing test case 103
Testcase 103 required "Disabled" functionality.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-08 20:18:37 +00:00
Seppo Takalo 51869b3e45 test: lwm2m: Implement bootstrap tests 4 - 7
* LightweightM2M-1.1-int-4 - Bootstrap Delete
* LightweightM2M-1.1-int-5 - Server Initiated Bootstrap
* LightweightM2M-1.1-int-6 - Bootstrap Sequence
* LightweightM2M-1.1-int-7 - Fallback to bootstrap

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-08 20:18:37 +00:00
Pieter De Gendt 8084a1c908 tests: net: mgmt: Add test cases new worker options
Run the Network event tests also on the system work queue and
synchronous.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-07 16:15:53 +00:00
Robert Lubos 429798c141 tests: net: socket: udp: Increase ztest stack size
The default ztest stack size was too small to run new UDP tests on
certain platforms (nrf52840 in this particular case), therefore increase
teh stack size in prj.conf.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-07 05:22:58 -05:00
Seppo Takalo 30dcf1b309 test: lwm2m: Refactor tests to work with fallback changes
In fallback refactoring to the LwM2M engine, some changes
to the server object are visible in hard-coded test
values.

Also, add Endpoint wrapper class that ensures the registration
state of the returned endpoint.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-05 16:40:06 -06:00
Seppo Takalo dc8f6da53c net: lwm2m: Implement fallback mechanism and support for diable
If server registration fails, allow fallback to secondary server,
or fallback to bootstrap.
Also allow fallback to different bootstrap server.

Add API to tell RD client when server have been disabled by
executable command.

Changes to RD state machine:
* All retry logic should be handled in NETWORK_ERROR state.
* New state SERVER_DISABLED.
* Internally disable servers that reject registration
* Temporary disable server on network error.
* Clean up all "disable timers" on start.
* Select server first, then find security object for it.
* State functions return void, error handling is done using states.
* DISCONNECT event will only come when client is requested to stop.
* NETWORK_ERROR will stop engine. This is generic error for all kinds
  of registration or network failures.
* BOOTSTRAP_REG_FAILURE also stops engine. This is fatal, and we cannot
  recover.

Refactoring:
* Server selection logic is inside server object.
* sm_handle_timeout_state() does not require msg parameter. Unused.
* When bootstrap fail, we should NOT back off to registration.
  This is a fatal error, and it stops the engine and informs application.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-05 16:40:06 -06:00
Pieter De Gendt b31d73f69c tests: net: mgmt: Add test for static event handlers
Add a testcase for event handlers in the iterable section.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-05 09:17:42 -05:00
Jukka Rissanen 0bc1423335 tests: net: mld: Add socket based join/leave tests
Make sure the IPV6_ADD_MEMBERSHIP and IPV4_DROP_MEMBERSHIP
work as expected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 16:38:49 +00:00
Jukka Rissanen 36f5cfae2c tests: net: igmp: Add socket based join/leave tests
Make sure the IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP
work as expected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 16:38:49 +00:00
Jukka Rissanen f8c88a3fa6 tests: net: dns-sd: Fix IPv4 TTL and IPv6 hop limit checking
We need to use multicast TTL/hoplimit instead of unicast one
in the test.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen 921c945dab tests: net: udp: Verify that packet is dropped from stats
Make sure that statistics is properly update for dropped
packets when IPv4 TTL is 0 or IPv6 hop limit is 0.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen c32e06fcb5 tests: net: udp: Add IPv6 hop limit 0 test
Make sure packet is dropped if IPv6 hop limit 0 packet is
tried to send.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen 28a8c6c00d tests: net: udp: Add IPv4 TTL 0 test
Make sure packet is dropped if TTL 0 packet is tried to
send.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen 27d4c5d491 tests: net: udp: Add IPv4 unicast TTL tests
Make sure that setting IPv4 unicast TTL works as expected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen 7474007e64 tests: net: udp: Add IPv6 unicast hop limit tests
Make sure that setting IPv6 unicast hop limit works as expected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen 8bd612c522 tests: net: udp: Add IPv6 multicast hop limit tests
Make sure that setting IPv6 multicast hop limit works as expected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen cee2b3ae26 tests: net: udp: Add IPv4 time-to-live multicast tests
Make sure that setting IPv4 multicast TTL works as expected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen de0268def0 net: context: Add support for adjusting IPv4 multicast ttl
Add option support for adjusting the IPv4 multicast
time-to-live value.

Fixes #60299

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen af610bb207 tests: net: shell: Increase number of IP address structs
A warning is printed in start of the test about this.
Increase CONFIG_NET_IF_MAX_IPV6_COUNT=2 and
CONFIG_NET_IF_MAX_IPV4_COUNT=2 so that the tests pass
in frdm_k64f and some other boards.

Fixes #66020

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 09:57:35 +01:00
Jukka Rissanen 3783a7eccd tests: net: dns_sd: Increase the number of contexts
Issue seen in frdm-k64f + some other boards.

Fixes #66033

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 09:57:35 +01:00
Pieter De Gendt b500f7216e tests: net: lib: coap_server: Do not autostart service B with port 0
A race condition for the test occurs as the service might have started
when booting.
Do not autostart the service to verify the port stays 0.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-01 10:56:47 +00:00
Jukka Rissanen 5d915398a4 net: sockets: Add additional checks to recvmsg()
Add extra checks that make sure that msg_iov is set
as we cannot receive anything if receive buffers are
not set.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-01 10:56:34 +00:00
Robert Lubos 5bbf898905 tests: net: socket: tcp: Fix FD leak in fionread tests
Socket close was missing in fionread tests, causing file descriptor
leak.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-30 10:06:50 +01:00
Robert Lubos 95155c1fae tests: net: tcp: Add small delay when checking context dereference
Since the TCP context (and thus net_context) is not dereferenced
directly from the test thread anymore, add a small delay so that TCP
work queue have a chance to run, before checking net_context count or
reusing the port on new allocation.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-30 10:06:50 +01:00
Andreas Chmielewski 72f7a05a8b tests: lwm2m_rd_client: Added more fff tests
If the rdclient is suspended or deregistered any network errors caused
by lwm2m_engine and forwarded by socket_fault handler should not change
the rd client state.

Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-11-30 10:05:30 +01:00
Jukka Rissanen 55958d851f net: context: Refactor option getters
Set separate option getters for bool, uint8_t and uint16_t
values. Use those generic getters when fetching the desired
option value.

Noticed mixed usage (bool vs int) for txtime option. Changed
the code to use int type like in other options.

The uint16_t option getter gets the value from uint16_t variable
but returns int value to the caller, and also expects that user
supplies int value.

For uint8_t value, it is expected that uint8_t value is supplied
instead of int.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-30 10:05:06 +01:00
Konrad Derda f9c4ae6cf6 tests: net: hostname: test hostname related events
Add test case to ensure that NET_EVENT_IF_HOSTNAME_CHANGED event is
triggered properly when the hostname changes.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2023-11-29 13:16:16 -06:00
Jukka Rissanen 5539a47eb6 tests: net: socket: Add recv pktinfo ancillary tests for recvmsg
Make sure recvmsg() is able to return IPv4 IP_PKTINFO and
IPv6 IPV6_RECVPKTINFO ancillary data to the caller.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-27 19:58:47 +01:00
Jukka Rissanen bb880c6457 tests: net: udp: Make receive timeout shorter
No need to wait 2.5 seconds for the test to pass, 400ms wait
is enough.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-27 19:58:47 +01:00
Jukka Rissanen 34929a57e0 tests: net: socket: Add TCP tests for recvmsg()
Make sure recvmsg() works as expected for TCP data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-27 19:58:47 +01:00
Jukka Rissanen 0b71043f6a tests: net: socket: Add UDP tests for recvmsg()
Make sure recvmsg() works as expected for UDP data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-27 19:58:47 +01:00
Seppo Takalo a8d56c4f1f net: scripts: Use native_sim instead of native_posix
Sample tests should also be using native_sim board.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-11-27 19:55:30 +01:00
Seppo Takalo 31e9a56742 test: lwm2m: Test cancellation using observe parameter
Implement test cases:
LightweightM2M-1.1-int-303 - Cancel observations using Observe with
Cancel parameter

LightweightM2M-1.1-int-305 - Cancel Observation-Composite Operation

Modify existing Leshan API to passive_cancel().

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-11-22 09:54:13 +01:00
Seppo Takalo 2135e009e4 test: lwm2m: Implement Read-Composite Operation on root path
Test case:
LightweightM2M-1.1-int-235 - Read-Composite Operation on root path
is now working as Leshan added a support for reading the root path.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-11-22 09:54:13 +01:00
Seppo Takalo 92ceaab491 test: lwm2m: Implement write_attributes()
Implement write and remove attributes command for Leshan.
Remove all written attributes at the end of test, so it won't
affect the next test case.

Remove skip marks from testcase that is fixed on Leshan side.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-11-22 09:54:13 +01:00
Seppo Takalo eb127538b1 test: lwm2m: Mark some tests as slow
This allows quick filtering with
pytest_args: ['-k not slow']

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-11-22 09:54:13 +01:00
Ibe Van de Veire 1d0f47b005 net: ip: igmp: add igmpv3 support
Added igmpv3 support based on the already existing structure for igmpv2.
The already existing api is not modified to prevent breaking exisiting
applications.

Signed-off-by: Ibe Van de Veire <ibe.vandeveire@basalte.be>
2023-11-21 15:50:31 +01:00
Alberto Escolar Piedras c5e0f6c0ff tests/net/lib/http_server: Switch from native_posix to native_sim
Switch from native_posix to native_sim as default test platform

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-20 09:21:13 +01:00
Alberto Escolar Piedras 8991e0176c tests/net/lib/coap_server: Switch from native_posix to native_sim
Switch from native_posix to native_sim as default test platform

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-20 09:21:13 +01:00
Alberto Escolar Piedras 0a81ea5406 tests/net/socket/can: Switch from native_posix to native_sim
Switch from native_posix to native_sim as default test platform

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-20 09:21:13 +01:00
Alberto Escolar Piedras a86e0a8da9 tests/net/lib/lwm2m/*: Switch integation_platforms to native_sim
Switch integation_platforms from native_posix to native_sim

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-20 09:21:13 +01:00
Alberto Escolar Piedras 640b926b0a tests/net/lib lwm2m_engine: Switch from native_posix to native_sim
Switch support of native_posix to native_sim

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-20 09:21:13 +01:00
Alberto Escolar Piedras 0de923e2b0 tests/net/lib/lwm2m/interop: Switch from native_posix to native_sim
Switch support of native_posix to native_sim

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-20 09:21:13 +01:00
Alberto Escolar Piedras f7b8ded41a tests/net/lib/coap_client/: Enable for native_sim
Enable this test for native_sim

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-20 09:21:13 +01:00
Alberto Escolar Piedras c64f33a648 tests/net lwm2m_rd_client: Switch from native_posix to native_sim
Switch these tests from native_posix to native_sim

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-20 09:21:13 +01:00
Alberto Escolar Piedras eae99c1035 tests net/ptp/clock: Enable for native_sim
Enable these tests for native_sim and switch from
native_posix to native_sim as default test platform

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-20 09:21:13 +01:00
Alberto Escolar Piedras 18d27f0a29 tests ieee802154: Enable for native_sim
Enable these tests for native_sim and switch from
native_posix to native_sim as default test platform

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-20 09:21:13 +01:00
Alberto Escolar Piedras 6bba2d955b tests/net/traffic_class: Enable for native_sim
Enable these tests in native_sim
and switch from native_posix to native_sim as default
test platform

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-20 09:21:13 +01:00
Anas Nashif f25e2201a4 tests: fix various test identifiers
Fix a few inconsistent test identifiers.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-17 09:27:40 +01:00
Pieter De Gendt 74db066941 tests: net: lib: Add CoAP service tests
Add a test for CoAP macro usage.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-09 11:21:42 +01:00
Robert Lubos f505dc528e tests: net: checksum_offload: Add tests involving IP fragmentation
Add test cases verifying proper checksum calculation involving
IPv4/IPv6 fragmentation.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos 5f8a73f6cb tests: net: checksum_offload: Move test code into helper function
Further reduce code duplication by moving test code for similar test
cases into a helper function, parametrized based on the test case.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos 736888be0c tests: net: checksum_offload: Move net context init to helper function
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>
2023-11-08 15:09:37 +00:00
Robert Lubos 08879ea7fb net: ip: Add option to force checksum calculation
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>
2023-11-08 15:09:37 +00:00
Andrei Emeltchenko a4a4e6872c tests: ieee802154: Remove double new line from logs
NET_XXX() functions already add newline.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-11-07 09:54:49 +01:00
Andrei Emeltchenko cde428cbca tests: ieee802154_test: Fix missing format specifier
Add missing format specifier.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-11-07 09:54:49 +01:00
Seppo Takalo 8608b2dc45 tests: lwm2m: Information Reporting Interface [300-399]
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>
2023-11-07 09:47:00 +01:00
Seppo Takalo 86efc9f1c3 tests: lwm2m: Refactor to use module scoped DUT
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>
2023-11-07 09:47:00 +01:00
Seppo Takalo 944ad183dc tests: lwm2m: Implement event stream support for Leshan
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>
2023-11-07 09:47:00 +01:00
Seppo Takalo e01657c269 tests: lwm2m: Add interoperability tests 222 - 281
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>
2023-11-07 09:47:00 +01:00
Seppo Takalo 1506a43705 tests: lwm2m: Enable DTLS CID for interoperability tests
Leshan Demo server seem to support it so it makes sense to
use it.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-11-07 09:47:00 +01:00
Seppo Takalo 0a104185fe tests: lwm2m: Add Qemu X86 and fix Qemu Cortex-M3
* 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>
2023-11-07 09:47:00 +01:00
Eduardo Montoya 1d0dda794c net: pkt: remove redundant net_pkt_cb_ieee802154 fields
Remove redundant `arb` and `fv2015` fields.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2023-11-03 11:44:40 +01:00
Marc Lasch 73bab817a0 net: lwm2m: Remove the resource type in registration message
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>
2023-11-03 11:44:28 +01:00
Jukka Rissanen 1e15949fe0 tests: net: socket: tls: Increase the mbedtls heap size
native_posix_64 needs more heap for the test to pass so
increase it by 2kb.

Fixes #64670

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-02 13:20:40 +01:00
Benedikt Schmidt aa25e212d1 tests: fix thread function signatures
Fix thread function signatures to avoid stack corruption on thread exit.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 12:24:34 +01:00
Robert Lubos 08d1bb2c92 tests: net: checksum_offload: Cleanup and fixes for the test suite
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>
2023-10-30 09:26:19 +01:00
Robert Lubos 9d3306b22f tests: net: socket: misc: Fix optlen type
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>
2023-10-26 12:34:12 -05:00
Robert Lubos f64d09040b tests: net: socket: misc: Increase stack size
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>
2023-10-26 12:34:12 -05:00
Juha Ylinen 8b1a7f88dd tests: coap_client: Add test case for resending request
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>
2023-10-26 09:49:29 +02:00
Keith Packard 565c9376f1 tests: Switch from NEWLIB_LIBC to REQUIRES_FULL_LIBC
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>
2023-10-25 08:32:06 +02:00
Jukka Rissanen b510073db3 tests: net: tcp: Add test case for connect timeout
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>
2023-10-24 00:48:03 -07:00
Jukka Rissanen 1005fbe16c tests: net: iface: Do not use eth0 name in the test
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>
2023-10-24 09:05:04 +02:00
Jukka Rissanen bc41d03e28 tests: net: socket: misc: Fix memory leak
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>
2023-10-23 09:57:22 -05:00
Jukka Rissanen 83aaeadddd tests: net: socket: Add tests for IPV6_V6ONLY option
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>
2023-10-23 09:57:22 -05:00
Robert Lubos 2b601b34ff tests: net: tcp: Add tests to cover improved RST handling
Add tests which verify that Zephyr's TCP stack replies with RST packet
as expected.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-10-20 15:13:22 +02:00
Seppo Takalo 015b1103fb net: lwm2m: Properly initialize buffers for resource instance
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>
2023-10-20 15:11:32 +02:00
Juha Ylinen 1aef034126 net: coap: add support for Echo option (RFC 9175)
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>
2023-10-20 15:09:44 +02:00
Anas Nashif 345735d0a8 tests: remove CONFIG_ZTEST_NEW_API in all tests
Remove all usage of CONFIG_ZTEST_NEW_API from tests and sample as this
is now enabled by default.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-20 15:04:29 +02:00
Seppo Takalo 8ffb64d46f net: lwm2m: Allow configuring update period
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>
2023-10-20 14:57:38 +02:00
Henrik Brix Andersen b603910214 tests: net: socket: can: split RTR flag from data contents test
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>
2023-10-13 10:08:45 +03:00
Jukka Rissanen 5c6dca3c52 tests: net: sockets: mgmt: Add tests for too long message
Add test that checks we get proper return code if trying
to copy too much data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-12 10:33:36 +03:00
Flavio Ceolin e7bd10ae71 random: Rename random header
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>
2023-10-10 14:23:50 +03:00
Seppo Takalo 5dcaf267fb net: lwm2m: Add Docker based test script
Add Docker based test script for LwM2M interoperability test.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-10-06 16:14:39 +03:00
Juha Ylinen 22f09e9fa0 net: coap: release non-confirmable messages
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>
2023-10-04 11:25:16 +02:00
Robert Lubos 1b21109c2c net: lwm2m: Reset ongoing notification in case token changes
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>
2023-10-04 11:23:53 +02:00
Kieran Tyrrell a714b42080 net: ip: fix promiscuous mode altering packets
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>
2023-10-03 15:10:57 +01:00
Peter Mitsis 2f003e59e4 kernel: Re-factor k_mem_slab definition
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>
2023-09-30 08:04:14 +03:00
Robert Lubos 51d3341066 net: icmp: Don't unref net_pkt from the registered handler
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>
2023-09-29 18:49:43 +03:00
Florian Grandel 36402b6d2a net: pkt: time: introduce ns timestamp helper
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>
2023-09-29 16:27:15 +02:00
Juha Heiskanen 647fb4dc8f net: lwm2m: RD client Deregister event indicate
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>
2023-09-29 16:53:55 +03:00
Robert Lubos e836427f97 tests: net: socket: reuseaddr_reuseport: Fix userspace testing
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>
2023-09-28 15:15:44 +02:00
Jukka Rissanen 729a8e622b tests: net: mld: Fix ICMP usage in the test
Convert the test to use new ICMP API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-28 09:34:20 +02:00
Jukka Rissanen 274f5d9a4b tests: net: ipv6_fragment: Fix ICMP usage in the test
Convert the test to use new ICMP API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-28 09:34:20 +02:00
Jukka Rissanen 8f74148bdd tests: net: icmpv6: Convert to use new ICMP API
Converting the ICMPv6 tests to use the new ICMP API so that
the tests pass.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-28 09:34:20 +02:00
Jukka Rissanen fe5638cf0f tests: net: icmpv4: Convert to use new ICMP API
Converting the ICMPv4 tests to use the new ICMP API so that
the tests pass.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-28 09:34:20 +02:00
Jukka Rissanen 44151d5ccd tests: net: icmp: Add offloaded ICMP API tests
Add some tests that verify that offloaded ICMP API works
as expected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-28 09:34:20 +02:00
Jukka Rissanen 19d1dd747f tests: net: icmp: Add test cases for new ICMP API
Tests cases for new ICMP API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-28 09:34:20 +02:00
Robert Lubos d9f4c1cff0 tests: net: dhcpv6: Add tests
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>
2023-09-28 09:31:20 +02:00
Florian Grandel a12a6ab5b9 drivers: ieee802154: introduce channel pages
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>
2023-09-27 12:44:15 -04:00
Seppo Takalo b9028bb722 net: lwm2m: Remove unneeded function pointer parameter
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>
2023-09-27 15:44:30 +02:00
Seppo Takalo f227b56792 net: lwm2m: Separate opaque content format into its own
Opaque content format is not part of clear-text, so it
should be separated into its own file.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-27 15:44:30 +02:00
Seppo Takalo 7b4f22edd1 net: lwm2m: Add functional tests for LwM2M against Leshan
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>
2023-09-26 16:53:16 +02:00
Pieter De Gendt 09e58e1ecc test: http_server: Fix copy-paste references
Fixed HTTP resource references in test_HTTP_RESOURCE_DEFINE.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-09-22 13:44:13 +02:00
Marcin Gasiorek 4ebf6e5fac tests: net: Add missing tests to net_pkt_clone
Add tests for flag cloning and couple extra.

Signed-off-by: Marcin Gasiorek <marcin.gasiorek@nordicsemi.no>
2023-09-21 13:36:20 +02:00
Tobias Frauenschläger 1de4e73e6d tests: net: sockets: add tests for SO_REUSEPORT
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>
2023-09-20 08:56:31 +02:00
Tobias Frauenschläger 795c96494a tests: net: sockets: add tests for SO_REUSEADDR
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>
2023-09-20 08:56:31 +02:00
Chaitanya Tata 40ee8791f2 net: socketpair: Fix use after free
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>
2023-09-18 20:34:12 +02:00
Manuel Argüelles 2d49ab6623 tests: mqtt: disable debug log level
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>
2023-09-12 10:56:35 +02:00
Huifeng Zhang 662a14a25e tests: net: lib: lwm2m: fix the missing float support
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>
2023-09-11 16:58:10 -04:00
Seppo Takalo 4798187801 test: lwm2m: Fix minor timing issue
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>
2023-09-11 19:56:08 +02:00
Robert Lubos 16870cd664 tests: net: tcp: Add test case for SYN/RST+ACK scenario
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>
2023-09-07 11:41:52 +02:00
Florian Grandel fa4f15a7d5 tests: net: conn_mgr_monitor: increase stack size
Fixes the broken conn_mgr_monitor test.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-06 09:32:36 +02:00
Alberto Escolar Piedras 4f0b2a0bf6 tests lwm2m_rd_client: Allow only on native_posix
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>
2023-09-01 13:59:12 +02:00
Jukka Rissanen 7aa4904b5a net: socket: Change SO_BINDTODEVICE to use interface name
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>
2023-08-31 14:43:36 +02:00
Jukka Rissanen bb5885580f tests: net: iface: Add unit test for interface name support
Check that we can set and get the network interface name.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-08-31 14:43:36 +02:00
Georges Oates_Larsen b25ea4742e net: conn_mgr: Rename connectivity monitor
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>
2023-08-29 16:13:37 +02:00
Georges Oates_Larsen 6d2ce0b30b net: conn_mgr: Create separate connectivity implementation API.
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>
2023-08-29 16:13:37 +02:00
Robert Lubos 9a90440226 tests: net: sockets: misc: Add getsockname() tests
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>
2023-08-27 07:35:34 -04:00
Georgij Cernysiov 986fb1e85d tests: net: lib: coap: test coap_packet_set_path
Adds testing of 'coap_packet_set_path'.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2023-08-25 13:15:12 +02:00
Robert Lubos e8a00b7ef6 tests: net: socket: udp: Add test to verify connected socket behavior
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>
2023-08-25 10:31:19 +02:00
Seppo Takalo e977fde7ee tests: lwm2m: Add more tests to LwM2M registry
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>
2023-08-24 22:07:32 +01:00
Seppo Takalo 0da806736e tests: lwm2m: Add engine tests on security and socket opts
Add tests regarding socket options and various security
options.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-24 22:07:32 +01:00
Seppo Takalo 40dd0c1fa0 tests: lwm2m: Add bootstrap tests into RD client tests
Add bootstrap and few corner cases into RD client tests
to improve code coverage.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-24 22:07:32 +01:00
Sjors Hettinga 2adc95ae7a tests: net: tcp: Add testcase for validating retransmitted FIN seq
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>
2023-08-22 10:00:14 +02:00
Sjors Hettinga 330561e47a tests: net: tcp: Add a testcase for data beyond TCP socket closure
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>
2023-08-22 10:00:14 +02:00
Christopher Friedt 9d16fbb70c tests: net: socket: tcp: reduce number of file descriptors
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>
2023-08-22 09:59:44 +02:00
Christopher Friedt 4cc5102225 net: sockets: udp: test FIONREAD with ipv4 and ipv6 sockets
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>
2023-08-22 09:59:44 +02:00
Christopher Friedt 0f139736f3 tests: net: socket: udp: clear fdtable in after()
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>
2023-08-22 09:59:44 +02:00
Christopher Friedt e7182beb40 tests: net: socket: tcp: clear fdtable in after()
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>
2023-08-22 09:59:44 +02:00
Christopher Friedt 37ca8e0697 net: sockets: tcp: test FIONREAD with ipv4 and ipv6 TCP sockets
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>
2023-08-22 09:59:44 +02:00
Christopher Friedt f1d7c0b196 tests: net: socketpair: use a test fixture to deduplicate code
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>
2023-08-22 09:59:44 +02:00
Christopher Friedt 2116c553a1 tests: net: socketpair: add fionread test
Add a test to exercise
`zsock_ioctl(fd, ZFD_IOCTL_FIONREAD, &avail)`.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-22 09:59:44 +02:00
Christopher Friedt 0f143c9ec9 tests: net: socketpair: reduce requirements for test
Reduce additional requirements for the socketpair testsuite.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-08-22 09:59:44 +02:00
Lukas Woodtli 6277a3904a net: coap: Add function for removing CoAP options
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>
2023-08-16 17:06:41 +02:00
Seppo Takalo fbabc0cd3d test: lwm2m: Allow longer waits and stop properly
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>
2023-08-16 10:21:46 +02:00
Seppo Takalo 01dab8690a net: lwm2m: Do not immediately close connection at Bootstrap
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>
2023-08-16 10:21:46 +02:00
Daniel Leung efeb2d13a7 tests: net: renames shadow variables
Renames	shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-10 08:14:43 +00:00
Robert Lubos 68be56d282 tests: net: tcp: Fix server tests
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>
2023-08-09 20:01:39 -04:00
Sjors Hettinga 9d2c17dee2 tests: net: tcp: Default disable logging in TCP socket test
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>
2023-08-09 08:34:06 +00:00
Benjamin Perseghetti 79796d5c74 tests: net/socket/socketpair: exclude vmu and 1160
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>
2023-08-08 12:09:10 -05:00
Sjors Hettinga 5b640ec9db net: tcp: Implement TCP new Reno collision avoidance
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>
2023-08-04 15:05:17 +02:00
Alberto Escolar Piedras 957ea755bb test lwm2m/engine: Fix build warning
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>
2023-08-02 23:33:37 +02:00
Jaxson Han 3509f8b977 tests: net: lib: lwm2m: Use 1 cpu only as a workaround
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>
2023-08-02 16:34:04 +02:00
Seppo Takalo 518bbc1303 net: lwm2m: Refactor RD client to be tickless
Call RD client service only when there is state transitioning.
Remove periodic 500 ms timer.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-08-01 12:07:12 +02:00
Seppo Takalo 1dfa711167 net: lwm2m: Create socketpair that can wake up zsock_poll()
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>
2023-08-01 12:07:12 +02:00
Florian Grandel a4cd5cee40 drivers: ieee802154: consistent high res timestamps
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>
2023-07-28 09:06:35 +00:00
Robert Lubos ea9d8b7295 tests: net: if: Add tests to verify net_if_ipv4/6_addr_foreach()
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>
2023-07-25 14:18:54 +02:00
Seppo Takalo 27a695dda0 tests: coap_client: Zero-initialize address structures
Even though tests don't use the address, it causes warnings
on static analyzers.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-07-18 16:22:10 +02:00
Florian Grandel b106c21acd net: l2: ieee802154: unified assertion order
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>
2023-07-14 09:38:01 +02:00
Florian Grandel cffb1a448e net: l2: ieee802154: test disassociation from coordinator
Introduces an integration test that simulates an incoming disassociaton
notification from a coordinator.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-14 09:38:01 +02:00
Florian Grandel 111a87efb1 net: l2: ieee802154: test enddevice disassociation
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>
2023-07-14 09:38:01 +02:00
Florian Grandel 81c1f19f1b net: l2: ieee802154: shell set_ext_addr test coverage
Introduces an integration test that covers the set_ext_addr shell
command.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-14 09:38:01 +02:00
Chaitanya Tata 980ad00f10 tests: wifi: Add Wi-Fi test suite
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>
2023-07-11 14:55:30 +02:00
Florian Grandel 27bfe68204 net: l2: ieee802154: mgmt: improve association procedure spec compliance
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>
2023-07-10 09:29:10 +02:00
Marcin Gasiorek eb16ab551f tests: net: pkt_filter: Add TCs for new hooks
Add new TCs to cover new hooks functionality.
These tests implement simple IP filter.

Signed-off-by: Marcin Gasiorek <marcin.gasiorek@nordicsemi.no>
2023-07-10 09:27:47 +02:00
Georges Oates_Larsen ad6fdaf2c2 net: conn_mgr: Bulk convenience functions
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>
2023-06-30 16:10:23 +02:00
Georges Oates_Larsen b65613e79c net: conn_mgr: Support Auto-Down
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>
2023-06-30 16:10:23 +02:00
Georges Oates_Larsen f3d75c4c65 net: conn_mgr: Support Auto-Connect
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>
2023-06-30 16:10:23 +02:00
Georges Oates_Larsen 8785a9f424 net: conn_mgr: Minor fixes
- 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>
2023-06-30 16:10:23 +02:00
Jarno Lämsä 7ae4e24728 net: lib: lwm2m: Use int16_t for signal strength
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>
2023-06-29 10:04:14 +00:00
Jarno Lämsä a3612c70c8 tests: Ztest tests for coap client
Test handling multiple requests.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-06-28 15:19:34 +02:00
Florian Vaussard 90355f143f tests: net: iface: verify multicast address not removed if used
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>
2023-06-28 06:51:21 +00:00
Florian Vaussard 6837229ff2 tests: net: iface: remove useless assignment
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>
2023-06-28 06:51:21 +00:00
Seppo Takalo 6050a10f8b net: lwm2m: Allow setting string to zero length
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>
2023-06-27 12:18:35 +00:00
Seppo Takalo a7498c39e2 tests: net: lwm2m: Remove unnecessary filtering
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>
2023-06-27 00:52:31 +02:00
Seppo Takalo e92f8acff9 tests: net: lwm2m: Remove timing sensitive assert
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>
2023-06-27 00:52:31 +02:00
Seppo Takalo 0f6ded7989 test: net: lwm2m: Fix build warning about unitialized vars
Few variables were uninitialized on certain cases.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-06-27 00:52:31 +02:00
Seppo Takalo 14573fcbf6 tests: lwm2m: Fix too small test buffer
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>
2023-06-26 14:18:06 +00:00
Seppo Takalo dc7fbc5d2e net: lwm2m: Fix pause and resume on non-closed sockets
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>
2023-06-26 12:37:13 +00:00
Seppo Takalo 5c1228770e net: lwm2m: Add support for X509 certificates
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>
2023-06-26 12:35:29 +00:00
Seppo Takalo 95cef5f3ab net: lwm2m: Ensure string termination
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>
2023-06-21 10:42:31 +02:00
Florian Grandel 267db64f39 net: l2: ieee802154: fix acknowledgment procedure
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>
2023-06-17 16:20:21 -04:00
Florian Grandel 7571be3261 net: l2: ieee802154: deprecate NET_L2_IEEE802154_ACK_REPLY
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>
2023-06-17 16:20:21 -04:00
Florian Grandel f96b620d12 net: l2: ieee802154: properly handle TX HW capabilities
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>
2023-06-17 16:20:21 -04:00
Florian Grandel 1ee4d3ed77 net: l2: ieee802154: document L1/L2 sep. of concerns
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>
2023-06-17 16:20:21 -04:00
Florian Grandel ffcae5f029 net: l2: ieee802154: separate CCA and retransmission
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>
2023-06-17 16:20:21 -04:00
Bjarki Arge Andreasen 22152915ab drivers/gsm_ppp: Update existing modules to use PPP L2
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>
2023-06-17 07:46:21 -04:00
Florian Grandel b224a099fd net: l2: ieee802154: standardize RSSI value
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>
2023-06-17 07:16:32 -04:00
Andrei Emeltchenko 2b607733e6 tests: coap_client: Type case to uint8_t after shift
Type casting to uint8_t before shift by 8 does not make sense.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-05-30 13:04:13 -04:00
Robert Lubos cf15f0e48e tests: net: socket: tls: Verify accept is interrupted correctly on close
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>
2023-05-29 14:34:03 -04:00
Robert Lubos af8c980e51 tests: net: socket: tcp: Verify accept is interrupted correctly on close
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>
2023-05-29 14:34:03 -04:00
Jarno Lämsä 2d06f8061b tests: Add ztest tests for coap client
Add tests for coap client and stubs for isolating the tests.

Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
2023-05-26 09:44:50 -04:00
Robert Lubos 1d5b3af3c1 tests: net: socket: tcp: Verify recv is interrupted correctly on close
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>
2023-05-26 09:05:12 -04:00
Anas Nashif 75c11c0564 tests: net: socket: fix test identifier
Remove definition of testcases in yaml file, those are now detected from
binary.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-05-25 04:44:11 -04:00
Florian Grandel ea6a55afad net: l2: ieee802154: zero-copy encryption
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>
2023-05-24 16:41:57 +02:00
Florian Grandel 315394eb53 net: l2: ieee802154: consistently name authtag length
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>
2023-05-24 16:41:57 +02:00
Florian Grandel fc879ffa16 net: l2: ieee802154: payload length coverage
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>
2023-05-22 16:33:28 +02:00
Florian Grandel ca6d552bbb net: l2: ieee802154: fix payload handling
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>
2023-05-22 16:33:28 +02:00
Florian Grandel 988ffe9c48 tests: net: l2: ieee802154: active scan shell/mgmnt coverage
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>
2023-05-22 16:33:28 +02:00
Matthias Breithaupt 82c39a7805 test: DHCPv4: Add test for option callbacks
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>
2023-05-22 15:25:40 +02:00