From 1b33a9e807c737e6b5064d2955ea89e4c8d59f8a Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 15 Jul 2014 12:21:24 -0700 Subject: . --- node/RoutingTable.hpp | 105 ++++++++++++++++++++++++++++++++++++++++++++ node/SystemNetworkStack.hpp | 105 -------------------------------------------- 2 files changed, 105 insertions(+), 105 deletions(-) create mode 100644 node/RoutingTable.hpp delete mode 100644 node/SystemNetworkStack.hpp diff --git a/node/RoutingTable.hpp b/node/RoutingTable.hpp new file mode 100644 index 00000000..2f8965b5 --- /dev/null +++ b/node/RoutingTable.hpp @@ -0,0 +1,105 @@ +/* + * ZeroTier One - Global Peer to Peer Ethernet + * Copyright (C) 2011-2014 ZeroTier Networks LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ + +#ifndef ZT_SYSTEMNETWORKSTACK_HPP +#define ZT_SYSTEMNETWORKSTACK_HPP + +#include + +#include +#include +#include + +#include "InetAddress.hpp" +#include "NonCopyable.hpp" + +namespace ZeroTier { + +/** + * Base class for OS-dependent interfaces to the system network configuration + */ +class SystemNetworkStack : NonCopyable +{ +public: + struct RoutingTableEntry + { + char device[128]; + InetAddress destination; + InetAddress gateway; + unsigned int deviceMetric; + }; + + SystemNetworkStack() {} + virtual ~SystemNetworkStack() {} + + /** + * @return All routing table entries sorted in order of destination + */ + virtual std::vector routingTable() const = 0; + + /** + * Add or update a routing table entry + * + * Note that metrics may only be changed at the device level, + * so changes to deviceMetric are ignored. + * + * @param re Entry to add/update + * @return True if successful + */ + virtual bool addUpdateRoute(const RoutingTableEntry &re) = 0; + + /** + * @param ifname Name of interface (Unix-style device or Windows device name) + * @return Interface metric (higher = lower priority) + */ + virtual unsigned int interfaceMetric(const char *ifname) const = 0; + + /** + * @param ifname Name of interface (Unix-style device or Windows device name) + * @param metric New metric (higher = lower priority) + * @return True if successful + */ + virtual bool setInterfaceMetric(const char *ifname,unsigned int metric) = 0; + + /** + * @return Interface names sorted in ascending order + */ + virtual std::vector interfaces() const = 0; + + /** + * @param ignoreInterfaces List of interfaces to exclude from fingerprint + * @return Integer CRC-type fingerprint of current network environment + */ + inline uint64_t networkEnvironmentFingerprint(const std::set &ignoreInterfaces) const + { + std::vector rtab(routingTable()); + }; +}; + +} // namespace ZeroTier + +#endif diff --git a/node/SystemNetworkStack.hpp b/node/SystemNetworkStack.hpp deleted file mode 100644 index 2f8965b5..00000000 --- a/node/SystemNetworkStack.hpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * ZeroTier One - Global Peer to Peer Ethernet - * Copyright (C) 2011-2014 ZeroTier Networks LLC - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * -- - * - * ZeroTier may be used and distributed under the terms of the GPLv3, which - * are available at: http://www.gnu.org/licenses/gpl-3.0.html - * - * If you would like to embed ZeroTier into a commercial application or - * redistribute it in a modified binary form, please contact ZeroTier Networks - * LLC. Start here: http://www.zerotier.com/ - */ - -#ifndef ZT_SYSTEMNETWORKSTACK_HPP -#define ZT_SYSTEMNETWORKSTACK_HPP - -#include - -#include -#include -#include - -#include "InetAddress.hpp" -#include "NonCopyable.hpp" - -namespace ZeroTier { - -/** - * Base class for OS-dependent interfaces to the system network configuration - */ -class SystemNetworkStack : NonCopyable -{ -public: - struct RoutingTableEntry - { - char device[128]; - InetAddress destination; - InetAddress gateway; - unsigned int deviceMetric; - }; - - SystemNetworkStack() {} - virtual ~SystemNetworkStack() {} - - /** - * @return All routing table entries sorted in order of destination - */ - virtual std::vector routingTable() const = 0; - - /** - * Add or update a routing table entry - * - * Note that metrics may only be changed at the device level, - * so changes to deviceMetric are ignored. - * - * @param re Entry to add/update - * @return True if successful - */ - virtual bool addUpdateRoute(const RoutingTableEntry &re) = 0; - - /** - * @param ifname Name of interface (Unix-style device or Windows device name) - * @return Interface metric (higher = lower priority) - */ - virtual unsigned int interfaceMetric(const char *ifname) const = 0; - - /** - * @param ifname Name of interface (Unix-style device or Windows device name) - * @param metric New metric (higher = lower priority) - * @return True if successful - */ - virtual bool setInterfaceMetric(const char *ifname,unsigned int metric) = 0; - - /** - * @return Interface names sorted in ascending order - */ - virtual std::vector interfaces() const = 0; - - /** - * @param ignoreInterfaces List of interfaces to exclude from fingerprint - * @return Integer CRC-type fingerprint of current network environment - */ - inline uint64_t networkEnvironmentFingerprint(const std::set &ignoreInterfaces) const - { - std::vector rtab(routingTable()); - }; -}; - -} // namespace ZeroTier - -#endif -- cgit v1.2.3