SNode.C
Loading...
Searching...
No Matches
net::in6::stream::config::ConfigSocketServer Class Reference

#include <ConfigSocketServer.h>

Inheritance diagram for net::in6::stream::config::ConfigSocketServer:
Collaboration diagram for net::in6::stream::config::ConfigSocketServer:

Public Member Functions

ConfigSocketServersetReuseAddress (bool reuseAddress=true)
bool getReuseAddress () const
ConfigSocketServersetReusePort (bool reusePort=true)
bool getReusePort () const
ConfigSocketServersetIPv6Only (bool iPv6Only=true)
bool getIPv6Only () const
ConfigSocketServersetDisableNagleAlgorithm (bool disableNagleAlgorithm=true)
bool getDisableNagleAlgorithm () const
Public Member Functions inherited from net::in6::config::ConfigAddress< net::config::ConfigAddressLocal >
SocketAddress getSocketAddress (const SocketAddress::SockAddr &sockAddr, SocketAddress::SockLen sockAddrLen)
ConfigAddresssetSocketAddress (const SocketAddress &socketAddress)
ConfigAddresssetHost (const std::string &ipOrHostname)
std::string getHost () const
ConfigAddresssetPort (uint16_t port)
uint16_t getPort () const
ConfigAddresssetNumeric (bool numeric=true)
bool getNumeric () const
ConfigAddresssetNumericReverse (bool numeric=true)
bool getNumericReverse () const
void configurable (bool configurable=true) final
Public Member Functions inherited from net::config::ConfigSection
template<typename T>
 ConfigSection (ConfigInstance *instance, T *sectionPtr, const std::string &group="Sections")
 ~ConfigSection () override
 ConfigSection (const ConfigSection &)=delete
 ConfigSection (ConfigSection &&)=delete
ConfigSectionoperator= (const ConfigSection &)=delete
Public Member Functions inherited from utils::SubCommand
 SubCommand (const SubCommand &)=delete
 SubCommand (SubCommand &&)=delete
