From 30307eab84d7e026d8a2357ae737d6b9fe4e6f7c Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 12 Jun 2023 12:21:52 -0700 Subject: [PATCH] consolidate config common to both server and client --- src/config.cpp | 3 +++ src/pvxs/client.h | 12 +----------- src/pvxs/netcommon.h | 15 ++++++++++++++- src/pvxs/server.h | 10 +--------- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index 96bca3ebc..6fb16d17e 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -29,6 +29,9 @@ DEFINE_LOGGER(config, "pvxs.config"); namespace pvxs { +namespace impl { +ConfigCommon::~ConfigCommon() {} +} // namespace impl SockEndpoint::SockEndpoint(const char* ep, uint16_t defport) { // diff --git a/src/pvxs/client.h b/src/pvxs/client.h index 2a5383efa..3de58860a 100644 --- a/src/pvxs/client.h +++ b/src/pvxs/client.h @@ -1002,7 +1002,7 @@ class DiscoverBuilder }; DiscoverBuilder Context::discover(std::function && fn) { return DiscoverBuilder(pvt, std::move(fn)); } -struct PVXS_API Config { +struct PVXS_API Config : public impl::ConfigCommon { /** List of unicast, multicast, and broadcast addresses to which search requests will be sent. * * Entries may take the forms: @@ -1021,19 +1021,9 @@ struct PVXS_API Config { //! @since 0.2.0 std::vector nameServers; - //! UDP port to bind. Default is 5076. May be zero, cf. Server::config() to find allocated port. - unsigned short udp_port = 5076; - //! Default TCP port for name servers - //! @since 0.2.0 - unsigned short tcp_port = 5075; - //! Whether to extend the addressList with local interface broadcast addresses. (recommended) bool autoAddrList = true; - //! Inactivity timeout interval for TCP connections. (seconds) - //! @since 0.2.0 - double tcpTimeout = 40.0; - private: bool BE = EPICS_BYTE_ORDER==EPICS_ENDIAN_BIG; bool UDP = true; diff --git a/src/pvxs/netcommon.h b/src/pvxs/netcommon.h index d9e86b26d..0b23b2b68 100644 --- a/src/pvxs/netcommon.h +++ b/src/pvxs/netcommon.h @@ -74,7 +74,20 @@ struct PVXS_API ReportInfo { virtual ~ReportInfo(); }; -#endif +#endif // PVXS_EXPERT_API_ENABLED + +struct PVXS_API ConfigCommon { + virtual ~ConfigCommon() =0; + + //! TCP port to bind. Default is 5075. May be zero. + unsigned short tcp_port = 5075; + //! UDP port to bind. Default is 5076. May be zero, cf. Server::config() to find allocated port. + unsigned short udp_port = 5076; + + //! Inactivity timeout interval for TCP connections. (seconds) + //! @since 0.2.0 + double tcpTimeout = 40.0; +}; } // namespace impl } // namespace pvxs diff --git a/src/pvxs/server.h b/src/pvxs/server.h index 03fe66579..9f83d4322 100644 --- a/src/pvxs/server.h +++ b/src/pvxs/server.h @@ -150,7 +150,7 @@ PVXS_API std::ostream& operator<<(std::ostream& strm, const Server& serv); //! Configuration for a Server -struct PVXS_API Config { +struct PVXS_API Config : public impl::ConfigCommon { //! List of network interface addresses (**not** host names) to which this server will bind. //! interfaces.empty() treated as an alias for "0.0.0.0", which may also be given explicitly. //! Port numbers are optional and unused (parsed and ignored) @@ -164,17 +164,9 @@ struct PVXS_API Config { //! May include broadcast and/or unicast addresses. //! Supplemented only if auto_beacon==true std::vector beaconDestinations; - //! TCP port to bind. Default is 5075. May be zero. - unsigned short tcp_port = 5075; - //! UDP port to bind. Default is 5076. May be zero, cf. Server::config() to find allocated port. - unsigned short udp_port = 5076; //! Whether to populate the beacon address list automatically. (recommended) bool auto_beacon = true; - //! Inactivity timeout interval for TCP connections. (seconds) - //! @since 0.2.0 - double tcpTimeout = 40.0; - //! Server unique ID. Only meaningful in readback via Server::config() ServerGUID guid{};