Commit graph

19237 commits

Author SHA1 Message Date
Andy Ross
24dcb8502c net: tcp: Fix race in net_tcp allocation
Move the IN_USE clear in net_tcp_release() to the END of the function
after the destruction is complete so someone else doesn't allocate it
while we're still cleaning it up.

Also, operations on the IN_USE flag need to be atomic for correctness.
Stick an irq_lock() around them.

Change-Id: I9d7557244fc8de5b0c69fd0bc749a9e28fa19a54
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2016-12-02 12:40:52 +02:00
Andy Ross
63c7565219 net: tcp: Remove dead/stubbed struct elements in struct net_tcp
Big chunks of this struct were essentially unused:

+ The prev_state field was stored at state change but never inspected.

+ The send_wnd, send_max_wnd, send_cwnd, send_pcount and
  send_ss_threshold fields were simply unused.

+ The recv_scale field was never initialized to anything but zero,
  remove the support. Windows greater than 64k seem very unlikely to
  be useful to Zephyr anyway; if we actually want window scaling (in
  either direction -- there are large memory costs!) it should
  probably be optional via Kconfig.  We surely don't want to carry
  this for all builds.

+ The buf_max_len field was hard-coded static, replace with a #define

+ Double-memset of the ack_timer field in initialization

Change-Id: I223665518529dc6a7f267bbc6992a645a30f5735
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2016-12-02 12:40:52 +02:00
Anas Nashif
e6bbc5003c net: do not depend on ARCH
Rename project configuration to be architecture independent and do not use ARCH
in Makefile.

Change-Id: Ic793751e3187bc74fd14cec929754d691b01a799
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-02 12:40:52 +02:00
Andrei Emeltchenko
408d0c2124 wpanusb: Improve debug for wpanusb
Change-Id: I90201df4a50f81cd9a479539826456a6ffb62bb9
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:52 +02:00
Andrei Emeltchenko
9bbfaef4a1 wpan_serial: Implement 802.15.4 serial radio protocol
Implement serial-radio protocol used in Contiki-based border routers
to interact with 802.15.4 devices connected over serial or USB-serial.

Change-Id: I938b34ca32ae7a08e5d48e3bea585cda6c98c113
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:52 +02:00
Andrei Emeltchenko
7b4acbff25 wpanusb: Add wpan radio protocol specification
Change-Id: I4ab00d87de50a9efa5b715649d4b5154e37ce1c0
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:52 +02:00
Andrei Emeltchenko
68e7037104 ieee802154: Correct error logging for cc2520 driver
Change DBG to ERR for error cases to get errors when only errors are
selected.

Change-Id: I51fd15900b1efb96d5dff36367afcdf380f11b88
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:52 +02:00
Andrei Emeltchenko
daefa3d979 ieee802154: Add log domain for CC2520 driver
This prepends logs instead of [general] with [cc2520].

Change-Id: I148159a451981fbe3da638732f0e97900f76bc58
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:40:52 +02:00
Jukka Rissanen
1c3c26a1f9 net: tests: Add TCP unit tests
This provides only initial set of functionality tests
for TCP. More tests are to be written.

Change-Id: I157fed85f561523bf063732ce86eaae551c2d384
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:52 +02:00
Jukka Rissanen
ddda50c214 net: tcp: Initial TCP functionality
This creates initial TCP handling logic but does not yet
enable fully working TCP connection.

Some of the connection logic is taken from FNET TCP
implementation.

Origin: FNET 3.6.1
URL: https://github.com/butok/FNET/blob/master/fnet_stack/stack/fnet_tcp.c

Change-Id: I1e100d9fa9c91437562b933d94d0bd3db1a5885e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:51 +02:00
Ravi kumar Veeramally
ed3dbe1cbf net: Fix typos in nbuf apis
Change-Id: Id89d0d7f1d49a275de0f735a6457fdb6fdad31ea
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:51 +02:00
Luiz Augusto von Dentz
1057c44c65 net: Kconfig: Add NET_NBUF_USER_DATA_SIZE
NET_NBUF_USER_DATA_SIZE can be used to set the user_data size required
by drivers in order to be able to reuse the network data buffer without
copying them.

Change-Id: I198b24ee6d2b8971801c8da40ce008da20bd95c4
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-12-02 12:40:51 +02:00
Jukka Rissanen
54a500a478 net: Add helpers to get sockaddr pointer
This way we avoid ugly casts in the calling code.