SubCommandoperator= (const SubCommand &)=delete
SubCommandoperator= (SubCommand &&)=delete
virtual ~SubCommand ()
std::string getName () const
std::string version () const
void parse (int argc, char *argv[])
CLI::Option * setConfig (const std::string &defaultConfigFile) const
CLI::Option * setLogFile (const std::string &defaultLogFile) const
CLI::Option * setVersionFlag (const std::string &version) const
bool hasParent () const
SubCommandgetParent ()
SubCommandallowExtras (bool allow=true)
SubCommandrequired (bool required=true, bool force=true)
SubCommandrequired (SubCommand *subCommand, bool required=true)
SubCommandrequired (CLI::Option *option, bool required=true)
SubCommandneeds (SubCommand *subCommand, bool needs=true)
SubCommanddisabled (SubCommand *subCommand, bool disabled=true)
SubCommandsetRequireCallback (const std::function< void(void)> &callback)
SubCommandfinalCallback (const std::function< void()> &finalCallback)
std::string configToStr () const
std::string help (const CLI::App *helpApp, const CLI::AppFormatMode &mode) const
template<typename NewSubCommand, typename... Args>
NewSubCommand * newSubCommand (Args &&... args)
template<typename RequestedSubCommand>
RequestedSubCommand * getSubCommand ()
template<typename RequestedSubCommand>
RequestedSubCommand * getSubCommand () const
CLI::Option * getOption (const std::string &name) const
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addOptionVariable (const std::string &name, ValueTypeT &variable, const std::string &description, const std::string &typeName, const CLI::Validator &additionalValidator) const
template<typename ValueTypeT>
CLI::Option * addOptionVariable (const std::string &name, ValueTypeT &variable, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &additionalValidator) const
CLI::Option * addOptionFunction (const std::string &name, std::function< void(const std::string &)> &callback, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addOptionFunction (const std::string &name, std::function< void(const std::string &)> &callback, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &validator) const
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &validator) const
CLI::Option * addFlagFunction (const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const CLI::Validator &validator)
CLI::Option * addFlagFunction (const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const std::string &defaultValue, const CLI::Validator &validator)
Public Member Functions inherited from net::config::ConfigAddress< net::in6::SocketAddress >
net::in6::SocketAddress getSocketAddress (const typename net::in6::SocketAddress::SockAddr &sockAddr, typename net::in6::SocketAddress::SockLen sockAddrLen)
void renew ()
Public Member Functions inherited from net::config::ConfigAddressBase< net::in6::SocketAddress >
net::in6::SocketAddress getSocketAddress (const typename net::in6::SocketAddress::SockAddr &sockAddr, typename net::in6::SocketAddress::SockLen sockAddrLen)
Public Member Functions inherited from net::in6::config::ConfigAddressReverse< net::config::ConfigAddressReverse >
SocketAddress getSocketAddress (const SocketAddress::SockAddr &sockAddr, SocketAddress::SockLen sockAddrLen)
ConfigAddressReversesetNumericReverse (bool numeric=true)
bool getNumericReverse () const
Public Member Functions inherited from net::config::ConfigConnection
utils::Timeval getReadTimeout () const
ConfigConnectionsetReadTimeout (const utils::Timeval &newReadTimeoutSet)
utils::Timeval getWriteTimeout () const
ConfigConnectionsetWriteTimeout (const utils::Timeval &newWriteTimeoutSet)
std::size_t getReadBlockSize () const
ConfigConnectionsetReadBlockSize (std::size_t newReadBlockSize)
std::size_t getWriteBlockSize () const
ConfigConnectionsetWriteBlockSize (std::size_t newWriteBlockSize)
utils::Timeval getTerminateTimeout () const
ConfigConnectionsetTerminateTimeout (const utils::Timeval &newTerminateTimeout)
Public Member Functions inherited from net::config::ConfigPhysicalSocketServer
ConfigPhysicalSocketServersetBacklog (int newBacklog)
int getBacklog () const
ConfigPhysicalSocketServersetAcceptsPerTick (int acceptsPerTickSet)
int getAcceptsPerTick () const
ConfigPhysicalSocketServersetAcceptTimeout (const utils::Timeval &acceptTimeout)
utils::Timeval getAcceptTimeout () const
Public Member Functions inherited from net::config::ConfigPhysicalSocket
const std::map< int, std::map< int, net::phy::PhysicalSocketOption > > & getSocketOptions () const
ConfigPhysicalSocketaddSocketOption (int optLevel, int optName, int optValue)
ConfigPhysicalSocketaddSocketOption (int optLevel, int optName, const std::string &optValue)
ConfigPhysicalSocketaddSocketOption (int optLevel, int optName, const std::vector< char > &optValue)
ConfigPhysicalSocketremoveSocketOption (int optLevel, int optName)
ConfigPhysicalSocketsetRetry (bool retry=true)
bool getRetry () const
ConfigPhysicalSocketsetRetryOnFatal (bool retry=true)
bool getRetryOnFatal () const
ConfigPhysicalSocketsetRetryTimeout (double sec)
double getRetryTimeout () const
ConfigPhysicalSocketsetRetryTries (unsigned int tries=0)
unsigned int getRetryTries () const
ConfigPhysicalSocketsetRetryBase (double base)
double getRetryBase () const
ConfigPhysicalSocketsetRetryLimit (unsigned int limit)
unsigned int getRetryLimit () const
ConfigPhysicalSocketsetRetryJitter (double percent)
double getRetryJitter () const
template<typename ConcretConfigPhysicalSocket>
 ConfigPhysicalSocket (ConfigInstance *instance, ConcretConfigPhysicalSocket *section)

Protected Member Functions

 ConfigSocketServer (net::config::ConfigInstance *instance)
 ~ConfigSocketServer () override
Protected Member Functions inherited from net::config::stream::ConfigSocketServer< net::in6::config::ConfigAddress, net::in6::config::ConfigAddressReverse >
 ConfigSocketServer (net::config::ConfigInstance *instance)
Protected Member Functions inherited from net::in6::config::ConfigAddress< net::config::ConfigAddressLocal >
 ConfigAddress (net::config::ConfigInstance *instance, const std::string &addressOptionName, const std::string &addressOptionDescription)
ConfigAddresssetIpv4Mapped (bool ipv4Mapped=true)
bool getIpv4Mapped () const
ConfigAddresssetAiFlags (int aiFlags)
int getAiFlags () const
ConfigAddresssetAiSockType (int aiSocktype)
int getAiSockType () const
ConfigAddresssetAiProtocol (int aiProtocol)
int getAiProtocol () const
ConfigAddresssetHostRequired (bool required=true)
ConfigAddresssetPortRequired (bool required=true)
Protected Member Functions inherited from utils::SubCommand
 SubCommand (SubCommand *parent, std::shared_ptr< utils::AppWithPtr > appWithPtr, const std::string &group, bool final)
