Commit graph

41120 commits

Author SHA1 Message Date
Flavio Santes
a1dc687b5d iot/http: Add test-case for HTTP header fields
This commit adds the following routines:

- test_invalid_header_content
- test_invalid_header_content
- test_invalid_header_field
- test_invalid_header_field
- test_preserve_data
- test_parse_url
- test_method_str
- test_header_nread_value
- test_double_content_length_error
- test_chunked_content_length_error
- test_header_cr_no_lf_error
- test_invalid_header_field_token_error
- test_invalid_header_field_content_error
- test_double_content_length_error
- test_chunked_content_length_error
- test_header_cr_no_lf_error
- test_invalid_header_field_token_error
- test_invalid_header_field_content_error

Origin:
https://github.com/nodejs/http-parser/releases/tag/v2.7.1
https://github.com/nodejs/http-parser/archive/v2.7.1.tar.gz

This patch reformats some http_parser files to reduce checkpatch
warnings.

See:
	https://gitlab.com/santes/http_parser/tree/refactoring1
Commit:
	c58dd8350fdf6ead0807ba37107b19f58e4f434c

Furthermore, method_str overflow test was updated to avoid compiler
warnings on some platforms.

Before:
	Line 627: http_method_str(1337)
After:
	Line 627: http_method_str(127)

Jira: ZEP-346
Jira: ZEP-776

Change-Id: If6163f59de21186f22f4f02d8c44f43ddbf9b59b
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:41:20 +02:00
Flavio Santes
b965fb5ff1 iot: Add HTTP support for Zephyr
This commit adds HTTP message handling support for Zephyr.
So, no network routines are involved at this level.

To add HTTP message handling support for Zephyr, we explored the
following options:

1. Importing an external project and perhaps adapting it to fit our
   requirements.
   The criteria to pick one codebase among all the available projects
   are: licensing, correctness and performance.

2. Writing our own implementation from scratch.

We decided to import an external project instead of implementing our
own parser, mainly due to code maturity and correctness. It could take
more time to obtain a production-ready parser from scratch than adapting
a state-of-art library.

The following is a list of some projects offering similar functionality.

lighttpd (many files)
	* License: revised BSD license
	* Supported: active
	* Comments: this parser can't be integrated to Zephyr due to
	  dependencies that currently are not satisficed by our SDK.

nginx (src/http/ngx_http_parse.c)
	* License: 2-clause BSD-like
	* Supported: very active
	* Comments: this parser can't be integrated to Zephyr due to
	  dependencies that currently are not satisficed by our SDK.

wget (src/http-parse.c)
	* License: GPL 3.0
	* Supported: very active
	* Comments: this code can't be included in Zephyr due to
	  licensing issues

curl (lib/http.c)
	* License: MIT/X derivate, see:
	  https://curl.haxx.se/docs/copyright.html
	* Supported: very active
	* Comment: it must be forked and adapted to run in Zephyr.
	  It is not optimized for low-power devices.

nodejs http-parser (http_parser.c)
	* License: nginx license (2-clause BSD-like) and MIT license
	* Supported: very active
	* Comments: optimized with performance in mind.
	  From https://github.com/nodejs/http-parser: "It does
	  not make any syscalls nor allocations, it does not buffer data,
	  it can be interrupted at anytime. It only requires about 40
	  bytes of data per message stream."

So, nodejs/http-parser looks a very good choice for Zephyr. In this
commit, we integrate nodejs' parser to Zephyr.

Origin: https://github.com/nodejs/http-parser/releases/tag/v2.7.1
        https://github.com/nodejs/http-parser/archive/v2.7.1.tar.gz

NOTE:
	This patch reformats the http_parser files to reduce checkpatch
	warnings. Changes made in this refactoring are available at:
Repo:	https://gitlab.com/santes/http_parser/commits/refactoring1
Commit:	9ccfaa23f1c8438855211fa902ec8e7236b702b1

Jira: ZEP-346
Jira: ZEP-776

