summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.cpp37
-rw-r--r--node/EthernetTap.hpp15
-rw-r--r--osnet/WindowsEthernetTap.cpp5
-rw-r--r--osnet/WindowsEthernetTap.hpp1
4 files changed, 55 insertions, 3 deletions
diff --git a/main.cpp b/main.cpp
index 386d751e..65ea7125 100644
--- a/main.cpp
+++ b/main.cpp
@@ -56,6 +56,7 @@
#endif
#include "node/Constants.hpp"
+
#include "node/Defaults.hpp"
#include "node/Utils.hpp"
#include "node/Node.hpp"
@@ -63,6 +64,33 @@
#include "node/Identity.hpp"
#include "node/Thread.hpp"
#include "node/CertificateOfMembership.hpp"
+#include "node/EthernetTapFactory.hpp"
+#include "node/RoutingTable.hpp"
+
+#ifdef __WINDOWS__
+#include "osnet/WindowsEthernetTapFactory.hpp"
+#include "osnet/WindowsRoutingTable.hpp"
+#define ZTCreatePlatformEthernetTapFactory (new WindowsEthernetTapFactory(homeDir))
+#define ZTCreatePlatformRoutingTable (new WindowsRoutingTable())
+#endif
+
+#ifdef __LINUX__
+#include "osnet/LinuxEthernetTapFactory.hpp"
+#include "osnet/LinuxRoutingTable.hpp"
+#define ZTCreatePlatformEthernetTapFactory (new LinuxEthernetTapFactory())
+#define ZTCreatePlatformRoutingTable (new LinuxRoutingTable())
+#endif
+
+#ifdef __APPLE__
+#include "osnet/OSXEthernetTapFactory.hpp"
+#include "osnet/BSDRoutingTable.hpp"
+#define ZTCreatePlatformEthernetTapFactory (new OSXEthernetTapFactory(homeDir,"tap.kext"))
+#define ZTCreatePlatformRoutingTable (new BSDRoutingTable())
+#endif
+
+#ifndef ZTCreatePlatformEthernetTapFactory
+#error Sorry, this platform has no osnet/ implementation yet. Fork me on GitHub and add one?
+#endif
using namespace ZeroTier;
@@ -649,7 +677,7 @@ int main(int argc,char **argv)
fclose(pf);
}
}
-#endif
+#endif // __UNIX_LIKE__
#ifdef __WINDOWS__
if (winRunFromCommandLine) {
@@ -670,12 +698,15 @@ int main(int argc,char **argv)
return 1;
}
}
-#endif
+#endif // __WINDOWS__
int exitCode = 0;
bool needsReset = false;
try {
- node = new Node(homeDir,udpPort,tcpPort,needsReset);
+ EthernetTapFactory *tapFactory = ZTCreatePlatformEthernetTapFactory;
+ RoutingTable *routingTable = ZTCreatePlatformRoutingTable;
+
+ node = new Node(homeDir,tapFactory,routingTable,udpPort,tcpPort,needsReset);
switch(node->run()) {
#ifdef __WINDOWS__
case Node::NODE_RESTART_FOR_UPGRADE: {
diff --git a/node/EthernetTap.hpp b/node/EthernetTap.hpp
index 87ab607d..0819fb49 100644
--- a/node/EthernetTap.hpp
+++ b/node/EthernetTap.hpp
@@ -196,6 +196,21 @@ public:
*/
virtual bool updateMulticastGroups(std::set<MulticastGroup> &groups) = 0;
+ /**
+ * Should this tap device get a pseudo-default-route?
+ *
+ * Some platforms (cough Windows) want all "real" network devices to have a
+ * routing table entry for default, even if it's got a high metric and is
+ * never used and goes nowhere. If this returns true, the underlying node
+ * code will use RoutingTable to create one if no default route is
+ * otherwise defined.
+ *
+ * Base class default returns false. Override to return true if needed.
+ *
+ * @return True if pseudo-default-route should always exist
+ */
+ virtual bool createPseudoDefaultRoute() const { return false; }
+
protected:
const char *_implName;
MAC _mac;
diff --git a/osnet/WindowsEthernetTap.cpp b/osnet/WindowsEthernetTap.cpp
index 02b902d0..16fc72d6 100644
--- a/osnet/WindowsEthernetTap.cpp
+++ b/osnet/WindowsEthernetTap.cpp
@@ -516,6 +516,11 @@ bool WindowsEthernetTap::updateMulticastGroups(std::set<MulticastGroup> &groups)
return changed;
}
+bool WindowsEthernetTap::createPseudoDefaultRoute() const
+{
+ return true;
+}
+
void WindowsEthernetTap::threadMain()
throw()
{
diff --git a/osnet/WindowsEthernetTap.hpp b/osnet/WindowsEthernetTap.hpp
index 516601bc..71ec2ce2 100644
--- a/osnet/WindowsEthernetTap.hpp
+++ b/osnet/WindowsEthernetTap.hpp
@@ -71,6 +71,7 @@ public:
virtual std::string deviceName() const;
virtual void setFriendlyName(const char *friendlyName);
virtual bool updateMulticastGroups(std::set<MulticastGroup> &groups);
+ virtual bool createPseudoDefaultRoute() const;
inline const NET_LUID &luid() const { return _deviceLuid; }
inline const GUID &guid() const { return _deviceGuid; }