dtls: handle no peer when receiving a CCS, alert or data package

This problem was introduced by allowing to call handle_handshake()
without a peer pointer.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: remove peer in case of an fatal alert

The logic seams to be wrong here, the peer was removed when it was
*not* deleted from the list of peers, reverse it to fix this problem.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
dtls: close connection before deleting peer on termination

This also cleans up the memory reserved for the cipher.

Without this patch we have a memory leak when a peer was freed and when
the client called dtls_free_context() the peer was not notified.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
test: memset session to zero to silence a valgrind warning

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
test: close connection on termination

This frees up the memory reserved earlier and notifies the peer.

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