This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
zhangyang-libzt/src/SDK_XcodeWrapper.cpp

76 lines
2.1 KiB
C++
Raw Normal View History

2016-07-05 14:47:14 -05:00
//
// SDK_XcodeWrapper.cpp
// SDK-iOS
2016-07-05 14:47:14 -05:00
//
// Created by Joseph Henry on 2/14/16.
// Copyright © 2016 ZeroTier. All rights reserved.
//
#include "SDK.h"
#include "SDK_XcodeWrapper.hpp"
#include "SDK_Signatures.h"
#include <sys/socket.h>
#define INTERCEPT_ENABLED 111
#define INTERCEPT_DISABLED 222
#include "SDK_ServiceSetup.hpp"
2016-07-05 15:52:23 -05:00
// Starts a ZeroTier service at the specified path
// This will only support SOCKS5 Proxy
2016-07-05 15:52:23 -05:00
extern "C" void start_service(const char * path) {
2016-07-05 14:47:14 -05:00
init_service(INTERCEPT_DISABLED, path);
}
// Starts a ZeroTier service at the specified path and initializes the RPC mechanism
// This will allow direct API calls
extern "C" void start_service_and_rpc(const char * path, const char * nwid) {
init_service_and_rpc(INTERCEPT_DISABLED, path, nwid);
}
2016-07-05 15:52:23 -05:00
// Joins a ZeroTier virtual network
2016-07-05 14:47:14 -05:00
extern "C" void zt_join_network(const char * nwid){
2016-07-05 15:52:23 -05:00
join_network(nwid);
2016-07-05 14:47:14 -05:00
}
2016-07-05 15:52:23 -05:00
// Leaves a ZeroTier virtual network
2016-07-05 14:47:14 -05:00
extern "C" void zt_leave_network(const char * nwid){
leave_network(nwid);
}
// Explicit ZT API wrappers
#if !defined(__IOS__)
// This isn't available for iOS since function interposition isn't as reliable
extern "C" void zts_init_rpc(const char *path, const char *nwid) {
zt_init_rpc(path, nwid);
}
#endif
2016-07-06 14:09:33 -05:00
extern "C" int zts_socket(SOCKET_SIG) {
2016-07-05 14:47:14 -05:00
return zt_socket(socket_family, socket_type, protocol);
}
extern "C" int zts_connect(CONNECT_SIG) {
return zt_connect(__fd, __addr, __len);
}
2016-07-06 14:09:33 -05:00
extern "C" int zts_bind(BIND_SIG){
2016-07-05 14:47:14 -05:00
return zt_bind(sockfd, addr, addrlen);
}
2016-07-06 14:09:33 -05:00
extern "C" int zts_accept(ACCEPT_SIG) {
2016-07-05 14:47:14 -05:00
return zt_accept(sockfd, addr, addrlen);
}
2016-07-06 14:09:33 -05:00
extern "C" int zts_listen(LISTEN_SIG) {
2016-07-05 14:47:14 -05:00
return zt_listen(sockfd, backlog);
}
2016-07-06 14:09:33 -05:00
extern "C" int zts_setsockopt(SETSOCKOPT_SIG) {
2016-07-05 14:47:14 -05:00
return zt_setsockopt(socket, level, option_name, option_value, option_len);
}
2016-07-06 14:09:33 -05:00
extern "C" int zts_getsockopt(GETSOCKOPT_SIG) {
2016-07-05 14:47:14 -05:00
return zt_getsockopt(sockfd, level, optname, optval, optlen);
}
2016-07-06 14:09:33 -05:00
extern "C" int zts_close(CLOSE_SIG) {
2016-07-05 14:47:14 -05:00
return zt_close(fd);
}
2016-07-06 14:09:33 -05:00
extern "C" int zts_getsockname(GETSOCKNAME_SIG) {
2016-07-05 14:47:14 -05:00
return zt_getsockname(sockfd, addr, addrlen);
}