summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorAnas Nashif <nashif@linux.intel.com>2017-02-08 12:03:09 +0000
committerAnas Nashif <nashif@linux.intel.com>2017-02-08 12:03:09 +0000
commit31f01f8ed648193e664afd985f742cfbd3ea90a2 (patch)
tree1c5cfc99b8092adebbf3bd252651c97f2bbb33aa /samples
parenta19d4ad0412d9424c074478b166ffa4a330a3ff2 (diff)
parent7498e22f6e2c65edc009eed0e3c1bc86fbf3f74f (diff)
Merge "Merge net branch into master"
Diffstat (limited to 'samples')
-rw-r--r--samples/bluetooth/ipsp/src/main.c2
-rw-r--r--samples/net/coaps_client/src/udp.c4
-rw-r--r--samples/net/coaps_server/src/udp.c4
-rw-r--r--samples/net/echo_client/prj_arduino_101_cc2520.conf10
-rw-r--r--samples/net/echo_client/prj_cc2520.conf4
-rw-r--r--samples/net/echo_client/prj_frdm_k64f_cc2520.conf10
-rw-r--r--samples/net/echo_client/prj_frdm_k64f_mcr20a.conf2
-rw-r--r--samples/net/echo_client/prj_qemu_802154.conf2
-rw-r--r--samples/net/echo_client/src/Makefile2
-rw-r--r--samples/net/echo_client/src/echo-client.c5
-rw-r--r--samples/net/echo_server/prj_arduino_101_cc2520.conf10
-rw-r--r--samples/net/echo_server/prj_cc2520.conf4
-rw-r--r--samples/net/echo_server/prj_frdm_k64f_cc2520.conf10
-rw-r--r--samples/net/echo_server/prj_frdm_k64f_mcr20a.conf2
-rw-r--r--samples/net/echo_server/prj_qemu_802154.conf2
-rw-r--r--samples/net/echo_server/src/Makefile2
-rw-r--r--samples/net/echo_server/src/echo-server.c8
-rw-r--r--samples/net/http_client/Makefile10
-rw-r--r--samples/net/http_client/README.rst229
-rw-r--r--samples/net/http_client/prj_frdm_k64f.conf34
-rw-r--r--samples/net/http_client/src/Makefile11
-rw-r--r--samples/net/http_client/src/config.h74
-rw-r--r--samples/net/http_client/src/http_client.c158
-rw-r--r--samples/net/http_client/src/http_client.h38
-rw-r--r--samples/net/http_client/src/http_client_cb.c133
-rw-r--r--samples/net/http_client/src/http_client_cb.h38
-rw-r--r--samples/net/http_client/src/http_client_rcv.c101
-rw-r--r--samples/net/http_client/src/http_client_rcv.h15
-rw-r--r--samples/net/http_client/src/http_client_types.h28
-rw-r--r--samples/net/http_client/src/main.c128
-rw-r--r--samples/net/http_client/src/tcp_client.c162
-rw-r--r--samples/net/http_client/src/tcp_client.h31
-rw-r--r--samples/net/http_client/testcase.ini4
-rw-r--r--samples/net/http_server/src/http_write_utils.c10
-rw-r--r--samples/net/ieee802154/hw/prj.conf4
-rw-r--r--samples/net/ieee802154/hw/prj_mcr20a.conf2
-rw-r--r--samples/net/ieee802154/hw/src/ieee802154_test.c8
-rw-r--r--samples/net/ieee802154/qemu/prj.conf2
-rw-r--r--samples/net/ieee802154/qemu/src/ieee802154_qemu_test.c2
-rw-r--r--samples/net/irc_bot/src/irc-bot.c6
-rw-r--r--samples/net/irc_bot/testcase.ini4
-rw-r--r--samples/net/leds_demo/prj_802154.conf2
-rw-r--r--samples/net/leds_demo/src/leds-demo.c16
-rw-r--r--samples/net/mbedtls_dtlsclient/src/udp.c4
-rw-r--r--samples/net/mbedtls_dtlsserver/src/udp.c4
-rw-r--r--samples/net/mbedtls_sslclient/Makefile4
-rw-r--r--samples/net/mbedtls_sslclient/prj_arduino_101.conf34
-rw-r--r--samples/net/mbedtls_sslclient/src/tcp.c4
-rw-r--r--samples/net/wpan_serial/prj.conf2
-rw-r--r--samples/net/wpan_serial/src/Makefile2
-rw-r--r--samples/net/wpan_serial/src/main.c10
-rw-r--r--samples/net/wpanusb/prj.conf4
-rw-r--r--samples/net/wpanusb/src/Makefile8
-rw-r--r--samples/net/wpanusb/src/wpanusb.c15
-rw-r--r--samples/net/zoap_client/src/zoap-client.c4
-rw-r--r--samples/net/zoap_server/prj_cc2520.conf2
-rw-r--r--samples/net/zoap_server/src/zoap-server.c40
-rw-r--r--samples/net/zperf/prj_quark_se_c1000_devboard.conf2
-rw-r--r--samples/net/zperf/src/zperf_tcp_uploader.c11
-rw-r--r--samples/net/zperf/src/zperf_udp_receiver.c4
-rw-r--r--samples/net/zperf/src/zperf_udp_uploader.c18
61 files changed, 1376 insertions, 129 deletions
diff --git a/samples/bluetooth/ipsp/src/main.c b/samples/bluetooth/ipsp/src/main.c
index 378dca0c7..e29b95cce 100644
--- a/samples/bluetooth/ipsp/src/main.c
+++ b/samples/bluetooth/ipsp/src/main.c
@@ -145,7 +145,7 @@ static struct net_buf *build_reply_buf(const char *name,
printk("%s received %d bytes", name,
net_nbuf_appdatalen(buf));
- reply_buf = net_nbuf_get_tx(context);
+ reply_buf = net_nbuf_get_tx(context, K_FOREVER);
recv_len = net_buf_frags_len(buf->frags);
diff --git a/samples/net/coaps_client/src/udp.c b/samples/net/coaps_client/src/udp.c
index 1da593e84..b2c8e3799 100644
--- a/samples/net/coaps_client/src/udp.c
+++ b/samples/net/coaps_client/src/udp.c
@@ -58,12 +58,12 @@ int udp_tx(void *context, const unsigned char *buf, size_t size)
udp_ctx = ctx->net_ctx;
- send_buf = net_nbuf_get_tx(udp_ctx);
+ send_buf = net_nbuf_get_tx(udp_ctx, K_FOREVER);
if (!send_buf) {
return MBEDTLS_ERR_SSL_ALLOC_FAILED;
}
- rc = net_nbuf_append(send_buf, size, (uint8_t *) buf);
+ rc = net_nbuf_append(send_buf, size, (uint8_t *) buf, K_FOREVER);
if (!rc) {
return MBEDTLS_ERR_SSL_INTERNAL_ERROR;
}
diff --git a/samples/net/coaps_server/src/udp.c b/samples/net/coaps_server/src/udp.c
index f2a7081db..76cd1500e 100644
--- a/samples/net/coaps_server/src/udp.c
+++ b/samples/net/coaps_server/src/udp.c
@@ -47,13 +47,13 @@ int udp_tx(void *context, const unsigned char *buf, size_t size)
net_ctx = ctx->net_ctx;
- send_buf = net_nbuf_get_tx(net_ctx);
+ send_buf = net_nbuf_get_tx(net_ctx, K_FOREVER);
if (!send_buf) {
printk("cannot create buf\n");
return -EIO;
}
- rc = net_nbuf_append(send_buf, size, (uint8_t *) buf);
+ rc = net_nbuf_append(send_buf, size, (uint8_t *) buf, K_FOREVER);
if (!rc) {
printk("cannot write buf\n");
return -EIO;
diff --git a/samples/net/echo_client/prj_arduino_101_cc2520.conf b/samples/net/echo_client/prj_arduino_101_cc2520.conf
index 70cfd90d5..4a5a3e072 100644
--- a/samples/net/echo_client/prj_arduino_101_cc2520.conf
+++ b/samples/net/echo_client/prj_arduino_101_cc2520.conf
@@ -36,8 +36,8 @@ CONFIG_NET_L2_IEEE802154_ORFD=y
CONFIG_NET_L2_IEEE802154_FRAGMENT=y
CONFIG_NET_DEBUG_L2_IEEE802154_FRAGMENT=y
-CONFIG_TI_CC2520=y
-CONFIG_TI_CC2520_AUTO_ACK=y
+CONFIG_IEEE802154_CC2520=y
+CONFIG_IEEE802154_CC2520_AUTO_ACK=y
CONFIG_SYS_LOG_IEEE802154_DRIVER_LEVEL=1
CONFIG_GPIO=y
@@ -47,6 +47,6 @@ CONFIG_SPI_1=y
CONFIG_SPI_CS_GPIO=y
CONFIG_SPI_1_CS_GPIO_PORT="GPIO_0"
CONFIG_SPI_1_CS_GPIO_PIN=0
-CONFIG_TI_CC2520_SPI_DRV_NAME="SPI_1"
-CONFIG_TI_CC2520_SPI_FREQ=4
-CONFIG_TI_CC2520_SPI_SLAVE=1 \ No newline at end of file
+CONFIG_IEEE802154_CC2520_SPI_DRV_NAME="SPI_1"
+CONFIG_IEEE802154_CC2520_SPI_FREQ=4
+CONFIG_IEEE802154_CC2520_SPI_SLAVE=1 \ No newline at end of file
diff --git a/samples/net/echo_client/prj_cc2520.conf b/samples/net/echo_client/prj_cc2520.conf
index 71edb1c9c..86ae60956 100644
--- a/samples/net/echo_client/prj_cc2520.conf
+++ b/samples/net/echo_client/prj_cc2520.conf
@@ -38,8 +38,8 @@ CONFIG_NET_L2_IEEE802154_ORFD=y
CONFIG_NET_L2_IEEE802154_FRAGMENT=y
CONFIG_NET_DEBUG_L2_IEEE802154_FRAGMENT=y
-CONFIG_TI_CC2520=y
-CONFIG_TI_CC2520_AUTO_ACK=y
+CONFIG_IEEE802154_CC2520=y
+CONFIG_IEEE802154_CC2520_AUTO_ACK=y
CONFIG_SYS_LOG_IEEE802154_DRIVER_LEVEL=1
CONFIG_NET_SAMPLES_IP_ADDRESSES=y
diff --git a/samples/net/echo_client/prj_frdm_k64f_cc2520.conf b/samples/net/echo_client/prj_frdm_k64f_cc2520.conf
index 2f34f5659..e47274194 100644
--- a/samples/net/echo_client/prj_frdm_k64f_cc2520.conf
+++ b/samples/net/echo_client/prj_frdm_k64f_cc2520.conf
@@ -42,12 +42,12 @@ CONFIG_SPI_0=y
CONFIG_SYS_LOG_SPI_LEVEL=1
-CONFIG_TI_CC2520=y
-CONFIG_TI_CC2520_AUTO_ACK=y
+CONFIG_IEEE802154_CC2520=y
+CONFIG_IEEE802154_CC2520_AUTO_ACK=y
CONFIG_SYS_LOG_IEEE802154_DRIVER_LEVEL=1
-CONFIG_TI_CC2520_SPI_DRV_NAME="SPI_0"
-CONFIG_TI_CC2520_SPI_FREQ=4000000
-CONFIG_TI_CC2520_SPI_SLAVE=0
+CONFIG_IEEE802154_CC2520_SPI_DRV_NAME="SPI_0"
+CONFIG_IEEE802154_CC2520_SPI_FREQ=4000000
+CONFIG_IEEE802154_CC2520_SPI_SLAVE=0
CONFIG_NET_SAMPLES_IP_ADDRESSES=y
CONFIG_NET_SAMPLES_MY_IPV6_ADDR="2001:db8::1"
diff --git a/samples/net/echo_client/prj_frdm_k64f_mcr20a.conf b/samples/net/echo_client/prj_frdm_k64f_mcr20a.conf
index c5f2e455f..ac8f07499 100644
--- a/samples/net/echo_client/prj_frdm_k64f_mcr20a.conf
+++ b/samples/net/echo_client/prj_frdm_k64f_mcr20a.conf
@@ -40,7 +40,7 @@ CONFIG_GPIO=y
CONFIG_SPI=y
CONFIG_SPI_0=y
-CONFIG_NXP_MCR20A=y
+CONFIG_IEEE802154_MCR20A=y
CONFIG_SYS_LOG_IEEE802154_DRIVER_LEVEL=1
CONFIG_NET_SAMPLES_IP_ADDRESSES=y
diff --git a/samples/net/echo_client/prj_qemu_802154.conf b/samples/net/echo_client/prj_qemu_802154.conf
index dd67ac581..d4ea56f5d 100644
--- a/samples/net/echo_client/prj_qemu_802154.conf
+++ b/samples/net/echo_client/prj_qemu_802154.conf
@@ -40,7 +40,7 @@ CONFIG_NET_L2_IEEE802154_ORFD=y
CONFIG_NET_L2_IEEE802154_FRAGMENT=y
CONFIG_NET_DEBUG_L2_IEEE802154_FRAGMENT=y
-CONFIG_UPIPE_15_4=y
+CONFIG_IEEE802154_UPIPE=y
CONFIG_SYS_LOG_IEEE802154_DRIVER_LEVEL=1
CONFIG_NET_SAMPLES_IP_ADDRESSES=y
diff --git a/samples/net/echo_client/src/Makefile b/samples/net/echo_client/src/Makefile
index 8802055a5..a05869c93 100644
--- a/samples/net/echo_client/src/Makefile
+++ b/samples/net/echo_client/src/Makefile
@@ -1,6 +1,6 @@
obj-y = echo-client.o
-ifeq ($(CONFIG_TI_CC2520),y)
+ifeq ($(CONFIG_IEEE802154_CC2520),y)
ifeq ($(CONFIG_BOARD_ARDUINO_101),y)
ccflags-y +=-I${ZEPHYR_BASE}/include/drivers/
diff --git a/samples/net/echo_client/src/echo-client.c b/samples/net/echo_client/src/echo-client.c
index 67cd58514..06f4ceafc 100644
--- a/samples/net/echo_client/src/echo-client.c
+++ b/samples/net/echo_client/src/echo-client.c
@@ -364,11 +364,12 @@ static struct net_buf *prepare_send_buf(const char *name,
struct net_buf *send_buf;
bool status;
- send_buf = net_nbuf_get_tx(context);
+ send_buf = net_nbuf_get_tx(context, K_FOREVER);
NET_ASSERT(send_buf);
- status = net_nbuf_append(send_buf, expecting_len, lorem_ipsum);
+ status = net_nbuf_append(send_buf, expecting_len, lorem_ipsum,
+ K_FOREVER);
if (!status) {
NET_ERR("%s: cannot create send buf", name);
return NULL;
diff --git a/samples/net/echo_server/prj_arduino_101_cc2520.conf b/samples/net/echo_server/prj_arduino_101_cc2520.conf
index 70cfd90d5..4a5a3e072 100644
--- a/samples/net/echo_server/prj_arduino_101_cc2520.conf
+++ b/samples/net/echo_server/prj_arduino_101_cc2520.conf
@@ -36,8 +36,8 @@ CONFIG_NET_L2_IEEE802154_ORFD=y
CONFIG_NET_L2_IEEE802154_FRAGMENT=y
CONFIG_NET_DEBUG_L2_IEEE802154_FRAGMENT=y
-CONFIG_TI_CC2520=y
-CONFIG_TI_CC2520_AUTO_ACK=y
+CONFIG_IEEE802154_CC2520=y
+CONFIG_IEEE802154_CC2520_AUTO_ACK=y
CONFIG_SYS_LOG_IEEE802154_DRIVER_LEVEL=1
CONFIG_GPIO=y
@@ -47,6 +47,6 @@ CONFIG_SPI_1=y
CONFIG_SPI_CS_GPIO=y
CONFIG_SPI_1_CS_GPIO_PORT="GPIO_0"
CONFIG_SPI_1_CS_GPIO_PIN=0
-CONFIG_TI_CC2520_SPI_DRV_NAME="SPI_1"
-CONFIG_TI_CC2520_SPI_FREQ=4
-CONFIG_TI_CC2520_SPI_SLAVE=1 \ No newline at end of file
+CONFIG_IEEE802154_CC2520_SPI_DRV_NAME="SPI_1"
+CONFIG_IEEE802154_CC2520_SPI_FREQ=4
+CONFIG_IEEE802154_CC2520_SPI_SLAVE=1 \ No newline at end of file
diff --git a/samples/net/echo_server/prj_cc2520.conf b/samples/net/echo_server/prj_cc2520.conf
index aa4e9bed8..7159d4a8d 100644
--- a/samples/net/echo_server/prj_cc2520.conf
+++ b/samples/net/echo_server/prj_cc2520.conf
@@ -38,8 +38,8 @@ CONFIG_NET_L2_IEEE802154_ORFD=y
CONFIG_NET_L2_IEEE802154_FRAGMENT=y
#CONFIG_NET_DEBUG_L2_IEEE802154_FRAGMENT=y
-CONFIG_TI_CC2520=y
-CONFIG_TI_CC2520_AUTO_ACK=y
+CONFIG_IEEE802154_CC2520=y
+CONFIG_IEEE802154_CC2520_AUTO_ACK=y
CONFIG_SYS_LOG_IEEE802154_DRIVER_LEVEL=1
CONFIG_NET_SAMPLES_IP_ADDRESSES=y
diff --git a/samples/net/echo_server/prj_frdm_k64f_cc2520.conf b/samples/net/echo_server/prj_frdm_k64f_cc2520.conf
index a913a06e0..7fbf67414 100644
--- a/samples/net/echo_server/prj_frdm_k64f_cc2520.conf
+++ b/samples/net/echo_server/prj_frdm_k64f_cc2520.conf
@@ -42,12 +42,12 @@ CONFIG_SPI_0=y
CONFIG_SYS_LOG_SPI_LEVEL=1
-CONFIG_TI_CC2520=y
-CONFIG_TI_CC2520_AUTO_ACK=y
+CONFIG_IEEE802154_CC2520=y
+CONFIG_IEEE802154_CC2520_AUTO_ACK=y
CONFIG_SYS_LOG_IEEE802154_DRIVER_LEVEL=1
-CONFIG_TI_CC2520_SPI_DRV_NAME="SPI_0"
-CONFIG_TI_CC2520_SPI_FREQ=4000000
-CONFIG_TI_CC2520_SPI_SLAVE=0
+CONFIG_IEEE802154_CC2520_SPI_DRV_NAME="SPI_0"
+CONFIG_IEEE802154_CC2520_SPI_FREQ=4000000
+CONFIG_IEEE802154_CC2520_SPI_SLAVE=0
CONFIG_NET_SAMPLES_IP_ADDRESSES=y
CONFIG_NET_SAMPLES_MY_IPV6_ADDR="2001:db8::2"
diff --git a/samples/net/echo_server/prj_frdm_k64f_mcr20a.conf b/samples/net/echo_server/prj_frdm_k64f_mcr20a.conf
index e8f8d2ff0..724420b43 100644
--- a/samples/net/echo_server/prj_frdm_k64f_mcr20a.conf
+++ b/samples/net/echo_server/prj_frdm_k64f_mcr20a.conf
@@ -39,7 +39,7 @@ CONFIG_GPIO=y
CONFIG_SPI=y
CONFIG_SPI_0=y
-CONFIG_NXP_MCR20A=y
+CONFIG_IEEE802154_MCR20A=y
CONFIG_SYS_LOG_IEEE802154_DRIVER_LEVEL=1
CONFIG_NET_SAMPLES_IP_ADDRESSES=y
diff --git a/samples/net/echo_server/prj_qemu_802154.conf b/samples/net/echo_server/prj_qemu_802154.conf
index b42b67ca0..0e2157e02 100644
--- a/samples/net/echo_server/prj_qemu_802154.conf
+++ b/samples/net/echo_server/prj_qemu_802154.conf
@@ -40,7 +40,7 @@ CONFIG_NET_L2_IEEE802154_ORFD=y
CONFIG_NET_L2_IEEE802154_FRAGMENT=y
CONFIG_NET_DEBUG_L2_IEEE802154_FRAGMENT=y
-CONFIG_UPIPE_15_4=y
+CONFIG_IEEE802154_UPIPE=y
CONFIG_SYS_LOG_IEEE802154_DRIVER_LEVEL=1
CONFIG_NET_SAMPLES_IP_ADDRESSES=y
diff --git a/samples/net/echo_server/src/Makefile b/samples/net/echo_server/src/Makefile
index c4dd7f726..3f8b03393 100644
--- a/samples/net/echo_server/src/Makefile
+++ b/samples/net/echo_server/src/Makefile
@@ -1,6 +1,6 @@
obj-y = echo-server.o
-ifeq ($(CONFIG_TI_CC2520),y)
+ifeq ($(CONFIG_IEEE802154_CC2520),y)
ifeq ($(CONFIG_BOARD_ARDUINO_101),y)
ccflags-y +=-I${ZEPHYR_BASE}/include/drivers/
diff --git a/samples/net/echo_server/src/echo-server.c b/samples/net/echo_server/src/echo-server.c
index 4d6b2c3b2..fb3deecbd 100644
--- a/samples/net/echo_server/src/echo-server.c
+++ b/samples/net/echo_server/src/echo-server.c
@@ -271,7 +271,7 @@ static struct net_buf *build_reply_buf(const char *name,
return NULL;
}
- reply_buf = net_nbuf_get_tx(context);
+ reply_buf = net_nbuf_get_tx(context, K_FOREVER);
NET_ASSERT(reply_buf);
@@ -292,7 +292,7 @@ static struct net_buf *build_reply_buf(const char *name,
net_buf_pull(tmp, header_len);
while (tmp) {
- frag = net_nbuf_get_data(context);
+ frag = net_nbuf_get_data(context, K_FOREVER);
if (!net_buf_headroom(tmp)) {
/* If there is no link layer headers in the
@@ -429,8 +429,8 @@ static void tcp_received(struct net_context *context,
void *user_data)
{
static char dbg[MAX_DBG_PRINT + 1];
- sa_family_t family = net_nbuf_family(buf);
struct net_buf *reply_buf;
+ sa_family_t family;
int ret;
if (!buf) {
@@ -438,6 +438,8 @@ static void tcp_received(struct net_context *context,
return;
}
+ family = net_nbuf_family(buf);
+
snprintk(dbg, MAX_DBG_PRINT, "TCP IPv%c",
family == AF_INET6 ? '6' : '4');
diff --git a/samples/net/http_client/Makefile b/samples/net/http_client/Makefile
new file mode 100644
index 000000000..f9767a77f
--- /dev/null
+++ b/samples/net/http_client/Makefile
@@ -0,0 +1,10 @@
+#
+# Copyright (c) 2017 Intel Corporation
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+BOARD ?= frdm_k64f
+CONF_FILE ?= prj_$(BOARD).conf
+
+include $(ZEPHYR_BASE)/Makefile.inc
diff --git a/samples/net/http_client/README.rst b/samples/net/http_client/README.rst
new file mode 100644
index 000000000..e3df1da85
--- /dev/null
+++ b/samples/net/http_client/README.rst
@@ -0,0 +1,229 @@
+HTTP Client
+###########
+
+Overview
+********
+
+This sample application shows how to create HTTP 1.1 requests to
+an HTTP server and how to parse the incoming responses.
+Supported HTTP 1.1 methods are: GET, HEAD, OPTIONS and POST.
+
+The source code for this sample application can be found at:
+:file:`samples/net/http_client`.
+
+Requirements
+************
+
+- Freedom Board (FRDM-K64F)
+- LAN for testing purposes (Ethernet)
+- Terminal emulator software
+- HTTP Server
+
+Building and Running
+********************
+
+Open the project configuration file for your platform, for example:
+:file:`prj_frdm_k64f.conf` is the configuration file for the
+:ref:`frdm_k64f` board. For IPv4 networks, set the following variables:
+
+.. code-block:: console
+
+ CONFIG_NET_IPV4=y
+ CONFIG_NET_IPV6=n
+
+IPv6 is the preferred routing technology for this sample application,
+if CONFIG_NET_IPV6=y is set, the value of CONFIG_NET_IPV4=y is ignored.
+
+In this sample application, only static IP addresses are supported,
+those addresses are specified in the project configuration file,
+for example:
+
+.. code-block:: console
+
+ CONFIG_NET_SAMPLES_MY_IPV6_ADDR="2001:db8::1"
+ CONFIG_NET_SAMPLES_PEER_IPV6_ADDR="2001:db8::2"
+
+are the IPv6 addresses for the HTTP client running Zephyr and the
+HTTP server, respectively.
+
+Alternatively, the IP addresses may be specified in the
+:file:`src/config.h` file.
+
+Open the :file:`src/config.h` file and set the server port
+to match the HTTP server setup, for example:
+
+.. code-block:: c
+
+ #define SERVER_PORT 80
+
+assumes that the HTTP server is listening at the TCP port 80.
+
+HTTP Server
+===========
+
+Setting up an HTTP server on your host computer is beyond the scope
+of this document.
+(We used `Apache 2 <http://httpd.apache.org/docs/2.4/getting-started.html>`_
+for testing this sample application.
+
+However, this application assumes that there is a server's
+resource that can process an HTTP 1.1 POST request.
+
+For example, assuming that the Apache 2 server with PHP support
+is used, and that the client sends a POST request with
+"Content-Type = application/x-www-form-urlencoded" the following
+PHP script will echo the POST payload back to the client:
+
+.. code-block:: html
+
+ <html>
+ <head>
+ <title>HTTP Server POST test</title>
+ </head>
+ <body>
+ <?php
+ echo '<p>POST key/values:</p>';
+ foreach ($_POST as $key => $value) {
+ echo "<p> {$key} : {$value} </p>";
+ }
+ ?>
+ </body>
+ </html>
+
+In the machine hosting the HTTP server, this php script is at
+:file:`/var/www/html/post_test.php`. However, for your test machine
+this path can be different, but should be at your server's root folder.
+
+HTTP Responses
+==============
+
+Server's responses are processed by the http_receive_cb routine
+defined inside the :file:`src/http_client_rcv.c` file.
+
+This sample application only prints the HTTP header fields via
+the HTTP Parser Library, see :file:`include/net/http_parser.h`.
+To process the HTTP response's body, use the HTTP Parser's callbacks
+to determine where the body begins. Depending on the payload's size,
+it may be necessary to traverse the network buffer's fragment chain.
+See the :file:`src/http_client_rcv.c` file at line 70 for sample code
+that shows how to walk the fragment chain.
+
+FRDM K64F
+=========
+
+Open a terminal window and type:
+
+.. code-block:: console
+
+ $ make BOARD=frdm_k64f
+
+The FRDM K64F board is detected as a USB storage device. The board
+must be mounted (i.e. to /mnt) to 'flash' the binary:
+
+.. code-block:: console
+
+ $ cp outdir/frdm_k64f/zephyr.bin /mnt
+
+On Linux, use the 'dmesg' program to find the right USB device for the
+FRDM serial console. Assuming that this device is ttyACM0, open a
+terminal window and type:
+
+.. code-block:: console
+
+ $ screen /dev/ttyACM0 115200
+
+Once the binary is loaded into the FRDM board, press the RESET button.
+
+Refer to the board documentation in Zephyr, :ref:`frdm_k64f`,
+for more information about this board and how to access the FRDM
+serial console under other operating systems.
+
+Sample Output
+=============
+
+This sample application loops a specified number of times doing four
+HTTP 1.1 requests and displays the header fields that were extracted
+from the server's response. The four requests are:
+
+- GET "/index.html"
+- HEAD "/"
+- OPTIONS "/"
+- POST "/post_test.php"
+
+The terminal window where screen is running will show something similar
+to the following:
+
+.. code-block:: console
+
+ *******************************************
+ HTTP Client: 2001:db8::1
+ Connecting to: 2001:db8::2 port 80
+ Hostname: 2001:db8::2
+ HTTP Request: GET
+
+ --------- HTTP response (headers) ---------
+ Date: Thu, 02 Feb 2017 00:51:31 GMT
+ Server: Apache/2.4.10 (Debian)
+ Last-Modified: Sat, 28 Jan 2017 02:55:09 GMT
+ ETag: "3c-5471eb5db3c73"
+ Accept-Ranges: bytes
+ Content-Length: 60
+ Connection: close
+ Content-Type: text/html
+
+ HTTP server response status: OK
+ HTTP parser status: success
+ HTTP body: 60 bytes, expected: 60 bytes
+
+ *******************************************
+ HTTP Client: 2001:db8::1
+ Connecting to: 2001:db8::2 port 80
+ Hostname: 2001:db8::2
+ HTTP Request: HEAD
+
+ --------- HTTP response (headers) ---------
+ Date: Thu, 02 Feb 2017 00:51:37 GMT
+ Server: Apache/2.4.10 (Debian)
+ Last-Modified: Sat, 28 Jan 2017 02:55:09 GMT
+ ETag: "3c-5471eb5db3c73"
+ Accept-Ranges: bytes
+ Content-Length: 60
+ Connection: close
+ Content-Type: text/html
+
+ HTTP server response status: OK
+ HTTP parser status: success
+
+ *******************************************
+ HTTP Client: 2001:db8::1
+ Connecting to: 2001:db8::2 port 80
+ Hostname: 2001:db8::2
+ HTTP Request: OPTIONS
+
+ --------- HTTP response (headers) ---------
+ Date: Thu, 02 Feb 2017 00:51:43 GMT
+ Server: Apache/2.4.10 (Debian)
+ Allow: GET,HEAD,POST,OPTIONS
+ Content-Length: 0
+ Connection: close
+ Content-Type: text/html
+
+ HTTP server response status: OK
+ HTTP parser status: success
+
+ *******************************************
+ HTTP Client: 2001:db8::1
+ Connecting to: 2001:db8::2 port 80
+ Hostname: 2001:db8::2
+ HTTP Request: POST
+
+ --------- HTTP response (headers) ---------
+ Date: Thu, 02 Feb 2017 00:51:49 GMT
+ Server: Apache/2.4.10 (Debian)
+ Vary: Accept-Encoding
+ Content-Length: 231
+ Connection: close
+ Content-Type: text/html; charset=UTF-8
+
+ HTTP server response status: OK
+ HTTP parser status: success
diff --git a/samples/net/http_client/prj_frdm_k64f.conf b/samples/net/http_client/prj_frdm_k64f.conf
new file mode 100644
index 000000000..c2f4410b1
--- /dev/null
+++ b/samples/net/http_client/prj_frdm_k64f.conf
@@ -0,0 +1,34 @@
+CONFIG_RANDOM_GENERATOR=y
+
+CONFIG_NETWORKING=y
+CONFIG_NET_TCP=y
+CONFIG_NET_ARP=y
+CONFIG_NET_L2_ETHERNET=y
+
+CONFIG_NET_IPV6_RA_RDNSS=y
+CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3
+
+CONFIG_NET_NBUF_RX_COUNT=64
+CONFIG_NET_NBUF_TX_COUNT=64
+CONFIG_NET_NBUF_DATA_COUNT=16
+
+CONFIG_NET_IPV4=n
+CONFIG_NET_IPV6=y
+
+CONFIG_HTTP_PARSER=y
+CONFIG_STDOUT_CONSOLE=y
+
+# Set the IP addresses here or in the
+# src/config.h file
+#
+CONFIG_NET_SAMPLES_IP_ADDRESSES=y
+CONFIG_NET_SAMPLES_MY_IPV6_ADDR="2001:db8::1"
+CONFIG_NET_SAMPLES_PEER_IPV6_ADDR="2001:db8::2"
+CONFIG_NET_SAMPLES_MY_IPV4_ADDR="192.168.1.101"
+CONFIG_NET_SAMPLES_PEER_IPV4_ADDR="192.168.1.10"
+
+#CONFIG_MAIN_STACK_SIZE=8192
+
+# See the config.h file and the LINEARIZE_BUFFER define
+#
+#CONFIG_NET_NBUF_DATA_SIZE=512
diff --git a/samples/net/http_client/src/Makefile b/samples/net/http_client/src/Makefile
new file mode 100644
index 000000000..32a9e074c
--- /dev/null
+++ b/samples/net/http_client/src/Makefile
@@ -0,0 +1,11 @@
+#
+# Copyright (c) 2017 Intel Corporation
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+obj-y += main.o
+obj-y += tcp_client.o
+obj-y += http_client.o
+obj-y += http_client_rcv.o
+obj-y += http_client_cb.o
diff --git a/samples/net/http_client/src/config.h b/samples/net/http_client/src/config.h
new file mode 100644
index 000000000..40523329b
--- /dev/null
+++ b/samples/net/http_client/src/config.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2017 Intel Corporation
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <net/net_ip.h>
+
+#define APP_NAP_TIME 3000
+
+#define HTTP_POOL_BUF_CTR 4
+#define HTTP_POOL_BUF_SIZE 1024
+#define HTTP_STATUS_STR_SIZE 32
+
+/* server port */
+#define SERVER_PORT 80
+/* rx tx timeout */
+#define HTTP_NETWORK_TIMEOUT 300
+
+#ifdef CONFIG_NET_SAMPLES_IP_ADDRESSES
+#ifdef CONFIG_NET_IPV6
+#define LOCAL_ADDR CONFIG_NET_SAMPLES_MY_IPV6_ADDR
+#define SERVER_ADDR CONFIG_NET_SAMPLES_PEER_IPV6_ADDR
+#else
+#define LOCAL_ADDR CONFIG_NET_SAMPLES_MY_IPV4_ADDR
+#define SERVER_ADDR CONFIG_NET_SAMPLES_PEER_IPV4_ADDR
+#endif
+#else
+#ifdef CONFIG_NET_IPV6
+#define LOCAL_ADDR "2001:db8::1"
+#define SERVER_ADDR "2001:db8::2"
+#else
+#define LOCAL_ADDR "192.168.1.101"
+#define SERVER_ADDR "192.168.1.10"
+#endif
+#endif /* CONFIG */
+
+/* It seems enough to hold 'Content-Length' and its value */
+#define CON_LEN_SIZE 48
+
+/* Default HTTP Header Field values for HTTP Requests */
+#define ACCEPT "text/plain"
+#define ACCEPT_ENC "identity"
+#define ACCEPT_LANG "en-US"
+#define CONNECTION "Close"
+#define USER_AGENT "ZephyrHTTPClient/1.7"
+#define HOST_NAME SERVER_ADDR /* or example.com, www.example.com */
+
+#define HEADER_FIELDS "Accept: "ACCEPT"\r\n" \
+ "Accept-Encoding: "ACCEPT_ENC"\r\n" \
+ "Accept-Language: "ACCEPT_LANG"\r\n" \
+ "User-Agent: "USER_AGENT"\r\n" \
+ "Host: "HOST_NAME"\r\n" \
+ "Connection: "CONNECTION"\r\n"
+
+/* Parsing and token tracking becomes a bit complicated if the
+ * RX buffer is fragmented. for example: an HTTP response with
+ * header fields that lie in two fragments. So, here we have
+ * two options:
+ *
+ * - Use the fragmented buffer, but increasing the fragment size
+ * - Linearize the buffer, it works better but consumes more memory
+ *
+ * Comment the following define to test the first case, set the
+ * CONFIG_NET_NBUF_DATA_SIZE variable to 384 or 512. See the
+ * prj_frdm_k64f.conf file.
+ */
+#define LINEARIZE_BUFFER
+
+#ifndef LINEARIZE_BUFFER
+#if CONFIG_NET_NBUF_DATA_SIZE <= 256
+#error set CONFIG_NET_NBUF_DATA_SIZE to 384 or 512
+#endif
+#endif
diff --git a/samples/net/http_client/src/http_client.c b/samples/net/http_client/src/http_client.c
new file mode 100644
index 000000000..5ae15713e
--- /dev/null
+++ b/samples/net/http_client/src/http_client.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2017 Intel Corporation
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include "http_client.h"
+#include "http_client_rcv.h"
+#include "http_client_cb.h"
+#include "config.h"
+
+#include <misc/printk.h>
+#include <net/nbuf.h>
+
+int http_init(struct http_client_ctx *http_ctx)
+{
+ memset(http_ctx, 0, sizeof(struct http_client_ctx));
+
+ http_ctx->settings.on_body = on_body;
+ http_ctx->settings.on_chunk_complete = on_chunk_complete;
+ http_ctx->settings.on_chunk_header = on_chunk_header;
+ http_ctx->settings.on_headers_complete = on_headers_complete;
+ http_ctx->settings.on_header_field = on_header_field;
+ http_ctx->settings.on_header_value = on_header_value;
+ http_ctx->settings.on_message_begin = on_message_begin;
+ http_ctx->settings.on_message_complete = on_message_complete;
+ http_ctx->settings.on_status = on_status;
+ http_ctx->settings.on_url = on_url;
+
+ return 0;
+}
+
+int http_reset_ctx(struct http_client_ctx *http_ctx)
+{
+ http_parser_init(&http_ctx->parser, HTTP_RESPONSE);
+
+ memset(http_ctx->http_status, 0, sizeof(http_ctx->http_status));
+
+ http_ctx->cl_present = 0;
+ http_ctx->content_length = 0;
+ http_ctx->processed = 0;
+ http_ctx->body_found = 0;
+
+ return 0;
+}
+
+static
+int http_send_request(struct http_client_ctx *http_ctx, const char *method,
+ const char *url, const char *protocol,
+ const char *content_type_value, const char *payload)
+{
+ const char *content_type = "Content-Type: ";
+ const char *sep = "\r\n\r\n";
+ struct net_buf *tx;
+ int rc;
+
+ tx = net_nbuf_get_tx(http_ctx->tcp_ctx.net_ctx, K_FOREVER);
+ if (tx == NULL) {
+ return -ENOMEM;
+ }
+
+ if (!net_nbuf_append(tx, strlen(method), (uint8_t *)method,
+ K_FOREVER)) {
+ goto lb_exit;
+ }
+
+ if (!net_nbuf_append(tx, strlen(url), (uint8_t *)url, K_FOREVER)) {
+ goto lb_exit;
+ }
+
+ if (!net_nbuf_append(tx, strlen(protocol), (uint8_t *)protocol,
+ K_FOREVER)) {
+ goto lb_exit;
+ }
+
+ if (!net_nbuf_append(tx, strlen(HEADER_FIELDS),
+ (uint8_t *)HEADER_FIELDS, K_FOREVER)) {
+ goto lb_exit;
+ }
+
+ if (content_type_value && payload) {
+ char content_len_str[CON_LEN_SIZE];
+
+ if (!net_nbuf_append(tx, strlen(content_type),
+ (uint8_t *)content_type, K_FOREVER)) {
+ rc = -ENOMEM;
+ goto lb_exit;
+ }
+
+ if (!net_nbuf_append(tx, strlen(content_type_value),
+ (uint8_t *)content_type_value,
+ K_FOREVER)) {
+ rc = -ENOMEM;
+ goto lb_exit;
+ }
+
+ rc = snprintk(content_len_str, sizeof(content_len_str),
+ "\r\nContent-Length: %u\r\n\r\n",
+ strlen(payload));
+ if (rc <= 0 || rc >= sizeof(content_len_str)) {
+ rc = -ENOMEM;
+ goto lb_exit;
+ }
+
+ if (!net_nbuf_append(tx, strlen(content_len_str),
+ (uint8_t *)content_len_str, K_FOREVER)) {
+ rc = -ENOMEM;
+ goto lb_exit;
+ }
+
+ if (!net_nbuf_append(tx, strlen(payload), (uint8_t *)payload,
+ K_FOREVER)) {
+ rc = -ENOMEM;
+ goto lb_exit;
+ }
+
+ } else {
+ if (!net_nbuf_append(tx, strlen(sep), (uint8_t *)sep,
+ K_FOREVER)) {
+ rc = -ENOMEM;
+ goto lb_exit;
+ }
+ }
+
+ return net_context_send(tx, NULL, http_ctx->tcp_ctx.timeout,
+ NULL, NULL);
+
+lb_exit:
+ net_buf_unref(tx);
+
+ return rc;
+}
+
+int http_send_get(struct http_client_ctx *http_ctx, const char *url)
+{
+ return http_send_request(http_ctx, "GET ", url, " HTTP/1.1\r\n",
+ NULL, NULL);
+}
+
+int http_send_head(struct http_client_ctx *http_ctx, const char *url)
+{
+ return http_send_request(http_ctx, "HEAD ", url, " HTTP/1.1\r\n",
+ NULL, NULL);
+}
+
+int http_send_options(struct http_client_ctx *http_ctx, const char *url,
+ const char *content_type_value, const char *payload)
+{
+ return http_send_request(http_ctx, "OPTIONS ", url, " HTTP/1.1\r\n",
+ content_type_value, payload);
+}
+
+int http_send_post(struct http_client_ctx *http_ctx, const char *url,
+ const char *content_type_value, const char *payload)
+{
+ return http_send_request(http_ctx, "POST ", url, " HTTP/1.1\r\n",
+ content_type_value, payload);
+}
diff --git a/samples/net/http_client/src/http_client.h b/samples/net/http_client/src/http_client.h
new file mode 100644
index 000000000..9096dfda0
--- /dev/null
+++ b/samples/net/http_client/src/http_client.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017 Intel Corporation
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef _HTTP_CLIENT_H_
+#define _HTTP_CLIENT_H_
+
+#include "http_client_types.h"
+
+int http_init(struct http_client_ctx *http_ctx);
+
+int http_reset_ctx(struct http_client_ctx *http_ctx);
+
+/* Reception callback executed by the IP stack */
+void http_receive_cb(struct tcp_client_ctx *tcp_ctx, struct net_buf *rx);
+
+/* Sends an HTTP GET request for URL url */
+int http_send_get(struct http_client_ctx *ctx, const char *url);
+
+/* Sends an HTTP HEAD request for URL url */
+int http_send_head(struct http_client_ctx *ctx, const char *url);
+
+/* Sends an HTTP OPTIONS request for URL url. From RFC 2616:
+ * If the OPTIONS request includes an entity-body (as indicated by the
+ * presence of Content-Length or Transfer-Encoding), then the media type
+ * MUST be indicated by a Content-Type field.
+ * Note: Transfer-Encoding is not yet supported.
+ */
+int http_send_options(struct http_client_ctx *http_ctx, const char *url,
+ const char *content_type_value, const char *payload);
+
+/* Sends an HTTP POST request for URL url with payload as content */
+int http_send_post(struct http_client_ctx *http_ctx, const char *url,
+ const char *content_type_value, const char *payload);
+
+#endif
diff --git a/samples/net/http_client/src/http_client_cb.c b/samples/net/http_client/src/http_client_cb.c
new file mode 100644
index 000000000..21368fdb8
--- /dev/null
+++ b/samples/net/http_client/src/http_client_cb.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2017 Intel Corporation
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include "http_client_cb.h"
+#include "http_client_types.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#define MAX_NUM_DIGITS 16
+
+int on_url(struct http_parser *parser, const char *at, size_t length)
+{
+ ARG_UNUSED(parser);
+
+ printf("URL: %.*s\n", length, at);
+
+ return 0;
+}
+
+int on_status(struct http_parser *parser, const char *at, size_t length)
+{
+ struct http_client_ctx *ctx;
+ uint16_t len;
+
+ ARG_UNUSED(parser);
+
+ ctx = CONTAINER_OF(parser, struct http_client_ctx, parser);
+ len = min(length, sizeof(ctx->http_status) - 1);
+ memcpy(ctx->http_status, at, len);
+ ctx->http_status[len] = 0;
+
+ return 0;
+}
+
+int on_header_field(struct http_parser *parser, const char *at, size_t length)
+{
+ char *content_len = "Content-Length";
+ struct http_client_ctx *ctx;
+ uint16_t len;
+
+ ctx = CONTAINER_OF(parser, struct http_client_ctx, parser);
+
+ len = strlen(content_len);
+ if (length >= len && memcmp(at, content_len, len) == 0) {
+ ctx->cl_present = 1;
+ }
+
+ printf("%.*s: ", length, at);
+
+ return 0;
+}
+
+int on_header_value(struct http_parser *parser, const char *at, size_t length)
+{
+ struct http_client_ctx *ctx;
+ char str[MAX_NUM_DIGITS];
+
+ ctx = CONTAINER_OF(parser, struct http_client_ctx, parser);
+
+ if (ctx->cl_present) {
+ if (length <= MAX_NUM_DIGITS - 1) {
+ long int num;
+
+ memcpy(str, at, length);
+ str[length] = 0;
+ num = strtol(str, NULL, 10);
+ if (num == LONG_MIN || num == LONG_MAX) {
+ return -EINVAL;
+ }
+
+ ctx->content_length = num;
+ }
+
+ ctx->cl_present = 0;
+ }
+
+ printf("%.*s\n", length, at);
+
+ return 0;
+}
+
+int on_body(struct http_parser *parser, const char *at, size_t length)
+{
+ struct http_client_ctx *ctx;
+
+ ctx = CONTAINER_OF(parser, struct http_client_ctx, parser);
+
+ ctx->body_found = 1;
+ ctx->processed += length;
+
+ return 0;
+}
+
+int on_headers_complete(struct http_parser *parser)
+{
+ ARG_UNUSED(parser);
+
+ return 0;
+}
+
+int on_message_begin(struct http_parser *parser)
+{
+ ARG_UNUSED(parser);
+
+ printf("\n--------- HTTP response (headers) ---------\n");
+
+ return 0;
+}
+
+int on_message_complete(struct http_parser *parser)
+{
+ ARG_UNUSED(parser);
+
+ return 0;
+}
+
+int on_chunk_header(struct http_parser *parser)
+{
+ ARG_UNUSED(parser);
+
+ return 0;
+}
+
+int on_chunk_complete(struct http_parser *parser)
+{
+ ARG_UNUSED(parser);
+
+ return 0;
+}
diff --git a/samples/net/http_client/src/http_client_cb.h b/samples/net/http_client/src/http_client_cb.h
new file mode 100644
index 000000000..457ee15e8
--- /dev/null
+++ b/samples/net/http_client/src/http_client_cb.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2017 Intel Corporation
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef _HTTP_CLIENT_CB_H_
+#define _HTTP_CLIENT_CB_H_
+
+#include <net/http_parser.h>
+
+/*
+ * This are the callbacks executed by the parser. Some of them
+ * are only useful when parsing requests (or responses).
+ * Unused callbacks may be removed.
+ */
+
+int on_url(struct http_parser *parser, const char *at, size_t length);
+
+int on_status(struct http_parser *parser, const char *at, size_t length);
+
+int on_header_field(struct http_parser *parser, const char *at, size_t length);
+
+int on_header_value(struct http_parser *parser, const char *at, size_t length);
+
+int on_body(struct http_parser *parser, const char *at, size_t length);
+
+int on_headers_complete(struct http_parser *parser);
+
+int on_message_begin(struct http_parser *parser);
+
+int on_message_complete(struct http_parser *parser);
+
+int on_chunk_header(struct http_parser *parser);
+
+int on_chunk_complete(struct http_parser *parser);
+
+#endif
diff --git a/samples/net/http_client/src/http_client_rcv.c b/samples/net/http_client/src/http_client_rcv.c
new file mode 100644
index 000000000..5c6a220dc
--- /dev/null
+++ b/samples/net/http_client/src/http_client_rcv.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2017 Intel Corporation
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include "http_client_rcv.h"
+#include "http_client_types.h"
+#include "config.h"
+
+#include <net/nbuf.h>
+
+#ifdef LINEARIZE_BUFFER
+
+NET_BUF_POOL_DEFINE(http_pool, HTTP_POOL_BUF_CTR, HTTP_POOL_BUF_SIZE, 0, NULL);
+
+void http_receive_cb(struct tcp_client_ctx *tcp_ctx, struct net_buf *rx)
+{
+ struct http_client_ctx *http_ctx;
+ struct net_buf *data_buf = NULL;
+ uint16_t data_len;
+ uint16_t offset;
+ int rc;
+
+ if (!rx) {
+ return;
+ }
+
+ data_buf = net_buf_alloc(&http_pool, tcp_ctx->timeout);
+ if (data_buf == NULL) {
+ goto lb_exit;
+ }
+
+ data_len = min(net_nbuf_appdatalen(rx), HTTP_POOL_BUF_SIZE);
+ offset = net_buf_frags_len(rx) - data_len;
+
+ rc = net_nbuf_linear_copy(data_buf, rx, offset, data_len);
+ if (rc != 0) {
+ rc = -ENOMEM;
+ goto lb_exit;
+ }
+
+ http_ctx = CONTAINER_OF(tcp_ctx, struct http_client_ctx, tcp_ctx);
+
+ /* The parser's error can be catched outside, reading the
+ * http_errno struct member
+ */
+ http_parser_execute(&http_ctx->parser, &http_ctx->settings,
+ data_buf->data, data_buf->len);
+
+lb_exit:
+ net_buf_unref(data_buf);
+ net_buf_unref(rx);
+}
+
+#else
+
+void http_receive_cb(struct tcp_client_ctx *tcp_ctx, struct net_buf *rx)
+{
+ struct http_client_ctx *http_ctx;
+ struct net_buf *buf = rx;
+ uint16_t offset;
+
+ if (!rx) {
+ return;
+ }
+
+ http_ctx = CONTAINER_OF(tcp_ctx, struct http_client_ctx, tcp_ctx);
+
+ offset = net_buf_frags_len(buf) - net_nbuf_appdatalen(buf);
+
+ /* find the fragment */
+ while (buf && offset >= buf->len) {
+ offset -= buf->len;
+ buf = buf->frags;
+ }
+
+ while (buf) {
+ (void)http_parser_execute(&http_ctx->parser,
+ &http_ctx->settings,
+ buf->data + offset,
+ buf->len - offset);
+
+ /* after the first iteration, we set offset to 0 */
+ offset = 0;
+
+ /* The parser's error can be catched outside, reading the
+ * http_errno struct member
+ */
+ if (http_ctx->parser.http_errno != HPE_OK) {
+ goto lb_exit;
+ }
+
+ buf = buf->frags;
+ }
+
+lb_exit:
+ net_buf_unref(rx);
+}
+
+#endif
diff --git a/samples/net/http_client/src/http_client_rcv.h b/samples/net/http_client/src/http_client_rcv.h
new file mode 100644
index 000000000..d75d9708e
--- /dev/null
+++ b/samples/net/http_client/src/http_client_rcv.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2017 Intel Corporation
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef _HTTP_CLIENT_RCV_H_
+#define _HTTP_CLIENT_RCV_H_
+
+#include "tcp_client.h"
+
+/* HTTP reception callback */
+void http_receive_cb(struct tcp_client_ctx *tcp_ctx, struct net_buf *rx);
+
+#endif
diff --git a/samples/net/http_client/src/http_client_types.h b/samples/net/http_client/src/http_client_types.h
new file mode 100644
index 000000000..16032607e
--- /dev/null
+++ b/samples/net/http_client/src/http_client_types.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017 Intel Corporation
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef _HTTP_CLIENT_TYPES_H_
+#define _HTTP_CLIENT_TYPES_H_
+
+#include <net/http_parser.h>
+#include "tcp_client.h"
+#include "config.h"
+
+struct http_client_ctx {
+ struct http_parser parser;
+ struct http_parser_settings settings;
+
+ struct tcp_client_ctx tcp_ctx;
+
+ uint32_t content_length;
+ uint32_t processed;
+ char http_status[HTTP_STATUS_STR_SIZE];
+
+ uint8_t cl_present:1;
+ uint8_t body_found:1;
+};
+
+#endif
diff --git a/samples/net/http_client/src/main.c b/samples/net/http_client/src/main.c
new file mode 100644
index 000000000..520728421
--- /dev/null
+++ b/samples/net/http_client/src/main.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2017 Intel Corporation
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <zephyr.h>
+#include <errno.h>
+#include <misc/printk.h>
+
+#include "http_client_types.h"
+#include "http_client.h"
+#include "config.h"
+
+#define POST_CONTENT_TYPE "application/x-www-form-urlencoded"
+#define POST_PAYLOAD "os=ZephyrRTOS&arch="CONFIG_ARCH
+
+#define MAX_ITERATIONS 100
+
+static struct http_client_ctx http_ctx;
+
+static void send_http_method(enum http_method method, const char *url,
+ const char *content_type, const char *payload);
+
+void main(void)
+{
+ int i = MAX_ITERATIONS;
+ int rc;
+
+ http_init(&http_ctx);
+ http_ctx.tcp_ctx.receive_cb = http_receive_cb;
+ http_ctx.tcp_ctx.timeout = HTTP_NETWORK_TIMEOUT;
+
+ rc = tcp_set_local_addr(&http_ctx.tcp_ctx, LOCAL_ADDR);
+ if (rc) {
+ printk("tcp_set_local_addr error\n");
+ goto lb_exit;
+ }
+
+ while (i-- > 0) {
+ send_http_method(HTTP_GET, "/index.html", NULL, NULL);
+ k_sleep(APP_NAP_TIME);
+
+ send_http_method(HTTP_HEAD, "/", NULL, NULL);
+ k_sleep(APP_NAP_TIME);
+
+ send_http_method(HTTP_OPTIONS, "/index.html", NULL, NULL);
+ k_sleep(APP_NAP_TIME);
+
+ send_http_method(HTTP_POST, "/post_test.php",
+ POST_CONTENT_TYPE, POST_PAYLOAD);
+ k_sleep(APP_NAP_TIME);
+ }
+
+lb_exit:
+ printk("\nBye!\n");
+}
+
+void print_banner(enum http_method method)
+{
+ printk("\n*******************************************\n"
+ "HTTP Client: %s\nConnecting to: %s port %d\n"
+ "Hostname: %s\nHTTP Request: %s\n",
+ LOCAL_ADDR, SERVER_ADDR, SERVER_PORT,
+ HOST_NAME, http_method_str(method));
+}
+
+static
+void send_http_method(enum http_method method, const char *url,
+ const char *content_type, const char *payload)
+{
+ int rc;
+
+ print_banner(method);
+
+ http_reset_ctx(&http_ctx);
+
+ rc = tcp_connect(&http_ctx.tcp_ctx, SERVER_ADDR, SERVER_PORT);
+ if (rc) {
+ printk("tcp_connect error\n");
+ return;
+ }
+
+ switch (method) {
+ case HTTP_GET:
+ rc = http_send_get(&http_ctx, url);
+ break;
+ case HTTP_POST:
+ rc = http_send_post(&http_ctx, url, content_type, payload);
+ break;
+ case HTTP_HEAD:
+ rc = http_send_head(&http_ctx, url);
+ break;
+ case HTTP_OPTIONS:
+ rc = http_send_options(&http_ctx, url, NULL, NULL);
+ break;
+ default:
+ printk("Not yet implemented\n");
+ goto lb_exit;
+ }
+
+ if (rc) {
+ printk("Send error\n");
+ goto lb_exit;
+ }
+
+ /* this is async, so we wait until the reception callback
+ * processes the server's response (if any)
+ */
+ k_sleep(APP_NAP_TIME);
+
+ printk("\nHTTP server response status: %s\n", http_ctx.http_status);
+
+ printk("HTTP parser status: %s\n",
+ http_errno_description(http_ctx.parser.http_errno));
+
+ if (method == HTTP_GET) {
+ if (http_ctx.body_found) {
+ printk("HTTP body: %u bytes, expected: %u bytes\n",
+ http_ctx.processed, http_ctx.content_length);
+ } else {
+ printk("Error detected during HTTP msg processing\n");
+ }
+ }
+
+lb_exit:
+ tcp_disconnect(&http_ctx.tcp_ctx);
+}
diff --git a/samples/net/http_client/src/tcp_client.c b/samples/net/http_client/src/tcp_client.c
new file mode 100644
index 000000000..43403f46d
--- /dev/null
+++ b/samples/net/http_client/src/tcp_client.c
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2017 Intel Corporation
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include "tcp_client.h"
+#include "config.h"
+
+#include <net/net_core.h>
+#include <net/net_if.h>
+#include <net/nbuf.h>
+
+#include <misc/printk.h>
+
+static
+int set_addr(struct sockaddr *sock_addr, const char *addr, uint16_t server_port)
+{
+ void *ptr = NULL;
+ int rc;
+
+#ifdef CONFIG_NET_IPV6
+ net_sin6(sock_addr)->sin6_port = htons(server_port);
+ sock_addr->family = AF_INET6;
+ ptr = &(net_sin6(sock_addr)->sin6_addr);
+ rc = net_addr_pton(AF_INET6, addr, ptr);
+#else
+ net_sin(sock_addr)->sin_port = htons(server_port);
+ sock_addr->family = AF_INET;
+ ptr = &(net_sin(sock_addr)->sin_addr);
+ rc = net_addr_pton(AF_INET, addr, ptr);
+#endif
+ if (rc) {
+ printk("Invalid IP address: %s\n", addr);
+ }
+
+ return rc;
+}
+
+static
+int if_addr_add(struct sockaddr *local_sock)
+{
+ void *p = NULL;
+
+#ifdef CONFIG_NET_IPV6
+ p = net_if_ipv6_addr_add(net_if_get_default(),
+ &net_sin6(local_sock)->sin6_addr,
+ NET_ADDR_MANUAL, 0);
+#else
+ p = net_if_ipv4_addr_add(net_if_get_default(),
+ &net_sin(local_sock)->sin_addr,
+ NET_ADDR_MANUAL, 0);
+#endif
+ if (p) {
+ return 0;
+ }
+
+ return -EINVAL;
+}
+
+int tcp_set_local_addr(struct tcp_client_ctx *ctx, const char *local_addr)
+{
+ int rc;
+
+ rc = set_addr(&ctx->local_sock, local_addr, 0);
+ if (rc) {
+ printk("set_addr (local) error\n");
+ goto lb_exit;
+ }
+
+ rc = if_addr_add(&ctx->local_sock);
+ if (rc) {
+ printk("if_addr_add error\n");
+ }
+
+lb_exit:
+ return rc;
+}
+
+static
+void recv_cb(struct net_context *net_ctx, struct net_buf *rx, int status,
+ void *data)
+{
+ struct tcp_client_ctx *ctx = (struct tcp_client_ctx *)data;
+
+ ARG_UNUSED(net_ctx);
+
+ if (status) {
+ return;
+ }
+
+ if (rx == NULL || net_nbuf_appdatalen(rx) == 0) {
+ goto lb_exit;
+ }
+
+ /* receive_cb must take ownership of the rx buffer */
+ if (ctx->receive_cb) {
+ ctx->receive_cb(ctx, rx);
+ return;
+ }
+
+lb_exit:
+ net_buf_unref(rx);
+}
+
+int tcp_connect(struct tcp_client_ctx *ctx, const char *server_addr,
+ uint16_t server_port)
+{
+#if CONFIG_NET_IPV6
+ socklen_t addr_len = sizeof(struct sockaddr_in6);
+ sa_family_t family = AF_INET6;
+#else
+ socklen_t addr_len = sizeof(struct sockaddr_in);
+ sa_family_t family = AF_INET;
+#endif
+ struct sockaddr server_sock;
+ int rc;
+
+ rc = net_context_get(family, SOCK_STREAM, IPPROTO_TCP, &ctx->net_ctx);
+ if (rc) {
+ printk("net_context_get error\n");
+ return rc;
+ }
+
+ rc = net_context_bind(ctx->net_ctx, &ctx->local_sock, addr_len);
+ if (rc) {
+ printk("net_context_bind error\n");
+ goto lb_exit;
+ }
+
+ rc = set_addr(&server_sock, server_addr, server_port);
+ if (rc) {
+ printk("set_addr (server) error\n");
+ goto lb_exit;
+ }
+
+ rc = net_context_connect(ctx->net_ctx, &server_sock, addr_len, NULL,
+ ctx->timeout, NULL);
+ if (rc) {
+ printk("net_context_connect error\n");
+ goto lb_exit;
+ }
+
+ (void)net_context_recv(ctx->net_ctx, recv_cb, K_NO_WAIT, ctx);
+
+ return 0;
+
+lb_exit:
+ net_context_put(ctx->net_ctx);
+
+ return rc;
+}
+
+int tcp_disconnect(struct tcp_client_ctx *ctx)
+{
+ if (ctx->net_ctx) {
+ net_context_put(ctx->net_ctx);
+ ctx->net_ctx = NULL;
+ }
+
+ return 0;
+}
diff --git a/samples/net/http_client/src/tcp_client.h b/samples/net/http_client/src/tcp_client.h
new file mode 100644
index 000000000..581321c35
--- /dev/null
+++ b/samples/net/http_client/src/tcp_client.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017 Intel Corporation
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef _TCP_CLIENT_H_
+#define _TCP_CLIENT_H_
+
+#include <net/net_context.h>
+#include <net/net_ip.h>
+
+struct tcp_client_ctx {
+ /* IP stack network context */
+ struct net_context *net_ctx;
+ /* Local sock address */
+ struct sockaddr local_sock;
+ /* Network timeout */
+ int32_t timeout;
+ /* User defined call back*/
+ void (*receive_cb)(struct tcp_client_ctx *ctx, struct net_buf *rx);
+};
+
+int tcp_set_local_addr(struct tcp_client_ctx *ctx, const char *local_addr);
+
+int tcp_connect(struct tcp_client_ctx *ctx, const char *server_addr,
+ uint16_t server_port);
+
+int tcp_disconnect(struct tcp_client_ctx *ctx);
+
+#endif
diff --git a/samples/net/http_client/testcase.ini b/samples/net/http_client/testcase.ini
new file mode 100644
index 000000000..1c14f3d70
--- /dev/null
+++ b/samples/net/http_client/testcase.ini
@@ -0,0 +1,4 @@
+[test]
+tags = net http
+build_only = true
+platform_whitelist = frdm_k64f
diff --git a/samples/net/http_server/src/http_write_utils.c b/samples/net/http_server/src/http_write_utils.c
index a96853040..1167cfdcb 100644
--- a/samples/net/http_server/src/http_write_utils.c
+++ b/samples/net/http_server/src/http_write_utils.c
@@ -22,7 +22,7 @@ uint16_t http_strlen(const char *str)
int http_add_header(struct net_buf *tx, const char *str)
{
- net_nbuf_append(tx, strlen(str), (uint8_t *)str);
+ net_nbuf_append(tx, strlen(str), (uint8_t *)str, K_FOREVER);
return 0;
}
@@ -36,13 +36,13 @@ int http_add_chunk(struct net_buf *tx, const char *str)
str_len = http_strlen(str);
snprintf(chunk_header, sizeof(chunk_header), "%x\r\n", str_len);
- net_nbuf_append(tx, strlen(chunk_header), chunk_header);
+ net_nbuf_append(tx, strlen(chunk_header), chunk_header, K_FOREVER);
if (str_len) {
- net_nbuf_append(tx, str_len, (uint8_t *)str);
+ net_nbuf_append(tx, str_len, (uint8_t *)str, K_FOREVER);
}
- net_nbuf_append(tx, strlen(rn), rn);
+ net_nbuf_append(tx, strlen(rn), rn, K_FOREVER);
return 0;
}
@@ -54,7 +54,7 @@ int http_write(struct http_server_ctx *ctx, const char *http_header,
struct net_buf *tx;
int rc = -EINVAL;
- tx = net_nbuf_get_tx(ctx->net_ctx);
+ tx = net_nbuf_get_tx(ctx->net_ctx, K_FOREVER);
printf("[%s:%d] net_nbuf_get_tx, rc: %d <%s>\n",
__func__, __LINE__, !tx, RC_STR(!tx));
if (tx == NULL) {
diff --git a/samples/net/ieee802154/hw/prj.conf b/samples/net/ieee802154/hw/prj.conf
index 5af2d29b4..311ed0f69 100644
--- a/samples/net/ieee802154/hw/prj.conf
+++ b/samples/net/ieee802154/hw/prj.conf
@@ -37,8 +37,8 @@ CONFIG_NET_L2_IEEE802154_RFD=y
CONFIG_NET_L2_IEEE802154_FRAGMENT=y
#CONFIG_NET_DEBUG_L2_IEEE802154_FRAGMENT=y
-CONFIG_TI_CC2520=y
-CONFIG_TI_CC2520_AUTO_ACK=y
+CONFIG_IEEE802154_CC2520=y
+CONFIG_IEEE802154_CC2520_AUTO_ACK=y
CONFIG_SYS_LOG_IEEE802154_DRIVER_LEVEL=1
CONFIG_NET_L2_IEEE802154_SHELL=y
diff --git a/samples/net/ieee802154/hw/prj_mcr20a.conf b/samples/net/ieee802154/hw/prj_mcr20a.conf
index 271efe4d1..0b47ba553 100644
--- a/samples/net/ieee802154/hw/prj_mcr20a.conf
+++ b/samples/net/ieee802154/hw/prj_mcr20a.conf
@@ -39,7 +39,7 @@ CONFIG_NET_L2_IEEE802154_RFD=y
CONFIG_NET_L2_IEEE802154_FRAGMENT=y
#CONFIG_NET_DEBUG_L2_IEEE802154_FRAGMENT=y
-CONFIG_NXP_MCR20A=y
+CONFIG_IEEE802154_MCR20A=y
CONFIG_SYS_LOG_IEEE802154_DRIVER_LEVEL=1
CONFIG_NET_L2_IEEE802154_SHELL=y
diff --git a/samples/net/ieee802154/hw/src/ieee802154_test.c b/samples/net/ieee802154/hw/src/ieee802154_test.c
index 6bfe55fc9..4dc1dbcef 100644
--- a/samples/net/ieee802154/hw/src/ieee802154_test.c
+++ b/samples/net/ieee802154/hw/src/ieee802154_test.c
@@ -15,11 +15,11 @@
#include <misc/printk.h>
#define PRINT printk
-#ifdef CONFIG_TI_CC2520_DRV_NAME
-#define IEEE802154_DRV_NAME CONFIG_TI_CC2520_DRV_NAME
+#ifdef CONFIG_IEEE802154_CC2520_DRV_NAME
+#define IEEE802154_DRV_NAME CONFIG_IEEE802154_CC2520_DRV_NAME
#endif
-#ifdef CONFIG_NXP_MCR20A_DRV_NAME
-#define IEEE802154_DRV_NAME CONFIG_NXP_MCR20A_DRV_NAME
+#ifdef CONFIG_IEEE802154_MCR20A_DRV_NAME
+#define IEEE802154_DRV_NAME CONFIG_IEEE802154_MCR20A_DRV_NAME
#endif
#ifndef CONFIG_NET_L2_IEEE802154_SHELL
diff --git a/samples/net/ieee802154/qemu/prj.conf b/samples/net/ieee802154/qemu/prj.conf
index 6112e5164..926023ee3 100644
--- a/samples/net/ieee802154/qemu/prj.conf
+++ b/samples/net/ieee802154/qemu/prj.conf
@@ -35,5 +35,5 @@ CONFIG_NET_L2_IEEE802154_ORFD=y
CONFIG_NET_L2_IEEE802154_FRAGMENT=y
#CONFIG_NET_DEBUG_L2_IEEE802154_FRAGMENT=y
-CONFIG_UPIPE_15_4=y
+CONFIG_IEEE802154_UPIPE=y
CONFIG_SYS_LOG_IEEE802154_DRIVER_LEVEL=4
diff --git a/samples/net/ieee802154/qemu/src/ieee802154_qemu_test.c b/samples/net/ieee802154/qemu/src/ieee802154_qemu_test.c
index ed406f846..50237842b 100644
--- a/samples/net/ieee802154/qemu/src/ieee802154_qemu_test.c
+++ b/samples/net/ieee802154/qemu/src/ieee802154_qemu_test.c
@@ -26,7 +26,7 @@ static struct net_if *init_device(void)
struct net_if *iface;
struct device *dev;
- dev = device_get_binding(CONFIG_UPIPE_15_4_DRV_NAME);
+ dev = device_get_binding(CONFIG_IEEE802154_UPIPE_DRV_NAME);
if (!dev) {
PRINT("Cannot get UPIPE device\n");
return NULL;
diff --git a/samples/net/irc_bot/src/irc-bot.c b/samples/net/irc_bot/src/irc-bot.c
index d3c668eb9..4c7246931 100644
--- a/samples/net/irc_bot/src/irc-bot.c
+++ b/samples/net/irc_bot/src/irc-bot.c
@@ -146,12 +146,12 @@ transmit(struct net_context *ctx, char buffer[], size_t len)
{
struct net_buf *send_buf;
- send_buf = net_nbuf_get_tx(ctx);
+ send_buf = net_nbuf_get_tx(ctx, K_FOREVER);
if (!send_buf) {
return -ENOMEM;
}
- if (!net_nbuf_append(send_buf, len, buffer)) {
+ if (!net_nbuf_append(send_buf, len, buffer, K_FOREVER)) {
return -EINVAL;
}
@@ -312,7 +312,7 @@ on_context_recv(struct net_context *ctx, struct net_buf *buf,
if (cmd_len + len > sizeof(cmd_buf)) {
/* overrun cmd_buf - bail out */
- NET_ERR("CMD BUFFER OVERRUN!! %lu > %lu",
+ NET_ERR("CMD BUFFER OVERRUN!! %zu > %zu",
cmd_len + len,
sizeof(cmd_buf));
break;
diff --git a/samples/net/irc_bot/testcase.ini b/samples/net/irc_bot/testcase.ini
new file mode 100644
index 000000000..e0efde996
--- /dev/null
+++ b/samples/net/irc_bot/testcase.ini
@@ -0,0 +1,4 @@
+[test]
+tags = net irc
+build_only = true
+platform_whitelist = qemu_x86 frdm_k64f
diff --git a/samples/net/leds_demo/prj_802154.conf b/samples/net/leds_demo/prj_802154.conf
index c459d3993..1efd33265 100644
--- a/samples/net/leds_demo/prj_802154.conf
+++ b/samples/net/leds_demo/prj_802154.conf
@@ -8,5 +8,5 @@ CONFIG_NET_LOG=y
CONFIG_NET_UDP=y
CONFIG_NET_YAIP=y
CONFIG_TEST_RANDOM_GENERATOR=y
-CONFIG_TI_CC2520=y
+CONFIG_IEEE802154_CC2520=y
CONFIG_ZOAP=y
diff --git a/samples/net/leds_demo/src/leds-demo.c b/samples/net/leds_demo/src/leds-demo.c
index 0fe8044d8..5f081bbea 100644
--- a/samples/net/leds_demo/src/leds-demo.c
+++ b/samples/net/leds_demo/src/leds-demo.c
@@ -100,12 +100,12 @@ static int led_get(struct zoap_resource *resource,
id = zoap_header_get_id(request);
- buf = net_nbuf_get_tx(context);
+ buf = net_nbuf_get_tx(context, K_FOREVER);
if (!buf) {
return -ENOMEM;
}
- frag = net_nbuf_get_data(context);
+ frag = net_nbuf_get_data(context, K_FOREVER);
if (!frag) {
return -ENOMEM;
}
@@ -167,12 +167,12 @@ static int led_post(struct zoap_resource *resource,
id = zoap_header_get_id(request);
- buf = net_nbuf_get_tx(context);
+ buf = net_nbuf_get_tx(context, K_FOREVER);
if (!buf) {
return -ENOMEM;
}
- frag = net_nbuf_get_data(context);
+ frag = net_nbuf_get_data(context, K_FOREVER);
if (!frag) {
return -ENOMEM;
}
@@ -245,12 +245,12 @@ static int led_put(struct zoap_resource *resource,
id = zoap_header_get_id(request);
- buf = net_nbuf_get_tx(context);
+ buf = net_nbuf_get_tx(context, K_FOREVER);
if (!buf) {
return -ENOMEM;
}
- frag = net_nbuf_get_data(context);
+ frag = net_nbuf_get_data(context, K_FOREVER);
if (!frag) {
return -ENOMEM;
}
@@ -307,12 +307,12 @@ static int dummy_get(struct zoap_resource *resource,
id = zoap_header_get_id(request);
- buf = net_nbuf_get_tx(context);
+ buf = net_nbuf_get_tx(context, K_FOREVER);
if (!buf) {
return -ENOMEM;
}
- frag = net_nbuf_get_data(context);
+ frag = net_nbuf_get_data(context, K_FOREVER);
if (!frag) {
return -ENOMEM;
}
diff --git a/samples/net/mbedtls_dtlsclient/src/udp.c b/samples/net/mbedtls_dtlsclient/src/udp.c
index 06f7fb9da..bf6f3142f 100644
--- a/samples/net/mbedtls_dtlsclient/src/udp.c
+++ b/samples/net/mbedtls_dtlsclient/src/udp.c
@@ -66,13 +66,13 @@ int udp_tx(void *context, const unsigned char *buf, size_t size)
udp_ctx = ctx->net_ctx;
- send_buf = net_nbuf_get_tx(udp_ctx);
+ send_buf = net_nbuf_get_tx(udp_ctx, K_FOREVER);
if (!send_buf) {
printk("cannot create buf\n");
return -EIO;
}
- rc = net_nbuf_append(send_buf, size, (uint8_t *) buf);
+ rc = net_nbuf_append(send_buf, size, (uint8_t *) buf, K_FOREVER);
if (!rc) {
printk("cannot write buf\n");
return -EIO;
diff --git a/samples/net/mbedtls_dtlsserver/src/udp.c b/samples/net/mbedtls_dtlsserver/src/udp.c
index 20b68a2d5..7ed500d8c 100644
--- a/samples/net/mbedtls_dtlsserver/src/udp.c
+++ b/samples/net/mbedtls_dtlsserver/src/udp.c
@@ -60,13 +60,13 @@ int udp_tx(void *context, const unsigned char *buf, size_t size)
net_ctx = ctx->net_ctx;
- send_buf = net_nbuf_get_tx(net_ctx);
+ send_buf = net_nbuf_get_tx(net_ctx, K_FOREVER);
if (!send_buf) {
printk("cannot create buf\n");
return -EIO;
}
- rc = net_nbuf_append(send_buf, size, (uint8_t *) buf);
+ rc = net_nbuf_append(send_buf, size, (uint8_t *) buf, K_FOREVER);
if (!rc) {
printk("cannot write buf\n");
return -EIO;
diff --git a/samples/net/mbedtls_sslclient/Makefile b/samples/net/mbedtls_sslclient/Makefile
index 6f417152f..80dcd69d7 100644
--- a/samples/net/mbedtls_sslclient/Makefile
+++ b/samples/net/mbedtls_sslclient/Makefile
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: Apache-2.0
#
-BOARD = galileo
-CONF_FILE = prj_galileo.conf
+BOARD ?= galileo
+CONF_FILE ?= prj_$(BOARD).conf
include $(ZEPHYR_BASE)/Makefile.inc
diff --git a/samples/net/mbedtls_sslclient/prj_arduino_101.conf b/samples/net/mbedtls_sslclient/prj_arduino_101.conf
new file mode 100644
index 000000000..8ed0f9db9
--- /dev/null
+++ b/samples/net/mbedtls_sslclient/prj_arduino_101.conf
@@ -0,0 +1,34 @@
+CONFIG_SYS_LOG=y
+CONFIG_NET_LOG=y
+CONFIG_INIT_STACKS=y
+CONFIG_MAIN_STACK_SIZE=4096
+CONFIG_TEST_RANDOM_GENERATOR=y
+
+CONFIG_NETWORKING=y
+CONFIG_NET_ARP=y
+CONFIG_NET_L2_ETHERNET=y
+CONFIG_NET_IPV4=y
+CONFIG_NET_IPV6=n
+CONFIG_NET_TCP=y
+CONFIG_NET_BUF=y
+CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3
+CONFIG_NET_NBUF_RX_COUNT=4
+CONFIG_NET_NBUF_TX_COUNT=4
+CONFIG_NET_NBUF_DATA_COUNT=12
+
+CONFIG_ETH_ENC28J60=y
+CONFIG_ETH_ENC28J60_0=y
+CONFIG_ETH_ENC28J60_0_SPI_PORT_NAME="SPI_1"
+CONFIG_ETH_ENC28J60_0_SPI_BUS_FREQ=2
+CONFIG_ETH_ENC28J60_0_MAC3=0x2D
+CONFIG_ETH_ENC28J60_0_MAC4=0x30
+CONFIG_ETH_ENC28J60_0_MAC5=0x32
+
+CONFIG_SPI=y
+CONFIG_SPI_CS_GPIO=y
+CONFIG_SPI_1_CS_GPIO_PORT="GPIO_0"
+CONFIG_SPI_1_CS_GPIO_PIN=0
+
+CONFIG_MBEDTLS=y
+CONFIG_MBEDTLS_BUILTIN=y
+CONFIG_MBEDTLS_CFG_FILE="config-ccm-psk-tls1_2.h"
diff --git a/samples/net/mbedtls_sslclient/src/tcp.c b/samples/net/mbedtls_sslclient/src/tcp.c
index 675cef09b..5f7cca16e 100644
--- a/samples/net/mbedtls_sslclient/src/tcp.c
+++ b/samples/net/mbedtls_sslclient/src/tcp.c
@@ -54,13 +54,13 @@ int tcp_tx(void *context, const unsigned char *buf, size_t size)
tcp_ctx = ctx->net_ctx;
- send_buf = net_nbuf_get_tx(tcp_ctx);
+ send_buf = net_nbuf_get_tx(tcp_ctx, K_FOREVER);
if (!send_buf) {
printk("cannot create buf\n");
return -EIO;
}
- rc = net_nbuf_append(send_buf, size, (uint8_t *) buf);
+ rc = net_nbuf_append(send_buf, size, (uint8_t *) buf, K_FOREVER);
if (!rc) {
printk("cannot write buf\n");
return -EIO;
diff --git a/samples/net/wpan_serial/prj.conf b/samples/net/wpan_serial/prj.conf
index 4343b0c77..b0c200cb2 100644
--- a/samples/net/wpan_serial/prj.conf
+++ b/samples/net/wpan_serial/prj.conf
@@ -10,7 +10,7 @@ CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y
-CONFIG_TI_CC2520_RAW=y
+CONFIG_IEEE802154_CC2520_RAW=y
CONFIG_NET_BUF=y
CONFIG_NETWORKING=y
diff --git a/samples/net/wpan_serial/src/Makefile b/samples/net/wpan_serial/src/Makefile
index 7ed962485..c560055f2 100644
--- a/samples/net/wpan_serial/src/Makefile
+++ b/samples/net/wpan_serial/src/Makefile
@@ -1,3 +1,3 @@
-ccflags-$(CONFIG_TI_CC2520_RAW) += -I${ZEPHYR_BASE}/subsys/net/ip
+ccflags-$(CONFIG_IEEE802154_CC2520_RAW) += -I${ZEPHYR_BASE}/subsys/net/ip
obj-y += main.o
diff --git a/samples/net/wpan_serial/src/main.c b/samples/net/wpan_serial/src/main.c
index a92e3b973..da56daf42 100644
--- a/samples/net/wpan_serial/src/main.c
+++ b/samples/net/wpan_serial/src/main.c
@@ -143,12 +143,12 @@ static int slip_process_byte(unsigned char c)
#endif
if (!pkt_curr) {
- pkt_curr = net_nbuf_get_reserve_rx(0);
+ pkt_curr = net_nbuf_get_reserve_rx(0, K_NO_WAIT);
if (!pkt_curr) {
SYS_LOG_ERR("No more buffers");
return 0;
}
- buf = net_nbuf_get_reserve_data(0);
+ buf = net_nbuf_get_reserve_data(0, K_NO_WAIT);
if (!buf) {
SYS_LOG_ERR("No more buffers");
net_nbuf_unref(pkt_curr);
@@ -220,13 +220,13 @@ static void send_data(uint8_t *cfg, uint8_t *data, size_t len)
{
struct net_buf *buf, *pkt;
- pkt = net_nbuf_get_reserve_rx(0);
+ pkt = net_nbuf_get_reserve_rx(0, K_NO_WAIT);
if (!pkt) {
SYS_LOG_DBG("No buf available");
return;
}
- buf = net_nbuf_get_reserve_data(0);
+ buf = net_nbuf_get_reserve_data(0, K_NO_WAIT);
if (!buf) {
SYS_LOG_DBG("No fragment available");
net_nbuf_unref(pkt);
@@ -505,7 +505,7 @@ static bool init_ieee802154(void)
SYS_LOG_INF("Initialize ieee802.15.4");
- ieee802154_dev = device_get_binding(CONFIG_TI_CC2520_DRV_NAME);
+ ieee802154_dev = device_get_binding(CONFIG_IEEE802154_CC2520_DRV_NAME);
if (!ieee802154_dev) {
SYS_LOG_ERR("Cannot get CC250 device");
return false;
diff --git a/samples/net/wpanusb/prj.conf b/samples/net/wpanusb/prj.conf
index 0fc0536a7..4fe6b8243 100644
--- a/samples/net/wpanusb/prj.conf
+++ b/samples/net/wpanusb/prj.conf
@@ -15,8 +15,8 @@ CONFIG_NET_NBUF_DATA_SIZE=128
CONFIG_NET_L2_IEEE802154=y
-#CONFIG_TI_CC2520=y
-CONFIG_TI_CC2520_RAW=y
+#CONFIG_IEEE802154_CC2520=y
+CONFIG_IEEE802154_CC2520_RAW=y
CONFIG_SYS_LOG=y
CONFIG_SYS_LOG_IEEE802154_DRIVER_LEVEL=1
diff --git a/samples/net/wpanusb/src/Makefile b/samples/net/wpanusb/src/Makefile
index 16a6a702f..23af5ad92 100644
--- a/samples/net/wpanusb/src/Makefile
+++ b/samples/net/wpanusb/src/Makefile
@@ -1,9 +1,9 @@
ccflags-y += -I${ZEPHYR_BASE}/usb/include -I${ZEPHYR_BASE}/include/drivers/usb -I${ZEPHYR_BASE}/include/usb/
-ccflags-$(CONFIG_TI_CC2520_LEGACY) += -I${ZEPHYR_BASE}/net/ip/contiki/os
-ccflags-$(CONFIG_TI_CC2520_LEGACY) += -I${ZEPHYR_BASE}/net/ip/contiki
-ccflags-$(CONFIG_TI_CC2520_LEGACY) += -I${ZEPHYR_BASE}/net/ip
+ccflags-$(CONFIG_IEEE802154_CC2520_LEGACY) += -I${ZEPHYR_BASE}/net/ip/contiki/os
+ccflags-$(CONFIG_IEEE802154_CC2520_LEGACY) += -I${ZEPHYR_BASE}/net/ip/contiki
+ccflags-$(CONFIG_IEEE802154_CC2520_LEGACY) += -I${ZEPHYR_BASE}/net/ip
-ccflags-$(CONFIG_TI_CC2520_RAW) += -I${ZEPHYR_BASE}/subsys/net/ip
+ccflags-$(CONFIG_IEEE802154_CC2520_RAW) += -I${ZEPHYR_BASE}/subsys/net/ip
obj-y += wpanusb.o
diff --git a/samples/net/wpanusb/src/wpanusb.c b/samples/net/wpanusb/src/wpanusb.c
index 528d93f2f..ee9bc0992 100644
--- a/samples/net/wpanusb/src/wpanusb.c
+++ b/samples/net/wpanusb/src/wpanusb.c
@@ -382,8 +382,17 @@ static int wpanusb_vendor_handler(struct usb_setup_packet *setup,
{
struct net_buf *pkt, *buf;
- pkt = net_nbuf_get_reserve_tx(0);
- buf = net_nbuf_get_reserve_data(0);
+ pkt = net_nbuf_get_reserve_tx(0, K_NO_WAIT);
+ if (!pkt) {
+ return -ENOMEM;
+ }
+
+ buf = net_nbuf_get_reserve_data(0, K_NO_WAIT);
+ if (!buf) {
+ net_nbuf_unref(pkt);
+ return -ENOMEM;
+ }
+
net_buf_frag_insert(pkt, buf);
net_buf_add_u8(buf, setup->bRequest);
@@ -587,7 +596,7 @@ void main(void)
#if DYNAMIC_REGISTER
ieee802154_dev = ieee802154_register_raw();
#else
- ieee802154_dev = device_get_binding(CONFIG_TI_CC2520_DRV_NAME);
+ ieee802154_dev = device_get_binding(CONFIG_IEEE802154_CC2520_DRV_NAME);
if (!ieee802154_dev) {
SYS_LOG_ERR("Cannot get CC250 device");
return;
diff --git a/samples/net/zoap_client/src/zoap-client.c b/samples/net/zoap_client/src/zoap-client.c
index 984afa451..6e12077a2 100644
--- a/samples/net/zoap_client/src/zoap-client.c
+++ b/samples/net/zoap_client/src/zoap-client.c
@@ -173,13 +173,13 @@ static void event_iface_up(struct net_mgmt_event_callback *cb,
k_delayed_work_init(&retransmit_work, retransmit_request);
- buf = net_nbuf_get_tx(context);
+ buf = net_nbuf_get_tx(context, K_FOREVER);
if (!buf) {
printk("Unable to get TX buffer, not enough memory.\n");
return;
}
- frag = net_nbuf_get_data(context);
+ frag = net_nbuf_get_data(context, K_FOREVER);
if (!frag) {
printk("Unable to get DATA buffer, not enough memory.\n");
return;
diff --git a/samples/net/zoap_server/prj_cc2520.conf b/samples/net/zoap_server/prj_cc2520.conf
index ea85c8242..934a1a598 100644
--- a/samples/net/zoap_server/prj_cc2520.conf
+++ b/samples/net/zoap_server/prj_cc2520.conf
@@ -8,7 +8,7 @@ CONFIG_NET_LOG=y
CONFIG_NET_UDP=y
CONFIG_NET_YAIP=y
CONFIG_TEST_RANDOM_GENERATOR=y
-CONFIG_TI_CC2520=y
+CONFIG_IEEE802154_CC2520=y
CONFIG_ZOAP=y
CONFIG_NET_SAMPLES_IP_ADDRESSES=y
CONFIG_NET_SAMPLES_MY_IPV6_ADDR="2001:db8::1"
diff --git a/samples/net/zoap_server/src/zoap-server.c b/samples/net/zoap_server/src/zoap-server.c
index 1c7d1a783..51862fe12 100644
--- a/samples/net/zoap_server/src/zoap-server.c
+++ b/samples/net/zoap_server/src/zoap-server.c
@@ -64,12 +64,12 @@ static int test_del(struct zoap_resource *resource,
NET_INFO("type: %u code %u id %u\n", type, code, id);
NET_INFO("*******\n");
- buf = net_nbuf_get_tx(context);
+ buf = net_nbuf_get_tx(context, K_FOREVER);
if (!buf) {
return -ENOMEM;
}
- frag = net_nbuf_get_data(context);
+ frag = net_nbuf_get_data(context, K_FOREVER);
if (!frag) {
return -ENOMEM;
}
@@ -123,12 +123,12 @@ static int test_put(struct zoap_resource *resource,
NET_INFO("type: %u code %u id %u\n", type, code, id);
NET_INFO("*******\n");
- buf = net_nbuf_get_tx(context);
+ buf = net_nbuf_get_tx(context, K_FOREVER);
if (!buf) {
return -ENOMEM;
}
- frag = net_nbuf_get_data(context);
+ frag = net_nbuf_get_data(context, K_FOREVER);
if (!frag) {
return -ENOMEM;
}
@@ -188,12 +188,12 @@ static int test_post(struct zoap_resource *resource,
NET_INFO("type: %u code %u id %u\n", type, code, id);
NET_INFO("*******\n");
- buf = net_nbuf_get_tx(context);
+ buf = net_nbuf_get_tx(context, K_FOREVER);
if (!buf) {
return -ENOMEM;
}
- frag = net_nbuf_get_data(context);
+ frag = net_nbuf_get_data(context, K_FOREVER);
if (!frag) {
return -ENOMEM;
}
@@ -257,12 +257,12 @@ static int location_query_post(struct zoap_resource *resource,
NET_INFO("type: %u code %u id %u\n", type, code, id);
NET_INFO("*******\n");
- buf = net_nbuf_get_tx(context);
+ buf = net_nbuf_get_tx(context, K_FOREVER);
if (!buf) {
return -ENOMEM;
}
- frag = net_nbuf_get_data(context);
+ frag = net_nbuf_get_data(context, K_FOREVER);
if (!frag) {
return -ENOMEM;
}
@@ -317,12 +317,12 @@ static int piggyback_get(struct zoap_resource *resource,
NET_INFO("type: %u code %u id %u\n", type, code, id);
NET_INFO("*******\n");
- buf = net_nbuf_get_tx(context);
+ buf = net_nbuf_get_tx(context, K_FOREVER);
if (!buf) {
return -ENOMEM;
}
- frag = net_nbuf_get_data(context);
+ frag = net_nbuf_get_data(context, K_FOREVER);
if (!frag) {
return -ENOMEM;
}
@@ -419,12 +419,12 @@ static int query_get(struct zoap_resource *resource,
NET_INFO("*******\n");
- buf = net_nbuf_get_tx(context);
+ buf = net_nbuf_get_tx(context, K_FOREVER);
if (!buf) {
return -ENOMEM;
}
- frag = net_nbuf_get_data(context);
+ frag = net_nbuf_get_data(context, K_FOREVER);
if (!frag) {
return -ENOMEM;
}
@@ -494,12 +494,12 @@ static int separate_get(struct zoap_resource *resource,
goto done;
}
- buf = net_nbuf_get_tx(context);
+ buf = net_nbuf_get_tx(context, K_FOREVER);
if (!buf) {
return -ENOMEM;
}
- frag = net_nbuf_get_data(context);
+ frag = net_nbuf_get_data(context, K_FOREVER);
if (!frag) {
return -ENOMEM;
}
@@ -525,12 +525,12 @@ static int separate_get(struct zoap_resource *resource,
}
done:
- buf = net_nbuf_get_tx(context);
+ buf = net_nbuf_get_tx(context, K_FOREVER);
if (!buf) {
return -ENOMEM;
}
- frag = net_nbuf_get_data(context);
+ frag = net_nbuf_get_data(context, K_FOREVER);
if (!frag) {
return -ENOMEM;
}
@@ -614,12 +614,12 @@ static int large_get(struct zoap_resource *resource,
NET_INFO("type: %u code %u id %u\n", type, code, id);
NET_INFO("*******\n");
- buf = net_nbuf_get_tx(context);
+ buf = net_nbuf_get_tx(context, K_FOREVER);
if (!buf) {
return -ENOMEM;
}
- frag = net_nbuf_get_data(context);
+ frag = net_nbuf_get_data(context, K_FOREVER);
if (!frag) {
return -ENOMEM;
}
@@ -712,12 +712,12 @@ static int large_update_put(struct zoap_resource *resource,
NET_INFO("type: %u code %u id %u\n", type, code, id);
NET_INFO("*******\n");
- buf = net_nbuf_get_tx(context);
+ buf = net_nbuf_get_tx(context, K_FOREVER);
if (!buf) {
return -ENOMEM;
}
- frag = net_nbuf_get_data(context);
+ frag = net_nbuf_get_data(context, K_FOREVER);
if (!frag) {
return -ENOMEM;
}
diff --git a/samples/net/zperf/prj_quark_se_c1000_devboard.conf b/samples/net/zperf/prj_quark_se_c1000_devboard.conf
index cff8c26ff..a2b532137 100644
--- a/samples/net/zperf/prj_quark_se_c1000_devboard.conf
+++ b/samples/net/zperf/prj_quark_se_c1000_devboard.conf
@@ -26,7 +26,7 @@ CONFIG_NET_L2_IEEE802154_ORFD_PAN_ID=0xabcd
CONFIG_NET_L2_IEEE802154_ORFD_CHANNEL=26
CONFIG_NET_L2_IEEE802154_FRAGMENT=y
-CONFIG_TI_CC2520=y
+CONFIG_IEEE802154_CC2520=y
CONFIG_NET_6LO=y
CONFIG_NET_6LO_CONTEXT=y
diff --git a/samples/net/zperf/src/zperf_tcp_uploader.c b/samples/net/zperf/src/zperf_tcp_uploader.c
index 7d1735203..c40b96dc8 100644
--- a/samples/net/zperf/src/zperf_tcp_uploader.c
+++ b/samples/net/zperf/src/zperf_tcp_uploader.c
@@ -54,23 +54,24 @@ void zperf_tcp_upload(struct net_context *ctx,
loop_time = k_cycle_get_32();
last_loop_time = loop_time;
- buf = net_nbuf_get_tx(ctx);
+ buf = net_nbuf_get_tx(ctx, K_FOREVER);
if (!buf) {
printk(TAG "ERROR! Failed to retrieve a buffer\n");
- continue;
+ break;
}
- frag = net_nbuf_get_data(ctx);
+ frag = net_nbuf_get_data(ctx, K_FOREVER);
if (!frag) {
+ net_nbuf_unref(buf);
printk(TAG "ERROR! Failed to retrieve a fragment\n");
- continue;
+ break;
}
net_buf_frag_add(buf, frag);
/* Fill in the TCP payload */
st = net_nbuf_append(buf, sizeof(sample_packet),
- sample_packet);
+ sample_packet, K_FOREVER);
if (!st) {
printk(TAG "ERROR! Failed to fill packet\n");
diff --git a/samples/net/zperf/src/zperf_udp_receiver.c b/samples/net/zperf/src/zperf_udp_receiver.c
index 68ff53e90..cf3681e89 100644
--- a/samples/net/zperf/src/zperf_udp_receiver.c
+++ b/samples/net/zperf/src/zperf_udp_receiver.c
@@ -67,8 +67,8 @@ static inline struct net_buf *build_reply_buf(struct net_context *context,
printk(TAG "received %d bytes\n", net_nbuf_appdatalen(buf));
- reply_buf = net_nbuf_get_tx(context);
- frag = net_nbuf_get_data(context);
+ reply_buf = net_nbuf_get_tx(context, K_FOREVER);
+ frag = net_nbuf_get_data(context, K_FOREVER);
net_buf_frag_add(reply_buf, frag);
diff --git a/samples/net/zperf/src/zperf_udp_uploader.c b/samples/net/zperf/src/zperf_udp_uploader.c
index cdff49d60..794dfb373 100644
--- a/samples/net/zperf/src/zperf_udp_uploader.c
+++ b/samples/net/zperf/src/zperf_udp_uploader.c
@@ -86,13 +86,13 @@ static inline void zperf_upload_fin(struct net_context *context,
struct net_buf *buf, *frag;
bool status;
- buf = net_nbuf_get_tx(context);
+ buf = net_nbuf_get_tx(context, K_FOREVER);
if (!buf) {
printk(TAG "ERROR! Failed to retrieve a buffer\n");
continue;
}
- frag = net_nbuf_get_data(context);
+ frag = net_nbuf_get_data(context, K_FOREVER);
if (!frag) {
printk(TAG "ERROR! Failed to retrieve a fragment\n");
continue;
@@ -107,7 +107,7 @@ static inline void zperf_upload_fin(struct net_context *context,
USEC_PER_SEC);
status = net_nbuf_append(buf, sizeof(datagram),
- (uint8_t *)&datagram);
+ (uint8_t *)&datagram, K_FOREVER);
if (!status) {
printk(TAG "ERROR! Cannot append datagram data\n");
break;
@@ -121,7 +121,8 @@ static inline void zperf_upload_fin(struct net_context *context,
frag = net_nbuf_write(buf, net_buf_frag_last(buf),
sizeof(struct zperf_udp_datagram),
- &pos, size, sample_packet);
+ &pos, size, sample_packet,
+ K_FOREVER);
}
/* Send the packet */
@@ -229,13 +230,13 @@ void zperf_udp_upload(struct net_context *context,
last_loop_time = loop_time;
- buf = net_nbuf_get_tx(context);
+ buf = net_nbuf_get_tx(context, K_FOREVER);
if (!buf) {
printk(TAG "ERROR! Failed to retrieve a buffer\n");
continue;
}
- frag = net_nbuf_get_data(context);
+ frag = net_nbuf_get_data(context, K_FOREVER);
if (!frag) {
printk(TAG "ERROR! Failed to retrieve a frag\n");
continue;
@@ -250,7 +251,7 @@ void zperf_udp_upload(struct net_context *context,
htonl(HW_CYCLES_TO_USEC(loop_time) % USEC_PER_SEC);
status = net_nbuf_append(buf, sizeof(datagram),
- (uint8_t *)&datagram);
+ (uint8_t *)&datagram, K_FOREVER);
if (!status) {
printk(TAG "ERROR! Cannot append datagram data\n");
break;
@@ -264,7 +265,8 @@ void zperf_udp_upload(struct net_context *context,
frag = net_nbuf_write(buf, net_buf_frag_last(buf),
sizeof(struct zperf_udp_datagram),
- &pos, size, sample_packet);
+ &pos, size, sample_packet,
+ K_FOREVER);
}
/* Send the packet */