template<typename ConcretSubCommand>
 SubCommand (SubCommand *parent, ConcretSubCommand *concretSubCommand, const std::string &group, bool final=true)
SubCommanddescription (const std::string &description)
SubCommandfooter (const std::string &footer)
template<typename ValueTypeT>
CLI::Option * setDefaultValue (CLI::Option *option, const ValueTypeT &value, bool clear=true) const
CLI::Option * setConfigurable (CLI::Option *option, bool configurable) const
Protected Member Functions inherited from net::config::ConfigAddress< net::in6::SocketAddress >
 ConfigAddress (ConfigInstance *instance, const std::string &addressOptionName, const std::string &addressOptionDescription)
 ~ConfigAddress () override
Protected Member Functions inherited from net::config::ConfigAddressBase< net::in6::SocketAddress >
 ConfigAddressBase (ConfigInstance *instance, const std::string &addressOptionName="", const std::string &addressOptionDescription="")
virtual ~ConfigAddressBase ()=default
Protected Member Functions inherited from net::in6::config::ConfigAddressReverse< net::config::ConfigAddressReverse >
 ConfigAddressReverse (net::config::ConfigInstance *instance, const std::string &addressOptionName, const std::string &addressOptionDescription)
Protected Member Functions inherited from net::config::ConfigConnection
 ConfigConnection (ConfigInstance *instance)
 ~ConfigConnection () override
Protected Member Functions inherited from net::config::ConfigPhysicalSocketServer
 ConfigPhysicalSocketServer (ConfigInstance *instance)
 ~ConfigPhysicalSocketServer () override
Protected Member Functions inherited from net::config::ConfigPhysicalSocket
template<typename ConcretConfigPhysicalSocketT>
 ConfigPhysicalSocket (ConfigInstance *instance, ConcretConfigPhysicalSocketT *section)
 ~ConfigPhysicalSocket () override
CLI::Option * addSocketOption (const std::string &name, int optLevel, int optName, const std::string &description, const std::string &typeName, const std::string &defaultValue, const CLI::Validator &validator)

Private Attributes

CLI::Option * reuseAddressOpt = nullptr
CLI::Option * reusePortOpt = nullptr
CLI::Option * iPv6OnlyOpt = nullptr
CLI::Option * disableNagleAlgorithmOpt = nullptr

Additional Inherited Members

Public Types inherited from net::config::stream::ConfigSocketServer< net::in6::config::ConfigAddress, net::in6::config::ConfigAddressReverse >
using Local
using Remote
using Connection
using Socket
Static Public Member Functions inherited from utils::SubCommand
static CLI::App * getHelpTriggerApp ()
static CLI::App * getShowConfigTriggerApp ()
static CLI::App * getCommandlineTriggerApp ()
Static Public Attributes inherited from utils::SubCommand
static std::shared_ptr< CLI::Formatter > sectionFormatter = makeSectionFormatter()
Static Public Attributes inherited from net::config::ConfigAddressLocal< net::in6::SocketAddress >
static constexpr std::string_view NAME
static constexpr std::string_view DESCRIPTION
Static Public Attributes inherited from net::config::ConfigAddressReverse< net::in6::SocketAddress >
static constexpr std::string_view NAME
static constexpr std::string_view DESCRIPTION
Static Public Attributes inherited from net::config::ConfigConnection
static constexpr std::string_view NAME {"connection"}
static constexpr std::string_view DESCRIPTION {"Configuration of established connections"}
Static Public Attributes inherited from net::config::ConfigPhysicalSocket
static constexpr std::string_view NAME {"socket"}
static constexpr std::string_view DESCRIPTION {"Configuration of socket behavior"}
Static Protected Attributes inherited from utils::SubCommand
static std::map< std::string, std::string > aliases
static CLI::App * helpTriggerApp = nullptr
static CLI::App * showConfigTriggerApp = nullptr
static CLI::App * commandlineTriggerApp = nullptr

Detailed Description

Definition at line 58 of file ConfigSocketServer.h.

Constructor & Destructor Documentation

◆ ConfigSocketServer()

net::in6::stream::config::ConfigSocketServer::ConfigSocketServer ( net::config::ConfigInstance * instance)
explicitprotected

Definition at line 62 of file ConfigSocketServer.cpp.