Change-Id: I9c949cf22ecd1603e9247a07240de5759bf85463
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:51 +02:00
Jukka Rissanen
a559ad37c2 eth: enc28j60_legacy: Make driver config_info structure const.
Change-Id: Ic3aac209024bd9a6e8456b228705b39e88179b01
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:51 +02:00
Paul Sokolovsky
4de34b3914 net: apps: Fix echo-server where IPv6 TCP context was used instead of IPv4
Apparently a copy-paste error.

Change-Id: I55aac4231384cbd95394f08a4c4f9c717aae5248
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2016-12-02 12:40:51 +02:00
Paul Sokolovsky
be96b7df62 net: Make net_context_get_ip_proto check correct flag.
Apparently, a copy-paste error: NET_CONTEXT_TYPE was used instead of
NET_CONTEXT_PROTO. The corresponding "set" function uses the latter,
so it for "get" too.

Change-Id: Ideb5bfaeb548222a6e64d53b782c9a111e3ef33b
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2016-12-02 12:40:51 +02:00
Ravi kumar Veeramally
c689fd6f1a net: Rename net_nbuf_write to net_nbuf_append
Current net_nbuf_write() api just appends data to last fragment. And
doesn't write data based on offset. That's why renaming this api.

New net_nbuf_write() apis based on offset will be coming soon.

Change-Id: Ie8e13e5f6091a279b62b6d8b0b3928a5187e75b0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:51 +02:00
Ravi kumar Veeramally
28a7df161c net: Fix ARP requests error
Reason for error is ARP message redirected back to ethernet
instead of sending directly.

Call flow:
  ehternet_send()
    net_arp_prepare()
      net_send_data().. which again calls ethernet_send().

So below check is necessary in net_arp_prepare().
"if (ntohs(hdr->type) == NET_ETH_PTYPE_ARP)".

When same buffer used for Tx, it still contains garbage in link
layer header (which is uninitialized). But this check
assumes buffer is ARP and send it immediately.

So first fix is just queue the Tx buf with net_if_queue_tx.
Now only ethernet_send() will call net_arp_prepare(), means
input buffer for net_arp_prepare is not ARP at all. So the check
is not necessary.

Jira: ZEP-1036

Change-Id: I86eaba5ffaa9cabfe43e643b17fa0f9171c4c521
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:51 +02:00
Ravi kumar Veeramally
c90e0ae58c net: Fix slip compilation issue with debug option enabled
Slip context parameter is not used in hexdump and in few places
it is not defined. So CONFIG_SLIP_DEBUG=y throws errors.

Change-Id: I73ca26b7d5cd7c3cd532462b5300e25bbdac9511
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:51 +02:00
Ravi kumar Veeramally
f1cd63c2b1 net: Fix net_nbuf_write buf ref count
net_buf_frag_add() maintains proper refcount. We loose refcount by doing
this "buf->frags = new_data_frag".

Change-Id: I16f9b7f1dc36a8acbc1b6545c42288956cf9d535
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:51 +02:00
Flavio Santes
8d001fa5cb iot/dns: Add support for Arduino 101 and ENC28J60
This commit adds support for the Arduino 101 board with the
ENC28J60 Ethernet module.

Change-Id: Ib852e9cfb2b3b2188d3320e00d6bc24620e187f5
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:40:51 +02:00
Flavio Santes
8b0467a967 iot/dns: Add '+' operator
This commit adds the '+' operator that keeps symmetry with the line
below.

Change-Id: Icb2a5f22b5202597e3e0cc252436b422ce7b44a2
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:40:51 +02:00
Sergio Rodriguez
05aded096e samples/mbedtls_dtlsclient: mbedTLS sample DTLS client app.
This is a sample app using ECJPAKE crypto algorithm on DTLS, using
mbedTLS, and native IP stack

Jira: ZEP-900
Jira: ZEP-943

Change-Id: Ica17b047aab11b989d3e8c8f6ac1b79e3041053a
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
2016-12-02 12:40:51 +02:00
Vinicius Costa Gomes
09b2bb05d0 drivers/slip: Fix circular dependency on NET_SLIP
Fixes this warning:

warning: (NET_SLIP_TUN && NET_SLIP_TAP && NET_SLIP_TUN && NET_SLIP_TAP) selects SLIP which has unmet direct dependencies (NET_SLIP)

Change-Id: Ic51f8403a4de19f90ba4dcdca93877d51dabf787
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:50 +02:00
Vinicius Costa Gomes
516edbf8ac net/yaip: Separate SLIP support into TAP and TUN options
For SLIP under QEMU, there is a choice between using TAP and TUN
interfaces, which have different frame formats. So, it makes sense that
we have different options for each, as they are incompatible.

