aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2025-05-11 21:11:09 -0700
committerGarrett D'Amore <garrett@damore.org>2025-05-26 19:08:14 -0700
commit08400bd437149c4fb31af9b2abece2ae44041283 (patch)
tree92e70ad8ffc0e074ea56fe0d062acedbd4245de6 /include
parent5d1254fc3d52d8b7421ca152eed1a79a1a50d37c (diff)
downloadnng-08400bd437149c4fb31af9b2abece2ae44041283.tar.gz
nng-08400bd437149c4fb31af9b2abece2ae44041283.tar.bz2
nng-08400bd437149c4fb31af9b2abece2ae44041283.zip
Add new nng_sockaddr_equal and nng_sockaddr_hash functions.
These are intended for new transports. Right now they are not documented, but that will be addressed soon.
Diffstat (limited to 'include')
-rw-r--r--include/nng/nng.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/include/nng/nng.h b/include/nng/nng.h
index 89fae345..32605e3c 100644
--- a/include/nng/nng.h
+++ b/include/nng/nng.h
@@ -317,7 +317,20 @@ NNG_DECL const char *nng_str_sockaddr(
// Obtain a port number (for NNG_AF_INET and NNG_AF_INET6this will be 16 bits
// maximum, but other address familiies may have larger port numbers.) For
// address that don't have the concept of port numbers, zero will be returned.
-uint32_t nng_sockaddr_port(const nng_sockaddr *sa);
+NNG_DECL uint32_t nng_sockaddr_port(const nng_sockaddr *sa);
+
+// Compare two socket addresses. Returns true if they are equal, false
+// otherwise.
+NNG_DECL bool nng_sockaddr_equal(
+ const nng_sockaddr *sa1, const nng_sockaddr *sa2);
+
+// Generate a quick non-zero 64-bit value for the sockaddr.
+// This should usually be unique, but collisions are possible.
+// The resulting hash is not portable between systems, and may not
+// be portable from one version of NNG to the next.
+//
+// The intended use is to allow creation of an index for use with id maps.
+NNG_DECL uint64_t nng_sockaddr_hash(const nng_sockaddr *sa);
// Arguably the pipe callback functions could be handled as an option,
// but with the need to specify an argument, we find it best to unify