Change-Id: I29b1d47f323a5841cd4d0a2afbc2cc83a0f576f0
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:41:20 +02:00
Jukka Rissanen
5ece8c26b5 net: tcp: Fixing the constness of TCP state debug string
Change-Id: I42a8271cf10efcd9ce67ef860a45fa54c0690387
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:20 +02:00
Sergio Rodriguez
e6b5239c33 wpanusb: Fix include path
Commit https://gerrit.zephyrproject.org/r/#/c/6971/ changed the
location of some include files, making compilation fail.

Change-Id: I43c124be28b55e550ef2204ca9faa7031665fb4a
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
2016-12-02 12:41:20 +02:00
Flavio Santes
c2f7c907c9 iot/dns: Update sample client application
This commit updates the dns client application to use the
new kernel API.

Change-Id: Ibf920532b02a1561bfb38f69e5dd994ab21574bc
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:41:20 +02:00
Jukka Rissanen
3eaec41ab8 net: Moved net/ to subsys/net
* Moved networking code into subsys/net.
* Renamed net/yaip to net/ip at the same time.
* Fixed the tests/net to compile
* Fixed the Makefiles and Kconfig files in subsys/net
  to use the new location of the IP stack

Change-Id: Ie45d9e8cb45a93fefdf969b20a81e3b1d3c16355
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:20 +02:00
Andy Ross
01f5fbdadd net: tcp: Add retry handling
Adds a simple retry mechanism on top of the existing queueing
framework.

* On the first packet transmitted with an empty queue, the timer is
  started (to an initial timeout of 200ms).

* On a received, valid ACK, the timer is restarted.

* The timer is stopped whenever the last packet is ACKed and the queue
  becomes empty.

* On timer expiration, the timeout is doubled and the first
  unacknowledged packet is retransmitted.

* When receiving an ACK when we are known to be retransmitting, we
  mark all sent packets as needing to be sent again.

Change-Id: Iee3544ed43d0a2d50c29fa82f958a34cc10f7cda
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:20 +02:00
Jukka Rissanen
481f67e266 net: nbuf: Provide metadata info for sent TCP buf
Create a variable in nbuf metadata area for storing TCP
buf_sent information.

Change-Id: I21a85c58183f1e4997d03d4a93546ddd9b32e977
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:19 +02:00
Andy Ross
ab3b4656f3 net: tcp: Handle received ACK packets correctly
Retain transmitted packets in the queue, and remove them only when a
matching ACK arrives.

Change-Id: I76d6586879dc0499371c52979128bd47e1204132
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:19 +02:00
Andy Ross
1ddb9f94d4 net: tcp: Rework ACK behavior
TCP ACK values aren't known until packet transmission time.  Set the
ACK value then, logging the last one sent for later comparison.

Note that this allows us to effect a neat trick: if your
net_context_send() callback produces a synchronous reply on the
stream, Zephyr can include the ACK in the sent data and not have to
transmit a separate packet.  Traditional OSes with internal queing and
a syscall interface can't do this.

Change-Id: If8b8546dac6163d763b8f8dd75865192f2eb302a
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:19 +02:00
Andy Ross
a93779b041 net: tcp: Refactor "finalize" step from "prepare"
The ACK field of a packet depends on the received sequence number from
the other side of a connection, which can change long after a packet
is prepared/queued.  The IP finalize step (which computes things like
the TCP checksum) needs to be invoked just before a packet is sent,
not from prepare.

Split it out to a separate function.

Change-Id: Ibdae0c9b6833bdfb130cc381f823150dceab6637
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2016-12-02 12:41:19 +02:00
Andy Ross
094c65051c net: tcp: TCP transmission
Hook up TCP transmission through the net_context_send() API.  Queues
packets via a list in the net_buf header, but as of right now simply
transmits the queue synchronously, ignoring the need for retransmit
and the limits of the receive window on the other side.

Requires that the ACK transmission be moved ahead of the net_context
callback invokation.  This to work around a glitch in the way ACKs
work with queueing (they depend on current state, but packets are
assembled just once) that will be fixed in a coming patch.

