summaryrefslogtreecommitdiff
path: root/osdep
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2016-04-06 16:57:37 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2016-04-06 16:57:37 -0700
commite9b2613d5facc5c3540eeb53be66a6becdfd347b (patch)
tree1f756447b4cf35f5e0ca3ea144d97bdcd7e8aa26 /osdep
parent24469a7f438a166e289dad00839e5dce631cd3e0 (diff)
downloadinfinitytier-e9b2613d5facc5c3540eeb53be66a6becdfd347b.tar.gz
infinitytier-e9b2613d5facc5c3540eeb53be66a6becdfd347b.zip
Put routing table code back in osdep/
Diffstat (limited to 'osdep')
-rw-r--r--osdep/BSDRoutingTable.cpp43
-rw-r--r--osdep/BSDRoutingTable.hpp19
-rw-r--r--osdep/LinuxRoutingTable.cpp27
-rw-r--r--osdep/LinuxRoutingTable.hpp30
-rw-r--r--osdep/RoutingTable.cpp77
-rw-r--r--osdep/RoutingTable.hpp122
-rw-r--r--osdep/RoutingTableEntry.hpp62
-rw-r--r--osdep/TestRoutingTable.cpp50
-rw-r--r--osdep/TestRoutingTable.hpp50
-rw-r--r--osdep/WindowsRoutingTable.cpp18
-rw-r--r--osdep/WindowsRoutingTable.hpp30
11 files changed, 153 insertions, 375 deletions
diff --git a/osdep/BSDRoutingTable.cpp b/osdep/BSDRoutingTable.cpp
index 6d44c3ec..5b24af96 100644
--- a/osdep/BSDRoutingTable.cpp
+++ b/osdep/BSDRoutingTable.cpp
@@ -25,6 +25,10 @@
* LLC. Start here: http://www.zerotier.com/
*/
+#include "../node/Constants.hpp"
+
+#ifdef __BSD__
+
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -45,7 +49,6 @@
#include <algorithm>
#include <utility>
-#include "../node/Constants.hpp"
#include "BSDRoutingTable.hpp"
// All I wanted was the bloody rounting table. I didn't expect the Spanish inquisition.
@@ -62,9 +65,9 @@ BSDRoutingTable::~BSDRoutingTable()
{
}
-std::vector<RoutingTable::Entry> BSDRoutingTable::get(bool includeLinkLocal,bool includeLoopback) const
+std::vector<RoutingTableEntry> BSDRoutingTable::get(bool includeLinkLocal,bool includeLoopback) const
{
- std::vector<RoutingTable::Entry> entries;
+ std::vector<RoutingTableEntry> entries;
int mib[6];
size_t needed;
@@ -88,7 +91,7 @@ std::vector<RoutingTable::Entry> BSDRoutingTable::get(bool includeLinkLocal,bool
char *saend = next + rtm->rtm_msglen;
if (((rtm->rtm_flags & RTF_LLINFO) == 0)&&((rtm->rtm_flags & RTF_HOST) == 0)&&((rtm->rtm_flags & RTF_UP) != 0)&&((rtm->rtm_flags & RTF_MULTICAST) == 0)) {
- RoutingTable::Entry e;
+ RoutingTableEntry e;
e.deviceIndex = -9999; // unset
int which = 0;
@@ -202,14 +205,14 @@ std::vector<RoutingTable::Entry> BSDRoutingTable::get(bool includeLinkLocal,bool
}
}
- for(std::vector<ZeroTier::RoutingTable::Entry>::iterator e1(entries.begin());e1!=entries.end();++e1) {
+ for(std::vector<ZeroTier::RoutingTableEntry>::iterator e1(entries.begin());e1!=entries.end();++e1) {
if ((!e1->device[0])&&(e1->deviceIndex >= 0))
if_indextoname(e1->deviceIndex,e1->device);
}
- for(std::vector<ZeroTier::RoutingTable::Entry>::iterator e1(entries.begin());e1!=entries.end();++e1) {
+ for(std::vector<ZeroTier::RoutingTableEntry>::iterator e1(entries.begin());e1!=entries.end();++e1) {
if ((!e1->device[0])&&(e1->gateway)) {
int bestMetric = 9999999;
- for(std::vector<ZeroTier::RoutingTable::Entry>::iterator e2(entries.begin());e2!=entries.end();++e2) {
+ for(std::vector<ZeroTier::RoutingTableEntry>::iterator e2(entries.begin());e2!=entries.end();++e2) {
if ((e1->gateway.within(e2->destination))&&(e2->metric <= bestMetric)) {
bestMetric = e2->metric;
Utils::scopy(e1->device,sizeof(e1->device),e2->device);
@@ -223,14 +226,14 @@ std::vector<RoutingTable::Entry> BSDRoutingTable::get(bool includeLinkLocal,bool
return entries;
}
-RoutingTable::Entry BSDRoutingTable::set(const InetAddress &destination,const InetAddress &gateway,const char *device,int metric)
+RoutingTableEntry BSDRoutingTable::set(const InetAddress &destination,const InetAddress &gateway,const char *device,int metric)
{
if ((!gateway)&&((!device)||(!device[0])))
- return RoutingTable::Entry();
+ return RoutingTableEntry();
- std::vector<RoutingTable::Entry> rtab(get(true,true));
+ std::vector<RoutingTableEntry> rtab(get(true,true));
- for(std::vector<RoutingTable::Entry>::iterator e(rtab.begin());e!=rtab.end();++e) {
+ for(std::vector<RoutingTableEntry>::iterator e(rtab.begin());e!=rtab.end();++e) {
if (e->destination == destination) {
if (((!device)||(!device[0]))||(!strcmp(device,e->device))) {
long p = (long)fork();
@@ -248,7 +251,7 @@ RoutingTable::Entry BSDRoutingTable::set(const InetAddress &destination,const In
}
if (metric < 0)
- return RoutingTable::Entry();
+ return RoutingTableEntry();
{
char hcstr[64];
@@ -270,8 +273,8 @@ RoutingTable::Entry BSDRoutingTable::set(const InetAddress &destination,const In
}
rtab = get(true,true);
- std::vector<RoutingTable::Entry>::iterator bestEntry(rtab.end());
- for(std::vector<RoutingTable::Entry>::iterator e(rtab.begin());e!=rtab.end();++e) {
+ std::vector<RoutingTableEntry>::iterator bestEntry(rtab.end());
+ for(std::vector<RoutingTableEntry>::iterator e(rtab.begin());e!=rtab.end();++e) {
if ((e->destination == destination)&&(e->gateway.ipsEqual(gateway))) {
if ((device)&&(device[0])) {
if (!strcmp(device,e->device)) {
@@ -286,7 +289,7 @@ RoutingTable::Entry BSDRoutingTable::set(const InetAddress &destination,const In
if (bestEntry != rtab.end())
return *bestEntry;
- return RoutingTable::Entry();
+ return RoutingTableEntry();
}
} // namespace ZeroTier
@@ -299,8 +302,8 @@ int main(int argc,char **argv)
BSDRoutingTable rt;
printf("<destination> <gateway> <interface> <metric>\n");
- std::vector<RoutingTable::Entry> ents(rt.get());
- for(std::vector<RoutingTable::Entry>::iterator e(ents.begin());e!=ents.end();++e)
+ std::vector<RoutingTableEntry> ents(rt.get());
+ for(std::vector<RoutingTableEntry>::iterator e(ents.begin());e!=ents.end();++e)
printf("%s\n",e->toString().c_str());
printf("\n");
@@ -311,7 +314,7 @@ int main(int argc,char **argv)
printf("<destination> <gateway> <interface> <metric>\n");
ents = rt.get();
- for(std::vector<RoutingTable::Entry>::iterator e(ents.begin());e!=ents.end();++e)
+ for(std::vector<RoutingTableEntry>::iterator e(ents.begin());e!=ents.end();++e)
printf("%s\n",e->toString().c_str());
printf("\n");
@@ -322,10 +325,12 @@ int main(int argc,char **argv)
printf("<destination> <gateway> <interface> <metric>\n");
ents = rt.get();
- for(std::vector<RoutingTable::Entry>::iterator e(ents.begin());e!=ents.end();++e)
+ for(std::vector<RoutingTableEntry>::iterator e(ents.begin());e!=ents.end();++e)
printf("%s\n",e->toString().c_str());
printf("\n");
return 0;
}
#endif
+
+#endif // __BSD__
diff --git a/osdep/BSDRoutingTable.hpp b/osdep/BSDRoutingTable.hpp
index 97969666..ac0e4749 100644
--- a/osdep/BSDRoutingTable.hpp
+++ b/osdep/BSDRoutingTable.hpp
@@ -28,7 +28,13 @@
#ifndef ZT_BSDROUTINGTABLE_HPP
#define ZT_BSDROUTINGTABLE_HPP
-#include "../node/RoutingTable.hpp"
+#include "../node/Constants.hpp"
+
+#ifdef __BSD__
+
+#include <vector>
+
+#include "RoutingTableEntry.hpp"
namespace ZeroTier {
@@ -37,15 +43,18 @@ namespace ZeroTier {
*
* Has currently only been tested on OSX/Darwin.
*/
-class BSDRoutingTable : public RoutingTable
+class BSDRoutingTable
{
public:
BSDRoutingTable();
- virtual ~BSDRoutingTable();
- virtual std::vector<RoutingTable::Entry> get(bool includeLinkLocal = false,bool includeLoopback = false) const;
- virtual RoutingTable::Entry set(const InetAddress &destination,const InetAddress &gateway,const char *device,int metric);
+ ~BSDRoutingTable();
+
+ std::vector<RoutingTableEntry> get(bool includeLinkLocal,bool includeLoopback) const;
+ RoutingTableEntry set(const InetAddress &destination,const InetAddress &gateway,const char *device,int metric);
};
} // namespace ZeroTier
+#endif // __BSD__
+
#endif
diff --git a/osdep/LinuxRoutingTable.cpp b/osdep/LinuxRoutingTable.cpp
index 581054e2..dd866922 100644
--- a/osdep/LinuxRoutingTable.cpp
+++ b/osdep/LinuxRoutingTable.cpp
@@ -25,6 +25,10 @@
* LLC. Start here: http://www.zerotier.com/
*/
+#include "../node/Constants.hpp"
+
+#ifdef __LINUX__
+
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -42,7 +46,6 @@
#include <algorithm>
#include <utility>
-#include "../node/Constants.hpp"
#include "../node/Utils.hpp"
#include "LinuxRoutingTable.hpp"
@@ -58,11 +61,11 @@ LinuxRoutingTable::~LinuxRoutingTable()
{
}
-std::vector<RoutingTable::Entry> LinuxRoutingTable::get(bool includeLinkLocal,bool includeLoopback) const
+std::vector<RoutingTableEntry> LinuxRoutingTable::get(bool includeLinkLocal,bool includeLoopback) const
{
char buf[131072];
char *stmp,*stmp2;
- std::vector<RoutingTable::Entry> entries;
+ std::vector<RoutingTableEntry> entries;
{
int fd = ::open("/proc/net/route",O_RDONLY);
@@ -102,7 +105,7 @@ std::vector<RoutingTable::Entry> LinuxRoutingTable::get(bool includeLinkLocal,bo
}
if ((iface)&&(destination)) {
- RoutingTable::Entry e;
+ RoutingTableEntry e;
if (destination)
e.destination.set(&destination,4,Utils::countBits(mask));
e.gateway.set(&gateway,4,0);
@@ -149,7 +152,7 @@ std::vector<RoutingTable::Entry> LinuxRoutingTable::get(bool includeLinkLocal,bo
if ((device)&&(destination)) {
unsigned char tmp[16];
- RoutingTable::Entry e;
+ RoutingTableEntry e;
Utils::unhex(destination,tmp,16);
if ((!Utils::isZero(tmp,16))&&(tmp[0] != 0xff))
e.destination.set(tmp,16,destPrefixLen);
@@ -167,12 +170,12 @@ std::vector<RoutingTable::Entry> LinuxRoutingTable::get(bool includeLinkLocal,bo
return entries;
}
-RoutingTable::Entry LinuxRoutingTable::set(const InetAddress &destination,const InetAddress &gateway,const char *device,int metric)
+RoutingTableEntry LinuxRoutingTable::set(const InetAddress &destination,const InetAddress &gateway,const char *device,int metric)
{
char metstr[128];
if ((!gateway)&&((!device)||(!device[0])))
- return RoutingTable::Entry();
+ return RoutingTableEntry();
Utils::snprintf(metstr,sizeof(metstr),"%d",metric);
@@ -212,9 +215,9 @@ RoutingTable::Entry LinuxRoutingTable::set(const InetAddress &destination,const
}
}
- std::vector<RoutingTable::Entry> rtab(get(true,true));
- std::vector<RoutingTable::Entry>::iterator bestEntry(rtab.end());
- for(std::vector<RoutingTable::Entry>::iterator e(rtab.begin());e!=rtab.end();++e) {
+ std::vector<RoutingTableEntry> rtab(get(true,true));
+ std::vector<RoutingTableEntry>::iterator bestEntry(rtab.end());
+ for(std::vector<RoutingTableEntry>::iterator e(rtab.begin());e!=rtab.end();++e) {
if ((e->destination == destination)&&(e->gateway.ipsEqual(gateway))) {
if ((device)&&(device[0])) {
if (!strcmp(device,e->device)) {
@@ -229,7 +232,9 @@ RoutingTable::Entry LinuxRoutingTable::set(const InetAddress &destination,const
if (bestEntry != rtab.end())
return *bestEntry;
- return RoutingTable::Entry();
+ return RoutingTableEntry();
}
} // namespace ZeroTier
+
+#endif // __LINUX__
diff --git a/osdep/LinuxRoutingTable.hpp b/osdep/LinuxRoutingTable.hpp
index 808ec7ea..205d7b7b 100644
--- a/osdep/LinuxRoutingTable.hpp
+++ b/osdep/LinuxRoutingTable.hpp
@@ -1,6 +1,6 @@
/*
* ZeroTier One - Network Virtualization Everywhere
- * Copyright (C) 2011-2015 ZeroTier, Inc.
+ * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/
*
* 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
@@ -14,36 +14,36 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * --
- *
- * 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_LINUXROUTINGTABLE_HPP
#define ZT_LINUXROUTINGTABLE_HPP
-#include "../node/RoutingTable.hpp"
+#include "../node/Constants.hpp"
+
+#ifdef __LINUX__
+
+#include <vector>
+
+#include "RoutingTableEntry.hpp"
namespace ZeroTier {
/**
* Routing table interface via /proc/net/route, /proc/net/ipv6_route, and /sbin/route command
*/
-class LinuxRoutingTable : public RoutingTable
+class LinuxRoutingTable
{
public:
LinuxRoutingTable();
- virtual ~LinuxRoutingTable();
- virtual std::vector<RoutingTable::Entry> get(bool includeLinkLocal = false,bool includeLoopback = false) const;
- virtual RoutingTable::Entry set(const InetAddress &destination,const InetAddress &gateway,const char *device,int metric);
+ ~LinuxRoutingTable();
+
+ std::vector<RoutingTableEntry> get(bool includeLinkLocal = false,bool includeLoopback = false) const;
+ RoutingTableEntry set(const InetAddress &destination,const InetAddress &gateway,const char *device,int metric);
};
} // namespace ZeroTier
+#endif // __LINUX__
+
#endif
diff --git a/osdep/RoutingTable.cpp b/osdep/RoutingTable.cpp
deleted file mode 100644
index bae4bea9..00000000
--- a/osdep/RoutingTable.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * ZeroTier One - Network Virtualization Everywhere
- * Copyright (C) 2011-2015 ZeroTier, Inc.
- *
- * 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 <http://www.gnu.org/licenses/>.
- *
- * --
- *
- * 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/
- */
-
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "Constants.hpp"
-#include "RoutingTable.hpp"
-#include "Utils.hpp"
-
-namespace ZeroTier {
-
-std::string RoutingTable::Entry::toString() const
-{
- char tmp[1024];
- Utils::snprintf(tmp,sizeof(tmp),"%s %s %s %d",destination.toString().c_str(),((gateway) ? gateway.toIpString().c_str() : "<link>"),device,metric);
- return std::string(tmp);
-}
-
-bool RoutingTable::Entry::operator==(const Entry &re) const
-{
- return ((destination == re.destination)&&(gateway == re.gateway)&&(strcmp(device,re.device) == 0)&&(metric == re.metric));
-}
-
-bool RoutingTable::Entry::operator<(const Entry &re) const
-{
- if (destination < re.destination)
- return true;
- else if (destination == re.destination) {
- if (gateway < re.gateway)
- return true;
- else if (gateway == re.gateway) {
- int tmp = (int)::strcmp(device,re.device);
- if (tmp < 0)
- return true;
- else if (tmp == 0)
- return (metric < re.metric);
- }
- }
- return false;
-}
-
-RoutingTable::RoutingTable()
-{
-}
-
-RoutingTable::~RoutingTable()
-{
-}
-
-} // namespace ZeroTier
diff --git a/osdep/RoutingTable.hpp b/osdep/RoutingTable.hpp
deleted file mode 100644
index e1c98984..00000000
--- a/osdep/RoutingTable.hpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * ZeroTier One - Network Virtualization Everywhere
- * Copyright (C) 2011-2015 ZeroTier, Inc.
- *
- * 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 <http://www.gnu.org/licenses/>.
- *
- * --
- *
- * 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_ROUTINGTABLE_HPP
-#define ZT_ROUTINGTABLE_HPP
-
-#include <vector>
-#include <string>
-
-#include "InetAddress.hpp"
-#include "NonCopyable.hpp"
-
-namespace ZeroTier {
-
-/**
- * Base class for OS routing table interfaces
- */
-class RoutingTable : NonCopyable
-{
-public:
- class Entry
- {
- public:
- Entry() throw() { device[0] = (char)0; }
-
- /**
- * Destination IP and netmask bits (CIDR format)
- */
- InetAddress destination;
-
- /**
- * Gateway or null address if direct link-level route, netmask/port part of InetAddress not used
- */
- InetAddress gateway;
-
- /**
- * System device index or ID (not included in comparison operators, may not be set on all platforms)
- */
- int deviceIndex;
-
- /**
- * Metric or hop count -- higher = lower routing priority
- */
- int metric;
-
- /**
- * System device name
- */
- char device[128];
-
- /**
- * @return Human-readable representation of this route
- */
- std::string toString() const;
-
- /**
- * @return True if at least one required field is present (object is not null)
- */
- inline operator bool() const { return ((destination)||(gateway)||(device[0])); }
-
- bool operator==(const Entry &re) const;
- inline bool operator!=(const Entry &re) const { return (!(*this == re)); }
- bool operator<(const Entry &re) const;
- inline bool operator>(const Entry &re) const { return (re < *this); }
- inline bool operator<=(const Entry &re) const { return (!(re < *this)); }
- inline bool operator>=(const Entry &re) const { return (!(*this < re)); }
- };
-
- RoutingTable();
- virtual ~RoutingTable();
-
- /**
- * Get routing table
- *
- * @param includeLinkLocal If true, include link-local address routes (default: false)
- * @param includeLoopback Include loopback (default: false)
- * @return Sorted routing table entries
- */
- virtual std::vector<RoutingTable::Entry> get(bool includeLinkLocal = false,bool includeLoopback = false) const = 0;
-
- /**
- * Add or update a routing table entry
- *
- * If there is no change, the existing entry is returned. Use a value of -1
- * for metric to delete a route.
- *
- * @param destination Destination IP/netmask
- * @param gateway Gateway IP (netmask/port part unused) or NULL/zero for device-level route
- * @param device Device name (can be null for gateway routes)
- * @param metric Route metric or hop count (higher = lower priority) or negative to delete
- * @return Entry or null entry on failure (or delete)
- */
- virtual RoutingTable::Entry set(const InetAddress &destination,const InetAddress &gateway,const char *device,int metric) = 0;
-};
-
-} // namespace ZeroTier
-
-#endif
diff --git a/osdep/RoutingTableEntry.hpp b/osdep/RoutingTableEntry.hpp
new file mode 100644
index 00000000..578972db
--- /dev/null
+++ b/osdep/RoutingTableEntry.hpp
@@ -0,0 +1,62 @@
+/*
+ * ZeroTier One - Network Virtualization Everywhere
+ * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ZT_ROUTINGTABLEENTRY_HPP
+#define ZT_ROUTINGTABLEENTRY_HPP
+
+#include "../node/InetAddress.hpp"
+
+namespace ZeroTier {
+
+class RoutingTableEntry
+{
+public:
+ /**
+ * Destination IP and netmask bits (CIDR format)
+ */
+ InetAddress destination;
+
+ /**
+ * Gateway or null address if direct link-level route, netmask/port part of InetAddress not used
+ */
+ InetAddress gateway;
+
+ /**
+ * System device index or ID (not included in comparison operators, may not be set on all platforms)
+ */
+ int deviceIndex;
+
+ /**
+ * Metric or hop count -- higher = lower routing priority
+ */
+ int metric;
+
+ /**
+ * System device name
+ */
+ char device[128];
+
+ /**
+ * @return True if at least one required field is present (object is not null)
+ */
+ inline operator bool() const { return ((destination)||(gateway)); }
+};
+
+} // namespace ZeroTier
+
+#endif
diff --git a/osdep/TestRoutingTable.cpp b/osdep/TestRoutingTable.cpp
deleted file mode 100644
index fd61b314..00000000
--- a/osdep/TestRoutingTable.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * ZeroTier One - Network Virtualization Everywhere
- * Copyright (C) 2011-2015 ZeroTier, Inc.
- *
- * 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 <http://www.gnu.org/licenses/>.
- *
- * --
- *
- * 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/
- */
-
-#include "TestRoutingTable.hpp"
-
-namespace ZeroTier {
-
-TestRoutingTable::TestRoutingTable()
-{
-}
-
-TestRoutingTable::~TestRoutingTable()
-{
-}
-
-std::vector<RoutingTable::Entry> TestRoutingTable::get(bool includeLinkLocal,bool includeLoopback) const
-{
- return std::vector<RoutingTable::Entry>();
-}
-
-RoutingTable::Entry TestRoutingTable::set(const InetAddress &destination,const InetAddress &gateway,const char *device,int metric)
-{
- return RoutingTable::Entry();
-}
-
-} // namespace ZeroTier
diff --git a/osdep/TestRoutingTable.hpp b/osdep/TestRoutingTable.hpp
deleted file mode 100644
index 69bd3d9f..00000000
--- a/osdep/TestRoutingTable.hpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * ZeroTier One - Network Virtualization Everywhere
- * Copyright (C) 2011-2015 ZeroTier, Inc.
- *
- * 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 <http://www.gnu.org/licenses/>.
- *
- * --
- *
- * 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_TESTROUTINGTABLE_HPP
-#define ZT_TESTROUTINGTABLE_HPP
-
-#include "../node/RoutingTable.hpp"
-
-namespace ZeroTier {
-
-/**
- * Dummy routing table -- right now this just does nothing
- */
-class TestRoutingTable : public RoutingTable
-{
-public:
- TestRoutingTable();
- virtual ~TestRoutingTable();
-
- virtual std::vector<RoutingTable::Entry> get(bool includeLinkLocal = false,bool includeLoopback = false) const;
- virtual RoutingTable::Entry set(const InetAddress &destination,const InetAddress &gateway,const char *device,int metric);
-};
-
-} // namespace ZeroTier
-
-#endif
diff --git a/osdep/WindowsRoutingTable.cpp b/osdep/WindowsRoutingTable.cpp
index 00674620..20abf90f 100644
--- a/osdep/WindowsRoutingTable.cpp
+++ b/osdep/WindowsRoutingTable.cpp
@@ -1,6 +1,6 @@
/*
* ZeroTier One - Network Virtualization Everywhere
- * Copyright (C) 2011-2015 ZeroTier, Inc.
+ * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/
*
* 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
@@ -14,17 +14,12 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * --
- *
- * 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/
*/
+#include "../node/Constants.hpp"
+
+#ifdef __WINDOWS__
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -35,7 +30,6 @@
#include <vector>
-#include "../node/Constants.hpp"
#include "WindowsRoutingTable.hpp"
namespace ZeroTier {
@@ -176,3 +170,5 @@ RoutingTable::Entry WindowsRoutingTable::set(const InetAddress &destination,cons
}
} // namespace ZeroTier
+
+#endif // __WINDOWS__
diff --git a/osdep/WindowsRoutingTable.hpp b/osdep/WindowsRoutingTable.hpp
index 491c3424..a36b4f66 100644
--- a/osdep/WindowsRoutingTable.hpp
+++ b/osdep/WindowsRoutingTable.hpp
@@ -1,6 +1,6 @@
/*
* ZeroTier One - Network Virtualization Everywhere
- * Copyright (C) 2011-2015 ZeroTier, Inc.
+ * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/
*
* 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
@@ -14,36 +14,36 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * --
- *
- * 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_WINDOWSROUTINGTABLE_HPP
#define ZT_WINDOWSROUTINGTABLE_HPP
-#include "../node/RoutingTable.hpp"
+#include "../node/Constants.hpp"
+
+#ifdef __WINDOWS__
+
+#include <vector>
+
+#include "RoutingTableEntry.hpp"
namespace ZeroTier {
/**
* Interface to Microsoft Windows (Vista or newer) routing table
*/
-class WindowsRoutingTable : public RoutingTable
+class WindowsRoutingTable
{
public:
WindowsRoutingTable();
- virtual ~WindowsRoutingTable();
- virtual std::vector<RoutingTable::Entry> get(bool includeLinkLocal = false,bool includeLoopback = false) const;
- virtual RoutingTable::Entry set(const InetAddress &destination,const InetAddress &gateway,const char *device,int metric);
+ ~WindowsRoutingTable();
+
+ std::vector<RoutingTableEntry> get(bool includeLinkLocal = false,bool includeLoopback = false) const;
+ RoutingTableEntry set(const InetAddress &destination,const InetAddress &gateway,const char *device,int metric);
};
} // namespace ZeroTier
+#endif // __WINDOWS__
+
#endif