diff --git a/ext/bin/tap-mac/tap.kext/Contents/Info.plist b/ext/bin/tap-mac/tap.kext/Contents/Info.plist
new file mode 100644
index 000000000..c20eefa58
--- /dev/null
+++ b/ext/bin/tap-mac/tap.kext/Contents/Info.plist
@@ -0,0 +1,36 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ English
+ CFBundleExecutable
+ tap
+ CFBundleIdentifier
+ com.zerotier.tap
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ tap
+ CFBundlePackageType
+ KEXT
+ CFBundleShortVersionString
+ 20150118
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ 1.0
+ OSBundleLibraries
+
+ com.apple.kpi.mach
+ 8.0
+ com.apple.kpi.bsd
+ 8.0
+ com.apple.kpi.libkern
+ 8.0
+ com.apple.kpi.unsupported
+ 8.0
+
+
+
+
diff --git a/ext/bin/tap-mac/tap.kext/Contents/MacOS/tap b/ext/bin/tap-mac/tap.kext/Contents/MacOS/tap
new file mode 100755
index 000000000..48bf96255
Binary files /dev/null and b/ext/bin/tap-mac/tap.kext/Contents/MacOS/tap differ
diff --git a/ext/bin/tap-mac/tap.kext/Contents/_CodeSignature/CodeResources b/ext/bin/tap-mac/tap.kext/Contents/_CodeSignature/CodeResources
new file mode 100644
index 000000000..0710b4008
--- /dev/null
+++ b/ext/bin/tap-mac/tap.kext/Contents/_CodeSignature/CodeResources
@@ -0,0 +1,105 @@
+
+
+
+
+ files
+
+ files2
+
+ rules
+
+ ^Resources/
+
+ ^Resources/.*\.lproj/
+
+ optional
+
+ weight
+ 1000
+
+ ^Resources/.*\.lproj/locversion.plist$
+
+ omit
+
+ weight
+ 1100
+
+ ^version.plist$
+
+
+ rules2
+
+ .*\.dSYM($|/)
+
+ weight
+ 11
+
+ ^(.*/)?\.DS_Store$
+
+ omit
+
+ weight
+ 2000
+
+ ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/
+
+ nested
+
+ weight
+ 10
+
+ ^.*
+
+ ^Info\.plist$
+
+ omit
+
+ weight
+ 20
+
+ ^PkgInfo$
+
+ omit
+
+ weight
+ 20
+
+ ^Resources/
+
+ weight
+ 20
+
+ ^Resources/.*\.lproj/
+
+ optional
+
+ weight
+ 1000
+
+ ^Resources/.*\.lproj/locversion.plist$
+
+ omit
+
+ weight
+ 1100
+
+ ^[^/]+$
+
+ nested
+
+ weight
+ 10
+
+ ^embedded\.provisionprofile$
+
+ weight
+ 20
+
+ ^version\.plist$
+
+ weight
+ 20
+
+
+
+
diff --git a/ext/installfiles/mac/ZeroTier One.pkgproj b/ext/installfiles/mac/ZeroTier One.pkgproj
index afda65546..2bd19123c 100755
--- a/ext/installfiles/mac/ZeroTier One.pkgproj
+++ b/ext/installfiles/mac/ZeroTier One.pkgproj
@@ -2,670 +2,731 @@
+ PACKAGES
+
+
+ MUST-CLOSE-APPLICATION-ITEMS
+
+ MUST-CLOSE-APPLICATIONS
+
+ PACKAGE_FILES
+
+ DEFAULT_INSTALL_LOCATION
+ /
+ HIERARCHY
+
+ CHILDREN
+
+
+ CHILDREN
+
+
+ CHILDREN
+
+ GID
+ 80
+ PATH
+ Utilities
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 80
+ PATH
+ ../../../macui/build/Release/ZeroTier One.app
+ PATH_TYPE
+ 1
+ PERMISSIONS
+ 493
+ TYPE
+ 3
+ UID
+ 0
+
+
+ GID
+ 80
+ PATH
+ Applications
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 509
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+
+ CHILDREN
+
+
+ CHILDREN
+
+
+ CHILDREN
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ get-proxy-settings.sh
+ PATH_TYPE
+ 1
+ PERMISSIONS
+ 493
+ TYPE
+ 3
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ launch.sh
+ PATH_TYPE
+ 1
+ PERMISSIONS
+ 493
+ TYPE
+ 3
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 80
+ PATH
+ ../../../MacEthernetTapAgent
+ PATH_TYPE
+ 1
+ PERMISSIONS
+ 493
+ TYPE
+ 3
+ UID
+ 0
+
+
+ BUNDLE_CAN_DOWNGRADE
+
+ BUNDLE_POSTINSTALL_PATH
+
+ PATH_TYPE
+ 0
+
+ BUNDLE_PREINSTALL_PATH
+
+ PATH_TYPE
+ 0
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ ../../bin/tap-mac/tap.kext
+ PATH_TYPE
+ 1
+ PERMISSIONS
+ 493
+ TYPE
+ 3
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ uninstall.sh
+ PATH_TYPE
+ 1
+ PERMISSIONS
+ 493
+ TYPE
+ 3
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ ../../../zerotier-one
+ PATH_TYPE
+ 1
+ PERMISSIONS
+ 493
+ TYPE
+ 3
+ UID
+ 0
+
+
+ GID
+ 80
+ PATH
+ One
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 2
+ UID
+ 0
+
+
+ GID
+ 80
+ PATH
+ ZeroTier
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 2
+ UID
+ 0
+
+
+ GID
+ 80
+ PATH
+ Application Support
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ Automator
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ Documentation
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ Filesystems
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ Frameworks
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ Input Methods
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ Internet Plug-Ins
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ LaunchAgents
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ com.zerotier.one.plist
+ PATH_TYPE
+ 1
+ PERMISSIONS
+ 420
+ TYPE
+ 3
+ UID
+ 0
+
+
+ GID
+ 0
+ PATH
+ LaunchDaemons
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ PreferencePanes
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ Preferences
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 80
+ PATH
+ Printers
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ PrivilegedHelperTools
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 1005
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ QuickLook
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ QuickTime
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ Screen Savers
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ Scripts
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ Services
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ Widgets
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ Extensions
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ GID
+ 0
+ PATH
+ Library
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+
+ CHILDREN
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ Extensions
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ GID
+ 0
+ PATH
+ Library
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ GID
+ 0
+ PATH
+ System
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ CHILDREN
+
+
+ CHILDREN
+
+ GID
+ 0
+ PATH
+ Shared
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 1023
+ TYPE
+ 1
+ UID
+ 0
+
+
+ GID
+ 80
+ PATH
+ Users
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+
+ GID
+ 0
+ PATH
+ /
+ PATH_TYPE
+ 0
+ PERMISSIONS
+ 493
+ TYPE
+ 1
+ UID
+ 0
+
+ PAYLOAD_TYPE
+ 0
+ PRESERVE_EXTENDED_ATTRIBUTES
+
+ SHOW_INVISIBLE
+
+ SPLIT_FORKS
+
+ TREAT_MISSING_FILES_AS_WARNING
+
+ VERSION
+ 5
+
+ PACKAGE_SCRIPTS
+
+ POSTINSTALL_PATH
+
+ PATH
+ postinst.sh
+ PATH_TYPE
+ 1
+
+ PREINSTALL_PATH
+
+ PATH
+ preinst.sh
+ PATH_TYPE
+ 1
+
+ RESOURCES
+
+
+ PACKAGE_SETTINGS
+
+ AUTHENTICATION
+ 1
+ CONCLUSION_ACTION
+ 0
+ FOLLOW_SYMBOLIC_LINKS
+
+ IDENTIFIER
+ com.zerotier.pkg.ZeroTierOne
+ LOCATION
+ 0
+ NAME
+ ZeroTier One
+ OVERWRITE_PERMISSIONS
+
+ PAYLOAD_SIZE
+ -1
+ REFERENCE_PATH
+
+ RELOCATABLE
+
+ USE_HFS+_COMPRESSION
+
+ VERSION
+ 1.4.2
+
+ TYPE
+ 0
+ UUID
+ 1B6AFC3A-9EA5-4401-83D4-37F06CD13CD6
+
+
PROJECT
- PACKAGE_FILES
-
- DEFAULT_INSTALL_LOCATION
- /
- HIERARCHY
-
- CHILDREN
-
-
- CHILDREN
-
-
- CHILDREN
-
- GID
- 80
- PATH
- Utilities
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
- GID
- 80
- PATH
- ../../../macui/build/Release/ZeroTier One.app
- PATH_TYPE
- 1
- PERMISSIONS
- 493
- TYPE
- 3
- UID
- 0
-
-
- GID
- 80
- PATH
- Applications
- PATH_TYPE
- 0
- PERMISSIONS
- 509
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
-
- CHILDREN
-
-
- CHILDREN
-
-
- CHILDREN
-
-
- CHILDREN
-
- GID
- 0
- PATH
- get-proxy-settings.sh
- PATH_TYPE
- 1
- PERMISSIONS
- 493
- TYPE
- 3
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- launch.sh
- PATH_TYPE
- 1
- PERMISSIONS
- 493
- TYPE
- 3
- UID
- 0
-
-
- CHILDREN
-
- GID
- 80
- PATH
- ../../../MacEthernetTapAgent
- PATH_TYPE
- 1
- PERMISSIONS
- 493
- TYPE
- 3
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- uninstall.sh
- PATH_TYPE
- 1
- PERMISSIONS
- 493
- TYPE
- 3
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- ../../../zerotier-one
- PATH_TYPE
- 1
- PERMISSIONS
- 493
- TYPE
- 3
- UID
- 0
-
-
- GID
- 80
- PATH
- One
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 2
- UID
- 0
-
-
- GID
- 80
- PATH
- ZeroTier
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 2
- UID
- 0
-
-
- GID
- 80
- PATH
- Application Support
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- Automator
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- Documentation
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- Filesystems
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- Frameworks
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- Input Methods
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- Internet Plug-Ins
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- LaunchAgents
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
-
- CHILDREN
-
- GID
- 0
- PATH
- com.zerotier.one.plist
- PATH_TYPE
- 1
- PERMISSIONS
- 420
- TYPE
- 3
- UID
- 0
-
-
- GID
- 0
- PATH
- LaunchDaemons
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- PreferencePanes
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- Preferences
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
- GID
- 80
- PATH
- Printers
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- PrivilegedHelperTools
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- QuickLook
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- QuickTime
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- Screen Savers
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- Scripts
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- Services
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
- GID
- 0
- PATH
- Widgets
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- GID
- 0
- PATH
- Library
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
-
- CHILDREN
-
-
- CHILDREN
-
- GID
- 0
- PATH
- Extensions
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- GID
- 0
- PATH
- Library
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- GID
- 0
- PATH
- System
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- CHILDREN
-
-
- CHILDREN
-
- GID
- 0
- PATH
- Shared
- PATH_TYPE
- 0
- PERMISSIONS
- 1023
- TYPE
- 1
- UID
- 0
-
-
- GID
- 80
- PATH
- Users
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
-
- GID
- 0
- PATH
- /
- PATH_TYPE
- 0
- PERMISSIONS
- 493
- TYPE
- 1
- UID
- 0
-
- PAYLOAD_TYPE
- 0
- SHOW_INVISIBLE
-
- SPLIT_FORKS
-
- TREAT_MISSING_FILES_AS_WARNING
-
- VERSION
- 3
-
- PACKAGE_SCRIPTS
-
- POSTINSTALL_PATH
-
- PATH
- postinst.sh
- PATH_TYPE
- 1
-
- PREINSTALL_PATH
-
- PATH
- preinst.sh
- PATH_TYPE
- 1
-
- RESOURCES
-
-
- PACKAGE_SETTINGS
-
- AUTHENTICATION
- 1
- CONCLUSION_ACTION
- 0
- FOLLOW_SYMBOLIC_LINKS
-
- IDENTIFIER
- com.zerotier.pkg.ZeroTierOne
- LOCATION
- 0
- NAME
-
- OVERWRITE_PERMISSIONS
-
- PAYLOAD_SIZE
- -1
- RELOCATABLE
-
- USE_HFS+_COMPRESSION
-
- VERSION
- 1.4.2
-
PROJECT_COMMENTS
NOTES
@@ -701,8 +762,139 @@
dG1sPgo=
+ PROJECT_PRESENTATION
+
+ BACKGROUND
+
+ APPAREANCES
+
+ DARK_AQUA
+
+ LIGHT_AQUA
+
+
+ SHARED_SETTINGS_FOR_ALL_APPAREANCES
+
+
+ INSTALLATION_STEPS
+
+
+ ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS
+ ICPresentationViewIntroductionController
+ INSTALLER_PLUGIN
+ Introduction
+ LIST_TITLE_KEY
+ InstallerSectionTitle
+
+
+ ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS
+ ICPresentationViewReadMeController
+ INSTALLER_PLUGIN
+ ReadMe
+ LIST_TITLE_KEY
+ InstallerSectionTitle
+
+
+ ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS
+ ICPresentationViewLicenseController
+ INSTALLER_PLUGIN
+ License
+ LIST_TITLE_KEY
+ InstallerSectionTitle
+
+
+ ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS
+ ICPresentationViewDestinationSelectController
+ INSTALLER_PLUGIN
+ TargetSelect
+ LIST_TITLE_KEY
+ InstallerSectionTitle
+
+
+ ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS
+ ICPresentationViewInstallationTypeController
+ INSTALLER_PLUGIN
+ PackageSelection
+ LIST_TITLE_KEY
+ InstallerSectionTitle
+
+
+ ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS
+ ICPresentationViewInstallationController
+ INSTALLER_PLUGIN
+ Install
+ LIST_TITLE_KEY
+ InstallerSectionTitle
+
+
+ ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS
+ ICPresentationViewSummaryController
+ INSTALLER_PLUGIN
+ Summary
+ LIST_TITLE_KEY
+ InstallerSectionTitle
+
+
+ INTRODUCTION
+
+ LOCALIZATIONS
+
+
+ LICENSE
+
+ LOCALIZATIONS
+
+ MODE
+ 0
+
+ README
+
+ LOCALIZATIONS
+
+
+ TITLE
+
+ LOCALIZATIONS
+
+
+
+ PROJECT_REQUIREMENTS
+
+ LIST
+
+
+ BEHAVIOR
+ 3
+ DICTIONARY
+
+ IC_REQUIREMENT_OS_DISK_TYPE
+ 0
+ IC_REQUIREMENT_OS_DISTRIBUTION_TYPE
+ 0
+ IC_REQUIREMENT_OS_MINIMUM_VERSION
+ 101000
+
+ IC_REQUIREMENT_CHECK_TYPE
+ 1
+ IDENTIFIER
+ fr.whitebox.Packages.requirement.os
+ MESSAGE
+
+ NAME
+ Operating System
+ STATE
+
+
+
+ RESOURCES
+
+ ROOT_VOLUME_ONLY
+
+
PROJECT_SETTINGS
+ BUILD_FORMAT
+ 0
BUILD_PATH
PATH
@@ -882,10 +1074,17 @@
ZeroTier One
PAYLOAD_ONLY
+ TREAT_MISSING_PRESENTATION_DOCUMENTS_AS_WARNING
+
+ SHARED_GLOBAL_DATA
+
+ IC_REQUIREMENT_JAVASCRIPT_SHARED_SOURCE_CODE
+
+
TYPE
- 1
+ 0
VERSION
2
diff --git a/ext/installfiles/mac/postinst.sh b/ext/installfiles/mac/postinst.sh
index b4ea2ee23..95301a4e9 100755
--- a/ext/installfiles/mac/postinst.sh
+++ b/ext/installfiles/mac/postinst.sh
@@ -3,6 +3,7 @@
export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
OSX_RELEASE=`sw_vers -productVersion | cut -d . -f 1,2`
+DARWIN_MAJOR=`uname -r | cut -d . -f 1`
launchctl unload /Library/LaunchDaemons/com.zerotier.one.plist >>/dev/null 2>&1
sleep 0.5
@@ -43,9 +44,11 @@ rm -f zerotier-cli zerotier-idtool
ln -sf "/Library/Application Support/ZeroTier/One/zerotier-one" zerotier-cli
ln -sf "/Library/Application Support/ZeroTier/One/zerotier-one" zerotier-idtool
-cd "/Library/Application Support/ZeroTier/One"
-kextload -r . tap.kext >>/dev/null 2>&1 &
-disown %1
+if [ $DARWIN_MAJOR -le 16 ]; then
+ cd "/Library/Application Support/ZeroTier/One"
+ kextload -r . tap.kext >>/dev/null 2>&1 &
+ disown %1
+fi
launchctl load /Library/LaunchDaemons/com.zerotier.one.plist >>/dev/null 2>&1
diff --git a/make-mac.mk b/make-mac.mk
index 0735a47fb..c71b3f778 100644
--- a/make-mac.mk
+++ b/make-mac.mk
@@ -19,7 +19,7 @@ ZT_VERSION_BUILD=$(shell cat version.h | grep -F VERSION_BUILD | cut -d ' ' -f 3
DEFS+=-DZT_BUILD_PLATFORM=$(ZT_BUILD_PLATFORM) -DZT_BUILD_ARCHITECTURE=$(ZT_BUILD_ARCHITECTURE)
include objects.mk
-ONE_OBJS+=osdep/MacEthernetTap.o ext/http-parser/http_parser.o
+ONE_OBJS+=osdep/MacEthernetTap.o osdep/MacKextEthernetTap.o ext/http-parser/http_parser.o
ifeq ($(ZT_CONTROLLER),1)
LIBS+=-lpq -lrabbitmq
diff --git a/objects.mk b/objects.mk
index 7b85263d9..147122b53 100644
--- a/objects.mk
+++ b/objects.mk
@@ -35,6 +35,7 @@ ONE_OBJS=\
controller/LFDB.o \
controller/PostgreSQL.o \
controller/RabbitMQ.o \
+ osdep/EthernetTap.o \
osdep/ManagedRoute.o \
osdep/Http.o \
osdep/OSUtils.o \
diff --git a/osdep/BSDEthernetTap.hpp b/osdep/BSDEthernetTap.hpp
index deefd5c74..5b1fe2dc8 100644
--- a/osdep/BSDEthernetTap.hpp
+++ b/osdep/BSDEthernetTap.hpp
@@ -38,10 +38,11 @@
#include "../node/MulticastGroup.hpp"
#include "../node/MAC.hpp"
#include "Thread.hpp"
+#include "EthernetTap.hpp"
namespace ZeroTier {
-class BSDEthernetTap
+class BSDEthernetTap : public EthernetTap
{
public:
BSDEthernetTap(
@@ -54,18 +55,18 @@ public:
void (*handler)(void *,void *,uint64_t,const MAC &,const MAC &,unsigned int,unsigned int,const void *,unsigned int),
void *arg);
- ~BSDEthernetTap();
+ virtual ~BSDEthernetTap();
- void setEnabled(bool en);
- bool enabled() const;
- bool addIp(const InetAddress &ip);
- bool removeIp(const InetAddress &ip);
- std::vector ips() const;
- void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len);
- std::string deviceName() const;
- void setFriendlyName(const char *friendlyName);
- void scanMulticastGroups(std::vector &added,std::vector &removed);
- void setMtu(unsigned int mtu);
+ virtual void setEnabled(bool en);
+ virtual bool enabled() const;
+ virtual bool addIp(const InetAddress &ip);
+ virtual bool removeIp(const InetAddress &ip);
+ virtual std::vector ips() const;
+ virtual void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len);
+ virtual std::string deviceName() const;
+ virtual void setFriendlyName(const char *friendlyName);
+ virtual void scanMulticastGroups(std::vector &added,std::vector &removed);
+ virtual void setMtu(unsigned int mtu);
void threadMain()
throw();
diff --git a/osdep/EthernetTap.cpp b/osdep/EthernetTap.cpp
new file mode 100644
index 000000000..c3bb4ca17
--- /dev/null
+++ b/osdep/EthernetTap.cpp
@@ -0,0 +1,129 @@
+/*
+ * ZeroTier One - Network Virtualization Everywhere
+ * Copyright (C) 2011-2019 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 .
+ *
+ * --
+ *
+ * You can be released from the requirements of the license by purchasing
+ * a commercial license. Buying such a license is mandatory as soon as you
+ * develop commercial closed-source software that incorporates or links
+ * directly against ZeroTier software without disclosing the source code
+ * of your own application.
+ */
+
+#include "EthernetTap.hpp"
+#include "OSUtils.hpp"
+
+#include
+#include
+
+#ifdef __APPLE__
+#include
+#include "MacEthernetTap.hpp"
+#include "MacKextEthernetTap.hpp"
+#endif // __APPLE__
+
+#ifdef __LINUX__
+#include "LinuxEthernetTap.hpp"
+#endif // __LINUX__
+
+#ifdef __WINDOWS__
+#include "WindowsEthernetTap.hpp"
+#endif // __WINDOWS__
+
+#ifdef __FreeBSD__
+#include "BSDEthernetTap.hpp"
+#endif // __FreeBSD__
+
+#ifdef __NetBSD__
+#include "NetBSDEthernetTap.hpp"
+#endif // __NetBSD__
+
+#ifdef __OpenBSD__
+#include "BSDEthernetTap.hpp"
+#endif // __OpenBSD__
+
+#ifdef ZT_SDK
+#include "../controller/EmbeddedNetworkController.hpp"
+#include "../node/Node.hpp"
+#include "../include/VirtualTap.hpp"
+#endif
+
+namespace ZeroTier {
+
+std::shared_ptr EthernetTap::newInstance(
+ const char *tapDeviceType, // OS-specific, NULL for default
+ const char *homePath,
+ const MAC &mac,
+ unsigned int mtu,
+ unsigned int metric,
+ uint64_t nwid,
+ const char *friendlyName,
+ void (*handler)(void *,void *,uint64_t,const MAC &,const MAC &,unsigned int,unsigned int,const void *,unsigned int),
+ void *arg)
+{
+
+#ifdef ZT_SDK
+ return std::shared_ptr(new VirtualTap(homePath,mac,mtu,metric,nwid,friendlyName,handler,arg));
+#else // not ZT_SDK
+
+#ifdef __APPLE__
+ char osrelease[256];
+ size_t size = sizeof(osrelease);
+ if (sysctlbyname("kern.osrelease",osrelease,&size,nullptr,0) == 0) {
+ char *dotAt = strchr(osrelease,'.');
+ if (dotAt) {
+ *dotAt = (char)0;
+ // The "feth" virtual Ethernet device type appeared in Darwin 17.x.x. Older versions
+ // (Sierra and earlier) must use the a kernel extension.
+ if (strtol(osrelease,(char **)0,10) < 17) {
+ return std::shared_ptr(new MacKextEthernetTap(homePath,mac,mtu,metric,nwid,friendlyName,handler,arg));
+ } else {
+ return std::shared_ptr(new MacEthernetTap(homePath,mac,mtu,metric,nwid,friendlyName,handler,arg));
+ }
+ }
+ }
+#endif // __APPLE__
+
+#ifdef __LINUX__
+ return std::shared_ptr(new LinuxEthernetTap(homePath,mac,mtu,metric,nwid,friendlyName,handler,arg));
+#endif // __LINUX__
+
+#ifdef __WINDOWS__
+ return std::shared_ptr(new WindowsEthernetTap(homePath,mac,mtu,metric,nwid,friendlyName,handler,arg));
+#endif // __WINDOWS__
+
+#ifdef __FreeBSD__
+ return std::shared_ptr(new BSDEthernetTap(homePath,mac,mtu,metric,nwid,friendlyName,handler,arg));
+#endif // __FreeBSD__
+
+#ifdef __NetBSD__
+ return std::shared_ptr(new NetBSDEthernetTap(homePath,mac,mtu,metric,nwid,friendlyName,handler,arg));
+#endif // __NetBSD__
+
+#ifdef __OpenBSD__
+ return std::shared_ptr(new BSDEthernetTap(homePath,mac,mtu,metric,nwid,friendlyName,handler,arg));
+#endif // __OpenBSD__
+
+#endif // ZT_SDK?
+
+ return std::shared_ptr();
+}
+
+EthernetTap::EthernetTap() {}
+EthernetTap::~EthernetTap() {}
+
+} // namespace ZeroTier
diff --git a/osdep/EthernetTap.hpp b/osdep/EthernetTap.hpp
new file mode 100644
index 000000000..fc8fc8482
--- /dev/null
+++ b/osdep/EthernetTap.hpp
@@ -0,0 +1,72 @@
+/*
+ * ZeroTier One - Network Virtualization Everywhere
+ * Copyright (C) 2011-2019 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 .
+ *
+ * --
+ *
+ * You can be released from the requirements of the license by purchasing
+ * a commercial license. Buying such a license is mandatory as soon as you
+ * develop commercial closed-source software that incorporates or links
+ * directly against ZeroTier software without disclosing the source code
+ * of your own application.
+ */
+
+#ifndef ZT_ETHERNETTAP_HPP
+#define ZT_ETHERNETTAP_HPP
+
+#include "../node/Constants.hpp"
+#include "../node/MAC.hpp"
+#include "../node/InetAddress.hpp"
+#include "../node/MulticastGroup.hpp"
+
+#include
+#include
+#include
+
+namespace ZeroTier {
+
+class EthernetTap
+{
+public:
+ static std::shared_ptr newInstance(
+ const char *tapDeviceType, // OS-specific, NULL for default
+ const char *homePath,
+ const MAC &mac,
+ unsigned int mtu,
+ unsigned int metric,
+ uint64_t nwid,
+ const char *friendlyName,
+ void (*handler)(void *,void *,uint64_t,const MAC &,const MAC &,unsigned int,unsigned int,const void *,unsigned int),
+ void *arg);
+
+ EthernetTap();
+ virtual ~EthernetTap();
+
+ virtual void setEnabled(bool en) = 0;
+ virtual bool enabled() const = 0;
+ virtual bool addIp(const InetAddress &ip) = 0;
+ virtual bool removeIp(const InetAddress &ip) = 0;
+ virtual std::vector ips() const = 0;
+ virtual void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len) = 0;
+ virtual std::string deviceName() const = 0;
+ virtual void setFriendlyName(const char *friendlyName) = 0;
+ virtual void scanMulticastGroups(std::vector &added,std::vector &removed) = 0;
+ virtual void setMtu(unsigned int mtu) = 0;
+};
+
+} // namespace ZeroTier
+
+#endif
diff --git a/osdep/LinuxEthernetTap.cpp b/osdep/LinuxEthernetTap.cpp
index 2ea93dd1d..5ed49eef8 100644
--- a/osdep/LinuxEthernetTap.cpp
+++ b/osdep/LinuxEthernetTap.cpp
@@ -24,6 +24,17 @@
* of your own application.
*/
+#include "../node/Constants.hpp"
+
+#ifdef __LINUX__
+
+#include "../node/Utils.hpp"
+#include "../node/Mutex.hpp"
+#include "../node/Dictionary.hpp"
+#include "OSUtils.hpp"
+#include "LinuxEthernetTap.hpp"
+#include "LinuxNetLink.hpp"
+
#include
#include
#include
@@ -50,14 +61,6 @@
#include
#include
-#include "../node/Constants.hpp"
-#include "../node/Utils.hpp"
-#include "../node/Mutex.hpp"
-#include "../node/Dictionary.hpp"
-#include "OSUtils.hpp"
-#include "LinuxEthernetTap.hpp"
-#include "LinuxNetLink.hpp"
-
// ff:ff:ff:ff:ff:ff with no ADI
static const ZeroTier::MulticastGroup _blindWildcardMulticastGroup(ZeroTier::MAC(0xff),0);
@@ -519,3 +522,5 @@ void LinuxEthernetTap::threadMain()
}
} // namespace ZeroTier
+
+#endif // __LINUX__
diff --git a/osdep/LinuxEthernetTap.hpp b/osdep/LinuxEthernetTap.hpp
index 050bec343..1acecb4b6 100644
--- a/osdep/LinuxEthernetTap.hpp
+++ b/osdep/LinuxEthernetTap.hpp
@@ -33,16 +33,15 @@
#include
#include
#include
+#include
#include "../node/MulticastGroup.hpp"
#include "Thread.hpp"
+#include "EthernetTap.hpp"
namespace ZeroTier {
-/**
- * Linux Ethernet tap using kernel tun/tap driver
- */
-class LinuxEthernetTap
+class LinuxEthernetTap : public EthernetTap
{
public:
LinuxEthernetTap(
@@ -55,21 +54,21 @@ public:
void (*handler)(void *,void *,uint64_t,const MAC &,const MAC &,unsigned int,unsigned int,const void *,unsigned int),
void *arg);
- ~LinuxEthernetTap();
+ virtual ~LinuxEthernetTap();
- void setEnabled(bool en);
- bool enabled() const;
- bool addIp(const InetAddress &ip);
+ virtual void setEnabled(bool en);
+ virtual bool enabled() const;
+ virtual bool addIp(const InetAddress &ip);
#ifdef __SYNOLOGY__
bool addIpSyn(std::vector ips);
#endif
- bool removeIp(const InetAddress &ip);
- std::vector ips() const;
- void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len);
- std::string deviceName() const;
- void setFriendlyName(const char *friendlyName);
- void scanMulticastGroups(std::vector &added,std::vector &removed);
- void setMtu(unsigned int mtu);
+ virtual bool removeIp(const InetAddress &ip);
+ virtual std::vector ips() const;
+ virtual void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len);
+ virtual std::string deviceName() const;
+ virtual void setFriendlyName(const char *friendlyName);
+ virtual void scanMulticastGroups(std::vector &added,std::vector &removed);
+ virtual void setMtu(unsigned int mtu);
void threadMain()
throw();
@@ -85,7 +84,7 @@ private:
unsigned int _mtu;
int _fd;
int _shutdownSignalPipe[2];
- volatile bool _enabled;
+ std::atomic_bool _enabled;
};
} // namespace ZeroTier
diff --git a/osdep/MacEthernetTap.cpp b/osdep/MacEthernetTap.cpp
index a11a75e24..237df4704 100644
--- a/osdep/MacEthernetTap.cpp
+++ b/osdep/MacEthernetTap.cpp
@@ -24,6 +24,17 @@
* of your own application.
*/
+#include "../node/Constants.hpp"
+
+#ifdef __APPLE__
+
+#include "../node/Utils.hpp"
+#include "../node/Mutex.hpp"
+#include "../node/Dictionary.hpp"
+#include "OSUtils.hpp"
+#include "MacEthernetTap.hpp"
+#include "MacEthernetTapAgent.h"
+
#include
#include
#include
@@ -57,14 +68,6 @@
#include
#include
-#include "../node/Constants.hpp"
-#include "../node/Utils.hpp"
-#include "../node/Mutex.hpp"
-#include "../node/Dictionary.hpp"
-#include "OSUtils.hpp"
-#include "MacEthernetTap.hpp"
-#include "MacEthernetTapAgent.h"
-
static const ZeroTier::MulticastGroup _blindWildcardMulticastGroup(ZeroTier::MAC(0xff),0);
namespace ZeroTier {
@@ -463,3 +466,5 @@ void MacEthernetTap::threadMain()
}
} // namespace ZeroTier
+
+#endif // __APPLE__
diff --git a/osdep/MacEthernetTap.hpp b/osdep/MacEthernetTap.hpp
index fb5bc6dbb..2eef59be6 100644
--- a/osdep/MacEthernetTap.hpp
+++ b/osdep/MacEthernetTap.hpp
@@ -27,6 +27,14 @@
#ifndef ZT_OSXETHERNETTAP_HPP
#define ZT_OSXETHERNETTAP_HPP
+#include "../node/Constants.hpp"
+#include "../node/MAC.hpp"
+#include "../node/InetAddress.hpp"
+#include "../node/MulticastGroup.hpp"
+#include "../node/Mutex.hpp"
+#include "Thread.hpp"
+#include "EthernetTap.hpp"
+
#include
#include
@@ -34,17 +42,9 @@
#include
#include
-#include "../node/Constants.hpp"
-#include "../node/MAC.hpp"
-#include "../node/InetAddress.hpp"
-#include "../node/MulticastGroup.hpp"
-#include "../node/Mutex.hpp"
-
-#include "Thread.hpp"
-
namespace ZeroTier {
-class MacEthernetTap
+class MacEthernetTap : public EthernetTap
{
public:
MacEthernetTap(
@@ -57,18 +57,18 @@ public:
void (*handler)(void *,void *,uint64_t,const MAC &,const MAC &,unsigned int,unsigned int,const void *,unsigned int),
void *arg);
- ~MacEthernetTap();
+ virtual ~MacEthernetTap();
- void setEnabled(bool en);
- bool enabled() const;
- bool addIp(const InetAddress &ip);
- bool removeIp(const InetAddress &ip);
- std::vector ips() const;
- void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len);
- std::string deviceName() const;
- void setFriendlyName(const char *friendlyName);
- void scanMulticastGroups(std::vector &added,std::vector &removed);
- void setMtu(unsigned int mtu);
+ virtual void setEnabled(bool en);
+ virtual bool enabled() const;
+ virtual bool addIp(const InetAddress &ip);
+ virtual bool removeIp(const InetAddress &ip);
+ virtual std::vector ips() const;
+ virtual void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len);
+ virtual std::string deviceName() const;
+ virtual void setFriendlyName(const char *friendlyName);
+ virtual void scanMulticastGroups(std::vector &added,std::vector &removed);
+ virtual void setMtu(unsigned int mtu);
void threadMain()
throw();
diff --git a/osdep/MacKextEthernetTap.cpp b/osdep/MacKextEthernetTap.cpp
new file mode 100644
index 000000000..4f0520a65
--- /dev/null
+++ b/osdep/MacKextEthernetTap.cpp
@@ -0,0 +1,703 @@
+/*
+ * ZeroTier One - Network Virtualization Everywhere
+ * Copyright (C) 2011-2018 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 .
+ *
+ * --
+ *
+ * You can be released from the requirements of the license by purchasing
+ * a commercial license. Buying such a license is mandatory as soon as you
+ * develop commercial closed-source software that incorporates or links
+ * directly against ZeroTier software without disclosing the source code
+ * of your own application.
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+// OSX compile fix... in6_var defines this in a struct which namespaces it for C++ ... why?!?
+struct prf_ra {
+ u_char onlink : 1;
+ u_char autonomous : 1;
+ u_char reserved : 6;
+} prf_ra;
+
+#include
+#include
+
+// These are KERNEL_PRIVATE... why?
+#ifndef SIOCAUTOCONF_START
+#define SIOCAUTOCONF_START _IOWR('i', 132, struct in6_ifreq) /* accept rtadvd on this interface */
+#endif
+#ifndef SIOCAUTOCONF_STOP
+#define SIOCAUTOCONF_STOP _IOWR('i', 133, struct in6_ifreq) /* stop accepting rtadv for this interface */
+#endif
+
+// --------------------------------------------------------------------------
+// --------------------------------------------------------------------------
+// This source is from:
+// http://www.opensource.apple.com/source/Libinfo/Libinfo-406.17/gen.subproj/getifmaddrs.c?txt
+// It's here because OSX 10.6 does not have this convenience function.
+
+#define SALIGN (sizeof(uint32_t) - 1)
+#define SA_RLEN(sa) ((sa)->sa_len ? (((sa)->sa_len + SALIGN) & ~SALIGN) : \
+(SALIGN + 1))
+#define MAX_SYSCTL_TRY 5
+#define RTA_MASKS (RTA_GATEWAY | RTA_IFP | RTA_IFA)
+
+/* FreeBSD uses NET_RT_IFMALIST and RTM_NEWMADDR from */
+/* We can use NET_RT_IFLIST2 and RTM_NEWMADDR2 on Darwin */
+//#define DARWIN_COMPAT
+
+//#ifdef DARWIN_COMPAT
+#define GIM_SYSCTL_MIB NET_RT_IFLIST2
+#define GIM_RTM_ADDR RTM_NEWMADDR2
+//#else
+//#define GIM_SYSCTL_MIB NET_RT_IFMALIST
+//#define GIM_RTM_ADDR RTM_NEWMADDR
+//#endif
+
+// Not in 10.6 includes so use our own
+struct _intl_ifmaddrs {
+ struct _intl_ifmaddrs *ifma_next;
+ struct sockaddr *ifma_name;
+ struct sockaddr *ifma_addr;
+ struct sockaddr *ifma_lladdr;
+};
+
+static inline int _intl_getifmaddrs(struct _intl_ifmaddrs **pif)
+{
+ int icnt = 1;
+ int dcnt = 0;
+ int ntry = 0;
+ size_t len;
+ size_t needed;
+ int mib[6];
+ int i;
+ char *buf;
+ char *data;
+ char *next;
+ char *p;
+ struct ifma_msghdr2 *ifmam;
+ struct _intl_ifmaddrs *ifa, *ift;
+ struct rt_msghdr *rtm;
+ struct sockaddr *sa;
+
+ mib[0] = CTL_NET;
+ mib[1] = PF_ROUTE;
+ mib[2] = 0; /* protocol */
+ mib[3] = 0; /* wildcard address family */
+ mib[4] = GIM_SYSCTL_MIB;
+ mib[5] = 0; /* no flags */
+ do {
+ if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
+ return (-1);
+ if ((buf = (char *)malloc(needed)) == NULL)
+ return (-1);
+ if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) {
+ if (errno != ENOMEM || ++ntry >= MAX_SYSCTL_TRY) {
+ free(buf);
+ return (-1);
+ }
+ free(buf);
+ buf = NULL;
+ }
+ } while (buf == NULL);
+
+ for (next = buf; next < buf + needed; next += rtm->rtm_msglen) {
+ rtm = (struct rt_msghdr *)(void *)next;
+ if (rtm->rtm_version != RTM_VERSION)
+ continue;
+ switch (rtm->rtm_type) {
+ case GIM_RTM_ADDR:
+ ifmam = (struct ifma_msghdr2 *)(void *)rtm;
+ if ((ifmam->ifmam_addrs & RTA_IFA) == 0)
+ break;
+ icnt++;
+ p = (char *)(ifmam + 1);
+ for (i = 0; i < RTAX_MAX; i++) {
+ if ((RTA_MASKS & ifmam->ifmam_addrs &
+ (1 << i)) == 0)
+ continue;
+ sa = (struct sockaddr *)(void *)p;
+ len = SA_RLEN(sa);
+ dcnt += len;
+ p += len;
+ }
+ break;
+ }
+ }
+
+ data = (char *)malloc(sizeof(struct _intl_ifmaddrs) * icnt + dcnt);
+ if (data == NULL) {
+ free(buf);
+ return (-1);
+ }
+
+ ifa = (struct _intl_ifmaddrs *)(void *)data;
+ data += sizeof(struct _intl_ifmaddrs) * icnt;
+
+ memset(ifa, 0, sizeof(struct _intl_ifmaddrs) * icnt);
+ ift = ifa;
+
+ for (next = buf; next < buf + needed; next += rtm->rtm_msglen) {
+ rtm = (struct rt_msghdr *)(void *)next;
+ if (rtm->rtm_version != RTM_VERSION)
+ continue;
+
+ switch (rtm->rtm_type) {
+ case GIM_RTM_ADDR:
+ ifmam = (struct ifma_msghdr2 *)(void *)rtm;
+ if ((ifmam->ifmam_addrs & RTA_IFA) == 0)
+ break;
+
+ p = (char *)(ifmam + 1);
+ for (i = 0; i < RTAX_MAX; i++) {
+ if ((RTA_MASKS & ifmam->ifmam_addrs &
+ (1 << i)) == 0)
+ continue;
+ sa = (struct sockaddr *)(void *)p;
+ len = SA_RLEN(sa);
+ switch (i) {
+ case RTAX_GATEWAY:
+ ift->ifma_lladdr =
+ (struct sockaddr *)(void *)data;
+ memcpy(data, p, len);
+ data += len;
+ break;
+
+ case RTAX_IFP:
+ ift->ifma_name =
+ (struct sockaddr *)(void *)data;
+ memcpy(data, p, len);
+ data += len;
+ break;
+
+ case RTAX_IFA:
+ ift->ifma_addr =
+ (struct sockaddr *)(void *)data;
+ memcpy(data, p, len);
+ data += len;
+ break;
+
+ default:
+ data += len;
+ break;
+ }
+ p += len;
+ }
+ ift->ifma_next = ift + 1;
+ ift = ift->ifma_next;
+ break;
+ }
+ }
+
+ free(buf);
+
+ if (ift > ifa) {
+ ift--;
+ ift->ifma_next = NULL;
+ *pif = ifa;
+ } else {
+ *pif = NULL;
+ free(ifa);
+ }
+ return (0);
+}
+
+static inline void _intl_freeifmaddrs(struct _intl_ifmaddrs *ifmp)
+{
+ free(ifmp);
+}
+
+// --------------------------------------------------------------------------
+// --------------------------------------------------------------------------
+
+#include
+#include