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
00050
00051 #ifndef MBEDTLS_NET_SOCKETS_H
00052 #define MBEDTLS_NET_SOCKETS_H
00053
00054 #if !defined(MBEDTLS_CONFIG_FILE)
00055 #include "config.h"
00056 #else
00057 #include MBEDTLS_CONFIG_FILE
00058 #endif
00059
00060 #include "ssl.h"
00061
00062 #include <stddef.h>
00063 #include <stdint.h>
00064
00065 #define MBEDTLS_ERR_NET_SOCKET_FAILED -0x0042
00066 #define MBEDTLS_ERR_NET_CONNECT_FAILED -0x0044
00067 #define MBEDTLS_ERR_NET_BIND_FAILED -0x0046
00068 #define MBEDTLS_ERR_NET_LISTEN_FAILED -0x0048
00069 #define MBEDTLS_ERR_NET_ACCEPT_FAILED -0x004A
00070 #define MBEDTLS_ERR_NET_RECV_FAILED -0x004C
00071 #define MBEDTLS_ERR_NET_SEND_FAILED -0x004E
00072 #define MBEDTLS_ERR_NET_CONN_RESET -0x0050
00073 #define MBEDTLS_ERR_NET_UNKNOWN_HOST -0x0052
00074 #define MBEDTLS_ERR_NET_BUFFER_TOO_SMALL -0x0043
00075 #define MBEDTLS_ERR_NET_INVALID_CONTEXT -0x0045
00077 #define MBEDTLS_NET_LISTEN_BACKLOG 10
00079 #define MBEDTLS_NET_PROTO_TCP 0
00080 #define MBEDTLS_NET_PROTO_UDP 1
00082 #ifdef __cplusplus
00083 extern "C" {
00084 #endif
00085
00093 typedef struct
00094 {
00095 int fd;
00096 }
00097 mbedtls_net_context;
00098
00105 void mbedtls_net_init( mbedtls_net_context *ctx );
00106
00122 int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host, const char *port, int proto );
00123
00141 int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char *port, int proto );
00142
00159 int mbedtls_net_accept( mbedtls_net_context *bind_ctx,
00160 mbedtls_net_context *client_ctx,
00161 void *client_ip, size_t buf_size, size_t *ip_len );
00162
00170 int mbedtls_net_set_block( mbedtls_net_context *ctx );
00171
00179 int mbedtls_net_set_nonblock( mbedtls_net_context *ctx );
00180
00189 void mbedtls_net_usleep( unsigned long usec );
00190
00203 int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len );
00204
00217 int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len );
00218
00240 int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len,
00241 uint32_t timeout );
00242
00248 void mbedtls_net_free( mbedtls_net_context *ctx );
00249
00250 #ifdef __cplusplus
00251 }
00252 #endif
00253
00254 #endif