Change-Id: I7490333e4b314e7734fcc03f2a63d76ae89d698a
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:19 +02:00
Andy Ross
74c3b9a3f4 net: tcp: Fix uninitialized garbage in TCP urgent field
Per spec, this is required to be zero when URG is unset, but we were
never initializing it.  It seems benign AFAICT, but produces warnings
in wireshark.

Change-Id: Ie4e28070e32767aabc60c63bb85287c1215ebb0d
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:19 +02:00
Andy Ross
e5a5f1da95 net: tcp: prepare_segment needs to work with pre-allocated buffers
Transmitted data coming in via net_context_send() must already have an
allocated TX nbuf.  Let prepare_segment() work with one if available,
adding any trailing data to the end of the generated buf chain.

Change-Id: I4f084ce51e6713773a48b8c9c59450656bc87d8e
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2016-12-02 12:41:19 +02:00
Andy Ross
b926166d56 net: Set REMOTE_ADDR_SET flag on new TCP connection contexts
Having this unset hits an error check in net_context_send().  Should
consider making this implicit in the destination address being valid
instead...

Change-Id: I52c273d018c3b780837f40678643255da34b6418
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2016-12-02 12:41:19 +02:00
Andy Ross
17656ecdb6 net: Remove net_tcp_prepare_data_segment
This is dead code in the tree as it stands, and the upcoming rework is
so changed as to make trying to evolve it in place impossible.  Also
removes some temporary tracking fields in the net_tcp and tcp_segment
structs which had been intended for this implementation.

Change-Id: I59fe00cd2d5c3e48bc5d38d3d096d9ff72fcdccf
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:19 +02:00
Jukka Rissanen
51da830b5e samples: zperf: Port to native IP stack
Port the zperf network performance tool to native IP stack.

TCP support is missing from this version.

Change-Id: I2648e7d81014bb0cae8cf50854b0ae5f89a6567c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:19 +02:00
Jukka Rissanen
c07222bcf1 net: icmpv6: Do not set destination ll address
We must not set destination link layer address when generating
ICMPv6 Echo-Reply message. The reason is that the address must
come from neighbor cache right before the reply is sent to the
network.

Jira: ZEP-1360

Change-Id: I32a23f5689107b6827728cce67a5d27fa964ebd2
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:19 +02:00
Jukka Rissanen
79e2178040 samples: net: Do not quit echo-server if sending fails
If we cannot send a network packet, do not quit as that is
really not necessary here.

Change-Id: I7613d46bdbc849b75aaf0fc71c58beba810fd658
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:19 +02:00
Jukka Rissanen
6c02719125 samples: net: Use qemu_x86 config file by default for echo apps
As the default board is qemu_x86, make sure there is similarly
named config file that can be used by default.

Change-Id: Ibc480d3b4eecc2601e3670c8da19be9c01833c36
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:19 +02:00
Jukka Rissanen
2631995fa9 samples: net: Use board specific conf file for echo apps
Use by default a board specific config files for both
echo-server and echo-client sample applications.
This makes more sense than using the network technology specific
config file that was used earlier.

Change-Id: I155fc138f4b0ed1166f4e25267513afc3fb6fd76
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:19 +02:00
Jukka Rissanen
7ebcf7398a samples: net: Remove prj.mdef file from echo sample apps
Change-Id: I6edb869a5998d47338dfb04e7ed8ee1aee8c1cb8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:18 +02:00
Jukka Rissanen
7048c992fb samples: net: Convert the echo apps config files to native stack
Remove legacy stack artifacts from the echo-server and echo-client
config files.

Change-Id: Icc591b9540495c4ee181517369b0df9bb91972bb
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:18 +02:00
Jukka Rissanen
f8bc4864a7 net: todo: Removed already done tasks
Removed already done items related to IPv6, 6LoWPAN, user space
protocols and documentation from the TODO file.

