10#ifndef ANJ_NET_WRAPPER_H
11#define ANJ_NET_WRAPPER_H
13#include <anj/anj_config.h>
16#ifdef ANJ_NET_WITH_UDP
19#ifdef ANJ_NET_WITH_TCP
22#ifdef ANJ_WITH_DTLS_BINDING
25#ifdef ANJ_WITH_TLS_BINDING
28#ifdef ANJ_WITH_NON_IP_BINDING
48#if defined(ANJ_NET_WITH_UDP)
52#if defined(ANJ_NET_WITH_TCP)
56#if defined(ANJ_WITH_DTLS_BINDING)
58 return anj_dtls_get_system_socket(ctx);
60#if defined(ANJ_WITH_TLS_BINDING)
62 return anj_tls_get_system_socket(ctx);
64#if defined(ANJ_WITH_NON_IP_BINDING)
66 return anj_non_ip_get_system_socket(ctx);
78#if defined(ANJ_NET_WITH_UDP)
82#if defined(ANJ_NET_WITH_TCP)
86#if defined(ANJ_WITH_DTLS_BINDING)
88 return anj_dtls_create_ctx(ctx, config);
90#if defined(ANJ_WITH_TLS_BINDING)
92 return anj_tls_create_ctx(ctx, config);
94#if defined(ANJ_WITH_NON_IP_BINDING)
96 return anj_non_ip_create_ctx(ctx, config);
106 const char *hostname,
109#if defined(ANJ_NET_WITH_UDP)
113#if defined(ANJ_NET_WITH_TCP)
117#if defined(ANJ_WITH_DTLS_BINDING)
119 return anj_dtls_connect(ctx, hostname, port);
121#if defined(ANJ_WITH_TLS_BINDING)
123 return anj_tls_connect(ctx, hostname, port);
125#if defined(ANJ_WITH_NON_IP_BINDING)
127 return anj_non_ip_connect(ctx, hostname, port);
141#if defined(ANJ_NET_WITH_UDP)
145#if defined(ANJ_NET_WITH_TCP)
149#if defined(ANJ_WITH_DTLS_BINDING)
151 return anj_dtls_send(ctx, bytes_sent, buf, length);
153#if defined(ANJ_WITH_TLS_BINDING)
155 return anj_tls_send(ctx, bytes_sent, buf, length);
157#if defined(ANJ_WITH_NON_IP_BINDING)
159 return anj_non_ip_send(ctx, bytes_sent, buf, length);
169 size_t *bytes_received,
173#if defined(ANJ_NET_WITH_UDP)
177#if defined(ANJ_NET_WITH_TCP)
181#if defined(ANJ_WITH_DTLS_BINDING)
183 return anj_dtls_recv(ctx, bytes_received, buf, length);
185#if defined(ANJ_WITH_TLS_BINDING)
187 return anj_tls_recv(ctx, bytes_received, buf, length);
189#if defined(ANJ_WITH_NON_IP_BINDING)
191 return anj_non_ip_recv(ctx, bytes_received, buf, length);
202#if defined(ANJ_NET_WITH_UDP)
206#if defined(ANJ_NET_WITH_TCP)
210#if defined(ANJ_WITH_DTLS_BINDING)
212 return anj_dtls_close(ctx);
214#if defined(ANJ_WITH_TLS_BINDING)
216 return anj_tls_close(ctx);
218#if defined(ANJ_WITH_NON_IP_BINDING)
220 return anj_non_ip_close(ctx);
231#if defined(ANJ_NET_WITH_UDP)
235#if defined(ANJ_NET_WITH_TCP)
239#if defined(ANJ_WITH_DTLS_BINDING)
241 return anj_dtls_shutdown(ctx);
243#if defined(ANJ_WITH_TLS_BINDING)
245 return anj_tls_shutdown(ctx);
247#if defined(ANJ_WITH_NON_IP_BINDING)
249 return anj_non_ip_shutdown(ctx);
260#if defined(ANJ_NET_WITH_UDP)
264#if defined(ANJ_NET_WITH_TCP)
268#if defined(ANJ_WITH_DTLS_BINDING)
270 return anj_dtls_cleanup_ctx(ctx);
272#if defined(ANJ_WITH_TLS_BINDING)
274 return anj_tls_cleanup_ctx(ctx);
276#if defined(ANJ_WITH_NON_IP_BINDING)
278 return anj_non_ip_cleanup_ctx(ctx);
289#if defined(ANJ_NET_WITH_UDP)
293#if defined(ANJ_NET_WITH_TCP)
297#if defined(ANJ_WITH_DTLS_BINDING)
299 return anj_dtls_reuse_last_port(ctx);
301#if defined(ANJ_WITH_TLS_BINDING)
303 return anj_tls_reuse_last_port(ctx);
305#if defined(ANJ_WITH_NON_IP_BINDING)
317 uint64_t *out_value) {
319#if defined(ANJ_NET_WITH_UDP)
323#if defined(ANJ_NET_WITH_TCP)
327#if defined(ANJ_WITH_DTLS_BINDING)
329 return anj_dtls_get_bytes_received(ctx, out_value);
331#if defined(ANJ_WITH_TLS_BINDING)
333 return anj_tls_get_bytes_received(ctx, out_value);
335#if defined(ANJ_WITH_NON_IP_BINDING)
337 return anj_non_ip_get_bytes_received(ctx, out_value);
347 uint64_t *out_value) {
349#if defined(ANJ_NET_WITH_UDP)
353#if defined(ANJ_NET_WITH_TCP)
357#if defined(ANJ_WITH_DTLS_BINDING)
359 return anj_dtls_bytes_sent(ctx, out_value);
361#if defined(ANJ_WITH_TLS_BINDING)
363 return anj_tls_bytes_sent(ctx, out_value);
365#if defined(ANJ_WITH_NON_IP_BINDING)
367 return anj_non_ip_get_bytes_sent(ctx, out_value);
377 int32_t *out_value) {
379#if defined(ANJ_NET_WITH_UDP)
383#if defined(ANJ_NET_WITH_TCP)
387#if defined(ANJ_WITH_DTLS_BINDING)
389 return anj_dtls_get_inner_mtu(ctx, out_value);
391#if defined(ANJ_WITH_TLS_BINDING)
393 return anj_tls_get_inner_mtu(ctx, out_value);
395#if defined(ANJ_WITH_NON_IP_BINDING)
397 return anj_non_ip_get_inner_mtu(ctx, out_value);
409#if defined(ANJ_NET_WITH_UDP)
413#if defined(ANJ_NET_WITH_TCP)
417#if defined(ANJ_WITH_DTLS_BINDING)
419 return anj_dtls_get_state(ctx, out_value);
421#if defined(ANJ_WITH_TLS_BINDING)
423 return anj_tls_get_state(ctx, out_value);
425#if defined(ANJ_WITH_NON_IP_BINDING)
427 return anj_non_ip_get_state(ctx, out_value);
#define ANJ_NET_ENOTSUP
Definition anj_net_api.h:56
struct anj_net_ctx_struct anj_net_ctx_t
Definition anj_net_api.h:378
anj_net_socket_state_t
Definition anj_net_api.h:58
static int anj_net_get_bytes_sent(anj_net_binding_type_t type, anj_net_ctx_t *ctx, uint64_t *out_value)
Definition anj_net_wrapper.h:345
static int anj_net_get_bytes_received(anj_net_binding_type_t type, anj_net_ctx_t *ctx, uint64_t *out_value)
Definition anj_net_wrapper.h:315
static int anj_net_get_state(anj_net_binding_type_t type, anj_net_ctx_t *ctx, anj_net_socket_state_t *out_value)
Definition anj_net_wrapper.h:405
static const void * anj_net_get_system_socket(anj_net_binding_type_t type, anj_net_ctx_t *ctx)
Definition anj_net_wrapper.h:45
anj_net_binding_type_t
Definition anj_net_wrapper.h:36
@ ANJ_NET_BINDING_TCP
Definition anj_net_wrapper.h:38
@ ANJ_NET_BINDING_TLS
Definition anj_net_wrapper.h:40
@ ANJ_NET_BINDING_NON_IP
Definition anj_net_wrapper.h:41
@ ANJ_NET_BINDING_DTLS
Definition anj_net_wrapper.h:39
@ ANJ_NET_BINDING_UDP
Definition anj_net_wrapper.h:37
static int anj_net_create_ctx(anj_net_binding_type_t type, anj_net_ctx_t **ctx, const anj_net_config_t *config)
Definition anj_net_wrapper.h:74
static int anj_net_shutdown(anj_net_binding_type_t type, anj_net_ctx_t *ctx)
Definition anj_net_wrapper.h:228
static int anj_net_cleanup_ctx(anj_net_binding_type_t type, anj_net_ctx_t **ctx)
Definition anj_net_wrapper.h:257
static int anj_net_connect(anj_net_binding_type_t type, anj_net_ctx_t *ctx, const char *hostname, const char *port)
Definition anj_net_wrapper.h:104
static int anj_net_close(anj_net_binding_type_t type, anj_net_ctx_t *ctx)
Definition anj_net_wrapper.h:199
static int anj_net_recv(anj_net_binding_type_t type, anj_net_ctx_t *ctx, size_t *bytes_received, uint8_t *buf, size_t length)
Definition anj_net_wrapper.h:167
static int anj_net_get_inner_mtu(anj_net_binding_type_t type, anj_net_ctx_t *ctx, int32_t *out_value)
Definition anj_net_wrapper.h:375
static int anj_net_send(anj_net_binding_type_t type, anj_net_ctx_t *ctx, size_t *bytes_sent, const uint8_t *buf, size_t length)
Definition anj_net_wrapper.h:135
static int anj_net_reuse_last_port(anj_net_binding_type_t type, anj_net_ctx_t *ctx)
Definition anj_net_wrapper.h:286
anj_net_recv_t anj_tcp_recv
Definition anj_tcp.h:28
anj_net_get_state_t anj_tcp_get_state
Definition anj_tcp.h:36
anj_net_connect_t anj_tcp_connect
Definition anj_tcp.h:25
anj_net_create_ctx_t anj_tcp_create_ctx
Definition anj_tcp.h:26
anj_net_get_system_socket_t anj_tcp_get_system_socket
Definition anj_tcp.h:23
anj_net_get_bytes_sent_t anj_tcp_get_bytes_sent
Definition anj_tcp.h:34
anj_net_get_inner_mtu_t anj_tcp_get_inner_mtu
Definition anj_tcp.h:35
anj_net_close_t anj_tcp_close
Definition anj_tcp.h:24
anj_net_get_bytes_received_t anj_tcp_get_bytes_received
Definition anj_tcp.h:33
anj_net_shutdown_t anj_tcp_shutdown
Definition anj_tcp.h:29
anj_net_send_t anj_tcp_send
Definition anj_tcp.h:27
anj_net_reuse_last_port_t anj_tcp_reuse_last_port
Definition anj_tcp.h:31
anj_net_cleanup_ctx_t anj_tcp_cleanup_ctx
Definition anj_tcp.h:30
anj_net_reuse_last_port_t anj_udp_reuse_last_port
Definition anj_udp.h:31
anj_net_get_bytes_received_t anj_udp_get_bytes_received
Definition anj_udp.h:33
anj_net_send_t anj_udp_send
Definition anj_udp.h:27
anj_net_connect_t anj_udp_connect
Definition anj_udp.h:25
anj_net_get_bytes_sent_t anj_udp_get_bytes_sent
Definition anj_udp.h:34
anj_net_close_t anj_udp_close
Definition anj_udp.h:24
anj_net_get_system_socket_t anj_udp_get_system_socket
Definition anj_udp.h:23
anj_net_create_ctx_t anj_udp_create_ctx
Definition anj_udp.h:26
anj_net_recv_t anj_udp_recv
Definition anj_udp.h:28
anj_net_cleanup_ctx_t anj_udp_cleanup_ctx
Definition anj_udp.h:30
anj_net_get_state_t anj_udp_get_state
Definition anj_udp.h:36
anj_net_shutdown_t anj_udp_shutdown
Definition anj_udp.h:29
anj_net_get_inner_mtu_t anj_udp_get_inner_mtu
Definition anj_udp.h:35
Definition anj_net_api.h:370