Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/FindmbedTLS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ endif ()
string(REGEX REPLACE ".*MBEDTLS_VERSION_STRING[\t ]+\"(.*)\"" "\\1" MBEDTLS_VERSION ${_MBEDTLS_VERLINE})

find_package_handle_standard_args(mbedTLS
REQUIRED_VARS MBEDTLS_TLS_LIBRARY MBEDTLS_CRYPTO_LIBRARY MBEDTLS_X509_LIBRARY MBEDTLS_INCLUDE_DIR VERSION_VAR MBEDTLS_VERSION)
REQUIRED_VARS MBEDTLS_TLS_LIBRARY MBEDTLS_CRYPTO_LIBRARY MBEDTLS_X509_LIBRARY MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARIES VERSION_VAR MBEDTLS_VERSION)

10 changes: 9 additions & 1 deletion cmake/NNGHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ function(nng_defines)
target_compile_definitions(nng_private INTERFACE ${ARGN})
endfunction()

# nng_find_package looks up required package and adds dependency to the cmake config.
macro(nng_find_package PACKAGE_NAME)
find_package(${PACKAGE_NAME} REQUIRED)
list(APPEND NNG_PKGS ${PACKAGE_NAME})
list(REMOVE_DUPLICATES NNG_PKGS)
set(NNG_PKGS ${NNG_PKGS} CACHE INTERNAL "nng package dependencies" FORCE)
endmacro()

# nng_link_libraries adds link dependencies to the libraries.
function(nng_link_libraries)
target_link_libraries(nng PRIVATE ${ARGN})
Expand Down Expand Up @@ -156,4 +164,4 @@ endfunction(nng_check_struct_member)

macro(nng_directory DIR)
set(NNG_TEST_PREFIX ${NNG_TEST_PREFIX}.${DIR})
endmacro(nng_directory)
endmacro(nng_directory)
4 changes: 4 additions & 0 deletions cmake/NNGOptions.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#
# Copyright 2020 Staysail Systems, Inc. <info@staysail.tech>
# Copyright 2022 Cogent Embedded, Inc.
#
# This software is supplied under the terms of the MIT License, a
# copy of which should be located in the distribution where this
Expand Down Expand Up @@ -46,6 +47,9 @@ mark_as_advanced(NNG_ENABLE_STATS)
option (NNG_PROTO_BUS0 "Enable BUSv0 protocol." ON)
mark_as_advanced(NNG_PROTO_BUS0)

option (NNG_PROTO_HUB0 "Enable HUBv0 protocol." ON)
mark_as_advanced(NNG_PROTO_HUB0)

option (NNG_PROTO_PAIR0 "Enable PAIRv0 protocol." ON)
mark_as_advanced(NNG_PROTO_PAIR0)

Expand Down
11 changes: 10 additions & 1 deletion cmake/nng-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ include("${CMAKE_CURRENT_LIST_DIR}/nng-targets.cmake")

