aboutsummaryrefslogtreecommitdiff
path: root/src/platform/windows
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-12-29 18:54:22 -0800
committerGarrett D'Amore <garrett@damore.org>2018-12-29 18:54:22 -0800
commit27b7827532abcbdbecc54795da5b5ac66e7f5e9f (patch)
tree7c8fad19dbb874af35324603204aae87f93d63b8 /src/platform/windows
parent5b35daaf2fe6c6fbe0b15740efbffe16ff278e6c (diff)
downloadnng-27b7827532abcbdbecc54795da5b5ac66e7f5e9f.tar.gz
nng-27b7827532abcbdbecc54795da5b5ac66e7f5e9f.tar.bz2
nng-27b7827532abcbdbecc54795da5b5ac66e7f5e9f.zip
progress on IPC endpoints
Diffstat (limited to 'src/platform/windows')
-rw-r--r--src/platform/windows/win_ipc.h4
-rw-r--r--src/platform/windows/win_ipcconn.c4
-rw-r--r--src/platform/windows/win_ipcdial.c21
-rw-r--r--src/platform/windows/win_ipclisten.c67
4 files changed, 77 insertions, 19 deletions
diff --git a/src/platform/windows/win_ipc.h b/src/platform/windows/win_ipc.h
index 9a4e245a..781522b9 100644
--- a/src/platform/windows/win_ipc.h
+++ b/src/platform/windows/win_ipc.h
@@ -1,7 +1,7 @@
//
// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
-// Copyright 2018 Devolutions <infos@devolutions.net>
+// Copyright 2018 Devolutions <info@devolutions.net>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -16,6 +16,7 @@
#include "core/nng_impl.h"
#include "win_impl.h"
+#include <nng/transport/ipc/ipc.h>
#define IPC_PIPE_PREFIX "\\\\.\\pipe\\"
@@ -54,6 +55,7 @@ struct nni_ipc_listener {
nni_mtx mtx;
nni_cv cv;
nni_win_io io;
+ nni_sockaddr sa;
int rv;
};
diff --git a/src/platform/windows/win_ipcconn.c b/src/platform/windows/win_ipcconn.c
index 5a1e4743..ded9ed76 100644
--- a/src/platform/windows/win_ipcconn.c
+++ b/src/platform/windows/win_ipcconn.c
@@ -1,7 +1,7 @@
//
// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
-// Copyright 2018 Devolutions <infos@devolutions.net>
+// Copyright 2018 Devolutions <info@devolutions.net>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -15,8 +15,6 @@
#include <stdio.h>
-#include <nng/transport/ipc/ipc.h>
-
#define CONN(c) ((nni_ipc_conn *) (c))
static void
diff --git a/src/platform/windows/win_ipcdial.c b/src/platform/windows/win_ipcdial.c
index 4c3d5c6c..98d848ae 100644
--- a/src/platform/windows/win_ipcdial.c
+++ b/src/platform/windows/win_ipcdial.c
@@ -1,6 +1,7 @@
//
// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
+// Copyright 2018 Devolutions <info@devolutions.net>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -227,6 +228,26 @@ nni_ipc_dialer_close(nni_ipc_dialer *d)
nni_mtx_unlock(&w->mtx);
}
+static const nni_option ipc_dialer_options[] = {
+ {
+ .o_name = NULL,
+ },
+};
+
+int
+nni_ipc_dialer_setopt(nni_ipc_dialer *d, const char *name, const void *buf,
+ size_t sz, nni_type t)
+{
+ return (nni_setopt(ipc_dialer_options, name, d, buf, sz, t));
+}
+
+int
+nni_ipc_dialer_getopt(
+ nni_ipc_dialer *d, const char *name, void *buf, size_t *szp, nni_type t)
+{
+ return (nni_getopt(ipc_dialer_options, name, d, buf, szp, t));
+}
+
int
nni_win_ipc_sysinit(void)
{
diff --git a/src/platform/windows/win_ipclisten.c b/src/platform/windows/win_ipclisten.c
index d0fd6ef9..4b3660ec 100644
--- a/src/platform/windows/win_ipclisten.c
+++ b/src/platform/windows/win_ipclisten.c
@@ -1,6 +1,7 @@
//
// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
+// Copyright 2018 Devolutions <info@devolutions.net>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -146,30 +147,66 @@ nni_ipc_listener_init(nni_ipc_listener **lp)
return (0);
}
-int
-nni_ipc_listener_set_permissions(nni_ipc_listener *l, int bits)
+static int
+ipc_listener_set_sec_desc(void *arg, const void *buf, size_t sz, nni_type t)
{
- NNI_ARG_UNUSED(l);
- NNI_ARG_UNUSED(bits);
- return (NNG_ENOTSUP);
-}
+ nni_ipc_listener *l = arg;
+ void * desc;
+ int rv;
-int
-nni_ipc_listener_set_security_descriptor(nni_ipc_listener *l, void *desc)
-{
+ if ((rv = nni_copyin_ptr(&desc, buf, sz, t)) != 0) {
+ return (rv);
+ }
if (!IsValidSecurityDescriptor((SECURITY_DESCRIPTOR *) desc)) {
return (NNG_EINVAL);
}
- nni_mtx_lock(&l->mtx);
- if (l->started) {
+ if (l != NULL) {
+ nni_mtx_lock(&l->mtx);
+ if (l->started) {
+ nni_mtx_unlock(&l->mtx);
+ return (NNG_EBUSY);
+ }
+ l->sec_attr.lpSecurityDescriptor = desc;
nni_mtx_unlock(&l->mtx);
- return (NNG_EBUSY);
}
- l->sec_attr.lpSecurityDescriptor = desc;
- nni_mtx_unlock(&l->mtx);
return (0);
}
+static int
+ipc_listener_get_addr(void *arg, void *buf, size_t *szp, nni_type t)
+{
+ nni_ipc_listener *l = arg;
+ return ((nni_copyout_sockaddr(&l->sa, buf, szp, t)));
+}
+
+static const nni_option ipc_listener_options[] = {
+ {
+ .o_name = NNG_OPT_IPC_SECURITY_DESCRIPTOR,
+ .o_set = ipc_listener_set_sec_desc,
+ },
+ {
+ .o_name = NNG_OPT_LOCADDR,
+ .o_get = ipc_listener_get_addr,
+ },
+ {
+ .o_name = NULL,
+ },
+};
+
+int
+nni_ipc_listener_setopt(nni_ipc_listener *l, const char *name, const void *buf,
+ size_t sz, nni_type t)
+{
+ return (nni_setopt(ipc_listener_options, name, l, buf, sz, t));
+}
+
+int
+nni_ipc_listener_getopt(
+ nni_ipc_listener *l, const char *name, void *buf, size_t *szp, nni_type t)
+{
+ return (nni_getopt(ipc_listener_options, name, l, buf, szp, t));
+}
+
int
nni_ipc_listener_listen(nni_ipc_listener *l, const nni_sockaddr *sa)
{
@@ -218,6 +255,7 @@ nni_ipc_listener_listen(nni_ipc_listener *l, const nni_sockaddr *sa)
l->f = f;
l->path = path;
l->started = true;
+ l->sa = *sa;
nni_mtx_unlock(&l->mtx);
return (0);
}
@@ -266,7 +304,6 @@ nni_ipc_listener_accept(nni_ipc_listener *l, nni_aio *aio)
void
nni_ipc_listener_close(nni_ipc_listener *l)
{
-
nni_mtx_lock(&l->mtx);
if (!l->closed) {
l->closed = true;