aboutsummaryrefslogtreecommitdiff
path: root/src/supplemental/tls/tls_common.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2025-11-09 09:36:52 -0800
committerGarrett D'Amore <garrett@damore.org>2025-11-10 05:26:05 -0800
commitc9e4b41e109b03ca9ffcf789f8278705451026c7 (patch)
tree335fcfc1218cda1344de8031ea9b352bece525ed /src/supplemental/tls/tls_common.h
parentfcd1adbb6d4d0307aacdd56034695a6083429163 (diff)
downloadnng-c9e4b41e109b03ca9ffcf789f8278705451026c7.tar.gz
nng-c9e4b41e109b03ca9ffcf789f8278705451026c7.tar.bz2
nng-c9e4b41e109b03ca9ffcf789f8278705451026c7.zip
refactor/dtls: Use message oriented send/receive for DTLS.
The protocol here needs to know and respect message boundaries.
Diffstat (limited to 'src/supplemental/tls/tls_common.h')
-rw-r--r--src/supplemental/tls/tls_common.h33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/supplemental/tls/tls_common.h b/src/supplemental/tls/tls_common.h
index 6d163fd5..78cfe793 100644
--- a/src/supplemental/tls/tls_common.h
+++ b/src/supplemental/tls/tls_common.h
@@ -15,6 +15,7 @@
#include "../../core/nng_impl.h"
+#include "core/lmq.h"
#include "tls_engine.h"
#ifndef NNG_TLS_TLS_COMMON_H
@@ -34,17 +35,30 @@
#define NNG_TLS_MAX_RECV_SIZE 16384
#endif
+// NNG_TLS_MAX_SEND_MSG_QUEUE limits the number of pending messages for
+// sending. This is only used for msg oriented transports like DTLS or SCTP.
+#ifndef NNG_TLS_MAX_SEND_MSG_QUEUE
+#define NNG_TLS_MAX_SEND_MSG_QUEUE 32
+#endif
+
+// NNG_TLS_MAX_RECV_MSG_QUEUE limits the number of pending messages for
+// receiving. This is only used for msg oriented transports like DTLS or SCTP.
+#ifndef NNG_TLS_MAX_RECV_MSG_QUEUE
+#define NNG_TLS_MAX_RECV_MSG_QUEUE 32
+#endif
+
// This file contains common code for TLS, and is only compiled if we
// have TLS configured in the system. In particular, this provides the
// parts of TLS support that are invariant relative to different TLS
// libraries, such as dialer and listener support.
struct nng_tls_config {
- nni_mtx lock;
- int ref;
- bool busy;
- bool key_is_set;
- size_t size;
+ nni_mtx lock;
+ int ref;
+ bool busy;
+ bool key_is_set;
+ nng_tls_mode mode;
+ size_t size;
// ... engine config data follows
};
@@ -64,9 +78,10 @@ typedef struct {
nng_tls_config *cfg;
size_t size;
nni_mtx lock;
- bool closed;
nni_atomic_flag did_close;
bool hs_done;
+ bool closed;
+ bool msg_oriented; // works with messages instead of streams
nni_list send_queue;
nni_list recv_queue;
@@ -86,13 +101,17 @@ typedef struct {
size_t bio_send_len;
size_t bio_send_head;
size_t bio_send_tail;
+ nni_lmq bio_send_lmq; // for msg oriented only
+ nni_lmq bio_recv_lmq; // for msg oriented only
+ nni_msg *bio_recv_msg; // for msg oriented only
nni_reap_node reap;
// ... engine connection data follows
} nni_tls_conn;
extern void nni_tls_fini(nni_tls_conn *conn);
-extern int nni_tls_init(nni_tls_conn *conn, nng_tls_config *cfg);
+extern int nni_tls_init(
+ nni_tls_conn *conn, nng_tls_config *cfg, bool msg_oriented);
extern int nni_tls_start(nni_tls_conn *conn, const nni_tls_bio_ops *biops,
void *bio, const nng_sockaddr *sa);
extern void nni_tls_stop(nni_tls_conn *conn);