63 : net::config::stream::ConfigSocketServer<net::in6::config::ConfigAddress, net::in6::config::ConfigAddressReverse>(instance) {
65 Local::setAiFlags(AI_PASSIVE);
66 Local::setAiSockType(SOCK_STREAM);
67 Local::setAiProtocol(IPPROTO_TCP);
68
70 "--reuse-address{true}",
71 SOL_SOCKET,
72 SO_REUSEADDR,
73 "Reuse socket address",
74 "bool",
75 XSTR(IN6_REUSE_ADDRESS),
76 CLI::IsMember({"true", "false"}));
77
79 "--reuse-port{true}",
80 SOL_SOCKET,
81 SO_REUSEPORT,
82 "Reuse port number",
83 "bool",
84 XSTR(IN6_REUSE_PORT),
85 CLI::IsMember({"true", "false"}));
86
87 std::string ipv6Only = XSTR(IN6_IPV6_ONLY);
88 if (ipv6Only == "default") {
89 std::ifstream in("/proc/sys/net/ipv6/bindv6only");
90 if (in) {
91 std::string s;
92 in >> s; // reads "0" or "1"
93
94 ipv6Only = s == "1" ? "true" : "false";
95 }
96 in.close();
97 }
99 "--ipv6-only{true}",
100 IPPROTO_IPV6,
101 IPV6_V6ONLY,
102 "Turn off IPv6 dual stack mode",
103 "bool",
104 XSTR(IN6_IPV6_ONLY),
105 CLI::IsMember({"true", "false", "default"}));
106 if (std::string(XSTR(IN6_IPV6_ONLY)) == "default") {
108 }
109
111 "--disable-nagle-algorithm{true}",
112 IPPROTO_TCP,
113 TCP_NODELAY,
114 "Turn of Nagle algorithm",
115 "tristat",
116 XSTR(IN6_SERVER_DISABLE_NAGLE_ALGORITHM),
117 CLI::IsMember({"true", "false", "default"}));
118 if (std::string(XSTR(IN6_SERVER_DISABLE_NAGLE_ALGORITHM)) == "default") {
120 }
121 }
#define XSTR(s)
ConfigPhysicalSocket & addSocketOption(int optLevel, int optName, int optValue)
CLI::Option * setDefaultValue(CLI::Option *option, const ValueTypeT &value, bool clear=true) const
Definition SubCommand.h:337

References net::config::ConfigPhysicalSocket::addSocketOption(), net::config::stream::ConfigSocketServer< ConfigAddressLocalT, ConfigAddressRemoteT >::ConfigSocketServer(), disableNagleAlgorithmOpt, iPv6OnlyOpt, reuseAddressOpt, reusePortOpt, net::in6::config::ConfigAddress< ConfigAddressTypeT >::setAiFlags(), net::in6::config::ConfigAddress< ConfigAddressTypeT >::setAiProtocol(), net::in6::config::ConfigAddress< ConfigAddressTypeT >::setAiSockType(), utils::SubCommand::setDefaultValue(), and net::in6::config::ConfigAddress< ConfigAddressTypeT >::setPortRequired().

Here is the call graph for this function:

◆ ~ConfigSocketServer()

net::in6::stream::config::ConfigSocketServer::~ConfigSocketServer ( )
overrideprotected

Definition at line 123 of file ConfigSocketServer.cpp.

123 {
124 }

Member Function Documentation

◆ getDisableNagleAlgorithm()

bool net::in6::stream::config::ConfigSocketServer::getDisableNagleAlgorithm ( ) const

Definition at line 194 of file ConfigSocketServer.cpp.

194 {
195 return disableNagleAlgorithmOpt->as<bool>();
196 }

References disableNagleAlgorithmOpt.

◆ getIPv6Only()

bool net::in6::stream::config::ConfigSocketServer::getIPv6Only ( ) const

Definition at line 176 of file ConfigSocketServer.cpp.

176 {
177 return iPv6OnlyOpt->as<bool>();
178 }

References iPv6OnlyOpt.

◆ getReuseAddress()

bool net::in6::stream::config::ConfigSocketServer::getReuseAddress ( ) const

Definition at line 140 of file ConfigSocketServer.cpp.

140 {
141 return reuseAddressOpt->as<bool>();
142 }

References reuseAddressOpt.

◆ getReusePort()

bool net::in6::stream::config::ConfigSocketServer::getReusePort ( ) const

Definition at line 158 of file ConfigSocketServer.cpp.

158 {
159 return reusePortOpt->as<bool>();
160 }

References reusePortOpt.

◆ setDisableNagleAlgorithm()

