Anjay Lite
Loading...
Searching...
No Matches
anj_net_api.h
Go to the documentation of this file.
1/*
2 * Copyright 2023-2026 AVSystem <avsystem@avsystem.com>
3 * AVSystem Anjay Lite LwM2M SDK
4 * All rights reserved.
5 *
6 * Licensed under AVSystem Anjay Lite LwM2M Client SDK - Non-Commercial License.
7 * See the attached LICENSE file for details.
8 */
9
10#include <anj/init.h>
11
34#ifndef ANJ_NET_API_H
35# define ANJ_NET_API_H
36
37# include <stdbool.h>
38# include <stddef.h>
39# include <stdint.h>
40
41# ifdef __cplusplus
42extern "C" {
43# endif
44
45# ifdef ANJ_WITH_SECURITY
46# include <anj/compat/rng.h>
47# include <anj/crypto.h>
48# endif // ANJ_WITH_SECURITY
49
59# define ANJ_NET_OK (0)
60
66# define ANJ_NET_EAGAIN (1)
67
71# define ANJ_NET_EMSGSIZE (2)
72
77# define ANJ_NET_ENOTSUP (3)
78
85# define ANJ_NET_EINPROGRESS (4)
86
94
109
144
155
156# ifdef ANJ_WITH_SECURITY
161
166
167typedef struct {
168 void *empty;
170
178
179typedef struct {
185
186# ifdef ANJ_WITH_EXTERNAL_CRYPTO_STORAGE
191# endif // ANJ_WITH_EXTERNAL_CRYPTO_STORAGE
193# endif // ANJ_WITH_SECURITY
194
206typedef struct {
208# ifdef ANJ_WITH_SECURITY
210# endif // ANJ_WITH_SECURITY
212
213struct anj_net_ctx_struct;
214
227typedef struct anj_net_ctx_struct anj_net_ctx_t;
228
238static inline bool anj_net_is_ok(int res) {
239 return ANJ_NET_OK == res;
240}
241
252static inline bool anj_net_is_again(int res) {
253 return ANJ_NET_EAGAIN == res;
254}
255
269static inline bool anj_net_is_inprogress(int res) {
270 return ANJ_NET_EINPROGRESS == res;
271}
272
289 const anj_net_config_t *config);
290
304
323typedef int
324anj_net_connect_t(anj_net_ctx_t *ctx, const char *hostname, const char *port);
325
348 size_t *bytes_sent,
349 const uint8_t *buf,
350 size_t length);
351
372 size_t *bytes_received,
373 uint8_t *buf,
374 size_t length);
375
391
404 anj_net_socket_state_t *out_value);
405
418typedef int anj_net_get_inner_mtu_t(anj_net_ctx_t *ctx, int32_t *out_value);
419
452
453# ifdef __cplusplus
454}
455# endif
456
457#endif // ANJ_NET_API_H
int anj_net_get_state_t(anj_net_ctx_t *ctx, anj_net_socket_state_t *out_value)
Definition anj_net_api.h:403
#define ANJ_NET_EAGAIN
Definition anj_net_api.h:66
int anj_net_close_t(anj_net_ctx_t *ctx)
Definition anj_net_api.h:390
static bool anj_net_is_ok(int res)
Check if a network operation succeeded.
Definition anj_net_api.h:238
anj_net_binding_type_t
Definition anj_net_api.h:89
@ ANJ_NET_BINDING_NON_IP
Definition anj_net_api.h:92
@ ANJ_NET_BINDING_DTLS
Definition anj_net_api.h:91
@ ANJ_NET_BINDING_UDP
Definition anj_net_api.h:90
anj_net_security_mode_t
Definition anj_net_api.h:157
@ ANJ_NET_SECURITY_PSK
Definition anj_net_api.h:158
@ ANJ_NET_SECURITY_CERTIFICATE
Definition anj_net_api.h:159
struct anj_net_ctx_struct anj_net_ctx_t
Opaque network context handle.
Definition anj_net_api.h:227
int anj_net_create_ctx_t(anj_net_ctx_t **ctx, const anj_net_config_t *config)
Definition anj_net_api.h:288
int anj_net_get_inner_mtu_t(anj_net_ctx_t *ctx, int32_t *out_value)
Definition anj_net_api.h:418
#define ANJ_NET_OK
Definition anj_net_api.h:59
int anj_net_recv_t(anj_net_ctx_t *ctx, size_t *bytes_received, uint8_t *buf, size_t length)
Definition anj_net_api.h:371
anj_net_socket_state_t
Definition anj_net_api.h:95
@ ANJ_NET_SOCKET_STATE_CONNECTED
Definition anj_net_api.h:107
@ ANJ_NET_SOCKET_STATE_CLOSED
Definition anj_net_api.h:100
int anj_net_cleanup_ctx_t(anj_net_ctx_t **ctx)
Definition anj_net_api.h:303
int anj_net_connect_t(anj_net_ctx_t *ctx, const char *hostname, const char *port)
Definition anj_net_api.h:324
anj_net_address_family_setting_t
Definition anj_net_api.h:113
@ ANJ_NET_AF_SETTING_PREFERRED_INET4
Definition anj_net_api.h:136
@ ANJ_NET_AF_SETTING_FORCE_INET4
Definition anj_net_api.h:124
@ ANJ_NET_AF_SETTING_FORCE_INET6
Definition anj_net_api.h:130
@ ANJ_NET_AF_SETTING_PREFERRED_INET6
Definition anj_net_api.h:142
@ ANJ_NET_AF_SETTING_UNSPEC
Definition anj_net_api.h:118
static bool anj_net_is_again(int res)
Check if data was received.
Definition anj_net_api.h:252
#define ANJ_NET_EINPROGRESS
Definition anj_net_api.h:85
static bool anj_net_is_inprogress(int res)
Check if a network operation is in progress.
Definition anj_net_api.h:269
int anj_net_send_t(anj_net_ctx_t *ctx, size_t *bytes_sent, const uint8_t *buf, size_t length)
Definition anj_net_api.h:347
int anj_net_queue_mode_rx_off_t(anj_net_ctx_t *ctx)
Definition anj_net_api.h:451
Cryptographic data descriptors used by Security Object and networking.
Global configuration validation header for Anjay Lite.
Platform hook for providing randomness.
Definition crypto.h:101
Definition anj_net_api.h:167
void * empty
Definition anj_net_api.h:168
Definition anj_net_api.h:206
anj_net_socket_configuration_t raw_socket_config
Definition anj_net_api.h:207
anj_net_ssl_configuration_t secure_socket_config
Definition anj_net_api.h:209
Definition anj_net_api.h:162
anj_crypto_security_info_t key
Definition anj_net_api.h:163
anj_crypto_security_info_t identity
Definition anj_net_api.h:164
Definition anj_net_api.h:171
anj_net_certificate_info_t cert
Definition anj_net_api.h:175
anj_net_security_mode_t mode
Definition anj_net_api.h:172
anj_net_psk_info_t psk
Definition anj_net_api.h:174
Definition anj_net_api.h:148
anj_net_address_family_setting_t af_setting
Definition anj_net_api.h:153
Definition anj_net_api.h:179
void * crypto_ctx
Definition anj_net_api.h:190
anj_net_security_info_t security
Definition anj_net_api.h:184