Commit graph

294 commits

Author SHA1 Message Date
Robert Lubos 7b8b09bde4 samples: net: Explicitly ignore socket close return value
Fixes #8994

Coverity ID :187072

Explicitly ignore return value of socket close.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2018-07-18 19:51:17 +03:00
Anas Nashif c8b114f25d samples: exclude socket samples on esp32
ESP32 does not like newlib, exclude for now to get a clean sanitycheck
run. We have issues about this already.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-07-16 19:00:32 -04:00
Robert Lubos f25baebf27 net: samples: Add TLS support to http_get and big_http_download samples
Add config file that enables to run http_get and big_http_download
samples with TLS enabled and receive the data through HTTPS.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2018-07-13 15:03:45 -04:00
Robert Lubos b813502077 samples: net: Socket based echo_server
Echo server sample running on top of network sockets.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2018-06-28 15:18:42 +03:00
Robert Lubos f01b81731b samples: net: Socket based echo_client
Echo client sample running on top of network sockets.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2018-06-28 15:18:42 +03:00
Satya Bhattacharya af70e8f7f0 samples: net: Check the return value of close()
Check the return value of close() in socket_dumb_http.c
If non-zero, print the error code

Fixes #8413.

Signed-off-by: Satya Bhattacharya <satyacube@gmail.com>
2018-06-18 10:47:24 +03:00
Paul Sokolovsky 59309c1a2d samples: sockets: dumb_http_server: Use consistent logging settings
Use logging settings consistent with other samples/net/sockets/ apps
(which includes error logging enabled by default).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-06-11 17:24:54 -04:00
Leandro Pereira e7a3d01dc5 samples: net: dumb_http_server: Handle recv() errors
The recv() call can return errors, so handle them before reading the
received byte.  Unrecoverable errors will just trigger the client
socket to be closed as usual.

Coverity-ID: 182778
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-06-08 13:07:19 -05:00
Paul Sokolovsky 659c241e3a samples: net: big_http_download: Ignore close() return value.
We aren't interested in doing error handling for close(), close()
is itself on error handling path, and its purpose if to free
socket resources.

Coverity-CID: 186062
Fixes: #7713

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-05-29 16:23:46 -04:00
Paul Sokolovsky 0b76b12837 samples: sockets: big_http_download: Update for DHCPv4 support.
Enable CONFIG_NET_DHCPV4, while keeping static IP configuration,
which allows the app to work both with static IP (e.g. when
connected to a workstation without DHCP server) and with DHCP (e.g.
when connected to a router). When using DHCP, getting an address
may take some time, during which getaddrinfo() may fail due to a
timeout. So, add retries for this call.

Tested with qemu_x86 (non-DHCP) and frdm_k64f (both DHCP and
non-DHCP).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-05-18 13:03:44 +03:00
Paul Sokolovsky 092f716020 samples: sockets: dumb_http_server: Disable TIME_WAIT delay
This is required to test the server with ab (ApacheBench), which
itself is an important integration test for the IP stack.

Fixes: #7377

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-05-16 11:03:49 +03:00
Paul Sokolovsky b56b1436ed samples: sockets: Make more errors fatal
In samples, using CHECK() helper macro, make it exist in case of
error. This makes sure that negative value (error indicator) can't
be passed as argument to other function and fixes Coverity reports.

Coverity-CID: 183062
Fixes: #6101

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-05-15 18:14:07 +03:00
Paul Sokolovsky 16a8a309a3 samples: sockets: dumb_http_server: Improve error handling
Check socket function return codes to address Coverity issues.

