Commit graph

41120 commits

Author SHA1 Message Date
Leandro Pereira
7c0e3f9580 net: tcp: Send a FIN|ACK when transitioning from ESTABLISHED->LAST_ACK
This sends FIN|ACK in one single segment instead of two while closing
a connection.

Change-Id: I80ff3da74deab2caffb69777438a0d13f75b4b32
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:13 +02:00
Leandro Pereira
99e4aa5dd4 net: Fix compile warnings when building with UDP disabled
The sanity checker should check for these as well eventually.

Change-Id: Ia22c8d0e000ee315ee2f582caa5a6b0c721e8b5f
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:13 +02:00
Tomasz Bursztyka
d02a9692ff wpan_serial: Minimize debug output by default and set proper nbuf size
Nbuf data size needs to be set to 128 bytes, specifically for wpan
sample.

Debug output kills timing, and thus can generate spurious failures on
reception, so limiting it to errors by default.

Change-Id: Ia0b8c904e0bc66a7922af4f317db623db6c51462
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:13 +02:00
Tomasz Bursztyka
1a22f76364 drivers: ieee802154: Fix cc2520 raw mode
Hack in commit-id 835f93b8250abc0f3edbee9a99463fccac03597c was breaking
raw mode needed for wpan* adaptations.

Change-Id: If1ff96fa8170cc84e356fb0452e487f0ff174da5
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:13 +02:00
Mahavir Jain
847432e7dd sample: dhcpv4_client: use unified kernel APIs
Remove legacy kernel APIs and use unified interface

Change-Id: I5ef9a31635aa4862640272353003c0c337509a97
Signed-off-by: Mahavir Jain <mjain@marvell.com>
2016-12-02 12:41:12 +02:00
Andy Ross
65e85f39a3 net: Wire up TCP receive callbacks
packet_received() does most of our work here already.  The appdata
needs to be filled in correctly for TCP packets, which needed the
header size computation to be abstracted out of the ACK code.

Change-Id: Ifeb87c8ddcaa6f4b116214a3b3fb737ab03286f1
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:12 +02:00
Andy Ross
9211918c56 net: Refactor net_context_recv() to separate UDP and sync handling
More protocols are incoming.  Put the UDP specific stuff (address
wrangling and connection creation) in a separate function, leaving the
synchronous handling in place for other protocols to use.

No behavior changes.

Change-Id: I67fd9f683314ca9b2e671b84c46b9392db9496b2
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:12 +02:00
Leandro Pereira
120468a858 net: udp: Remove protocol check in (private) net_udp_append()
I believe the original intention was to have code similar to:

	buf = net_ipv6_create(...)
	buf = net_udp_append(...)
	buf = net_tcp_append(...)
	buf = net_ipv6_finalize(...)

However, each protocol has different ways of creating packets and
checking invariants.  Thus, the code now does something similar to:

	if (proto == UDP) {
		// original UDP code
	} else if (proto == TCP) {
		// TCP code, which creates the IP header as well
	} else {
		// unknown protocol
	}

Which negates the need of such check in net_udp_append().

Change-Id: I7f05b7d556462b0db35aaecdf060539f8c246e8c
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:12 +02:00
Leandro Pereira
c4937e85ed net: tcp: Disallow sending messages to unconnected contexts
The call would eventually return -EDESTADDRREQ, however -ENOTCONN is
the sane error value in this case.

Change-Id: I6c24bf9bf2ecc4bff6a615567547390e6f5b7d77
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:12 +02:00
Leandro Pereira
2543b2f6ee samples: net: Finish TCP support in echo server
This adds the required code to echo server so that it works with TCP as
well.

Change-Id: Ib45dd91a52a60ddb4d8f0ae11175ceb52199c398
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:12 +02:00
Leandro Pereira
6a8dcce179 net: tcp: Allow sending packets using send() and sendto()
Adds support to send TCP packets using net_context_send() and
net_context_sendto() functions.