Change-Id: I0d864675c544ae69ad3ef351c0d42680a6a0b4e6
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:18 +02:00
Jukka Rissanen
368ef49331 tests: net: ipv6: Add test for neighbor advertisement
Check that we change the ll address in neighbor cache
properly when receiving NA.

Change-Id: Ib0373751abebdfe1c5e83fd38ec91b9587797e32
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:18 +02:00
Jukka Rissanen
e2a4432e85 tests: net: ipv6: Wrong IP address was added to cache
Peer address is used when sending NS so that it is added
properly to neighbor cache.

Change-Id: I51c2e236a0b137f7ab086a782f3baced13aa3ee3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:18 +02:00
Jukka Rissanen
bd9f9e7cde tests: net: ipv6: Fix prefix test
Also disable prefix lifetime overflow test as it does not work
properly.

Change-Id: I54c8716f6a6d4f5bec76b0a61fe0e18e983924f4
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:18 +02:00
Jukka Rissanen
96f05c334e net: if: Print IPv6 prefix lifetime timeout value
The value is useful debugging information.

Change-Id: I8b0b378299644edb9d887fa3248b3cd821360526
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:18 +02:00
Jukka Rissanen
4aefda34b8 net: ipv6: Make NA sending function public
This is needed so that we can call it from module test
application.

Change-Id: I1e92d1a62af1db823e4f89f30783c94fd7edf324
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:18 +02:00
Jukka Rissanen
76623a5e5a net: ipv6: Fix debug print when DAD fails
Interface pointer was not given in parameter list which
caused garbage to be printed.

Change-Id: If6c4487bb21e0639d5ada283b9e478e5417f18a0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:18 +02:00
Jukka Rissanen
bf5f378311 net: arp: Add ethernet header if it is missing
If we are suppose to send an IPv4 buffer that does not have
ethernet header, then add it here so that the packet can
be sent properly.

Change-Id: If873bd299d7f2d6762a6e593ef69043a9190e976
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:18 +02:00
Jukka Rissanen
b4cba17408 net: Fix stack info collector in net shell
The cc2520 driver RX thread did not like the stack information
collection macros defined in net_core.h. Both the cc2520 TX and
RX got the same variable name which did not compile.
This is now changed so that the first parameter is added to
the variable name to create a unique variable.

Change-Id: Ia41d01a71afd73af2ef31aa5f7a890a3cf0385aa
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:18 +02:00
Jukka Rissanen
bd48a9eca7 net: ipv6: Check extension header No Next Header
If we receive extension 59 (No Next Header), then drop the
packet as we do not support forwarding atm.

Change-Id: I8b1a2a3748f2e88dbf47eb24b732f5edfb9c006c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:18 +02:00
Jukka Rissanen
037f9c5c9e net: Drop IPv4 and IPv6 packet if size is wrong
If the fragment size is different than the value in IP
header, then drop the packet as there is clearly something
wrong in L2 layer. The fragment size must match the value in
protocol headers.

Change-Id: Ibfdb0ab37b3cd4e81e6e03c36beb1e0abfa8c00d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:18 +02:00
Jukka Rissanen
27f624d6f7 net: Check duplicate IPv4 address when adding address
Same IPv4 address can only be added once to the network interface.

Change-Id: I5fb545dd07c11f0e4ed358759ea39afd1334606f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:18 +02:00
Jukka Rissanen
e13ff65c22 net: Check duplicate IPv6 prefix when adding it
Same IPv6 prefix can only be added once to the network interface.

Change-Id: Ib972bb76cf2589d0c873023d1dc2ad49f9b5cf25
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:17 +02:00
Jukka Rissanen
852c117d6f net: Check duplicate IPv6 address when adding address
Same IPv6 address can only be added once to the network interface.

Change-Id: Iabc02ffb4026bdccc46e5b2e7ffee82b3c0a59ea
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:17 +02:00
Jukka Rissanen
4b01094acd net: net_send_data() should not free the net_buf
It is expected that the caller of the net_send_data() function
will release the net_buf or do whatever it wants with it if
there is an error while sending the net_buf.

