00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef MBEDTLS_NET_SOCKETS_H
00025 #define MBEDTLS_NET_SOCKETS_H
00026
00027 #if !defined(MBEDTLS_CONFIG_FILE)
00028 #include "config.h"
00029 #else
00030 #include MBEDTLS_CONFIG_FILE
00031 #endif
00032
00033 #include "ssl.h"
00034
00035 #include <stddef.h>
00036 #include <stdint.h>
00037
00038 #define MBEDTLS_ERR_NET_SOCKET_FAILED -0x0042
00039 #define MBEDTLS_ERR_NET_CONNECT_FAILED -0x0044
00040 #define MBEDTLS_ERR_NET_BIND_FAILED -0x0046
00041 #define MBEDTLS_ERR_NET_LISTEN_FAILED -0x0048
00042 #define MBEDTLS_ERR_NET_ACCEPT_FAILED -0x004A
00043 #define MBEDTLS_ERR_NET_RECV_FAILED -0x004C
00044 #define MBEDTLS_ERR_NET_SEND_FAILED -0x004E
00045 #define MBEDTLS_ERR_NET_CONN_RESET -0x0050
00046 #define MBEDTLS_ERR_NET_UNKNOWN_HOST -0x0052
00047 #define MBEDTLS_ERR_NET_BUFFER_TOO_SMALL -0x0043
00048 #define MBEDTLS_ERR_NET_INVALID_CONTEXT -0x0045
00050 #define MBEDTLS_NET_LISTEN_BACKLOG 10
00052 #define MBEDTLS_NET_PROTO_TCP 0
00053 #define MBEDTLS_NET_PROTO_UDP 1
00055 #ifdef __cplusplus
00056 extern "C" {
00057 #endif
00058
00066 typedef struct
00067 {
00068 int fd;
00069 }
00070 mbedtls_net_context;
00071
00078 void mbedtls_net_init( mbedtls_net_context *ctx );
00079
00095 int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host, const char *port, int proto );
00096
00114 int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char *port, int proto );
00115
00132 int mbedtls_net_accept( mbedtls_net_context *bind_ctx,
00133 mbedtls_net_context *client_ctx,
00134 void *client_ip, size_t buf_size, size_t *ip_len );
00135
00143 int mbedtls_net_set_block( mbedtls_net_context *ctx );
00144
00152 int mbedtls_net_set_nonblock( mbedtls_net_context *ctx );
00153
00162 void mbedtls_net_usleep( unsigned long usec );
00163
00176 int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len );
00177
00190 int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len );
00191
00213 int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len,
00214 uint32_t timeout );
00215
00221 void mbedtls_net_free( mbedtls_net_context *ctx );
00222
00223 #ifdef __cplusplus
00224 }
00225 #endif
00226
00227 #endif