diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-11-09 08:32:33 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-11-11 10:31:44 -0800 |
| commit | db5467e6c3b502f6e93a6f6c5d1f2a8f86a8eaa5 (patch) | |
| tree | 71fb23ed0f0e2eb980245fcdf72cf2fce5d152be /src/nng.c | |
| parent | 768eaa4d50a6a436b714188ec9c6b98fd729b306 (diff) | |
| download | nng-db5467e6c3b502f6e93a6f6c5d1f2a8f86a8eaa5.tar.gz nng-db5467e6c3b502f6e93a6f6c5d1f2a8f86a8eaa5.tar.bz2 nng-db5467e6c3b502f6e93a6f6c5d1f2a8f86a8eaa5.zip | |
Add new functions for socket identity.
These functions were added in the main branch for NNG 2.0, and
we add them here to facilitate converting any code that happened
to use the options (`NNG_OPT_PROTO`, `NNG_OPT_PROTONAME`,
`NNG_OPT_PEER`, `NNG_OPT_PEERNAME`, and `NNG_OPT_RAW`.
Its unlikely that many applications need this, but providing these
as a transition aid may help applications start adopting new APIs now.
Diffstat (limited to 'src/nng.c')
| -rw-r--r-- | src/nng.c | 79 |
1 files changed, 79 insertions, 0 deletions
@@ -1146,6 +1146,85 @@ nng_socket_get_addr(nng_socket id, const char *n, nng_sockaddr *v) } int +nng_socket_proto_id(nng_socket id, uint16_t *idp) +{ + int rv; + nni_sock *sock; + + if (((rv = nni_init()) != 0) || + ((rv = nni_sock_find(&sock, id.id)) != 0)) { + return (rv); + } + + *idp = nni_sock_proto_id(sock); + nni_sock_rele(sock); + return (0); +} + +int +nng_socket_peer_id(nng_socket id, uint16_t *idp) +{ + int rv; + nni_sock *sock; + + if (((rv = nni_init()) != 0) || + ((rv = nni_sock_find(&sock, id.id)) != 0)) { + return (rv); + } + + *idp = nni_sock_peer_id(sock); + nni_sock_rele(sock); + return (0); +} + +int +nng_socket_proto_name(nng_socket id, const char **name) +{ + int rv; + nni_sock *sock; + + if (((rv = nni_init()) != 0) || + ((rv = nni_sock_find(&sock, id.id)) != 0)) { + return (rv); + } + + *name = nni_sock_proto_name(sock); + nni_sock_rele(sock); + return (0); +} + +int +nng_socket_peer_name(nng_socket id, const char **name) +{ + int rv; + nni_sock *sock; + + if (((rv = nni_init()) != 0) || + ((rv = nni_sock_find(&sock, id.id)) != 0)) { + return (rv); + } + + *name = nni_sock_peer_name(sock); + nni_sock_rele(sock); + return (0); +} + +int +nng_socket_raw(nng_socket id, bool *rawp) +{ + int rv; + nni_sock *sock; + + if (((rv = nni_init()) != 0) || + ((rv = nni_sock_find(&sock, id.id)) != 0)) { + return (rv); + } + *rawp = nni_sock_raw(sock); + nni_sock_rele(sock); + return (0); +} + +int nng_pipe_notify(nng_socket s, nng_pipe_ev ev, nng_pipe_cb cb, void *arg) { int rv; |
