Commit graph

41120 commits

Author SHA1 Message Date
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
Jukka Rissanen
f836032d39 samples: net: Bind any IPv6 address by default in echo-server
This commit allows echo-server to listen all defined addresses
specified to its network interfaces.

Change-Id: I52874210f6987c75d7921e514399a9eda55911bb
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:07 +02:00
Tomasz Bursztyka
ed6ccead1e drivers: ieee802154: Let the initialization priority be done via Kconfig
Since the whole init level changes: all drivers and most of subsystems
are initialized at level POST_KERNEL. Unfortunately that broke legacy
tweaks on what to start first and after.

Let's raise cc2520 priority, still below net_init.

Jira: ZEP-1261

Change-Id: I0d91aa87a893584b3f5b39a193c823127961402f
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:07 +02:00
Tomasz Bursztyka
54ddabc7e6 net: context: Instead of 0 as timeout, K_NO_WAIT is better.
Updating the API documentation to use K_NO_WAIT instead of 0.

Change-Id: I10ba31fe116210443f383b343993c3cca830a7c2
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:07 +02:00
Tomasz Bursztyka
3964a6cef3 samples: net: echo apps: Using unified kernel API
Dropping legacy API.

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

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

Change-Id: Ife835e38fb03e909e89c3060771f42d1cfa12164
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:07 +02:00
Tomasz Bursztyka
8e075eb469 net: route/rpl: Using unified kernel API
Dropping legacy API.

Change-Id: If9f52f88c77e4e5ef19b9c0cc66c0d4e31efbe98
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:07 +02:00
Tomasz Bursztyka
500cc706b1 net: dhcpv4: Using unified kernel API
Dropping legacy API.

Change-Id: I0f1a04d0f9a19696ddb50d976beba00a19a830cd
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:07 +02:00
Tomasz Bursztyka
799c57b261 net: nbuf: Using unified kernel API
Dropping legacy API.

Change-Id: I8766a27f90c99aca0aa222833018a4dd8d65b885
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:07 +02:00
Tomasz Bursztyka
92700ee8ef net: tcp: Using unified kernel API
Dropping legacy API.

Change-Id: Ia1eecd5d6dad07f3e9272d7b62c0b7a4b939317b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:06 +02:00
Tomasz Bursztyka
1aaf5aaa93 net: l2: Using unified kernel API
Dropping legacy API.

Change-Id: Icf24ecef714a9d6ddbe16aff6422b4fcc6c428e2
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:06 +02:00
Tomasz Bursztyka
710e6c327e net: ipv6: Using unified kernel API
Dropping legacy API.

Change-Id: I6e7887d8212ec59214b1c28dd9a3320b1a8fff1f
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:06 +02:00
Tomasz Bursztyka
aa9a552012 net: if: Using unified kernel API
Dropping legacy API.

Change-Id: I46eb30f691f5e0a9e9156f8b4dab3c00e64ffb9b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:06 +02:00
Tomasz Bursztyka
bd293e4dd9 net: mgmt: Using unified kernel API
Dropping legacy API.

Change-Id: Ifcada6513cf57bf2b73809bd9ed886f2c623baab
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:06 +02:00
Tomasz Bursztyka
ea13cf8575 net: context: Using unified kernel API
Dropping legacy API.

Change-Id: I2f98ec39906bd8c0a8979171904d244b6a82a5e7
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:06 +02:00
Tomasz Bursztyka
f3cb3ff40e net: core: Using unified kernel API
Dropping legacy API.

Change-Id: I756e47855cc979aa130ad0de4fd527c4a79e8d71
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:06 +02:00
Tomasz Bursztyka
764cd1118b drivers: ieee802154: Using unified kernel API
Dropping legacy API.

Change-Id: Ifa3b61082036b0f7b593f1f28a30a1d0ad18e179
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:06 +02:00
Jukka Rissanen
aa438d10fe net: Add more debugging when receiving invalid packet
Also fix typo in debug print when discarding a packet.

Change-Id: I3ac41e86d7b2dc05b9d92cde93a646f2dc49d8c0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:06 +02:00
Jukka Rissanen
40508b1747 net: nbuf: Add more debugging if ref count is wrong
Change-Id: I0fc77456c20b6ecd4066e8a70c1df4ecab9a689d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:06 +02:00
Andrei Emeltchenko
3d67b5badb wpan_serial: Correct SLIP buffer size
SLIP buffer size depends on maximum IEEE 802.15.4 frame size and start
byte.

Change-Id: I1cb0a848dce6b0c85bf11408733d777f7a3b03c9
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:41:06 +02:00
Flavio Santes
c55ca20ad4 iot/mqtt: Add support for frdm_k64f
This commit adds the frdm_k64f board to the testcase.ini while list.
It also updates the README file with the build instructions and
firmware version used in this test.

Change-Id: Ia0e989d483aede51aa53e7453bbd1c260223372d
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:41:06 +02:00
Leandro Pereira
0596472772 net: Fix connection-in-use test while unregistering connection
The bitwise and operator was being applied to a boolean operand because
of lack of parenthesis in the expression.

Change-Id: Ibfbdd8acce9db95f9274f48fd145f4d8467508e2
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:06 +02:00
Leandro Pereira
90f324869f net: Print more debug messages when processing corrupted buffers
Change-Id: I62fa8cd05b1b4598dfefc7a82b28467072b06ae3
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:05 +02:00