dtls: use a negative number to indicate an error

In preparation to convert a error code into a TLS alert message convert
the code to indicate a success with 0 or a positive number and an error
with a negative number.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: convert more functions to return -1 on error

Return a negative number in some more functions and forward the actual
error code in some functions.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: forward the error we get from a function we call

It is a bad practice to replace an error code we get from a function
call with an own value.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: move role to peer config

The role does not change while being connected to one peer, make it a
peer and not a security property.
Before this patch the role was the role of the remote peer, now it is
the role of the local peer.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: convert switch in handle_handshake to use package type

This makes it later possible to also handle the receiving of the
ClientHello in this functions.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: handle all handshake messages in handle_handshake()

Now also the initial ClientHello is handled in the handle_handshake()
function and not in some dedicated place. The rehandshake should now
use mostly the same code as the initial handshake.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: Add missing break when receiving an alert

There was a break statement missing after handling a alert message.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>