# Make sure we find packages for our dependencies
foreach(_PKG IN ITEMS @NNG_PKGS@)
find_package(${_PKG} REQUIRED)
if (${_PKG} STREQUAL "mbedTLS")
# Workaround to use FindmbedTLS.cmake from installed location
set(BACKUP_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
get_filename_component(NNG_CONFIG_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(CMAKE_MODULE_PATH ${NNG_CONFIG_DIR})
find_package(${_PKG} REQUIRED)
set(CMAKE_MODULE_PATH ${BACKUP_CMAKE_MODULE_PATH})
else()
find_package(${_PKG} REQUIRED)
endif()
endforeach ()

set(NNG_LIBRARY nng::nng)
Expand Down
2 changes: 2 additions & 0 deletions docs/man/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ if (NNG_ENABLE_DOC)
nng_aio_wait
nng_alloc
nng_bus_open
nng_hub_open
nng_close
nng_ctx_close
nng_ctx_get
Expand Down Expand Up @@ -379,6 +380,7 @@ if (NNG_ENABLE_DOC)
set(NNG_MAN7
nng
nng_bus
nng_hub
nng_inproc
nng_ipc
nng_pair
Expand Down
2 changes: 2 additions & 0 deletions docs/man/libnng.3.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
// Copyright 2019 Devolutions <info@devolutions.net>
// Copyright 2020 Dirac Research <robert.bielik@dirac.com>
// Copyright 2022 Cogent Embedded, Inc.
//
// This document is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
Expand Down Expand Up @@ -193,6 +194,7 @@ The following functions are used to construct a socket with a specific protocol:

|===
|xref:nng_bus_open.3.adoc[nng_bus_open()]|open a bus socket
|xref:nng_hub_open.3.adoc[nng_hub_open()]|open a hub socket
|xref:nng_pair_open.3.adoc[nng_pair_open()]|open a pair socket
|xref:nng_pub_open.3.adoc[nng_pub_open()]|open a pub socket
|xref:nng_pull_open.3.adoc[nng_pull_open()]|open a pull socket
Expand Down
2 changes: 2 additions & 0 deletions docs/man/nng.7.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
= nng(7)
//
// Copyright 2022 Cogent Embedded, Inc.
// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
Expand Down Expand Up @@ -54,6 +55,7 @@ other languages please check the http://nanomsg.org/[website].

[horizontal]
xref:nng_bus.7.adoc[nng_bus(7)]:: Bus protocol
xref:nng_hub.7.adoc[nng_hub(7)]:: Hub protocol
xref:nng_pair.7.adoc[nng_pair(7)]:: Pair protocol
xref:nng_pub.7.adoc[nng_pub(7)]:: Publisher side of publish/subscribe protocol
xref:nng_pull.7.adoc[nng_pull(7)]:: Pull side of pipeline protocol
Expand Down
58 changes: 58 additions & 0 deletions docs/man/nng_hub.7.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
= nng_hub(7)
//
// Copyright 2022 Cogent Embedded, Inc.
//
// This document 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.
//

== NAME

nng_hub - hub protocol

== SYNOPSIS

[source,c]
----
#include <nng/protocol/hub0/hub.h>
----

== DESCRIPTION

(((protocol, _hub_)))
The ((_hub_ protocol)) provides for building star networks where
all peers are connected to one peer.
In this protocol, each message sent by a node is sent to every one of
its directly connected peers.

All message delivery in this pattern is guaranteed.

This protocol is compatible with pair0

=== Socket Operations

The xref:nng_hub_open.3.adoc[`nng_hub0_open()`] functions create a hub socket.
This socket may be used to send and receive messages.
Sending messages will attempt to deliver to each connected peer.

=== Protocol Versions

Only version 0 of this protocol is supported.
(At the time of writing, no other versions of this protocol have been defined.)

=== Protocol Options

The _hub_ protocol has no protocol-specific options.

=== Protocol Headers

No message headers are present.

== SEE ALSO

[.text-left]
xref:nng_hub_open.3.adoc[nng_hub_open(3)],
xref:nng_pair.7.adoc[nng_pair],
xref:nng.7.adoc[nng(7)]
45 changes: 45 additions & 0 deletions docs/man/nng_hub_open.3.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
= nng_hub_open(3)
//
// Copyright 2022 Cogent Embedded, Inc.
//
// This document 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.
//

== NAME

nng_hub_open - create hub socket

== SYNOPSIS

[source,c]
----
#include <nng/nng.h>
#include <nng/protocol/hub0/hub.h>

int nng_hub0_open(nng_socket *s);
----

== DESCRIPTION

The `nng_hub0_open()` function creates a xref:nng_hub.7.adoc[_hub_] version 0
xref:nng_socket.5.adoc[socket] and returns it at the location pointed to by _s_.

== RETURN VALUES

These functions return 0 on success, and non-zero otherwise.

== ERRORS

[horizontal]
`NNG_ENOMEM`:: Insufficient memory is available.
`NNG_ENOTSUP`:: The protocol is not supported.

== SEE ALSO

[.text-left]
xref:nng_socket.5.adoc[nng_socket(5)],
xref:nng_hub.7.adoc[nng_hub(7)],
xref:nng.7.adoc[nng(7)]
31 changes: 31 additions & 0 deletions include/nng/protocol/hub0/hub.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// Copyright 2022 Cogent Embedded, Inc.
//
// 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_PROTOCOL_HUB0_HUB_H
#define NNG_PROTOCOL_HUB0_HUB_H

#ifdef __cplusplus
extern "C" {
#endif

#define NNG_HUB0_SELF 0x10
#define NNG_HUB0_PEER 0x10
#define NNG_HUB0_SELF_NAME "hub"
#define NNG_HUB0_PEER_NAME "hub"

NNG_DECL int nng_hub0_open(nng_socket *);

#ifndef nng_hub_open
#define nng_hub_open nng_hub0_open
#endif

#ifdef __cplusplus
}
#endif

#endif /* NNG_PROTOCOL_HUB0_HUB_H_ */
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}-config
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
PATH_VARS INCLUDE_INSTALL_DIRS)

install(FILES "${project_config}" "${version_config}"
install(FILES "${project_config}" "${version_config}" ${PROJECT_SOURCE_DIR}/cmake/FindmbedTLS.cmake
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
COMPONENT Library)
2 changes: 1 addition & 1 deletion src/core/taskq.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ nni_task_dispatch(nni_task *task)

nni_mtx_lock(&tq->tq_mtx);
nni_list_append(&tq->tq_tasks, task);
nni_cv_wake1(&tq->tq_sched_cv); // waking just one waiter is adequate
nni_cv_wake(&tq->tq_sched_cv);
nni_mtx_unlock(&tq->tq_mtx);
}

Expand Down
4 changes: 2 additions & 2 deletions src/platform/posix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# the static library unless they also go into the dynamic.
if (NNG_PLATFORM_POSIX)

find_package(Threads REQUIRED)
nng_find_package(Threads)
nng_link_libraries(Threads::Threads)

# Unconditionally declare the following feature test macros. These are
Expand Down Expand Up @@ -108,4 +108,4 @@ if (NNG_PLATFORM_POSIX)

nng_test(posix_ipcwinsec_test)

endif ()
endif ()
2 changes: 2 additions & 0 deletions src/sp/protocol/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#
# Copyright 2020 Staysail Systems, Inc. <info@staystail.tech>
# Copyright 2022 Cogent Embedded, Inc.
#
# This software is supplied under the terms of the MIT License, a
# copy of which should be located in the distribution where this
Expand All @@ -11,6 +12,7 @@
nng_directory(protocol)

add_subdirectory(bus0)
add_subdirectory(hub0)
add_subdirectory(pair0)
add_subdirectory(pair1)
add_subdirectory(pipeline0)
Expand Down
16 changes: 16 additions & 0 deletions src/sp/protocol/hub0/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Copyright 2022 Cogent Embedded, Inc.
#
# 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.
#

nng_directory(hub0)

nng_sources_if(NNG_PROTO_HUB0 hub.c)
nng_headers_if(NNG_PROTO_HUB0 nng/protocol/hub0/hub.h)
nng_defines_if(NNG_PROTO_HUB0 NNG_HAVE_HUB0)

nng_test(hub_test)
Loading