22 #ifndef _MBED_HTTPS_TLS_SOCKET_WRAPPER_H_    23 #define _MBED_HTTPS_TLS_SOCKET_WRAPPER_H_    26 #include "rtos/EventFlags.h"    27 #include "platform/Callback.h"    28 #include "mbedtls/platform.h"    29 #include "mbedtls/ssl.h"    30 #include "mbedtls/entropy.h"    31 #include "mbedtls/ctr_drbg.h"    32 #include "mbedtls/error.h"    35 #if defined(MBEDTLS_SSL_CLI_C) || defined(DOXYGEN_ONLY)   105                                       const void *client_private_key_pem, 
size_t client_private_key_len);
   160 #if defined(MBEDTLS_X509_CRT_PARSE_C) || defined(DOXYGEN_ONLY)   224     bool is_handshake_started() 
const;
   237     static void print_mbedtls_error(
const char *name, 
int err);
   239 #if MBED_CONF_TLS_SOCKET_DEBUG_LEVEL > 0   244     static void my_debug(
void *ctx, 
int level, 
const char *file, 
int line,
   251     static int my_verify(
void *data, mbedtls_x509_crt *crt, 
int depth, uint32_t *flags);
   258     static int ssl_recv(
void *ctx, 
unsigned char *buf, 
size_t len);
   263     static int ssl_send(
void *ctx, 
const unsigned char *buf, 
size_t len);
   265     mbedtls_ssl_context _ssl;
   266 #ifdef MBEDTLS_X509_CRT_PARSE_C   267     mbedtls_pk_context _pkctx;
   269     mbedtls_ctr_drbg_context _ctr_drbg;
   270     mbedtls_entropy_context _entropy;
   277 #ifdef MBEDTLS_X509_CRT_PARSE_C   278     mbedtls_x509_crt *_cacert;
   279     mbedtls_x509_crt *_clicert;
   281     mbedtls_ssl_config *_ssl_conf;
   283     bool _connect_transport: 1;
   284     bool _close_transport: 1;
   285     bool _tls_initialized: 1;
   286     bool _handshake_completed: 1;
   287     bool _cacert_allocated: 1;
   288     bool _clicert_allocated: 1;
   289     bool _ssl_conf_allocated: 1;
   294 #endif // _MBED_HTTPS_TLS_SOCKET_WRAPPER_H_ 
The EventFlags class is used to control event flags or wait for event flags other threads control...
virtual nsapi_size_or_error_t sendto(const SocketAddress &address, const void *data, nsapi_size_t size)
Send a message on a socket. 
virtual void sigio(mbed::Callback< void()> func)
Register a callback on state change of the socket. 
TLSSocket is a wrapper around Socket for interacting with TLS servers. 
virtual nsapi_error_t listen(int backlog=1)
Listen for incoming connections. 
virtual ~TLSSocketWrapper()
Destroy a socket wrapper. 
signed int nsapi_error_t
Type used to represent error codes. 
virtual nsapi_error_t connect(const SocketAddress &address=SocketAddress())
Connects socket to a remote address. 
virtual Socket * accept(nsapi_error_t *error=NULL)
Accepts a connection on a socket. 
virtual nsapi_error_t getpeername(SocketAddress *address)
Get the remote-end peer associated with this socket. 
mbedtls_ssl_config * get_ssl_config()
Get internal Mbed TLS configuration structure. 
signed int nsapi_size_or_error_t
Type used to represent either a size or error passed through sockets. 
Abstract Socket interface. 
Does call only connect() on transport socket. 
virtual nsapi_size_or_error_t recv(void *data, nsapi_size_t size)
Receive data over a TLS socket. 
virtual nsapi_error_t setsockopt(int level, int optname, const void *optval, unsigned optlen)
Set socket options. 
virtual nsapi_error_t close()
Closes the socket. 
Does call close() on transport socket. 
mbedtls_x509_crt * get_ca_chain()
Get CA chain structure. 
int set_own_cert(mbedtls_x509_crt *crt)
Set own certificate directly to Mbed TLS. 
nsapi_error_t set_root_ca_cert(const void *root_ca, size_t len)
Sets the certification of Root CA. 
virtual nsapi_error_t send(const void *data, nsapi_size_t size)
Send data over a TLS socket. 
nsapi_error_t set_client_cert_key(const void *client_cert, size_t client_cert_len, const void *client_private_key_pem, size_t client_private_key_len)
Sets client certificate, and client private key. 
void set_ca_chain(mbedtls_x509_crt *crt)
Set CA chain directly to Mbed TLS. 
void set_hostname(const char *hostname)
Set hostname. 
mbedtls_x509_crt * get_own_cert()
Get own certificate directly from Mbed TLS. 
Doesn't call connect() or close() on transport socket. 
void set_ssl_config(mbedtls_ssl_config *conf)
Override Mbed TLS configuration. 
Does call connect() and close() on transport socket. 
virtual nsapi_size_or_error_t recvfrom(SocketAddress *address, void *data, nsapi_size_t size)
Receive a data from a socket. 
unsigned int nsapi_size_t
Type used to represent the size of data passed through sockets. 
control_transport
Transport modes. 
virtual void set_timeout(int timeout)
Set timeout on blocking socket operations. 
virtual nsapi_error_t getsockopt(int level, int optname, void *optval, unsigned *optlen)
Get socket options. 
virtual nsapi_error_t bind(const SocketAddress &address)
Bind a specific address to a socket. 
TLSSocketWrapper(Socket *transport, const char *hostname=NULL, control_transport control=TRANSPORT_CONNECT_AND_CLOSE)
Create a TLSSocketWrapper. 
Callback class based on template specialization. 
mbedtls_ssl_context * get_ssl_context()
Get internal Mbed TLS context structure. 
virtual void set_blocking(bool blocking)
Set blocking or non-blocking mode of the socket.