ConfigSocketServer & net::in6::stream::config::ConfigSocketServer::setDisableNagleAlgorithm ( bool disableNagleAlgorithm = true)

Definition at line 180 of file ConfigSocketServer.cpp.

180 {
181 const utils::PreserveErrno preserveErrno;
182
183 if (disableNagleAlgorithm) {
184 addSocketOption(IPPROTO_TCP, TCP_NODELAY, 1);
185 } else {
186 addSocketOption(IPPROTO_TCP, TCP_NODELAY, 0);
187 }
188
189 Local::setDefaultValue(disableNagleAlgorithmOpt, disableNagleAlgorithm ? "true" : "false");
190
191 return *this;
192 }

References net::config::ConfigPhysicalSocket::addSocketOption(), disableNagleAlgorithmOpt, and utils::SubCommand::setDefaultValue().

Here is the call graph for this function:

◆ setIPv6Only()

ConfigSocketServer & net::in6::stream::config::ConfigSocketServer::setIPv6Only ( bool iPv6Only = true)

Definition at line 162 of file ConfigSocketServer.cpp.

162 {
163 const utils::PreserveErrno preserveErrno;
164
165 if (iPv6Only) {
166 addSocketOption(IPPROTO_IPV6, IPV6_V6ONLY, 1);
167 } else {
168 addSocketOption(IPPROTO_IPV6, IPV6_V6ONLY, 0);
169 }
170
171 Local::setDefaultValue(iPv6OnlyOpt, iPv6Only ? "true" : "false");
172
173 return *this;
174 }

References net::config::ConfigPhysicalSocket::addSocketOption(), iPv6OnlyOpt, and utils::SubCommand::setDefaultValue().

Here is the call graph for this function:

◆ setReuseAddress()

ConfigSocketServer & net::in6::stream::config::ConfigSocketServer::setReuseAddress ( bool reuseAddress = true)

Definition at line 126 of file ConfigSocketServer.cpp.

126 {
127 const utils::PreserveErrno preserveErrno;
128
129 if (reuseAddress) {
130 addSocketOption(SOL_SOCKET, SO_REUSEADDR, 1);
131 } else {
132 addSocketOption(SOL_SOCKET, SO_REUSEADDR, 0);
133 }
134
135 Local::setDefaultValue(reuseAddressOpt, reuseAddress ? "true" : "false");
136
137 return *this;
138 }

References net::config::ConfigPhysicalSocket::addSocketOption(), reuseAddressOpt, and utils::SubCommand::setDefaultValue().

Here is the call graph for this function:

◆ setReusePort()

ConfigSocketServer & net::in6::stream::config::ConfigSocketServer::setReusePort ( bool reusePort = true)

Definition at line 144 of file ConfigSocketServer.cpp.

144 {
145 const utils::PreserveErrno preserveErrno;
146
147 if (reusePort) {
148 addSocketOption(SOL_SOCKET, SO_REUSEPORT, 1);
149 } else {
150 addSocketOption(SOL_SOCKET, SO_REUSEPORT, 0);
151 }
152
153 Local::setDefaultValue(reusePortOpt, reusePort ? "true" : "false");
154
155 return *this;
156 }

References net::config::ConfigPhysicalSocket::addSocketOption(), reusePortOpt, and utils::SubCommand::setDefaultValue().

Here is the call graph for this function:

Member Data Documentation

◆ disableNagleAlgorithmOpt

CLI::Option* net::in6::stream::config::ConfigSocketServer::disableNagleAlgorithmOpt = nullptr
private

◆ iPv6OnlyOpt

CLI::Option* net::in6::stream::config::ConfigSocketServer::iPv6OnlyOpt = nullptr
private

Definition at line 81 of file ConfigSocketServer.h.

Referenced by ConfigSocketServer(), getIPv6Only(), and setIPv6Only().

◆ reuseAddressOpt

CLI::Option* net::in6::stream::config::ConfigSocketServer::reuseAddressOpt = nullptr
private

Definition at line 79 of file ConfigSocketServer.h.

Referenced by ConfigSocketServer(), getReuseAddress(), and setReuseAddress().

◆ reusePortOpt

CLI::Option* net::in6::stream::config::ConfigSocketServer::reusePortOpt = nullptr
private

Definition at line 80 of file ConfigSocketServer.h.

Referenced by ConfigSocketServer(), getReusePort(), and setReusePort().


The documentation for this class was generated from the following files: