aboutsummaryrefslogtreecommitdiff
path: root/src/transport/tcp
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-10-31 13:06:38 -0700
committerGarrett D'Amore <garrett@damore.org>2017-11-02 16:10:26 -0700
commit7bf591e20a94b8d926f92ab9b320f3b75d342345 (patch)
treed67ce7cab328a004346419047feede7d579dad77 /src/transport/tcp
parentd340af7dc250388f48d36c5078c4857c51bb6121 (diff)
downloadnng-7bf591e20a94b8d926f92ab9b320f3b75d342345.tar.gz
nng-7bf591e20a94b8d926f92ab9b320f3b75d342345.tar.bz2
nng-7bf591e20a94b8d926f92ab9b320f3b75d342345.zip
fixes #143 Protocols and transports should be "configurable"
This makes all the protocols and transports optional. All of them except ZeroTier are enabled by default, but you can now disable them (remove from the build) with cmake options. The test suite is modified so that tests still run as much as they can, but skip over things caused by missing functionality from the library (due to configuration). Further, the constant definitions and prototypes for functions that are specific to transports or protocols are moved into appropriate headers, which should be included directly by applications wishing to use these. We have also added and improved documentation -- all of the transports are documented, and several more man pages for protocols have been added. (Req/Rep and Surveyor are still missing.)
Diffstat (limited to 'src/transport/tcp')
-rw-r--r--src/transport/tcp/CMakeLists.txt18
-rw-r--r--src/transport/tcp/tcp.c10
-rw-r--r--src/transport/tcp/tcp.h18
3 files changed, 43 insertions, 3 deletions
diff --git a/src/transport/tcp/CMakeLists.txt b/src/transport/tcp/CMakeLists.txt
new file mode 100644
index 00000000..305c357a
--- /dev/null
+++ b/src/transport/tcp/CMakeLists.txt
@@ -0,0 +1,18 @@
+#
+# Copyright 2017 Garrett D'Amore <garrett@damore.org>
+# Copyright 2017 Capitar IT Group BV <info@capitar.com>
+#
+# This software is supplied under the terms of the MIT License, a
+# copy of which should be located in the distribution where this
+# file was obtained (LICENSE.txt). A copy of the license may also be
+# found online at https://opensource.org/licenses/MIT.
+#
+
+# TCP protocol
+
+if (NNG_TRANSPORT_TCP)
+ set(TCP_SOURCES transport/tcp/tcp.c transport/tcp/tcp.h)
+ install(FILES tcp.h DESTINATION include/nng/transport/tcp)
+endif()
+
+set(NNG_SOURCES ${NNG_SOURCES} ${TCP_SOURCES} PARENT_SCOPE)
diff --git a/src/transport/tcp/tcp.c b/src/transport/tcp/tcp.c
index 43b2890d..e33db865 100644
--- a/src/transport/tcp/tcp.c
+++ b/src/transport/tcp/tcp.c
@@ -854,9 +854,7 @@ static nni_tran_ep nni_tcp_ep_ops = {
.ep_options = nni_tcp_ep_options,
};
-// This is the TCP transport linkage, and should be the only global
-// symbol in this entire file.
-struct nni_tran nni_tcp_tran = {
+static nni_tran nni_tcp_tran = {
.tran_version = NNI_TRANSPORT_VERSION,
.tran_scheme = "tcp",
.tran_ep = &nni_tcp_ep_ops,
@@ -864,3 +862,9 @@ struct nni_tran nni_tcp_tran = {
.tran_init = nni_tcp_tran_init,
.tran_fini = nni_tcp_tran_fini,
};
+
+int
+nng_tcp_register(void)
+{
+ return (nni_tran_register(&nni_tcp_tran));
+}
diff --git a/src/transport/tcp/tcp.h b/src/transport/tcp/tcp.h
new file mode 100644
index 00000000..b4c79461
--- /dev/null
+++ b/src/transport/tcp/tcp.h
@@ -0,0 +1,18 @@
+//
+// Copyright 2017 Garrett D'Amore <garrett@damore.org>
+// Copyright 2017 Capitar IT Group BV <info@capitar.com>
+//
+// This software is supplied under the terms of the MIT License, a
+// copy of which should be located in the distribution where this
+// file was obtained (LICENSE.txt). A copy of the license may also be
+// found online at https://opensource.org/licenses/MIT.
+//
+
+#ifndef NNG_TRANSPORT_TCP_TCP_H
+#define NNG_TRANSPORT_TCP_TCP_H
+
+// TCP transport. This is used for communication over TCP/IP.
+
+extern int nng_tcp_register(void);
+
+#endif // NNG_TRANSPORT_TCP_TCP_H