There's one behavior change: net_udp_append() will only append UDP
headers+payload if the context protocol matches.  This would allow
sending only IP packets from Zephyr.  Proper support for raw packets
should be added later if required, so the new behavior is to return
-EPROTONOSUPPORT if trying to send a packet through an
-unknown/unsupported protocol.

Note that sending packets outbound from Zephyr is still WIP; this is
just a step in the general direction of making it work.

Change-Id: Idcf26ad3820e85f1495e7029aed94f3b7abf25ed
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:12 +02:00
Leandro Pereira
287111d236 net: Implement net_context_send() in function of net_context_sendto()
Both functions perform the same logic, except that the sendto() variant
expects two more parameters to specify the destination address.

Just obtain that from the context in the send() case and forward the
information to the sendto() variant.

Reduces code slightly, while also making it easier to add more
protocols later.

Change-Id: I48da621d8788d5ba2cddaf2982324d3e896c13c3
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:12 +02:00
Vinicius Costa Gomes
b3dc2f8ecd samples/zoap_server: Using unified kernel API
Dropping legacy API.

Change-Id: If01eb40b7dfd9fac322ab8c001b7ebe37c0fed43
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:41:12 +02:00
Vinicius Costa Gomes
19087b8eca samples/zoap_client: Using unified kernel API
Dropping legacy API.

Change-Id: I8df78bc33550467b8558f8e58a6c390ce84f3b12
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:41:12 +02:00
Vinicius Costa Gomes
b1749afbc2 iot/zoap: Increase the range of timeouts
To avoid the risk of overflowing when dealing with retransmission
timeouts, increase the size of their representation to 32-bits.

Change-Id: I7c9c1e00c41f5ba75e19b0fd4527f273852eb85f
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:41:12 +02:00
Vinicius Costa Gomes
f1822a0252 net: Fix compilation when DEBUG is enabled
When debugging is enabled, compilation fails with an error, similar to
this:

... net/yaip/net_mgmt.c:155:35:
error: 'struct k_sem' has no member named 'sem'
     k_sem_count_get(&network_event.sem));
                                   ^

As 'network_event' is a k_sem, there is no '.sem' field.

Change-Id: I09fb46ec02b62c30b9a12972abcaea8a36b84610
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:41:12 +02:00
Andrei Emeltchenko
b0aee95eda wpanusb: Log INF about upper layer start/stop
Change-Id: Ibb841afb94150ccc73b5e80a41a2ca9c949a25c8
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:41:12 +02:00
Andrei Emeltchenko
88b41debd8 drivers: ieee802154: cc2520: Log errors when starting/stopping cc2520
Change-Id: I55efbfcd91da48b98654a5d1dfcbf02b2d76cf75
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:41:12 +02:00
Andrei Emeltchenko
75844e7847 drivers: ieee802154: cc2520: Flush RX fifo earlier when stopping
flush_rxfifo() leaves fifop interrupts enabled.

Change-Id: I76d5e270982e2cd8f958417f310c1d3547bc061d
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:41:11 +02:00
Andrei Emeltchenko
17b6c45e79 wpanusb: Include shell to the sample
Including shell allows to execute some kernel commands and make sure
system is not crashed.

Change-Id: I6157229614655dc7e523f1cf0f84ee7c58d7a717
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:41:11 +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
Tomasz Bursztyka
640ba28793 samples: net: No need of full debug output on cc2520 in echo client
Change-Id: I6ffe5e5c9e8f4baa55386c2f5f430c2765e6f6ab
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:11 +02:00
Tomasz Bursztyka
3ac3fb1f1e net: ieee802154: Add debug output to 6lo fragmentation
Change-Id: I429398b31a4ebf55658376bdc294faae5774edbf
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:11 +02:00
Tomasz Bursztyka
1e39eabcb7 drivers: ieee802154: Set a fake MTU of 125 instead of real 127
This is a hack, related to:
commit-id 835f93b8250abc0f3edbee9a99463fccac03597c

Change-Id: I7e305cef9ca908e2a71a011920663e1603ad8d6e
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:11 +02:00
Tomasz Bursztyka
aa556f828e net: ieee802154: Fix wrong ifdef statement
Fragments reassembly was never used in l2.

Change-Id: Ia06ccbcd591ff79c43915e81c0b273533c607aa6
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:11 +02:00
Tomasz Bursztyka
3312663011 net: Raise TX stack size to 1200 bytes by default
Current value is not enough anymore it seems. (depends however, if some
debug output is enabled or not).

Would be much better if the build system could automatically compute
such size.

Change-Id: I9052616a7923e484664e4f5c7760e6a6e1152c63
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@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
28255628f8 net: rpl: Add RPL option to IPv6 HBHO extension header
See RFC 6553 for details.

Change-Id: I2448f6fa03819e797c4825238ff3e125d2f92bbf
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:11 +02:00
Jukka Rissanen
314068d924 net: Avoid compiler warning when compiled for Arduino 101 ARC
There is something wrong with Arduino 101 ARC compiler.

Sanitycheck runs ethernet tests for this board basically using
this command:

cd tests/drivers/build_all
make pristine && make CONF_FILE=ethernet.conf BOARD=arduino_101_sss

Which then gives following warning

warning: missing braces around initializer [-Wmissing-braces]

which is then converted to error in sanitycheck.

Change-Id: I822c599cb172825a79b5b8e4a71cb9252757a435
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
7a11439020 net: ieee802154: Fix current stack to completely drop CRC handling
The 802.15.4 frame has a header and in the end after the payload a CRC.
Overall MTU is 127 bytes, but CRC is most likely going to be generated
by the device itself (offloading). Because the limitation of current
nbuf, it's not possible to keep this CRC in the buffer because it
require a user data size of 127 bytes but if we do so, IP stack will
fill in as much as it can as packet data, thus occupying the 2 last
bytes. This generates bugs. A perfect solution would be to generalize a
better handling of MTU and head or tail reserve data into nbuf, but
this will probably be solved in the future.

Change-Id: I1a0fee4d555e2717c1edd5afba399a1f17d9c7a9
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:11 +02:00
Andrei Emeltchenko
82ac4f68f7 wpan_serial: Correct file description
Correct leftovers from CDC sample.

Change-Id: I337440a4f9a9016bb0635f49e205c1b6fee56e96
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:41:10 +02:00
Jukka Rissanen
c4cec90f68 net: shell: Add IPv4 ping support
User is able to send ICMPv4 Echo Request to destination
address.

Change-Id: Ie32d5970e5f3e75e925c283947f97e096e509555
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:10 +02:00
Jukka Rissanen
137e34a795 net: Fix net_addr_pton() IPv4 address parsing
Change-Id: Ib84067b66e3e417561045a4746408cecb6c2c67a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:10 +02:00
Jukka Rissanen
23d32722e8 net: Check loopback and unspecified address in sending
If the destination IP address is loopback, then bypass
the L2 layer and directly feed the IP packet back to us.

If the destination IP address is unspecified, then
drop the packet.

All this is only done if CONFIG_NET_IP_ADDR_CHECK is
set as this extra processing can be unnecessary if
it is always known what addresses the device is going
to use. By default the address checking is enabled.

Change-Id: I323cce97a72533c75b0424870f08729479024ebf
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:10 +02:00
Jukka Rissanen
b9d2113f02 net: Add util to send IPv4 ICMP Echo Request packet
Change-Id: I879eec03bc93cbf8935d62be9bff3e6cb03a8d72
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:10 +02:00
Jukka Rissanen
209b0cdb1c net: Add IPv4 address string max length
Change-Id: I37a2ea9371c34353f259300452fd228a00b26aa8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:10 +02:00
Jukka Rissanen
5db9bc8895 net: ipv4: Add utils to create IPv4 network packet
Create utility functions to create IPv4 packet if the
network context is not known.

