oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
net_tls.h
1/*
2 * Copyright (C) 2026 Kamil Lulko <kamil.lulko@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 *
6 * This file is part of oveRTOS.
7 */
8
9#ifndef OVE_NET_TLS_H
10#define OVE_NET_TLS_H
11
26#include "ove/types.h"
27#include "ove/net.h"
28#include "ove_config.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
37typedef struct {
38 const unsigned char *ca_cert;
39 size_t ca_cert_len;
40 const char *hostname;
41 const unsigned char *client_cert;
43 const unsigned char *client_key;
46
47#include "ove/storage.h"
48
49#ifdef CONFIG_OVE_NET_TLS
50
58int ove_tls_init(ove_tls_t *tls, ove_tls_storage_t *storage);
59
65void ove_tls_deinit(ove_tls_t tls);
66
75int ove_tls_handshake(ove_tls_t tls, ove_socket_t sock,
76 const ove_tls_config_t *cfg);
77
87int ove_tls_send(ove_tls_t tls, const void *data, size_t len,
88 size_t *sent);
89
99int ove_tls_recv(ove_tls_t tls, void *buf, size_t len,
100 size_t *received);
101
109void ove_tls_close(ove_tls_t tls);
110
111#ifdef OVE_HEAP_NET_TLS
118int ove_tls_create(ove_tls_t *tls);
119
125void ove_tls_destroy(ove_tls_t tls);
126#endif /* OVE_HEAP_NET_TLS */
127
128#else /* !CONFIG_OVE_NET_TLS */
129
131#ifndef CONFIG_OVE_NET_TLS
132typedef struct { uint8_t _unused; } ove_tls_storage_t;
133#endif
134
135static inline int ove_tls_init(ove_tls_t *tls, ove_tls_storage_t *storage) { (void)tls; (void)storage; return OVE_ERR_NOT_SUPPORTED; }
136static inline void ove_tls_deinit(ove_tls_t tls) { (void)tls; }
137static inline int ove_tls_handshake(ove_tls_t tls, ove_socket_t sock, const ove_tls_config_t *cfg) { (void)tls; (void)sock; (void)cfg; return OVE_ERR_NOT_SUPPORTED; }
138static inline int ove_tls_send(ove_tls_t tls, const void *data, size_t len, size_t *sent) { (void)tls; (void)data; (void)len; (void)sent; return OVE_ERR_NOT_SUPPORTED; }
139static inline int ove_tls_recv(ove_tls_t tls, void *buf, size_t len, size_t *received) { (void)tls; (void)buf; (void)len; (void)received; return OVE_ERR_NOT_SUPPORTED; }
140static inline void ove_tls_close(ove_tls_t tls) { (void)tls; }
143#endif /* CONFIG_OVE_NET_TLS */
144
145#ifdef __cplusplus
146}
147#endif
148
151#endif /* OVE_NET_TLS_H */
#define OVE_ERR_NOT_SUPPORTED
The requested feature is not supported by the active backend.
Definition types.h:38
struct ove_tls * ove_tls_t
Opaque handle for a TLS session.
Definition types.h:127
struct ove_socket * ove_socket_t
Opaque handle for a network socket.
Definition types.h:121
TLS session configuration.
Definition net_tls.h:37
size_t client_key_len
Definition net_tls.h:44
const unsigned char * ca_cert
Definition net_tls.h:38
size_t ca_cert_len
Definition net_tls.h:39
size_t client_cert_len
Definition net_tls.h:42
const char * hostname
Definition net_tls.h:40
const unsigned char * client_cert
Definition net_tls.h:41
const unsigned char * client_key
Definition net_tls.h:43