Coverity-CID: 182771
Fixes: #6100

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-05-15 17:21:08 +03:00
Paul Sokolovsky a3a5c48d93 samples: net: echo_async: Better error and write handling
Initially this sample was intended to be very simple and schematic,
but as this sample going to become a base for stream API conversion,
time to handle all the edge conditions.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-03-02 16:50:41 +01:00
Paul Sokolovsky 8e867378da samples: sockets: echo: Better error and short write handling
Initially this sample was intended to be very simple and schematic,
but as this sample going to become a base for stream API conversion,
time to handle all the edge conditions.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-02-26 10:20:50 -06:00
Kumar Gala d9bd6909c3 samples: dump_http_server: move generated files into include/generated
Move the generated files into include/generated so they live with the
build and not in the zephyr source tree.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-02-21 18:53:23 -05:00
Paul Sokolovsky 7e06be2218 samples: sockets: http_get: Include Host: header in request
The Host header is even mandatory in HTTP 1.1, and indeed without
it, many virtual hosting setups don't work (which are many), so to
be faithful to what README says: "You can edit the source code to
issue a request to any other site on the Internet", let's
complicate the sample by including it.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-02-19 10:39:14 +02:00
Paul Sokolovsky f303e9d115 samples: sockets: Add big_http_download sample
This sample downloads a more or less big file (~6MB as preconfigured)
over HTTP and checks its hash for integrity. It also repeat such a
download indefinitely, counting total number of bytes transferred.

This is thus a kind of traffic load testing sample. (Ported to C
from MicroPython original).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-02-17 09:11:29 -05:00
Paul Sokolovsky bc1a82acc7 samples: net: sockets: Clean up/improve socket samples
With 323e8cf069 applied and printf() working out of the box,
CONFIG_NET_BUF_LOG=y workarounds can be removed from configs of
all samples.

Also, print an intro message at the start of each server sample,
to give a user hint that the app didn't just hang and what to do
next. (The port waiting for connection is printed. We can't (easily)
print host address, because the samples should run on both Zephyr
and POSIX systems, and finding out local host address would require
hairy #ifdef's undermining the purpose of these samples (that is,
showing that the *same* code can be used on both types of systems)).

Fixes: #5379

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-02-11 09:49:31 -05:00
Paul Sokolovsky 166cd7f66d samples: sockets: http_get: More configurability and logging
Make it easy to override HTTP host/port/path. Print URL which we
request and make few other adjustment to the output for clarity.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-02-06 12:57:48 +02:00
Anas Nashif b5b8095749 samples: bluetooth and net samples need test setup
remove build_only and make them depend on test harness (bluetooth)

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-28 20:24:29 -05:00
Anas Nashif 23f81eeb42 tests/samples: fixed yaml syntax
Use a map directory, avoid the list which makes parsing a bit
cumbersome.

Fixes #5109

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-11 14:47:08 -05:00
Paul Sokolovsky ed3ede06e1 samples: net: sockets: Reinstate POSIX Makefiles.
All current socket samples as one of the points show portability to
POSIX platforms, and provide POSIX makefiles to let user build such
a version of application easily. These Makefiles were lost during
CMake conversion.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-11-13 16:41:14 -05:00
Sebastian Bøe 965f78088f samples: dump_http_server: Change where the .inc file is written
KBuild would write the .inc file to the source directory, this was
changed during the CMake migration because whenever possible it should
be avoided to write files outside of the build directory.

But Makefile.posix assumes that these files are generated in the
source directory so we need to keep generating them there for now.

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-13 10:08:41 -05:00
Jukka Rissanen dea2868a82 samples: net: Update compilation instructions for cmake
Update network sample documentation for cmake.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-11-10 11:36:33 -05:00
Sebastian Bøe 0829ddfe9a kbuild: Removed KBuild
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Sebastian Bøe 12f8f76165 Introduce cmake-based rewrite of KBuild
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.

Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.

This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.

For users that just want to continue their work with minimal
disruption the following should suffice:

Install CMake 3.8.2+

Port any out-of-tree Makefiles to CMake.

Learn the absolute minimum about the new command line interface:

$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..

$ cd build
$ make

PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Anas Nashif 0fb51fa849 headers: fix global includes for various source files
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-31 12:32:34 -04:00
Paul Sokolovsky 5cbfa397c5 samples: sockets: dumb_http_server: Use big payload by default
This sends out 2KB+ payload (i.e. guaranteedly more than 1 network
packet). When this sample was initially written, using such payload
quickly let to a deadlock somewhere in the network stack. However
as of now, running with such payload can sustain testing with
"ab -n10000" (10000 consecutive HTTP requests using Apache Bench),
so set is as a default, to serve as a mark point against possible
future regressions.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-10-18 12:38:36 -04:00
David B. Kinder ee71332b99 doc: fix doc misspellings
Found some spelling issues missed during regular PR review

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-10-17 14:31:52 -04:00
Paul Sokolovsky de6fafb701 samples: net: sockets: Print incoming connection number
This helps to debug issues with mass connection handling (e.g. when
issues happen at ~500th connection).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-10-16 11:01:06 +03:00
Anas Nashif 0356590df5 tests: samples: fix yaml syntax
Fix indentation and syntax and make it pass yamllint tool.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-10-15 08:15:00 -04:00
Paul Sokolovsky ef39533365 samples: sockets: Add a dumb HTTP server example
It's dumb, because it doesn't really parse HTTP request, just always
sends the same page in response. Even such, it's useful for socket
load testing with tools like Apache Bench (ab) and for regression
checking in the net subsystem.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-09-22 08:24:36 -04:00
Paul Sokolovsky 4a771bad37 samples: net: sockets: Add HTTP GET example
This example shows usage of client connection and getaddrinfo().

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-09-19 17:39:44 +03:00
Paul Sokolovsky 756e729c00 samples: net: echo_async: Add IPv6 support
The main reason is allowing to run on 6LoWPAN devices, though also to
demonstrate IPv6 support with BSD Sockets in general.

Tested on 96b_carbon.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-08-21 08:40:46 -04:00
Paul Sokolovsky d9af77bfd6 net: sockets: Consistently use "BSD Sockets compatible API" moniker
This is how it's called in the main docs, so use this same phrase in
Kconfig and samples too.

Also, added some articles to docs.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-08-17 12:02:55 -05:00
Paul Sokolovsky e314de5d53 samples: net: sockets: Add READMEs for echo/echo_async samples
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-08-16 16:09:05 -04:00
Johan Hedberg 2975ca0754 Bluetooth: Kconfig: Rename CONFIG_BLUETOOTH_* to CONFIG_BT_*
The API name space for Bluetooth is bt_* and BT_* so it makes sense to
align the Kconfig name space with this. The additional benefit is that
this also makes the names shorter. It is also in line with what Linux
uses for Bluetooth Kconfig entries.

Some Bluetooth-related Networking Kconfig defines are renamed as well
in order to be consistent, such as NET_L2_BLUETOOTH.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-08-09 11:14:19 +03:00
Paul Sokolovsky 5245a686fc samples: net: sockets: Switch to net_app auto-init
Don't call net configuration explicitly, instead rely on net_app
auto init service.

Thus, the only difference between POSIX and Zephyr versions of these
samples are different include files. The application code is 100%
the same.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-08-07 10:13:47 +03:00
Anas Nashif 48b351e34c samples: socket: echo_async unify prj.conf
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-02 07:31:22 -04:00
Anas Nashif 6ca686cc51 samples: socket: echo: unify prj.conf
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-02 07:31:22 -04:00
Anas Nashif ca0ad13a61 net: enable SLIP only on QEMU targets
In many networking tests we had to configure SLIP in the prj.conf
leaving those configurations Qemu specific. This change enables SLIP for
QEMU targets automatically and allows reuse of prj.conf for multiple
boards.

Additionally, the TUN options is removed. This option was not used
anywhere.

To enable self-contained networking tests that do not depend on SLIP, we
introduce the new option NET_TEST which disables TAP and allows testing
in QEMU without the need for a host interface.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-26 10:57:48 -04:00
Paul Sokolovsky 0e5c365f9a samples: net: sockets: Move socket sample(s) under a subdir
It's expected that there will be few socket-based samples, so move
tehm under samples/sockets/ to not clutter the main dir.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-07-18 21:46:56 +03:00
Paul Sokolovsky 00e8309f03 samples: sockets: Add async echo server example
Implements asynchronous TCP echo server using non-blocking sockets
and poll, with concurrent connections support.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-07-18 21:46:06 +03:00