Examples for "Zstream" Socket/TLS API

Paul Sokolovsky


At yesterday's TSC meeting, it was requested to provide examples of the
usage of 2 contender TLS APIs, to better assess trade-offs they make.
(Please see an earlier email today re: background on TLS API

Here's an information about usage examples for my Zstream API

Work on examples was the integral part of my PR. Currently, Zephyr has
5 samples for BSD Socket usage in the tree:

While developing my API, I converted each of them in turn from pure BSD
Sockets API to Zstream API. Beyond that, I also added build files
(specifically, Makefiles) which allow to build all these samples on
another POSIX-compatible OS, tested on Linux. In this regard, the
Zstream samples are the same as the original Socket samples they were
derived from - they also have the makefiles and demonstrate portability
to other systems offering BSD Sockets API. Note that requirement of
portability across POSIX OSes was one the basic requirements for the
design of Zstream API.

Beyond converting the existing socket samples, I also converted a WIP
socket-based MQTT client PR, as previously prepared by Gil Pitney:

With the above work done, for the final version of PR in
https://github.com/zephyrproject-rtos/zephyr/pull/5985 , I decided to
include just one sample, to not overload reviewers, I decided to
include just one example, "the most complex" in a sense,
"big_http_download", which downloads a large file (few MBs) over HTTPS
connection and verifies its hash.

Summing up, the following samples are available for review:

1. https://github.com/zephyrproject-rtos/zephyr/pull/5985 includes a
*standalone* version of "big_http_download" sample, i.e. all related
files are added as new (to keep the socket-based original intact, as of
course Zstream API does not replace BSD Socket API, it's optional layer
on top of it). Direct link:
(may be broken if rebase happens).

2. All the samples mentioned above can be viewed in a diff form in my
https://github.com/pfalcon/zephyr/tree/net-zstream-api-samples . To
ease the review, I created a pseudo-PR which allows to access the diffs
directly. For example, the diff between the original socket version of
"big_http_download" and its Zstream conversion is here:

I would like to propose to Patrik, the author of the alternative
proposal, to take the "big_http_download" socket sample as the
baseline for API comparison (followed by the other 4 in-tree samples if
there're enough resources). I also would like to draw attention to
showing portability of a TLS application to other POSIX/BSD Sockets


Linaro.org | Open source software for ARM SoCs
Follow Linaro: http://www.facebook.com/pages/Linaro
http://twitter.com/#!/linaroorg - http://www.linaro.org/linaro-blog