Change-Id: Id9ddeed3da8b5091c0a8b9d72377f9d12fa76b59
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:17 +02:00
Anas Nashif
47b27514a3 test: net: remove nano/micro tests
Change-Id: I57898f5d9f050a2301504a3df43feb2bd1e6d4fc
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-02 12:41:17 +02:00
Anas Nashif
3d97803c02 tests: net: remove qemu.pid file and bad filters
Change-Id: I26ef207fdebab674a89d54efeb3f4a1a3c4258f6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-02 12:41:17 +02:00
Ruslan Mstoi
fed49c7493 samples: net: enable debugging with qemu target
This enables application debugging using qemu target:

export QEMU_EXTRA_FLAGS="-s -S"
make qemu

Was tested with echo_server

Change-Id: I1906dea2fbc5afe03b11729d2edb8f3629a629f8
Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
2016-12-02 12:41:17 +02:00
Jukka Rissanen
68ea9377e6 net: Make native IP stack the default
As the native IP stack is now the default, there is no need
for corresponding Kconfig option.

Change-Id: I08e4992f540f928a2b7378e8803e634e38725348
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:17 +02:00
Flavio Santes
3c28f9c211 net: Remove legacy IoT sample applications
This commit removes the old MQTT and NATS publisher and subscriber
applications that were based on the uIP stack.

Change-Id: I7ba8e155e32ba0aa53c8dec1b6c0cc5170d70943
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:41:17 +02:00
Jukka Rissanen
6b43821f20 net: Remove legacy Contiki based uIP stack
This commit removes the legacy Contiki based uIP stack.
The new native IP stack must be used after this commit.

The commit also removes following things:
- legacy cc2520 driver
- legacy ethernet drivers
- legacy IP stack samples

and changes these things:
- disabled tests that only work for legacy IP stack
- select new IP stack by default
- enable random number generator by default as it is needed
  by the new IP stack

Change-Id: I1229f9960a4c6654e9ccc6dac14a7efb9394e45d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:17 +02:00
Jukka Rissanen
f2b7492269 ethernet: Add driver initialization priority to Kconfig
The default kernel init priority is too low. Make this
configurable and set the default priority so that the
ethernet driver is started just before the network stack.

This commit adds generic ethernet priority and changes
currently available ethernet drivers to use it.

Change-Id: If695e52b6dd9ea227f10ba306bb145d72d2312b0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:17 +02:00
Mahavir Jain
e12d73e45e ethernet: enc28j60: use unified kernel interface
Remove legacy kernel interface and use unified APIs

Change-Id: I8e99aa5399707a28a326e8abfa8725079de31be6
Signed-off-by: Mahavir Jain <mjain@marvell.com>
2016-12-02 12:41:17 +02:00
Jukka Rissanen
30285fd550 net: ICMPv6 Echo-Reply message was incorrectly setup
We tried to use the received Echo-Request buffer to send
the Echo-Reply. This did not work that well as then the
source link layer address was set to be the same as
destination address by the lower level L2 driver.

Jira: ZEP-1350

Change-Id: I0e7c06866d5b863f091e1d5c2a79dfcc2f23df20
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:17 +02:00
Andrei Emeltchenko
4abf1a26f6 drivers: cc2520: Inform about missing SPI device
Refactor code to exit earlier in case of error.

Change-Id: I9ff893f923ff877d69b0e985bb6e4159504e67cd
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-12-02 12:41:17 +02:00
Jukka Rissanen
0b8e5f3729 net: shell: Print info about active TCP connections
The "net conn" net-shell command will print information
about currently active TCP connections.

Change-Id: I6ef67887997553f4bfad14bcfd4fcde0e062a77b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:16 +02:00
Jukka Rissanen
797b642a61 net: tcp: Add util to loop through all TCP connections
This is to be used in net-shell to view currently active
TCP connections.

Change-Id: I9c2a69e3ab6013835a42dfde47d580623998b3fa
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:16 +02:00