zephyr/samples/net/mbedtls_dtlsclient
Jukka Rissanen bd3908b2a9 net: nbuf: Add timeout to net_buf getters
This commit changes the net_buf getter functions in nbuf.h
by adding a timeout parameter. These function prototypes
are changed to accept a timeout parameter.
	net_nbuf_get_rx()
	net_nbuf_get_tx()
	net_nbuf_get_data()
	net_nbuf_get_reserve_rx()
	net_nbuf_get_reserve_tx()
	net_nbuf_get_reserve_data()
	net_nbuf_copy()
	net_nbuf_copy_all()
	net_nbuf_push()
	net_nbuf_append()
	net_nbuf_write()
	net_nbuf_insert()

Following convinience functions have not been changed
	net_nbuf_append_u8
	net_nbuf_append_be16
	net_nbuf_append_be32
	net_nbuf_insert_u8
	net_nbuf_insert_be16
	net_nbuf_insert_be32
	net_nbuf_write_u8
	net_nbuf_write_be16
	net_nbuf_write_be32
so they call the base function using K_FOREVER. Use the
base function if you want to have a timeout when net_buf
is allocated.

Change-Id: I20bb602ffb73069e5a02668fce60575141586c0f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-02-08 10:12:35 +02:00
..
src net: nbuf: Add timeout to net_buf getters 2017-02-08 10:12:35 +02:00
Makefile license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
README.rst doc: net: use Qemu setup section in current documentation 2017-02-03 15:59:19 +02:00
prj_arduino_101.conf drivers/ethernet: Update default GPIO pin for the ENC28J60 module 2017-01-20 16:23:17 +02:00
prj_qemu_x86.conf net: samples: Fix config option 2017-01-27 12:35:51 +02:00
testcase.ini samples/mbedtls_dtlsclient: mbedTLS sample DTLS client app on Arduino 101. 2016-12-02 12:41:01 +02:00

README.rst

mbedTLS DTLS client
####################

Overview
********
This sample code shows a simple DTLS client using mbed TLS on top of Zephyr

Building and running
********************

Follow the steps for testing :ref:`networking with Qemu <networking_with_qemu>`.

Obtain the mbed TLS code from:

https://tls.mbed.org/download/start/mbedtls-2.3.0-apache.tgz

and put it in a well known directory on your Linux machine, this will be your
server.

change to that directory and compile the mbedTLS on your host machine:

.. code-block:: console

   $ tar -xvzf mbedtls-2.3.0-apache.tgz
   $ cd mbedtls-2.3.0
   $ CFLAGS="-I$PWD/configs -DMBEDTLS_CONFIG_FILE='<config-thread.h>'" make

Assign the server IP address and start the DTLS server.

.. code-block:: console

   $ sudo ip addr add 192.0.2.2/24 dev tap0
   $ ./programs/ssl/ssl_server2 dtls=1 ecjpake_pw=passwd

.. code-block:: console

   . Seeding the random number generator... ok
   . Bind on udp://*:4433/ ... ok
   . Setting up the SSL/TLS structure... ok
   . Waiting for a remote connection ...

To stop the server use Ctrl-C and repeat steps described in f) every time
QEMU gets terminated, due the Netwrok interface (tap) being restarted.

From the application directory type

.. code-block:: console

   $ make run

This will result in Qemu running with the following output:

.. code-block:: console

	. Seeding the random number generator... ok
	. Setting up the DTLS structure... ok
	. Connecting to udp 192.0.2.2:4433... ok
	. Setting up ecjpake password ... ok
	. Performing the SSL/TLS handshake... ok
	> Write to server: ok
	. Closing the connection... done

On the server side you should see this

.. code-block:: console

	. Performing the SSL/TLS handshake... hello verification requested
	. Waiting for a remote connection ... ok
	. Performing the SSL/TLS handshake... ok
	[ Protocol is DTLSv1.2 ]
	[ Ciphersuite is TLS-ECJPAKE-WITH-AES-128-CCM-8 ]
	[ Record expansion is 29 ]
	[ Maximum fragment length is 16384 ]
	< Read from client: 18 bytes read

	GET / HTTP/1.0

	> Write to client: 143 bytes written in 1 fragments


	HTTP/1.0 200 OK
	Content-Type: text/html

	<h2>mbed TLS Test Server</h2>
	<p>Successful connection using: TLS-ECJPAKE-WITH-AES-128-CCM-8</p>

	. Closing the connection... done
	. Waiting for a remote connection ... ok
	. Performing the SSL/TLS handshake... failed
	! mbedtls_ssl_handshake returned -0x7900

	. Waiting for a remote connection ...

Disregard the last handshake failed message, due the closing connection.

If the server does not receive the  messages, use a network traffic analyzer,
like Wireshark.

Reset the board.

References
**********

- https://tls.mbed.org/