aboutsummaryrefslogtreecommitdiff
path: root/src/transport/ipc/ipc.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-05-03 14:28:44 -0700
committerGarrett D'Amore <garrett@damore.org>2018-05-03 15:14:45 -0700
commitafd555af4fba0acbf16c174dd9dece24181a1a38 (patch)
tree9d49fec85c58ecad9a034a98e092627968494bc0 /src/transport/ipc/ipc.c
parentfa986e725f08e30eab68e16765b2cf71613b871c (diff)
downloadnng-afd555af4fba0acbf16c174dd9dece24181a1a38.tar.gz
nng-afd555af4fba0acbf16c174dd9dece24181a1a38.tar.bz2
nng-afd555af4fba0acbf16c174dd9dece24181a1a38.zip
fixes #383 Would like peerid for IPC
We offer uid, gid, process id, and even zone id where we have them. Docs and tests are provided.
Diffstat (limited to 'src/transport/ipc/ipc.c')
-rw-r--r--src/transport/ipc/ipc.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/transport/ipc/ipc.c b/src/transport/ipc/ipc.c
index 3dbccb50..e5f3d533 100644
--- a/src/transport/ipc/ipc.c
+++ b/src/transport/ipc/ipc.c
@@ -537,6 +537,54 @@ nni_ipc_pipe_get_addr(void *arg, void *buf, size_t *szp, int typ)
return (nni_copyout_sockaddr(&p->sa, buf, szp, typ));
}
+static int
+nni_ipc_pipe_get_peer_uid(void *arg, void *buf, size_t *szp, int typ)
+{
+ nni_ipc_pipe *p = arg;
+ uint64_t id;
+ int rv;
+ if ((rv = nni_plat_ipc_pipe_get_peer_uid(p->ipp, &id)) != 0) {
+ return (rv);
+ }
+ return (nni_copyout_u64(id, buf, szp, typ));
+}
+
+static int
+nni_ipc_pipe_get_peer_gid(void *arg, void *buf, size_t *szp, int typ)
+{
+ nni_ipc_pipe *p = arg;
+ uint64_t id;
+ int rv;
+ if ((rv = nni_plat_ipc_pipe_get_peer_gid(p->ipp, &id)) != 0) {
+ return (rv);
+ }
+ return (nni_copyout_u64(id, buf, szp, typ));
+}
+
+static int
+nni_ipc_pipe_get_peer_pid(void *arg, void *buf, size_t *szp, int typ)
+{
+ nni_ipc_pipe *p = arg;
+ uint64_t id;
+ int rv;
+ if ((rv = nni_plat_ipc_pipe_get_peer_pid(p->ipp, &id)) != 0) {
+ return (rv);
+ }
+ return (nni_copyout_u64(id, buf, szp, typ));
+}
+
+static int
+nni_ipc_pipe_get_peer_zoneid(void *arg, void *buf, size_t *szp, int typ)
+{
+ nni_ipc_pipe *p = arg;
+ uint64_t id;
+ int rv;
+ if ((rv = nni_plat_ipc_pipe_get_peer_zoneid(p->ipp, &id)) != 0) {
+ return (rv);
+ }
+ return (nni_copyout_u64(id, buf, szp, typ));
+}
+
static void
nni_ipc_ep_fini(void *arg)
{
@@ -785,6 +833,26 @@ static nni_tran_pipe_option nni_ipc_pipe_options[] = {
.po_type = NNI_TYPE_SOCKADDR,
.po_getopt = nni_ipc_pipe_get_addr,
},
+ {
+ .po_name = NNG_OPT_IPC_PEER_UID,
+ .po_type = NNI_TYPE_UINT64,
+ .po_getopt = nni_ipc_pipe_get_peer_uid,
+ },
+ {
+ .po_name = NNG_OPT_IPC_PEER_GID,
+ .po_type = NNI_TYPE_UINT64,
+ .po_getopt = nni_ipc_pipe_get_peer_gid,
+ },
+ {
+ .po_name = NNG_OPT_IPC_PEER_PID,
+ .po_type = NNI_TYPE_UINT64,
+ .po_getopt = nni_ipc_pipe_get_peer_pid,
+ },
+ {
+ .po_name = NNG_OPT_IPC_PEER_ZONEID,
+ .po_type = NNI_TYPE_UINT64,
+ .po_getopt = nni_ipc_pipe_get_peer_zoneid,
+ },
// terminate list
{
.po_name = NULL,