Match formatting of Bond-related sources to ZeroTier standard (no functional changes)

This commit is contained in:
Joseph Henry 2021-05-03 17:59:31 -07:00
commit 29e5880d8b
No known key found for this signature in database
GPG key ID: C45B33FF5EBC9344
6 changed files with 971 additions and 654 deletions

View file

@ -14,19 +14,20 @@
#ifndef ZT_LINK_HPP
#define ZT_LINK_HPP
#include <string>
#include "../node/AtomicCounter.hpp"
#include "../node/SharedPtr.hpp"
#include <string>
namespace ZeroTier {
class Link
{
class Link {
friend class SharedPtr<Link>;
public:
Link() {}
public:
Link()
{
}
/**
*
@ -38,123 +39,165 @@ public:
* @param failoverToLinkStr
* @param userSpecifiedAlloc
*/
Link(std::string& ifnameStr,
uint8_t ipvPref,
uint32_t speed,
uint32_t linkMonitorInterval,
uint32_t upDelay,
uint32_t downDelay,
bool enabled,
uint8_t mode,
std::string failoverToLinkStr,
float userSpecifiedAlloc) :
_ifnameStr(ifnameStr),
_ipvPref(ipvPref),
_speed(speed),
_relativeSpeed(0),
_linkMonitorInterval(linkMonitorInterval),
_upDelay(upDelay),
_downDelay(downDelay),
_enabled(enabled),
_mode(mode),
_failoverToLinkStr(failoverToLinkStr),
_userSpecifiedAlloc(userSpecifiedAlloc),
_isUserSpecified(false)
{}
Link(std::string& ifnameStr, uint8_t ipvPref, uint32_t speed, uint32_t linkMonitorInterval, uint32_t upDelay, uint32_t downDelay, bool enabled, uint8_t mode, std::string failoverToLinkStr, float userSpecifiedAlloc)
: _ifnameStr(ifnameStr)
, _ipvPref(ipvPref)
, _speed(speed)
, _relativeSpeed(0)
, _linkMonitorInterval(linkMonitorInterval)
, _upDelay(upDelay)
, _downDelay(downDelay)
, _enabled(enabled)
, _mode(mode)
, _failoverToLinkStr(failoverToLinkStr)
, _userSpecifiedAlloc(userSpecifiedAlloc)
, _isUserSpecified(false)
{
}
/**
* @return The string representation of this link's underlying interface's system name.
*/
inline std::string ifname() { return _ifnameStr; }
inline std::string ifname()
{
return _ifnameStr;
}
/**
* @return Whether this link is designated as a primary.
*/
inline bool primary() { return _mode == ZT_MULTIPATH_SLAVE_MODE_PRIMARY; }
inline bool primary()
{
return _mode == ZT_MULTIPATH_SLAVE_MODE_PRIMARY;
}
/**
* @return Whether this link is designated as a spare.
*/
inline bool spare() { return _mode == ZT_MULTIPATH_SLAVE_MODE_SPARE; }
inline bool spare()
{
return _mode == ZT_MULTIPATH_SLAVE_MODE_SPARE;
}
/**
* @return The name of the link interface that should be used in the event of a failure.
*/
inline std::string failoverToLink() { return _failoverToLinkStr; }
inline std::string failoverToLink()
{
return _failoverToLinkStr;
}
/**
* @return Whether this link interface was specified by the user or auto-detected.
*/
inline bool isUserSpecified() { return _isUserSpecified; }
inline bool isUserSpecified()
{
return _isUserSpecified;
}
/**
* Signify that this link was specified by the user and not the result of auto-detection.
*
* @param isUserSpecified
*/
inline void setAsUserSpecified(bool isUserSpecified) { _isUserSpecified = isUserSpecified; }
inline void setAsUserSpecified(bool isUserSpecified)
{
_isUserSpecified = isUserSpecified;
}
/**
* @return Whether or not the user has specified failover instructions.
*/
inline bool userHasSpecifiedFailoverInstructions() { return _failoverToLinkStr.length(); }
inline bool userHasSpecifiedFailoverInstructions()
{
return _failoverToLinkStr.length();
}
/**
* @return The speed of the link relative to others in the bond.
*/
inline uint8_t relativeSpeed() { return _relativeSpeed; }
inline uint8_t relativeSpeed()
{
return _relativeSpeed;
}
/**
* Sets the speed of the link relative to others in the bond.
*
* @param relativeSpeed The speed relative to the rest of the link.
*/
inline void setRelativeSpeed(uint8_t relativeSpeed) { _relativeSpeed = relativeSpeed; }
inline void setRelativeSpeed(uint8_t relativeSpeed)
{
_relativeSpeed = relativeSpeed;
}
/**
* Sets the speed of the link relative to others in the bond.
*
* @param relativeSpeed
*/
inline void setMonitorInterval(uint32_t interval) { _linkMonitorInterval = interval; }
inline void setMonitorInterval(uint32_t interval)
{
_linkMonitorInterval = interval;
}
/**
* @return The absolute speed of the link (as specified by the user.)
*/
inline uint32_t monitorInterval() { return _linkMonitorInterval; }
inline uint32_t monitorInterval()
{
return _linkMonitorInterval;
}
/**
* @return The absolute speed of the link (as specified by the user.)
*/
inline uint32_t speed() { return _speed; }
inline uint32_t speed()
{
return _speed;
}
/**
* @return The address preference for this link (as specified by the user.)
*/
inline uint8_t ipvPref() { return _ipvPref; }
inline uint8_t ipvPref()
{
return _ipvPref;
}
/**
* @return The mode (e.g. primary/spare) for this link (as specified by the user.)
*/
inline uint8_t mode() { return _mode; }
inline uint8_t mode()
{
return _mode;
}
/**
* @return The upDelay parameter for all paths on this link.
*/
inline uint32_t upDelay() { return _upDelay; }
inline uint32_t upDelay()
{
return _upDelay;
}
/**
* @return The downDelay parameter for all paths on this link.
*/
inline uint32_t downDelay() { return _downDelay; }
inline uint32_t downDelay()
{
return _downDelay;
}
/**
* @return Whether this link is enabled or disabled
*/
inline uint8_t enabled() { return _enabled; }
private:
inline uint8_t enabled()
{
return _enabled;
}
private:
/**
* String representation of underlying interface's system name
*/
@ -223,15 +266,15 @@ private:
float _userSpecifiedAlloc;
/**
* Whether or not this link was created as a result of manual user specification. This is
* important to know because certain policy decisions are dependent on whether the user
* intents to use a specific set of interfaces.
*/
* Whether or not this link was created as a result of manual user specification. This is
* important to know because certain policy decisions are dependent on whether the user
* intents to use a specific set of interfaces.
*/
bool _isUserSpecified;
AtomicCounter __refCount;
};
} // namespace ZeroTier
} // namespace ZeroTier
#endif
#endif