Change-Id: I982830d09f3b91e23b75e6b63a5d97bfea0e8d4e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:10 +02:00
Jukka Rissanen
e69fbacc5a net: Add util to check if IPv4 address is unspecified
Change-Id: I373bc32481ad186a3c198ed29709f12ea40cf583
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:10 +02:00
Jukka Rissanen
ba65d1ef1d net: Add util to check if IPv4 address is a loopback one
Change-Id: I55a6e07060993fc7274749706d063fc15953c38f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:10 +02:00
Jukka Rissanen
9c99fbe601 net: shell: Fix hostname parsing for ping command
If the user uses set_module command, then the target host
name pointer will be wrong. This is fixed so user can
either say "net ping 2001:db8::2" or if set_module command
is used "ping 2001:db8::2"

Change-Id: I708c53e329a11a18fcb448b34213e4b2f19c6390
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:10 +02:00
Andrei Emeltchenko
fd57ca6f23 wpan_serial: Use unified API for wpan_serial sample
Convert API to unified.

Change-Id: Ie00eb84441295a8311181186cbb117837a0fd3ca
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:41:10 +02:00
Andrei Emeltchenko
3f2db79cd2 wpanusb: Use unified API for the wpanusb sample
Convert to unified API.

Change-Id: I8f400fe5fca6411f3c3da40d409cff49a05da619
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:41:10 +02:00
Andrei Emeltchenko
cf66ddfd39 wpanusb: Use INFO default logging level
Due to huge delays with DEBUG log level change it to INFO.

Change-Id: I81caf78fc6e9e064c2ed8e18caa99351028af62a
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:41:10 +02:00
Andrei Emeltchenko
b2d2c7fe06 wpanusb: Send zero sequence for unsuccessful transmit
In a case transmit is failed send ack to the driver with zero sequence
number which is not used for valid seqs.

Change-Id: I1047de9ab5de636c5a8983f31376046757c4dc0c
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:41:10 +02:00
Andrei Emeltchenko
5ceb1133c4 wpanusb: Allow retransmission when cc2520 transmit not done
Following replacing semaphore with timeout semaphore transmit may not
be finished returning error after which communication stalls. Allowing
3 retransmits solves the issue.

Change-Id: Ibad05c2eac43dd6bb0ed72aaf16a7a2ef4185067
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:41:09 +02:00
Tomasz Bursztyka
0bb17f9639 samples: net: Put a proper stack size for echo-client
Having 1024 bytes was really unsufficient and creating a lot of weird
bugs everywhere.

Change-Id: Ib642744fa6dfc9f3a699a0dc2f0c1783dc6f87b2
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:09 +02:00
Tomasz Bursztyka
1e7a92f7da samples: net: Fix how k_sem_take is used in echo_client
Semantic has changed in k_sem_take in comparison with legacy
nano_sem_take.

Change-Id: I06129b6f15f66266919bf371c2358e5634109156
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:09 +02:00
Tomasz Bursztyka
2dd1b5df0f samples: net: Use uart-pipe for 802154 iface in echo apps
This is meant to test echo applications with 802.15.4 L2 directly in
qemu.

Change-Id: I0edccd8c39360421dc77e0064147221d86877bdf
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:09 +02:00
Tomasz Bursztyka
7e8ebf4733 net: ieee802154: Fix and use pkt_hexdump relevantly
Use frag->data as a reference, not net_nbuf_ll or net_nbuf_ip_data.

Print out packet before compression/fragmentation, so it will help to
spot issues after such process.

Make sure as well no coloration is done if frag reserver is not set.

Change-Id: I7f1bdc9e5c39913b8d7f62b5ffacb9ba3e11ecc8
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:09 +02:00