From 3163a56e06a58abb10c753fc77da388234d580c2 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 9 Nov 2024 09:25:22 -0800 Subject: Add nng_sub0_subscribe and friends. These are new functions that replace `NNG_OPT_SUBSCRIBE` and `NNG_OPT_UNSUBSCRIBE`. They are provided here as a transition aid before those options are removed in NNG 2.0. --- src/core/socket.c | 18 ++++++++++++++++++ src/core/socket.h | 6 +++++- 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/socket.c b/src/core/socket.c index bf550a24..241b0401 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -889,12 +889,30 @@ nni_sock_proto_pipe_ops(nni_sock *sock) return (&sock->s_pipe_ops); } +struct nni_proto_sock_ops * +nni_sock_proto_ops(nni_sock *sock) +{ + return (&sock->s_sock_ops); +} + +struct nni_proto_ctx_ops * +nni_ctx_proto_ops(nni_ctx *ctx) +{ + return (&ctx->c_ops); +} + void * nni_sock_proto_data(nni_sock *sock) { return (sock->s_data); } +void * +nni_ctx_proto_data(nni_ctx *ctx) +{ + return (ctx->c_data); +} + int nni_sock_add_listener(nni_sock *s, nni_listener *l) { diff --git a/src/core/socket.h b/src/core/socket.h index 343310ca..d4bf1a97 100644 --- a/src/core/socket.h +++ b/src/core/socket.h @@ -1,5 +1,5 @@ // -// Copyright 2021 Staysail Systems, Inc. +// Copyright 2024 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -26,7 +26,9 @@ extern bool nni_sock_raw(nni_sock *); extern void *nni_sock_proto_data(nni_sock *); extern void nni_sock_add_stat(nni_sock *, nni_stat_item *); +extern struct nni_proto_sock_ops *nni_sock_proto_ops(nni_sock *); extern struct nni_proto_pipe_ops *nni_sock_proto_pipe_ops(nni_sock *); +extern struct nni_proto_ctx_ops *nni_ctx_proto_ops(nni_ctx *); extern int nni_sock_setopt( nni_sock *, const char *, const void *, size_t, nni_opt_type); @@ -89,6 +91,8 @@ extern void nni_ctx_close(nni_ctx *); // nni_ctx_id returns the context ID, which can be used with nni_ctx_find. extern uint32_t nni_ctx_id(nni_ctx *); +extern void *nni_ctx_proto_data(nni_ctx *); + // nni_ctx_recv receives asynchronously. extern void nni_ctx_recv(nni_ctx *, nni_aio *); -- cgit v1.2.3-70-g09d2