From 1a808eb90bbea075aa40ff40ee29507d37f41a10 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 6 Jan 2019 15:51:27 -0800 Subject: fixes #853 Move IPC options to nng.h --- include/nng/nng.h | 36 +++++++++++++++++++++++++++++++++++- include/nng/transport/ipc/ipc.h | 33 +-------------------------------- src/platform/posix/posix_ipc.h | 4 +--- src/platform/windows/win_ipc.h | 3 +-- src/platform/windows/win_tcp.h | 4 +--- 5 files changed, 39 insertions(+), 41 deletions(-) diff --git a/include/nng/nng.h b/include/nng/nng.h index 5ea9d374..3063a652 100644 --- a/include/nng/nng.h +++ b/include/nng/nng.h @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. +// Copyright 2019 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -754,6 +754,40 @@ enum nng_flag_enum { // state current). This is a boolean. #define NNG_OPT_TCP_KEEPALIVE "tcp-keepalive" +// IPC options. These will largely vary depending on the platform, +// as POSIX systems have very different options than Windows. + +// Security Descriptor. This option may only be set on listeners +// on the Windows platform, where the object is a pointer to a +// a Windows SECURITY_DESCRIPTOR. +#define NNG_OPT_IPC_SECURITY_DESCRIPTOR "ipc:security-descriptor" + +// Permissions bits. This option is only valid for listeners on +// POSIX platforms and others that honor UNIX style permission bits. +// Note that some platforms may not honor the permissions here, although +// at least Linux and macOS seem to do so. Check before you rely on +// this for security. +#define NNG_OPT_IPC_PERMISSIONS "ipc:permissions" + +// Peer UID. This is only available on POSIX style systems. +#define NNG_OPT_IPC_PEER_UID "ipc:peer-uid" + +// Peer GID (primary group). This is only available on POSIX style systems. +#define NNG_OPT_IPC_PEER_GID "ipc:peer-gid" + +// Peer process ID. Available on Windows, Linux, and SunOS. +// In theory we could obtain this with the first message sent, +// but we have elected not to do this for now. (Nice RFE for a FreeBSD +// guru though.) +#define NNG_OPT_IPC_PEER_PID "ipc:peer-pid" + +// Peer Zone ID. Only on SunOS systems. (Linux containers have no +// definable kernel identity; they are a user-land fabrication made up +// from various pieces of different namespaces. FreeBSD does have +// something called JailIDs, but it isn't obvious how to determine this, +// or even if processes can use IPC across jail boundaries.) +#define NNG_OPT_IPC_PEER_ZONEID "ipc:peer-zoneid" + // XXX: TBD: priorities, ipv4only // Statistics. These are for informational purposes only, and subject diff --git a/include/nng/transport/ipc/ipc.h b/include/nng/transport/ipc/ipc.h index 497fb2b5..c69c4dc9 100644 --- a/include/nng/transport/ipc/ipc.h +++ b/include/nng/transport/ipc/ipc.h @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. +// Copyright 2019 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -16,35 +16,4 @@ NNG_DECL int nng_ipc_register(void); -// Security Descriptor. This option may only be set on listeners -// on the Windows platform, where the object is a pointer to a -// a Windows SECURITY_DESCRIPTOR. -#define NNG_OPT_IPC_SECURITY_DESCRIPTOR "ipc:security-descriptor" - -// Permissions bits. This option is only valid for listeners on -// POSIX platforms and others that honor UNIX style permission bits. -// Note that some platforms may not honor the permissions here, although -// at least Linux and macOS seem to do so. Check before you rely on -// this for security. -#define NNG_OPT_IPC_PERMISSIONS "ipc:permissions" - -// Peer UID. This is only available on POSIX style systems. -#define NNG_OPT_IPC_PEER_UID "ipc:peer-uid" - -// Peer GID (primary group). This is only available on POSIX style systems. -#define NNG_OPT_IPC_PEER_GID "ipc:peer-gid" - -// Peer process ID. Available on Windows, Linux, and SunOS. -// In theory we could obtain this with the first message sent, -// but we have elected not to do this for now. (Nice RFE for a FreeBSD -// guru though.) -#define NNG_OPT_IPC_PEER_PID "ipc:peer-pid" - -// Peer Zone ID. Only on SunOS systems. (Linux containers have no -// definable kernel identity; they are a user-land fabrication made up -// from various pieces of different namespaces. FreeBSD does have -// something called JailIDs, but it isn't obvious how to determine this, -// or even if processes can use IPC across jail boundaries.) -#define NNG_OPT_IPC_PEER_ZONEID "ipc:peer-zoneid" - #endif // NNG_TRANSPORT_IPC_IPC_H diff --git a/src/platform/posix/posix_ipc.h b/src/platform/posix/posix_ipc.h index baf27206..bbe11f0d 100644 --- a/src/platform/posix/posix_ipc.h +++ b/src/platform/posix/posix_ipc.h @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. +// Copyright 2019 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // Copyright 2018 Devolutions // @@ -14,8 +14,6 @@ #ifdef NNG_PLATFORM_POSIX #include "platform/posix/posix_aio.h" -#include - #include // For mode_t struct nni_ipc_conn { diff --git a/src/platform/windows/win_ipc.h b/src/platform/windows/win_ipc.h index 781522b9..e8e83957 100644 --- a/src/platform/windows/win_ipc.h +++ b/src/platform/windows/win_ipc.h @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. +// Copyright 2019 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // Copyright 2018 Devolutions // @@ -16,7 +16,6 @@ #include "core/nng_impl.h" #include "win_impl.h" -#include #define IPC_PIPE_PREFIX "\\\\.\\pipe\\" diff --git a/src/platform/windows/win_tcp.h b/src/platform/windows/win_tcp.h index 96854ac1..1b34aa29 100644 --- a/src/platform/windows/win_tcp.h +++ b/src/platform/windows/win_tcp.h @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. +// Copyright 2019 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // Copyright 2018 Devolutions // @@ -16,8 +16,6 @@ #include "core/nng_impl.h" -#include - struct nni_tcp_conn { SOCKET s; nni_win_io recv_io; -- cgit v1.2.3-70-g09d2