Commit graph

1729 commits

Author SHA1 Message Date
Jukka Rissanen
eb018f8109 tests: net: mgmt: Verify that info_length is correct
If info is sent by net_mgmt, make sure it contains correct data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 13:50:08 -07:00
Jukka Rissanen
02b3826fa0 net: mgmt: Add info length to event wait API
The info parameter is difficult to use if the caller does not
get information how long the info struct is. So add info_length
parameter to net_mgmt_event_wait_on_iface() and
net_mgmt_event_wait() APIs.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 13:50:08 -07:00
Jukka Rissanen
7063921e87 net: if: Add userspace support to IPv4 gateway set function
Allow application to call net_if_ipv4_set_gw_by_index()
and set the gateway if enabled by configuration.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 15:34:11 +03:00
Jukka Rissanen
813ae63f6b net: if: Add userspace support to IPv4 netmask set function
Allow application to call net_if_ipv4_set_netmask_by_index()
and set the netmask if enabled by configuration.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 15:34:11 +03:00
Jukka Rissanen
01fa8a6fe2 tests: net: if: Test userspace support in net_if
Add more tests to test userspace enabled APIs.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 15:34:11 +03:00
Jukka Rissanen
f3b0b441ed tests: net: dns: Add tests for dns_unpack_answer()
Make sure that dns_unpack_answer() works as expected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 09:44:29 +03:00
Anas Nashif
a2fd7d70ec cleanup: include/: move misc/util.h to sys/util.h
move misc/util.h to sys/util.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif
9ab2a56751 cleanup: include/: move misc/printk.h to sys/printk.h
move misc/printk.h to sys/printk.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif
0c9e280547 cleanup: include/: move misc/mutex.h to sys/mutex.h
move misc/mutex.h to sys/mutex.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Jukka Rissanen
c9aaab74db net: ptp: clock: Add usermode support to ptp_clock_get()
It is useful that the ptp_clock_get() function can be called from
the userspace. Create also unit test for calling that function
from userspace.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-25 15:22:51 +03:00
Jukka Rissanen
95e8498c27 net: ptp: Add usermode support to net_eth_get_ptp_clock_by_index()
Make net_eth_get_ptp_clock_by_index() clock API to work with user space.
Create also unit test for testing this user mode support.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-25 15:22:51 +03:00
Jukka Rissanen
2c4b2a16a5 tests: net: getaddrinfo: Make sure we receive two queries
If user supplies AF_UNSPEC, we need to do two queries, one for
IPv4 A record and one for IPv6 AAAA record.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-20 14:45:43 +03:00
Håkon Øye Amundsen
05cd3420ac net: mqtt: add mqtt_readall_publish_payload()
This function uses mqtt_read_publish_payload_blocking to perform a
blocking read of the specified number of bytes.

When reading out a payload, the normal use case is to read the
entire payload. This function facilitates that use case.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2019-06-20 13:06:08 +03:00
Anas Nashif
f2cb20c772 docs: fix misspelling across the tree
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-19 15:34:13 -05:00
Andrew Boie
86586b2d8d tests: getaddrinfo: set newlib heap size
Some MPU systems require region power-of-two alignment
and can't automatically use remaining RAM for the newlib
heap. Set it for this case. Fixes this test on mps2_an385.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-06-19 10:57:33 +03:00
Jukka Rissanen
194893d52d tests: net: udp: Add tests for SO_PRIORITY and setsockopt
Verify that user is able to set SO_PRIORITY socket option.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-09 12:54:05 +03:00
Jukka Rissanen
1cbda7d4ac tests: net: socket: register: Close socket after test
The file descriptor was not closed after the test which caused
Coverity to complain about resource leak.

Coverity-CID: 198640
Fixes #16493

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-06-06 17:49:01 +08:00
Marc Herbert
4afcc0f8af sanitycheck: CONFIG_TEST_USERSPACE / userspace tag cleanup
- Delete CONFIG_TEST_USERSPACE=n no-ops because it's the default
since commit 7b1ee5cf13

- Some tests have a "userspace" tag pretending to TEST_USERSPACE but
don't and vice versa: fix missing or spurious "userspace" tags in
testcase.yaml files.

Tests have a _spurious_ "userspace" tag when they PASS this command
cause none should pass:

  ./scripts/sanitycheck --tag=userspace -p qemu_x86 \
      --extra-args=CONFIG_TEST_USERSPACE=n  \
      --extra-args=CONFIG_USERSPACE=n | tee userspace.log

All tests run by this command must either fail to build or fail to run
with some userspace related error. Shortcut to look at all test
failures:

 zephyr_failure_logs() {
     awk '/see.*log/ {print $2}' "$@"
 }

Tests _missing_ "userspace" tag FAIL to either build or to run with some
userspace related error when running this:

  ./scripts/sanitycheck --exclude=userspace -p qemu_x86 \
      --extra-args=CONFIG_TEST_USERSPACE=n  \
      --extra-args=CONFIG_USERSPACE=n | tee excludeuserspace.log

Note the detection methods above are not 100% perfect because some
flexible tests like tests/kernel/queue/src/main.c evade them with #ifdef
CONFIG_USERSPACE smarts. Considering they never break, it is purely the
test author's decision to include or not such flexible tests in the
"userspace" subset.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2019-05-30 08:45:39 -04:00
Tomasz Bursztyka
c3c6dfaaeb tests/net: Fix IPv6 and UDP test as UDP got stricter on checking header
Now length of the UDP header is checked, and obviously these test were
avoiding setting it properly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-05-30 13:01:30 +08:00
Nicolas Pitre
4d4cd7e3c8 test/net: fix PTP clock test code
The various ptp_clock_driver_api methods receive a struct ptp_context
not a struct eth_context, and the later must be obtained from a
reference stored in the former. Failing to do so by directly
interpreting driver_data as a struct eth_context instance does end up
corrupting memory past the actual struct ptp_context storage. The test
may still pass as ptp_clock_get() reads from the same out-of-bounds
memory as the previous ptp_clock_set() and therefore the content
matches, and with luck the corrupted memory is not essential to the
completion of the test. But that wasn't my case which allowed me to
find this issue.

Fix this by properly obtaining a reference to the struct eth_context
instance via the actual struct ptp_context, and adding a test like
the one found in eth_tx() to make sure we got the right memory.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-05-30 10:53:24 +08:00
Paul Sokolovsky
4d8941a91d tests: net: getaddrinfo: Add cases for numeric IPv4 addr
And also for AI_NUMERICHOST flag.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-05-29 17:46:56 +08:00
Jukka Rissanen
0c639a8a9a tests: net: socket: Add tests for socket family registration
Make sure that socket registration does something sane.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-05-10 22:43:27 +03:00
Robert Lubos
b8494d9a51 net: lib: mqtt: Enable blocking PUBLISH payload readout
It is convenient to have a blocking version of
`mqtt_read_publish_payload` function, for cases when it is called from
the event handler. Therefore, extend the 'mqtt_read_publish_payload'
argument list with information whether the call should block or not.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-05-07 22:08:30 -04:00
Tomasz Bursztyka
b2b21412ae net/connection: Removing cache feature
There were various flaws in it that motivated its removal:

- No hash collision handling mechanism. In case that would happen, the
behavior of the network connection would be unknown. This is the main
drawback
- The lookup is not that much more efficient than the default one. The
only difference of gain is in connection comparison (a u32t comparison
vs a full connection compare). But the list handling is the same. It's
made worse by the presence of a negatives match array which can be
easily filled in and becomes then fully usless, appart from consuming
CPU. As well as adding a new connection: it requires the whole cache
to be cleared which is unefficient.
- Not memory efficient, even compared to a proper hash table.
Two arrays instead of one etc...

All of this could be fixed by using a proper hash table, though it
remains to be seen if such object could fit in Zephyr core.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-05-07 15:40:53 +03:00
Maksim Masalski
f1f1a9f38a tests: fix unchecked return value in test_net_pkt_basics_of_rw
Inside function test_net_pkt_basics_of_rw result of function call
net_pkt_read_be16 is not checked which might result performance
of the program and cause errors.

Coverity-CID 198003
Fixes #15776

Signed-off-by: Maksim Masalski <maxxliferobot@gmail.com>
2019-05-07 15:27:31 +03:00
Paul Sokolovsky
b2bfcc27b9 tests: socket: misc: Add tests for inet_pton()
Basic testcases for accepting correct input and rejecting invalid.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-05-07 08:30:32 +03:00
Jukka Rissanen
758a2468fd tests: net: mqtt_publisher: Allow compilation in every platform
Fixes the compile errors in various platforms like:
* sam_e70_xplained (too few network buffers)
* galileo, cc3220sf_launchxl and mps2_an385 (missing random number
  generator configuration options)

Fixes #15878

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-05-04 18:28:37 -04:00
Andrew Boie
e9b5fe333e tests: ieee802154: set min_ram
Fix a sanitycheck failure on usb_kw24d512 with the
whitelist removed.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-03 14:21:45 -04:00
Andrew Boie
643d689107 tests: mqtt_publisher: enable random numbers
tls_entropy_func() requires an entropy source.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-03 14:21:45 -04:00
Andrew Boie
dc27ec3e05 tests: ethernet_mgmt: enable random generator
net_if_ipv6_calc_reachable_time() requires sys_rand32_get().
Enable the test random number generator so the build doesn't
fail.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-03 14:21:45 -04:00
Andrew Boie
543c5c1b7f tests: getaddrinfo: fix stack overflow
This thread was blowing its stack if code coverage was
enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-05-02 11:13:31 +03:00
Jukka Rissanen
960e6d9504 tests: net: getaddrinfo: Fix test to check the query is sent
As the getaddrinfo() test is suppose to be self contained, then
we will need to install handler for the sent DNS query. After we
receive the query in process_dns() thread, we verify that the
query was sent properly. We do not return DNS reply back to
the caller in this case as we do not want to create DNS server
just for this simple test application. This can be changed later
if we get DNS server functionality in Zephyr network stack.

Fixes #15193

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-04-30 09:56:01 -07:00
Ravi kumar Veeramally
7fbe087d8d net: tests: ipv6_fragment: Use NET_DBG instead of DBG
ipv6_fragment tests registered log module but still use DBG
macro of printk. Replaced them with NET_DBG.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-04-26 10:45:45 +03:00
Ravi kumar Veeramally
d19097f8c5 tests: net: Add more tests to ipv6 fragmentation
IPv6 fragmentation test case for reassembly.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-04-26 10:45:45 +03:00
Jukka Rissanen
fcf392c6c8 tests: net: all: Add more options to catch-all test
Add more Kconfig options to prj.conf file. In the future we need
to compile also in other hw than qemu_x86 in which case we need to
create separate test cases for those configurations.

Fixes #15282

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-04-23 10:29:38 +03:00
Jukka Rissanen
6bf369f306 tests: net: pkt: Verify that net_pkt_write() writes correct data
Write the net_pkt using net_pkt_write() and then verify that the
data is actually written into net_buf.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-04-17 10:50:09 -04:00
Anas Nashif
3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Andrew Boie
7b1ee5cf13 tests: CONFIG_TEST_USERSPACE now off by default
Unlike CONFIG_HW_STACK_PROTECTION, which greatly helps
expose stack overflows in test code, activating
userspace without putting threads in user mode is of
very limited value.

Now CONFIG_TEST_USERSPACE is off by default. Any test
which puts threads in user mode will need to set
CONFIG_TEST_USERSPACE.

This should greatly increase sanitycheck build times
as there is non-trivial build time overhead to
enabling this feature. This also allows some tests
which failed the build on RAM-constrained platforms
to compile properly.

tests/drivers/build_all is a special case; it doesn't
put threads in user mode, but we want to ensure all
the syscall handlers compile properly.

Fixes: #15103 (and probably others)

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-06 14:30:42 -04:00
Andrew Boie
027b6aaf89 tests: set userspace tag for all tests that use it
This lets us quickly filter tests that exercise userspace
when developing it.

Some tests had a whitelist with qemu_cortex_m3; change
this to mps2_an385, which is the QEMU target with an
MPU enabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-06 14:30:42 -04:00
Andrew Boie
ce6b80470d net: add missing syscall for gethostname()
We need all the socket APIs to work from user mode.
tests/net/socket/misc now runs in userspace.

Fixes: #15227

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-06 14:30:42 -04:00
Andrew Boie
1d0369f606 tests: net: getnameinfo: run in user mode
The test is designed to run in user mode, but was disabled
for some reason.

Re-enable, and add mps2_an385 to the whitelist as this is
the QEMU target that emulates an MPU.

Fixes: #15228

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-06 14:30:42 -04:00
Andrew Boie
0ccaa5d908 tests: mqtt_packet: run in user mode
Various globals for the test cases have been moved to
the ztest memory domain data section via ZTEST_DMEM tags
so that user mode can access them.

Some anonymous arrays whose address was being placed in
the msg_subackX structs have been split out so they
are in ztest memory domain.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-03 13:47:45 -04:00
Patrik Flykt
21358baa72 all: Update unsigend 'U' suffix due to multiplication
As the multiplication rule is updated, new unsigned suffixes
are added in the code.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Patrik Flykt
24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Ravi kumar Veeramally
65d100e7f0 tests: net: Add more tests to ipv6 fragmentation
IPv6 fragmentation test case without any extra header (HBHO)
added.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-03-26 15:55:15 -04:00
Jukka Rissanen
079a2919cb tests: socket: tcp: Increase the buf count
With default buf count, we ran out of bufs in connect() in
test_v6_sendto_recvfrom().

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-26 07:29:26 -05:00
Ravi kumar Veeramally
2f941d2630 tests: net: ipv6: Add one more test case
Test case added for IPv6 neighbors. This will add more than
CONFIG_NET_IPV6_MAX_NEIGHBORS neighbors. Network stack should
remove oldest neighbor which is in STALE state and it should
add new neighbor. So call to net_ipv6_nbr_add() should succeed.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-03-25 22:49:52 -04:00
Tedd Ho-Jeong An
2d8ac0cf5e tests: net: mld: Check return after updating packet
This patch checks the return value after updating the packet.

Fix Bugs: #14821
Coverity CID: 196635

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
2019-03-25 15:53:13 -04:00
Tomasz Bursztyka
cf322c44db net: Switch usage of net_pkt_get_reserve to net_pkt_alloc
Some places were still using the old allocator. Using the new one does
not change any behavior. This will help to remove the useless data_len
attribute in net_pkt which legacy allocator was still setting.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka
03bfc5dd0f net/context: Remove token parameter from net_context_send/sendto
And also to the relevant callbacks.

That parameter is not used anywhere so it is useless.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka
d6d52ce9e5 net/pkt: Remove _new suffix to net_pkt_write functions
Suffix is now useless, as these functions are now the only ones.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka
a25f054cbd net/pkt: Remove _new suffix to net_pkt_read functions
Suffix is now useless, as these functions are now the only ones.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka
f8a091104e net/pkt: Remove _new suffix to net_pkt_get_data_new function
Now that legacy - and unrelated - function named net_pkt_get_data has
been removed, we can rename net_pkt_get_data_new relevantly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka
820f3ad006 net/ipv6: Replace legacy net_ipv6_create by the new one
Thus removing the legacy one, and renaming the new one to legacy name.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka
ca58b4c761 net/ipv4: Replace legacy net_ipv4_create by the new one
Thus removing the legacy one, and renaming the new one to legacy name.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka
172fe5a87b net/context: Remove _new suffix on net_context_send/sendto functions
Now that legacy functions are removew, let's rename the new functions by
removing the _new suffix.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Andrei Emeltchenko
99403c5b13 net: ethernet: Define and use Ethernet frame and datagram size
Remove magic numbers from Ethernet drivers and tests by defining
NET_ETH_MAX_DATAGRAM_SIZE and NET_ETH_MAX_FRAME_SIZE.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-03-15 06:44:13 -05:00
Paul Sokolovsky
f38c4c97ce tests: socket_helpers: Use zsock_ prefixed socket functions
Don't depend on CONFIG_NET_SOCKETS_POSIX_NAMES being defined (e.g.,
it's going to conflict with POSIX API).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-03-15 06:00:21 +01:00
Jukka Rissanen
dc41aad2a5 tests: net: mld: Check null ptr dereference
If pkt allocation fails, then prepare to handle NULL pointer.

Coverity-CID: 195844
Fixes #14405

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-14 13:01:01 +01:00
Tedd Ho-Jeong An
401a598503 tests: net: iface: Handle pkt allocation failure
This patch handles null pointer when packet allocation fails.

Fixes: #14390
Coverity-CID: 195903

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
2019-03-14 12:06:21 +01:00
Jukka Rissanen
6301ae74d9 tests: net: tcp: Check null ptr dereference
If pkt allocation fails, then prepare to handle NULL pointer.

Coverity-CID: 195819
Coverity-CID: 195860
Coverity-CID: 195921

Fixes #14412
Fixes #14399
Fixes #14388

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-13 05:39:41 -05:00
Jukka Rissanen
55cd97bc43 tests: net: dhcpv4: Check null ptr dereference
If pkt allocation fails, then prepare to handle NULL pointer.

Coverity-CID: 195880
Coverity-CID: 195816

Fixes #14413
Fixes #14395

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-13 05:38:26 -05:00
Jukka Rissanen
bafdf5b329 tests: net: ipv6: Check null ptr dereference
If pkt allocation fails, then prepare to handle NULL pointer.

Coverity-CID: 195835
Fixes #14409

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-03-13 05:34:46 -05:00
Thomas Stenersen
7516476386 kconfig: Use depend on instead of select to avoid kconfig loop
Remove use of select to "force" enabling other configs in subsys/fs
and subsys/net/l2. The forcing will cause infinite kconfig recursion.

Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
2019-03-12 19:42:40 +01:00
Tedd Ho-Jeong An
922f53864f tests: net: mqtt: Fix the error handling aftre read
If the rc = -EAGAIN from mqtt_read_publich_payload(), it shouldn't be
used in memcpy() since it is a negative value, and instead, it should
try to read again.

Fix: #13825
Coverity-CID: 191002

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
2019-03-09 10:50:25 -05:00
Tomasz Bursztyka
462fc32f7c tests/unit: Switch vlan test to new net_pkt/net_context API
Use the new net_pkt allocator. Fix a small leak in the test as well.

No need to build the net_pkt, just send the data directly through
net_context_sendto_new()

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka
a03efe1928 tests/net: Fix vlan test timeout values
s/0/K_NO_WAIT for all timeouts

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka
ab1d38c3c3 tests/net: Reducing utils test by removing redundant ones
The very first test was basically testing the checksum calculation. And
that's already tested in more relevant tests. It was also trying in a
cumbersome way to generate packets scattered over many net_buf. But
that's also already tested in various other tests, and it's not at all
part of core utils anyway.

In any case, that all redundant, so let's remove it.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka
6a1387d1cf tests/net: Switch tx timestamp test to new net_context API
No need to build the net_pkt, just send the data directly through
net_context_sendto_new()

Use the new net_context option to enable timestamping of outgoing
packet (NET_CONTEXT_TIMESTAMP).

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka
3e6e0922fe tests/net: Fix tx timestamp test timeout values
s/0/K_NO_WAIT for timeouts

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka
3fb49d89d6 tests/net: Switch traffic class test to new net_context API
No need to build the packet by ourselves.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka
5cff958a4f tests/net: Fix traffic class test timeout values
s/0/K_NO_WAIT for all timeouts

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka
eca8f1072a tests/net: Switch tcp test to new net_pkt API
Switch to new allocators and r/w functions.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka
344962270e tests/net: Switch promiscuous test to new net_pkt API
Switch to new allocator and write function.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka
2a18ec99bf tests/net: Switch MLD to new net_pkt API
Switch to new allocators and r/w functions.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka
07d34b0f3e tests/net: Replace the legacy net_pkt API test by the new one.
Just a quick rm/mv. The new API is going to be the only one, so legacy
test can disappear.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka
da37c67aba tests/net: Switch ipv6 fragmentation test to new net_pkt API
Switch to new allocators and r/w functions.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka
07f9040ebb tests/net: Switch ipv6 test to new net_pkt API
Switch to new allocators and r/w functions.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka
32dfb13b03 tests/net: Switch iface test to new net_pkt API
No need to play with net_buf by ourselves.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka
8e8bd65783 tests/net: Switch icmpv6 test to new net_pkt API
No need to play with net_buf by ourselves.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka
ae94e2ec1d tests/net: Switch context test to new net_context API
No need to build the net_pkt, just send the data directly through
net_context_sendto_new()

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka
a05c29f0db tests/net: Fix context test timeout values and function calls
s/0/K_NO_WAIT for all timeouts
And fix tcp context connect call (it's not net_context_listen obviously,
and one parameter was missing).

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Tomasz Bursztyka
8b857dadc5 tests/net: Switch checksum test to new net_context API
No need to build the net_pkt, just send the data directly through
net_context_sendto_new()

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-09 10:09:33 -05:00
Ravi kumar Veeramally
a391daa95a net: tests: Migrate ARP tests
Migrate ARP tests to new net_pkt API.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-03-08 07:18:19 -05:00
Ravi kumar Veeramally
746618460b net: tests: Migrate UDP tests
Migrate UDP tests to new net_pkt API.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-03-07 07:17:36 -05:00
Paul Sokolovsky
1b837d64de tests: socket: tcp: Test handling of EOF condition on socket
If peer socket closed, the other side should get 0 from recv(), and
should get in stable manner (no matter how much time went from the
closure and/or how many times recv() is called).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-03-06 15:57:40 -05:00
Ravi kumar Veeramally
0aa61651ce net: tests: Fix DHCPv4 tests
net_pkt_alloc_with_buffer() takes IP header and protocol header
length while calculating total length internally. Need not
specify explicitly. Also mutex was not properly initialized.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-03-05 08:29:02 -05:00
Maksim Masalski
b324f35e61 macros: deleted macros SECONDS(), MSEC(), USEC()
Changed everywhere these macros to the K_MSEC(), K_SECONDS()

Signed-off-by: Maksim Masalski <maxxliferobot@gmail.com>
2019-03-04 19:04:21 -05:00
Sebastian Bøe
4e5300ba7f cmake: Drop all in-tree usage 'set_conf_file'
Port all users of 'set_conf_file' to use the built-in rules
instead. This follows the convention-over-configuration principle to
make the system as a whole simpler and more consistent.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-03-01 09:44:09 +01:00
Ravi kumar Veeramally
c4f2ab143d net: tests: Migrate DHCPv4 tests
Migrate DHCPv4 tests to new net_pkt API.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-02-26 02:25:14 +01:00
Tomasz Bursztyka
ca7b3b3703 net/ieee802154: Switch fragmentation support to new net_pkt API
- differentiating actual "fragment" to buffer element from a net_pkt
- instead of copying data (and thus allocating buffer) let's just take
the fragment buffer and put it into result packet.
- fixing compilation issue in relevant test

It's more efficient that way, as we use already allocated fragment
buffer instead of reallocating/deallocating after each fragment
reception.

A possible optimization would be to calculate the actual size + header
difference if only the actual size is close to the target size.
It would avoid to get a dry run of the header decompression for each
fragment received. The difficulty being in finding the sweet spot when
it is relevant to calculate the header difference.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-23 07:44:59 -05:00
Paul Sokolovsky
49341e0065 tests: socket: Add test for getnameinfo()
Basic test for IPv4/IPv6 addresses conversion.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-02-19 17:34:57 -05:00
Jukka Rissanen
d4d61895b8 tests: net: ipv6_fragment: Fix interface index values
The test needs to use interface index starting from 1.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-18 15:10:54 -05:00
Jukka Rissanen
299832738e tests: net: ip-addr: Fix interface index values
The test needs to use interface index starting from 1.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-18 15:10:54 -05:00
Jukka Rissanen
3043b50403 tests: net: dns: Fix test as the interface index starts from 1
The test was using index 0 which is no longer correct.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-18 15:10:54 -05:00
Carlos Stuart
75f77db432 include: misc: util.h: Rename min/max to MIN/MAX
There are issues using lowercase min and max macros when compiling a C++
application with a third-party toolchain such as GNU ARM Embedded when
using some STL headers i.e. <chrono>.

This is because there are actual C++ functions called min and max
defined in some of the STL headers and these macros interfere with them.
By changing the macros to UPPERCASE, which is consistent with almost all
other pre-processor macros this naming conflict is avoided.

All files that use these macros have been updated.

Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
2019-02-14 22:16:03 -05:00
Tomasz Bursztyka
2b22b71e42 net/pkt: Remove useless legacy net_frag_linearize function
Now that the stack does not use this function, it can be removed
safely.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
bc5411816a net/pkt: Remove useless legacy net_pkt_append_memset function
Now that the stack does not use this function, it can be removed
safely.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
1fab039102 net/pkt: Remove useless legacy net_pkt_split function
Now that the stack does not use this function, it can be removed
safely.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
09b782a82d net/pkt: Remove useless legacy net_pkt_pull function
Now that the stack uses the new API from net_pkt for pulling, no need
to keep the legacy one around.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
c65304f088 net/pkt: Rename net_pkt_copy_new to net_pkt_copy
Now that legacy net_pkt_clone function has been removed, the new
function can be renamed accordingly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
895c8eb0e3 net/pkt: Remove useless legacy net_pkt_copy/_all functions
Now that the stack uses the new API from net_pkt for copying, no need
to keep the legacy one around.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
38a3e79f9b net/pkt: Rename net_pkt_clone_new to net_pkt_clone
Now that legacy net_pkt_clone function has been removed, the new
function can be renamed accordingly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
a6426620da net/private: Rename net_hexdump_frags to net_pkt_hexdump
And remove the parameter "full" as there is no "ll reserve" distinction
anymore. The parameter was unused since the ll reserve concept removal.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
909eb7271a net/udp: Remove net_pkt_udp_data() function
It is now useless and can be replaced by net_udp_get_hdr() directly, in
the 2 unit tests it was used.

Removing as well the dbg function too_short_msg()

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
8ceedafdc4 net/udp: Switch net_udp_get/set_hdr to new net_pkt API
Let's use the new API for these 2 functions. Note that in some places,
using these functions is under-optimized (like in llmnr-responder in
dns: it gets the ip/udp headers already from the recv callback. That
will need to be taken care of later).

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
674d7c47b4 net/udp: Remove useless net_udp_set_chksum
It was only used in ipv6_fragment unit test and could be easily
replaced.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
d8624513e6 net/icmp: Remove useless icmp functions using legacy net_pkt API
net_pkt_icmp_data was only used in ipv6 unit test and could be easily
replaced.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
04966ac10d net/tcp: Remove useless tcp function using legacy net_pkt API
net_pkt_tcp_data was only used in tcp unit test and could be replaced by
local net_tcp_get_hdr.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
fd1401495b net/tcp: Move net_tcp_set_hdr() away from net core
Only the unit test needs it now, so let's move it there.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
1a54cabe5e net/ipv4: Rename net_ipv4_finalize since legacy version disappeared
s/net_ipv4_finalize_new/net_ipv4_finalize

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
0c80a84bc7 net/ipv6: Rename net_ipv6_finalize since legacy version disappeared
s/net_ipv6_finalize_new/net_ipv6_finalize

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
b93df74fa2 net/context: Let's use the new net_ipv4_finalize
And removing the legacy and unused one.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
31a079023f net/context: Let's use the new net_ipv6_finalize
And removing the legacy and unused one.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
78198810ac net/tcp: Move net_tcp_get_hdr() away from net core
Only the unit test needs it now, so let's move it there.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Tomasz Bursztyka
024a7e0502 net/sockets: Adapt net_pkt_get_src_addr to new net_pkt API
This function is only used in sockets, thus making it a private function
of socket library and renaming it relevantly.

