Skip to content

Commit

Permalink
consolidate config common to both server and client
Browse files Browse the repository at this point in the history
  • Loading branch information
mdavidsaver committed Apr 22, 2024
1 parent 0591b99 commit 30307ea
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
3 changes: 3 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
// <IP46>
Expand Down
12 changes: 1 addition & 11 deletions src/pvxs/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ class DiscoverBuilder
};
DiscoverBuilder Context::discover(std::function<void (const Discovered &)> && 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:
Expand All @@ -1021,19 +1021,9 @@ struct PVXS_API Config {
//! @since 0.2.0
std::vector<std::string> 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;
Expand Down
15 changes: 14 additions & 1 deletion src/pvxs/netcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 1 addition & 9 deletions src/pvxs/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -164,17 +164,9 @@ struct PVXS_API Config {
//! May include broadcast and/or unicast addresses.
//! Supplemented only if auto_beacon==true
std::vector<std::string> 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{};

Expand Down

0 comments on commit 30307ea

Please sign in to comment.