Commit Graph

10643 Commits

Author SHA1 Message Date
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
Flavio Santes d37b9fa9b5 iot/mqtt: Add the MQTT high-level API
This commit adds the MQTT high-level API with Quality-of-Service
support. The following MQTT messages are covered by this commit:

CONNECT (tx), DISCONNECT (tx), PUBACK (tx, rx), PUBCOMP (tx, rx),
PUBREC (tx, rx), PUBREL (tx, rx), PUBLISH (tx), PINGREQ (tx),
SUBSCRIBE (tx), UNSUBSCRIBE (tx), CONNACK (rx), PINGRESP (rx),
SUBACK (rx) and UNSUBACK (rx).

Where 'tx' stands for transmission: routines that create and send
messages. 'rx' stands for reception: routines that receive an RX
buffer from the IP stack and parse the MQTT mesage contained in
that buffer.

Jira: ZEP-365
Jira: ZEP-591
Jira: ZEP-856

Change-Id: Ibee701a298127eb713aa3fde5aaf7d089ecd1b9d
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:41:09 +02:00
Tomasz Bursztyka fa678cfdb6 net: ieee802154: Fix some debug output
Do not color the packet hexdump if there is no reserve set.
Do not print the ll part after 6lo compression/fragmentation.
Print out the actual frag being sent in radio driver.

Change-Id: I43118203c37fc76f60673c046732c8655ab7067b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:09 +02:00
Tomasz Bursztyka 094ef65130 net: 6lo: LL content is set after 6lo compression/fragmentation
Thus no need to copy anything from there.

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

Change-Id: I175943f32065ae81b1a4453dde40f36738c28084
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:09 +02:00
Jukka Rissanen a9673d9f56 net: Replacing TICKS_UNLIMITED by K_FOREVER
Unified kernel uses K_FOREVER so use it instead.

Change-Id: I24ae75e99cf54d6959c014b8a848e22a33848657
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:09 +02:00
Leandro Pereira 2bfc42610d net: tcp: Reduce some of the boilerplate to send control segments
Move most of the code to send a control segment to a single function to
avoid copies of boilerplate code in a few functions.

Change-Id: Id2d4770b6bec3f10b4eb786af3eb2a25482d953d
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:09 +02:00
Leandro Pereira 6154e3c809 net: tcp: Implement the rest of active close machinery
This implements the active close state set (FIN_WAIT_1, CLOSING,
FIN_WAIT_2, TIME_WAIT).

Change-Id: Id146ba3d6a774bfeac93401779a246fd32e2c523
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:09 +02:00
Leandro Pereira 79b9e1413d net: Allow changing the callback of a connection
For certain scenarios, such as handling TCP active close, where the
state group {FIN_WAIT_1, FIN_WAIT_2, CLOSING, TIME_WAIT} can be reached
from more than one state (ESTABLISHED and SYN_RCVD respectively), it's
cleaner to handle all the transitions inside a single callback
function.

Change-Id: I3d4d210dd667fef5cf81d5174d626adbf8675019
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:09 +02:00
Leandro Pereira 3b2dabec2b net: tcp: Implement part of active connection close
This transitions a connection to FIN_WAIT_1 state if it was in either
SYN_RCVD or ESTABLISHED states and the local peer decided to close the
connection.

A timer is started to close the connection after 2 MSL (which is 120
seconds; this might be easily tunable through kconfig).  No transition
from this state to FIN_WAIT_2, CLOSING, or TIME_WAIT are implemented on
this change: oncoming changes will implement the rest of this
machinery.

Change-Id: Ic9e2eceef81a82fb37c0a829860cfcf52f424475
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:09 +02:00
Leandro Pereira f3d5a36940 net: tcp: On error, dispose of net_buf when sending control segment
The net_buf structs were being dereferenced when the packet was
correctly sent by the underlying layers, and never on error.  This
could lead to crashes, double unrefs, and buffer leaks.

Change-Id: I81b280f9d108c18ebe0e5914b73da4656afbd6ae
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:08 +02:00
Leandro Pereira 264b93c736 net: tcp: Implement passive close (FIN packets in ESTABLISHED state)
If a packet with the FIN flag is received while in ESTABLISHED estate,
transition to CLOSE_WAIT and send the ACK as usual.

