diff --git a/integrations/Apple/ZeroTierSDK_Apple/ZeroTierSDK_Apple.xcodeproj/project.pbxproj b/integrations/Apple/ZeroTierSDK_Apple/ZeroTierSDK_Apple.xcodeproj/project.pbxproj index cae31ed..88777be 100644 --- a/integrations/Apple/ZeroTierSDK_Apple/ZeroTierSDK_Apple.xcodeproj/project.pbxproj +++ b/integrations/Apple/ZeroTierSDK_Apple/ZeroTierSDK_Apple.xcodeproj/project.pbxproj @@ -1382,8 +1382,18 @@ isa = XCBuildConfiguration; buildSettings = { COMBINE_HIDPI_IMAGES = YES; + HEADER_SEARCH_PATHS = ( + "$(SRCROOT)/../../../zerotierone", + "$(SRCROOT)/../../../ext/lwip/src/include/", + "$(SRCROOT)/../../../ext/lwip/src/include/ipv4/", + ); INFOPLIST_FILE = ZeroTierSDK_Unity3D_iOS/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; + OTHER_CFLAGS = ( + "-D__UNITY_3D__", + "-DZT_SDK", + "-DZT_SDK_DEBUG", + ); PRODUCT_BUNDLE_IDENTIFIER = "zerotier.ZeroTierSDK-Unity3D-iOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -1396,8 +1406,18 @@ isa = XCBuildConfiguration; buildSettings = { COMBINE_HIDPI_IMAGES = YES; + HEADER_SEARCH_PATHS = ( + "$(SRCROOT)/../../../zerotierone", + "$(SRCROOT)/../../../ext/lwip/src/include/", + "$(SRCROOT)/../../../ext/lwip/src/include/ipv4/", + ); INFOPLIST_FILE = ZeroTierSDK_Unity3D_iOS/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; + OTHER_CFLAGS = ( + "-D__UNITY_3D__", + "-DZT_SDK", + "-DZT_SDK_DEBUG", + ); PRODUCT_BUNDLE_IDENTIFIER = "zerotier.ZeroTierSDK-Unity3D-iOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -1586,6 +1606,7 @@ 7CC0031D1D1216B0003E68DC /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 7CC003281D1216E3003E68DC /* Build configuration list for PBXNativeTarget "ZeroTierSDK_iOS" */ = { isa = XCConfigurationList; @@ -1594,6 +1615,7 @@ 7CC0032A1D1216E3003E68DC /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 7CC003351D1216F8003E68DC /* Build configuration list for PBXNativeTarget "ZeroTierSDK_OSX" */ = { isa = XCConfigurationList; @@ -1602,6 +1624,7 @@ 7CC003371D1216F8003E68DC /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 7CC0033F1D121742003E68DC /* Build configuration list for PBXNativeTarget "ZeroTierSDK_Unity3D_OSX" */ = { isa = XCConfigurationList; @@ -1610,6 +1633,7 @@ 7CC003411D121742003E68DC /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/integrations/Apple/ZeroTierSDK_Apple/ZeroTierSDK_Apple.xcodeproj/project.xcworkspace/xcuserdata/Joseph.xcuserdatad/UserInterfaceState.xcuserstate b/integrations/Apple/ZeroTierSDK_Apple/ZeroTierSDK_Apple.xcodeproj/project.xcworkspace/xcuserdata/Joseph.xcuserdatad/UserInterfaceState.xcuserstate index fb5bbbd..0b12d04 100644 Binary files a/integrations/Apple/ZeroTierSDK_Apple/ZeroTierSDK_Apple.xcodeproj/project.xcworkspace/xcuserdata/Joseph.xcuserdatad/UserInterfaceState.xcuserstate and b/integrations/Apple/ZeroTierSDK_Apple/ZeroTierSDK_Apple.xcodeproj/project.xcworkspace/xcuserdata/Joseph.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/integrations/Unity3D/Assets/ZeroTier.cs b/integrations/Unity3D/Assets/ZeroTier.cs index c7c776b..3707a27 100644 --- a/integrations/Unity3D/Assets/ZeroTier.cs +++ b/integrations/Unity3D/Assets/ZeroTier.cs @@ -38,9 +38,32 @@ using System.Net; using System.IO; - public class ZeroTierNetworkInterface { + // Apple + #if UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX + const string DLL_PATH = "ZeroTierSDK_Unity3D_OSX"; + #endif + + #if UNITY_IOS || UNITY_IPHONE + const string DLL_PATH = "ZeroTierSDK_Unity3D_iOS"; + #endif + + // Windows + #if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN + const string DLL_PATH = "ZeroTierSDK_Unity3D_WIN"; + #endif + + // Linux + #if UNITY_STANDALONE_LINUX + const string DLL_PATH = "ZeroTierSDK_Unity3D_LINUX"; + #endif + + // Android + #if UNITY_ANDROID + const string DLL_PATH = "ZeroTierSDK_Unity3D_ANDROID"; + #endif + // ZeroTier background thread private Thread ztThread; @@ -66,44 +89,43 @@ public class ZeroTierNetworkInterface { } // ZeroTier service / debug initialization - [DllImport ("ZeroTierSDK_Unity3D_OSX")] + [DllImport (DLL_PATH)] public static extern void SetDebugFunction( IntPtr fp ); - [DllImport ("ZeroTierSDK_Unity3D_OSX")] + [DllImport (DLL_PATH)] private static extern int unity_start_service(string path); // Connection calls - [DllImport ("ZeroTierSDK_Unity3D_OSX")] + [DllImport (DLL_PATH)] private static extern int zt_socket(int family, int type, int protocol); - - [DllImport ("ZeroTierSDK_Unity3D_OSX")] + [DllImport (DLL_PATH)] unsafe private static extern int zt_bind(int sockfd, System.IntPtr addr, int addrlen); - [DllImport ("ZeroTierSDK_Unity3D_OSX")] + [DllImport (DLL_PATH)] unsafe private static extern int zt_connect(int sockfd, System.IntPtr addr, int addrlen); - [DllImport ("ZeroTierSDK_Unity3D_OSX")] + [DllImport (DLL_PATH)] private static extern int zt_accept(int sockfd); - [DllImport ("ZeroTierSDK_Unity3D_OSX")] + [DllImport (DLL_PATH)] private static extern int zt_listen(int sockfd, int backlog); - [DllImport ("ZeroTierSDK_Unity3D_OSX")] + [DllImport (DLL_PATH)] private static extern int zt_close(int sockfd); // RX / TX - [DllImport ("ZeroTierSDK_Unity3D_OSX")] + [DllImport (DLL_PATH)] unsafe private static extern int zt_recv(int sockfd, System.IntPtr buf, int len); - [DllImport ("ZeroTierSDK_Unity3D_OSX")] + [DllImport (DLL_PATH)] unsafe private static extern int zt_send(int sockfd, System.IntPtr buf, int len); // ZT Thread controls - [DllImport ("ZeroTierSDK_Unity3D_OSX")] + [DllImport (DLL_PATH)] private static extern bool zt_is_running(); - [DllImport ("ZeroTierSDK_Unity3D_OSX")] + [DllImport (DLL_PATH)] private static extern void zt_terminate(); // ZT Network controls - [DllImport ("ZeroTierSDK_Unity3D_OSX")] + [DllImport (DLL_PATH)] private static extern bool zt_join_network(string nwid); - [DllImport ("ZeroTierSDK_Unity3D_OSX")] + [DllImport (DLL_PATH)] private static extern void zt_leave_network(string nwid); // Thread which starts the ZeroTier service