Commit graph

41120 commits

Author SHA1 Message Date
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
Juan Manuel Cruz
ddf447c500 net: arp: Fix issue with compiler optimization on Quark SE x86
On Quark SE x86 core, the usage of the inline funtion: net_nbuf_family
is optimized by the compiler in a way that the ARP verification
of the protocol family fails. This leads the native stack to never
respond to ARP requests.

This commit fixes the issue by recoding the verification flow to get
the family value before the evaluation.

Change-Id: I666d29dff770a3df1a819c4396027e907b137297
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@intel.com>
2016-12-02 12:40:49 +02:00
Ravi kumar Veeramally
712f0c90db net: tests: Add 6lo context based unit tests
Change-Id: I73e18d830d1dcd4f5181b0de74cb7818086504a3
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:48 +02:00
Ravi kumar Veeramally
e68625345a net: Add support for 6lo context based compression
RFC 6282, 3.1.1 (If SAC == 1 and M = 0, DAC = 1).
Source and Destination address compression support if addresses are
based on context based information from Router Advertisement message.

Change-Id: I23a3bf4f111016a8e54be5f0181a113353ad4b88
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:48 +02:00
Ravi kumar Veeramally
2bb8eed501 net: Add more inline helper functions in 6lowpan
6lowpan IPHC compression and uncompression functions are very big and
bit difficult to follow. Added more inline helper routines. No changes
in functionality.

Change-Id: I310e636e2a23fe5f19a254c158b65c6f4d6253b0
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:48 +02:00
Ravi kumar Veeramally
e8f40a970a net: tests: Add sample 6CO context data to IPv6 RA test
Test is only for parsing 6CO data. Nothing more than that.

Change-Id: I7e5851f389216473379a9e50b83dfb03fbe1e68e
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:48 +02:00
Ravi kumar Veeramally
5fbca8a0d2 net: Add support for 6CO
6lowpan context options(CO) are supplied in RA (Router Advertisement)
message. Added support for parsing and cache it. This information
will be used in context based compression and uncompression.

Change-Id: I6e9b5bf02aab3a574ba6a1454232e2d56e855bb0
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:48 +02:00
Ravi kumar Veeramally
2d1475e03b net: Fix ND RA length
Neighbor discovery options length is inclusive of type and length.
It's in multiple of 8 bytes. So actual length is length * 8 - 2.

Change-Id: I628d6b8c0a0b5a4e8b5f6d48cebed3856cb8e4b7
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:48 +02:00
Tomasz Bursztyka
1069d26eae net: Differentiate IPv6 event command and final event
Enum names are colliding with defines, which is bad.

Change-Id: Ia8c003983ddeb1ebed8a9210e682bcb21abfa687
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:48 +02:00
Vinicius Costa Gomes
42c3969ad8 tests/net/nbuf: Fix invalid memory access
The memcmp() could reach after the buffer that is used for verification
ends, which was causing this test to fail on the qemu_cortex_m3 board.

Change-Id: Ia05df823f201d9017acb35c7634fa506389ae9f1
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:48 +02:00
Vinicius Costa Gomes
61bb244ab1 tests/net/nbuf: Fix wrong size to linearize() call
linearize() expects the amount of room available in the buffer.

Change-Id: I1062912f76951758177b7dd6588e7e0ae280dc03
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:48 +02:00
Vinicius Costa Gomes
f2236bb2d7 tests/net: Exclude tests needing more RAM than available
Quark D2000 doesn't not have enough RAM for these tests.

Change-Id: Iba79eaadb15eb8f1eae4bfdbc6865985d3da3fd3
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:48 +02:00
Ravi kumar Veeramally
3ccf24ccab net: Remove assert and return false in net_nbuf_write
In case of invalid parameters return false than NET_ASSERT.
This way we can continue calling net_nbuf_write() and the
function will will cause no ill effects to the net_buf.

Change-Id: I008a044069d26cb8b5971524dd3e1f23f0786926
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:48 +02:00
Jukka Rissanen
5fd1fb05f0 net: Refactor nbuf data fragment detection
Previously the code was using the size of the user data part
to determine whether the buf was a data fragment or RX/TX
buf. This is not enough as we might have a buffer that has
user data but is still allocated from data pool.

This commit changes the detection logic. Now the pool free
pointer is checked against the data pool fifo pointer. If
those match then the buf was allocated from data pool.

Change-Id: I627a960fd2e9cbb7ac8a2e06a914a3ab9596985d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:48 +02:00
Jukka Rissanen
4bf941ee39 net: Re-order fields in net_nbuf struct
Re-ordering fields in struct net_nbuf in order to avoid
holes because of memory alignment.

Change-Id: I5a3ab31a0232003c161fd65848f70d83e07a75c9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:40:48 +02:00
Tomasz Bursztyka
1b7282a986 net: ethernet: Set ll_reserve only when ready
Let's set ll_reserve only when the ethernet header has been verified.

Change-Id: Icd369cd3a84a6d8c98b4df5ca95227d177b12c3d
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:48 +02:00
Tomasz Bursztyka
5e96fa9544 net: ethernet: Drop the packet early when relevant
If PTYPE is unknown, let's drop the packet.

Change-Id: I2fcdd99b01a875e21b2a1952d556f09e40829d2b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:47 +02:00
Tomasz Bursztyka
805e475e9d net: events: Fix a mix up between code and command
Code is actually meant to identify the part in the layer from which the
events originates. Adding or removing an address is a command.

Change-Id: I42b4823d2585b15851c4fdd91802a13d2a5759c1
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:40:47 +02:00