The act of preparing a segment in CLOSE_WAIT state will automatically
transition the TCP context to the LAST_ACK state.  Next time a packet
comes in with the ACK flag set, put the context.

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

Change-Id: Ie876c538599fabae6b800a53613b6ad17dc45620
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen 26ea431c5f samples: net: echo apps: Do not set preferred IPv6 address
Previous commits support auto configured IPv6 addresses so no
need to manually tweak the address settings.

Change-Id: Ie641212981a04229721c84990a54876977d9cfc4
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen 57e565855a net: Fix IPv6 router lifetime handling
Create a timer when router is added, update it if needed after
receiving Router Advertisement, and then delete the router lifetime
timer when the router is removed from the system.

Change-Id: I784e0534da300fdcb43349d9cf40354ebe109e07
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen b650b758c9 net: Add util to remove an IPv6 router from the network interface
Change-Id: Ie9cc461187a25355819e685cec68b04d4eba8c87
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen 5092b3c555 net: Add util to update router lifetime
Change-Id: I38ecf574f2a0c69348ed73efb9b26aadab4344aa
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen 83219eeefb net: ipv6: RA messages were incorrectly handled
Received Router Advertisement messages were incorrectly received
and handled which could cause hanging or crashing of the system.

Jira: ZEP-1267

Change-Id: I05b57221581e9f671825dbc147adb0a55bea091e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen 4a7c146e24 net: ipv6: Print info about unknown RA options
Print information about every unknown RA option we receive.
These options need to be implemented later.

Change-Id: Ic2d189e4a130162569a81ca58d38b8129183b2fd
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen 0ea0fe3f75 net: ipv6: Fix network interface address lifetime handling
Setup IPv6 address lifetime timer if needed and start Duplicate
Address Detection procedure for every IPv6 address added to
the network interface. If the IPv6 address is removed from
network interface, cancel any pending lifetime timers.

Change-Id: I5b6ffd97836cfe78ddb9ff8fdb78d8be0bb81348
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen 41e547673a net: Add util to update IPv6 address validity time
Change-Id: I951c9e781c74724c69fbd700ef738dd487ec15a7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen a1ea8ef642 net: ipv6: Validity time is already in host byte order
The validity time is already converted to host byte order
when reading the field from the Router Advertisement message.
No need to use ntohl() here.

Change-Id: If1106748f268a245871510563c7e7849020e3b3a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen 3d363db33c net: Remember IPv6 extension header len when packet is received
This is needed in other part of the stack in order to able to
parse packets properly.

Change-Id: I8082860333bdcb2c6114d517ff0b782b9ba526a0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen 7e9eaaacb9 samples: net: Fix echo-server UDP packet sending
This commit fixes the case when we receive large amount of
data and then copy it into new fragments. If the MTU is larger
than the fragment size, then it is possible that we might
overwrite net_buf memory and crash. This is typical in ethernet
network.

Change-Id: Ib1c65819c3bc718ec04f558e3df235246b5655dd
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Sergio Rodriguez 8a7ca107b5 samples/mbedtls_dtlsclient: Using unified kernel thread spawn API
Change-Id: I760183861e458f3daf8d419a5234332141a732dc
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
2016-12-02 12:41:07 +02:00
Sergio Rodriguez 67ce715d0d samples/mbedtls_dtlsclient: Removing unnecessary files
The DTLS client will not longer use the legacy IP stack.

Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
Change-Id: I7402a188fc7501873d98d3b6cb2f03ee51f3506b
2016-12-02 12:41:07 +02:00
Andrei Emeltchenko afc122eeec drivers: cc2520: Remove double space in debug and errors
commit-id 67c465d2cc introduced this
weird format by not removing unnecessary spaces.

Change-Id: I964185c8a894cfcf10e253e6d378c63ec02ad8d7
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:41:07 +02:00
Tomasz Bursztyka 4438278133 net: ieee802154: Fix a double ll address swap
Commit 7bdd30d99d447b89b89c7fb0c76d52586744176f was properly swapping
incoming ll address, but in case of sending, frame creation logic is
already doing the job properly.

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