Change-Id: I43f76391ccf3574da16741b314639427f5c1dd40
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:50 +02:00
Vinicius Costa Gomes
46be4f4907 samples/zoap_client: Use token generator helper
Change-Id: If3dfe80deb8ff753fecae539032399deb15279ee
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:50 +02:00
Vinicius Costa Gomes
ea28e4fccb iot/zoap: Add helper for generating tokens
Most applications will want to use randomly generated tokens, add a
helper for that.

Change-Id: If2a6b1d96596024afd2d2ce8e3632900adfe9c0f
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:50 +02:00
Vinicius Costa Gomes
dc45748d50 iot/zoap: Port to the native stack
This ports zoap to the native stack.

Just for reference, and totally not scientific, here are the numbers
using the old stack:

$ size outdir/qemu_x86/zephyr.elf
   text	   data	    bss	    dec	    hex	filename
  34657	  10316	  16916	  61889	   f1c1	outdir/qemu_x86/zephyr.elf

With yaip:

$ size outdir/qemu_x86/zephyr.elf
   text	   data	    bss	    dec	    hex	filename
  30575	   9148	   6164	  45887	   b33f	outdir/qemu_x86/zephyr.elf

Jira: ZEP-818

Change-Id: I7992a3e2af7d419081ee5a64d7cc2d49fb628ead
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:50 +02:00
Juan Manuel Cruz Alcaraz
92539f21fc enc28j60: Modify echo server and client samples to support enc28j60
Extends the echo server and echo client samples to work with YAIP
network stack with ethernet L2 layer and ENC28J60 ethernet device
on Arduino 101 boards.

Jira: ZEP-859

Change-Id: I242e5555aff18741bf00a551424b081b5396f4b3
Signed-off-by: Juan Manuel Cruz Alcaraz <juan.m.cruz.alcaraz@intel.com>
2016-12-02 12:40:50 +02:00
Juan Manuel Cruz Alcaraz
8d6206c9be enc28j60: Adapt driver for native IP stack
Jira: ZEP-859

Change-Id: I7a073168a2bfba95291e43b227ffb6bfea1f5692
Signed-off-by: Juan Manuel Cruz Alcaraz <juan.m.cruz.alcaraz@intel.com>
2016-12-02 12:40:50 +02:00
Luiz Augusto von Dentz
8c7aa2d085 net: Add TODO item for Bluetooth
Add item for enabling samples with CONFIG_NET_L2_BLUETOOTH.

Change-Id: I2a51c197c2b1cf4a81edb189e86f645de754533b
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-12-02 12:40:50 +02:00
Luiz Augusto von Dentz
83c9da8af8 net: Add initial Bluetooth support using native IP stack
Initial Kconfig and L2 layer support.

Jira: ZEP-992

Change-Id: Ia60316566ea1e535d9cdb3f372c3c46630d0e9c0
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-12-02 12:40:50 +02:00
Vinicius Costa Gomes
f996299754 iot/zoap: Add support for error 4.15
The "Unsupported Content-Format" error was missing from the list of
supported errors.

Change-Id: I208d79f8949838187b877eaa0a53597d8a5bc6cb
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:50 +02:00
Vinicius Costa Gomes
fa5481b1cb zoap: Fix alignment of multiline function arguments
Change-Id: I0a96c87db84671be1790fda34083e7cd53e00cd0
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:50 +02:00
Tomasz Bursztyka
b49d6246b3 net: drivers: slip: Let's cleanup a bit for better readability
Change-Id: I50fef5bb607da600f0c878066312d4b7b2d71d58
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:50 +02:00
Tomasz Bursztyka
37d0958321 net: driver: SLIP does not need to store ll reserve at any time
ll_reserve is given through each buffer to be sent, it is therefore easy
to get it from there.

Change-Id: I8b52fe1b72065f5f58275f939253942f7db1f136
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:50 +02:00
Tomasz Bursztyka
9c70e1ca06 net: drivers: Slip can get the MTU set on it's interface
No need to store the mtu locally as the network interface already holds
it.

Change-Id: I4a1c3d164eefa28622dcb6cd510a66a825c3d9fb
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:50 +02:00
Tomasz Bursztyka
076235c23b net: drivers: SLIP should not reserve anything while receiving
Link Layer reserved space will be handled by relevant L2 layer.

Change-Id: I8e45119adb4de84ba321cad444c11bedef4415e8
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:49 +02:00
Tomasz Bursztyka
3aef2a6f34 net: nbuf: Make sure ll_reserve is not holding previous value
While testing SLIP driver, I found out that after some packets, the
ethernet L2 was getting the eth hdr pointer 14 bytes behind the proper
place. That's because at some point the slip driver got a buf which had
been used already, and thus had a ll_reserve value set from previous
usage. That's bad, so let's make sure ll_reserve is 0 when we take a
buffer. (Note that ll_reserve and reserver_head is much different at
this point).

