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/posix/posix_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/posix/posix_ipcconn.c')
| -rw-r--r-- | src/platform/posix/posix_ipcconn.c | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/src/platform/posix/posix_ipcconn.c b/src/platform/posix/posix_ipcconn.c index fd3cdbd8..11bd03d8 100644 --- a/src/platform/posix/posix_ipcconn.c +++ b/src/platform/posix/posix_ipcconn.c @@ -300,6 +300,14 @@ ipc_recv(void *arg, nni_aio *aio) } static nng_err +ipc_sock_addr(void *arg, const nng_sockaddr **sap) +{ + ipc_conn *c = arg; + *sap = &c->sa; + return (NNG_OK); +} + +static nng_err ipc_get_peer_uid(void *arg, void *buf, size_t *szp, nni_type t) { ipc_conn *c = arg; @@ -367,13 +375,6 @@ ipc_get_peer_pid(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_int(id, buf, szp, t)); } -static nng_err -ipc_get_addr(void *arg, void *buf, size_t *szp, nni_type t) -{ - ipc_conn *c = arg; - return (nni_copyout_sockaddr(&c->sa, buf, szp, t)); -} - static void ipc_stop(void *arg) { @@ -413,14 +414,6 @@ ipc_free(void *arg) static const nni_option ipc_options[] = { { - .o_name = NNG_OPT_LOCADDR, - .o_get = ipc_get_addr, - }, - { - .o_name = NNG_OPT_REMADDR, - .o_get = ipc_get_addr, - }, - { .o_name = NNG_OPT_IPC_PEER_PID, .o_get = ipc_get_peer_pid, }, @@ -455,7 +448,7 @@ ipc_set(void *arg, const char *name, const void *val, size_t sz, nni_type t) return (nni_setopt(ipc_options, name, c, val, sz, t)); } -int +nng_err nni_posix_ipc_alloc( nni_ipc_conn **cp, nni_sockaddr *sa, nni_ipc_dialer *d, int fd) { @@ -465,16 +458,18 @@ nni_posix_ipc_alloc( return (NNG_ENOMEM); } - c->closed = false; - c->dialer = d; - 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->sa = *sa; + c->closed = false; + c->dialer = d; + 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_sock_addr, + c->stream.s_peer_addr = ipc_sock_addr; + c->sa = *sa; nni_mtx_init(&c->mtx); nni_aio_list_init(&c->readq); |
