Skip to content

Commit

Permalink
Add minimal support for ssl module using Mbed TLS and sockets
Browse files Browse the repository at this point in the history
Add APIs to otp_socket so it can be called from bio callbacks
Fix a bug in lwIP recv revealed by ssl tests
Fix a bug in BSD recvfrom revealed by refactoring
Update documentation and workflows to reflect the requirement on Mbed TLS
Fix exported types of inet module

Signed-off-by: Paul Guyot <[email protected]>
  • Loading branch information
pguyot committed Nov 4, 2023
1 parent 3746e5e commit eefc2b3
Show file tree
Hide file tree
Showing 29 changed files with 1,934 additions and 216 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
submodules: 'recursive'

- name: "Install deps"
run: brew install gperf doxygen erlang@${{ matrix.otp }} ninja
run: brew install gperf doxygen erlang@${{ matrix.otp }} ninja mbedtls

# Builder info
- name: "System info"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test-other.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
apt update &&
apt install -y -t stretch-backports-sloppy libarchive13 &&
apt install -y -t stretch-backports cmake &&
apt install -y file gcc g++ binutils make doxygen gperf zlib1g-dev libssl-dev
apt install -y file gcc g++ binutils make doxygen gperf zlib1g-dev libssl-dev libmbedtls-dev
- arch: "arm32v7"
platform: "arm/v7"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ jobs:
run: sudo apt update -y

- name: "Install deps"
run: sudo apt install -y ${{ matrix.compiler_pkgs}} cmake gperf zlib1g-dev doxygen valgrind
run: sudo apt install -y ${{ matrix.compiler_pkgs}} cmake gperf zlib1g-dev doxygen valgrind libmbedtls-dev

# Builder info
- name: "System info"
Expand Down
1 change: 1 addition & 0 deletions README.Md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Required for building:
* gperf ([GNU Perfect Hash Function Generator](https://www.gnu.org/software/gperf/manual/gperf.html))
* erlc ([erlang compiler](https://www.erlang.org/))
* elixirc ([elixir compiler](https://elixir-lang.org))
* Mbed TLS ([portable TLS library, optionally required to support SSL](https://www.trustedfirmware.org/projects/mbed-tls/))
* zlib ([zlib compression and decompression library](https://zlib.net/))

Documentation and Coverage:
Expand Down
1 change: 1 addition & 0 deletions doc/src/build-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The following software is required in order to build AtomVM in generic UNIX syst
* `make`
* `gperf`
* `zlib`
* `Mbed TLS`
* Erlang/OTP compiler (`erlc`)
* Elixir compiler

Expand Down
1 change: 1 addition & 0 deletions libs/estdlib/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ set(ERLANG_MODULES
logger_std_h
proplists
socket
ssl
string
timer
unicode
Expand Down
11 changes: 5 additions & 6 deletions libs/estdlib/src/inet.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@

-type port_number() :: 0..65535.
-type socket() :: pid().
-type address() :: ipv4_address().
-type ipv4_address() :: {octet(), octet(), octet(), octet()}.
-type octet() :: 0..255.
-type ip_address() :: ip4_address().
-type ip4_address() :: {0..255, 0..255, 0..255, 0..255}.
-type hostname() :: iodata().

-export_type([socket/0, port_number/0, address/0, ipv4_address/0, octet/0, hostname/0]).
-export_type([socket/0, port_number/0, ip_address/0, ip4_address/0, hostname/0]).

%%-----------------------------------------------------------------------------
%% @param Socket the socket from which to obtain the port number
Expand Down Expand Up @@ -61,7 +60,7 @@ close(Socket) ->
%% This function should be called on a running socket instance.
%% @end
%%-----------------------------------------------------------------------------
-spec sockname(Socket :: socket()) -> {ok, {address(), port_number()}} | {error, Reason :: term()}.
-spec sockname(Socket :: socket()) -> {ok, {ip_address(), port_number()}} | {error, Reason :: term()}.
sockname(Socket) ->
call(Socket, {sockname}).

Expand All @@ -72,7 +71,7 @@ sockname(Socket) ->
%% This function should be called on a running socket instance.
%% @end
%%-----------------------------------------------------------------------------
-spec peername(Socket :: socket()) -> {ok, {address(), port_number()}} | {error, Reason :: term()}.
-spec peername(Socket :: socket()) -> {ok, {ip_address(), port_number()}} | {error, Reason :: term()}.
peername(Socket) ->
call(Socket, {peername}).

Expand Down
Loading

0 comments on commit eefc2b3

Please sign in to comment.