diff options
-rw-r--r-- | attic/Range.hpp (renamed from node/Range.hpp) | 0 | ||||
-rw-r--r-- | node/Address.hpp | 50 | ||||
-rw-r--r-- | node/Buffer.hpp | 19 | ||||
-rw-r--r-- | node/Defaults.cpp | 4 | ||||
-rw-r--r-- | node/Defaults.hpp | 4 | ||||
-rw-r--r-- | node/Demarc.cpp | 1 | ||||
-rw-r--r-- | node/Demarc.hpp | 3 | ||||
-rw-r--r-- | node/NodeConfig.cpp | 4 | ||||
-rw-r--r-- | node/NodeConfig.hpp | 6 | ||||
-rw-r--r-- | node/PacketDecoder.cpp | 1 | ||||
-rw-r--r-- | node/PacketDecoder.hpp | 3 | ||||
-rw-r--r-- | node/SysEnv.cpp | 3 | ||||
-rw-r--r-- | node/SysEnv.hpp | 3 | ||||
-rw-r--r-- | node/Topology.cpp | 3 | ||||
-rw-r--r-- | node/Topology.hpp | 4 |
15 files changed, 42 insertions, 66 deletions
diff --git a/node/Range.hpp b/attic/Range.hpp index 7e3785b5..7e3785b5 100644 --- a/node/Range.hpp +++ b/attic/Range.hpp diff --git a/node/Address.hpp b/node/Address.hpp index 250e95f3..71c85f01 100644 --- a/node/Address.hpp +++ b/node/Address.hpp @@ -150,25 +150,12 @@ public: inline void appendTo(Buffer<C> &b) const throw(std::out_of_range) { - b.append((unsigned char)((_a >> 32) & 0xff)); - b.append((unsigned char)((_a >> 24) & 0xff)); - b.append((unsigned char)((_a >> 16) & 0xff)); - b.append((unsigned char)((_a >> 8) & 0xff)); - b.append((unsigned char)(_a & 0xff)); - } - - /** - * @return String containing address as 5 binary bytes - */ - inline std::string toBinaryString() const - { - std::string b; - b.push_back((char)((_a >> 32) & 0xff)); - b.push_back((char)((_a >> 24) & 0xff)); - b.push_back((char)((_a >> 16) & 0xff)); - b.push_back((char)((_a >> 8) & 0xff)); - b.push_back((char)(_a & 0xff)); - return b; + unsigned char *p = (unsigned char *)b.appendField(ZT_ADDRESS_LENGTH); + *(p++) = (unsigned char)((_a >> 32) & 0xff); + *(p++) = (unsigned char)((_a >> 24) & 0xff); + *(p++) = (unsigned char)((_a >> 16) & 0xff); + *(p++) = (unsigned char)((_a >> 8) & 0xff); + *p = (unsigned char)(_a & 0xff); } /** @@ -201,19 +188,12 @@ public: inline bool wouldHaveMac(const MAC &mac) const throw() { - if (mac.data[0] != ZT_MAC_FIRST_OCTET) - return false; - if (mac.data[1] != (unsigned char)((_a >> 32) & 0xff)) - return false; - if (mac.data[2] != (unsigned char)((_a >> 24) & 0xff)) - return false; - if (mac.data[3] != (unsigned char)((_a >> 16) & 0xff)) - return false; - if (mac.data[4] != (unsigned char)((_a >> 8) & 0xff)) - return false; - if (mac.data[5] != (unsigned char)(_a & 0xff)) - return false; - return true; + return ((mac.data[0] != ZT_MAC_FIRST_OCTET)|| + (mac.data[1] != (unsigned char)((_a >> 32) & 0xff))|| + (mac.data[2] != (unsigned char)((_a >> 24) & 0xff))|| + (mac.data[3] != (unsigned char)((_a >> 16) & 0xff))|| + (mac.data[4] != (unsigned char)((_a >> 8) & 0xff))|| + (mac.data[5] != (unsigned char)(_a & 0xff))); } /** @@ -234,11 +214,7 @@ public: /** * Set to null/zero */ - inline void zero() - throw() - { - _a = 0; - } + inline void zero() throw() { _a = 0; } /** * Check if this address is reserved diff --git a/node/Buffer.hpp b/node/Buffer.hpp index 73d0e5de..1767ae04 100644 --- a/node/Buffer.hpp +++ b/node/Buffer.hpp @@ -302,6 +302,25 @@ public: } /** + * Increment size and return pointer to field of specified size + * + * The memory isn't actually written, so this is a shortcut for a multi-step + * process involving getting the current pointer and adding size. + * + * @param l Length of field to append + * @return Pointer to beginning of appended field of length 'l' + */ + inline char *appendField(unsigned int l) + throw(std::out_of_range) + { + if ((_l + l) > C) + throw std::out_of_range("Buffer: append beyond capacity"); + char *r = _b + _l; + _l += l; + return r; + } + + /** * Increment size by a given number of bytes * * The contents of new space are undefined. diff --git a/node/Defaults.cpp b/node/Defaults.cpp index 8e3a8c9f..0a0003b0 100644 --- a/node/Defaults.cpp +++ b/node/Defaults.cpp @@ -43,7 +43,6 @@ namespace ZeroTier { const Defaults ZT_DEFAULTS; static inline std::map< Identity,std::vector<InetAddress> > _mkSupernodeMap() - throw(std::runtime_error) { std::map< Identity,std::vector<InetAddress> > sn; Identity id; @@ -99,8 +98,7 @@ static inline std::string _mkDefaultHomePath() #endif } -Defaults::Defaults() - throw(std::runtime_error) : +Defaults::Defaults() : #ifdef ZT_TRACE_MULTICAST multicastTraceWatcher(ZT_TRACE_MULTICAST), #endif diff --git a/node/Defaults.hpp b/node/Defaults.hpp index 4937ec03..5f870194 100644 --- a/node/Defaults.hpp +++ b/node/Defaults.hpp @@ -49,9 +49,7 @@ namespace ZeroTier { class Defaults { public: - Defaults() - throw(std::runtime_error); - ~Defaults() {} + Defaults(); #ifdef ZT_TRACE_MULTICAST /** diff --git a/node/Demarc.cpp b/node/Demarc.cpp index e607abda..71606074 100644 --- a/node/Demarc.cpp +++ b/node/Demarc.cpp @@ -94,7 +94,6 @@ bool Demarc::has(Port p) const } bool Demarc::bindLocalUdp(unsigned int localPort) - throw() { Mutex::Lock _l(_ports_m); diff --git a/node/Demarc.hpp b/node/Demarc.hpp index 767cc864..fc283fef 100644 --- a/node/Demarc.hpp +++ b/node/Demarc.hpp @@ -100,8 +100,7 @@ public: * @param localPort Local IP port * @return True if successfully bound, or if already bound */ - bool bindLocalUdp(unsigned int localPort) - throw(); + bool bindLocalUdp(unsigned int localPort); /** * Pick a port to send to an address of a given type diff --git a/node/NodeConfig.cpp b/node/NodeConfig.cpp index afdf75d9..0dda8da7 100644 --- a/node/NodeConfig.cpp +++ b/node/NodeConfig.cpp @@ -58,8 +58,7 @@ namespace ZeroTier { -NodeConfig::NodeConfig(const RuntimeEnvironment *renv,const char *authToken,unsigned int controlPort) - throw(std::runtime_error) : +NodeConfig::NodeConfig(const RuntimeEnvironment *renv,const char *authToken,unsigned int controlPort) : _r(renv), _controlSocket(true,controlPort,false,&_CBcontrolPacketHandler,this) { @@ -266,7 +265,6 @@ std::vector<std::string> NodeConfig::execute(const char *command) } std::vector< Buffer<ZT_NODECONFIG_MAX_PACKET_SIZE> > NodeConfig::encodeControlMessage(const void *key,unsigned long conversationId,const std::vector<std::string> &payload) - throw(std::out_of_range) { char poly1305tag[ZT_POLY1305_MAC_LEN]; char iv[8]; diff --git a/node/NodeConfig.hpp b/node/NodeConfig.hpp index 12bc32b3..0e7e4c98 100644 --- a/node/NodeConfig.hpp +++ b/node/NodeConfig.hpp @@ -63,8 +63,7 @@ public: * @param controlPort Control port for local control packet I/O * @throws std::runtime_error Unable to bind to local control port */ - NodeConfig(const RuntimeEnvironment *renv,const char *authToken,unsigned int controlPort) - throw(std::runtime_error); + NodeConfig(const RuntimeEnvironment *renv,const char *authToken,unsigned int controlPort); ~NodeConfig(); @@ -143,8 +142,7 @@ public: * @return One or more transport armored packets (if payload too big) * @throws std::out_of_range An element of payload is too big */ - static std::vector< Buffer<ZT_NODECONFIG_MAX_PACKET_SIZE> > encodeControlMessage(const void *key,unsigned long conversationId,const std::vector<std::string> &payload) - throw(std::out_of_range); + static std::vector< Buffer<ZT_NODECONFIG_MAX_PACKET_SIZE> > encodeControlMessage(const void *key,unsigned long conversationId,const std::vector<std::string> &payload); /** * Decode a packet from the control bus diff --git a/node/PacketDecoder.cpp b/node/PacketDecoder.cpp index 37b46a67..c23fab1d 100644 --- a/node/PacketDecoder.cpp +++ b/node/PacketDecoder.cpp @@ -45,7 +45,6 @@ namespace ZeroTier { bool PacketDecoder::tryDecode(const RuntimeEnvironment *_r) - throw(std::out_of_range,std::runtime_error) { if ((!encrypted())&&(verb() == Packet::VERB_HELLO)) { // Unencrypted HELLOs are handled here since they are used to diff --git a/node/PacketDecoder.hpp b/node/PacketDecoder.hpp index e5035317..cb3522ff 100644 --- a/node/PacketDecoder.hpp +++ b/node/PacketDecoder.hpp @@ -100,8 +100,7 @@ public: * @throws std::out_of_range Range error processing packet (should be discarded) * @throws std::runtime_error Other error processing packet (should be discarded) */ - bool tryDecode(const RuntimeEnvironment *_r) - throw(std::out_of_range,std::runtime_error); + bool tryDecode(const RuntimeEnvironment *_r); /** * @return Time of packet receipt / start of decode diff --git a/node/SysEnv.cpp b/node/SysEnv.cpp index 150b26a8..3fb2c872 100644 --- a/node/SysEnv.cpp +++ b/node/SysEnv.cpp @@ -74,7 +74,6 @@ SysEnv::~SysEnv() #ifdef __APPLE__ uint64_t SysEnv::getNetworkConfigurationFingerprint() - throw() { int mib[6]; size_t needed; @@ -141,7 +140,6 @@ uint64_t SysEnv::getNetworkConfigurationFingerprint() #if defined(__linux__) || defined(linux) || defined(__LINUX__) || defined(__linux) uint64_t SysEnv::getNetworkConfigurationFingerprint() - throw() { char buf[16384]; uint64_t fingerprint = 5381; // djb2 hash algorithm is used below @@ -218,7 +216,6 @@ uint64_t SysEnv::getNetworkConfigurationFingerprint() #ifdef __WINDOWS__ uint64_t SysEnv::getNetworkConfigurationFingerprint() - throw() { // TODO: windows version return 1; diff --git a/node/SysEnv.hpp b/node/SysEnv.hpp index 2db275c3..21c25713 100644 --- a/node/SysEnv.hpp +++ b/node/SysEnv.hpp @@ -48,8 +48,7 @@ public: /** * @return Fingerprint of currently running network environment */ - uint64_t getNetworkConfigurationFingerprint() - throw(); + uint64_t getNetworkConfigurationFingerprint(); private: const RuntimeEnvironment *_r; diff --git a/node/Topology.cpp b/node/Topology.cpp index 8acbb027..3414812a 100644 --- a/node/Topology.cpp +++ b/node/Topology.cpp @@ -37,8 +37,7 @@ namespace ZeroTier { #define ZT_KISSDB_KEY_SIZE ZT_ADDRESS_LENGTH #define ZT_KISSDB_VALUE_SIZE ZT_PEER_MAX_SERIALIZED_LENGTH -Topology::Topology(const RuntimeEnvironment *renv,const char *dbpath) - throw(std::runtime_error) : +Topology::Topology(const RuntimeEnvironment *renv,const char *dbpath) : _r(renv), _amSupernode(false) { diff --git a/node/Topology.hpp b/node/Topology.hpp index 637cbb36..acae83d6 100644 --- a/node/Topology.hpp +++ b/node/Topology.hpp @@ -55,9 +55,7 @@ class RuntimeEnvironment; class Topology { public: - Topology(const RuntimeEnvironment *renv,const char *dbpath) - throw(std::runtime_error); - + Topology(const RuntimeEnvironment *renv,const char *dbpath); ~Topology(); /** |