Change-Id: If68d010775f1093cf087e164968751e3cd634fe3
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:49 +02:00
Tomasz Bursztyka
83c2b85341 net: ethernet: Update the data pointer according to ll reserve
Or then the ip data pointer will still point at the beginning of the
packet, and not after ethernet header.

Change-Id: I24a621e0beb9ac43628eec6234ce7dd2dd939a3f
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:49 +02:00
Vinicius Costa Gomes
7131ab2e43 net: Small simplififcation to net_nbuf_write
The underlying function 'net_nbuf_write_bytes()' was writing one byte
at a time, allowing it to handle multiple bytes at a time is a useful
adition, as it seems the common use case.

Change-Id: Ifa1a906d3ef135b9a48f50f9a9d86875696c5869
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:49 +02:00
Jukka Rissanen
23b0a8856e net: l2: Assert if frag cannot hold ethernet header
Print an error message if the fragment list that we have
gotten from upper layers contains too short fragments.

In this case the issue is not in ethernet.c as it expects
to get full fragments.

Change-Id: I067b7a286a336ab8b7f955a4c3ec0084286eeb9c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:49 +02:00
Ravi kumar Veeramally
bd55cfe420 net: Update TODO for DHCPv4
DHCPv4 client functionality removed as it is done.

Change-Id: I830f1b80911e0aa8006eabbd72f881bcb6182ead
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:49 +02:00
Vinicius Costa Gomes
e505e4641d net: Disable warning about unused label
When CONFIG_NET_ARP is disabled the 'setup_hdr' label is unused. To
avoid warnings during compilation, we can tell the compiler that that
label is unused intentionally.

Change-Id: Iaeed6831cb37cb534bdf23991ee57d4363f238a5
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:49 +02:00
Ravi kumar Veeramally
ead511ddae net: Fix net_nbuf_read corner cases
Valid case:
 1) If the offset is more than current fragment length, adjusts offset
    from next relevant fragment and starts reading or skipping.
 2) If the read or skip length is more than available data length,
    then throw an error.

In case of an error, frag is 'NULL' pos is '0xffff'. Rest of the cases
are successful read and skip.

Change-Id: I88c4b85e14e5821f681966b5148ba9519b91cca4
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:49 +02:00
Ravi kumar Veeramally
e29b00b387 net: Calculate UDP checksum in 6lowpan uncompression
If the received packet checksum is elided and checksum bit is set,
calculate UDP checksum locally.

Change-Id: I53e64d76313b5fad01d708edfc5922e7f7011dbc
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:49 +02:00
Jukka Rissanen
962400f9b1 net: uip: Fix the net_context.h content for legacy stack
The legacy stack has all the net_context API stuff in
net_socket.h so include it in net/net_context.h file.

This re-works the commit 627feb92d4 which added the
net_context_get_internal_connection() to net_context.h.
Now that function prototype is found in net_socket.h.

Change-Id: If22fa63357f4b2e9503f8c9850e69ffda39c61c7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:49 +02:00
Flavio Santes
552dfaeaa7 iot/dns: Add DNS Client sample app
This commit adds the DNS Client sample app on top of the new native
IP stack. This sample app supports IPv4 and IPv6. See README_IPv4 and
README_IPv6 files.

Origin: Original

Jira: ZEP-793
Jira: ZEP-855
Jira: ZEP-975

Change-Id: Id78bd634c44e216fd45b395c91d95b71ef68c976
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:40:49 +02:00
Flavio Santes
36bbd7a935 iot/dns: Add DNS Client support for Zephyr
This commit adds support the DNS client API on top of the new
native IP stack. Some features of this implementation are:

- Support for IPv4 and IPv6
- Support for multiple concurrent queries. A net_buf structure is
  required per context. See the DNS_RESOLVER_ADDITIONAL_BUF_CTR
  configuration variable

Origin: Original

Jira: ZEP-793
Jira: ZEP-855
Jira: ZEP-975

Change-Id: I351a636462a1b78a412c9bce1ef3cd0fa6223a52
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:40:49 +02:00
Flavio Santes
eb03404bce iot/dns: Remove legacy DNS client sample code
This commit removes the legacy DNS client sample code.

This patch is part of a commit series that will add support for
DNS client services on top of the new native IP stack.

Jira: ZEP-793
Jira: ZEP-855
Jira: ZEP-975

Change-Id: Ieb3366b21a365b8f77e576109c64c0fc4218aabb
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:40:49 +02:00