Commit graph

41120 commits

Author SHA1 Message Date
Michael Scott
01e3c3380f samples: net: irc_bot: remove unneeded typecasts and extra var
From function: zirc_connect

Change-Id: Ie0abc919c62b12995af7605bd080eafa48b48841
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-02-03 15:59:15 +02:00
Michael Scott
79dc068bea samples: net: irc_bot: release net_context reference upon error
Change-Id: I69451b3035d09c0de8ae0f448c80b780a09e72bd
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-02-03 15:59:15 +02:00
Michael Scott
14a6306069 samples: net: irc_bot: establish privmsg callback typedef
Change-Id: I005fc4d33da7b2c81e2add5e73f11f6c5bd2c42c
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-02-03 15:59:15 +02:00
Michael Scott
ed7ea99244 samples: net: irc_bot: run sample process as a thread
This allows for a set app stack and threaded functions to be used later.

Change-Id: I647a3defdf6eb4cca2a4a21192b20641f5bf8d4a
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-02-03 15:59:15 +02:00
Leandro Pereira
2bcd700462 samples: net: Add IRC bot example
This is a sample IRC bot program, written using the new IP stack API.
All it does is join an IRC channel, wait for some commands, and react
to them:
	!hello will greet whoever sent the command
	!random will generate a pseudo-random number and send it back
	!led_toggle will toggle an LED in the board [1]
	!led_on will turn the LED on regardless of its current state
	!led_off will turn the LED off
	!rejoin will part the current channel and join again
	!disconnect will quit from the IRC server

As far as the IRC protocol goes, it doesn't do much more than this, but
it should be straightforward to add support for other things (such as
notices, CTCP, DCC, etc) if someone is inclined to do so.  However,
that's way beyond the scope of this sample, which is to show how to use
the network API to write a TCP client.

Some things are still missing as an example of how to use the APIs,
namely DNS resolution, automatically setting up the network with DHCP,
maybe saving settings on EEPROM.  These are good candidates to be added
in the future.

[1] The LED code has been shamelessly stolen from the CoAP sample code.

Change-Id: I7152e97c0726f3559db545579ae8ae8d07bf04cd
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-02-03 15:59:15 +02:00
Andy Ross
3efe6b7ede net: tcp: Add optional TIME_WAIT support
The RFC requires we honor the 2MSL TIME_WAIT timeout, support for
which was just removed with the FIN cleanup.  Add it back, but make it
optional (proper sequence number and ephemeral port randomization
makes true collisions a birthday problem in a ~80 bit space!).

Change-Id: I176c6250f43bba0c914da1ee7f0136dcb1008046
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-02-03 15:59:15 +02:00
Andy Ross
f3cce9082d net: net_context: Drop callbacks in net_context_put()
The context may live for a while after the user closes it (c.f. TCP),
and of course the documentation specifies that the user must not use
it after calling net_context_put().  Don't confuse them by invoking
their callbacks on the "closed" connection; it's likely that the user
has destroyed her own tracking data and the user_data pointers would
be garbage.

