From af7df64ae78e939546b7c0093873995507d8c397 Mon Sep 17 00:00:00 2001 From: Simon Giesecke Date: Fri, 4 Sep 2020 15:24:24 +0200 Subject: [PATCH] Problem: mask and to_string member functions of tcp_address_mask_t are not referenced Solution: remove them --- src/tcp_address.cpp | 52 --------------------------------------------- src/tcp_address.hpp | 5 ----- 2 files changed, 57 deletions(-) diff --git a/src/tcp_address.cpp b/src/tcp_address.cpp index d788f3c4..bdda66a2 100644 --- a/src/tcp_address.cpp +++ b/src/tcp_address.cpp @@ -203,11 +203,6 @@ zmq::tcp_address_mask_t::tcp_address_mask_t () : _address_mask (-1) memset (&_network_address, 0, sizeof (_network_address)); } -int zmq::tcp_address_mask_t::mask () const -{ - return _address_mask; -} - int zmq::tcp_address_mask_t::resolve (const char *name_, bool ipv6_) { // Find '/' at the end that separates address from the cidr mask number. @@ -264,53 +259,6 @@ int zmq::tcp_address_mask_t::resolve (const char *name_, bool ipv6_) return 0; } -int zmq::tcp_address_mask_t::to_string (std::string &addr_) const -{ - if (_network_address.family () != AF_INET - && _network_address.family () != AF_INET6) { - addr_.clear (); - return -1; - } - if (_address_mask == -1) { - addr_.clear (); - return -1; - } - - char hbuf[NI_MAXHOST]; - const int rc = getnameinfo (_network_address.as_sockaddr (), - _network_address.sockaddr_len (), hbuf, - sizeof (hbuf), NULL, 0, NI_NUMERICHOST); - if (rc != 0) { - addr_.clear (); - return rc; - } - - const size_t max_mask_len = 4; - const char ipv6_prefix[] = "["; - const char ipv6_suffix[] = "]/"; - const char ipv4_suffix[] = "/"; - char - buf[NI_MAXHOST + sizeof ipv6_prefix + sizeof ipv6_suffix + max_mask_len]; - char *pos = buf; - if (_network_address.family () == AF_INET6) { - memcpy (pos, ipv6_prefix, sizeof ipv6_prefix - 1); - pos += sizeof ipv6_prefix - 1; - } - const size_t hbuf_len = strlen (hbuf); - memcpy (pos, hbuf, hbuf_len); - pos += hbuf_len; - if (_network_address.family () == AF_INET6) { - memcpy (pos, ipv6_suffix, sizeof ipv6_suffix - 1); - pos += sizeof ipv6_suffix - 1; - } else { - memcpy (pos, ipv4_suffix, sizeof ipv4_suffix - 1); - pos += sizeof ipv4_suffix - 1; - } - pos += sprintf (pos, "%d", _address_mask); - addr_.assign (buf, pos - buf); - return 0; -} - bool zmq::tcp_address_mask_t::match_address (const struct sockaddr *ss_, const socklen_t ss_len_) const { diff --git a/src/tcp_address.hpp b/src/tcp_address.hpp index 6e69f615..4d3edf49 100644 --- a/src/tcp_address.hpp +++ b/src/tcp_address.hpp @@ -82,11 +82,6 @@ class tcp_address_mask_t // Works only with remote hostnames. int resolve (const char *name_, bool ipv6_); - // The opposite to resolve() - int to_string (std::string &addr_) const; - - int mask () const; - bool match_address (const struct sockaddr *ss_, socklen_t ss_len_) const; private: