Commit graph

880 commits

Author SHA1 Message Date
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