Note that sockets should be reviewed at some point to avoid using such
function: zsock_received_cb() already get the ip header and the protocol
header, so it could grab the src addr/port from there. It would be way
more optimized to do so, since net_pkt_get_src_addr is costly as it
parses all over again the ip/protocol headers.

utils unit test is updated and the test of the former
net_pkt_get_src_addr/net_pkt_get_dst_addr are removed.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-12 20:24:02 -05:00
Jukka Rissanen
8de351c45f tests: net: ipv6: Fix the DAD failure in the test
The DAD was failing because we received the DAD network packet
even when should not had received it. Fix it by discarding all
the ICMPv6 NS packets that we receive.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-08 14:24:03 +02:00
Tomasz Bursztyka
499ffd6573 net/ethernet: Remove inserted L2 header buffer
The packet can be referenced somewhere else and letting the newly added
L2 header will generate corrupt packet. If the same packet is being
resent, ethernet will add again its L2 header. Thus the need to remove
such L2 header every time a packet has been sent, successfully or not.

Fixes #12560

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-08 14:24:03 +02:00
Andrei Gansari
0730ab8bef tests: CONFIG_NET* fixup
Fixed typo: CONFIG_NET_NET_PKT_LOG_LEVEL_DBG, removed extra _NET.
Removed debug macro CONFIG_NET_DEBUG_NET_PKT that is not used.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
2019-02-08 13:57:55 +02:00
Paul Sokolovsky
36e437f537 tests: socket: misc: Add test for gethostname()
Just a basic test.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-02-08 10:39:30 +02:00
Jukka Rissanen
85c8c0fe3c tests: net: context: Fix invalid address family test
The test had hard coded address family with value 4. This test
was failing as we have now AF_CAN family with value 4. Use 99
as an invalid address family value instead.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-07 18:08:27 +02:00
Ravi kumar Veeramally
f0fb82dce9 net: ip: Add protocol family type to conn handler
As we are adding more protocol families and protocol types
to connection handlers, some values might be same across
different types. Current connection handler only stores
proto type to match the handler, which is not enough if
we add more types. Also combination of family and types
may vary too. So adding family to connection handler to
figure out best match.

Also changing proto variable in net_conn from u8_t to u16_t.
net_context has 16 bit proto.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-02-07 14:43:30 +02:00
Robert Lubos
418b9236fa net: lib: mqtt: Get rid of _sock suffix
As the legacy library has been removed, we no longer need to
differentiate betwen MQTT implementations. Therefore align the library
folder name with other libraries and remove the `_sock` suffix.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-02-05 11:05:26 -05:00
Ravi kumar Veeramally
1e47f26d1c net: coap: Remove legacy CoAP implementation
As we are removing net_app and net_pkt based libraries and
applications, CoAP legacy based libraries and apps are moved
to socket based implementations. So removing legacy CoAP.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2019-02-04 16:49:59 -05:00
Paul Sokolovsky
92962ddc5e tests: socket: poll, select: Fix non-blocking timing tests
As written originally, the tests assumed that if k_uptime_get_32()
returns times in milliseconds, that it also has millisecond
resolution. That however doesn't have to be the case, and indeed,
default timer interrupt period used by Zephyr is 10ms, and so system
time is incremented in such units. So, instead of "<= 1" tests to
account for timing increment, use "<= FUZZ".

For blocking tests, increase the timeout from previously used 10ms,
so we can reliably tests delays under the conditions described.

Also, enable CONFIG_QEMU_TICKLESS_WORKAROUND. Most other
timing-related tests have this enabled, and it may affect
stability of QEMU testing too.

Fixes: #12994

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-02-04 15:31:10 -05:00
Tomasz Bursztyka
968d423a44 net/pkt: Allocate relevant size on AF_UNSPEC
In case of Ethernet, if the requested size is larger than MTU and if
AF_UNSPEC is provided, the allocator will need to take into account
the ethernet header size which is not accounted in the MTU.

Other current L2 do not follow that rule as their MTU is based on IP
one (IPv6 most of the time). What they declare as MTU is the full frame
size they handle (minus the FCS for instance in 15.4). So with
AF_UNSPEC, such assumption on L2 header size is unrelevant.
(On 15.4 the header size is variable anyway and cannot be known until
the frame is parsed).

Fixes #12982

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-04 17:15:52 +02:00
Tomasz Bursztyka
4b78a251d7 net/context: Make recv_cb providing the ip and protocol headers
If status is 0, both ip_hdr and proto_hdr will own a pointer to the
relevant IP and Protocol headers. In order to know which of ipv4/ipv6
and udp/tcp one will need to use respectively net_pkt_family(pkt) and
net_context_get_ip_proto(context).

Having access to those headers directly, many callbacks will not need
to parse the packet again no get the src/dst addresses or the src/dst
ports. This will be change after this commit.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka
e4ebe486b8 net/ip: Let's make public the 2 utility unions for ip/proto headers
Though these are currently used by the core only, it will be then used
by net_context as well. This one of the steps to get rid of net_pkt's
appdata/appdatalen attributes.

Also normalizing all ip/proto parameters name to ip_hdr and proto_hdr.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka
6596c304fb test/net: Quick sample explaining/testing the new net_pkt buffer API
This goes through basic allocation, atomic read/write, data
getter/setter and cloning/copying.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka
99dbe467e5 tests/icmpv6: Real packet length must be given
The test counts the '\0' of the data copied, though it does not belong
to the packet.

Since the test by-passes net_ipv6_input, which would update the packet
length according to what is in the IPv6 header, the checksum calculation
fails.

Before, checksum calculation used to grab the length from IPv6 header,
but that changed to use net_pkt_get_len(): that one must provide the
real lenth.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka
8d21c68718 net/tcp: Switch rest of TCP to new net_pkt API
Only next to be removed functions like net_tcp_set_checksum() are left
untouched. All the rest is switched.

Adding net_tcp_finalize() to follow the same logic as for UDP and else.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka
baa9784008 net/tcp: Apply connection callback signature change
This proovse to drastically reduce runtime overhead as it does not need
to parse IP nor TCP header all over again in a lot of places.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka
118a0f0d22 net/conn: Change callback signature to pass TCP/IP headers
As these were parsed already by IPv4/6 input functions let's use them.

Applying the change on trivial UDP usage. TCP usage will have its own
commit.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka
e04914a963 net/ipv6: Switch sending fragmented IPv6 packet to new API
This optimizes the memory quite a bit since we do not need to clone nor
split the original packet at any time.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka
88f5672e4c net/ipv6: Switch MLD join, leave and report to new net_pkt API
Most of the code had to be reworked due to the new API: it's more
logical to do everything sequentially (first headers, then MLD part)
than the contrary with inserting headers at the end.

Using get_data/set_data as well it makes the code clearer.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka
ae7243b0d5 net/ipv6: Switch RA msg handler to new net_pkt API
Reworking the logic to reduce the amount of variables.
This part was heavier to change as it was not accessing the headers
directly but instead was read parts by parts.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka
9a6027ba5c net/icmpv6: Improve callback signature to pass icmp header
In nbr part, this is a useful information. Since net_icmpv6_input has
already parsed the icmpv6 header, let's get pass it, instead of
retrieving/parsing it again in various handler functions.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka
47f3b339eb net/icmpv6: Rework relevant signatures to pass ipv6 header pointer
This is meant to remove the need for macro NET_IPV6_HDR(), since we
don't know in future if accessing the header that way will be valid.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka
86ac993e0c net/ipv6: Rework input function
Use the new net_pkt API to proceed through IPv6 header and all the
extension header as well.

Use udp/tcp input functions relevantly, and call net_conn_input
afterwards.

Note: This commit temporarly disable IPv6 fragmentation support
in the code directly. Which support will be re-enabled afterwards.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Tomasz Bursztyka
c0db7efff9 tests/net: Avoid using net_udp_get_chksum()
checksum_offload is now the only one using that function, let's get rid
of such usage.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02:00
Jukka Rissanen
d1162600e9 net: app: Remove net-app API files
The net-app API is removed. Users should use the BSD socket API
for application development.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-02-01 12:29:21 +02:00
Jukka Rissanen
8b8d1dd300 tests: net: dns: Temporarily disable IPv6 query test
The disabled test causes crash in qemu_x86, so temporarily disable
it until a proper fix is found.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-01-31 08:53:58 -05:00
Vincent Wan
ef049cc976 tests: net: port mqtt tests to cc3220sf_launchxl
This commit makes the necessary changes to allow the following tests
to run on cc3220sf_launchxl:
- mqtt_packet
- mqtt_publisher
- mqtt_subscriber
- mqtt_pubsub

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-01-31 06:36:08 -05:00
Jukka Rissanen
34b07b99da tests: net: context: Fix tests when using locking
There was a false timeout error because we did not check the
return value correctly. This issue is seen now because code
flow in core IP stack is happening in different order than
before.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-01-31 11:20:26 +02:00
Tomasz Bursztyka
12995b95c2 net/ip: Protocol family do not have to follow any other OS's value
It is the macro name that matters, not its value. Here, that will help
to save 1 bit in struct net_pkt later on.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-01-30 16:27:18 +02:00
Daniel Glöckner
d678f309b8 net: pkt: convert remaining users of ref to atomic_ref
The previous commit replaced the net_pkt element ref with an element
atomic_ref. CI tests turned up more places where ref was used directly.
This commit converts them to use the new element.

