summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--make-freebsd.mk (renamed from attic/make-freebsd.mk)13
-rw-r--r--osnet/BSDEthernetTapFactory.cpp88
-rw-r--r--osnet/BSDEthernetTapFactory.hpp64
-rw-r--r--osnet/OSXEthernetTapFactory.hpp4
4 files changed, 161 insertions, 8 deletions
diff --git a/attic/make-freebsd.mk b/make-freebsd.mk
index 74499972..69f094ab 100644
--- a/attic/make-freebsd.mk
+++ b/make-freebsd.mk
@@ -6,7 +6,7 @@ DEFS=
LIBS=
include objects.mk
-OBJS+=
+OBJS+=osnet/BSDEthernetTapFactory.o osnet/BSDEthernetTap.o osnet/BSDRoutingTable.o
TESTNET_OBJS=testnet/SimNet.o testnet/SimNetSocketManager.o testnet/TestEthernetTap.o testnet/TestEthernetTapFactory.o testnet/TestRoutingTable.o
# Enable SSE-optimized Salsa20 on x86 and x86_64 machines
@@ -72,8 +72,9 @@ testnet: $(TESTNET_OBJS) $(OBJS) testnet.o
$(CXX) $(CXXFLAGS) -o zerotier-testnet testnet.o $(OBJS) $(TESTNET_OBJS) $(LIBS)
$(STRIP) zerotier-testnet
-installer: one FORCE
- ./buildinstaller.sh
+# No installer on FreeBSD yet
+#installer: one FORCE
+# ./buildinstaller.sh
clean:
rm -rf $(OBJS) $(TESTNET_OBJS) node/*.o osnet/*.o control/*.o testnet/*.o *.o zerotier-* build-* ZeroTierOneInstaller-*
@@ -81,8 +82,8 @@ clean:
debug: FORCE
make -j 4 ZT_DEBUG=1
-official: FORCE
- make -j 4 ZT_OFFICIAL_RELEASE=1
- ./buildinstaller.sh
+#official: FORCE
+# make -j 4 ZT_OFFICIAL_RELEASE=1
+# ./buildinstaller.sh
FORCE:
diff --git a/osnet/BSDEthernetTapFactory.cpp b/osnet/BSDEthernetTapFactory.cpp
new file mode 100644
index 00000000..202b1de4
--- /dev/null
+++ b/osnet/BSDEthernetTapFactory.cpp
@@ -0,0 +1,88 @@
+/*
+ * 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 <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 <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+#include "BSDEthernetTapFactory.hpp"
+#include "BSDEthernetTap.hpp"
+
+#include "../node/Utils.hpp"
+
+namespace ZeroTier {
+
+BSDEthernetTapFactory::BSDEthernetTapFactory()
+{
+ struct stat stattmp;
+ if (!stat("/sbin/ifconfig",&stattmp))
+ _pathToIfconfig = "/sbin/ifconfig";
+ else if (!stat("/usr/sbin/ifconfig",&stattmp))
+ _pathToIfconfig = "/usr/sbin/ifconfig";
+ else throw std::runtime_error("can't find ifconfig");
+}
+
+BSDEthernetTapFactory::~BSDEthernetTapFactory()
+{
+ Mutex::Lock _l(_devices_m);
+ for(std::vector<EthernetTap *>::iterator d(_devices.begin());d!=_devices.end();++d)
+ delete *d;
+}
+
+EthernetTap *BSDEthernetTapFactory::open(
+ const MAC &mac,
+ unsigned int mtu,
+ unsigned int metric,
+ uint64_t nwid,
+ const char *desiredDevice,
+ const char *friendlyName,
+ void (*handler)(void *,const MAC &,const MAC &,unsigned int,const Buffer<4096> &),
+ void *arg)
+{
+ Mutex::Lock _l(_devices_m);
+ EthernetTap *t = new BSDEthernetTap(mac,mtu,metric,nwid,desiredDevice,friendlyName,handler,arg);
+ _devices.push_back(t);
+ return t;
+}
+
+void BSDEthernetTapFactory::close(EthernetTap *tap,bool destroyPersistentDevices)
+{
+ {
+ Mutex::Lock _l(_devices_m);
+ for(std::vector<EthernetTap *>::iterator d(_devices.begin());d!=_devices.end();++d) {
+ if (*d == tap) {
+ _devices.erase(d);
+ break;
+ }
+ }
+ }
+ delete tap;
+}
+
+} // namespace ZeroTier
diff --git a/osnet/BSDEthernetTapFactory.hpp b/osnet/BSDEthernetTapFactory.hpp
new file mode 100644
index 00000000..b5988625
--- /dev/null
+++ b/osnet/BSDEthernetTapFactory.hpp
@@ -0,0 +1,64 @@
+/*
+ * 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 <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_BSDETHERNETTAPFACTORY_HPP
+#define ZT_BSDETHERNETTAPFACTORY_HPP
+
+#include <vector>
+#include <string>
+
+#include "../node/EthernetTapFactory.hpp"
+#include "../node/Mutex.hpp"
+
+namespace ZeroTier {
+
+class BSDEthernetTapFactory : public EthernetTapFactory
+{
+public:
+ BSDEthernetTapFactory();
+ virtual ~BSDEthernetTapFactory();
+
+ virtual EthernetTap *open(
+ const MAC &mac,
+ unsigned int mtu,
+ unsigned int metric,
+ uint64_t nwid,
+ const char *desiredDevice,
+ const char *friendlyName,
+ void (*handler)(void *,const MAC &,const MAC &,unsigned int,const Buffer<4096> &),
+ void *arg);
+ virtual void close(EthernetTap *tap,bool destroyPersistentDevices);
+
+private:
+ std::vector<EthernetTap *> _devices;
+ Mutex _devices_m;
+ const char *_pathToIfconfig;
+};
+
+} // namespace ZeroTier
+
+#endif
diff --git a/osnet/OSXEthernetTapFactory.hpp b/osnet/OSXEthernetTapFactory.hpp
index 45d6eab5..ee1d5989 100644
--- a/osnet/OSXEthernetTapFactory.hpp
+++ b/osnet/OSXEthernetTapFactory.hpp
@@ -25,8 +25,8 @@
* LLC. Start here: http://www.zerotier.com/
*/
-#ifndef ZT_LINUXETHERNETTAPFACTORY_HPP
-#define ZT_LINUXETHERNETTAPFACTORY_HPP
+#ifndef ZT_OSXETHERNETTAPFACTORY_HPP
+#define ZT_OSXETHERNETTAPFACTORY_HPP
#include <vector>
#include <string>