ReactOS 0.4.15-dev-8100-g1887773
net_sockets.h
Go to the documentation of this file.
1
22/*
23 * Copyright The Mbed TLS Contributors
24 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
25 *
26 * This file is provided under the Apache License 2.0, or the
27 * GNU General Public License v2.0 or later.
28 *
29 * **********
30 * Apache License 2.0:
31 *
32 * Licensed under the Apache License, Version 2.0 (the "License"); you may
33 * not use this file except in compliance with the License.
34 * You may obtain a copy of the License at
35 *
36 * http://www.apache.org/licenses/LICENSE-2.0
37 *
38 * Unless required by applicable law or agreed to in writing, software
39 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
40 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41 * See the License for the specific language governing permissions and
42 * limitations under the License.
43 *
44 * **********
45 *
46 * **********
47 * GNU General Public License v2.0 or later:
48 *
49 * This program is free software; you can redistribute it and/or modify
50 * it under the terms of the GNU General Public License as published by
51 * the Free Software Foundation; either version 2 of the License, or
52 * (at your option) any later version.
53 *
54 * This program is distributed in the hope that it will be useful,
55 * but WITHOUT ANY WARRANTY; without even the implied warranty of
56 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 * GNU General Public License for more details.
58 *
59 * You should have received a copy of the GNU General Public License along
60 * with this program; if not, write to the Free Software Foundation, Inc.,
61 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
62 *
63 * **********
64 */
65#ifndef MBEDTLS_NET_SOCKETS_H
66#define MBEDTLS_NET_SOCKETS_H
67
68#if !defined(MBEDTLS_CONFIG_FILE)
69#include "config.h"
70#else
71#include MBEDTLS_CONFIG_FILE
72#endif
73
74#include "ssl.h"
75
76#include <stddef.h>
77#include <stdint.h>
78
79#define MBEDTLS_ERR_NET_SOCKET_FAILED -0x0042
80#define MBEDTLS_ERR_NET_CONNECT_FAILED -0x0044
81#define MBEDTLS_ERR_NET_BIND_FAILED -0x0046
82#define MBEDTLS_ERR_NET_LISTEN_FAILED -0x0048
83#define MBEDTLS_ERR_NET_ACCEPT_FAILED -0x004A
84#define MBEDTLS_ERR_NET_RECV_FAILED -0x004C
85#define MBEDTLS_ERR_NET_SEND_FAILED -0x004E
86#define MBEDTLS_ERR_NET_CONN_RESET -0x0050
87#define MBEDTLS_ERR_NET_UNKNOWN_HOST -0x0052
88#define MBEDTLS_ERR_NET_BUFFER_TOO_SMALL -0x0043
89#define MBEDTLS_ERR_NET_INVALID_CONTEXT -0x0045
90#define MBEDTLS_ERR_NET_POLL_FAILED -0x0047
91#define MBEDTLS_ERR_NET_BAD_INPUT_DATA -0x0049
93#define MBEDTLS_NET_LISTEN_BACKLOG 10
95#define MBEDTLS_NET_PROTO_TCP 0
96#define MBEDTLS_NET_PROTO_UDP 1
98#define MBEDTLS_NET_POLL_READ 1
99#define MBEDTLS_NET_POLL_WRITE 2
101#ifdef __cplusplus
102extern "C" {
103#endif
104
113{
114 int fd;
115}
117
125
141int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host, const char *port, int proto );
142
161int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char *port, int proto );
162
182 mbedtls_net_context *client_ctx,
183 void *client_ip, size_t buf_size, size_t *ip_len );
184
211
220
229
238void mbedtls_net_usleep( unsigned long usec );
239
252int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len );
253
266int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len );
267
294int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len,
296
303
304#ifdef __cplusplus
305}
306#endif
307
308#endif /* net_sockets.h */
UINT32 uint32_t
Definition: types.h:75
USHORT port
Definition: uri.c:228
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722
int mbedtls_net_recv(void *ctx, unsigned char *buf, size_t len)
Read at most 'len' characters. If no error occurs, the actual amount read is returned.
int mbedtls_net_set_nonblock(mbedtls_net_context *ctx)
Set the socket non-blocking.
int mbedtls_net_accept(mbedtls_net_context *bind_ctx, mbedtls_net_context *client_ctx, void *client_ip, size_t buf_size, size_t *ip_len)
Accept a connection from a remote client.
int mbedtls_net_send(void *ctx, const unsigned char *buf, size_t len)
Write at most 'len' characters. If no error occurs, the actual amount read is returned.
int mbedtls_net_recv_timeout(void *ctx, unsigned char *buf, size_t len, uint32_t timeout)
Read at most 'len' characters, blocking for at most 'timeout' seconds. If no error occurs,...
void mbedtls_net_usleep(unsigned long usec)
Portable usleep helper.
void mbedtls_net_free(mbedtls_net_context *ctx)
Gracefully shutdown the connection and free associated data.
int mbedtls_net_bind(mbedtls_net_context *ctx, const char *bind_ip, const char *port, int proto)
Create a receiving socket on bind_ip:port in the chosen protocol. If bind_ip == NULL,...
int mbedtls_net_poll(mbedtls_net_context *ctx, uint32_t rw, uint32_t timeout)
Check and wait for the context to be ready for read/write.
int mbedtls_net_connect(mbedtls_net_context *ctx, const char *host, const char *port, int proto)
Initiate a connection with host:port in the given protocol.
void mbedtls_net_init(mbedtls_net_context *ctx)
Initialize a context Just makes the context ready to be used or freed safely.
int mbedtls_net_set_block(mbedtls_net_context *ctx)
Set the socket blocking.
#define rw
Definition: rosglue.h:38
SSL/TLS functions.
Definition: dhcpd.h:245
char * host
Definition: whois.c:55