Change-Id: Iba9cc7025c6ea4a94cc4796903966f8d1b831996
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-02-03 15:59:15 +02:00
Andy Ross
fece856959 net: tcp: Clean up FIN handling
The connection close paths were a little tangle. The use of separate
callbacks for "active" and "passive" close obscured the fundamentally
symmetric operation of those modes and made it hard to check sequence
numbers for validation (they didn't).  Similarly the use of the
official TCP states missed some details we need, like the distinction
between having "queued" a FIN packet for transmission and the state
reached when it's actually transmitted.

Remove the state-specific callbacks (which actually had very little to
do) and just rely on the existing packet queuing and generic sequence
number handling in tcp_established().  A few new state bits in the
net_tcp struct help us track current state in a way that doesn't fall
over the asymmetry of the TCP state diagram.  We can also junk the
FIN-specific timer and just use the same retransmit timer we do for
data packets (though long term we should investigate choosing
different timeouts by state).

Change-Id: I09951b848c63fefefce33962ee6cff6a09b4ca50
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-02-03 15:59:15 +02:00
Andy Ross
f16886d419 net: tcp: Don't send active close FIN packets synchronously
A FIN packet generated by a net_context_put() must go into the normal
transmit queue and not be sent synchronously.  Previously sent data is
expected to be delivered and acknowledged before the connection is
terminated.

An advantage we get with this change is unified timeout and retry
handling for FIN packets.

Note that there remains a misfeature here where the queing of the FIN
results in a synchronous switching of the connection callback to
tcp_active_close(), which will prevent any further data received from
being provided to the user.

Change-Id: I2d41316549da9fee383b4f32af5e8b3adf4cb122
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-02-03 15:59:15 +02:00
Andy Ross
5d6e0d425b net: tcp: Clean up net_context lifecycle
The death of a network context was sort of a mess.  There was one
function, net_context_put(), which was used both by the user as a way
to "close" the connection and by the internals to delete it and to
"clean up" a TCP connection at the end of its life.

This has led to repeated gotchas where contexts die before you are
ready for them (one example: when a user callback decides the
transation is complete and calls net_context_put() underneath the
receive callback for the EOF, which then returns and tries to inspect
the now-freed memory inside the TCP internals).  I've now stepped into
this mess four times now, and it's time to fix the architecture:

Swap the solitary put() call for a more conventional reference
counting implementation.  The put() call now is a pure user API (and
maybe should be renamed "close" or "shutdown").  For compatibility,
it still calls unref() where appropriate (i.e. when the context can be
synchronously deleted) and the FIN processing will still do an unref()
when the FIN packets have been both transmitted and acked.  The
context will start with a refcount of 1, and all TCP callbacks made on
it will increment the refcount around the callback to prevent
premature deletion.

Note that this gives the user a "destroy" mechanism for an in-progress
connection that doesn't require a network round trip.  That might be
useful in some circumstances.

Change-Id: I44cb355e42941605913b2f84eb14d4eb3c134570
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-02-03 15:59:14 +02:00
Tomasz Bursztyka
bc406fab08 samples/net: Add a simple telnet sample
It will setup IPv4/IPv6 addresses. Telnet is ran in the background,
along with net and kernel shell modules.

See the README.rst for more information how to start and use this
sample.

Change-Id: I3e935014c79b534aab43a6fa8256792b23abb38e
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-02-03 15:59:14 +02:00
Vinicius Costa Gomes
d689c5ee97 samples/zoap_server: Add a 802.15.4 case to the test suite
Allow build-testing zoap-server with support for the CC2520 radio.

Change-Id: I986afd7b15208d477bd79f42a52dd45b217214cb
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-02-03 15:59:14 +02:00
Vinicius Costa Gomes
0ef657904d samples/zoap_server: Allow overriding the BOARD variable
In case the user wants to use BOARD make variable to conveniently use
another board with this sample.

Change-Id: I6dd0656da223218d116dd498c1336c890563b212
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-02-03 15:59:14 +02:00
Jukka Rissanen
1997a049fa net: Increasing the default number of network contexts
The old default 2 is too low especially if TCP is enabled.
So in order not to confuse the application developer,
increase the default number of network contexts to 6.

Change-Id: I263bb4b6f31354a11d921d94aa97214abd85ae24
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-02-03 15:59:14 +02:00
Jorge Ramirez-Ortiz
8b9212d57d net/mqtt: Check function return value
Change-Id: I4a4df19d50b9422f3e72d6386c0c726b6d9b82f2
Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
2017-02-03 15:59:14 +02:00
Ravi kumar Veeramally
2de8bd928a net: tests: Add unit tests for net_addr_ntop() utils function
Change-Id: I72ee5f6444d2e45de0ee7a3aa96884282d41b72d
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-02-03 15:59:14 +02:00
Ravi kumar Veeramally
b13f44bcdd net: utils: Add net_addr_ntop() helper function
net_addr_ntop() will convert IPv4|6 address to string form.
Renamed existing net_sprint_ip_addr_buf() to net_addr_ntop()
and adjusted parameters as per API.

Jira: ZEP-1638

Change-Id: Ia497be6bf876ca63b120529acbadcfd9162a96e3
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-02-03 15:59:14 +02:00
Ravi kumar Veeramally
10e5162fc2 net: tests: Add unit tests for net_addr_pton() utils function
Change-Id: Ib1e89ce3bb7eff5afe14394062ee6f53a28cc4e6
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-02-03 15:59:14 +02:00
Luiz Augusto von Dentz
3171610f8b net: bt: Fix failing to resolve link-local address
This make sure the link-local address of the destination is added to the
nbr cache as that is accessed when calling net_ipv6_prepare_for_send,
this is needed when following RFC 7668 since link-local addresses are
never registered using nbr discovery.

Change-Id: I2bc578d33d1061726d0cbf46e4464df74d79e992
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-02-03 15:59:14 +02:00
Sergio Rodriguez
1bbfd3effe driver: ethernet: Fix typo on enc28j60 driver Kconfig
Change-Id: Ie7178db2da5e4de476192516dfb9ff3a5e8f082a
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
2017-02-03 15:59:14 +02:00
Tomasz Bursztyka
227bf97f60 samples/net: Fix a tiny mistake in dhcpv4_client README.rst
Change-Id: I7ce6e9a762f13d3db5d2769301719f17b798a4fe
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-02-03 15:59:14 +02:00
Paul Sokolovsky
63e6b60969 net: echo_server: Enable TCP for frdm_k64f
To match qemu_x86.

Change-Id: I04806d8a8850a76c984f3cda1efaa065bcf4596e
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-02-03 15:59:14 +02:00
Kumar Gala
54c642caec net: ip: stat: fix typo in rpl.dio.sent stat
in net_print_statistics for RPL we had:

GET_STAT(rpl.dio..sent)

This wouldn't work or compile, so drop a dot.

Change-Id: Idd6b4dfd5fcae3b90bc977fe3ed301cd813ca87c
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-02-03 15:59:13 +02:00
Vinicius Costa Gomes
f0f8a99257 samples/zoap_server: Enable support for 802.15.4
This configuration file allows using the device 802.15.4 radio for
IPv6 networks.

Change-Id: I9b3ee9a64acb71e97e4e8f7aae3e619196ad0462
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-02-03 15:59:13 +02:00
Michael Scott
ca6a686495 net: correct in*_addr parameter of net_addr_pton()
Currently, the function accepts a struct sockaddr * but the code
immediately type casts this to either in_addr or in6_addr.  This is
incorrect behavior as the first field in a sockaddr is sa_family_t
and not address data.

So without special knowledge, a developer will use a sockaddr structure
as the parameter and then wonder why the address information isn't being
set correctly.

Let's change this parameter to void * which makes this function similar
to inet_pton().

Jira: ZEP-1616

Change-Id: I1fc9368da999d90feb07c03fac55dcc749d4eba6
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-02-03 15:59:13 +02:00
Jukka Rissanen
6d50b47987 net: tcp: Call connect callback later
If the user supplied connect callback uses too much time, then
it is possible that the connect_wait semaphore will timeout
even if the TCP connection was established correctly. This issue
can be avoided if connect_cb is called after we have released
the connect_wait semaphore.

Change-Id: I175e80f2ad48de657d0d99a44340c5ee1a17364c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-02-03 15:59:13 +02:00
Benjamin Walsh
e440759dbb tests/kernel/poll: test object runtime init functions
Change-Id: I04eac2e5cf5e49ea92fd6195c94a25e783aab253
Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
2017-02-03 13:54:01 +00:00
Benjamin Walsh
a304f16773 kernel/poll: add k_poll_signal_init() runtime init
Change-Id: Id5a27f7d25e26a1a71ef87000d35a18777210c19
Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
2017-02-03 13:54:01 +00:00
Benjamin Walsh
b017986347 kernel/poll: add missing poll_event runtime init
It was in the static initializers, but was missing from the object
runtime init functions.

Change-Id: I10d519760eabdbe640a19cc5cfa9241c1356b070
Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
2017-02-03 13:54:00 +00:00
Benjamin Walsh
31189d9ec8 tests/kernel/poll: verify tag is untouched by API
Change-Id: I56f0f0db64c20db40c26b197bba8f1e6bb80a499
Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
2017-02-03 13:53:59 +00:00
Benjamin Walsh
969d4a7ff1 kernel/poll: add user tag to struct k_poll_event
This will allow users to install a way of finding out what the event and
the objects are used for without looking at the object itself, or to
tag a bunch of objects that belong together.

The runtime init function _does not_ take a tag so that there is no
runtime hit if not needed. The static initializer macro _does_ take the
tag, so that it does not have to be initialized at runtime if needed,
and thus avoids a runtime hit.

Change-Id: I89a36c6f969ff952f9d1673b1bb5136e407535c6
Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
2017-02-03 13:53:59 +00:00
Jithu Joseph
1eba370efd tests: kernel: import pool/heap tests to unified kernel
Jira: ZEP-932

Change-Id: I4adf43f63db8dca7c252e40433f6ff0095dc1f26
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-02-03 05:19:46 +00:00
Jithu Joseph
cacb2edfb7 tests: kernel: port mutex/priority inheritance test to unified
Jira: ZEP-932

Change-Id: I41728a1448998e32c9ad8217f132afbfafbae3d7
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-02-03 05:19:46 +00:00
Jithu Joseph
10e36609b6 tests: kernel: import libs test to unified kernel
This tests access to standard libraries. Adapted
to use ZTEST.

Jira: ZEP-932

Change-Id: I3564bfa61221b2456323c1018402237b6129b5ca
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-02-03 05:19:45 +00:00
Anas Nashif
6ca73fb744 tests: legacy: resolve conflict with MON defined in HAL
Some header files were defining MON and causing a conflict, so call this
something unique and avoid future conflicts.

Change-Id: If9d2553a20b3afae50a09f4c0e10733ee1cdd58d
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-02-03 04:50:10 +00:00
Anas Nashif
2ab4fa2d4e Revert "[REVERTME]boards: omit frame pointer for ARC boards"
This reverts commit 813d550361.

This change requires Zephyr SDK 0.9.

Change-Id: Ic296cee1cd472b99cad4f9140d608640eb9ed66a
Jira: ZEP-1403
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-02-03 04:15:53 +00:00
Jithu Joseph
9659fec761 tests: kernel: import errno test to unified
Jira: ZEP-932

Change-Id: I59b3d0aebc7df37c9b59e8bf1358d20500f24f57
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
2017-02-03 03:21:05 +00:00
Jithu Joseph
5800f16484 tests: kernel: import floating point sharing tests to unified
This is the microkernel version of the FPU sharing test from legacy
modified to  use unified APIs directly.

Jira: ZEP-932

Change-Id: I133a1466ea75201a97c2f8b83c3586fea0a19447
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-02-03 03:20:32 +00:00
Jithu Joseph
d33c42a19d kernel: thread: Fix legacy symbol mixup in fp path
When CONFIG_FP_SHARING is enabled without CONFIG_LEGACY
thread.c was referencing symbols like K_TASK_GROUP_FPU
which are defined in legacy.h

Change-Id: I4bb1723f91c3e3586c5d1bf05cf23a1c0d3d5aac
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
2017-02-03 03:20:31 +00:00
Andrew Boie
f7a6e28a3c sanitycheck: don't override environment for USE_CCACHE
Many users set USE_CCACHE=1 in their envionment. Sanitycheck was
disregarding that and placing USE_CCACHE=0 in the generated
Makefile unless --ccache was added to the command line every time
it was invoked.

Issue: ZEP-1663
Change-Id: Id3c1379f5039d4d2f4a3ae01d2ec8d0dd216f523
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-02-02 13:09:00 -08:00
Andrew Boie
4fc96066b0 irq: introduce 'direct' interrupt API definition
These interrupts are for ISRs that need the lowest possible latency.
They do not take parameters and are installed directly in the interrupt
vector table.

Issue: ZEP-1038
Change-Id: I7583e9191dd32d9253ad933181d2103a6e191dea
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-02-02 17:46:33 +00:00
Anas Nashif
d4dddf7f52 doc: update intro section with new architectures
Change-Id: I4439bf84b02110337e605ef06a1d52ac97764d3e
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-02-02 15:55:17 +00:00
Anas Nashif
7bf9055760 doc: cc3200_launchxl: fixed bullets
Change-Id: I54e1e319e01073b0b717fe66f69b56e11893c12e
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-02-02 15:53:09 +00:00
Johan Hedberg
1387effa86 kernel: Fix k_poll support for k_fifo_put_list
With the recently added k_poll feature, k_fifo_put_list was forgotten
about. Add the necessary code to wake up a k_poll call when
k_fifo_put_list is called.

Change-Id: Ib9baef5ee2bd00620e2eea5afdd81accc4518bd5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-02-02 15:12:36 +00:00
Anas Nashif
0650911a0d samples: philosophers: adjust stack size and build by sanitycheck
Jira: ZEP-1598
Change-Id: I5e2126e946c0a4935d938051acd98702065f458e
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-02-02 14:44:46 +00:00
Anas Nashif
9f004d9b7c drivers: make ethernet init prio depend on NET_L2_ETHERNET
Change-Id: I5e72e7ba53e65e5ebc2b41fa30b84513fe10c998
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-02-02 14:43:51 +00:00
David B. Kinder
65d7ffed5d doc: remove artifacts of doc build recently added
Document building now copies files from the boards/ and samples/
folders into the doc/ folder, but didn't delete these copies after
the build. Remove the copied folders after the docs are built and
include removing these folders in the make clean actions.

Jira: ZEP-1650

Change-Id: Id5f04a53f0d865bd4211138a35852ac8ab115239
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-02-02 13:40:39 +00:00
Benjamin Walsh
ed536245f7 tests: add poll kernel test
Change-Id: I87af7c404b9c77fd82746e5bc2baf4df74d9380c
Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
2017-02-02 00:30:01 +00:00
Benjamin Walsh
acc68c1e59 kernel: add k_poll() API
k_poll() is similar to the POSIX poll() API in spirit in that it allows
a single thread to monitor multiple events without actively polling
them, but rather pending for one or more to become ready. Such events
can be a direct event, or kernel objects (currently only semaphores and
fifos).

When a kernel object being polled on is ready, it is not "given" to the
poller: the poller must then acquire it via the regular API for the
object (e.g. k_sem_take()). Only one thread can poll on a particular
object at one time. These restrictions mean that k_poll() is most
effective when a single thread monitors multiple events that are not
subject for contention. For example, being the sole reader on multiple
fifos, or the only thread being signalled by multiple semaphores, or a
combination of both.

Change-Id: I7035a9baf4aa016fb87afc5f5c0f5f8cb216480f
Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
2017-02-02 00:30:00 +00:00
Benjamin Walsh
fcdb0fd6ea kernel: add _WAIT_Q_INIT()
Dissociate wait queue initialization from doubly-linked lists if the
underlying implementation is to be abstracted.

Change-Id: Id7544c6ac506643437f9c4f0ae97e7eecab8d06d
Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
2017-02-02 00:30:00 +00:00