00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef MBEDTLS_NET_SOCKETS_H
00050 #define MBEDTLS_NET_SOCKETS_H
00051
00052 #if !defined(MBEDTLS_CONFIG_FILE)
00053 #include "config.h"
00054 #else
00055 #include MBEDTLS_CONFIG_FILE
00056 #endif
00057
00058 #include "ssl.h"
00059
00060 #include <stddef.h>
00061 #include <stdint.h>
00062
00063 #define MBEDTLS_ERR_NET_SOCKET_FAILED -0x0042
00064 #define MBEDTLS_ERR_NET_CONNECT_FAILED -0x0044
00065 #define MBEDTLS_ERR_NET_BIND_FAILED -0x0046
00066 #define MBEDTLS_ERR_NET_LISTEN_FAILED -0x0048
00067 #define MBEDTLS_ERR_NET_ACCEPT_FAILED -0x004A
00068 #define MBEDTLS_ERR_NET_RECV_FAILED -0x004C
00069 #define MBEDTLS_ERR_NET_SEND_FAILED -0x004E
00070 #define MBEDTLS_ERR_NET_CONN_RESET -0x0050
00071 #define MBEDTLS_ERR_NET_UNKNOWN_HOST -0x0052
00072 #define MBEDTLS_ERR_NET_BUFFER_TOO_SMALL -0x0043
00073 #define MBEDTLS_ERR_NET_INVALID_CONTEXT -0x0045
00075 #define MBEDTLS_NET_LISTEN_BACKLOG 10
00077 #define MBEDTLS_NET_PROTO_TCP 0
00078 #define MBEDTLS_NET_PROTO_UDP 1
00080 #ifdef __cplusplus
00081 extern "C" {
00082 #endif
00083
00091 typedef struct
00092 {
00093 int fd;
00094 }
00095 mbedtls_net_context;
00096
00103 void mbedtls_net_init( mbedtls_net_context *ctx );
00104
00120 int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host, const char *port, int proto );
00121
00139 int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char *port, int proto );
00140
00157 int mbedtls_net_accept( mbedtls_net_context *bind_ctx,
00158 mbedtls_net_context *client_ctx,
00159 void *client_ip, size_t buf_size, size_t *ip_len );
00160
00168 int mbedtls_net_set_block( mbedtls_net_context *ctx );
00169
00177 int mbedtls_net_set_nonblock( mbedtls_net_context *ctx );
00178
00187 void mbedtls_net_usleep( unsigned long usec );
00188
00201 int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len );
00202
00215 int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len );
00216
00238 int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len,
00239 uint32_t timeout );
00240
00246 void mbedtls_net_free( mbedtls_net_context *ctx );
00247
00248 #ifdef __cplusplus
00249 }
00250 #endif
00251
00252 #endif