mbed TLS v2.16.1
net_sockets.h
Go to the documentation of this file.
1 
22 /*
23  * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
24  * SPDX-License-Identifier: GPL-2.0
25  *
26  * This program is free software; you can redistribute it and/or modify
27  * it under the terms of the GNU General Public License as published by
28  * the Free Software Foundation; either version 2 of the License, or
29  * (at your option) any later version.
30  *
31  * This program is distributed in the hope that it will be useful,
32  * but WITHOUT ANY WARRANTY; without even the implied warranty of
33  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34  * GNU General Public License for more details.
35  *
36  * You should have received a copy of the GNU General Public License along
37  * with this program; if not, write to the Free Software Foundation, Inc.,
38  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
39  *
40  * This file is part of mbed TLS (https://tls.mbed.org)
41  */
42 #ifndef MBEDTLS_NET_SOCKETS_H
43 #define MBEDTLS_NET_SOCKETS_H
44 
45 #if !defined(MBEDTLS_CONFIG_FILE)
46 #include "config.h"
47 #else
48 #include MBEDTLS_CONFIG_FILE
49 #endif
50 
51 #include "ssl.h"
52 
53 #include <stddef.h>
54 #include <stdint.h>
55 
56 #define MBEDTLS_ERR_NET_SOCKET_FAILED -0x0042
57 #define MBEDTLS_ERR_NET_CONNECT_FAILED -0x0044
58 #define MBEDTLS_ERR_NET_BIND_FAILED -0x0046
59 #define MBEDTLS_ERR_NET_LISTEN_FAILED -0x0048
60 #define MBEDTLS_ERR_NET_ACCEPT_FAILED -0x004A
61 #define MBEDTLS_ERR_NET_RECV_FAILED -0x004C
62 #define MBEDTLS_ERR_NET_SEND_FAILED -0x004E
63 #define MBEDTLS_ERR_NET_CONN_RESET -0x0050
64 #define MBEDTLS_ERR_NET_UNKNOWN_HOST -0x0052
65 #define MBEDTLS_ERR_NET_BUFFER_TOO_SMALL -0x0043
66 #define MBEDTLS_ERR_NET_INVALID_CONTEXT -0x0045
67 #define MBEDTLS_ERR_NET_POLL_FAILED -0x0047
68 #define MBEDTLS_ERR_NET_BAD_INPUT_DATA -0x0049
70 #define MBEDTLS_NET_LISTEN_BACKLOG 10
72 #define MBEDTLS_NET_PROTO_TCP 0
73 #define MBEDTLS_NET_PROTO_UDP 1
75 #define MBEDTLS_NET_POLL_READ 1
76 #define MBEDTLS_NET_POLL_WRITE 2
78 #ifdef __cplusplus
79 extern "C" {
80 #endif
81 
89 typedef struct mbedtls_net_context
90 {
91  int fd;
92 }
94 
102 
118 int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host, const char *port, int proto );
119 
137 int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char *port, int proto );
138 
156  mbedtls_net_context *client_ctx,
157  void *client_ip, size_t buf_size, size_t *ip_len );
158 
180 int mbedtls_net_poll( mbedtls_net_context *ctx, uint32_t rw, uint32_t timeout );
181 
190 
199 
208 void mbedtls_net_usleep( unsigned long usec );
209 
222 int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len );
223 
236 int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len );
237 
259 int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len,
260  uint32_t timeout );
261 
268 
269 #ifdef __cplusplus
270 }
271 #endif
272 
273 #endif /* net_sockets.h */