diff options
| author | Garrett D'Amore <garrett@damore.org> | 2025-10-25 11:43:59 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2025-10-25 20:11:51 -0700 |
| commit | cc419cf01d9c060a3bd3fc318f9b9bc9e736dae9 (patch) | |
| tree | 2f26cd782a54bed35e03b451003deee5df701983 /src/platform/windows/win_ipcconn.c | |
| parent | ebc479a61b8f2d2f3a6d846d18debfb9022e6010 (diff) | |
| download | nng-cc419cf01d9c060a3bd3fc318f9b9bc9e736dae9.tar.gz nng-cc419cf01d9c060a3bd3fc318f9b9bc9e736dae9.tar.bz2 nng-cc419cf01d9c060a3bd3fc318f9b9bc9e736dae9.zip | |
Add stream direct address functions for socket addresses.
This is going to be used to facilitate debugging, and eliminate some
inconveniences around these things. We plan to move the pipe functions
to use these directly, hopefully moving away from the pipe_getopt hack.
(The transport API will need to grow these. For now this is just the
streams.)
Diffstat (limited to 'src/platform/windows/win_ipcconn.c')
| -rw-r--r-- | src/platform/windows/win_ipcconn.c | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/src/platform/windows/win_ipcconn.c b/src/platform/windows/win_ipcconn.c index 45235387..a5ef16a6 100644 --- a/src/platform/windows/win_ipcconn.c +++ b/src/platform/windows/win_ipcconn.c @@ -9,8 +9,8 @@ // found online at https://opensource.org/licenses/MIT. // -#include "core/aio.h" -#include "core/nng_impl.h" +#include "../../core/nng_impl.h" +#include "win_impl.h" #include "win_ipc.h" @@ -276,7 +276,7 @@ ipc_send_cb(nni_win_io *io, int rv, size_t num) } static void -ipc_send_cancel(nni_aio *aio, void *arg, int rv) +ipc_send_cancel(nni_aio *aio, void *arg, nng_err rv) { ipc_conn *c = arg; nni_mtx_lock(&c->mtx); @@ -388,12 +388,6 @@ ipc_free(void *arg) } static nng_err -ipc_conn_get_addr(void *c, void *buf, size_t *szp, nni_opt_type t) -{ - return (nni_copyout_sockaddr(&(CONN(c))->sa, buf, szp, t)); -} - -static nng_err ipc_conn_get_peer_pid(void *c, void *buf, size_t *szp, nni_opt_type t) { ULONG id; @@ -415,14 +409,6 @@ ipc_conn_get_peer_pid(void *c, void *buf, size_t *szp, nni_opt_type t) static const nni_option ipc_conn_options[] = { { - .o_name = NNG_OPT_LOCADDR, - .o_get = ipc_conn_get_addr, - }, - { - .o_name = NNG_OPT_REMADDR, - .o_get = ipc_conn_get_addr, - }, - { .o_name = NNG_OPT_IPC_PEER_PID, .o_get = ipc_conn_get_peer_pid, }, @@ -445,6 +431,14 @@ ipc_get(void *arg, const char *nm, void *val, size_t *szp, nni_opt_type t) return (nni_getopt(ipc_conn_options, nm, c, val, szp, t)); } +static nng_err +ipc_addr(void *arg, const nng_sockaddr **sap) +{ + ipc_conn *c = arg; + *sap = &c->sa; + return (NNG_OK); +} + int nni_win_ipc_init( nng_stream **connp, HANDLE p, const nng_sockaddr *sa, bool dialer) @@ -459,15 +453,17 @@ nni_win_ipc_init( nni_cv_init(&c->cv, &c->mtx); nni_aio_list_init(&c->recv_aios); nni_aio_list_init(&c->send_aios); - c->dialer = dialer; - c->sa = *sa; - c->stream.s_free = ipc_free; - c->stream.s_close = ipc_close; - c->stream.s_stop = ipc_stop; - c->stream.s_send = ipc_send; - c->stream.s_recv = ipc_recv; - c->stream.s_get = ipc_get; - c->stream.s_set = ipc_set; + c->dialer = dialer; + c->sa = *sa; + c->stream.s_free = ipc_free; + c->stream.s_close = ipc_close; + c->stream.s_stop = ipc_stop; + c->stream.s_send = ipc_send; + c->stream.s_recv = ipc_recv; + c->stream.s_get = ipc_get; + c->stream.s_set = ipc_set; + c->stream.s_self_addr = ipc_addr; + c->stream.s_peer_addr = ipc_addr; nni_win_io_init(&c->recv_io, ipc_recv_cb, c); nni_win_io_init(&c->send_io, ipc_send_cb, c); |