Signed-off-by: Daniel Glöckner <dg@emlix.com>
2019-01-29 09:22:14 +02:00
Jukka Rissanen
4043909d69 net: http: Remove HTTP client and server APIs
The old legacy APIs use net-app library and as that is being
removed, then the dependencies need to be removed also.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-01-25 11:21:20 -05:00
Jukka Rissanen
1cba0161ed net: websocket: Remove the websocket as HTTP APIs are removed
Remove the experimental websocket code as it uses HTTP APIs
which are being removed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-01-25 11:21:20 -05:00
Paul Sokolovsky
858684a72c tests: socket: select: Add actual tests for select()
Ported from earlier poll() test.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-01-25 10:35:39 +02:00
Paul Sokolovsky
9ff4d47a8f tests: socket: poll: Add test for poll()
Basic test for poll() behavior. UDP sockets are used for simplicity
so far (poll-related paths for UDP and TCP are similar, though later
adding TCP explicitly for full coverage may be useful).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-01-25 10:35:39 +02:00
Paul Sokolovsky
3339de34eb tests: net: socket: Add "socket" tag to testcase.yaml's
So it was easy to run all socket tests without remembering
the exact path(s).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-01-25 10:35:39 +02:00
Paul Sokolovsky
3ede9feb97 tests: net: socket: socket_helpers.h: Factor out socket test helpers
The idea is that we should have many, many tests. The only reasonable
way to achieve that is by making tests easy and pleasant to write,
and that requires common, easy to reuse infrastructure.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-01-25 10:35:39 +02:00
Paul Sokolovsky
0d0ce47c4e tests: net: socket: udp: Refactor and elaborate tests.
1. Consistently use prepare_sock helpers.
2. Test not just client->server sending, but sending reply.
3. Send large packets (>1 net_buf fragment), not just small.
4. Check POSIX behavior on recv()ing datagram incompletely (the rest
should be discarded and next recv() should read next datagram.
5. More cleanroom testing, e.g. explicitly reinitialize input params
on each call (without assumptions that they're left with suitable
values from previous calls), clear input buffers before each read
operations, etc.
6. Reformat code. Previously it was very sparse, giving long test
functions, and thus impression that tests are complicated and hard
to write.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-01-25 10:35:39 +02:00
Paul Sokolovsky
10442a3f9f tests: socket: select: Basic test for select().
Currently actually just tests fd_set manipulation.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-01-24 17:14:43 +02:00
Adithya Baglody
25572f3b85 tests: Dont run coverage for select test cases.
Disabled the CONFIG_COVERAGE for benchmarks and other tests.
This is needed because it interferes with normal behavior of the
test case.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-16 06:12:33 -05:00
Jukka Rissanen
a7afdc3512 net: rpl: Remove the deprecated code
The RPL was deprecated earlier so remove it by this commit.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-01-13 09:40:36 -05:00
Paul Sokolovsky
c922ce6ce4 tests: net_pkt: More net_frag_linearize tests
Add tests for "can return less data than requested" behavior.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-01-08 11:06:56 +02:00
Anas Nashif
5060ca6a30 cmake: increase minimal required version to 3.13.1
Move to latest cmake version with many bug fixes and enhancements.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-01-03 11:51:29 -05:00
Tomasz Bursztyka
77d1c86478 tests/net: Remove usage of net_pkt_ll() function
This function is planned to be removed, thus avoiding its usage.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka
7f8d92827f net/ethernet: Remove usage of net_pkt_ll() function
This function is planned to be removed, thus avoiding its usage.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka
b105fc58f2 net/pkt: Rename net_pkt_ll_clear for better relevancy
Now it does not mangle with any ll reserver space, let's rename it to
net_pkt_lladdr_clear instead.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka
e97a543e9b net/pkt: Remove parameters to "reserve" some headroom
Such parameter is not used anymore, it was defaulted to 0 previously.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka
0e88d6d068 tests/net: Switch ieee802154 tests to ztest
These were not ran anymore.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka
c73c9e2040 tests/ieee80154: Apply L2 changes
Now that fragmentation is serialized and ll_reserve has disappeared from
15.4 L2.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka
57a0c55dac net/6lo: Remove fragmentation function parameter on compression
Fragmentation has nothing to do with 6lo. Up to the bearer to do so.

This change is required for futur serialization of 15.4 fragmentation.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka
c77d864841 tests/net: Get rid of the ll reserve
As it is unused now, let's default to 0.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Jukka Rissanen
7a0c52277c tests: net: ipv6: Fix reference to stack variable
Valgrind reported this:

==14823== Invalid read of size 4
==14823==    at 0x113FB9: memcpy (string_fortified.h:34)
==14823==    by 0x113FB9: ethernet_fill_header (ethernet.c:483)
==14823==    by 0x113FB9: ethernet_send (ethernet.c:588)
==14823==    by 0x116720: net_if_tx (net_if.c:173)
==14823==    by 0x116720: process_tx_packet (net_if.c:211)
==14823==    by 0x10FDB6: z_work_q_main (work_q.c:32)
==14823==    by 0x10FD55: _thread_entry (thread_entry.c:29)
==14823==    by 0x111CF7: posix_thread_starter (posix_core.c:301)
==14823==    by 0x49673BC: start_thread (pthread_create.c:463)
==14823==    by 0x4A78E15: clone (clone.S:108)
==14823==  Address 0x87822a6 is in a rw- anonymous segment

The issue is that we had a pointer that pointed to local stack
variable and that pointer was used to access stuff after the
test function had returned.

Fixes #12006

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-11 10:18:06 -05:00
Tomasz Bursztyka
bd23754387 net/icmpv6: Refactoring ICMPv6 input end-point
It was weird to pre-parse ICMPv6 headers in IPv6. Moreover parsing
failure of such header would not generate the right statistic.

Instead, centralizing all into net_icmpv6_input relevantly, and adapting
the test cases which were using that function. In RPL test, removing the
dummy dio test was simpler since dio is anyway tested later on.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-11 15:49:45 +02:00
Jukka Rissanen
d551f6c5ff tests: net: context: Disable assertion for net_context tests
The unit test gives net_context_get() an invalid protocol family
value which triggers an assert in net_context.c:160
This assert fails the test when it should not as we properly
check the return value. Fix this by disabling asserts for this
test.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-07 12:00:04 +02:00
Jukka Rissanen
0869a86760 tests: net: tcp: Fix interface initialization
The network interface mac address was not initialized properly
which caused assert in net_if.c:2881 to fail.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-07 12:00:04 +02:00
Jukka Rissanen
86689030e8 net: Clarify logging in networking code
Remove network specific default and max log level setting
and start to use the zephyr logging values for those.

Remove LOG_MODULE_REGISTER() from net_core.h and place the
calls into .c files. This is done in order to avoid weird
compiler errors in some cases and to make the code look similar
as other subsystems.

Fixes #11343
Fixes #11659

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-07 12:00:04 +02:00
Tomasz Bursztyka
0dd5113ca4 net/connection: Verify UDP and TCP checksum the easy way
No need to store/reset/recompute the chksums, only compute it again and
if it's not 0: drop the packet.

RFC 1071:

"To check a checksum, the 1's complement sum is computed over the
 same set of octets, including the checksum field.  If the result
 is all 1 bits (-0 in 1's complement arithmetic), the check succeeds."

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-05 11:43:54 +02:00
Tomasz Bursztyka
b4f79ae418 net: Return fully calculated chksum
IPv4, ICMPv4/6, UDP, TCP: all checksums are meant to be one's complement
on a calculated sum. Thus return one's complement already from the right
place instead of applying it in each and every place where
net_calc_chksum is called.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-05 11:43:54 +02:00
Patrik Flykt
440b535602 tests: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Tomasz Bursztyka
72e1c2b4c1 tests/net: Apply L2 change everywhere where relevant
Many tests use either Ethernet or Dummy L2 and as such require
modifications towards the driver API on their fake devices.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-30 11:12:13 -08:00
Himanshu Jha
13a3199ad3 tests: net: mgmt: remove unnecessary variable
Remove an unnecessary local variable to store the
return value, instead return directly thereby saving
few bits of memory.

Found using Coccinelle.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
2018-11-28 11:54:01 -08:00
Anas Nashif
3d906dc4c1 net: coap: Move both CoAP implementations into one Kconfig
Two separate folders and Kconfig options causing confusion on
CoAP and CoAP_SOCK implementations. This patch simplifies it.
Current CoAP Kconfig option moved to COAP_NET_PKT.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-11-22 09:08:46 -05:00
Robert Lubos
b5fd15de0c tests: mqtt: Add test to verify publish reception
Add MQTT test to verify PUBLISH message reception.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2018-11-19 09:31:01 -05:00
Robert Lubos
0f7698be8b tests: mqtt: Port tests to use new implementation
Port existing MQTT tests to new socket MQTT API.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2018-11-19 09:31:01 -05:00
Robert Lubos
f50aa6d3fb net: mqtt: Mark existing implementation as legacy
Rename existing headers and sybols to mqtt_legacy, to allow new
implementation to keep old config and header names.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2018-11-19 09:31:01 -05:00
Jukka Rissanen
6c64cb9e67 tests: net: ethernet_mgmt: Enable IPv6 for this test
IPv6 is needed as there is special handling of IPv6 addresses
when MAC address is changed. We do not need DAD + other IPv6
specific features so those are disabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-11-08 15:23:05 +02:00
Jukka Rissanen
a561913516 tests: net: ipv6: Test interface local scope dst pkt sending
Make sure that if network packet destination IPv6 address is
interface local scope multicast address FF01::, then those
packets must routed back to us when sending them.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-11-06 11:11:08 +02:00
Paul Sokolovsky
9aafe38828 tests: socket: Bump number of available fd's
These tests require much bigger number than default 4.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-11-04 22:04:11 +01:00
Jukka Rissanen
cf063fe85b net: Rename net_is_xxx...() functions to net_xxx_is...()
Unify the function naming for various network checking functions.

For example:
     net_is_ipv6_addr_loopback() -> net_ipv6_is_addr_loopback()
     net_is_my_ipv6_maddr() -> net_ipv6_is_my_maddr()
etc.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-11-02 14:52:33 -04:00
Jukka Rissanen
f87c4c03f4 tests: net: ipv6: Calculate ICMPv6 checksum for RA message
The IPv6 test was failing because the ICMPv6 checksum was
wrong.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-11-02 16:03:18 +02:00
Jukka Rissanen
75ed6d78df tests: net: mld: Fix ICMPv6 checksum calculation
The ICMP checksum was not placed to correct position in the
created test packet. This caused the checksum to be bad, and
because we now check the ICMP checksum, the packet was rejected
and the mld test failed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-11-02 16:03:18 +02:00
Jukka Rissanen
0a3b5f2294 tests: net: ipv6: Drop pkt for org scope mcast addresses
Test that we drop the received packet if the destination
address is organisation scope (ff08::) multicast address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-11-02 15:10:48 +02:00
Jukka Rissanen
bd37a9462b tests: net: ipv6: Drop pkt for site scope mcast addresses
Test that we drop the received packet if the destination
address is site scope (ff05::) multicast address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-11-02 15:10:48 +02:00
Jukka Rissanen
57ae1db1e0 tests: net: ipv6: Drop pkt for zero scope mcast addresses
Test that we drop the received packet if the destination
address is zero scope (ff00::) multicast address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-11-02 15:10:48 +02:00
Jukka Rissanen
5fba8bfda2 tests: net: ipv6: Drop pkt for iface scope mcast addresses
Test that we drop the received packet if the destination
address is interface scope multicast address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-11-02 15:10:48 +02:00
Jukka Rissanen
ae6ed44883 tests: net: ipv6: Check if we receive ::1 as src or dst address
Add two tests that will check if the source or destination address
is loopback address ::1 and we drop those packets.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-11-01 14:32:21 +02:00
Ravi kumar Veeramally
b925452911 tests: net: coap: Add new tests
New tests are added.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-10-31 19:44:25 -04:00
Reto Schneider
7eabab2f5d samples, tests: Use semi-accurate project names
When using an IDE (e.g. Eclipse, Qt Creator), the project name gets
displayed. This greatly simplifies the navigation between projects when
having many of them open at the same time. Naming every project "NONE"
defeats this functionality.

This patch tries to use sensible project names while not duplicating
too much of what is already represented in the path. This is done by
using the name of the directory the relevant CMakeLists.txt file is
stored in. To ensure unique project names in the samples (and again, in
the tests folder) folder, small manual adjustments have been done.

Signed-off-by: Reto Schneider <code@reto-schneider.ch>
2018-10-27 21:31:25 -04:00
Jukka Rissanen
a85a123477 tests: net: ip-addr: Add checks for IPv4 broadcast addresses
Make sure that IPv4 broadcast address checks work as expected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-26 15:37:21 +03:00
Jukka Rissanen
601426866a net: Set used transport protocol to net_pkt
Cache the used transport protocol in net_pkt. This way we can
avoid traversing IP header to get the last protocol in network
packet. This is mostly an issue in IPv6 which can have a long
list of extension headers after IPv6 header and before the
transport protocol header.

Fixes #10853

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-26 14:08:43 +03:00
Jukka Rissanen
55673d045d tests: net: pkt: Do not print extra errors
Some irrelevant errors were printed even if the tests passed.
Make sure that these obsolete errors at not printed so that
sanitychecker does not get confused about them.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-24 15:10:33 +03:00
Jukka Rissanen
d0679d9dd7 tests: net: Fix possible null dereference in net_pkt tests
It might be that the test might access null pointer in some cases.
In practice this is not possible as the test is using pre-defined
data when running the test.

Fixes #10777

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-24 14:25:28 +03:00
Jukka Rissanen
2c69edc149 net: Remove obsolete config options from samples and tests
Removed obsolete CONFIG_SYS_LOG_* and CONFIG_NET_DEBUG_* options
from various sample and test applications.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-11 14:44:14 -04:00
Jukka Rissanen
7ff64bfead tests: net: arp: Add gratuitous ARP tests
Make sure that we change the HW address in ARP cache if we
receive gratuitous ARP.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-10 16:12:35 +03:00
Jukka Rissanen
f3f04bf9eb tests: net: Convert to new logging system
Use new logging system with support for network log level.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-04 14:13:57 +03:00
Mark Ruvald Pedersen
d67096da05 portability: Avoid void* arithmetics which is a GNU extension
Under GNU C, sizeof(void) = 1. This commit merely makes it explicit u8.

Pointer arithmetics over void types is:
 * A GNU C extension
 * Not supported by Clang
 * Illegal across all ISO C standards

See also: https://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
2018-09-28 07:57:28 +05:30
Flavio Ceolin
da49f2e440 coccicnelle: Ignore return of memset
The return of memset is never checked. This patch explicitly ignore
the return to avoid MISRA-C violations.

The only directory excluded directory was ext/* since it contains
only imported code.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-14 16:55:37 -04:00
Tomasz Bursztyka
b6468999e4 net/pkt: Rename link layer address accessors relevantly
*_ll_src/*_ll_dst/*_ll_swap/*_ll_if were not self explanatory, ll
meaning "link layer" it's ambiguous what the names meant.
Changing to:
*_lladdr_src/*_lladdr_dst/*_lladdr_swap/*_lladdr_if to fix this.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-09-11 16:06:13 +03:00
Jukka Rissanen
6850df31a0 tests: net: ipv6: Test long lifetime IPv6 prefixes
Make sure that long lifetime IPv6 prefixes are supported
properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-09-11 10:53:30 +03:00
Jukka Rissanen
f8c6c7f0f0 tests: net: ipv6: Test long address lifetime timeouts
Check that long (> 24 days) IPv6 address lifetime timer is
properly handled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-09-11 10:53:30 +03:00
Jukka Rissanen
44498e6c8a tests: net: websocket: Fix crash when tearing down tests
No need to have setup and teardown functions. Teardown will
even cause crash when tearing down last IPv4 test.

Fixes #9617

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-29 10:57:56 -04:00
Jukka Rissanen
a81aad9756 tests: net: Run networking tests only for selected platforms
Run networking tests for native_posix, qemu_x86 and qemu_cortex_m3
platforms only as the tests are generic enough so no need to run
them in real physical device.

Fixes #9623 #9614 #9622 #9621 #9618

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-29 10:57:56 -04:00
Jørgen Kvalvaag
70f85fee34 tests: net: mqtt: Fix rc check in mqtt_publisher test
Actually use the inverted condition.

Signed-off-by: Jørgen Kvalvaag <jorgen.kvalvaag@nordicsemi.no>
2018-08-29 07:56:29 -04:00
Jukka Rissanen
9038416bdd tests: net: ipv6: Add tests for verifying DAD timers
Make sure that DAD timers are triggered in proper order.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-21 14:01:10 +03:00
Jukka Rissanen
db2cbe7ed4 tests: net: iface: Initialize port number
Coverity-CID: 187671
Coverity-CID: 187672

Fixes #9460
Fixes #9461

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-17 15:42:21 +03:00
Jukka Rissanen
aaaf20e615 tests: net: ptp: Check max number of interfaces
Add checks so that we do not overflow the network interface
array. Similar issues was fixed in commit b4dae00741 for
TX timestamp tests.

Fixes #9465

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-17 13:50:59 +03:00
Oleg Zhurakivskyy
99dc5aef88 net: ip: Refactor usage of net_sprint_ip*()
Refactor usage of net_sprint_ip*() where multiple
invocations are needed per single log call.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2018-08-17 12:36:50 +03:00
Tomasz Gorochowik
fe1797f62c tests: net: ethernet_mgmt: Don't recalculate deltaBW with no link
Fixes #9462

Coverity ID: 187670

Attempts to recalculate deltaBandwidth with no link lead to division by
zero.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-08-17 12:27:44 +03:00
Anas Nashif
9956dfc7b1 tests: update test identifier
Fix some wrong test identifiers.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-08-16 13:20:53 -07:00
Daniel Egger
5d3bc8b3d8 net: pkt: Added new function net_pkt_append_memset() to prefill packet
Some locations like DHCPv4 client create a prefilled packet by appending
new fragments in a loop with one byte each via net_pkt_append_u8() which
is wasteful and noisy. This patch adds the new functions
net_pkt_append_memset() which creates fragments as needed in the desired
size and initialises it to the specified value.

This change also adds a unittest for the new function.

Prerequisite for #9287

Signed-off-by: Daniel Egger <daniel@eggers-club.de>
2018-08-16 10:35:01 +03:00
Kumar Gala
331659c76b tests/net: ieee802154: fragment: Fix build error
Commit ac92a01f5a changed the net_ipv6_hdr
definition.  The ieee802154 fragment test wasn't updated to match this
change.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-08-15 23:48:22 +03:00
Sebastian Bøe
55ee53ce91 cmake: Prepend 'cmake_minimum_required()' into 'app' build scripts
Prepend the text 'cmake_minimum_required(VERSION 3.8.2)' into the
application and test build scripts.

Modern versions of CMake will spam users with a deprecation warning
when the toplevel CMakeLists.txt does not specify a CMake
version. This is documented in bug #8355.

To resolve this we include a cmake_minimum_required() line into the
toplevel build scripts. Additionally, cmake_minimum_required is
invoked from within boilerplate.cmake. The highest version will be
enforced.

This patch allows us to afterwards change CMake policy CMP000 from OLD
to NEW which in turn finally rids us of the verbose warning.

The extra boilerplate is considered more acceptable than the verbosity
of the CMP0000 policy.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-08-15 04:06:50 -07:00
Paul Sokolovsky
028aae1ec9 net: config: Rename Kconfig options to correspond to library name
This finishes refactor of splitting off net_config library name from
net_app library, started in c60df1311, c89a06dbc. This commit makes
sure that Kconfig options are prefixed with CONFIG_NET_CONFIG_
instead of CONFIG_NET_APP_, and propagates these changes thru the
app configs in the tree.

Also, minor dependency, etc. tweaks are made.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-08-13 18:42:31 -07:00
Andrew Boie
18cec245ba net: introduce system calls for zsock socket APIs
Add system calls for the zsock implementations of socket,
close, bind, connect, listen, accept, sendto, recvfrom,
fcntl, poll, inet_pton, and getaddrinfo.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2018-08-13 07:19:39 -07:00
Oleg Zhurakivskyy
ac92a01f5a net: ipv6: Refactor IPv6 header length handling
Change the length to uint16_t and work with it
through standard htons/ntohs() macros.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2018-08-13 13:53:14 +03:00
Jukka Rissanen
45a1c1fb67 tests: net: ipv6: Wrong API struct was used for ethernet device
As ethernet_api is larger than net_if_api, and we are accessing
ethernet_api elements in ethernet L2 driver, then invalid memory
was accessed in L2 ethernet.c.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-10 12:36:19 +03:00
Oleg Zhurakivskyy
fbac80bb94 net: ipv4: Refactor IPv4 header length handling
Change the length to uint16_t and work with it
through standard htons/ntohs() macros.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2018-08-09 16:25:17 +03:00
Jukka Rissanen
297efa514d tests: net: iface: Add test for net_if_select_src_iface() function
Make sure net_if_select_src_iface() function works ok for both IPv4
and IPv6 addresses.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-08 14:54:27 +03:00
Jukka Rissanen
05d9b0461c tests: net: iface: Add test for net_if_ipv6_select_src_iface()
Make sure that net_if_ipv6_select_src_iface() returns correct network
interface for a given destination address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-08 14:54:27 +03:00
Tomasz Gorochowik
7930419ad6 tests: net: ethernet_mgmt: Improve and finish Qav testing
With this commit all Qav parameters are tested and the fake driver
properly stores and recalculates info about all the Qav parameters to
make them available for read-back.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-08-06 10:37:09 +03:00
Tomasz Gorochowik
d380c891cc tests: net: Add new TC mappings testcases
The new mappings require at least two traffic classes so there are fewer
tests than there are for the strict mapping.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-08-06 10:23:57 +03:00
Tarun Kumar Agarwal
b8ca8cf9b7 tests: net: lib: coap: Added new functions to improve code coverage
In coap module previous test cases are modified as well as
new test functions are added to increase the code coverage

Signed-off-by: Tarun Kumar Agarwal <tarun.kumar.agarwal@intel.com>
2018-08-02 20:35:33 +03:00
Jukka Rissanen
334ce69e2a tests: net: ipv6: Must use Ethernet L2 instead of Dummy L2
As the test is testing neighbor discovery which needs to know
link addresses, we must run the test using Ethernet L2.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-08-02 16:41:55 +03:00
Tomasz Gorochowik
805e2f2c79 net: eth: mgmt: Merge 802.1Qav related mgmt requests
There are too many individual requests for Qav related parameters. There
are more Qav parameters that need to be supported (and will be supported
soon - both on the GET and SET side). Handling it the way it was handled
so far would render the eth mgmt API dominated by Qav parameters. That
would make the file hard to read and understand.

Instead of that - use a single GET and SET requests for all Qav
parameters. This works by adding a separate enum with Qav request type
to the ethernet_qav_param struct.

Additionally this approach makes it much easier to document it all since
we now have just a single request and documentation comments in the
ethernet_qav_param struct.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-08-01 15:58:05 +03:00
Tomasz Gorochowik
966ab0e42f tests: net: ethernet_mgmt: Add Qav status tests
This commit changes how the fake driver stores info about priority
queues. This allows it to test the Qav status API.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-31 17:54:24 +03:00
Jukka Rissanen
00e37cbb5b net: IPv4 link local support
Add basic IPv4 Link Local support as described in RFC 3927.

Signed-off-by: Matthias Boesl <matthias.boesl@gmail.com>
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-31 16:34:28 +03:00
Anas Nashif
87de383c66 tests: CONFIG_ARC_INIT is n by default
CONFIG_ARC_INIT is set to 'n' by default, no need to set this in the
prj.conf.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-30 15:17:51 -04:00
Tomasz Bursztyka
2c1863ff4c net/ethernet: Add a way to configure MAC address filters into devices
Some Ethernet devices can filter out incoming packets through a list of
valid MAC addresses, so let's add a way to expose this capability, using
it through the ethernet device API.

Fixes #7596

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-07-30 08:28:38 -04:00
Robert Lubos
6101e232f8 tests: net: TLS credentials subsystem tests
Add some tests to verify basic TLS credentials subsystem operation.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2018-07-27 20:28:15 +03:00
Tomasz Gorochowik
abd646c3e7 tests: net: ethernet_mgmt: Test the new get_config callback
This commit adds the get_config callback to the fake driver and makes
use of it to get the number of priority queues. That number is in turn
used in Qav tests.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-27 20:27:59 +03:00
Jukka Rissanen
d202834e86 tests: net: Add tests for net_promisc API
Test that user is able to turn on/off promiscuous mode and
also receive any data from network interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-24 15:12:37 +03:00
Jukka Rissanen
e18900c5c5 tests: net: if: Add promisc mode tests
Make sure that user is able to toggle promiscuous mode flag
in network interface level and that flag value is passed
to device driver.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-24 15:12:37 +03:00
Jukka Rissanen
7352260696 tests: net: ethernet_mgmt: Add promisc mode tests
Test in ethernet mgmt level that promiscuous flag is passed
properly to the device driver.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-24 15:12:37 +03:00
Ravi kumar Veeramally
3fafe4f9ad net: ipv6: Handle large IPv6 packets properly
Current implementation does not handle large extension headers
(e.g HBHO). Which resulted network stack crashes or due to
misinterpretation of lengths network packets are dropped. Also
caused issues while preparing IPv6 packet (e.g. large HBHO header
with IPv6 fragmentation support).

Issues fixed and provided more unit tests.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-07-23 15:01:09 +03:00
Jukka Rissanen
127220c663 tests: net: Run various tests only in qemu_x86 or native_posix
No need to run the tests in real hardware as there we can run
out of network buffers that happened with Atmel SAM-E70.

Fixes #8966

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-21 08:26:02 -04:00
Jukka Rissanen
faae730a53 tests: net: Print proper error if we run out of net bufs
Generate proper error if we run out of network buffers which means
so that the test can fail properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-21 08:26:02 -04:00
Jukka Rissanen
cf6a870863 tests: net: udp: Increase network buffer counts
In some hw like Atmel SAM-E70, the original amount of network
buffers is too small so increasing it slightly.
Also generate proper error if this happens in the test so it
is easier to figure out.

Fixes #8865

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-18 07:46:37 -04:00
Jukka Rissanen
cf71938aa1 tests: net: tcp: Use correct network interface for sending
The test app creates two network interfaces, one for simulating
local device and the other one for peer device. Make sure that
the tests use correct network interface in each test. We cannot
guarantee that net_if_get_default() will always return correct
interface in different architectures as that depends how the
net_if structs are placed in corresponding linker section.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-17 21:12:45 +03:00
Jukka Rissanen
9ad36e7145 tests: net: arp: Increase network buffer counts
In some hw like Atmel SAM-E70, the original amount of network
buffers is too small so increasing it slightly.
Also generate proper error if this happens in the test so it
is easier to figure out.

Fixes #8866

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-12 23:12:32 -04:00
Jukka Rissanen
f5ec56747e tests: net: trickle: Initialize test variables earlier
The cb_[1|2]_called variables were initialized just before running
the test. This was too late as in some cases the Trickle timer
was triggered before the variables were init, which then caused the
test to fail even though there was no actual timer failure.

This was seen with frdm_k64f and when CONFIG_BOOT_DELAY=1000 was set.

Fixes #8658

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-06 13:07:06 +03:00
Tomasz Gorochowik
01c11c172a tests: net: Add 802.1Qav test
For now just assume that the fake driver has just one priority/Qav
capable queue.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-04 16:27:34 -04:00
Tomasz Gorochowik
2ca3b1e3c4 net: if: Fix TX timestamp callbacks invocation
The problem is that net_if_call_timestamp_cb only checked if the
callback was registered for the PORT which invoked the whole action.

There is a possibility, that the callback will be registered, and packet
A will be passed to eth driver. Before the driver is finished with
packet A, network layer will start handling another packet (B) - so it
will unregister the callback for packet A and register it for B. After
that the network driver will finish processing packet A and invoke the
timestamp callback. The mechanism would then only check if a callback is
registered for the port of the driver and invoke the callback for the
packet that was registered earlier (so A instead of B).

This commit fixes that by storing info not only about the port but about
the packet too.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-07-04 16:26:35 -04:00
Jukka Rissanen
b4dae00741 tests: net: tx_timestamp: Check max number of interfaces
Add checks so that we do not overflow the network interface
array.

Fixes #8715

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-04 16:00:22 +03:00
Jukka Rissanen
482865c4c4 tests: net: ptp: Make sure we check clock increment properly
If the sys_rand32_get() returns large value, then we might
decrement the clock which is not intended in this test.

Fixes #8657

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-04 08:29:50 -04:00
Paul Sokolovsky
c89a06dbc1 net: config: Introduce a dedicated header for the library
Split out definition of net_app_init() and its parameter flags from
net_app.h header to new net_config.h header. As we do this, rename
the function to net_config_init() and flags to NET_CONFIG_NEED_*.
This is a second step in splitting out network configuration API
out of net_app API, started in the c60df1311 commit.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-07-02 12:36:35 +03:00
Tomasz Bursztyka
d309c870c7 net/ipv6: Properly separate what belongs to ipv6 from the rest
Context part should be in context. Then, rename ipv6 function for
clarity.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-07-02 12:34:12 +03:00
Kumar Gala
9127c4b3b1 tests: Cleanup converting int result to string
Introduce TC_RESULT_TO_STR to convert from an integer test result to a
string like "PASS", "FAIL", "SKIP".  Do this to remove the defines of
PASS/FAIL/SKIP since those names might get used by other code and to
have a single consistent way of doing the conversion.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-06-29 11:53:59 -05:00
Tomasz Bursztyka
1a12571482 tests/net: Fix L2 directory lookup for header inclusion
L2 directory is now located in subsys/net/l2

Fixes #8642

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-06-29 10:32:27 -05:00
Tomasz Bursztyka
89eeba4250 net/arp: No need to expose publicly arp header
ARP is something internal to ethernet L2, let's just hide its header
file.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-06-29 12:57:45 +03:00
Jukka Rissanen
45b06a252f net: gptp: Initial core IEEE 802.1AS support
Core IEEE 802.1AS-2011 (gPTP) support and application interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Julien Chevrier <julien.chevrier@intel.com>
2018-06-28 16:50:50 +03:00
Sebastian Bøe
2bcfb88aed cmake: Remove duplicate invocations of target_link_libraries on app
It is not necessary to link 'app' with mbedTLS because mbedTLS is
covered by the 'APP_LINK_WITH_MBEDTLS' mechanism that automatically
links 'app' with mbedTLS.

This patch removes the redundant target_link_libraries invocations.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-06-26 15:53:32 +02:00
Jukka Rissanen
2c8c1310fb tests: net: ptp: Add ptp clock driver tests
Make sure that the PTP clock driver works as expected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-06-26 12:37:28 +03:00
Jukka Rissanen
c63363711d tests: net: Add unit test for network pkt timestamping
Test that Tx timestamp callback code is called properly if network
packet timestamping is enabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-06-22 12:31:32 -04:00
Leandro Pereira
c16bce7a6a samples, subsys, tests: Use ARRAY_SIZE() whenever possible
The ARRAY_SIZE() utility macro will actually test the parameter types,
and ensure that it is only called with arrays, and not arrays decayed
to pointers.

Changes were performed with a simple Coccinelle script.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-06-14 19:12:51 -04:00
Jukka Rissanen
59bf65f481 tests: net: Fix tests so they can be run in real hw
Both the vlan and checksum_offload tests expect to be run in
controlled environment where the test application is providing
ethernet connectivity. If the board under test has also ethernet
support, then internal checks will fail in the test application.
Because of this, disable on board ethernet so that the tests will
pass.

Fixes #8172

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-06-05 10:30:30 -04:00
Jukka Rissanen
b43000f5eb tests: net: trickle: Fix running on frdm-k64f
The trickle API tests were not run properly in frdm-k64f board.

Fixes #8171

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-06-05 10:30:30 -04:00
Jukka Rissanen
a803335a7c tests: net: Increase the stack size of frdm-k64f
The icmpv6, http_header_fields, mqtt_packet, dns_packet and
net utils tests were failing in frdm-k64f because of too small
stack.

Fixes #8171

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-06-05 10:30:30 -04:00
Anas Nashif
b5a3ddf7d7 tests: ieee802154/crypto: use console harness
Use console harness to detect PASS/FAIL. This test should be moved to
ztest at some point.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-06-04 14:34:00 -04:00
Ulf Magnusson
12f87f7a94 tests: net: Fix assignments to CONFIG_NET_DEBUG_6LO
This symbol was renamed by commit 14e73e73c3 ("net: Make DEBUG config
option naming consistent"), but an assignment (and a commented-out
assignment) to the old name remained.

Fix the assignments to use the new name.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-05-29 16:20:35 -04:00
Ulf Magnusson
4317a181c9 tests: net: all: Increase NET_MAX_CONTEXTS from 4 to 5
DNS_RESOLVER_MAX_SERVERS has the range [1,NET_MAX_CONTEXTS], with
NET_MAX_CONTEXTS being set to 4, but is set to 5. Out-of-range .config
values are ignored, so the symbol reverts to its default value (1).

Increase NET_MAX_CONTEXTS to 5. DNS_SERVER{1-5} being set probably
implies that DNS_RESOLVER_MAX_SERVERS shouldn't be decreased to 4.

This fixes two Kconfig warnings (out-of-range + didn't get assigned
value).

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-05-28 12:20:10 -04:00
Ulf Magnusson
3c8e033e69 tests: net: all: Remove CONFIG_HTTP_HEADER_FIELD_ITEMS assignment
This symbol was removed by commit d1675bf3e6 ("net: http: Remove the
old legacy API").

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-05-25 11:21:01 -04:00
Ulf Magnusson
f6bdcb71ea tests: net: all: Fix assignments to old nbuf API Kconfig symbols
These symbols were renamed by commit bf964cdd4c ("net: Renaming net
nbuf API to net pkt API").

Update the assignments to use the new names.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-05-25 11:21:01 -04:00
Ulf Magnusson
7765813787 tests: net: all: Fix assignments to old TIME_WAIT Kconfig symbols
CONFIG_NET_TCP_{TIME_WAIT,2MSL_TIME} were replaced by
CONFIG_NET_TCP_TIME_WAIT_DELAY in commit 89f57c225a ("net:tcp: Define
single condig option for TIME_WAIT delay"), which also switched from
seconds to milliseconds for specifying the delay.

Remove the old assignments and set the new symbol to give the same
behavior as before.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-05-25 11:21:01 -04:00
Ulf Magnusson
637ad4cc49 tests: net: all: Remove redundant/misspelled NET_RPL assignments
CONFIG_NET_RPL_MC_ETX was misspelled as "..._EXT".

CONFIG_NET_RPL_MC_{NONE,EXT,ENERGY} are choice symbols. Setting a choice
symbol to 'y' implies that none of the other choice symbols are
selected, so remove the 'n' assignments and keep just the
CONFIG_NET_RPL_MC_ENERGY=y assignment.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-05-25 11:21:01 -04:00
Ulf Magnusson
2facf33f28 net: ieee802154: Remove old cc2520 AUTO_ACK assignments
CONFIG_IEEE802154_CC2520_AUTO_ACK started out as
CONFIG_TI_CC2520_AUTO_ACK, which was removed in commit 6b43821f20
("net: Remove legacy Contiki based uIP stack"). The assignments were
later renamed in commit 573774a9bf ("drivers/net/ieee802154: Change
configuration prefix").

Remove them.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-05-25 11:20:37 -04:00
Jukka Rissanen
d6b11e15be tests: net: arp: Check NULL in unicast test
Coverity-CID: 186047
Fixes #7724

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-05-24 08:01:28 -04:00
Punit Vara
7a3ace35dd tests: Remove newline character
Remove new line character from all zassert_*
messages. Following script has been used to do this.

https://github.com/punitvara/scripts/blob/master/remove_newlinech.py

zassert test framework adds newlines character implicitly.

issue: #7170

Signed-off-by: Punit Vara <punit.vara@intel.com>
2018-05-23 12:59:12 -04:00
Kumar Gala
ac13bedc84 tests: net: all: Fix COAP enablement in prj.conf
We had a left over from the old ZOAP lib in pjr.conf.  So enable the
COAP lib instead of ZOAP.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-05-23 09:06:05 -05:00
Ulf Magnusson
4190f61c28 tests: net: Fix misspelled CONFIG_DNS_NUM_CONCUR_QUERIES assignments
CONFIG_DNS_NUM_OF_CONCUR_QUERIES doesn't exist.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-05-23 08:51:11 -04:00
Ulf Magnusson
5414a7de5f tests: mqtt: Fix CONFIG_NET_BUF_DATA_SIZE assignments
These were using the older name CONFIG_NET_NBUF_DATA_SIZE (note the
extra 'N'). The symbol was renamed in commit bf964cdd4c ("net:
Renaming net nbuf API to net pkt API").

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-05-23 08:50:48 -04:00
Jukka Rissanen
6180b904af net: Too long timeout was passed to k_sleep
The code was using MSEC() macro in few places instead of more
proper K_MSEC(). The MSEC() takes seconds as a parameter and
K_MSEC() takes milliseconds.

Fixes #7657

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-05-22 08:55:27 -04:00
Tomasz Gorochowik
e2db76c9cc tests/net: Fix ethernet mgmt mac change test
The test checked if the change was reported as successful and it always
was.  What needs to be done is comparing whether the mac address was
actually changed to the requested one.

This commit adds this check.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2018-05-16 16:22:38 +03:00
Michael Scott
2c987298f2 net: tcp: expose some TCP helper functions
Similar to UDP, some drivers can make use of the following functions:
net_tcp_get_hdr()
net_tcp_set_hdr()

Let's expose them as <net/tcp.h> and change all internal references
to "tcp_internal.h".

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-05-15 18:07:47 +03:00
Jukka Rissanen
e8d0571b26 tests: net: tcp: Remove unnecessary code
As this test uses dummy L2 driver, there is no need for ethernet
specific setup as that is not used for anything.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-05-14 14:54:24 +03:00
Jukka Rissanen
4763844013 tests: net: tcp: IPv4 header was not initialized
When creating IPv4 packet, the IPv4 header contained uninitialized
values. This was reported by valgrind.

Conditional jump or move depends on uninitialised value(s)
   at 0x8066AB0: calc_chksum (utils.c:386)
   by 0x8066C99: calc_chksum_pkt (utils.c:428)
   by 0x806710A: net_calc_chksum (utils.c:487)
   by 0x8067B8D: net_calc_chksum_icmpv4 (net_private.h:138)
   by 0x8067FEC: net_icmpv4_set_chksum (icmpv4.c:90)
   by 0x8068E7A: net_icmpv4_send_error (icmpv4.c:338)
   by 0x807272F: send_icmp_error (connection.c:773)
   by 0x80731A3: net_conn_input (connection.c:992)
   by 0x806A34D: net_ipv4_process_pkt (ipv4.c:212)
   by 0x805D8B9: process_data (net_core.c:103)
   by 0x805D939: processing_data (net_core.c:117)
   by 0x805E498: net_rx (net_core.c:300)
 Uninitialised value was created by a stack allocation
   at 0x804A437: setup_ipv4_tcp (main.c:297)

Conditional jump or move depends on uninitialised value(s)
   at 0x8067117: net_calc_chksum (utils.c:489)
   by 0x8067B8D: net_calc_chksum_icmpv4 (net_private.h:138)
   by 0x8067FEC: net_icmpv4_set_chksum (icmpv4.c:90)
   by 0x8068E7A: net_icmpv4_send_error (icmpv4.c:338)
   by 0x807272F: send_icmp_error (connection.c:773)
   by 0x80731A3: net_conn_input (connection.c:992)
   by 0x806A34D: net_ipv4_process_pkt (ipv4.c:212)
   by 0x805D8B9: process_data (net_core.c:103)
   by 0x805D939: processing_data (net_core.c:117)
   by 0x805E498: net_rx (net_core.c:300)
   by 0x805E51D: process_rx_packet (net_core.c:312)
   by 0x8085E87: work_q_main (work_q.c:39)
 Uninitialised value was created by a stack allocation
   at 0x804A437: setup_ipv4_tcp (main.c:297)

Fixes #7447

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-05-14 14:54:07 +03:00
Jukka Rissanen
d551565802 tests: net: coap: Fix uninitialized memory access
The options array was not initialized to 0 and the size of the
array was not set properly. This caused following error in valgrind

Conditional jump or move depends on uninitialised value(s)
   at 0x8056777: coap_find_options (coap.c:1096)
   by 0x804AEFF: test_parse_simple_pdu (main.c:455)
   by 0x80500E6: zephyr_app_main (main.c:1585)
   by 0x807E231: bg_thread_main (init.c:254)
   by 0x80842D7: _thread_entry (thread.c:201)
   by 0x8059618: posix_thread_starter (posix_core.c:301)
   by 0x40752C8: start_thread (in /usr/lib/libpthread-2.25.so)
   by 0x4182055: clone (in /usr/lib/libc-2.25.so)

Fixes #7447

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-05-14 14:54:07 +03:00
Jukka Rissanen
93e71ab092 tests: net: mgmt: Do not allocate link address from stack
This will lead invalid IPv6 address to be generated. This was seen
in valgrind.

Conditional jump or move depends on uninitialised value(s)
   at 0x40371A4: bcmp (vg_replace_strmem.c:1100)
   by 0x8058833: net_ipv6_addr_cmp (net_ip.h:542)
   by 0x805B999: ipv6_addr_find (net_if.c:768)
   by 0x805BC8C: net_if_ipv6_addr_add (net_if.c:846)
   by 0x804A7D7: _iface_ip6_add (mgmt.c:271)
   by 0x804A5DC: test_core_event (mgmt.c:251)
   by 0x804AD1D: test_mgmt (mgmt.c:320)
   by 0x807EA81: run_test_functions (ztest.c:56)
   by 0x807EC3C: test_cb (ztest.c:196)
   by 0x8085AFD: _thread_entry (thread.c:201)
   by 0x8051B43: posix_thread_starter (posix_core.c:301)
   by 0x40752C8: start_thread (in /usr/lib/libpthread-2.25.so)

Fixes #7447

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-05-14 14:54:07 +03:00
Andy Gross
f71e497d98 tests: net: ipv6: Add assert for net_if_config_ipv6_get
This patch fixes a coverity issue with checking the outcome of a call
to net_if_config_ipv6_get().

Coverity-ID: 183478

Signed-off-by: Andy Gross <andy.gross@linaro.org>
2018-05-11 18:43:13 -04:00
Andy Gross
d76cc488a2 tests: net: checksum_offload: Check for valid UDP_HDR
This patch fixes a coverity issue with dereferencing a null ptr.  The
test needs to make sure there is a valid udp hdr before inspecting the
contents.

Coverity-ID: 183484
Coverity-ID: 183480

Signed-off-by: Andy Gross <andy.gross@linaro.org>
2018-05-11 16:50:59 -04:00
Anas Nashif
540e11ced7 tests: rename main test to main.c
For many tests, avoid splitting into files and put eveything in main.c.
For many of the tests, use main.c as the test source file to keep things
consistent.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-07 12:27:07 -04:00
Anas Nashif
bc672895ba tests: remove duplicate tests
Remove a few duplicates and avoid calling tests multiple times for
setup/teardown.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-07 12:27:07 -04:00
Anas Nashif
ee6b8761cd tests: ipv6: convert to ztest
Use ztest instead of custom routine to iterate over tests.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-07 12:27:07 -04:00
Anas Nashif
478f6807a4 tests: http: call tests via ztest macro
Move tests to be ztest items instead of calling them directly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-07 12:27:07 -04:00
Anas Nashif
efb52c5bc0 tests: neighbor: use ztest asserts
Use ztest macro and convert to ztest proper.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-07 12:27:07 -04:00
Anas Nashif
93109f2d8e tests: enhance test meta-data/improve test naming
Enhance the test meta-data and test names. This will is needed for
better and consistent reporting.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-05-07 12:27:07 -04:00
Paras Jain
12c5bfaf14 tests : ipv6_fragment : Avoid NULL pointer access
Assign the pointer only when it is not NULL.
Coverity-CID: 185397

Signed-off-by: Paras Jain <parasjain2000@gmail.com>
2018-05-05 00:39:48 -04:00
Jukka Rissanen
542f10de78 tests: net: ip: Refactor and add IPv4 tests
Add new test for testing IPv4 source address selection functions.
Refactor the tests:
- split tests to smaller pieces
- use proper zassert() statements
- print debugging information only when needed

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-05-03 12:47:52 +03:00
Anas Nashif
7a5ff13703 tests: allow unsupported tests to be skipped
Instead of completely excluding those tests, mark them as skipped and
provide an noop function that marks the test as skipped where test is
not supported.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-25 14:18:15 +05:30
Anas Nashif
1f2627a638 tests: net: style, tag, and category fixes
Fix coding style, test tags and use categories.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-25 14:18:15 +05:30
Anas Nashif
63f21391b9 tests: use consistent test function names
Minor change to make test names consistent with other tests using ztest.
All test functions need to start with test_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-25 14:18:15 +05:30
Paul Sokolovsky
e564d58b7d tests: socket: udp: Close test sockets
Close test sockets in test_send_recv_2_sock() to avoid Coverity
warnings.

Coverity-Id: 182764
Fixes: #6107

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-04-25 10:26:19 +03:00
Paul Sokolovsky
1d1db121d3 tests: socket: udp: Tighten up error checking
Add zassert's to check results of intermediate operations like
socket/bind/connect. Also, use symbolic expressions instead of
constants like 4 (for data length).

Coverity-Id: 182765, 182767
Fixes: #6104, #6106

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-04-23 15:26:43 +03:00
Stig Bjørlykke
e8bcc6f1f0 tests: socket: Free resources with freeaddrinfo
In Zephyr this has no effect because getaddrinfo() returns a pointer
to a static array, but Coverity scan checks for this pattern.

Coverity-CID: 185273
Coverity-CID: 185279

Fixes #7085
Fixes #7091

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2018-04-20 10:48:52 +03:00
Paul Sokolovsky
edc048e06f tests: socket: udp: Make sure client sockaddr fully initialized
Previously, some fields like sin6_scope_id weren't explicitly
initialized. Such aren't really used, but to keep Coverity
happy, let's zero out the entire address structure.

Coverity-Id: 182763
Fixes: #6108

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-04-20 10:47:27 +03:00
Erwan Gouriou
25e5c60c41 tests/net: utils: increase min RAM requirement to 24K
Min RAM requirement for tests/net/utils was 16K,
hence run on nucleo_l073rz.
Though, build size is a little more than 20K which
overflows board RAM.

Increase min RAM requirement for this test to 24K

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2018-04-13 13:40:05 -05:00
Andrzej Głąbek
f2177bfb8e tests: net: Make "app" tests dependent on netif
This will prevent building these tests for boards not supposed to run
a TCP/IP stack, particularly 96b_carbon_nrf51 where test-with-dns
would not fit into 32 kB of RAM.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-04-13 17:04:16 +02:00
Dario Pennisi
6d387ec98f net: Remove the need for an l2 on offloaded drivers
Drivers will be directly contacted via net_if's offload attribute. No
need for a an extra layer as an L2.

Signed-off-by: Dario Pennisi <dario@iptronix.com>
Signed-off-by: Massimiliano Agneni <massimiliano.agneni@iptronix.com>
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-12 09:56:07 -04:00
Marti Bolivar
3718684e06 tests: net: dhcpv4: fix net mgmt event handler
This is missing a mandatory check against the actual event.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-04-12 10:35:10 +03:00
Marti Bolivar
0d83900ddf tests: net: mld: fix net mgmt event handler
This is missing a mandatory check against the actual event.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-04-12 10:35:10 +03:00
Tomasz Bursztyka
757c5d1857 net/ethernet: Fix uninitialized attributes in ethernet mgmt parameters
Without that, behavior is unknown and bogus.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-10 16:43:32 +03:00
Jukka Rissanen
3c8560289c tests: net: checksum_offload: Adjust number of interfaces
The test actually has three network interfaces in native_posix board
and not two so check that correctly.

Fixes #6988

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-04-10 08:36:26 -04:00
Tomasz Bursztyka
b71d6babfb tests/net: Add a test for Ethernet net mgmt interface
Basically testing the various requests that can be done through this
interface.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-10 14:45:37 +03:00
Tomasz Bursztyka
4bf1a9bd60 net/ethernet: All types are prefixed with ethernet_
Aligning eth_hw_caps to the right prefix, so ethernet_hw_caps.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-10 14:45:37 +03:00
Tomasz Bursztyka
e996b37c0a net/ethernet: Add capabilities exposed by device drivers
Curently only link speed is exposed.
Opportunity taken to remove any post-fix enumerating the iface init
and/or the api: these must be generic and used by all the instances.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-10 14:45:37 +03:00
Anas Nashif
835ee3fff0 tests: net: checksum_offload: exclude native [REVERTME]
Failing on this platform right now, needs fix.

See GH-6988.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-09 22:55:20 -04:00
Anas Nashif
d7e7b08cdc tests: cleanup meta-data of various tests
Use sensible test name and cleanup filtering.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-09 22:55:20 -04:00
Anas Nashif
31e201b5dc tests: net: context: simplify filtering
Remove complex filtering based on BT feature being on/off.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-09 22:55:20 -04:00
Anas Nashif
5c89a4ce2f tests: ipv6: cleanup tests
Clean tagging and test names. Also make test depend on netif

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-09 22:55:20 -04:00
Anas Nashif
848c105485 tests: classify net tests and cleanup
More tagging and filterting cleanup.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-09 22:55:20 -04:00
Anas Nashif
4f4f135b9e tests: mqtt: fix dependencies
Fix platform dependencies.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-09 22:55:20 -04:00
Anas Nashif
1934d3bd5a tests: enhance test filtering for net tests
Use common section of testcase.yaml.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-04-09 22:55:20 -04:00
Jukka Rissanen
bdda369580 tests: net: vlan: Fix VLAN disable test
Because we now return first non VLAN interface if found, the
VLAN disable test case needs adjustment.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-04-09 17:17:00 +03:00
Jukka Rissanen
14e356c79a tests: net: vlan: Add VLAN tests
Add tests to verify the bit manipulation functions in net/vlan.h
file. Also check that we can check if given network interface has
VLAN enabled or not. Verify also that received network packet
contains correct VLAN tag.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-04-05 08:54:19 -04:00
Jukka Rissanen
de13e979fc net: if: vlan: Add virtual lan support
This allows creation of virtual lan (VLAN) networks. VLAN support is
only available for ethernet network technology.

Fixes #3234

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-04-05 08:54:19 -04:00
Jukka Rissanen
a0df4f6698 samples: net: Fix sanitycheck for sam_e70_xplained board
Some of the sanitycheck tests were having too small limit for
network buffers when compiling for sam_e70_xplained board.
Increase the buffer limits when testing this for this board.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-04-05 08:25:49 -04:00
Jukka Rissanen
5e6c2c3a9b tests: net: tc: Run the tests only for qemu_x86
Speedup the CI by only running the tests in qemu_x86 instead of
almost all boards.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-04-03 09:38:14 -04:00
Stig Bjørlykke
97b83ffc2c net: sockets: Check for errors from dns_get_addr_info
When dns_get_addr_info() returns an error it does not call the
resolve callback, and thus the semaphore will not be given.

This fix will avoid a deadlock situation for various errors.

Added some small tests for getaddrinfo().

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2018-04-03 14:15:43 +03:00
Patrik Flykt
41d21bd123 tests: socket: Enable loopback and net tests
Enable the loopback driver and set up network testing so that it
will not require a SLIP driver. Move values from the extra test
config so that they are always enabled.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-03-29 12:39:43 +03:00
Jukka Rissanen
c609bd8fd7 tests: net: Increase the size of main stack
This avoids this crashing in qemu_x86

***** Stack Check Fail! *****
Current thread ID = 0x004015e0
Faulting segment:address = 0x0008:0x00003593
eax: 0x0041e930, ebx: 0x00000000, ecx: 0x004170bc, edx: 0x0000dff8
esi: 0xffffffff, edi: 0x0041e930, ebp: 0x00417010, esp: 0x00416ffc
eflags: 0x216
Fatal fault in essential thread! Spinning...
Terminate emulator due to fatal kernel error

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-27 10:06:54 -04:00
Jukka Rissanen
ba3c0bb123 samples: net: Add traffic class sample application
This demostrates how to classify the network traffic when sending
data. The application will create similar functionality as
echo-client so user can use echo-server running in remote host to
test this sample application.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-27 10:06:54 -04:00
Jukka Rissanen
2a3de97ce9 tests: net: Add unit test for traffic class support
Test that we can set the priority of the network packet and
that high priority packets are sent before low priority ones.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-27 10:06:54 -04:00
Jukka Rissanen
ca8b00a3cc net: if: Make interface IP configuration more flexible
Instead of always allocating both IPv6 and IPv4 address information
to every network interface, allow more fine grained address
configuration. So it is possible to have IPv6 or IPv4 only network
interfaces.

This commit introduces two new config options:
CONFIG_NET_IF_MAX_IPV4_COUNT and CONFIG_NET_IF_MAX_IPV6_COUNT
which tell how many IP address information structs are allocated
statically. At runtime when network interface is setup, it is then
possible to attach this IP address info struct to a specific
network interface. This can save considerable amount of memory
as the IP address information struct can be quite large (depends
on how many IP addresses user configures in the system).

Note that the value of CONFIG_NET_IF_MAX_IPV4_COUNT and
CONFIG_NET_IF_MAX_IPV6_COUNT should reflect the estimated number of
network interfaces in the system. So if if CONFIG_NET_IF_MAX_IPV6_COUNT
is set to 1 and there are two network interfaces that need IPv6
addresses, then the system will not be able to setup IPv6 addresses to
the second network interface in this case. This scenario might be
just fine if the second network interface is IPv4 only. The net_if.c
will print a warning during startup if mismatch about the counts and
the actual number of network interface is detected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-27 10:06:54 -04:00
Jukka Rissanen
47dafffb67 net: if: Separate IP address configuration from net_if
Move IP address settings from net_if to separate structs.
This is needed for VLAN support.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-27 10:06:54 -04:00
Jukka Rissanen
4d16076efe tests: net: websocket: Fix null at the end of string
We might access too long string when copying URL.

Coverity-CID: 183041
Fixes #6691

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-26 13:01:07 +03:00
Jukka Rissanen
6170ae5e2e net: websocket: Use system provided base64 function
Instead of using mbedtls_base64, use system provided base64 encoding
function.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-23 08:30:26 -04:00
Jukka Rissanen
22eeb70a26 tests: net: Network packet checksum offloading tests
Test that if the checksum offloading is enabled, then we do not
calculate the checksum. Also the normal case, where offloading is
disabled and we need to calculate the checksum, is tested.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-23 08:37:01 +02:00
Jukka Rissanen
85a2459edb net: Support network packet checksum calc offloading
Create infrastructure that allows ethernet device driver to tell
if it supports network packet checksum offloading. This applies only
to IPv4, UDP or TCP checksums. The driver can enable/disable checksum
offloading separately for Tx and Rx network packets.

If the device (ethernet in this case) can calculate the network
packet checksum for IPv4, UDP or TCP, then do not calculate the
corresponding checksum by the stack itself.

Fixes #2987

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-23 08:37:01 +02:00
Jukka Rissanen
44eb83624f tests: net: websocket: Fix null pointer dereference
Network packet cannot be NULL so no need to check its value.

Coverity-CID: 183063
Fixes #6669

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-20 12:19:13 -04:00
Stig Bjørlykke
7c9c825138 net: sockets: Support MSG_PEEK flag in zsock_recvfrom
Add support for MSG_PEEK flag in recv and recvfrom.

This flag is needed when using non-zephyr embedded applications with
Zephyr's socket API.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2018-03-20 15:55:04 +02:00
Jukka Rissanen
24da695ad9 tests: net: websocket: Fix buiding on qemu_xtensa
The net-shell must be turned off in order to build on xtensa.

Fixes #6635

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-16 08:48:42 -05:00
Kumar Gala
0fea45aa4f samples/tests: net: websocket: Fix yaml files
The yaml files had a '-' before test: which was causing an error
relating to trying to load the yaml

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-03-15 16:29:01 -05:00
Kumar Gala
f303337fea tests: net: websocket: exclude qemu_xtensa
We don't currently build on qemu_xtensa because completion is missing.
Seems like we have some dependency issue.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-03-15 16:29:01 -05:00
Kumar Gala
8b08f851d2 tests: net: websocket: Bump min ram to 46k
On most arm targets this looks like it needs at least 45-46k of memory.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-03-15 16:29:01 -05:00
Jukka Rissanen
4d4c7bf3ea tests: net: websocket: Add tests for websocket
This tests websocket by creating a websocket support http server
and sending data to it and verifying the returned data is the same.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-15 15:17:36 +02:00
Stig Bjørlykke
a7e01f4d40 samples: net: Remove references to ZoAP
Rename variable zpkt to cpkt to complete the move from ZoAP to CoAP.

Remove unused tests/net/lib/zoap/CMakeLists.txt file.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2018-03-09 20:25:37 -05:00
Johan Hedberg
4637620a66 tests: net/buf: Update to new API
Update the net_buf unit test to test the features from the new API.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-02-10 09:20:42 +02:00
Johan Hedberg
09dcbcc579 tests: net: mgmt: Increase mgmt event stack
This stack seems to be overflowing on xtensa.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-02-10 09:20:42 +02:00
Ravi kumar Veeramally
9ac64c1837 net: tests: Fix coap test case
Test case should first check for next block in the coap packet and
unref the packet (assuming packet has been sent).

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-07 13:24:25 +02:00
Ravi kumar Veeramally
49894b98e4 net: Improve net management event information
Provided separate event information structs based on events. This way
user will know what kind of information will be received to that
particular event.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-02 16:50:07 +02:00
Jukka Rissanen
17fcbb0507 tests: net: ipv6: Increase the multicast address count
Increasing the IPv6 multicast address count from 2 to 5 so that
tests will always run ok.

Fixes #4401

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-02-01 14:41:37 +02:00
Anas Nashif
320c078c02 tests: mqtt_packet: fix README and adapt for cmake
Use built-in macro for build instructions.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-11 12:50:14 -05:00
Anas Nashif
829598be2b tests: add CONFIG_TEST for marking tests
Mark tests with CONFIG_TEST to allow for test specific setup and
configuration.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-08 10:03:57 -05:00
Sebastian Bøe
6f642a19fd cmake: Ported mbedTLS to use Zephyr interface libraries
mbedTLS include directories will now default to be in the 'app'
include path when mbedTLS has been enabled.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-02 22:09:01 -05:00
Anas Nashif
d4784555d0 tests: remove build_only option
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-28 20:24:29 -05:00
Anas Nashif
23f81eeb42 tests/samples: fixed yaml syntax
Use a map directory, avoid the list which makes parsing a bit
cumbersome.

Fixes #5109

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-11 14:47:08 -05:00
Paul Sokolovsky
898c88f908 tests: net: mld: Update after solicited-node mcast refactor.
1. MLD events now can happen before the test starts to run, (at iface
initialization time), so use static initialization of test semaphore.
2. Don't use a well-known multicast group like ff02::1 (all nodes),
as they are managed by the underlying stack. Use a dedicated test
address (ff10::1 here).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-12-11 09:09:48 -05:00
Kumar Gala
6b38f57225 Add missing license and copyright headers
The following files didn't have any copyright or license headers on them
when they got contributed.  So add the SPDX Apache license and
appropriate copyright info:

boards/arm/stm32l476g_disco/pinmux.c
samples/basic/threads/src/main.c
tests/net/socket/tcp/src/main.c

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-12-05 08:21:05 -06:00
Tomasz Bursztyka
b52c0f24a6 net/ieee802154: Make RAW mode generic
- Renaming NET_L2_RAW_CHANNEL to NET_RAW_MODE
- Create a generic IEEE 802.15.4 raw mode for drivers
- Modify the IEEE 802.15.4 drivers so it passes the packet unmodified,
up to code using that mode to apply the necessary changes on the
received net_pkt according to their needs
- Modify wpanusb/wpan_serial relevantly

Fixes #5004

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-11-22 10:10:09 -05:00
Jukka Rissanen
425d9fb43a tests: net: context: Fix timeout test
Fix unreachable code issue when handling test timeout.

Coverity-CID: 178788
Fixes #4786

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-11-22 07:44:10 -05:00
Paul Sokolovsky
d775ab5c26 tests: socket: Make runnable with sanitycheck
Relies on loopback network interface added recently and being able
to run QEMU without connecting to host networking.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-11-21 06:54:01 -05:00
Aska Wu
718b3cd7d0 net: sockets: Support ipv6 wildcard and loopback address
Add in6addr_any and in6addr_loopback which are defined in RFC2553 Basic
Socket Interface Extensions for IPv6.

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-11-20 13:42:38 +02:00
Robert Chou
1d70a39d1b net: samples: replace tag zoap with coap
Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2017-11-14 06:42:57 -05:00
Sebastian Bøe
0829ddfe9a kbuild: Removed KBuild
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Sebastian Bøe
12f8f76165 Introduce cmake-based rewrite of KBuild
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.

Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.

This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.

For users that just want to continue their work with minimal
disruption the following should suffice:

Install CMake 3.8.2+

Port any out-of-tree Makefiles to CMake.

Learn the absolute minimum about the new command line interface:

$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..

$ cd build
$ make

PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Aska Wu
a9b2d57664 tests: sockets: Check the value-result argument
The addrlen of accept() and recvfrom() should be updated to the actual
value of source address.

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-11-06 20:59:05 +02:00
Jukka Rissanen
2486694eb9 net: http: Create HTTP library that uses net-app
Create http library that uses net-app instead of net_context
directly. The old HTTP API is deprecated.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-11-06 09:33:00 -05:00
Aska Wu
6bbb5f2094 net: tests: Add tests for net pkt address parsing
Add IPv6/TCP, IPv6/UDP, IPv4/TCP, IPv4/UDP address parsing test cases.

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-11-06 14:09:46 +02:00
Punit Vara
658a5a2ddb tests: rpl: convert legacy test in ztest
This patch makes use of ztest apis to make output unified with
other test cases

Signed-off-by: Punit Vara <punit.vara@intel.com>
2017-11-02 17:22:59 -04:00
Aska Wu
34b5ca6122 tests: sockets: Add TCP test cases
- Test ipv4/ipv6 send() and recv().
- Test ipv4/ipv6 sendto() and recvfrom().
- Test ipv4/ipv6 sendto() and recvfrom() with NULL dest address.

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-11-01 15:08:39 +02:00
Leandro Pereira
da9b0ddf5b drivers: Rename random to entropy
This should clear up some of the confusion with random number
generators and drivers that obtain entropy from the hardware.  Also,
many hardware number generators have limited bandwidth, so it's natural
for their output to be only used for seeding a random number generator.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-11-01 08:26:29 -04:00
Leandro Pereira
7929db12bb tests: icmpv6: Assert that net_pkt and net_buf could be allocated
Coverity-ID: 177215

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-10-31 18:52:09 -04:00
Leandro Pereira
972992c524 tests: dns_resolve: Fix NULL pointer derefence if iface is NULL
Coverity-ID: 173653

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-10-31 18:52:09 -04:00
Punit Vara
aeb6a7e323 tests: 6lo: convert legacy test to ztest with cleanup
Test uses ztest and coding cleanup errors along with
warnings are removed through this patch

Signed-off-by: Punit Vara <punit.vara@intel.com>
2017-10-31 09:49:20 +02:00
Jukka Rissanen
0e7c8edc92 net: context: Make sure we honor timeout when waiting data
The call to net_context_recv() with timeout returned -ETIMEDOUT
even when data was returned properly and there was no timeout.

Fixes #4565

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-10-30 17:18:11 +02:00
Aska Wu
939aad913f tests: sockets: Make udp test cases self-contained
Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-10-30 14:53:13 +02:00
Punit Vara
68e00378d0 tests: trickle: convert legacy test to ztest
This patch makes legacy test to use ztest APIs.

Signed-off-by: Punit Vara <punit.vara@intel.com>
2017-10-30 11:11:34 +02:00
Tomasz Bursztyka
1b77ee12ea samples/net: Reducing prj*.conf files by relevantly removing 6Lo option
If NET_L2_IEEE802154 and NET_IPV6 are enabled:
- NET_6LO is enabled
- NET_L2_IEEE802154_FRAGMENT is enabled

Thus removing setting this config options to yes where applicable.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-28 14:28:02 -04:00
Punit Vara
9544b7eca4 tests: context: Make legacy test to use ztest API
Use ztest APIs in test case to make output unified with other test
cases.

Signed-off-by: Punit Vara <punit.vara@intel.com>
2017-10-26 14:51:00 +03:00
Punit Vara
a29f67beed tests: route: Convert legacy test to use ztest framework
This patch makes use of ztest apis to make output unified with other
test cases.

Signed-off-by: Punit Vara <punit.vara@intel.com>
2017-10-26 12:55:22 +02:00
Paul Sokolovsky
cdfdac394a tests: net: tcp: Update for clean up in seqno handling
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-10-25 14:19:04 +03:00
Robert Chou
7aa223174a net: coap: empty payload with payload marker is malformed
From RFC 7252, section 3
"The absence of the Payload Marker denotes a zero-length payload.
The presence of a marker followed by a zero-length payload MUST
be processed as a message format error."

Check empty payload when COAP_MARKER is found and add a test case to
cover it

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2017-10-25 13:21:53 +03:00
Ravi kumar Veeramally
a3a1772218 net: tests: Add more CoAP test cases
More test cases related to malformed packets (invalid options).

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-10-25 10:54:25 +03:00
Jukka Rissanen
964f399813 tests: net: coap: Use proper array for payload
The payload variable was one byte long but we read 32 bytes
from it.

Coverity-CID: 178064
Fixes #4397

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-10-24 11:31:16 +03:00
Ravi kumar Veeramally
ca642fbf62 net: tests: Add more testcases to 6lo tests
Add more testcases of SAC 1 and SAM 00 combinations to 6lo tests.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-10-20 10:33:28 +03:00
Tomasz Bursztyka
81b9c8fcf6 net/utils: Make net_hexdump_frags being able to print ll reserve
If requested only and with colors with right SYS_LOG Kconfig options.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-19 05:33:23 -04:00
Kumar Gala
3316b78268 tests: net: lib: dns_resolve: bump min memory to over 20k
We are failing on all systems with 20k of memory so bump up the limit
needed to build this test.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-10-18 09:47:19 -05:00
David B. Kinder
4600c37ff1 doc: Fix misspellings in header/doxygen comments
Occasional scan for misspellings missed during PR reviews

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-10-17 19:40:29 -04:00
Jukka Rissanen
faeab7f2bf tests: net: app: Simple testcases for net-app testing
These are simple tests for net-app testing. These do not try to
actually send anything to net but test mainly net-app setup and
close functionality.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-10-17 14:07:14 -04:00
Anas Nashif
0356590df5 tests: samples: fix yaml syntax
Fix indentation and syntax and make it pass yamllint tool.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-15 08:15:00 -04:00
Tomasz Bursztyka
ea0aee2bb3 drivers/ieee802154: Stop exposing old radio API functions
set_ieee_addr, set_short_addr and set_pan_id are now unused by L2, so
removing their exposure through the radio API.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-13 13:48:32 +03:00
Tomasz Bursztyka
b2726e14a6 drivers/ieee802154: Implement get_capabilities in existing drivers
Further support will need work per-driver basis, as soon as the L2 will
be able to make usage of such support.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-13 13:48:32 +03:00
Tomasz Bursztyka
dedecdaed8 tests/net: Add a test for net_mgmt_event_notify_with_info()
As previous test without info, this one will be thrown with/without
receiver 1 and 2 times.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-09 10:53:17 +03:00
Tomasz Bursztyka
c3a7b4342d tests/net: Fixing parameters alignment in mgmt test
Commit be8a106cb3 messed up the alignment. Removing also the useless
comments.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-09 10:53:17 +03:00
Tomasz Bursztyka
8e25695937 net/mgmt: Make event notifiers able to pass info to listeners
Adding net_mgmt_event_notify_with_info() which lets the event notifier
to pass dedicated data along with the event. The size of data that can
be passed must be limited to the biggest data passed (which will be
currently IPv6 + prefix).

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-09 10:53:17 +03:00
Ravi kumar Veeramally
86fe6a3bd6 net: tests: Update CoAP tests to use new API
ZoAP tests are modified to use new CoAP API. Also modified tests
name from 'zoap' to 'coap'.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-10-06 22:07:37 -04:00
Aska Wu
7c60eadd58 tests: sockets: Add tests of sendto() and recvfrom()
- Add test cases of ipv4/ipv6 sendto() and recvfrom()
- Set the main stack size to 2048 to enable both ipv4 and ipv6 on
  qemu_x86.
- Use net app for network setup.

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-10-03 14:40:05 +03:00
Jukka Rissanen
80bfd25a6c tests: net: Add IPv4 multicast address tests
These tests test the IPv4 multicast address add, lookup and
removal functions found for network interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-29 11:34:06 +03:00
Jukka Rissanen
43aa12fe25 net: dns: Do not resolve IPv6 address if IPv6 is disabled
If IPv6 is disabled, then it is useless to try to resolve
IPv6 address because "struct sockaddr" does not have enough
space to store IPv6 address.

Fixes #1487

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-20 08:55:06 +03:00
Jukka Rissanen
91b6964de1 tests: net: ipv6: Make sure test case compiles and runs
Fixing regression, address family is now called sa_family.

The testcase.yaml file was missing so no tests were actually run.

After making test to run, it was also failing because link address
was accessed before first fragment was set. This caused null pointer
access.

Fixes #1474

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-13 09:07:49 -04:00
Jukka Rissanen
e71a31e22f net: Wrong networking defines used in the code
There were bunch of config options in tests/net, net-shell and
wpan_serial sample, and those options had wrong name so they
were ignored by the code.

Fixes #1428

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-12 08:37:53 -04:00
Jukka Rissanen
bd425e6857 net: dns: Do not resolve numeric IP address
If the query name is already in numeric format, there is no
need to send the query string to DNS server as we can just
convert it ourselves.

Jira: ZEP-2562

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-31 14:33:59 -04:00
Jukka Rissanen
0bde2df491 net: tests: Add tests for IP address parsing
Add IPv4 and IPv6 address parsing tests.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-31 14:33:59 -04:00
Tomasz Bursztyka
3e2e1c3e09 tests/ieee802154: Fix a coverity warning
Jira: ZEP-2539
Coverity-CID: 173636

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-08-31 08:56:05 -04:00
Jukka Rissanen
e0dd4ff74a tests: net: mld: Ignore already joined error when sending report
The verify_send_report() failed in quark_se_c1000_devboard because
the multicast group was already joined. We can safely ignore this
error for this specific test.

Fixes #1240

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-25 22:15:33 -04:00
Anas Nashif
704f879f8a tests: ztest: call test_main() without arguments
Arguments are not needed and in some cases are being set as unused in
the same function. The test_main function is called from ztest main
routine without any arguments.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-24 09:29:14 -07:00
Paul Sokolovsky
dcb80f7ab8 net: struct sockaddr should have field "sa_family"
POSIX requires struct sockaddr's field to be named "sa_family"
(not just "family"):
http://pubs.opengroup.org/onlinepubs/009696699/basedefs/sys/socket.h.html

This change allows to port POSIX apps easier (including writing
portable apps using BSD Sockets compatible API).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-08-18 16:34:51 -04:00
Tomasz Bursztyka
9034d73f1d tests/dns_resolve: Fix possible NULL dereference
Coverity-CID: 173653

Jira: ZEP-2531

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-08-17 14:10:01 -04:00
Tomasz Bursztyka
8e77ef5493 tests/zoap: Fix possible NULL pointer dereference
Coverity-CID: 173648

Jira: ZEP-2535

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-08-17 14:10:01 -04:00
Anas Nashif
2de59023dc tests: update min ram requirements and filters
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-14 13:28:42 -04:00
Punit Vara
3251b9036a tests: neighbor: convert normal test to use ztest
This patch convert net test cases to use ztest framework APIs
which makes output unified to other test cases.

Signed-off-by: Punit Vara <punit.vara@intel.com>
2017-08-09 21:42:29 -04:00
Punit Vara
2acf077a3a tests: dhcpv4: convert normal test to use ztest
This patch convert net test cases to use ztest framework APIs
which makes output unified to other test cases.

Signed-off-by: Punit Vara <punit.vara@intel.com>
2017-08-09 21:42:29 -04:00
Niranjhana N
49d2dea875 tests: utils: convert to ztest
- replaced test points with ztest APIs wherever possible
- replaced CONFIG_MAIN_STACK_SIZE with CONFIG_ZTEST_STACKSIZE
  in config file, reduced size to 1024

JIRA: ZEP-2249

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2017-08-09 21:41:30 -04:00
Niranjhana N
e17ed87729 tests: udp: convert to ztest
- replaced test points with ztest APIs wherever possible
- replaced CONFIG_MAIN_STACK_SIZE with CONFIG_ZTEST_STACKSIZE
  in config file

JIRA: ZEP-2249

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2017-08-09 21:41:30 -04:00
Niranjhana N
9f182e07b1 tests: http_header_fields: convert to ztest
- replaced test points with ztest APIs wherever possible
- added CONFIG_ZTEST_STACKSIZE=320

JIRA: ZEP-2249

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2017-08-09 21:41:30 -04:00
Niranjhana N
0ac077af60 tests: mqtt_packet: convert to ztest
- replaced test points with ztest APIs wherever possible

JIRA: ZEP-2249

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2017-08-09 21:41:30 -04:00
Niranjhana N
be8a106cb3 tests: mgmt: convert to ztest
- replaced test points with ztest APIs wherever possible
- replaced CONFIG_MAIN_STACK_SIZE with CONFIG_ZTEST_STACKSIZE
  in config file, reduced size to 896

JIRA: ZEP-2249

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2017-08-09 21:41:30 -04:00
Niranjhana N
7d1c9184a8 tests: arp: convert to ztest
- replaced test points with ztest APIs wherever possible
- replaced CONFIG_MAIN_STACK_SIZE with CONFIG_ZTEST_STACKSIZE
  in config file

JIRA: ZEP-2249

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2017-08-09 21:41:30 -04:00
Niranjhana N
fbb6cb4fdd tests: ip-addr: convert to ztest
- replaced test points with ztest APIs wherever possible
- replaced CONFIG_MAIN_STACK_SIZE with CONFIG_ZTEST_STACKSIZE
  in config file, reduced the size by half

JIRA: ZEP-2249

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2017-08-09 21:41:30 -04:00
Niranjhana N
456f7a4d90 tests: icmpv6: convert to ztest
- replaced test points with ztest APIs wherever possible
- replaced CONFIG_MAIN_STACK_SIZE with CONFIG_ZTEST_STACKSIZE
  in config file, reduced size by half

JIRA: ZEP-2249

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2017-08-09 21:41:30 -04:00
Johan Hedberg
2975ca0754 Bluetooth: Kconfig: Rename CONFIG_BLUETOOTH_* to CONFIG_BT_*
The API name space for Bluetooth is bt_* and BT_* so it makes sense to
align the Kconfig name space with this. The additional benefit is that
this also makes the names shorter. It is also in line with what Linux
uses for Bluetooth Kconfig entries.

Some Bluetooth-related Networking Kconfig defines are renamed as well
in order to be consistent, such as NET_L2_BLUETOOTH.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-08-09 11:14:19 +03:00
Luiz Augusto von Dentz
c4f632bd09 net: bt: app: Add NET_APP_BLUETOOTH_NODE option
This enables IPSP node role which requires IPSS GATT service to be
registered.

Jira: ZEP-2451

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-08-04 18:18:40 +03:00
Aska Wu
e7acafd967 net: sockets: Fix a link error if CONFIG_NET_TCP is not enabled
Always support net_pkt_sent() and net_pkt_set_sent().

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-08-04 16:50:37 +03:00
Aska Wu
545b17a03e tests: mqtt: Add a mqtt tls test case
This adds a "build-only" test case to check if any compile error
when CONFIG_MQTT_LIB_TLS is enabled.

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-07-28 11:25:43 +03:00
Aska Wu
fb79837862 net/mqtt: Convert mqtt lib to use net app API
Use net app API since we want to enable MQTT with TLS.
mqtt_connect() and mqtt_close() are added to build and close the
connection to the broker. The caller doesn't need to deal with
the net context anymore and the most of network setup code in
mqtt_publisher is removed.

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-07-28 11:25:43 +03:00
Anas Nashif
85684d1737 tests: net: limit builds in a catch all test
This is a configuration that is unrealistic and used only to verify
Kconfig dependencies, trying to build this for every board fails due to
size limitations and due to unavailable device support on some of those
boards, building for qemu targets should be good enough.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-26 18:17:01 -04:00
Anas Nashif
52e7cdae57 tests: mqtt_subscriber: unify prj.conf
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-26 10:57:48 -04:00
Anas Nashif
80010b04cb tests: mqtt_publisher: unify prj.conf
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-26 10:57:48 -04:00
Anas Nashif
ca0ad13a61 net: enable SLIP only on QEMU targets
In many networking tests we had to configure SLIP in the prj.conf
leaving those configurations Qemu specific. This change enables SLIP for
QEMU targets automatically and allows reuse of prj.conf for multiple
boards.

Additionally, the TUN options is removed. This option was not used
anywhere.

To enable self-contained networking tests that do not depend on SLIP, we
introduce the new option NET_TEST which disables TAP and allows testing
in QEMU without the need for a host interface.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-26 10:57:48 -04:00
Jukka Rissanen
cb7b96bcc7 tests: net: trickle: Fix the Trickle parameters
The Imax doublings value was too large which caused overflow
of Imax_abs value, which then could cause Trickle test to fail.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-26 07:56:51 -05:00
Kumar Gala
dd6d34e7dc tests: net: second pass at cleanup tests to build on all platforms
The majority of these fixes adjust the memory limit needed to build the
various tests on systems with and without BLE support.  We also fixup
one test case that was able to run on platforms with 16k of memory.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-07-26 11:47:14 +03:00
Anas Nashif
1f9d8a9fd8 tests: trickle: exclude qemu_cortex_m3
Fails in CI, exclude while we investigate the issue.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-25 17:39:37 -05:00
Kumar Gala
ebc948d818 tests: net: limit tests to boards with enough memory to build them
A number of the network tests have minimal memory requirements that not
all boards are able to meet.  Add in those memory requirements so we
don't attempt to build these tests for those platforms.  Utilized the
frdm_kl25z (with 16K of memory) and cc2650_sensortag (with 20K) to test
the limits.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-07-25 15:51:18 -05:00
Jukka Rissanen
45eac217a2 net: tests: Enable net tests for all suitable platforms
Instead of only running net tests in qemu_x86, enable those
tests in all suitable platforms. The tests are disabled for
bbc_microbit as that platform does not have enough memory.

The tests/net/arp and tests/net/ieee802154/l2 are disabled
for qemu_xtensa as the qemu crashed when running the tests.
For tests/net/all there was a weird build error for qemu_xtensa
so that test is also disabled for that platform.

Increased the trickle timeout to 3 secs in tests/net/trickle as
occacionally there was timeout error in qemu_cortex_m3 when the
test was run.

Jira: ZEP-2398

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-25 10:46:44 -04:00
Jukka Rissanen
c99bc8cf53 tests: net: LLVM build warning from tests/net/dhcpv4
Duplicate config option in prj.conf file.

Jira: ZEP-2374

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-20 10:16:44 -05:00
Jukka Rissanen
5871fda709 tests: net: LLVM build warning from tests/net/udp
Missing (u8_t *) cast.

Jira: ZEP-2375

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-20 10:16:44 -05:00
Robert Chou
33c54ee6fd net: zoap: advance block context by checking M bit from block option
According to RFC7959 page 30, "The end of a block-wise transfer is
governed by the M bits in the Block options, _not_ by exhausting the
size estimates exchanges."

Therefore, we should check the M bit instead of total size (which
is not always available, too)

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2017-07-14 11:06:54 +03:00
David B. Kinder
eeed8ce179 doc: fix wiki board references in non .rst files
Some README files referenced wiki articles that have been
moved to the doc area on the website.

Fixes #668

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-07-11 12:45:35 -05:00
Jukka Rissanen
ee989be286 net: tcp: Fix sequence number validator
The sequence number validator was checking the seq numbers
incorrectly. This caused some valid RST packets to be dropped
and the TCP stream to hang.

Added also a TCP test case that tests the seq validator.

Jira: ZEP-2289

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-11 10:35:19 +03:00
Jukka Rissanen
0c5ef71c07 tests: net: 6lo: Remove CONFIG_MAIN_STACK_SIZE setting
No need to set the main stack size as the test runs just fine
without it.

Jira: ZEP-2341

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-11 10:31:11 +03:00
Andrew Boie
ed1962a65c tests: net: remove overriden RAM size
The QEMU targets have plenty of RAM now and the current value
specified wasn't a multiple of a 4K page.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-10 11:44:56 -07:00
Andrew Boie
304f91c4cb tests: net: route: fix semaphore usage
A network stack thread was trying to use a semaphore before it was
initialized. Set it up at toplevel so it is ready to go.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-10 11:44:56 -07:00
Tomasz Bursztyka
dc33d8f49e tests/ieee802154: Fix accessing unmapped memory area
commit-id b07f20c143 had wrong fix.

Jira: ZEP-2331

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-07-10 09:25:32 -07:00
Geoff Gustafson
1405627c37 net: context: Use K_NO_WAIT instead of 0 for timeout
Signed-off-by: Geoff Gustafson <geoff@linux.intel.com>
2017-07-10 10:59:28 +03:00
Jukka Rissanen
9c907fca43 net: tcp: Remove NET_TCP_HDR() macro and direct access to net_buf
Remove NET_TCP_HDR() macro as we cannot safely access TCP header
via it if the network packet header spans over multiple net_buf
fragments.

Fixed also the TCP unit tests so that they pass correctly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-07 15:24:00 +03:00
Jukka Rissanen
3604c391e6 net: udp: Remove NET_UDP_HDR() macro and direct access to net_buf
Remove NET_UDP_HDR() macro as we cannot safely access UDP header
via it if the network packet header spans over multiple net_buf
fragments.

Fixed also the UDP unit tests so that they pass correctly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-07 15:24:00 +03:00
Jukka Rissanen
8476da9d9b net: icmp: Remove NET_ICMP_HDR() macro and direct access to net_buf
Remove NET_ICMP_HDR() macro as we cannot safely access ICMP header
via it if the network packet header spans over multiple net_buf
fragments.

Jira: ZEP-2306

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-07 15:24:00 +03:00
Tomasz Bursztyka
b07f20c143 tests/ieee802154: Fix a null pointer deferencing
Jira: ZEP-2331

Reported-by Andrew Boie <andrew.p.boie@intel.com>

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-07-07 12:41:41 +03:00
Jukka Rissanen
90fc27e652 tests: net: ip-addr: Fix null pointer access in the test
IP-address test was accessing NULL pointer.

Jira: ZEP-2332

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-06 09:17:53 -07:00
Anas Nashif
882c19ddbc tests: remove build_only tag
build_only is set to false by default, so remove it.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-05 12:43:13 -04:00
Anas Nashif
c01c074b5b net: fix wrong Kconfig
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT should be used instead of
CONFIG_NET_IFACE_UNICAST_IPV6_ADDR_COUNT.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-05 12:43:13 -04:00
Tomasz Bursztyka
37af7b5096 tests/ieee802154: Fix how is initialized the driver lock in l2 test
The test starts the last one: after the driver and the net stack.
However, the net stack (due to DAD and else) will already try to send
some packet, resulting it giving a uninitialized semaphore. But once
properly initialized, this semaphore will end up with a non-zero count
when the test will start: thus reseting it to 0 before running the
tests.

Jira: ZEP-2319

Reported-by Andrew Boie <andrew.p.boie@intel.com>

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-07-03 20:58:57 -04:00
Punit Vara
fe882f407d tests: Remove camel case and fix coding style
Test whichever had Camel case defined for functions and variables have
been replaced.

Following warnings have been fixed in test cases as well.
- line over 80 characters
- Macros with flow control statements should be avoided
- Macros with complex values should be enclosed in parentheses
- break quoted strings at a space character
- do not add new typedefs
- Comparisons should place the constant on the right
  side of the test
- suspect code indent for conditional statements
- Missing a blank line after declarations
- macros should not use a trailing semicolon
- Macros with multiple statements should be
  enclosed in a do - while loop
- do not use C99 // comments

JIRA: ZEP-2249

Signed-off-by: Punit Vara <punit.vara@intel.com>
2017-06-29 07:00:50 -04:00
Anas Nashif
6c05ccb226 tests: convert testcase.ini to new format
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-28 09:20:36 -05:00
Paul Sokolovsky
b650fa8a72 tests: net: Add test for Sockets API UDP socket/bind/connect/send/recv
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-06-28 16:07:55 +03:00
Anas Nashif
6ff291a174 tests: do not exclude quark_d2000_crb
quark_d2000_crb does not build net/bluetooth tests by default now.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-27 17:44:23 -04:00
Anas Nashif
3c50f7aa12 tests: samples: remove duplicate filtering
We have many testcases doing filtering both on the architecture level
and the platform level, which is redundant. Also many testcases are
running the same test twice on the same SoC for no good reason, cleanup
the tests and cleanup the filtering.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-27 17:44:23 -04:00
Anas Nashif
60e752a9f9 tests: dns: do not set as slow test
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-21 21:38:12 -04:00
Jukka Rissanen
cc3cee0017 tests: net: context: Do not print error for passed test
It is confusing if we print timeout error when expecting
a timeout to happen. So for timeout test, do not print
an error message as the timeout is suppose to happen.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-21 21:38:12 -04:00
Jukka Rissanen
269e53609b tests: net: tcp: Fix tests and run them automatically
The TCP tests had several failures because of unnecessary
Kconfig options. These are now fixed and the TCP tests are
also run automatically by CI.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-21 21:38:12 -04:00
Jukka Rissanen
dcbe20dcb0 tests: net: mld: Fix tests and run them automatically
The MLD (Multicast Listener Discovery) tests had a failure.
This is now fixed and the MLD tests are also run automatically by CI.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-21 21:38:12 -04:00
Jukka Rissanen
e5337672e1 tests: net: ipv6: Fix tests and run them automatically
The IPv6 tests had failures and the tests did not pass
properly. These are now fixed and the tests are also
run automatically by CI.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-21 21:38:12 -04:00
Jukka Rissanen
e9368af1b4 tests: net: buf: Run the net_buf tests automatically
The test app works so it can be run automatically.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-21 21:38:12 -04:00
Anas Nashif
470c5f3189 tests: remove testcase.ini files
We now use yaml files.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-21 20:56:53 -04:00
Anas Nashif
cc24f4b03c tests: samples: convert testcase files to yaml
This will prepare test cases and samples with metadata and information
that will be consumed by the sanitycheck script which will be changed to
parse YAML files instead of ini.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-21 20:56:53 -04:00
Anas Nashif
397d29db42 linker: move all linker headers to include/linker
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-18 09:24:04 -05:00
Johan Hedberg
9703927f84 net: buf: Move net_buf_pool objects to dedicated linker area
Moving the net_buf_pool objects to a dedicated area lets us access
them by array offset into this area instead of directly by pointer.
This helps reduce the size of net_buf objects by 4 bytes.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-06-16 17:05:06 +03:00
Jukka Rissanen
72567677e7 net: pkt: Fix net_pkt_split()
The net_pkt_split() was incorrectly checking fragA pointer
even before it was allocated.

The unit test is fixed and converted to ztest.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-16 17:05:06 +03:00
Jukka Rissanen
096a9984b2 tests: net: ipv6_fragment: Fix llvm compiler warning
llvm complains about char* -> u8_t* type conversion.

tests/net/ipv6_fragment/src/main.c:645:52: warning:
  passing 'char [11]' to parameter of type 'const u8_t *' (aka
  'const unsigned char *') converts between pointers to integer
  types with different sign [-Wpointer-sign]
        bool written = net_pkt_append_all(pkt, data_len, data,

Jira: ZEP-2274

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-16 16:07:08 +03:00
Andrew Boie
15ed8ec7ea tests: use K_THREAD_STACK_DEFINE macros
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-09 18:53:28 -04:00
Andrew Boie
bcb4cfe9e4 tests: net: use main thread for test
The main thread was doing nothing but spawning another thread to perform
the test. Delete the alternate thread, and just do the test on the main
thread, adjusting stack size and priority as necessary.

Issue: ZEP-2236
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-09 18:53:28 -04:00
Ravi kumar Veeramally
7a01988c64 net: 6lo: Fix source address uncompression
When src and dst addresses are compressed based on context
information, uncompression method should verify CID bit,
SAC and DAC bits and context ID's. But it has missed some
cases which resulted in invalid uncompressed IPv6 header.

e.g. CID is set, SAC is 0 and DAC is 1 and context id's provided.
Uncompression method assumed that src address is compressed based
on context information but it is not.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-06-06 09:06:01 -04:00
Jukka Rissanen
3f46248bb5 tests: net: ipv6: Test IPv6 fragmentation sending
These tests make sure that the IPv6 fragments are build correctly
when a large IPv6 packet is being sent.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-30 11:21:51 +03:00
Paul Sokolovsky
cc47918166 tests: net: ipv6: Fix possible NULL pointer dereference behind a macro
As this is a test, it's minor issue, but let's keep Coverity report
clean.

Coverity-CID: 169303

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-05-25 18:54:22 +03:00
Jukka Rissanen
3677caa37e tests: net: zoap: Add path uri matching tests
Test the match_path_uri() function that was fixed by previous
commit.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-25 18:49:56 +03:00
Michael Scott
5ace805097 tests/zoap: fix net_pkt leak in test_observer_client()
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-05-19 09:59:07 +03:00
Anas Nashif
e9a7fa7fd7 tests: net: increase RAM for test
This tests enables all networking features and requires lots of RAM, so
increase the available RAM to avoid failures due to not enough RAM when
building.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-05-18 22:23:31 -04:00
Jukka Rissanen
69b25c0788 net: conn: Check UDP and TCP checksum before accepting packet
We did not check UDP or TCP checksum to be valid after receiving
the packet. Fix this so that the checksum is validated when
packet is received in connection handler. As the checksum validation
can be resource intensive, do it after we have verified that
there is a connection handler for this connection.

The checksum calculation can be turned OFF if needed, but it is
ON by default.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-18 10:53:39 +03:00
Anas Nashif
876334c699 tests: net: reduce timeout of testcase
Use a reasonable timeout for the testcase.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-05-17 16:35:26 +03:00
Andrew Boie
68d3678abb tests: use k_thread_create()
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-11 20:24:22 -04:00
Anas Nashif
e40bd685f6 tests: net: set reasonable timeout on dns test
This test has been slowing daily tests for no good reason, timeout of
10800 is way too high.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-05-01 09:37:34 -04:00
Paul Sokolovsky
25307d5331 net: net_pkt_append: Refactor to return length of data actually added
For stream-based protocols (TCP), adding less data than requested
("short write") is generally not a problem - the rest of data can
be sent in the next packet. So, make net_pkt_append() return length
of written data instead of just bool flag, which makes it closer
to the behavior of POSIX send()/write() calls.

There're many users of older net_pkt_append() in the codebase
however, so net_pkt_append_all() convenience function is added which
keeps returning a boolean flag. All current users were converted to
this function, except for two:

samples/net/http_server/src/ssl_utils.c
samples/net/mbedtls_sslclient/src/tcp.c

Both are related to TLS and implement mbedTLS "tx callback", which
follows POSIX short-write semantics. Both cases also had a code to
workaround previous boolean-only behavior of net_pkt_append() - after
calling it, they measured length of the actual data added (but only
in case of successful return of net_pkt_append(), so that didn't
really help). So, these 2 cases are already improved.

Jira: ZEP-1984

Change-Id: Ibaf7c029b15e91b516d73dab3612eed190ee982b
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-04-28 15:01:09 +03:00
Kumar Gala
a509441210 net: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I4ec03eb2183d59ef86ea2c20d956e5d272656837
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 09:30:38 -05:00
Jukka Rissanen
f498a90b77 net: pkt: Make the debug print eye friendly
Print "pkt" instead of "Pkt" when printing network packet
pointer value.

Change-Id: Id4225be9c55807def3d892d372cdfc5c79c871fc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 14:19:51 +03:00
Tomasz Bursztyka
f3ff4f7bd3 net_pkt: Let's make all IPv6 related attributes prefixed with ipv6_
Only 2 attributes lacked this prefix, which makes sense to have, so
applying it accordingly and changing the helpers as well.

Change-Id: I095b2729f977f8fb1624eff8801a4a4e21416693
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:51 +03:00
Tomasz Bursztyka
e5896906f6 net: Rename all *_BUF() macros to *_HDR()
Most of these macros are not exactly exposing a buffer, but a specific
header pointer (ipv6, ivp4, ethernet and so on), so it relevant to
rename them accordingly.

Change-Id: I66e32f7c3f2bc75994befb28d823e24299a53f5c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:51 +03:00
Tomasz Bursztyka
db11fcd174 net/net_pkt: Fully separate struct net_pkt from struct net_buf
- net_pkt becomes a stand-alone structure with network packet meta
  information.
- network packet data is still managed through net_buf, mostly named
  'frag'.
- net_pkt memory management is done through k_mem_slab
- function got introduced or relevantly renamed to target eithe net_pkt
  or net_buf fragments.
- net_buf's sent_list ends up in net_pkt now, and thus helps to save
  memory when TCP is enabled.

Change-Id: Ibd5c17df4f75891dec79db723a4c9fc704eb843d
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:50 +03:00
Tomasz Bursztyka
bf964cdd4c net: Renaming net nbuf API to net pkt API
There have been long lasting confusion between net_buf and net_nbuf.
While the first is actually a buffer, the second one is not. It's a
network buffer descriptor. More precisely it provides meta data about a
network packet, and holds the chain of buffer fragments made of net_buf.

Thus renaming net_nbuf to net_pkt and all names around it as well
(function, Kconfig option, ..).

Though net_pkt if the new name, it still inherit its logic from net_buf.
'
This patch is the first of a serie that will separate completely net_pkt
from net_buf.

Change-Id: Iecb32d2a0d8f4647692e5328e54b5c35454194cd
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:50 +03:00
Kumar Gala
789081673f Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t.  This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.

We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.

We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.

Jira: ZEP-2051

Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-20 16:07:08 +00:00
Anas Nashif
0ac3a231f1 tests: rename ztests' assert > zassert
Change-Id: Ibccc5da75ad42bc035052e5946f977a49f6a7d2f
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-04-14 00:07:06 -04:00
Anas Nashif
d3af7f75c9 Merge "Merge net branch into master" 2017-04-14 01:43:34 +00:00
Kumar Gala
c7bc909914 tests/ztest: rename assert macros to be zephyr specific
ztest has a number of assert style macros and used a baseline assert()
that varies from the system definition of assert() so lets rename
everything as zassert to be clear.

Change-Id: I7f176b3bae94d1045054d665be8b5bda947e5bb0
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-13 21:17:33 +00:00
Jukka Rissanen
bed1117423 net: tests: Enables all net kconfig options in one test case
This creates a test case that enables all the currently known
network related Kconfig options. This is useful so that we can
compile test various Kconfig options. Note that the result binary
is not meant to be run anywhere and it will probably not run as
some of the enabled options do not make sense in real life.

Change-Id: Iede36131b43d95acb78b4094004626e1b86e0f95
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:44 +03:00
Tomasz Bursztyka
000539ecd2 tests/net: arp_input() unref the buffer on success
Since commit-id 1ab40390c9 arp_input()
unrefs the buffer on success (NET_OK) so no need to do it afterward.

Change-Id: I84ab7e8eb07f50d52b329e4c025d88753a5de4db
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-13 15:21:43 +03:00
Tomasz Bursztyka
19a321090c tests/net: MQTT tests should be under lib
moving tests/net/mqtt_* tests under tests/net/lib/

Change-Id: I966a6b303ad4d0fb467f277a4a7379b29fe40e98
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-13 15:21:43 +03:00
Jukka Rissanen
31d3406efa net: rpl: Fix the statistics collection
The Kconfig.rpl file was missing option to actually collect
RPL statistics. Unified the config option name to be
CONFIG_NET_STATISTICS_RPL as there was two conflicting settings
in the code and both of them were missing from Kconfig file.

Change-Id: I4ce4fcbaa317b36cac315ea3b3f710fa7a344b25
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:42 +03:00
Wu Jiequan
0e3d582623 tests: net: Add mqtt testcases
Add two testcases for mqtt_publisher and mqtt_subscriber.
The combination of the two, covering most of the MQTT APIs.

Change-Id: Ib663ee1f550362ca493501046ddf8508a25ac956
Signed-off-by: Wu Jiequan <jiequanx.wu@intel.com>
2017-04-13 15:21:42 +03:00
Jukka Rissanen
1b2c16a498 net: nbuf: Add function to split a data fragment
Add net_nbuf_split() function that can be used to split
an existing net_buf fragment into two arbitrary length pieces,
and return the two new fragments to the caller. The data from
the original fragment is copied into these two new fragments.

Existing fragment is not modified.

Change-Id: I463e675232c6e19c2a42929f480893a6d1265873
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:41 +03:00
Jukka Rissanen
f8c3467bde tests: net: tcp: Fix NULL pointer dereference
Incorrectly use variable even if it is null.

Coverity-CID: 157593

Change-Id: I883421a16870e5fe3c1d81e461f55f912ea168c0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:41 +03:00
Tomasz Bursztyka
8108a608ff net/mgmt: Mask vs event should be verified part by part
It needs to check if current event matches:

- cb's layer
- cb's layer code
- cb's command

If none match, it will not raise the event.

Fixing the unit test as layer must be always != 0.

Jira: ZEP-1940

Change-Id: Iadd63e751fa6e534a10e7da9cae0f5bb5a384461
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 12:15:29 +00:00
Tomasz Bursztyka
dc7be7c54f net/ieee802154: Disable ACK reply handling by default
Most (if not all) 802.15.4 devices can handle ACK replies by
themselves.

Change-Id: I0319d59de767b20eb67c1592bacaa4a7b7015cad
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 11:24:28 +02:00
Tomasz Bursztyka
5e3354dad5 net/ieee802154: We don't get the MFR from device drivers
commit id 7a11439020 changed this.
Hopefully that changed did not affect anything.

Reducing minimal frame length and applying the change everywhere where
relevant.

Change-Id: I5ae203751bfcf70cef833620106d2c2d0e33b7a5
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 11:24:28 +02:00
Tomasz Bursztyka
82709802a9 tests/net/ieee802154: Add a unit test for secured data frame validation
Change-Id: I3e35d13d1fdfacb6625dfe1b7b30cc2354a7ee93
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 11:24:28 +02:00
Tomasz Bursztyka
cca117d8b9 tests/net/ieee802154: Switch l2 to ztest framework
Change-Id: Ibce93d4652e3991a06e870fc81e952788f0c6465
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 11:24:27 +02:00
Tomasz Bursztyka
7f50b56c0e tests/net/ieee802154: Add a simple CC2520 crypto dev test
It will first run the datasheet example.

Change-Id: Ic4da5ba9170a253cfdff4b17010d72dc86376555
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 10:39:33 +02:00
Jukka Rissanen
a8dc0e60aa net: tests: Fix nbr lookup in route tests
The neighbor was added very fragile way into neighbor cache which
caused following queries to fail. This is now fixed by manually
adding neighbor to the cache.

Change-Id: I1831557fd5f9df5afd0a6c6833b0af769f5167eb
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-31 10:58:17 +03:00
Jukka Rissanen
625870a2f6 net: rpl: Temporarily disable some of the RPL tests
Couple of tests started to fail without any apparent reason.
Disabling them temporarily until the root cause is found.

Change-Id: Id82e0eab60dc744c8ce6f02a5834e731be153883
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-31 10:58:17 +03:00
Jukka Rissanen
c3b1070d10 tests: dns: Resolve API test cases
Change-Id: I090515c0e720c5779e3b5a9f2eb19e398ea0e987
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-24 17:31:42 +02:00
Tomasz Bursztyka
1e3dc0cbb4 net/ipv6: Renaming IPv6 neighbor state related macros and function
Refining the names around IPv6's neighbor states to differentiate them
easily from any net_nbr related names (which are not tighten to IPv6).

Change-Id: Ibc24df2a9485477a53fe5fe1c8f993f0fcd91635
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-24 17:31:41 +02:00
Michael Scott
081246737c net/http: let HTTP_SERVER, HTTP_CLIENT and HTTP_PARSER select HTTP
Due to commit 8308b9bd2d ("net/http: Add the HTTP/1.1 API")
every user of CONFIG_HTTP_PARSER would need to add CONFIG_HTTP to
their .conf files.  Which is fine for intree samples/tests as they
have been adjusted, but the rest of world working on Zephyr apps
will need to make this changes as well.

Instead, we should have each of the following select HTTP instead of
depend on it, which will make future use of these configs and their
dependencies more intuitive:
HTTP_SERVER
HTTP_CLIENT
HTTP_PARSER

NOTE: As cleanup, this commit also removes the CONFIG_HTTP added to
samples and test .conf files.

Change-Id: I81cfaa19e37333b1bf98778f8147814780e7f77c
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-03-17 10:34:45 +02:00
Jukka Rissanen
157c383260 net: ipv6: Make config options more fine grained
Add CONFIG_NET_IPV6_NBR_CACHE option that is the base for both
neighbor discovery (ND) and duplicate address detection (DAD).

Both ND and DAD can be disabled if needed. If NBR cache is
disabled, then ND and DAD are disabled too.

Note that it makes not much sense to disable DAD or NBR cache
as IPv6 will not work properly without them. It is possible
to disable ND but then the neighbor information needs to come
via other sources like RPL.

Change-Id: I57c8668ad828b3a153dfc58eea78bf5f7ac3938a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-17 10:34:43 +02:00
Jukka Rissanen
fc2542b88b net: tests: Fix the default MAC address
Use the proper MAC address space (00-00-5E-00-53-xx) dedicated
for documentation and specified in RFC 7042 ch 2.1.2.

Change-Id: If8ef9e4ee4e041ad005060664ebafe60df0a6bf9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-17 10:34:43 +02:00
Tomasz Bursztyka
87b80191b6 tests/net/mgmt: Add 2 unit tests around synchronous event listeners.
Test net_mgmt_event_wait() and net_mgmt_event_wait_on_iface()

Change-Id: I82ba70a697f0d13aa2e1eef2110e139b3621c119
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-17 10:34:42 +02:00
Tomasz Bursztyka
35e5aa8865 net/mgmt: Add a function to wait on a event synchronously
Instead of creating a handler and a related callback structure on an
event_mask: net_mgmt_event_wait() can be used to wait synchronously on
such event_mask. The core mgmt part will seamlessly reuse the struct
net_mgmt_event_callback so the whole internal notification mechanism is
using the same code.

Change-Id: I426d782c770e75e5222aa3c5b703172b1f1f2e5e
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-17 10:34:42 +02:00
Ravi kumar Veeramally
8cb97ae47d net: Modify IPv4/6 packet finalize API's
Current finalize api's takes buf as input parameter and returns
the finalized buf. But if there are any issue while finalizing,
it failed to throw an error.

Change-Id: I6db54b7453eec41a8051fab50d5c0dc937debd54
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-03-17 10:34:42 +02:00
Ravi kumar Veeramally
ad855fc31d net: ipv6: Fix handling of RA 6CO options
As per RFC 6775 4.2, context length holds number of leading bits
in the Context Prefix field that are valid. Rest are not valid
for compression.

Change-Id: Id21cc2d7a5d42980cf9295f85e75c4869ff6cb99
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-03-17 10:34:41 +02:00
Flavio Santes
f1ec62ed75 tests/net/dns: Add routines to evaluate DNS responses
This patch adds some routines to evaluate DNS responses as specified
by RFC 1035.

Jira: ZEP-1876

Change-Id: Ia78a1175229962128a0bcee985e507d72ed26aea
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-03-17 10:34:41 +02:00
Jukka Rissanen
1274a229cc net: tests: nbuf: Fix compiler warnings
LLVM/icx compiler gives warnings for uint16_t vs. size_t
values.

Jira: ZEP-1886

Change-Id: I63c5deea672568946d91421a873c470af3cec6df
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-17 10:34:41 +02:00
Flavio Santes
8308b9bd2d net/http: Add the HTTP/1.1 API
This patch adds the HTTP/1.1 API for Zephyr. This API consists of client
and server context structures enabled via Kconfig variables.
HTTP parser support is enabled via the CONFIG_HTTP_PARSER configuration
variable.

Currently, this API only includes support for writing HTTP requests
(client mode) and HTTP responses (server mode). TLS support is not
considered in this iteration.

Supported HTTP methods:
	GET, HEAD, OPTIONS and POST.

Supported HTTP responses:
	400, 403 404. The http_response routine may be used to write
	any HTTP status code, for example 200 OK.

Jira: ZEP-1701

Change-Id: Ic9ccd4d4578d6d0f3a439976ea332b031644ca7d
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-03-09 20:33:49 +02:00
Flavio Santes
bed2f43120 tests/net/dns: Add the test case for the DNS low-level routines
This patch adds the test case for the DNS API low-level routines.

The following routines are evaluated by this test case:

- dns_msg_pack_qname
- dns_msg_pack_query
- dns_unpack_header_id
- dns_header_qr
- dns_header_opcode
- dns_header_aa
- dns_header_tc
- dns_header_rd
- dns_header_ra
- dns_header_z
- dns_header_rcode
- dns_header_qdcount
- dns_header_ancount
- dns_header_nscount
- dns_header_arcount
- dns_unpack_query_qclass
- dns_unpack_query_qtype

Next iterations will consider IPv6 and DNS RR coverage.

Jira: ZEP-1499

Change-Id: I4ef46203e6fec57c6fe5a5db8132ed140b412fc2
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-03-09 20:33:49 +02:00
Jukka Rissanen
e82f7a6a31 tests: net: Check allnodes and solicit node addresses.
Make sure that the network interface has proper allnodes and
solicit node multicast addresses set.

Change-Id: I2318d63df0b5d09dfaa8347b69c843b84ed63f4b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-09 20:33:48 +02:00
Jukka Rissanen
253e9a377f tests: net: Add MLD query tests
Add tests for verifying that we can receive Multicast Listener
Discovery query and act on it.

Change-Id: I926cf5e9f77cd250d2d7094f2379e320ef163540
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-09 20:33:48 +02:00
Jukka Rissanen
8d8e3772e6 net: ipv6: Respond to MLD query
If we receive MLDv2 (Multicast Listener Discover) query,
we send out information about the multicast groups that
we have joined.

Change-Id: If4ea9fa685319b2ad900e1949a5cbe12e7696b43
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-09 20:33:48 +02:00
Jukka Rissanen
d0fc787c21 tests: net: Add unit tests for mld
MLD (Multicast Listerer Discovery) unit tests when joining
or leaving an IPv6 multicast group.

Change-Id: I7cd0f4c5f31c693d816fb5d27d3d23bb27679c35
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-09 20:33:48 +02:00
Jukka Rissanen
ba5bb5a9df net: if: Join/leave pre-defined IPv6 multicast groups
When we setup the network interface, add predefined IPv6 multicast
groups into the network interface. When interface is taken down,
then leave all the multicast groups that joined.
See RFC 4291 ch 2.8 for details.

Change-Id: If17d3e8c75157a02aa93c92e2fb499619c1484cf
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-09 20:33:47 +02:00
Jukka Rissanen
74e747a27f net: ipv6: Add support to join/leave multicast group
This and subsequent commits adds API to join or leave
an IPv6 multicast group.

Jira: ZEP-1673

Change-Id: I26dcfe16a4527dbf7886a30827a5d4ebfdeaac01
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-09 20:33:47 +02:00
Ravi kumar Veeramally
476f46f61b net: icmpv6: Remove unused variable 'len' from input calls
Variable len is not used in net_icmpv6_input() and if required
it can be obtained from 'buf'.

Change-Id: I4b0710e1cf16cff9837173ad9d6908ec54ebafae
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-03-09 20:33:45 +02:00
Jukka Rissanen
5032bdc46d net: nbuf: Pass ll_reserve when creating TX buffer
Instead of always calling net_nbuf_get_reserve_tx() with zero
ll_reserve (first parameter) and then setting the link layer
reserve separately, pass the reserve to that function which can
then set the ll_reserve in buf itself.

Change-Id: I21c14cb7e2e6c36d170c09998bca0207ecf65c75
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-09 20:33:43 +02:00
Jukka Rissanen
189ec2b6ad net: Remove link layer reserve param from IP packet creator
The ll_reserve parameter is useless in net_ipv{4|6}_create_raw()
function as the reserve information is already stored in buf.

Change-Id: I7815a78c001e3da532478c04b3dac9b37bbc723c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-09 20:33:43 +02:00
Jukka Rissanen
5197266768 net: nbuf: Use net_nbuf_get_frag() to allocate a fragment
The code used net_nbuf_get_reserve_{rx|tx}_data() function to
allocate a fragment. Instead of that low level function, use
net_nbuf_get_frag() instead. There are few places this is not
possible or is too big change like in few test programs.

Change-Id: Ied7e2b7db352de998b200ffa6ff82471bfa5ebe3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-09 20:33:43 +02:00
Jukka Rissanen
d32503f57e net: nbuf: Split one global DATA pool to RX and TX DATA pools
If we receive lot of packets, it might happen that we exhaust
all the DATA buffers in the system. This would prevent from
us sending anything to the network.
Change this by splitting the DATA buffer pool into RX and TX
parts. This way RX flooding cannot consume all DATA buffers
that needs to be sent.

Change-Id: I8e8934c6d5fdd47b579ffa6268721b5eb3d64b6d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-09 20:33:43 +02:00
Jukka Rissanen
4bcc2a47d0 net: nbuf: Fix net_nbuf_copy() so that original nbuf is not modified
It makes no sense to modify the original net_buf so change the
copy function not to touch the original buffer.

Change-Id: I5d22445ce50cee62994c36567f0e995a500cb89d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-09 20:33:42 +02:00
Jukka Rissanen
6a4372b0df net: nbuf: Fix the net_nbuf_copy() buf parameter
The first parameter of net_nbuf_copy() must be the head
of the buffer chain i.e., it must contain the user_data
part. If a fragment is given, then we do not know enough
information to allocate the data fragments.

Change-Id: I052b183d8c63d7326b320254f36f00b2fc48b0a0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-09 20:33:42 +02:00
Vinicius Costa Gomes
8e304ef2e6 iot/zoap: Fix requiring that the buffer is unchanged for retransmit
It is possible that the buffer waiting for retransmission is modified
after it is sent, for example, it can be compacted by 6lo, and our
assumption of where is the message ID is located in the buffer is no
longer valid.

As the message ID is the only information that is necessary for
keeping track of retransmissions, we keep a copy of it in the pending
struct, as well as the destination address of the retransmission.

Change-Id: Id33d54353404628673541225a1a05e27ee08765f
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-02-27 10:28:54 +02:00
Vinicius Costa Gomes
45fe87a425 tests/zoap: Adds test for the length of payload on the RX side
This unit test verifies that zoap_packet_get_payload() returns the
expected size for received packets.

Jira: ZEP-1662

Change-Id: Ibe011959f4d6593f4f20f0f5901c9033c76c9518
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-02-27 10:28:54 +02:00
Jukka Rissanen
4eb2020055 net: Set the network link address type when setting link address
The interface L2 address type is set at the same time as the
L2 address is set to the network interface. This is most
convinient place to set the address type.

Change-Id: I712d7357d075959eb79df3463141cfbc6d163a74
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-02-22 17:28:25 +02:00
Flavio Santes
216ccb7198 tests/mqtt: Fix compiler warnings in MQTT Packet test case
Cast to uint8_t * some char * values to avoid compiler warnings.

Jira: ZEP-1179

Change-Id: I9973eecbed357a2fc44958cad22f812d166f6756
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-02-22 17:28:24 +02:00
Flavio Santes
057f31e7e9 net/mqtt: Remove length computations for some msg fields
Currently, for the following MQTT msg fields:

- client_id
- will_topic
- user_name
- topic

their length is computed inside the routine that receives the MQTT msg.

Although this simplifies development, also imposes one restriction:
data must be null-terminated. Sometimes, data is received from other
sources and not generated by the application, so the null-terminated
constraint may be considered problematic for the user.

This patch removes the assumption that string fields are null-terminated.
Current data structures are already prepared to handle this case, so no
API change is required.

Change-Id: I5a147a5b21e0da49541cbe62baac363c8737cd3e
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-02-15 12:20:08 +02:00
Ravi kumar Veeramally
3bb2f3b29a net: tests: Unref net_buf using net_nbuf_unref
Using net_buf_unref() technically works but debugging the network buffer
allocations is more difficult if done like that.

Change-Id: Ieaa0978aa69e2f0baa924fe842ca1f116c348ef1
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-02-09 12:29:29 +02:00
Ravi kumar Veeramally
58ba1d834e net: nbuf: Fix net_nbuf_compact() API
Current API description of net_nbuf_compact() is not very clear.
The first parameter needs to be the first net_buf in the chain.

The changes to this API are needed in order to clarify following
use cases:
1) User provides fragment that is not first of the chain and compact is
successfully done. In this case there is no free space in fragment list
after the input fragment. But there might be empty space in previous
fragments. So fragment chain is not completely compacted.

2) What if input fragment has been deleted and api returns the same
buf?

So this commit simplifies the API behavior. Now net_nbuf_compact()
expects the first parameter to be either TX or RX net_buf and then it
compacts it. It fails only if the input fragment is a data fragment.

Change-Id: I9e02dfcb6f3f2e2998826522a25ec207850a8056
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-02-08 10:12:36 +02:00
Ravi kumar Veeramally
999338ea94 net: nbuf: Remove unused net_nbuf_push() API
The net_nbuf_push() API is not used by anyone. Semantics are not
clear and following patch requires changes to push api, so removing
this API for now. If needed this can be re-introduced later.

Change-Id: I1d669c861590aa9bc80cc1ccb08144bd6020dac5
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-02-08 10:12:36 +02:00
Ravi kumar Veeramally
70f7922cee net: tests: 15.4: Increase max data size and fix config option
Test with max data in order to test the fragmentation code better.

Change-Id: I301a96eae1dd637f0291354120389c2bd7575695
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-02-08 10:12:35 +02:00
Jukka Rissanen
bd3908b2a9 net: nbuf: Add timeout to net_buf getters
This commit changes the net_buf getter functions in nbuf.h
by adding a timeout parameter. These function prototypes
are changed to accept a timeout parameter.
	net_nbuf_get_rx()
	net_nbuf_get_tx()
	net_nbuf_get_data()
	net_nbuf_get_reserve_rx()
	net_nbuf_get_reserve_tx()
	net_nbuf_get_reserve_data()
	net_nbuf_copy()
	net_nbuf_copy_all()
	net_nbuf_push()
	net_nbuf_append()
	net_nbuf_write()
	net_nbuf_insert()

Following convinience functions have not been changed
	net_nbuf_append_u8
	net_nbuf_append_be16
	net_nbuf_append_be32
	net_nbuf_insert_u8
	net_nbuf_insert_be16
	net_nbuf_insert_be32
	net_nbuf_write_u8
	net_nbuf_write_be16
	net_nbuf_write_be32
so they call the base function using K_FOREVER. Use the
base function if you want to have a timeout when net_buf
is allocated.

Change-Id: I20bb602ffb73069e5a02668fce60575141586c0f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-02-08 10:12:35 +02:00
Jukka Rissanen
cc8eb4144b tests: net: Add tests for network interface
Change-Id: I35f0b3f1794c65b08d32ca561b6189ee59a7a76c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-02-03 15:59:18 +02:00
Jukka Rissanen
3c95a56c2a tests: net: rpl: Fix unicast NS sending
If we send unicast NS, then the destination IPv6 address needs
to be in the neighbor cache, otherwise we have a NS sending loop.

Change-Id: I11e8f5d5740248024a0becc77055786cd2e32199
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-02-03 15:59:17 +02:00
Jukka Rissanen
6b069f1589 net: tests: Add unit tests for net_nbuf_compact()
The compact function was never really properly tested
but it is used by other routines that have unit tests.
This commit makes sure there is a special testing for
the buffer compact function.

Change-Id: I35c108fd8459a9482ccae68a51ffa28fb2e0ae99
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-02-03 15:59:17 +02:00
Ravi kumar Veeramally
2de8bd928a net: tests: Add unit tests for net_addr_ntop() utils function
Change-Id: I72ee5f6444d2e45de0ee7a3aa96884282d41b72d
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-02-03 15:59:14 +02:00
Ravi kumar Veeramally
10e5162fc2 net: tests: Add unit tests for net_addr_pton() utils function
Change-Id: Ib1e89ce3bb7eff5afe14394062ee6f53a28cc4e6
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-02-03 15:59:14 +02:00
Andrei Emeltchenko
6043dddd4a net: Remove unused CONFIG_NET_IPV6_NO_DAD option
Option CONFIG_NET_IPV6_NO_DAD is not used anymore, clean project
configuration files.

Change-Id: I368e076d2f79f1d4bc86edee11ff5befe37362c8
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-01-27 12:35:54 +02:00
Andrei Emeltchenko
7ab5d4f572 net: tests: Correct project file for route tests
Routing tests uses ND so do not disable it, otherwise tests might fail
if disabling ND supported.

Change-Id: Ie020de8dac4447931d1067f1ed781a72cf05e8af
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-01-27 12:35:54 +02:00
Tomasz Bursztyka
83ed3a29be net/ieee802154: Modify radio TX function signature
The cause for this change is TCP. Until now, the radio strategy driver
(ALOHA or CSMA) was providing the actual nbuf, and not the buffer
fragment, counting on the fact that the loop was using
net_buf_frag_del() which made so, iteration after iteration, buffer
framgent to be always buf->frags. The problem with this logic is loosing
the fragments that might be still referenced by TCP, in case the whole
buffer did not make it so TCP can retry later and so on.

Instead, TX now takes the nbuf and the actual frag to send. It could
have been working with just a pointer on the data, and the whole length
of the frame. But it has been avoided due to possible future devices,
that will be smarter and run CSMA directly in the hw, thus it will
require to access the whole buffer list through the nbuf.

Change-Id: I8d77b1e13b648c0ec3645cb2d55d1910d00381ea
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-01-27 12:35:53 +02:00
Andrei Emeltchenko
5794d80c10 net: Remove CONFIG_NET_IPV6_NO_ND config option
The option is no longer used so it can be removed.
Use CONFIG_NET_IPV6_ND option instead.

Change-Id: Ibaa3d3deb52b8b176e85f8b9e1d8c80c1026aea1
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-01-27 12:35:53 +02:00
Ravi kumar Veeramally
538d8d4032 net: tests: Use lighter printk() instead of printf()
Use printk(), snprintk() instead of printf() and snprintf().
CONFIG_STDOUT_CONSOLE is anyway disabled by default so printf()
will not output anything without it.

Change-Id: I5899741df2e187dae7b4602d074e9b4cbb9952aa
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-01-27 12:35:51 +02:00
Ravi kumar Veeramally
b80878496d net: tests: Fix invalid config option in 6lo tests
The debug config was incorrect.

Change-Id: Id32cbcfb809acc9e4ab202b401d25e41a7531c42
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-01-27 12:35:50 +02:00
Jukka Rissanen
088289ec28 net: context: Add status to connect callback
It is useful that the user API can know whether the connection
was established properly or not. So this commit adds status
parameter to connect callback in net_context API.

The call to connect callback needs to be set properly in TCP
code. This commit does not fix the connect callback call which
is not properly done right now in net_context.c.

Change-Id: I284a60ddd658ceef9e65022e96591f467a936a09
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-01-20 16:23:21 +02:00
Jukka Rissanen
ba026941a1 net: ipv6: Fix IPv6 prefix comparision
If the prefix length % 8 is not 0, then the remaining
bit length was calculated incorrectly and the prefixes
were claimed to match even though they might not be the
same.

Adding a test cases for testing this properly.

Coverity-CID: 157591

Change-Id: I9cb5a73d5cc211ec183176400fa5e2dfd209e2da
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-01-20 16:23:18 +02:00
Michael Scott
4aad767328 net: linkaddr: calculate linkaddr storage addr size via config
- Introduce NET_LINK_ADDR_MAX_LENGTH which is either 6 or 8
  depending on whether CONFIG_NET_L2_IEEE802154 is used
- Instead of being a placeholder single index array of uint8_t,
  let's use NET_LINK_ADDR_MAX_LENGTH to assign the size of the
  "addr" array field in the net_linkaddr_storage structure.
- Now that the "addr" field of net_linkaddr_storage contains the
  true size of the link address, we can remove "storage" field
  which was hard coded to 8 bytes (2 uint32_t's).
- Fix 2 references to the "storage" field of the net_linkaddr_storage
  structure.

Change-Id: I2ea12058280b289f65085964eb7d503d4fd260c2
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-01-20 16:23:16 +02:00
David B. Kinder
ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Anas Nashif
2bc9d69981 build: abstract emulation and replace qemu goal with run
This will replace the current goal of 'make qemu' with 'make run' and
moves Qemu handling into its own file and into the boards instead of
being architecture specific.

We should be able to add new boards that support some other type of
emulation (by adding scripts/Makefile.<emu type>) and allow the board to
define their own options for the use type of emulation.

'make qemu' will still work, however it will be deprecated, starting
with this commit it is recommended to use 'make run'.

Jira: ZEP-359
Change-Id: I1cacd56b4ec09421a58cf5d010e22e9035214df6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-01-10 20:20:47 +00:00
Anas Nashif
f6e039062a kernel: remove dependency on CONFIG_NANO_TIMERS/TIMEOUTS
Remove legacy option and use SYS_CLOCK_EXISTS where appropriate.

Change-Id: I3d524ea2776e638683f0196c0cc342359d5d810f
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-01-08 18:09:52 +00:00
Andy Ross
a5b694fbbc net: tcp: Select correct source address for SYNACK packets
The source address for a TCP SYNACK must (obviously) be the same as
the destination address of the SYN that produced it.  But the existing
IP packet creation routines would simply fill in a default address
from the net_context struct, which is correct for *established*
connections, but for the listening socket is generally INADDR_ANY
(i.e. all zeroes) and will result in an arbitrary choice for source
address (e.g. a link-local address on the same interface) which can
easily be wrong.

So we need to pass the correct address all the way down from the SYN
packet handler code through the net_ipv*_create() packet creation
functions.  This requires lots of API plumbing, but relatively little
logic change.

Change-Id: Ic368f8cef6689f8a27cbafd5933a4964d5cc457e
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-01-06 08:21:15 -05:00
Anas Nashif
66cfcc26bc tests: introduce Makefile.test
To customise test builds and support test related features such as time
stamps and a boot banner, introduce a Makefile variant that is dedicated
to testing.

Initially we introduce a new config overlay that is used for all tests, in
this case we enable BOOT_BANNER and BUILD_TIMESTAMP. This will print the
current version and the date, useful when reporting bugs and also an
indicator that the system has booted before the test has started.

For example:

[QEMU] CPU: qemu32
***** BOOTING ZEPHYR OS v1.6.99 - BUILD: Dec 21 2016 19:57:13 *****
tc_start() - Test Nanokernel CPU and thread routines
Initializing nanokernel objects
...
..

Change-Id: I224318cdeb55a301964ea366dbc577e2e3a09175
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-01-03 17:48:44 +00:00
Tomasz Bursztyka
a1aa08c288 net: ip: Improve logging by adding a dedicated sys_log level
Let's make net stack having its own level of debugging through sys_log.
It replaces NET_DEBUG by NET_LOG_ENABLED, which is then semantically
better: someone wanting to log the errors might want that not only for
debugging.

Along with it, CONFIG_NET_LOG_GLOBAL option is added, in order to enable
all available logging in network stack. It is disabled by default but
might be found useful when warning/errors need to be logged, so it is
then unnecessary to selectively enable by hand all CONFIG_NET_DEBUG_*
options.

It is possible, locally, to override CONFIG_SYS_LOG_NET_LEVEL by setting
the level one want to NET_SYS_LOG_LEVEL. This can be useful on samples
or tests.

Change-Id: I56a8f052340bc3a932229963cc69b39912093b88
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-01-02 10:03:20 +01:00
Tomasz Bursztyka
4869dc9786 net: tests: Add platforms whitelist to http header unit test
quark_d2000_crb does not build as ROM and RAM space are way too little
for it.

Change-Id: I1a5992dcd49f90fa6604cd8ab76db7e170be7cd4
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-01-02 10:03:20 +01:00
Flavio Santes
ac7300611c net: Restructure network protocols
This commit restructures the network protocols. Changes applied are:

- Move lib/iot/ to subsys/net/lib
- Move network protocol headers to include/net
- Move lib/iot/zoap/link-format.h to include/net/zoap_link_format.h
  and link-format.c to zoap_link_format.c
- Move tests/iot/ to tests/net/lib/
- Adapt sample code
- Adapt build system
- Modify doxygen paths

Change-Id: I37085fa4cc76a8a8e19a499ecb4e87b451120349
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-02 10:03:19 +01:00
Vinicius Costa Gomes
c538bb6602 tests/zoap: Add test for payload size
Add a test for the available space for the payload, so the problem with
the payload length doesn't regresses.

Change-Id: Ifef541d8428947eb482729aa773a7e9ddd2b6f81
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-01-02 10:03:19 +01:00
Tomasz Bursztyka
0a1617365f net: buf: Change NET_BUF_DEBUG to NET_BUF_LOG and add a level option
It will be thus possible to enable only the error logging, or the other
sys_log levels.

Change-Id: I0c0ed789f7cfbb4811320e8f8249151288274873
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-01-02 10:03:17 +01:00
Tomasz Bursztyka
56f25b49a9 tests: net: Fix format issues
Fixes:
error: format '%u' expects argument of type 'unsigned int'

Change-Id: I02aaaea79150967d7831d89d0c05427bf2685708
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-01-02 10:03:17 +01:00
Flavio Santes
a73a5bc41e tests/tcp: Initialize buffer to NULL
This commit initializes some net_buf variables to NULL to solve the
issue reported by Coverity: "Memory illegal accesses (UNINIT)".

Coverity-CID: 157610
Coverity-CID: 157611
Coverity-CID: 157612
Coverity-CID: 157617
Coverity-CID: 157619
Coverity-CID: 157620
Coverity-CID: 157622
Coverity-CID: 157624
Coverity-CID: 157626
Coverity-CID: 157627
Coverity-CID: 157628

Change-Id: I98a1ea5db4c169f69e3fa3d5de4c0ed7fdf1820a
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-16 19:14:53 +01:00
Anas Nashif
6ce672d753 net: remove unused variable pkt1
Change-Id: I987765a6020b7d5b5ff8fd1213dfc4b9a13cdf7f
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-15 14:33:02 +00:00
Anas Nashif
200c4031dd net: remove unused variable dis
Change-Id: Iec80bd13532b17d36fbe1b3d07f31b8f481859d9
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-15 14:32:52 +00:00
Tomasz Bursztyka
ca4ac62611 net: tests: Remove unused variables from dhcpv4 unit test
Fixes this:
error: ‘zero_addr’ defined but not used [-Werror=unused-const-variable=]
...

Change-Id: I5b0baf597e62f3206e15638a63e129503b76b048
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-15 14:34:16 +01:00
Johan Hedberg
d659bb020e net: buf: Remove redundant user_data_size from buffers
Since the user data size is now stored in the pool there's very little
value in storing it as well per-buffer.

Change-Id: I17a99123b232423c52a2179b4eccd813728d51b1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-15 09:58:17 +02:00
Johan Hedberg
71c7c01819 net: buf: Remove the need for net_buf_pool_init()
In order to keep the initialization process light-weight, remove
net_buf_pool_init() and instead perform the initialization of the pool
and buffers in a "lazy" manner. This means storing more information
in the pool, and removing any 'const' members from net_buf. Since
there are no more const members in net_buf the buffer array can be
declared with __noinit, which further reduces initialization overhead.

Change-Id: Ia126af101c2727c130651b697dcba99d159a1c76
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-15 09:58:02 +02:00
Johan Hedberg
45bc46d42e net: buf: Introduce net_buf_destroy() wrapper
This is only for use with custom destroy callbacks, so that the
application gets isolated away from the details of how exactly the
buffers are managed. This opens up the possibility of switching away
from k_fifo to potentially better solutions, such as k_lifo.

Change-Id: I0d8322fdec3500d8ae060ae471b9448aeaa4572a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-15 08:45:05 +02:00
Marcus Shawcroft
954baea90b random: Restructure RANDOM Kconfig
Restructure the RANDOM Kconfig to match the structure used in other
drivers with a single top level menu.  Move the true random number
generators to appear first in the menu, with pseudo generators at the
bottom.  Do not present pseudo generators if a true random generator
is presented.

This change implies that tests, samples and applications that require
the random driver interface must now select CONFIG_RANDOM_GENERATOR.

In order for tests and samples to build (and run) on platforms that
have no random driver it remains necessary to select
the CONFIG_TEST_RANDOM_GENERATOR.

Note that CONFIG_TEST_RANDOM_GENERATOR retains its original purpose of
enabling a random driver that delivers non random numbers for the
purpose of testing only.

Change-Id: I2e28e44b4adf800e64a885aefe36a52da8aa455a
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-12-13 22:50:18 +00:00
Johan Hedberg
c3e08c8fea net: buf: Redesigned pool & buffer allocation API
Until now it has been necessary to separately define a k_fifo and
an array of buffers when creating net_buf pools. This has been a bit
of an inconvenience as well as blurred the line of what exactly
constitutes the "pool".

This patch removes the NET_BUF_POOL() macro and replaces it with a
NET_BUF_POOL_DEFINE() macro that internally expands into the buffer
array and new net_buf_pool struct with a given name:

	NET_BUF_POOL_DEFINE(pool_name, ...);

Having a dedicated context struct for the pool has the added benefit
that we can start moving there net_buf members that have the same
value for all buffers from the same pool. The first such member that
gets moved is the destroy callback, thus shrinking net_buf by four
bytes. Another potential candidate is the user_data_size, however
right not that's left out since it would just leave 2 bytes of padding
in net_buf (i.e. not influence its size). Another common value is
buf->size, however that one is also used by net_buf_simple and can
therefore not be moved.

This patch also splits getting buffers from a FIFO and allocating a
new buffer from a pool into two separate APIs: net_buf_get and
net_buf_alloc, thus simplifying the APIs and their usage. There is no
separate 'reserve_head' parameter anymore when allocating, rather the
user is expected to call net_buf_reserve() afterwards if something
else than 0 headroom is desired.

Change-Id: Id91b1e5c2be2deb1274dde47f5edebfe29af383a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-13 21:41:53 +00:00
Anas Nashif
918740d15b tests: net: exclude quark_d2000_crb
Not enough memory on this device with 8K of SRAM

Change-Id: I359cce806098cac7e0e2a9e00ce40c91bc535c5b
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-05 16:44:46 +00:00
Jukka Rissanen
3eaec41ab8 net: Moved net/ to subsys/net
* Moved networking code into subsys/net.
* Renamed net/yaip to net/ip at the same time.
* Fixed the tests/net to compile
* Fixed the Makefiles and Kconfig files in subsys/net
  to use the new location of the IP stack

Change-Id: Ie45d9e8cb45a93fefdf969b20a81e3b1d3c16355
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:20 +02:00
Jukka Rissanen
368ef49331 tests: net: ipv6: Add test for neighbor advertisement
Check that we change the ll address in neighbor cache
properly when receiving NA.

Change-Id: Ib0373751abebdfe1c5e83fd38ec91b9587797e32
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:18 +02:00
Jukka Rissanen
e2a4432e85 tests: net: ipv6: Wrong IP address was added to cache
Peer address is used when sending NS so that it is added
properly to neighbor cache.

Change-Id: I51c2e236a0b137f7ab086a782f3baced13aa3ee3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:18 +02:00
Jukka Rissanen
bd9f9e7cde tests: net: ipv6: Fix prefix test
Also disable prefix lifetime overflow test as it does not work
properly.

Change-Id: I54c8716f6a6d4f5bec76b0a61fe0e18e983924f4
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:18 +02:00
Anas Nashif
47b27514a3 test: net: remove nano/micro tests
Change-Id: I57898f5d9f050a2301504a3df43feb2bd1e6d4fc
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-02 12:41:17 +02:00
Anas Nashif
3d97803c02 tests: net: remove qemu.pid file and bad filters
Change-Id: I26ef207fdebab674a89d54efeb3f4a1a3c4258f6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-02 12:41:17 +02:00
Jukka Rissanen
68ea9377e6 net: Make native IP stack the default
As the native IP stack is now the default, there is no need
for corresponding Kconfig option.

Change-Id: I08e4992f540f928a2b7378e8803e634e38725348
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:17 +02:00
Jukka Rissanen
6b43821f20 net: Remove legacy Contiki based uIP stack
This commit removes the legacy Contiki based uIP stack.
The new native IP stack must be used after this commit.

The commit also removes following things:
- legacy cc2520 driver
- legacy ethernet drivers
- legacy IP stack samples

and changes these things:
- disabled tests that only work for legacy IP stack
- select new IP stack by default
- enable random number generator by default as it is needed
  by the new IP stack

Change-Id: I1229f9960a4c6654e9ccc6dac14a7efb9394e45d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:17 +02:00
Ravi kumar Veeramally
72c71e8310 net: ieee802154: Add offset based reassembly feature
Current reassembly of 802.15.4 packets works only if fragments are
in correct order. But as per RFC 6282 reassembly should be based on
offset parameter in fragmentation header.

Change-Id: Icdcb10b9aa8f5837063b0201a64f8eb050c75681
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:41:11 +02:00
Jukka Rissanen
f4be98b4bb tests: net: Change the tag of network tests to net
There were different tags defined in testcase.ini files for
networking tests. Unify these and change the tag to "net"
in all networking tests. This makes it easy to execute
all network tests via sanitycheck.

Change-Id: I8ce7ccf8cccca35234602e37f6568db0b986d181
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:11 +02:00
Jukka Rissanen
d048b5c9d1 tests: buf: Do not depend on IP stack
The net_buf tests were including net_ip.h which requires some
extra config options to be usable when the new native IP stack
is used. In order to avoid this dependency, define struct in6_addr
locally in the source file.

Change-Id: Iafe0d2b5b507665baaed23f5e2c55a9d9a300d47
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:11 +02:00
Tomasz Bursztyka
a54d5607ad tests: ieee802154: Fix compilation error in fragment test
Which happens only when internal DEBUG is set to 1

Change-Id: I175943f32065ae81b1a4453dde40f36738c28084
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:09 +02:00
Leandro Pereira
6b9b9a6f75 net: tcp: Provide NET_TCP_FLAGS macro
Instead of having to write "NET_TCP_BUF(buf)->flags & NET_TCP_CTL"
every single time, provide a NET_TCP_FLAGS macro that expands to this
expression.

Change-Id: Ie876c538599fabae6b800a53613b6ad17dc45620
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:08 +02:00
Tomasz Bursztyka
85a8f8e6fa net: trickle: Using unified kernel API
Dropping legacy API. This commit also contains updated
unit tests in order to pass the test.

Change-Id: Ibc7426837e2f4f23bb5f3ed3719635c5c3d0ed0f
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:07 +02:00
Tomasz Bursztyka
06362ff5c6 tests: net: Using unified kernel API
Dropping legacy API.

Change-Id: Ife835e38fb03e909e89c3060771f42d1cfa12164
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:07 +02:00
Jukka Rissanen
1b58d970ca net: ipv6: Move unspecified address getter to ipv6.c
More logical place for net_ipv6_unspecified_address() is in ipv6.c
instead of net_if.c. Removing the net_if_ipv6_unspecified_addr()
variant as it is no longer needed.

Change-Id: Ib5b4f6748030a8bf50fb848a87eef2968e2bcbc8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:04 +02:00
Tomasz Bursztyka
b52f8f1fa1 tests: net: TCP Context needs to be listening before running accept
Change-Id: I433ddac41afcb055cd45e2e7fc4c26ed8c56e3c2
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:02 +02:00
Tomasz Bursztyka
64e7dc2caa tests: net: Unified kernel is now default and only one
Adapting all unit tests so:

- main task's prj.mdef is already provided by unified kernel with a
default stack of 2kb.
- unified is the only kernel to be used now, removing unecessary kernel
type make option.
- removing all NANOKERNEL/MICROKERNEL related #ifdefs and so on.

Change-Id: I9b853dbd2aef971d355188cbf7fe2ececaaa80c1
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:02 +02:00
Leandro Pereira
ad1a9d088d net: tcp: Add better type safety for connection handlers
This creates a `struct net_conn_handle` that's only used as an opaque
pointer.  The purpose is to avoid assigning a void* to a void** in
connection registering/unregistering functions, avoiding a
previously-caught bug by issuing an incompatible pointer types warning:

	warning: passing argument 7 of 'net_tcp_register' from
		incompatible pointer type [-Wincompatible-pointer-types]

Suggested by Andy Ross in 5beec6.  This particular commit didn't catch
any bugs, but the one caught in 5beec6 wouldn't exist if this were in
place at the time.

Change-Id: I5c13fb4c5826adce6397feb7b400d36e426c4a87
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:02 +02:00
Jukka Rissanen
c15b467d42 net: tests: Send IPv6 hop-by-hop option to IP stack
Added a test to send HBH option to IP stack. Currently
the test will always pass, activate some more debugging
to see what the IP stack is doing with the option.

Change-Id: Id0ab1590eb8216f5f67c4d43ce2e882186334198
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:01 +02:00
Jukka Rissanen
dffafbd290 net: tests: Unit tests for RPL
Change-Id: I5c2c4dd4eb8a8af77bd0d8db06b09a25871893b3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:00 +02:00
Jukka Rissanen
cac9d1b3cf net: Add support for embedding extra data to routing entries
This can be used to store routing protocol specific data
into neighbor entry. By default no extra data is allocated.

Change-Id: Iabff0a1df676398a47b86adbc398c4f566dcc40a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:58 +02:00
Jukka Rissanen
c38dd8870c tests: net: 6lo: Make sure no error in microkernel
Microkernel test for 6lo was giving error because the
prj.mdef file was refering to wrong function name.

Change-Id: I4197c509fb266a908eb03cc0bda34e39c66b229c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:57 +02:00
Tomasz Bursztyka
91c3f06e97 tests: net: Moving IEEE 802.15.4 fragmentation test in proper place
fragment is only about testing 15.4 6lo fragmentation, so let's put it
in dedicated tests/net/ieee802154/ directory.

Change-Id: Ib838600e571753ab976c74dac78ee774f628c2ab
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:56 +02:00
Tomasz Bursztyka
593fc81bf4 tests: net: Multiple test will go inside ieee802154
So reordering files in order to put more specific tests in it.

Change-Id: I000bc5efb8442d02e9a50e1b85cb45e0bec12789
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:56 +02:00
Tomasz Bursztyka
831bfcb048 net: ieee802154: Improve 6lo frag reassemble API
No reassembly logic is changed besides removing the final reassembled
pointer. Instead of requiring such pointer, let's just use the frag one.
Such changes will ease the usage of ieee802154_reassemble():
the given frag buffer, in case it finally got reassembled and thus
provided a NET_CONTINUE verdict, will directly be handled by net_core.

This makes things consistent as well with verdicts:
- in case of NET_OK, buf has been consumed and thus unrefed
- in case of NET_DROP, buf needs to be unrefed by caller
- in case of NET_CONTINUE, buf is updated with reassembled and
  decompressed data packet, up to net_core to handel it accordingly.

Change-Id: Ibd1588debd22a7f4571b36713dd46bf8b1d88329
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:56 +02:00
Tomasz Bursztyka
34988043a4 net: ieee802154: Reverse 6lo fragmentation verdict
As soon as fragment is put into the cache and as long as it is not
identified to be the last one: let's return NET_OK to notifiy the
fragment has been consumed by ieee802154 L2.

That way, net_core will not try to interpret it - and fail - unnecessary
increasing the drop statistics.

On the contrary, once the buffer is fully reassemble, let's return
NET_CONTINUE in order to let net_core consume the buffer relevantly.

Change-Id: I715b687e451f4643656e122b0d119f114696340b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:56 +02:00
Tomasz Bursztyka
2887bbf7fc tests: ieee802154: Make the test ready to handle multi fragments buffer
Buffer sent by 802.15.4 L2 might have more than one fragment, thus
handling it properly.

Change-Id: I12fef8a9c5de56615c3a084c57f438e71b320fcf
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:56 +02:00
Vinicius Costa Gomes
86b1ef7b7b tests/zoap: Fix extra unref on net_buf fragments
Since "22e919872206b1d net: Adapt to new behavior of net_buf_frag_add"
net_buf_frag_add() takes onwership of the fragment, so this _unref()
after a net_buf_frag_add() is wrong.

Change-Id: I1559c2978cf8d800891d6e752478537fbee7c02b
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:55 +02:00
Vinicius Costa Gomes
3aa352e622 tests/zoap: Port observer tests to the native stack
This enables the tests for the observer feature to be run using the
native IP stack.

Change-Id: I325dcd1f5d9fffe3821eed1bd950a717e5f17b67
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:55 +02:00
Ravi kumar Veeramally
78502f1804 net: tests: Update DHCPv4 test results based on events
Earlier test results was updated as soon as test server ACK client
dhcpv4 request. But update results on IPv4 address add event on
interface.

Change-Id: I212309a4d1d2eae88f73470e00754db1d6fecda5
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:54 +02:00
Marcus Shawcroft
f903cb3763 net: dhcpv4: Implement XID
RFC2131 requires that a client must choose XIDs in order to minimize
the chance of collision with another client.  Selection of a random
XID at boot is a valid approach. Adjust the XID representation from
array of bytes to the more convenient uint32_t representation,
initialize the XID to a random number and increment for each request.

Refactor the dhcp test case to generate response messages with the XID
from the received message.

Change-Id: I93f180e6aa02430f807e0a97186577dc956fb653
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-12-02 12:40:53 +02:00
Jukka Rissanen
7f4275ef52 iot/zoap: Temporarily disable block size transfer test
The test "Test block sized transfer" does not work with
new IP stack so disable it temporarily for new stack.
This needs to be fixed later.

Change-Id: Ie89dd101270ab9b8a9b056757de79cd3da009180
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:53 +02:00
Ravi kumar Veeramally
d3b21f0171 net: tests: Add unit tests for net_nbuf_write/insert utilites
Change-Id: I4df5672777af2c27511465b72ea17b7b5e0c8e8f
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:53 +02:00
Anas Nashif
e6bbc5003c net: do not depend on ARCH
Rename project configuration to be architecture independent and do not use ARCH
in Makefile.

Change-Id: Ic793751e3187bc74fd14cec929754d691b01a799
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-02 12:40:52 +02:00
Jukka Rissanen
1c3c26a1f9 net: tests: Add TCP unit tests
This provides only initial set of functionality tests
for TCP. More tests are to be written.

Change-Id: I157fed85f561523bf063732ce86eaae551c2d384
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:52 +02:00
Ravi kumar Veeramally
c689fd6f1a net: Rename net_nbuf_write to net_nbuf_append
Current net_nbuf_write() api just appends data to last fragment. And
doesn't write data based on offset. That's why renaming this api.

New net_nbuf_write() apis based on offset will be coming soon.

Change-Id: Ie8e13e5f6091a279b62b6d8b0b3928a5187e75b0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:51 +02:00
Vinicius Costa Gomes
dc45748d50 iot/zoap: Port to the native stack
This ports zoap to the native stack.

Just for reference, and totally not scientific, here are the numbers
using the old stack:

$ size outdir/qemu_x86/zephyr.elf
   text	   data	    bss	    dec	    hex	filename
  34657	  10316	  16916	  61889	   f1c1	outdir/qemu_x86/zephyr.elf

With yaip:

$ size outdir/qemu_x86/zephyr.elf
   text	   data	    bss	    dec	    hex	filename
  30575	   9148	   6164	  45887	   b33f	outdir/qemu_x86/zephyr.elf

Jira: ZEP-818

Change-Id: I7992a3e2af7d419081ee5a64d7cc2d49fb628ead
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:50 +02:00
Ravi kumar Veeramally
ead511ddae net: Fix net_nbuf_read corner cases
Valid case:
 1) If the offset is more than current fragment length, adjusts offset
    from next relevant fragment and starts reading or skipping.
 2) If the read or skip length is more than available data length,
    then throw an error.

In case of an error, frag is 'NULL' pos is '0xffff'. Rest of the cases
are successful read and skip.

Change-Id: I88c4b85e14e5821f681966b5148ba9519b91cca4
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:49 +02:00
Ravi kumar Veeramally
712f0c90db net: tests: Add 6lo context based unit tests
Change-Id: I73e18d830d1dcd4f5181b0de74cb7818086504a3
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:48 +02:00
Ravi kumar Veeramally
e68625345a net: Add support for 6lo context based compression
RFC 6282, 3.1.1 (If SAC == 1 and M = 0, DAC = 1).
Source and Destination address compression support if addresses are
based on context based information from Router Advertisement message.

Change-Id: I23a3bf4f111016a8e54be5f0181a113353ad4b88
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:48 +02:00
Ravi kumar Veeramally
e8f40a970a net: tests: Add sample 6CO context data to IPv6 RA test
Test is only for parsing 6CO data. Nothing more than that.

Change-Id: I7e5851f389216473379a9e50b83dfb03fbe1e68e
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:48 +02:00
Vinicius Costa Gomes
42c3969ad8 tests/net/nbuf: Fix invalid memory access
The memcmp() could reach after the buffer that is used for verification
ends, which was causing this test to fail on the qemu_cortex_m3 board.

Change-Id: Ia05df823f201d9017acb35c7634fa506389ae9f1
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:48 +02:00
Vinicius Costa Gomes
61bb244ab1 tests/net/nbuf: Fix wrong size to linearize() call
linearize() expects the amount of room available in the buffer.

Change-Id: I1062912f76951758177b7dd6588e7e0ae280dc03
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:48 +02:00
Vinicius Costa Gomes
f2236bb2d7 tests/net: Exclude tests needing more RAM than available
Quark D2000 doesn't not have enough RAM for these tests.

Change-Id: Iba79eaadb15eb8f1eae4bfdbc6865985d3da3fd3
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:48 +02:00
Ravi kumar Veeramally
918703cba3 net: tests: Decrease the required buffers count
Buffer leaks are fixed in 6lowpan compression and ieee802154
fragmentation. So lower the count in tests.

Change-Id: Ic9581f898156fedc20a3e445be8b7a466ee15d99
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:47 +02:00
Tomasz Bursztyka
08b748432b tests: Add network core event tests
A fake network device and interface are setup. Test implies add and
removing an IPv6 address which should trigger the related notification.

Change-Id: I6035cfbfaf80c8f4352b5d31b47ca1445434d926
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:47 +02:00
Tomasz Bursztyka
af703e1106 net: Normalizing net_mgmt API names
While doing some documentation for it, I realized names were not all
good and it missed some stuff:

- what belongs to event should contain "event" in it
- we have a structur as callback so let's type the handler as a handler
- let's add the request handler signature

Change-Id: I18822cbcdc3c10e33600d6db38abab5ca73a228c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:46 +02:00
Flavio Santes
7e7f72b104 net: Fix tests/net/nbuf/Makefile
Use ?= for the CONF_FILE variable to match the default assignement for
BOARD ?= qemu_x86.

Change-Id: I0b6cf1e967eeb437d99aa7286cf560426d48fbf9
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:40:46 +02:00
Tomasz Bursztyka
8b1953f740 tests: net: Add net management event sender/receiver tests
It mimics how event could be thrown through a dedicated thrower (a
fiber). The amount and event it can throw is gived through parameters.

Change-Id: I484bc72bdb730a77ce976b0b2998411d9918b7fc
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:46 +02:00
Tomasz Bursztyka
ec1d2c5a48 tests: net: Add a basic network management API test
Testing if net_mng() works.

Change-Id: I303cffa206859184a503ba8efe392b673b162e43
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:45 +02:00
Ravi kumar Veeramally
1ce3550779 net: tests: Add RA message unit tests.
Basic unit tests for Router Advertisement message handler.

Change-Id: Ia99cd160632972a12e2099a3ff6e41e6ea48ff9b
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:45 +02:00
Jukka Rissanen
d8cb2fb161 net: Make sure buf is correct one in net_nbuf_write()
The buf parameter cannot point to a data fragment in
net_nbuf_write() because we need to use user data inside
that function and the fragments do not have that information.

Change-Id: I45b9c23869df08a0852bd99c0b453210ad2300b5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:45 +02:00
Ravi kumar Veeramally
913c1f29ca net: Add unit tests for new nbuf API's
Tests for net_nbuf_read, net_nbuf_write and net_nbuf_skip API's.

Change-Id: I77f702dda8c9df7892120f47ff03a6b256191d31
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:28 +02:00
Jukka Rissanen
338c2be888 net: tests: Add initial set of IPv6 tests
Change-Id: Ib68b38a809068ca14ee9307e9ea605f03611ebd3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:28 +02:00
Jukka Rissanen
fb9af2523d net: tests: Increase the timeout of trickle tests
One second timeout seems to be too short as some test runs
fail when run in Jenkins.

Change-Id: Ifb01929148415961712468e3cc85387aac5eb2bb
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:28 +02:00
Jukka Rissanen
66d3601dd5 net: tests: Add tests for route management API
Change-Id: Ic2f8d2d270f63baa0a16ae76f248485bc00eef08
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:27 +02:00
Tomasz Bursztyka
640d524f69 net: tests: Add a simple IEEE 802.15.4 Beacon frame test
It's an empty beacon frame, juste to validate the Beacon frame parsing
logic.

Change-Id: I90916eb87187c9eae9b2267f34dc93bee554d4b5
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:26 +02:00
Ravi kumar Veeramally
2a9d75ac1c net: tests: Add DHCPv4 client unit tests
Change-Id: Ief15927975bb0398c39c656068ec8c73c4f62e82
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:26 +02:00
Ravi kumar Veeramally
846201d049 net: tests: Remove broadcast and multicast tests from ARP
If ethernet address is broadcast or multicast, l2 layer does not
send any ARP messages. Handle this scenario in ethernet tests.

Change-Id: I8e11832803e1539887152447090d1286c7fa3eb0
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:26 +02:00
Jukka Rissanen
c427e9bbd6 net: Context accept cb needs to return failure code
If the connection establishment has an error, the accept
callback needs to be able to return that error to user space
so that the application can know about it.
This is especially important in TCP where application needs
to start to listen again if reset is sent during connection
establishment.

Change-Id: I55f36e4f101c7237c1288f09baf6e602b33da2b3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:25 +02:00
Jukka Rissanen
84ffca2eb1 net: tests: Add unit test for net_nbuf_pull functionality
Change-Id: I929f7c6eed21aca0f92975b96380a91e5e50587f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:25 +02:00
Jukka Rissanen
96e629c877 net: Fix remaining debug option naming issues
Some of the DEBUG options for the new IP stack still used
the CONFIG_NETWORK_IP_STACK_DEBUG_ prefix.

Change-Id: I8f039ac5e303a7c571a870403ce17d758db540d5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:25 +02:00
Tomasz Bursztyka
becf74743b net: Split debug Kconfig options from legacy to new stack
- new stack options are renamed and placed in their respective menus
- new stack Kconfig gets normalized (tabs vs spaces, etc...)

Change-Id: Ia68f6589fed464bbdd76dc0812775684b2f94a58
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:24 +02:00
Jukka Rissanen
58a7ada44c net: Add network address length to user API
Add socklen_t addrlen parameter to net_context_bind(),
net_context_sendto() and accept callback.

Currently the address length option is not really mandatory
as we can figure out the length from the address family.
But if we are going to support other protocol address families
it might be needed.

Change-Id: I59206465c3259050c469c5b2150221646a9a08d7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:24 +02:00
Jukka Rissanen
103a98d173 net: tests: Fix printf modifiers in new IP stack unit tests
Because of printk fixes in master, some of the networking
unit tests will fail in next merge.

Change-Id: I3e28aae72c0c10b402b78c0f406ecb3513b967a7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:23 +02:00
Ravi kumar Veeramally
0d76826a0d net: tests: Extented 6lo unit tests
Earlier all unit tests are with IPv6 and UDP as next header.
Modified tests with IPv6 only, IPv6 + UDP and IPv6 + IPHC next
headers.

Change-Id: Ie02cecb37e07ceae8a06a0653e2ccdfe0db91239
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:23 +02:00
Jukka Rissanen
2eb01fe191 net: tests: Enable unit tests for the new IP stack
We are not just checking the test build but this time
the tests are also run.

Change-Id: I7b0b24c51dfc2dc58f290cca7a593be431b8077f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:22 +02:00
Tomasz Bursztyka
9c62543f62 net: Follow file naming in ieee802154 l2 stack
For consistency as well as for helping when grepping etc.

Change-Id: Ib5e6b3369e510dd2b996f735d801c2b80291ad7f
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:21 +02:00
Jukka Rissanen
c03028f1f1 net: tests: Test Trickle algorithm
This is only meant for the new IP stack.

Change-Id: I643b0556f87423f09555274749db93397ef66c59
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:21 +02:00
Ravi kumar Veeramally
ae1ce83dd1 net: tests: Add fragmentation unit tests for 802.15.4
Change-Id: I5722f86c00c76921e94f6f2a8e9add8960498107
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:21 +02:00
Ravi kumar Veeramally
fe4a4efe78 net: Add support for IEEE 802.15.4 re-assembly
Reassembly IEEE 802.15.4 fragments as per it's datagram size
and datagram tag. Uncompress IP header fragment as soon as it
arrives. Size matches only after uncompression of IP header with
total length.

Support added for multiple IP packet reception. Default is one full
IP packet at a time. Cache size can be modified via Kconfig option
(NET_L2_IEEE802154_FRAGMENT_REASS_CACHE_SIZE).

Note: If you increase the size by 1 means, you should have N number
of data buffers available at max.
e.g. One full IP packet (1280 MTU) needs 15~16 data fragments means,
multiply size by same number of fragments. It requires more memory.

Offset based reassembly yet to be done (fragments can come in any order
[e.g. mesh]). Now assuming that fragments are in right order.

Change-Id: I17baee30a1087eb9ec6dc25f03ed64bbe0df2917
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:21 +02:00
Ravi kumar Veeramally
dc36bdb89d net: Integrate 6lo and 802.15.4 fragmentation
Change-Id: I348656e0049d79f4dfdaba7909ad0b770f3ee922
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:21 +02:00
Ravi kumar Veeramally
8743ac7ec8 net: tests: Add unit tests for 6lo IPv6 dispatch
Change-Id: I962b1f94b6b2ba6ef2429ef0deca3ee5352df3d8
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:20 +02:00
Ravi kumar Veeramally
1725ac66d7 net: Add 6lowpan without compression header support
Add support for IPv6 header dispatch (without IPv6 compression
and uncompression). Only IPv6 dispatch header will be added at the
beginning of the buffer.

Change-Id: I7400a4dd115ac3b4b3d9deecd3cdb9ea292573fb
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:20 +02:00
Ravi kumar Veeramally
9217b68f3c net: Change 6lo API returned parameter
6lowpan compression and uncompression done on original
input buffer. So no need to return paramter as net_buf *.
If the compression or uncompression fails, unref the buffer
as it cannot be used further.

Change-Id: I64f496e22b2008a91a358fff65de1b87659cd9eb
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:20 +02:00
Ravi kumar Veeramally
142ca7f01e net: tests: Fix 6lo tests
UDP length was wrongly set and test count was hardcoded.

Change-Id: Iade959e1b8c3580b43aa2a9ff1fc10eb5a462f2f
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:20 +02:00
Tomasz Bursztyka
4e7efd4bcb tests: net: Add a IEEE 802.15.4 ACK replies test
- Parsing a proper ACK reply
- Generating a ACK reply from a data packet requesting it, and comparing
  it to a proper one.

Change-Id: I1717fedc899eafa0aa849e1e253f02cd3dc3d4fc
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:18 +02:00
Tomasz Bursztyka
11c9b8dac7 tests: Add grounds for IEEE 802.15.4 stack tests.
First test is a unit test for frame parsing

Change-Id: I080d64a71fe4b6ff00e071a0cdee97ab9cd922d5
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:18 +02:00
Tomasz Bursztyka
3560f58293 net: L2 might need private data per-interface
Allocate the right amount of space for L2's context.

Change-Id: Ia2f4f4162334e9e9c26dc95230abdfde5986e052
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:18 +02:00
Jukka Rissanen
04a65534e1 net: Change srctree to ZEPHYR_BASE in Makefiles
This is related to changes in commit 7dcbbc39e7
("build: move from srctree to ZEPHYR_BASE for app include paths")

Change-Id: Ie902ed66bb74188ed54aae44e2f4289f954ec351
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:17 +02:00
Jukka Rissanen
498f9e04de net: tests: Unit tests for user space socket API
Change-Id: Ifd149e4f4313abde4cead135f7533f26dec6bdf7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
9331b2bc7b net: Add net_conn pointer to callback
When a UDP packet has been received and if a watcher match
is found, then a callback is called. It is useful to have
a pointer to net_conn when calling the callback.

Change-Id: Ifa97b37c22b1fc9cac7eadfba23aa68dfd473fda
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
1932d4c3ec net: Convert network connection to use sockaddr
As the net_conn needs port information, use struct sockaddr
internally as it has the port numbers built in.

Change-Id: Idb1c87afa956dfe55dc8d533d867fa7845545b12
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:15 +02:00
Jukka Rissanen
f88da0fa36 net: tests: UDP unit test had incorrect ll address length
Change-Id: Ie3231c6fda2faf49f4767a78250b923bedb2d293
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:14 +02:00
Jukka Rissanen
432f3b3914 net: tests: udp: Print debug info only when activated
No need to print debug prints if debugging is not activated.

Change-Id: I42a6453b4f3e11106119561b580ebea41e56452d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:14 +02:00
Jukka Rissanen
2658ac7a73 net: IP address lookup functions return interface
When checking the IP address from network interface, return
also the used network interface.

Change-Id: If7b8385193da4cb1b469f697e219cfae3b6477dd
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:14 +02:00
Tomasz Bursztyka
a1fde2bff8 net: Fix dedicated IPv4 function for net_if
IPv4/6 functions follows this scheme: net_if_ipv<4/6>_<name>.
Applying that to net_if_set_gw/net_if_set_netmask which are IPv4
functions.

Change-Id: I2dcbb16ce81cfdffbfbb5cae24ad76ddf2b9919a
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:14 +02:00
Ravi kumar Veeramally
c1ee601962 net: tests: Add unit tests for 6lowpan functionality
Change-Id: Ie13a05300e05fdc536fcb4ec64e323789704ba8b
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:14 +02:00
Tomasz Bursztyka
97daa51c80 net: Cleanup net_if's documentation
Change-Id: Idd139ee5f56c8b55119db69582393fe2906eae74
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:13 +02:00
Tomasz Bursztyka
b8e3415264 net: Let's use inline function for type checking for net_nbuf
Using macros does not let the compiler verifying about the type we are
providing, which usually give an error easier to understand.
Also, this will let the compiler deciding how to actually optimize
(inline or not) the code.

Change-Id: Iba49590b620ef0a1bd0ed5621453524fcfea747c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:13 +02:00
Jukka Rissanen
55dcaf9e22 net: tests: Fix project file for IP address tests
Disable IPv6 DAD and ND for IP address test as there is
no need to do neighbor discovery in the test. We also
would like to see network interface debugging and use
dummy L2 driver instead of ethernet one.

Change-Id: Ia9f218c8d4c13afa1482302691d2ef72af4a7b13
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:13 +02:00
Jukka Rissanen
894e42d025 net: tests: Fix IP address test so that it will not crash
The driver_api pointer was set to NULL and send() pointer
was missing which caused a crash in TX fiber.

Change-Id: I7204c975691476dd9ab2c61bfd11b7664343e47c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:13 +02:00
Jukka Rissanen
fe16af1e06 net: tests: ICMPv6 was missing random number config
Change-Id: Ibcfa6662f30727a31cc2fa371e8a3ec3923db3cd
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:12 +02:00
Jukka Rissanen
b9b1dec6a3 net: tests: Turning off IPv6 for ARP tests
ARP is IPv4 only so no need to have IPv6 functionality.

Change-Id: Ie70242f5763ba4945c311898643414851f7e8660
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:12 +02:00
Jukka Rissanen
f42c8126eb net: tests: Unit tests for net_nbuf_push()
These tests will verify that we can successfully insert
some space in front of the net_buf fragment chain.

Change-Id: Idf52ed56c52d66268783fb4fecd44b70fc852734
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:12 +02:00
Jukka Rissanen
a1a17d5a98 net: tests: Fix ARP test so that it will not crash
The driver_api pointer was set to NULL which will cause
a crash in TX fiber.

Change-Id: If1c9a1e44904970f3a0019741eaaad4bf62d2c73
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:12 +02:00
Jukka Rissanen
87fd856041 net: tests: Unit tests for UDP handler
Simple UDP protocol testing.

Change-Id: I3ee37ff93127245a80fdf31856a95d9efc403862
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:12 +02:00
Jukka Rissanen
f923adb038 net: tests: Add unit tests for net_nbuf_copy()
The tests will make sure net_nbuf_copy() works as expected.

Change-Id: I48dc3b794c70ec4d6436feb76508952c88bbf09b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:11 +02:00
Jukka Rissanen
9818cc7b1d net: ARP unit test needs to be run from fiber
The ARP unit test is not able to pass packets between fiber
and task. Because of this the test is run from fiber.

Change-Id: I1825a0abdc1b04a78de76d58425f4d2a2ce26ab7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:10 +02:00
Jukka Rissanen
53caa13652 net: Refactored ARP packet header handling
The ARP packet header contained ethernet header. This is very
confusing so separate the link layer header. Fixed also the
unit tests to run properly.

Change-Id: I8b00bde280ad9f49494766370acb2a8e9cade033
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:10 +02:00
Jukka Rissanen
e04639cb66 net: tests: Fix unit test for IP utils
Change-Id: I7e14ec17656fdcc985000dba6fb67e90a053dfde
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:08 +02:00
Jukka Rissanen
21a491c065 net: tests: Fix unit test for IP addresses
Change-Id: Ia0b3b2846078a18b9b342c3aa99ea201d06d1642
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:08 +02:00
Jukka Rissanen
f1532fe647 net: tests: Fix unit test for ARP
Change-Id: I962c00500c57f0f49314d10765b821976679e39b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:08 +02:00
Jukka Rissanen
4695e53391 net: tests: Add unit tests for neighbor cache handling
Change-Id: I1518c102232a607a9c0f91bf5fd71e4b3183a419
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:07 +02:00
Jukka Rissanen
feaef3626e net: tests: Additional tests for ICMPv4 checksum verification
Change-Id: I21566c9365b8abc5753f6bedba55a3fb494745b9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:05 +02:00
Jukka Rissanen
f6dc86c678 net: tests: Fixed the ARP test
Now uses net_nbuf_ll() to point to link layer header.
Also the ARP req test passes properly.

Change-Id: If649ff19a064490bff33d03b4ce70ef11bfa7cd5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:05 +02:00
Jukka Rissanen
7eff526e3b net: tests: Unit tests for the IPv4 ARP code
Change-Id: I607ffdbffc7348fae70272c7add57456fcaf79af
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:04 +02:00
Jukka Rissanen
6e3c12a820 net: tests: Add tests for IPv4 netmask, gateway and subnet compare
Unit tests added for checking network interface netmask, gateway
and IPv4 subnet compare utility functions.

Change-Id: I5b4a07d6a064097ab41ad6552d14181b1631eb53
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:04 +02:00
Jukka Rissanen
1bf6a529a1 net: tests: Tweak the IP address test to use new net_if API
Instead of using hard coded net_if, get the default network
interface using net_if_get_default() function.

Change-Id: I6248555ce57ae5196adea7baa9db325660a71255
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:04 +02:00
Jukka Rissanen
5580cdcc54 net: Add unit tests for ICMPv6 handler
Change-Id: Ibdbe82ed56f110e2e0c6443700863632ee1ef56b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:03 +02:00
Jukka Rissanen
4445e53f1e net: tests: Unit tests for network utilities
Right now there are tests for IP packet checksum calculation.

Change-Id: I1e9e72d01d4690728269c4484f8628350cf95729
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:03 +02:00
Jukka Rissanen
e467c009e5 net: tests: Add more IPv6 address getters unit tests
Change-Id: I0ab22af76073c02c93eb205686472f69b58a1107
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:02 +02:00
Jukka Rissanen
7851aecc1c net: tests: Add IPv4 address unit tests
These tests will check that caller is able to set IPv4 address
to a network interface and check if an address is one of the
assigned to a network interface.

Change-Id: I8aa748c40fbc02eef50ccf76d10a0057ef29021b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:02 +02:00
Jukka Rissanen
c3deb96dd7 net: tests: Add IPv6 address manipulation unit tests
Change-Id: Ide3bce35dcfd3ec31bfe3cd842a87ca3b639ba4f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:02 +02:00
Jukka Rissanen
2ade6ddb60 net: tests: Add unit test for IP and MAC address printing
Change-Id: Ida0901fa9687814932119d006459de12e6a229d5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:02 +02:00
Jukka Rissanen
9821cb6eb4 net: tests: Temporarily remove nbuf unit test
Tests have issues right now so these will be activated later.

Change-Id: Ib5549f9ed5600a20b2cfddbddcde8e7f7b297eef
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:01 +02:00
Jukka Rissanen
69b8c675a6 net: Add nbuf buffer API
User should use the net_nbuf API that is supporting a concept
of RX, TX and DATA buffers, instead of using directly the net_buf
low level API.

Change-Id: I3b8f5f13cd37d42d2322a58b35573e117d520c54
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:00 +02:00
Anas Nashif
e5b157bc1e net: buf: move test to unified kernel
Change-Id: I6757d32c8e9c713b73f160d46d4fbe4111ac73c1
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-11-28 20:17:23 +00:00
Szymon Janc
2f45faba8c net: buf: Use unified k_fifo API for FIFOs
Only net_receive() is using non-special value for net_buf_get_timeout
so this change is included here. Other users are using special values
which are already correctly handling ticks vs ms change.

Change-Id: Ib12d34ac5a546b36fa7b35615f082c82a256bd07
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-11-11 06:00:17 +00:00
Anas Nashif
d622b09bc0 samples: tests: remove obsolete KERNEL_TYPE and kernel variables
Remove those from Makefiles and testcase.ini, we now support unified kernel
only and sanitycheck script now knows how to deal with this.

Change-Id: I853ebcadfa7b56a4de5737d95f2ba096babb2e13
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-11-04 15:47:25 -04:00
Kumar Gala
6f6632ddc5 tests: Mark a bunch of testcases that are memory (RAM) limited
These testcases can't build on common platforms with 16K or less of
memory.

Change-Id: Iade2aa423f42a1f174a5ebb5d183b362917f503e
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2016-11-03 19:20:19 +00:00
Kumar Gala
bfcf575cbb tests: exclude quark_d2000_crb from net/buf test
Currently the net/buf test fails on quark_d2000_crb due to RAM
overflow:
	region `RAM' overflowed by 2256 bytes

Change-Id: I854960a3c22c7318f5f5e9341ca7aaaf8743d30d
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2016-11-01 15:03:04 +00:00
Johan Hedberg
ee0412a7d1 net: tests: Fix net_buf_unref() tests for fragment chains
The net_buf_unref() API will unref all associated fragments, so it's
wrong to assume that no fragment destroy callbacks would be called
when the head buf is unreffed. Instead the right expectation is that
all fragments get unrefed as well.

Change-Id: I00530e4c1cfa5dddbfcbeab9609347873010ff4d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-10-31 23:53:40 +00:00
Anas Nashif
a32579749b ztest: move ztest to unified kernel
ztest was not working with unified kernel and v1 APIs and not many tests are
using ztest right now, so instead of making it work with old APIs, convert it
to unified kernel completely so that new tests written using ztest would be
unified kenrel based.

Change-Id: Ibfcc7783dcb266abbd388662ba61c4b55d32b10c
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-10-31 21:38:04 +00:00
Vinicius Costa Gomes
cc9da10aab iot/zoap: Add unit tests for block-wise transfers
Change-Id: Ie529d2989481a6be674632dc256fb3995a9953c3
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-10-25 12:56:51 +00:00
Vinicius Costa Gomes
08e0e86bb0 tests/zoap: Add tests for the observe feature
Change-Id: I993437169715ce57f6c5c9f3e95689f785db65c4
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-10-01 01:11:26 +00:00
Jaakko Hannikainen
6f8e7b33b1 tests: convert tests/net/buf to the new framework
This is a sample how to use the framework in an integration test
environment.

Change-Id: I01619fce06759ed523c8c878e8bbda6d8d87d604
Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-09-30 21:17:41 +00:00
Vinicius Costa Gomes
47e8893654 tests/zoap: Add simple test for retransmission
Change-Id: I3a552f10e02e3880bbeb00b31f31c31414c6f163
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-09-22 00:54:36 +00:00
Vinicius Costa Gomes
3a53a73d8f tests: Add simple CoAP tests
Change-Id: I3d7b11ac5a623eab8e07d484b60c24c8a9a824f1
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-09-12 12:25:24 +00:00
Andrew Boie
d89ddc6441 tests: net: fix incorrect printk() usage
Change-Id: Iee5b94c24e1cce1f3a0e607deee2c5bc73e22d7b
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-28 07:47:28 -04:00
Inaky Perez-Gonzalez
3e63a74514 net/yaip: revert merge
Follow up to TSC decission for further discussion in the networking
WIG.

Change-Id: I148b484dfe308661573e47ed3e60cceed673bddf
Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
2016-07-22 04:43:09 +00:00
Jukka Rissanen
19dc87ea7d net: tests: Additional tests for ICMPv4 checksum verification
Change-Id: I21566c9365b8abc5753f6bedba55a3fb494745b9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-13 14:06:12 +00:00
Jukka Rissanen
99fd48acdd net: tests: Fixed the ARP test
Now uses net_nbuf_ll() to point to link layer header.
Also the ARP req test passes properly.

Change-Id: If649ff19a064490bff33d03b4ce70ef11bfa7cd5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-13 14:06:11 +00:00
Jukka Rissanen
a5b96021a7 net: tests: Unit tests for IPv4 ARP code
Change-Id: I607ffdbffc7348fae70272c7add57456fcaf79af
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-13 14:06:08 +00:00
Jukka Rissanen
9924b41297 net: tests: Add tests for IPv4 netmask, gw and subnet compare
Unit tests added for checking network interface netmask, gateway
and IPv4 subnet compare utility functions.

Change-Id: I5b4a07d6a064097ab41ad6552d14181b1631eb53
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-13 14:06:07 +00:00
Jukka Rissanen
dd42617b2f net: tests: Tweak the IP address test to use new net_if API
Instead of using hard coded net_if, get the default network
interface using net_if_get_default() function.

Change-Id: I6248555ce57ae5196adea7baa9db325660a71255
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-13 14:06:04 +00:00
Jukka Rissanen
663ba2b7f0 net: yaip: Add unit tests for ICMPv6 handler
Change-Id: Ibdbe82ed56f110e2e0c6443700863632ee1ef56b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:56 +00:00
Jukka Rissanen
441a054a07 net: tests: Unit tests for network utilities
Right now there are tests for IP packet checksum calculation.

Change-Id: I1e9e72d01d4690728269c4484f8628350cf95729
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:55 +00:00
Jukka Rissanen
cedd655cdb net: tests: Add more IPv6 address getters unit tests
Change-Id: I0ab22af76073c02c93eb205686472f69b58a1107
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:49 +00:00
Jukka Rissanen
03294c3f75 net: tests: Add IPv4 address unit tests
These tests will check that caller is able to set IPv4 address
to a network interface and check if an address is one of the
assigned to a network interface.

Change-Id: I8aa748c40fbc02eef50ccf76d10a0057ef29021b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:48 +00:00
Jukka Rissanen
eb87a36e44 net: tests: Add IPv6 address manipulation unit tests
Change-Id: Ide3bce35dcfd3ec31bfe3cd842a87ca3b639ba4f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:47 +00:00
Jukka Rissanen
cf673cf585 net: tests: Add unit test for IP and MAC address printing
Change-Id: Ida0901fa9687814932119d006459de12e6a229d5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 19:20:45 +00:00
Jukka Rissanen
2d7d86bdde net: tests: Temporarily remove nbuf unit test
Tests have issues right now so these will be activated later.

Change-Id: Ib5549f9ed5600a20b2cfddbddcde8e7f7b297eef
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 11:23:04 +00:00
Jukka Rissanen
b7bc53ece9 net: yaip: Add nbuf buffer API
User should use the net_nbuf API that is supporting a concept
of RX, TX and DATA buffers, instead of using directly the net_buf
low level API.

Change-Id: I3b8f5f13cd37d42d2322a58b35573e117d520c54
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-12 07:22:24 +00:00
Jukka Rissanen
95f5cd2b9a net: buf: Add tests for net_buf fragmentation
More realistic IPv6 packet creation tests created.
One test creates one big IPv6 packet and manipulates that.
Second test creates a list of IPv6 header + data fragments
and sets some user data in those fragment buffers.

Change-Id: Ic8309ff115e1d735e98c30b3c8292b0d6ffc5f42
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-11 18:06:11 +00:00
Jukka Rissanen
7d6197cf94 net: buf: Add fragmentation API tests
Add tests for checking that the net_buf fragmentation works ok.

Change-Id: I778f79bae971314b6f19c1bf00ed42e1c2128e99
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-07-11 18:05:41 +00:00
Johan Hedberg
c78a5a9aae net: tests: Clean up logging of net_buf tests
Change-Id: I8f82c586c730691c72f8996a25843ba786c73fe6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-09 10:26:38 +03:00
Johan Hedberg
bab34ea49c net: tests: Add task-fiber test for net_buf_get/put
Change-Id: I48c050254fca913c59bfbfd9a160c7d6ca79d53b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-09 10:26:38 +03:00
Johan Hedberg
6d93cbb627 net: tests: Refactor net_buf tests for easier extensibility
Change-Id: I23380b1c78b5a9c8814c037a2d48b3505c99f6ea
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-06 11:22:23 +03:00
Johan Hedberg
7029d6ed62 net: tests: Remove unnecessary microkernel ifdef for mainloop
Change-Id: Ifbf41aeece7f889eb8f4e836c59df5e830882942
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-06 11:22:23 +03:00
Johan Hedberg
8919bdc573 net: tests: Update net_buf test
Add testing for fragmented buffers to the net_buf test.

Change-Id: Id6c541b86c30ac94931a7086ebb6f1312fbc34f7
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-06 08:17:24 +03:00
Johan Hedberg
118a36fc26 net: tests: Fix returning net_buf to free pool
When using a custom destroy callback it's the responsibility of the
callback of placing the buffer back in the free pool.

Change-Id: I5ff99c32bcb31ccc5eb0fad544d86b0c830e7051
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-05 19:28:54 +03:00
Johan Hedberg
e8620aaada Bluetooth: Take advantage of net_buf_get_timeout()
Use the more explicit net_buf_get_timeout() call where it makes sense
(e.g. where we always want to wait or never want to wait).

Change-Id: Id1eabe0ad2f9fa79f7be39e51fefa5161f9cc550
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-06-02 10:32:29 +00:00
Anas Nashif
60b18711f3 tests: remove duplicate kernel configs and usage of ARCH
Many test configs are the same, remove complexity and duplication by
using just one kernel config where applicable.

This removes the usage of ARCH which is a remnant from the days where
we had to specify the architecture of the board, the architecture is now
part of Kconfig and determined basded on the board configuration.

This will also make it easy adding new architectures to test cases without
having to add an architecture specific config file when it is actually not
needed, for example now that we will enable micro-kernel support on ARC.

Jira: ZEP-238
Change-Id: I143fa3c4629c58329cfeb0c761c7a896fc1ef63a
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-05-23 16:46:08 +00:00
Andrew Boie
3ea7892410 sanitycheck: allow for more expressive filtering in testcase.ini
The old 'config_whitelist' directive in testcase.ini has been removed.
We use the new expr_parser module to parse a 'filter' directive which
is a boolean expression. This gives a great deal more flexibility
in how tests can be filtered.

To keep the tree bisectable, use of config_whitelist in testcase.ini
converted to the new expression language.

Change-Id: I0617319818c5559c0f0569d2fa73d09b681cac51
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-05-04 22:57:39 +00:00
Anas Nashif
74df249dd8 move net/buf test under tests/
This test should be under tests and is not a sample.

Change-Id: Ibb42207f72554516a650625a2cf4cc9cb7a0b021
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-11 13:08:44 -05:00