Slight re-org of C API naming convention
This commit is contained in:
@@ -85,7 +85,7 @@ int main(int argc, char** argv)
|
||||
printf("Join %llx from another machine and ping6 me at %s\n", net_id, ipstr);
|
||||
|
||||
// Do network stuff!
|
||||
// zts_socket, zts_connect, etc
|
||||
// zts_bsd_socket, zts_bsd_connect, etc
|
||||
|
||||
while (1) {
|
||||
zts_util_delay(500); // Idle indefinitely
|
||||
|
||||
@@ -97,7 +97,7 @@ int main(int argc, char** argv)
|
||||
printf("Join %llx from another machine and ping me at %s\n", net_id, ipstr);
|
||||
|
||||
// Do network stuff!
|
||||
// zts_socket, zts_connect, etc
|
||||
// zts_bsd_socket, zts_bsd_connect, etc
|
||||
|
||||
while (1) {
|
||||
zts_util_delay(500); // Idle indefinitely
|
||||
|
||||
@@ -76,23 +76,23 @@ int main(int argc, char** argv)
|
||||
|
||||
// Connect to remote host
|
||||
|
||||
// Can also use traditional: zts_socket(), zts_connect(), etc
|
||||
// Can also use traditional: zts_bsd_socket(), zts_bsd_connect(), etc
|
||||
|
||||
printf("Attempting to connect...\n");
|
||||
while ((fd = zts_simple_tcp_client(remote_addr, remote_port)) < 0) {
|
||||
while ((fd = zts_tcp_client(remote_addr, remote_port)) < 0) {
|
||||
printf("Re-attempting to connect...\n");
|
||||
}
|
||||
|
||||
// Data I/O
|
||||
|
||||
printf("Sending message string to server...\n");
|
||||
if ((bytes = zts_write(fd, msgStr, strlen(msgStr))) < 0) {
|
||||
if ((bytes = zts_bsd_write(fd, msgStr, strlen(msgStr))) < 0) {
|
||||
printf("Error (fd=%d, ret=%d, zts_errno=%d). Exiting.\n", fd, bytes, zts_errno);
|
||||
exit(1);
|
||||
}
|
||||
printf("Sent %d bytes: %s\n", bytes, msgStr);
|
||||
printf("Reading message string from server...\n");
|
||||
if ((bytes = zts_read(fd, recvBuf, sizeof(recvBuf))) < 0) {
|
||||
if ((bytes = zts_bsd_read(fd, recvBuf, sizeof(recvBuf))) < 0) {
|
||||
printf("Error (fd=%d, ret=%d, zts_errno=%d). Exiting.\n", fd, bytes, zts_errno);
|
||||
exit(1);
|
||||
}
|
||||
@@ -101,6 +101,6 @@ int main(int argc, char** argv)
|
||||
// Close
|
||||
|
||||
printf("Closing sockets\n");
|
||||
zts_close(fd);
|
||||
zts_bsd_close(fd);
|
||||
return zts_node_stop();
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// Create socket
|
||||
|
||||
if ((fd = zts_socket(ZTS_AF_INET, ZTS_SOCK_STREAM, 0)) < 0) {
|
||||
if ((fd = zts_bsd_socket(ZTS_AF_INET, ZTS_SOCK_STREAM, 0)) < 0) {
|
||||
printf("Error (fd=%d, zts_errno=%d). Exiting.\n", fd, zts_errno);
|
||||
exit(1);
|
||||
}
|
||||
@@ -73,8 +73,8 @@ int main(int argc, char** argv)
|
||||
// Connect
|
||||
|
||||
// Can also use:
|
||||
// zts_connect(int fd, const struct zts_sockaddr* addr, zts_socklen_t addrlen);
|
||||
while (zts_simple_connect(fd, remote_addr, remote_port, 0) != ZTS_ERR_OK) {
|
||||
// zts_bsd_connect(int fd, const struct zts_sockaddr* addr, zts_socklen_t addrlen);
|
||||
while (zts_connect(fd, remote_addr, remote_port, 0) != ZTS_ERR_OK) {
|
||||
printf("Attempting to connect...\n");
|
||||
}
|
||||
|
||||
@@ -83,14 +83,14 @@ int main(int argc, char** argv)
|
||||
// Wait random intervals to send a message to the server
|
||||
// The non-blocking aspect of this example is server-side
|
||||
while (1) {
|
||||
if ((bytes = zts_send(fd, msgStr, strlen(msgStr), 0)) < 0) {
|
||||
if ((bytes = zts_bsd_send(fd, msgStr, strlen(msgStr), 0)) < 0) {
|
||||
printf("Error (fd=%d, ret=%d, zts_errno=%d). Exiting.\n", fd, bytes, zts_errno);
|
||||
exit(1);
|
||||
}
|
||||
printf("zts_send()=%d\n", bytes);
|
||||
printf("zts_bsd_send()=%d\n", bytes);
|
||||
zts_util_delay((rand() % 100) * 50);
|
||||
}
|
||||
|
||||
zts_close(fd);
|
||||
zts_bsd_close(fd);
|
||||
return zts_node_stop();
|
||||
}
|
||||
|
||||
@@ -69,20 +69,20 @@ int main(int argc, char** argv)
|
||||
// Sockets
|
||||
|
||||
printf("Creating socket...\n");
|
||||
if ((fd = zts_socket(ZTS_AF_INET, ZTS_SOCK_STREAM, 0)) < 0) {
|
||||
if ((fd = zts_bsd_socket(ZTS_AF_INET, ZTS_SOCK_STREAM, 0)) < 0) {
|
||||
printf("Error (fd=%d, ret=%d, zts_errno=%d). Exiting.\n", fd, err, zts_errno);
|
||||
exit(1);
|
||||
}
|
||||
printf("Binding...\n");
|
||||
// Can also use:
|
||||
// zts_bind(int fd, const struct zts_sockaddr* addr, zts_socklen_t addrlen)
|
||||
if ((err = zts_simple_bind(fd, local_addr, local_port) < 0)) {
|
||||
// zts_bsd_bind(int fd, const struct zts_sockaddr* addr, zts_socklen_t addrlen)
|
||||
if ((err = zts_bind(fd, local_addr, local_port) < 0)) {
|
||||
printf("Error (fd=%d, ret=%d, zts_errno=%d). Exiting.\n", fd, err, zts_errno);
|
||||
exit(1);
|
||||
}
|
||||
printf("Listening...\n");
|
||||
int backlog = 100;
|
||||
if ((err = zts_listen(fd, backlog)) < 0) {
|
||||
if ((err = zts_bsd_listen(fd, backlog)) < 0) {
|
||||
printf("Error (fd=%d, ret=%d, zts_errno=%d). Exiting.\n", fd, err, zts_errno);
|
||||
exit(1);
|
||||
}
|
||||
@@ -93,12 +93,12 @@ int main(int argc, char** argv)
|
||||
while (1) {
|
||||
// Accept
|
||||
// Can also use
|
||||
// zts_accept(int fd, struct zts_sockaddr* addr, zts_socklen_t* addrlen)
|
||||
// zts_bsd_accept(int fd, struct zts_sockaddr* addr, zts_socklen_t* addrlen)
|
||||
|
||||
char ipstr[ZTS_INET6_ADDRSTRLEN] = { 0 };
|
||||
unsigned int port = 0;
|
||||
printf("Accepting on listening socket...\n");
|
||||
if ((accfd = zts_simple_accept(fd, ipstr, ZTS_INET6_ADDRSTRLEN, &port)) < 0) {
|
||||
if ((accfd = zts_accept(fd, ipstr, ZTS_INET6_ADDRSTRLEN, &port)) < 0) {
|
||||
printf("Error (fd=%d, ret=%d, zts_errno=%d). Exiting.\n", fd, err, zts_errno);
|
||||
}
|
||||
printf("Accepted connection from %s:%d\n", ipstr, port);
|
||||
@@ -108,16 +108,16 @@ int main(int argc, char** argv)
|
||||
|
||||
// Technique 1: ZTS_O_NONBLOCK
|
||||
if (0) {
|
||||
zts_fcntl(fd, ZTS_F_SETFL, ZTS_O_NONBLOCK);
|
||||
zts_fcntl(accfd, ZTS_F_SETFL, ZTS_O_NONBLOCK);
|
||||
zts_bsd_fcntl(fd, ZTS_F_SETFL, ZTS_O_NONBLOCK);
|
||||
zts_bsd_fcntl(accfd, ZTS_F_SETFL, ZTS_O_NONBLOCK);
|
||||
while (1) {
|
||||
bytes = zts_recv(accfd, recvBuf, sizeof(recvBuf), 0);
|
||||
printf("zts_recv(%d, ...)=%d\n", accfd, bytes);
|
||||
bytes = zts_bsd_recv(accfd, recvBuf, sizeof(recvBuf), 0);
|
||||
printf("zts_bsd_recv(%d, ...)=%d\n", accfd, bytes);
|
||||
zts_util_delay(100);
|
||||
}
|
||||
}
|
||||
|
||||
// Technique 2: zts_select
|
||||
// Technique 2: zts_bsd_select
|
||||
if (0) {
|
||||
struct zts_timeval tv;
|
||||
tv.tv_sec = 0;
|
||||
@@ -128,21 +128,21 @@ int main(int argc, char** argv)
|
||||
ZTS_FD_SET(accfd, &active_fd_set);
|
||||
while (1) {
|
||||
read_fd_set = active_fd_set;
|
||||
if ((result = zts_select(ZTS_FD_SETSIZE, &read_fd_set, NULL, NULL, &tv) < 0)) {
|
||||
if ((result = zts_bsd_select(ZTS_FD_SETSIZE, &read_fd_set, NULL, NULL, &tv) < 0)) {
|
||||
// perror ("select");
|
||||
exit(1);
|
||||
}
|
||||
for (int i = 0; i < ZTS_FD_SETSIZE; i++) {
|
||||
if (ZTS_FD_ISSET(i, &read_fd_set)) {
|
||||
bytes = zts_recv(accfd, recvBuf, sizeof(recvBuf), 0);
|
||||
printf("zts_recv(%d, ...)=%d\n", i, bytes);
|
||||
bytes = zts_bsd_recv(accfd, recvBuf, sizeof(recvBuf), 0);
|
||||
printf("zts_bsd_recv(%d, ...)=%d\n", i, bytes);
|
||||
}
|
||||
// ZTS_FD_CLR(i, &active_fd_set);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Technique 3: zts_poll
|
||||
// Technique 3: zts_bsd_poll
|
||||
if (1) {
|
||||
int numfds = 0;
|
||||
struct zts_pollfd poll_set[16];
|
||||
@@ -153,17 +153,17 @@ int main(int argc, char** argv)
|
||||
int result = 0;
|
||||
int timeout_ms = 50;
|
||||
while (1) {
|
||||
result = zts_poll(poll_set, numfds, timeout_ms);
|
||||
printf("zts_poll()=%d\n", result);
|
||||
result = zts_bsd_poll(poll_set, numfds, timeout_ms);
|
||||
printf("zts_bsd_poll()=%d\n", result);
|
||||
for (int i = 0; i < numfds; i++) {
|
||||
if (poll_set[i].revents & ZTS_POLLIN) {
|
||||
bytes = zts_recv(poll_set[i].fd, recvBuf, sizeof(recvBuf), 0);
|
||||
printf("zts_recv(%d, ...)=%d\n", i, bytes);
|
||||
bytes = zts_bsd_recv(poll_set[i].fd, recvBuf, sizeof(recvBuf), 0);
|
||||
printf("zts_bsd_recv(%d, ...)=%d\n", i, bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = zts_close(fd);
|
||||
err = zts_bsd_close(fd);
|
||||
return zts_node_stop();
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
// Do network stuff!
|
||||
// zts_socket, zts_connect, etc
|
||||
// zts_bsd_socket, zts_bsd_connect, etc
|
||||
|
||||
printf("Node %llx is now online. Idling.\n", zts_node_get_id());
|
||||
while (1) {
|
||||
|
||||
@@ -56,7 +56,7 @@ int main(int argc, char** argv)
|
||||
printf("Join %llx from another machine and ping me at %s\n", net_id, ipstr);
|
||||
|
||||
// Do network stuff!
|
||||
// zts_socket, zts_connect, etc
|
||||
// zts_bsd_socket, zts_bsd_connect, etc
|
||||
|
||||
while (1) {
|
||||
zts_util_delay(500); // Idle indefinitely
|
||||
|
||||
@@ -72,12 +72,12 @@ int main(int argc, char** argv)
|
||||
|
||||
// Accept incoming connection
|
||||
|
||||
// Can also use traditional: zts_socket(), zts_bind(), zts_listen(), zts_accept(), etc.
|
||||
// Can also use traditional: zts_bsd_socket(), zts_bsd_bind(), zts_bsd_listen(), zts_bsd_accept(), etc.
|
||||
|
||||
char remote_addr[ZTS_INET6_ADDRSTRLEN] = { 0 };
|
||||
int remote_port = 0;
|
||||
int len = ZTS_INET6_ADDRSTRLEN;
|
||||
if ((accfd = zts_simple_tcp_server(local_addr, local_port, remote_addr, len, &remote_port)) < 0) {
|
||||
if ((accfd = zts_tcp_server(local_addr, local_port, remote_addr, len, &remote_port)) < 0) {
|
||||
printf("Error (fd=%d, zts_errno=%d). Exiting.\n", accfd, zts_errno);
|
||||
exit(1);
|
||||
}
|
||||
@@ -89,13 +89,13 @@ int main(int argc, char** argv)
|
||||
char recvBuf[128] = { 0 };
|
||||
|
||||
printf("Reading message string from client...\n");
|
||||
if ((bytes = zts_read(accfd, recvBuf, sizeof(recvBuf))) < 0) {
|
||||
if ((bytes = zts_bsd_read(accfd, recvBuf, sizeof(recvBuf))) < 0) {
|
||||
printf("Error (fd=%d, ret=%d, zts_errno=%d). Exiting.\n", fd, bytes, zts_errno);
|
||||
exit(1);
|
||||
}
|
||||
printf("Read %d bytes: %s\n", bytes, recvBuf);
|
||||
printf("Sending message string to client...\n");
|
||||
if ((bytes = zts_write(accfd, recvBuf, bytes)) < 0) {
|
||||
if ((bytes = zts_bsd_write(accfd, recvBuf, bytes)) < 0) {
|
||||
printf("Error (fd=%d, ret=%d, zts_errno=%d). Exiting.\n", fd, bytes, zts_errno);
|
||||
exit(1);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ int main(int argc, char** argv)
|
||||
// Close
|
||||
|
||||
printf("Closing sockets\n");
|
||||
err = zts_close(accfd);
|
||||
err = zts_close(fd);
|
||||
err = zts_bsd_close(accfd);
|
||||
err = zts_bsd_close(fd);
|
||||
return zts_node_stop();
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ int main(int argc, char** argv)
|
||||
printf("Join %llx from another machine and ping me at %s\n", net_id, ipstr);
|
||||
|
||||
// Do network stuff!
|
||||
// zts_socket, zts_connect, etc
|
||||
// zts_bsd_socket, zts_bsd_connect, etc
|
||||
|
||||
// Show protocol statistics
|
||||
|
||||
|
||||
@@ -1834,7 +1834,7 @@ ZTS_API int ZTCALL zts_stats_get_all(zts_stats_counter_t* dst);
|
||||
* @return Numbered file descriptor on success, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_socket(int family, int type, int protocol);
|
||||
ZTS_API int ZTCALL zts_bsd_socket(int family, int type, int protocol);
|
||||
|
||||
/**
|
||||
* @brief Connect a socket to a remote host
|
||||
@@ -1845,7 +1845,7 @@ ZTS_API int ZTCALL zts_socket(int family, int type, int protocol);
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_connect(int fd, const struct zts_sockaddr* addr, zts_socklen_t addrlen);
|
||||
ZTS_API int ZTCALL zts_bsd_connect(int fd, const struct zts_sockaddr* addr, zts_socklen_t addrlen);
|
||||
|
||||
/**
|
||||
* @brief Bind a socket to a local address
|
||||
@@ -1856,7 +1856,7 @@ ZTS_API int ZTCALL zts_connect(int fd, const struct zts_sockaddr* addr, zts_sock
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_bind(int fd, const struct zts_sockaddr* addr, zts_socklen_t addrlen);
|
||||
ZTS_API int ZTCALL zts_bsd_bind(int fd, const struct zts_sockaddr* addr, zts_socklen_t addrlen);
|
||||
|
||||
/**
|
||||
* @brief Listen for incoming connections on socket
|
||||
@@ -1866,7 +1866,7 @@ ZTS_API int ZTCALL zts_bind(int fd, const struct zts_sockaddr* addr, zts_socklen
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_listen(int fd, int backlog);
|
||||
ZTS_API int ZTCALL zts_bsd_listen(int fd, int backlog);
|
||||
|
||||
/**
|
||||
* @brief Accept an incoming connection
|
||||
@@ -1877,7 +1877,7 @@ ZTS_API int ZTCALL zts_listen(int fd, int backlog);
|
||||
* @return New file descriptor if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_accept(int fd, struct zts_sockaddr* addr, zts_socklen_t* addrlen);
|
||||
ZTS_API int ZTCALL zts_bsd_accept(int fd, struct zts_sockaddr* addr, zts_socklen_t* addrlen);
|
||||
|
||||
// Socket level option number
|
||||
#define ZTS_SOL_SOCKET 0x0fff
|
||||
@@ -2017,7 +2017,7 @@ typedef struct zts_ipv6_mreq {
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_setsockopt(int fd, int level, int optname, const void* optval, zts_socklen_t optlen);
|
||||
ZTS_API int ZTCALL zts_bsd_setsockopt(int fd, int level, int optname, const void* optval, zts_socklen_t optlen);
|
||||
|
||||
/**
|
||||
* @brief Get socket options.
|
||||
@@ -2030,7 +2030,7 @@ ZTS_API int ZTCALL zts_setsockopt(int fd, int level, int optname, const void* op
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_getsockopt(int fd, int level, int optname, void* optval, zts_socklen_t* optlen);
|
||||
ZTS_API int ZTCALL zts_bsd_getsockopt(int fd, int level, int optname, void* optval, zts_socklen_t* optlen);
|
||||
|
||||
/**
|
||||
* @brief Get the name (address) of the local end of the socket
|
||||
@@ -2041,7 +2041,7 @@ ZTS_API int ZTCALL zts_getsockopt(int fd, int level, int optname, void* optval,
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_getsockname(int fd, struct zts_sockaddr* addr, zts_socklen_t* addrlen);
|
||||
ZTS_API int ZTCALL zts_bsd_getsockname(int fd, struct zts_sockaddr* addr, zts_socklen_t* addrlen);
|
||||
|
||||
/**
|
||||
* @brief Get the name (address) of the remote end of the socket
|
||||
@@ -2052,7 +2052,7 @@ ZTS_API int ZTCALL zts_getsockname(int fd, struct zts_sockaddr* addr, zts_sockle
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_getpeername(int fd, struct zts_sockaddr* addr, zts_socklen_t* addrlen);
|
||||
ZTS_API int ZTCALL zts_bsd_getpeername(int fd, struct zts_sockaddr* addr, zts_socklen_t* addrlen);
|
||||
|
||||
/**
|
||||
* @brief Close socket.
|
||||
@@ -2061,7 +2061,7 @@ ZTS_API int ZTCALL zts_getpeername(int fd, struct zts_sockaddr* addr, zts_sockle
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_close(int fd);
|
||||
ZTS_API int ZTCALL zts_bsd_close(int fd);
|
||||
|
||||
/* FD_SET used for lwip_select */
|
||||
|
||||
@@ -2117,7 +2117,7 @@ typedef struct zts_timeval {
|
||||
* `ZTS_ERR_SERVICE` on failure. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL
|
||||
zts_select(int nfds, zts_fd_set* readfds, zts_fd_set* writefds, zts_fd_set* exceptfds, struct zts_timeval* timeout);
|
||||
zts_bsd_select(int nfds, zts_fd_set* readfds, zts_fd_set* writefds, zts_fd_set* exceptfds, struct zts_timeval* timeout);
|
||||
|
||||
// fnctl() commands
|
||||
#define ZTS_F_GETFL 0x0003
|
||||
@@ -2138,7 +2138,7 @@ zts_select(int nfds, zts_fd_set* readfds, zts_fd_set* writefds, zts_fd_set* exce
|
||||
* @param flags Flags
|
||||
* @return
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_fcntl(int fd, int cmd, int flags);
|
||||
ZTS_API int ZTCALL zts_bsd_fcntl(int fd, int cmd, int flags);
|
||||
|
||||
#define ZTS_POLLIN 0x001
|
||||
#define ZTS_POLLOUT 0x002
|
||||
@@ -2170,7 +2170,7 @@ struct zts_pollfd {
|
||||
* the node experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets
|
||||
* `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_poll(struct zts_pollfd* fds, zts_nfds_t nfds, int timeout);
|
||||
ZTS_API int ZTCALL zts_bsd_poll(struct zts_pollfd* fds, zts_nfds_t nfds, int timeout);
|
||||
|
||||
/**
|
||||
* @brief Control a device
|
||||
@@ -2181,7 +2181,7 @@ ZTS_API int ZTCALL zts_poll(struct zts_pollfd* fds, zts_nfds_t nfds, int timeout
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_ioctl(int fd, unsigned long request, void* argp);
|
||||
ZTS_API int ZTCALL zts_bsd_ioctl(int fd, unsigned long request, void* argp);
|
||||
|
||||
/**
|
||||
* @brief Send data to remote host
|
||||
@@ -2193,7 +2193,7 @@ ZTS_API int ZTCALL zts_ioctl(int fd, unsigned long request, void* argp);
|
||||
* @return Number of bytes sent if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API ssize_t ZTCALL zts_send(int fd, const void* buf, size_t len, int flags);
|
||||
ZTS_API ssize_t ZTCALL zts_bsd_send(int fd, const void* buf, size_t len, int flags);
|
||||
|
||||
/**
|
||||
* @brief Send data to remote host
|
||||
@@ -2208,7 +2208,7 @@ ZTS_API ssize_t ZTCALL zts_send(int fd, const void* buf, size_t len, int flags);
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API ssize_t ZTCALL
|
||||
zts_sendto(int fd, const void* buf, size_t len, int flags, const struct zts_sockaddr* addr, zts_socklen_t addrlen);
|
||||
zts_bsd_sendto(int fd, const void* buf, size_t len, int flags, const struct zts_sockaddr* addr, zts_socklen_t addrlen);
|
||||
|
||||
struct zts_iovec {
|
||||
void* iov_base;
|
||||
@@ -2239,7 +2239,7 @@ struct zts_msghdr {
|
||||
* @return Number of bytes sent if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API ssize_t ZTCALL zts_sendmsg(int fd, const struct zts_msghdr* msg, int flags);
|
||||
ZTS_API ssize_t ZTCALL zts_bsd_sendmsg(int fd, const struct zts_msghdr* msg, int flags);
|
||||
|
||||
/**
|
||||
* @brief Receive data from remote host
|
||||
@@ -2251,7 +2251,7 @@ ZTS_API ssize_t ZTCALL zts_sendmsg(int fd, const struct zts_msghdr* msg, int fla
|
||||
* @return Number of bytes received if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API ssize_t ZTCALL zts_recv(int fd, void* buf, size_t len, int flags);
|
||||
ZTS_API ssize_t ZTCALL zts_bsd_recv(int fd, void* buf, size_t len, int flags);
|
||||
|
||||
/**
|
||||
* @brief Receive data from remote host
|
||||
@@ -2266,7 +2266,7 @@ ZTS_API ssize_t ZTCALL zts_recv(int fd, void* buf, size_t len, int flags);
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API ssize_t ZTCALL
|
||||
zts_recvfrom(int fd, void* buf, size_t len, int flags, struct zts_sockaddr* addr, zts_socklen_t* addrlen);
|
||||
zts_bsd_recvfrom(int fd, void* buf, size_t len, int flags, struct zts_sockaddr* addr, zts_socklen_t* addrlen);
|
||||
|
||||
/**
|
||||
* @brief Receive a message from remote host
|
||||
@@ -2277,7 +2277,7 @@ zts_recvfrom(int fd, void* buf, size_t len, int flags, struct zts_sockaddr* addr
|
||||
* @return Number of bytes received if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API ssize_t ZTCALL zts_recvmsg(int fd, struct zts_msghdr* msg, int flags);
|
||||
ZTS_API ssize_t ZTCALL zts_bsd_recvmsg(int fd, struct zts_msghdr* msg, int flags);
|
||||
|
||||
/**
|
||||
* @brief Read data from socket onto buffer
|
||||
@@ -2288,7 +2288,7 @@ ZTS_API ssize_t ZTCALL zts_recvmsg(int fd, struct zts_msghdr* msg, int flags);
|
||||
* @return Number of bytes read if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API ssize_t ZTCALL zts_read(int fd, void* buf, size_t len);
|
||||
ZTS_API ssize_t ZTCALL zts_bsd_read(int fd, void* buf, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Read data from socket into multiple buffers
|
||||
@@ -2299,7 +2299,7 @@ ZTS_API ssize_t ZTCALL zts_read(int fd, void* buf, size_t len);
|
||||
* @return Number of bytes read if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API ssize_t ZTCALL zts_readv(int fd, const struct zts_iovec* iov, int iovcnt);
|
||||
ZTS_API ssize_t ZTCALL zts_bsd_readv(int fd, const struct zts_iovec* iov, int iovcnt);
|
||||
|
||||
/**
|
||||
* @brief Write data from buffer to socket
|
||||
@@ -2310,7 +2310,7 @@ ZTS_API ssize_t ZTCALL zts_readv(int fd, const struct zts_iovec* iov, int iovcnt
|
||||
* @return Number of bytes written if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API ssize_t ZTCALL zts_write(int fd, const void* buf, size_t len);
|
||||
ZTS_API ssize_t ZTCALL zts_bsd_write(int fd, const void* buf, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Write data from multiple buffers to socket.
|
||||
@@ -2321,7 +2321,7 @@ ZTS_API ssize_t ZTCALL zts_write(int fd, const void* buf, size_t len);
|
||||
* @return Number of bytes written if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API ssize_t ZTCALL zts_writev(int fd, const struct zts_iovec* iov, int iovcnt);
|
||||
ZTS_API ssize_t ZTCALL zts_bsd_writev(int fd, const struct zts_iovec* iov, int iovcnt);
|
||||
|
||||
#define ZTS_SHUT_RD 0x0
|
||||
#define ZTS_SHUT_WR 0x1
|
||||
@@ -2336,20 +2336,31 @@ ZTS_API ssize_t ZTCALL zts_writev(int fd, const struct zts_iovec* iov, int iovcn
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_shutdown(int fd, int how);
|
||||
ZTS_API int ZTCALL zts_bsd_shutdown(int fd, int how);
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
// Convenience functions //
|
||||
// Simplified socket API //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
/**
|
||||
* Helper functions that simplify API wrapper generation and usage in other
|
||||
* non-C-like languages. Use simple integer types instead of bit flags,
|
||||
* limit the number of operations each function performs, prevent the user
|
||||
* from needing to manipulate the contents of structures in a non-native
|
||||
* language.
|
||||
* A subset (and) extension of the traditional BSD-style socket API that simplifies
|
||||
* API wrapper generation and usage in other non-C-like languages. Uses simple
|
||||
* integer types instead of bit flags, limit the number of operations each function
|
||||
* performs, prevent the user from needing to manipulate the contents of structures
|
||||
* in a non-native language.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Create a socket
|
||||
*
|
||||
* @param family `ZTS_AF_INET` or `ZTS_AF_INET6`
|
||||
* @param type `ZTS_SOCK_STREAM` or `ZTS_SOCK_DGRAM`
|
||||
* @param protocol Protocols supported on this socket
|
||||
* @return Numbered file descriptor on success, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_socket(int family, int type, int protocol);
|
||||
|
||||
/**
|
||||
* @brief Connect a socket to a remote host
|
||||
*
|
||||
@@ -2357,9 +2368,9 @@ ZTS_API int ZTCALL zts_shutdown(int fd, int how);
|
||||
* links. This means that links between peers do not exist until peers try to
|
||||
* talk to each other. This can be a problem during connection procedures since
|
||||
* some of the initial packets are lost. To alleviate the need to try
|
||||
* `zts_connect` many times, this function will keep re-trying for you, even if
|
||||
* `zts_bsd_connect` many times, this function will keep re-trying for you, even if
|
||||
* no known routes exist. However, if the socket is set to `non-blocking` mode
|
||||
* it will behave identically to `zts_connect` and return immediately upon
|
||||
* it will behave identically to `zts_bsd_connect` and return immediately upon
|
||||
* failure.
|
||||
*
|
||||
* @param fd Socket file descriptor
|
||||
@@ -2373,7 +2384,7 @@ ZTS_API int ZTCALL zts_shutdown(int fd, int how);
|
||||
* out with no connection made, `ZTS_ERR_SERVICE` if the node experiences a
|
||||
* problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_connect(int fd, const char* ipstr, unsigned short port, int timeout_ms);
|
||||
ZTS_API int ZTCALL zts_connect(int fd, const char* ipstr, unsigned short port, int timeout_ms);
|
||||
|
||||
/**
|
||||
* @brief Bind a socket to a local address
|
||||
@@ -2384,7 +2395,17 @@ ZTS_API int ZTCALL zts_simple_connect(int fd, const char* ipstr, unsigned short
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_bind(int fd, const char* ipstr, unsigned short port);
|
||||
ZTS_API int ZTCALL zts_bind(int fd, const char* ipstr, unsigned short port);
|
||||
|
||||
/**
|
||||
* @brief Listen for incoming connections on socket
|
||||
*
|
||||
* @param fd Socket file descriptor
|
||||
* @param backlog Number of backlogged connections allowed
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_listen(int fd, int backlog);
|
||||
|
||||
/**
|
||||
* @brief Accept an incoming connection
|
||||
@@ -2397,7 +2418,89 @@ ZTS_API int ZTCALL zts_simple_bind(int fd, const char* ipstr, unsigned short por
|
||||
* @return New file descriptor if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_accept(int fd, char* remote_addr, int len, unsigned short* port);
|
||||
ZTS_API int ZTCALL zts_accept(int fd, char* remote_addr, int len, unsigned short* port);
|
||||
|
||||
/**
|
||||
* @brief Send data to remote host
|
||||
*
|
||||
* @param fd Socket file descriptor
|
||||
* @param buf Pointer to data buffer
|
||||
* @param len Length of data to write
|
||||
* @param flags (e.g. `ZTS_MSG_DONTWAIT`, `ZTS_MSG_MORE`)
|
||||
* @return Number of bytes sent if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API ssize_t ZTCALL zts_send(int fd, const void* buf, size_t len, int flags);
|
||||
|
||||
/**
|
||||
* @brief Receive data from remote host
|
||||
*
|
||||
* @param fd Socket file descriptor
|
||||
* @param buf Pointer to data buffer
|
||||
* @param len Length of data buffer
|
||||
* @param flags Specifies the type of message receipt
|
||||
* @return Number of bytes received if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API ssize_t ZTCALL zts_recv(int fd, void* buf, size_t len, int flags);
|
||||
|
||||
/**
|
||||
* @brief Read data from socket onto buffer
|
||||
*
|
||||
* @param fd Socket file descriptor
|
||||
* @param buf Pointer to data buffer
|
||||
* @param len Length of data buffer to receive data
|
||||
* @return Number of bytes read if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API ssize_t ZTCALL zts_read(int fd, void* buf, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Write data from buffer to socket
|
||||
*
|
||||
* @param fd Socket file descriptor
|
||||
* @param buf Pointer to data buffer
|
||||
* @param len Length of buffer to write
|
||||
* @return Number of bytes written if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API ssize_t ZTCALL zts_write(int fd, const void* buf, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Shut down `read` aspect of a socket
|
||||
*
|
||||
* @param fd Socket file descriptor
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_shutdown_rd(int fd);
|
||||
|
||||
/**
|
||||
* @brief Shut down `write` aspect of a socket
|
||||
*
|
||||
* @param fd Socket file descriptor
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_shutdown_wr(int fd);
|
||||
|
||||
/**
|
||||
* @brief Shut down both `read` and `write` aspect of a socket
|
||||
*
|
||||
* @param fd Socket file descriptor
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_shutdown_rdwr(int fd);
|
||||
|
||||
/**
|
||||
* @brief Close socket.
|
||||
*
|
||||
* @param fd Socket file descriptor
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_close(int fd);
|
||||
|
||||
/**
|
||||
* @brief Get the name (address) of the remote end of the socket
|
||||
@@ -2408,7 +2511,7 @@ ZTS_API int ZTCALL zts_simple_accept(int fd, char* remote_addr, int len, unsigne
|
||||
* @param port Value-result parameter that will contain resultant port number
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_getpeername(int fd, char* remote_addr_str, int len, unsigned short* port);
|
||||
ZTS_API int ZTCALL zts_getpeername(int fd, char* remote_addr_str, int len, unsigned short* port);
|
||||
|
||||
/**
|
||||
* @brief Get the name (address) of the local end of the socket
|
||||
@@ -2419,7 +2522,7 @@ ZTS_API int ZTCALL zts_simple_getpeername(int fd, char* remote_addr_str, int len
|
||||
* @param port Value-result parameter that will contain resultant port number
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_getsockname(int fd, char* local_addr_str, int len, unsigned short* port);
|
||||
ZTS_API int ZTCALL zts_getsockname(int fd, char* local_addr_str, int len, unsigned short* port);
|
||||
|
||||
/**
|
||||
* @brief A convenience function that takes a remote address IP string and creates
|
||||
@@ -2431,7 +2534,7 @@ ZTS_API int ZTCALL zts_simple_getsockname(int fd, char* local_addr_str, int len,
|
||||
* @return New file descriptor if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_tcp_client(const char* remote_ipstr, unsigned short remote_port);
|
||||
ZTS_API int ZTCALL zts_tcp_client(const char* remote_ipstr, unsigned short remote_port);
|
||||
|
||||
/**
|
||||
* @brief A convenience function that takes a remote address IP string and creates
|
||||
@@ -2446,7 +2549,7 @@ ZTS_API int ZTCALL zts_simple_tcp_client(const char* remote_ipstr, unsigned shor
|
||||
* @return New file descriptor if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_tcp_server(
|
||||
ZTS_API int ZTCALL zts_tcp_server(
|
||||
const char* local_ipstr,
|
||||
unsigned short local_port,
|
||||
char* remote_ipstr,
|
||||
@@ -2463,11 +2566,11 @@ ZTS_API int ZTCALL zts_simple_tcp_server(
|
||||
* @return New file descriptor if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_udp_server(const char* local_ipstr, unsigned short local_port);
|
||||
ZTS_API int ZTCALL zts_udp_server(const char* local_ipstr, unsigned short local_port);
|
||||
|
||||
/**
|
||||
* @brief This function doesn't really do anything other than be a namespace
|
||||
* counterpart to `zts_simple_udp_server`. All this function does is create a
|
||||
* counterpart to `zts_udp_server`. All this function does is create a
|
||||
* `ZTS_SOCK_DGRAM` socket and return its file descriptor.
|
||||
*
|
||||
* @param remote_ipstr Remote address string. IPv4 or IPv6
|
||||
@@ -2475,7 +2578,7 @@ ZTS_API int ZTCALL zts_simple_udp_server(const char* local_ipstr, unsigned short
|
||||
* @return New file descriptor if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_udp_client(const char* remote_ipstr);
|
||||
ZTS_API int ZTCALL zts_udp_client(const char* remote_ipstr);
|
||||
|
||||
/**
|
||||
* @brief Enable or disable `TCP_NODELAY`. Enabling this is equivalent to
|
||||
@@ -2486,7 +2589,7 @@ ZTS_API int ZTCALL zts_simple_udp_client(const char* remote_ipstr);
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_set_no_delay(int fd, int enabled);
|
||||
ZTS_API int ZTCALL zts_set_no_delay(int fd, int enabled);
|
||||
|
||||
/**
|
||||
* @brief Return whether `TCP_NODELAY` is enabled
|
||||
@@ -2495,7 +2598,7 @@ ZTS_API int ZTCALL zts_simple_set_no_delay(int fd, int enabled);
|
||||
* @return `1` if enabled, `0` if disabled, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_get_no_delay(int fd);
|
||||
ZTS_API int ZTCALL zts_get_no_delay(int fd);
|
||||
|
||||
/**
|
||||
* @brief Enable or disable `SO_LINGER` while also setting its value
|
||||
@@ -2506,7 +2609,7 @@ ZTS_API int ZTCALL zts_simple_get_no_delay(int fd);
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_set_linger(int fd, int enabled, int value);
|
||||
ZTS_API int ZTCALL zts_set_linger(int fd, int enabled, int value);
|
||||
|
||||
/**
|
||||
* @brief Return whether `SO_LINGER` is enabled
|
||||
@@ -2515,7 +2618,7 @@ ZTS_API int ZTCALL zts_simple_set_linger(int fd, int enabled, int value);
|
||||
* @return `1` if enabled, `0` if disabled, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_get_linger_enabled(int fd);
|
||||
ZTS_API int ZTCALL zts_get_linger_enabled(int fd);
|
||||
|
||||
/**
|
||||
* @brief Return the value of `SO_LINGER`
|
||||
@@ -2524,7 +2627,7 @@ ZTS_API int ZTCALL zts_simple_get_linger_enabled(int fd);
|
||||
* @return Value of `SO_LINGER` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_get_linger_value(int fd);
|
||||
ZTS_API int ZTCALL zts_get_linger_value(int fd);
|
||||
|
||||
/**
|
||||
* @brief Return the number of bytes available to read from the network buffer
|
||||
@@ -2533,7 +2636,7 @@ ZTS_API int ZTCALL zts_simple_get_linger_value(int fd);
|
||||
* @return Number of bytes to read if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_get_pending_data_size(int fd);
|
||||
ZTS_API int ZTCALL zts_get_pending_data_size(int fd);
|
||||
|
||||
/**
|
||||
* @brief Enable or disable `SO_REUSEADDR`
|
||||
@@ -2543,7 +2646,7 @@ ZTS_API int ZTCALL zts_simple_get_pending_data_size(int fd);
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_set_reuse_addr(int fd, int enabled);
|
||||
ZTS_API int ZTCALL zts_set_reuse_addr(int fd, int enabled);
|
||||
|
||||
/**
|
||||
* @brief Return whether `SO_REUSEADDR` is enabled
|
||||
@@ -2552,7 +2655,7 @@ ZTS_API int ZTCALL zts_simple_set_reuse_addr(int fd, int enabled);
|
||||
* @return `1` if enabled, `0` if disabled, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_get_reuse_addr(int fd);
|
||||
ZTS_API int ZTCALL zts_get_reuse_addr(int fd);
|
||||
|
||||
/**
|
||||
* @brief Set the value of `SO_RCVTIMEO`
|
||||
@@ -2563,7 +2666,7 @@ ZTS_API int ZTCALL zts_simple_get_reuse_addr(int fd);
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_set_recv_timeout(int fd, int seconds, int microseconds);
|
||||
ZTS_API int ZTCALL zts_set_recv_timeout(int fd, int seconds, int microseconds);
|
||||
|
||||
/**
|
||||
* @brief Return the value of `SO_RCVTIMEO`
|
||||
@@ -2572,7 +2675,7 @@ ZTS_API int ZTCALL zts_simple_set_recv_timeout(int fd, int seconds, int microsec
|
||||
* @return Value of `SO_RCVTIMEO` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_get_recv_timeout(int fd);
|
||||
ZTS_API int ZTCALL zts_get_recv_timeout(int fd);
|
||||
|
||||
/**
|
||||
* @brief Set the value of `SO_SNDTIMEO`
|
||||
@@ -2583,7 +2686,7 @@ ZTS_API int ZTCALL zts_simple_get_recv_timeout(int fd);
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_set_send_timeout(int fd, int seconds, int microseconds);
|
||||
ZTS_API int ZTCALL zts_set_send_timeout(int fd, int seconds, int microseconds);
|
||||
|
||||
/**
|
||||
* @brief Return the value of `SO_SNDTIMEO`
|
||||
@@ -2592,7 +2695,7 @@ ZTS_API int ZTCALL zts_simple_set_send_timeout(int fd, int seconds, int microsec
|
||||
* @return Value of `SO_SNDTIMEO` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_get_send_timeout(int fd);
|
||||
ZTS_API int ZTCALL zts_get_send_timeout(int fd);
|
||||
|
||||
/**
|
||||
* @brief Set the value of `SO_SNDBUF`
|
||||
@@ -2602,7 +2705,7 @@ ZTS_API int ZTCALL zts_simple_get_send_timeout(int fd);
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_set_send_buf_size(int fd, int size);
|
||||
ZTS_API int ZTCALL zts_set_send_buf_size(int fd, int size);
|
||||
|
||||
/**
|
||||
* @brief Return the value of `SO_SNDBUF`
|
||||
@@ -2611,7 +2714,7 @@ ZTS_API int ZTCALL zts_simple_set_send_buf_size(int fd, int size);
|
||||
* @return Value of `SO_SNDBUF` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_get_send_buf_size(int fd);
|
||||
ZTS_API int ZTCALL zts_get_send_buf_size(int fd);
|
||||
|
||||
/**
|
||||
* @brief Set the value of `SO_RCVBUF`
|
||||
@@ -2621,7 +2724,7 @@ ZTS_API int ZTCALL zts_simple_get_send_buf_size(int fd);
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_set_recv_buf_size(int fd, int size);
|
||||
ZTS_API int ZTCALL zts_set_recv_buf_size(int fd, int size);
|
||||
|
||||
/**
|
||||
* @brief Return the value of `SO_RCVBUF`
|
||||
@@ -2630,7 +2733,7 @@ ZTS_API int ZTCALL zts_simple_set_recv_buf_size(int fd, int size);
|
||||
* @return Value of `SO_RCVBUF` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_get_recv_buf_size(int fd);
|
||||
ZTS_API int ZTCALL zts_get_recv_buf_size(int fd);
|
||||
|
||||
/**
|
||||
* @brief Set the value of `IP_TTL`
|
||||
@@ -2640,7 +2743,7 @@ ZTS_API int ZTCALL zts_simple_get_recv_buf_size(int fd);
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_set_ttl(int fd, int ttl);
|
||||
ZTS_API int ZTCALL zts_set_ttl(int fd, int ttl);
|
||||
|
||||
/**
|
||||
* @brief Return the value of `IP_TTL`
|
||||
@@ -2649,7 +2752,7 @@ ZTS_API int ZTCALL zts_simple_set_ttl(int fd, int ttl);
|
||||
* @return Value of `IP_TTL` `[0,255]` if successful, `ZTS_ERR_SERVICE` if the
|
||||
* node experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_get_ttl(int fd);
|
||||
ZTS_API int ZTCALL zts_get_ttl(int fd);
|
||||
|
||||
/**
|
||||
* @brief Change blocking behavior `O_NONBLOCK`
|
||||
@@ -2660,7 +2763,7 @@ ZTS_API int ZTCALL zts_simple_get_ttl(int fd);
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_set_blocking(int fd, int enabled);
|
||||
ZTS_API int ZTCALL zts_set_blocking(int fd, int enabled);
|
||||
|
||||
/**
|
||||
* @brief Return whether blocking mode `O_NONBLOCK` is enabled
|
||||
@@ -2669,7 +2772,7 @@ ZTS_API int ZTCALL zts_simple_set_blocking(int fd, int enabled);
|
||||
* @return `1` if enabled, `0` if disabled, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_get_blocking(int fd);
|
||||
ZTS_API int ZTCALL zts_get_blocking(int fd);
|
||||
|
||||
/**
|
||||
* @brief Enable or disable `SO_KEEPALIVE`
|
||||
@@ -2679,7 +2782,7 @@ ZTS_API int ZTCALL zts_simple_get_blocking(int fd);
|
||||
* @return `ZTS_ERR_OK` if successful, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_set_keepalive(int fd, int enabled);
|
||||
ZTS_API int ZTCALL zts_set_keepalive(int fd, int enabled);
|
||||
|
||||
/**
|
||||
* @brief Return whether `SO_KEEPALIVE` is enabled
|
||||
@@ -2688,7 +2791,7 @@ ZTS_API int ZTCALL zts_simple_set_keepalive(int fd, int enabled);
|
||||
* @return `1` if enabled, `0` if disabled, `ZTS_ERR_SERVICE` if the node
|
||||
* experiences a problem, `ZTS_ERR_ARG` if invalid argument. Sets `zts_errno`
|
||||
*/
|
||||
ZTS_API int ZTCALL zts_simple_get_keepalive(int fd);
|
||||
ZTS_API int ZTCALL zts_get_keepalive(int fd);
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
// DNS //
|
||||
@@ -2712,7 +2815,7 @@ struct zts_hostent {
|
||||
* @param name A null-terminated string representing the name of the host
|
||||
* @return Pointer to struct zts_hostent if successful, NULL otherwise
|
||||
*/
|
||||
struct zts_hostent* zts_gethostbyname(const char* name);
|
||||
struct zts_hostent* zts_bsd_gethostbyname(const char* name);
|
||||
|
||||
struct zts_ip4_addr {
|
||||
uint32_t addr;
|
||||
|
||||
@@ -26,7 +26,7 @@ Other API options:
|
||||
|
||||
We offer two other API layers depending on your use case. The first is a lower-
|
||||
level BSD-style socket API. This API is similar to BSD-style sockets
|
||||
(zts_socket(), zts_listen(), zts_bind(), etc.) The second is a Highly-
|
||||
(zts_bsd_socket(), zts_bsd_listen(), zts_bsd_bind(), etc.) The second is a Highly-
|
||||
performant virtual Ethernet layer. It can be used for any transport protocol
|
||||
and is only recommended for those who have advanced or specialty applications.
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.3.4-alpha.0
|
||||
1.4.0
|
||||
|
||||
548
src/Sockets.cpp
548
src/Sockets.cpp
@@ -32,7 +32,7 @@ namespace ZeroTier {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int zts_socket(const int socket_family, const int socket_type, const int protocol)
|
||||
int zts_bsd_socket(const int socket_family, const int socket_type, const int protocol)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -40,7 +40,7 @@ int zts_socket(const int socket_family, const int socket_type, const int protoco
|
||||
return lwip_socket(socket_family, socket_type, protocol);
|
||||
}
|
||||
|
||||
int zts_connect(int fd, const struct zts_sockaddr* addr, zts_socklen_t addrlen)
|
||||
int zts_bsd_connect(int fd, const struct zts_sockaddr* addr, zts_socklen_t addrlen)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -55,46 +55,7 @@ int zts_connect(int fd, const struct zts_sockaddr* addr, zts_socklen_t addrlen)
|
||||
return lwip_connect(fd, (sockaddr*)addr, addrlen);
|
||||
}
|
||||
|
||||
int zts_simple_connect(int fd, const char* ipstr, unsigned short port, int timeout_ms)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
if (timeout_ms < 0) {
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
if (timeout_ms == 0) {
|
||||
timeout_ms = 30000; // Default
|
||||
}
|
||||
int div = 4; // Must be > 0, Four connection attempts per second
|
||||
int n_tries = (timeout_ms / 1000) * div;
|
||||
int connect_delay = 1000 / div;
|
||||
int err = ZTS_ERR_SOCKET;
|
||||
|
||||
zts_socklen_t addrlen = 0;
|
||||
struct zts_sockaddr_storage ss;
|
||||
struct zts_sockaddr* sa = NULL;
|
||||
|
||||
// Convert to standard address structure
|
||||
|
||||
addrlen = sizeof(ss);
|
||||
zts_util_ipstr_to_saddr(ipstr, port, (struct zts_sockaddr*)&ss, &addrlen);
|
||||
sa = (struct zts_sockaddr*)&ss;
|
||||
|
||||
if (addrlen > 0 && sa != NULL) {
|
||||
if (zts_simple_get_blocking(fd)) {
|
||||
do {
|
||||
err = zts_connect(fd, sa, addrlen);
|
||||
zts_util_delay(connect_delay);
|
||||
n_tries--;
|
||||
} while ((err < 0) && (zts_errno != 0) && (n_tries > 0));
|
||||
}
|
||||
return err;
|
||||
}
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
|
||||
int zts_bind(int fd, const struct zts_sockaddr* addr, zts_socklen_t addrlen)
|
||||
int zts_bsd_bind(int fd, const struct zts_sockaddr* addr, zts_socklen_t addrlen)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -108,26 +69,7 @@ int zts_bind(int fd, const struct zts_sockaddr* addr, zts_socklen_t addrlen)
|
||||
return lwip_bind(fd, (sockaddr*)addr, addrlen);
|
||||
}
|
||||
|
||||
int zts_simple_bind(int fd, const char* ipstr, unsigned short port)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
zts_socklen_t addrlen = 0;
|
||||
struct zts_sockaddr_storage ss;
|
||||
struct zts_sockaddr* sa = NULL;
|
||||
|
||||
addrlen = sizeof(ss);
|
||||
int err = ZTS_ERR_OK;
|
||||
if ((err = zts_util_ipstr_to_saddr(ipstr, port, (struct zts_sockaddr*)&ss, &addrlen)) != ZTS_ERR_OK) {
|
||||
printf("ERRRRRRR=%d\n", err);
|
||||
return err;
|
||||
}
|
||||
sa = (struct zts_sockaddr*)&ss;
|
||||
return zts_bind(fd, sa, addrlen);
|
||||
}
|
||||
|
||||
int zts_listen(int fd, int backlog)
|
||||
int zts_bsd_listen(int fd, int backlog)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -135,7 +77,7 @@ int zts_listen(int fd, int backlog)
|
||||
return lwip_listen(fd, backlog);
|
||||
}
|
||||
|
||||
int zts_accept(int fd, struct zts_sockaddr* addr, zts_socklen_t* addrlen)
|
||||
int zts_bsd_accept(int fd, struct zts_sockaddr* addr, zts_socklen_t* addrlen)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -143,124 +85,7 @@ int zts_accept(int fd, struct zts_sockaddr* addr, zts_socklen_t* addrlen)
|
||||
return lwip_accept(fd, (sockaddr*)addr, (socklen_t*)addrlen);
|
||||
}
|
||||
|
||||
int zts_simple_accept(int fd, char* remote_addr, int len, unsigned short* port)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
if (len != ZTS_INET6_ADDRSTRLEN) {
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
zts_sockaddr_storage ss;
|
||||
zts_socklen_t addrlen = sizeof(ss);
|
||||
|
||||
int acc_fd = zts_accept(fd, (zts_sockaddr*)&ss, (zts_socklen_t*)&addrlen);
|
||||
int err = ZTS_ERR_OK;
|
||||
if ((err = zts_util_ntop((struct zts_sockaddr*)&ss, addrlen, remote_addr, len, port)) < ZTS_ERR_OK) {
|
||||
return err;
|
||||
}
|
||||
return acc_fd;
|
||||
}
|
||||
|
||||
int zts_simple_getpeername(int fd, char* remote_addr_str, int len, unsigned short* port)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
if (len != ZTS_INET6_ADDRSTRLEN) {
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
struct zts_sockaddr_storage ss;
|
||||
struct zts_sockaddr* sa = (struct zts_sockaddr*)&ss;
|
||||
int err = ZTS_ERR_OK;
|
||||
zts_socklen_t addrlen = sizeof(ss);
|
||||
if ((err = zts_getpeername(fd, sa, &addrlen)) < 0) {
|
||||
return err;
|
||||
}
|
||||
return zts_util_ntop(sa, addrlen, remote_addr_str, len, port);
|
||||
}
|
||||
|
||||
int zts_simple_getsockname(int fd, char* local_addr_str, int len, unsigned short* port)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
if (len != ZTS_INET6_ADDRSTRLEN) {
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
struct zts_sockaddr_storage ss;
|
||||
struct zts_sockaddr* sa = (struct zts_sockaddr*)&ss;
|
||||
int err = ZTS_ERR_OK;
|
||||
zts_socklen_t addrlen = sizeof(ss);
|
||||
if ((err = zts_getsockname(fd, sa, &addrlen)) < 0) {
|
||||
return err;
|
||||
}
|
||||
return zts_util_ntop(sa, addrlen, local_addr_str, len, port);
|
||||
}
|
||||
|
||||
int zts_simple_tcp_client(const char* remote_ipstr, unsigned short remote_port)
|
||||
{
|
||||
int fd, family = zts_util_get_ip_family(remote_ipstr);
|
||||
if ((fd = zts_socket(family, ZTS_SOCK_STREAM, 0)) < 0) {
|
||||
return fd; // Failed to create socket
|
||||
}
|
||||
int timeout = 0;
|
||||
if ((fd = zts_simple_connect(fd, remote_ipstr, remote_port, timeout)) < 0) {
|
||||
zts_close(fd);
|
||||
return fd; // Failed to connect
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int zts_simple_tcp_server(
|
||||
const char* local_ipstr,
|
||||
unsigned short local_port,
|
||||
char* remote_ipstr,
|
||||
int len,
|
||||
unsigned short* remote_port)
|
||||
{
|
||||
int listen_fd, family = zts_util_get_ip_family(local_ipstr);
|
||||
if ((listen_fd = zts_socket(family, ZTS_SOCK_STREAM, 0)) < 0) {
|
||||
return listen_fd; // Failed to create socket
|
||||
}
|
||||
if ((listen_fd = zts_simple_bind(listen_fd, local_ipstr, local_port)) < 0) {
|
||||
return listen_fd; // Failed to bind
|
||||
}
|
||||
int backlog = 0;
|
||||
if ((listen_fd = zts_listen(listen_fd, backlog)) < 0) {
|
||||
return listen_fd; // Failed to listen
|
||||
}
|
||||
int acc_fd = 0;
|
||||
if ((acc_fd = zts_simple_accept(listen_fd, remote_ipstr, len, remote_port)) < 0) {
|
||||
return acc_fd; // Failed to accept
|
||||
}
|
||||
zts_close(listen_fd);
|
||||
return acc_fd;
|
||||
}
|
||||
|
||||
int zts_simple_udp_server(const char* local_ipstr, unsigned short local_port)
|
||||
{
|
||||
int fd, family = zts_util_get_ip_family(local_ipstr);
|
||||
if ((fd = zts_socket(family, ZTS_SOCK_DGRAM, 0)) < 0) {
|
||||
return fd; // Failed to create socket
|
||||
}
|
||||
if ((fd = zts_simple_bind(fd, local_ipstr, local_port)) < 0) {
|
||||
zts_close(fd);
|
||||
return fd; // Failed to connect
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int zts_simple_udp_client(const char* remote_ipstr)
|
||||
{
|
||||
int fd, family = zts_util_get_ip_family(remote_ipstr);
|
||||
if ((fd = zts_socket(family, ZTS_SOCK_DGRAM, 0)) < 0) {
|
||||
return fd; // Failed to create socket
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int zts_setsockopt(int fd, int level, int optname, const void* optval, zts_socklen_t optlen)
|
||||
int zts_bsd_setsockopt(int fd, int level, int optname, const void* optval, zts_socklen_t optlen)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -268,7 +93,7 @@ int zts_setsockopt(int fd, int level, int optname, const void* optval, zts_sockl
|
||||
return lwip_setsockopt(fd, level, optname, optval, optlen);
|
||||
}
|
||||
|
||||
int zts_getsockopt(int fd, int level, int optname, void* optval, zts_socklen_t* optlen)
|
||||
int zts_bsd_getsockopt(int fd, int level, int optname, void* optval, zts_socklen_t* optlen)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -276,7 +101,7 @@ int zts_getsockopt(int fd, int level, int optname, void* optval, zts_socklen_t*
|
||||
return lwip_getsockopt(fd, level, optname, optval, (socklen_t*)optlen);
|
||||
}
|
||||
|
||||
int zts_getsockname(int fd, struct zts_sockaddr* addr, zts_socklen_t* addrlen)
|
||||
int zts_bsd_getsockname(int fd, struct zts_sockaddr* addr, zts_socklen_t* addrlen)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -290,7 +115,7 @@ int zts_getsockname(int fd, struct zts_sockaddr* addr, zts_socklen_t* addrlen)
|
||||
return lwip_getsockname(fd, (sockaddr*)addr, (socklen_t*)addrlen);
|
||||
}
|
||||
|
||||
int zts_getpeername(int fd, struct zts_sockaddr* addr, zts_socklen_t* addrlen)
|
||||
int zts_bsd_getpeername(int fd, struct zts_sockaddr* addr, zts_socklen_t* addrlen)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -304,7 +129,7 @@ int zts_getpeername(int fd, struct zts_sockaddr* addr, zts_socklen_t* addrlen)
|
||||
return lwip_getpeername(fd, (sockaddr*)addr, (socklen_t*)addrlen);
|
||||
}
|
||||
|
||||
int zts_close(int fd)
|
||||
int zts_bsd_close(int fd)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -312,7 +137,12 @@ int zts_close(int fd)
|
||||
return lwip_close(fd);
|
||||
}
|
||||
|
||||
int zts_select(int nfds, zts_fd_set* readfds, zts_fd_set* writefds, zts_fd_set* exceptfds, struct zts_timeval* timeout)
|
||||
int zts_bsd_select(
|
||||
int nfds,
|
||||
zts_fd_set* readfds,
|
||||
zts_fd_set* writefds,
|
||||
zts_fd_set* exceptfds,
|
||||
struct zts_timeval* timeout)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -320,7 +150,7 @@ int zts_select(int nfds, zts_fd_set* readfds, zts_fd_set* writefds, zts_fd_set*
|
||||
return lwip_select(nfds, (fd_set*)readfds, (fd_set*)writefds, (fd_set*)exceptfds, (timeval*)timeout);
|
||||
}
|
||||
|
||||
int zts_fcntl(int fd, int cmd, int flags)
|
||||
int zts_bsd_fcntl(int fd, int cmd, int flags)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -328,7 +158,7 @@ int zts_fcntl(int fd, int cmd, int flags)
|
||||
return lwip_fcntl(fd, cmd, flags);
|
||||
}
|
||||
|
||||
int zts_poll(struct zts_pollfd* fds, nfds_t nfds, int timeout)
|
||||
int zts_bsd_poll(struct zts_pollfd* fds, nfds_t nfds, int timeout)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -336,7 +166,7 @@ int zts_poll(struct zts_pollfd* fds, nfds_t nfds, int timeout)
|
||||
return lwip_poll((pollfd*)fds, nfds, timeout);
|
||||
}
|
||||
|
||||
int zts_ioctl(int fd, unsigned long request, void* argp)
|
||||
int zts_bsd_ioctl(int fd, unsigned long request, void* argp)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -347,7 +177,7 @@ int zts_ioctl(int fd, unsigned long request, void* argp)
|
||||
return lwip_ioctl(fd, request, argp);
|
||||
}
|
||||
|
||||
ssize_t zts_send(int fd, const void* buf, size_t len, int flags)
|
||||
ssize_t zts_bsd_send(int fd, const void* buf, size_t len, int flags)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -359,7 +189,7 @@ ssize_t zts_send(int fd, const void* buf, size_t len, int flags)
|
||||
}
|
||||
|
||||
ssize_t
|
||||
zts_sendto(int fd, const void* buf, size_t len, int flags, const struct zts_sockaddr* addr, zts_socklen_t addrlen)
|
||||
zts_bsd_sendto(int fd, const void* buf, size_t len, int flags, const struct zts_sockaddr* addr, zts_socklen_t addrlen)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -373,7 +203,7 @@ zts_sendto(int fd, const void* buf, size_t len, int flags, const struct zts_sock
|
||||
return lwip_sendto(fd, buf, len, flags, (sockaddr*)addr, addrlen);
|
||||
}
|
||||
|
||||
ssize_t zts_sendmsg(int fd, const struct zts_msghdr* msg, int flags)
|
||||
ssize_t zts_bsd_sendmsg(int fd, const struct zts_msghdr* msg, int flags)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -381,7 +211,7 @@ ssize_t zts_sendmsg(int fd, const struct zts_msghdr* msg, int flags)
|
||||
return lwip_sendmsg(fd, (const struct msghdr*)msg, flags);
|
||||
}
|
||||
|
||||
ssize_t zts_recv(int fd, void* buf, size_t len, int flags)
|
||||
ssize_t zts_bsd_recv(int fd, void* buf, size_t len, int flags)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -392,7 +222,7 @@ ssize_t zts_recv(int fd, void* buf, size_t len, int flags)
|
||||
return lwip_recv(fd, buf, len, flags);
|
||||
}
|
||||
|
||||
ssize_t zts_recvfrom(int fd, void* buf, size_t len, int flags, struct zts_sockaddr* addr, zts_socklen_t* addrlen)
|
||||
ssize_t zts_bsd_recvfrom(int fd, void* buf, size_t len, int flags, struct zts_sockaddr* addr, zts_socklen_t* addrlen)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -403,7 +233,7 @@ ssize_t zts_recvfrom(int fd, void* buf, size_t len, int flags, struct zts_sockad
|
||||
return lwip_recvfrom(fd, buf, len, flags, (sockaddr*)addr, (socklen_t*)addrlen);
|
||||
}
|
||||
|
||||
ssize_t zts_recvmsg(int fd, struct zts_msghdr* msg, int flags)
|
||||
ssize_t zts_bsd_recvmsg(int fd, struct zts_msghdr* msg, int flags)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -414,7 +244,7 @@ ssize_t zts_recvmsg(int fd, struct zts_msghdr* msg, int flags)
|
||||
return lwip_recvmsg(fd, (struct msghdr*)msg, flags);
|
||||
}
|
||||
|
||||
ssize_t zts_read(int fd, void* buf, size_t len)
|
||||
ssize_t zts_bsd_read(int fd, void* buf, size_t len)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -425,7 +255,7 @@ ssize_t zts_read(int fd, void* buf, size_t len)
|
||||
return lwip_read(fd, buf, len);
|
||||
}
|
||||
|
||||
ssize_t zts_readv(int fd, const struct zts_iovec* iov, int iovcnt)
|
||||
ssize_t zts_bsd_readv(int fd, const struct zts_iovec* iov, int iovcnt)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -433,7 +263,7 @@ ssize_t zts_readv(int fd, const struct zts_iovec* iov, int iovcnt)
|
||||
return lwip_readv(fd, (iovec*)iov, iovcnt);
|
||||
}
|
||||
|
||||
ssize_t zts_write(int fd, const void* buf, size_t len)
|
||||
ssize_t zts_bsd_write(int fd, const void* buf, size_t len)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -444,7 +274,7 @@ ssize_t zts_write(int fd, const void* buf, size_t len)
|
||||
return lwip_write(fd, buf, len);
|
||||
}
|
||||
|
||||
ssize_t zts_writev(int fd, const struct zts_iovec* iov, int iovcnt)
|
||||
ssize_t zts_bsd_writev(int fd, const struct zts_iovec* iov, int iovcnt)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -452,7 +282,7 @@ ssize_t zts_writev(int fd, const struct zts_iovec* iov, int iovcnt)
|
||||
return lwip_writev(fd, (iovec*)iov, iovcnt);
|
||||
}
|
||||
|
||||
int zts_shutdown(int fd, int how)
|
||||
int zts_bsd_shutdown(int fd, int how)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -460,7 +290,7 @@ int zts_shutdown(int fd, int how)
|
||||
return lwip_shutdown(fd, how);
|
||||
}
|
||||
|
||||
struct zts_hostent* zts_gethostbyname(const char* name)
|
||||
struct zts_hostent* zts_bsd_gethostbyname(const char* name)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return NULL;
|
||||
@@ -554,7 +384,231 @@ int zts_util_ipstr_to_saddr(
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
|
||||
int zts_simple_set_no_delay(int fd, int enabled)
|
||||
int zts_socket(int family, int type, int protocol)
|
||||
{
|
||||
return zts_bsd_socket(family, type, protocol);
|
||||
}
|
||||
|
||||
int zts_connect(int fd, const char* ipstr, unsigned short port, int timeout_ms)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
if (timeout_ms < 0) {
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
if (timeout_ms == 0) {
|
||||
timeout_ms = 30000; // Default
|
||||
}
|
||||
int div = 4; // Must be > 0, Four connection attempts per second
|
||||
int n_tries = (timeout_ms / 1000) * div;
|
||||
int connect_delay = 1000 / div;
|
||||
int err = ZTS_ERR_SOCKET;
|
||||
|
||||
zts_socklen_t addrlen = 0;
|
||||
struct zts_sockaddr_storage ss;
|
||||
struct zts_sockaddr* sa = NULL;
|
||||
|
||||
// Convert to standard address structure
|
||||
|
||||
addrlen = sizeof(ss);
|
||||
zts_util_ipstr_to_saddr(ipstr, port, (struct zts_sockaddr*)&ss, &addrlen);
|
||||
sa = (struct zts_sockaddr*)&ss;
|
||||
|
||||
if (addrlen > 0 && sa != NULL) {
|
||||
if (zts_get_blocking(fd)) {
|
||||
do {
|
||||
err = zts_bsd_connect(fd, sa, addrlen);
|
||||
zts_util_delay(connect_delay);
|
||||
n_tries--;
|
||||
} while ((err < 0) && (zts_errno != 0) && (n_tries > 0));
|
||||
}
|
||||
return err;
|
||||
}
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
|
||||
int zts_bind(int fd, const char* ipstr, unsigned short port)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
zts_socklen_t addrlen = 0;
|
||||
struct zts_sockaddr_storage ss;
|
||||
struct zts_sockaddr* sa = NULL;
|
||||
|
||||
addrlen = sizeof(ss);
|
||||
int err = ZTS_ERR_OK;
|
||||
if ((err = zts_util_ipstr_to_saddr(ipstr, port, (struct zts_sockaddr*)&ss, &addrlen)) != ZTS_ERR_OK) {
|
||||
return err;
|
||||
}
|
||||
sa = (struct zts_sockaddr*)&ss;
|
||||
return zts_bsd_bind(fd, sa, addrlen);
|
||||
}
|
||||
|
||||
int zts_listen(int fd, int backlog)
|
||||
{
|
||||
return zts_bsd_listen(fd, backlog);
|
||||
}
|
||||
|
||||
int zts_accept(int fd, char* remote_addr, int len, unsigned short* port)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
if (len != ZTS_INET6_ADDRSTRLEN) {
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
zts_sockaddr_storage ss;
|
||||
zts_socklen_t addrlen = sizeof(ss);
|
||||
|
||||
int acc_fd = zts_bsd_accept(fd, (zts_sockaddr*)&ss, (zts_socklen_t*)&addrlen);
|
||||
int err = ZTS_ERR_OK;
|
||||
if ((err = zts_util_ntop((struct zts_sockaddr*)&ss, addrlen, remote_addr, len, port)) < ZTS_ERR_OK) {
|
||||
return err;
|
||||
}
|
||||
return acc_fd;
|
||||
}
|
||||
|
||||
ssize_t zts_send(int fd, const void* buf, size_t len, int flags)
|
||||
{
|
||||
return zts_bsd_send(fd, buf, len, flags);
|
||||
}
|
||||
|
||||
ssize_t zts_recv(int fd, void* buf, size_t len, int flags)
|
||||
{
|
||||
return zts_bsd_recv(fd, buf, len, flags);
|
||||
}
|
||||
|
||||
ssize_t zts_read(int fd, void* buf, size_t len)
|
||||
{
|
||||
return zts_bsd_read(fd, buf, len);
|
||||
}
|
||||
|
||||
ssize_t zts_write(int fd, const void* buf, size_t len)
|
||||
{
|
||||
return zts_bsd_write(fd, buf, len);
|
||||
}
|
||||
|
||||
int zts_shutdown_rd(int fd)
|
||||
{
|
||||
return zts_bsd_shutdown(fd, ZTS_SHUT_RD);
|
||||
}
|
||||
|
||||
int zts_shutdown_wr(int fd)
|
||||
{
|
||||
return zts_bsd_shutdown(fd, ZTS_SHUT_WR);
|
||||
}
|
||||
|
||||
int zts_shutdown_rdwr(int fd)
|
||||
{
|
||||
return zts_bsd_shutdown(fd, ZTS_SHUT_RDWR);
|
||||
}
|
||||
|
||||
int zts_close(int fd)
|
||||
{
|
||||
return zts_bsd_close(fd);
|
||||
}
|
||||
|
||||
int zts_getpeername(int fd, char* remote_addr_str, int len, unsigned short* port)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
if (len != ZTS_INET6_ADDRSTRLEN) {
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
struct zts_sockaddr_storage ss;
|
||||
struct zts_sockaddr* sa = (struct zts_sockaddr*)&ss;
|
||||
int err = ZTS_ERR_OK;
|
||||
zts_socklen_t addrlen = sizeof(ss);
|
||||
if ((err = zts_bsd_getpeername(fd, sa, &addrlen)) < 0) {
|
||||
return err;
|
||||
}
|
||||
return zts_util_ntop(sa, addrlen, remote_addr_str, len, port);
|
||||
}
|
||||
|
||||
int zts_getsockname(int fd, char* local_addr_str, int len, unsigned short* port)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
if (len != ZTS_INET6_ADDRSTRLEN) {
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
struct zts_sockaddr_storage ss;
|
||||
struct zts_sockaddr* sa = (struct zts_sockaddr*)&ss;
|
||||
int err = ZTS_ERR_OK;
|
||||
zts_socklen_t addrlen = sizeof(ss);
|
||||
if ((err = zts_bsd_getsockname(fd, sa, &addrlen)) < 0) {
|
||||
return err;
|
||||
}
|
||||
return zts_util_ntop(sa, addrlen, local_addr_str, len, port);
|
||||
}
|
||||
|
||||
int zts_tcp_client(const char* remote_ipstr, unsigned short remote_port)
|
||||
{
|
||||
int fd, family = zts_util_get_ip_family(remote_ipstr);
|
||||
if ((fd = zts_bsd_socket(family, ZTS_SOCK_STREAM, 0)) < 0) {
|
||||
return fd; // Failed to create socket
|
||||
}
|
||||
int timeout = 0;
|
||||
if ((fd = zts_connect(fd, remote_ipstr, remote_port, timeout)) < 0) {
|
||||
zts_bsd_close(fd);
|
||||
return fd; // Failed to connect
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int zts_tcp_server(
|
||||
const char* local_ipstr,
|
||||
unsigned short local_port,
|
||||
char* remote_ipstr,
|
||||
int len,
|
||||
unsigned short* remote_port)
|
||||
{
|
||||
int listen_fd, family = zts_util_get_ip_family(local_ipstr);
|
||||
if ((listen_fd = zts_bsd_socket(family, ZTS_SOCK_STREAM, 0)) < 0) {
|
||||
return listen_fd; // Failed to create socket
|
||||
}
|
||||
if ((listen_fd = zts_bind(listen_fd, local_ipstr, local_port)) < 0) {
|
||||
return listen_fd; // Failed to bind
|
||||
}
|
||||
int backlog = 0;
|
||||
if ((listen_fd = zts_bsd_listen(listen_fd, backlog)) < 0) {
|
||||
return listen_fd; // Failed to listen
|
||||
}
|
||||
int acc_fd = 0;
|
||||
if ((acc_fd = zts_accept(listen_fd, remote_ipstr, len, remote_port)) < 0) {
|
||||
return acc_fd; // Failed to accept
|
||||
}
|
||||
zts_bsd_close(listen_fd);
|
||||
return acc_fd;
|
||||
}
|
||||
|
||||
int zts_udp_server(const char* local_ipstr, unsigned short local_port)
|
||||
{
|
||||
int fd, family = zts_util_get_ip_family(local_ipstr);
|
||||
if ((fd = zts_bsd_socket(family, ZTS_SOCK_DGRAM, 0)) < 0) {
|
||||
return fd; // Failed to create socket
|
||||
}
|
||||
if ((fd = zts_bind(fd, local_ipstr, local_port)) < 0) {
|
||||
zts_bsd_close(fd);
|
||||
return fd; // Failed to connect
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int zts_udp_client(const char* remote_ipstr)
|
||||
{
|
||||
int fd, family = zts_util_get_ip_family(remote_ipstr);
|
||||
if ((fd = zts_bsd_socket(family, ZTS_SOCK_DGRAM, 0)) < 0) {
|
||||
return fd; // Failed to create socket
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int zts_set_no_delay(int fd, int enabled)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -562,23 +616,23 @@ int zts_simple_set_no_delay(int fd, int enabled)
|
||||
if (enabled != 0 && enabled != 1) {
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
return zts_setsockopt(fd, ZTS_IPPROTO_TCP, ZTS_TCP_NODELAY, (void*)&enabled, sizeof(int));
|
||||
return zts_bsd_setsockopt(fd, ZTS_IPPROTO_TCP, ZTS_TCP_NODELAY, (void*)&enabled, sizeof(int));
|
||||
}
|
||||
|
||||
int zts_simple_get_no_delay(int fd)
|
||||
int zts_get_no_delay(int fd)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
int err, optval = 0;
|
||||
zts_socklen_t len = sizeof(optval);
|
||||
if ((err = zts_getsockopt(fd, ZTS_IPPROTO_TCP, ZTS_TCP_NODELAY, (void*)&optval, &len)) < 0) {
|
||||
if ((err = zts_bsd_getsockopt(fd, ZTS_IPPROTO_TCP, ZTS_TCP_NODELAY, (void*)&optval, &len)) < 0) {
|
||||
return err;
|
||||
}
|
||||
return optval != 0;
|
||||
}
|
||||
|
||||
int zts_simple_set_linger(int fd, int enabled, int value)
|
||||
int zts_set_linger(int fd, int enabled, int value)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -592,10 +646,10 @@ int zts_simple_set_linger(int fd, int enabled, int value)
|
||||
struct zts_linger linger;
|
||||
linger.l_onoff = enabled;
|
||||
linger.l_linger = value;
|
||||
return zts_setsockopt(fd, ZTS_SOL_SOCKET, ZTS_SO_LINGER, (void*)&linger, sizeof(linger));
|
||||
return zts_bsd_setsockopt(fd, ZTS_SOL_SOCKET, ZTS_SO_LINGER, (void*)&linger, sizeof(linger));
|
||||
}
|
||||
|
||||
int zts_simple_get_linger_enabled(int fd)
|
||||
int zts_get_linger_enabled(int fd)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -603,13 +657,13 @@ int zts_simple_get_linger_enabled(int fd)
|
||||
struct zts_linger linger;
|
||||
zts_socklen_t len = sizeof(linger);
|
||||
int err;
|
||||
if ((err = zts_getsockopt(fd, ZTS_SOL_SOCKET, ZTS_SO_LINGER, (void*)&linger, &len)) < 0) {
|
||||
if ((err = zts_bsd_getsockopt(fd, ZTS_SOL_SOCKET, ZTS_SO_LINGER, (void*)&linger, &len)) < 0) {
|
||||
return err;
|
||||
}
|
||||
return linger.l_onoff;
|
||||
}
|
||||
|
||||
int zts_simple_get_linger_value(int fd)
|
||||
int zts_get_linger_value(int fd)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -617,26 +671,26 @@ int zts_simple_get_linger_value(int fd)
|
||||
struct zts_linger linger;
|
||||
zts_socklen_t len = sizeof(linger);
|
||||
int err;
|
||||
if ((err = zts_getsockopt(fd, ZTS_SOL_SOCKET, ZTS_SO_LINGER, (void*)&linger, &len)) < 0) {
|
||||
if ((err = zts_bsd_getsockopt(fd, ZTS_SOL_SOCKET, ZTS_SO_LINGER, (void*)&linger, &len)) < 0) {
|
||||
return err;
|
||||
}
|
||||
return linger.l_linger;
|
||||
}
|
||||
|
||||
int zts_simple_get_pending_data_size(int fd)
|
||||
int zts_get_pending_data_size(int fd)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
int bytes_available = 0;
|
||||
int err = ZTS_ERR_OK;
|
||||
if ((err = zts_ioctl(fd, ZTS_FIONREAD, &bytes_available)) < 0) {
|
||||
if ((err = zts_bsd_ioctl(fd, ZTS_FIONREAD, &bytes_available)) < 0) {
|
||||
return err;
|
||||
}
|
||||
return bytes_available;
|
||||
}
|
||||
|
||||
int zts_simple_set_reuse_addr(int fd, int enabled)
|
||||
int zts_set_reuse_addr(int fd, int enabled)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -644,23 +698,23 @@ int zts_simple_set_reuse_addr(int fd, int enabled)
|
||||
if (enabled != 0 && enabled != 1) {
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
return zts_setsockopt(fd, ZTS_SOL_SOCKET, ZTS_SO_REUSEADDR, (void*)&enabled, sizeof(enabled));
|
||||
return zts_bsd_setsockopt(fd, ZTS_SOL_SOCKET, ZTS_SO_REUSEADDR, (void*)&enabled, sizeof(enabled));
|
||||
}
|
||||
|
||||
int zts_simple_get_reuse_addr(int fd)
|
||||
int zts_get_reuse_addr(int fd)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
int err, optval = 0;
|
||||
zts_socklen_t optlen = sizeof(optval);
|
||||
if ((err = zts_getsockopt(fd, ZTS_SOL_SOCKET, ZTS_SO_REUSEADDR, (void*)&optval, &optlen)) < 0) {
|
||||
if ((err = zts_bsd_getsockopt(fd, ZTS_SOL_SOCKET, ZTS_SO_REUSEADDR, (void*)&optval, &optlen)) < 0) {
|
||||
return err;
|
||||
}
|
||||
return optval != 0;
|
||||
}
|
||||
|
||||
int zts_simple_set_recv_timeout(int fd, int seconds, int microseconds)
|
||||
int zts_set_recv_timeout(int fd, int seconds, int microseconds)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -671,10 +725,10 @@ int zts_simple_set_recv_timeout(int fd, int seconds, int microseconds)
|
||||
struct timeval tv;
|
||||
tv.tv_sec = seconds;
|
||||
tv.tv_usec = microseconds;
|
||||
return zts_setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (void*)&tv, sizeof(tv));
|
||||
return zts_bsd_setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (void*)&tv, sizeof(tv));
|
||||
}
|
||||
|
||||
int zts_simple_get_recv_timeout(int fd)
|
||||
int zts_get_recv_timeout(int fd)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -682,13 +736,13 @@ int zts_simple_get_recv_timeout(int fd)
|
||||
struct timeval tv;
|
||||
zts_socklen_t optlen = sizeof(tv);
|
||||
int err;
|
||||
if ((err = zts_getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (void*)&tv, &optlen)) < 0) {
|
||||
if ((err = zts_bsd_getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (void*)&tv, &optlen)) < 0) {
|
||||
return err;
|
||||
}
|
||||
return tv.tv_sec; // TODO microseconds
|
||||
}
|
||||
|
||||
int zts_simple_set_send_timeout(int fd, int seconds, int microseconds)
|
||||
int zts_set_send_timeout(int fd, int seconds, int microseconds)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -699,10 +753,10 @@ int zts_simple_set_send_timeout(int fd, int seconds, int microseconds)
|
||||
struct timeval tv;
|
||||
tv.tv_sec = seconds;
|
||||
tv.tv_usec = microseconds;
|
||||
return zts_setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (void*)&tv, sizeof(tv));
|
||||
return zts_bsd_setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (void*)&tv, sizeof(tv));
|
||||
}
|
||||
|
||||
int zts_simple_get_send_timeout(int fd)
|
||||
int zts_get_send_timeout(int fd)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -710,13 +764,13 @@ int zts_simple_get_send_timeout(int fd)
|
||||
struct zts_timeval tv;
|
||||
zts_socklen_t optlen = sizeof(tv);
|
||||
int err;
|
||||
if ((err = zts_getsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (void*)&tv, &optlen)) < 0) {
|
||||
if ((err = zts_bsd_getsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (void*)&tv, &optlen)) < 0) {
|
||||
return err;
|
||||
}
|
||||
return tv.tv_sec; // TODO microseconds
|
||||
}
|
||||
|
||||
int zts_simple_set_send_buf_size(int fd, int size)
|
||||
int zts_set_send_buf_size(int fd, int size)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -724,23 +778,23 @@ int zts_simple_set_send_buf_size(int fd, int size)
|
||||
if (size < 0) {
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
return zts_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void*)&size, sizeof(int));
|
||||
return zts_bsd_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void*)&size, sizeof(int));
|
||||
}
|
||||
|
||||
int zts_simple_get_send_buf_size(int fd)
|
||||
int zts_get_send_buf_size(int fd)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
int err, optval = 0;
|
||||
zts_socklen_t optlen = sizeof(optval);
|
||||
if ((err = zts_getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*)&optval, &optlen)) < 0) {
|
||||
if ((err = zts_bsd_getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*)&optval, &optlen)) < 0) {
|
||||
return err;
|
||||
}
|
||||
return optval;
|
||||
}
|
||||
|
||||
int zts_simple_set_recv_buf_size(int fd, int size)
|
||||
int zts_set_recv_buf_size(int fd, int size)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -748,23 +802,23 @@ int zts_simple_set_recv_buf_size(int fd, int size)
|
||||
if (size < 0) {
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
return zts_setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void*)&size, sizeof(int));
|
||||
return zts_bsd_setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void*)&size, sizeof(int));
|
||||
}
|
||||
|
||||
int zts_simple_get_recv_buf_size(int fd)
|
||||
int zts_get_recv_buf_size(int fd)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
int err, optval = 0;
|
||||
zts_socklen_t optlen = sizeof(optval);
|
||||
if ((err = zts_getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*)&optval, &optlen)) < 0) {
|
||||
if ((err = zts_bsd_getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*)&optval, &optlen)) < 0) {
|
||||
return err;
|
||||
}
|
||||
return optval;
|
||||
}
|
||||
|
||||
int zts_simple_set_ttl(int fd, int ttl)
|
||||
int zts_set_ttl(int fd, int ttl)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -772,23 +826,23 @@ int zts_simple_set_ttl(int fd, int ttl)
|
||||
if (ttl < 0 || ttl > 255) {
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
return zts_setsockopt(fd, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl));
|
||||
return zts_bsd_setsockopt(fd, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl));
|
||||
}
|
||||
|
||||
int zts_simple_get_ttl(int fd)
|
||||
int zts_get_ttl(int fd)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
int err, ttl = 0;
|
||||
zts_socklen_t optlen = sizeof(ttl);
|
||||
if ((err = zts_getsockopt(fd, IPPROTO_IP, IP_TTL, &ttl, &optlen)) < 0) {
|
||||
if ((err = zts_bsd_getsockopt(fd, IPPROTO_IP, IP_TTL, &ttl, &optlen)) < 0) {
|
||||
return err;
|
||||
}
|
||||
return ttl;
|
||||
}
|
||||
|
||||
int zts_simple_set_blocking(int fd, int enabled)
|
||||
int zts_set_blocking(int fd, int enabled)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -796,29 +850,29 @@ int zts_simple_set_blocking(int fd, int enabled)
|
||||
if (enabled != 0 && enabled != 1) {
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
int flags = zts_fcntl(fd, ZTS_F_GETFL, 0);
|
||||
int flags = zts_bsd_fcntl(fd, ZTS_F_GETFL, 0);
|
||||
if (! enabled) {
|
||||
return zts_fcntl(fd, ZTS_F_SETFL, flags | ZTS_O_NONBLOCK);
|
||||
return zts_bsd_fcntl(fd, ZTS_F_SETFL, flags | ZTS_O_NONBLOCK);
|
||||
}
|
||||
else {
|
||||
// Default
|
||||
return zts_fcntl(fd, ZTS_F_SETFL, flags & (~ZTS_O_NONBLOCK));
|
||||
return zts_bsd_fcntl(fd, ZTS_F_SETFL, flags & (~ZTS_O_NONBLOCK));
|
||||
}
|
||||
}
|
||||
|
||||
int zts_simple_get_blocking(int fd)
|
||||
int zts_get_blocking(int fd)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
int flags = zts_fcntl(fd, ZTS_F_GETFL, 0);
|
||||
int flags = zts_bsd_fcntl(fd, ZTS_F_GETFL, 0);
|
||||
if (flags < 0) {
|
||||
return flags;
|
||||
}
|
||||
return ! (flags & ZTS_O_NONBLOCK);
|
||||
}
|
||||
|
||||
int zts_simple_set_keepalive(int fd, int enabled)
|
||||
int zts_set_keepalive(int fd, int enabled)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
@@ -827,17 +881,17 @@ int zts_simple_set_keepalive(int fd, int enabled)
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
int keepalive = enabled;
|
||||
return zts_setsockopt(fd, ZTS_SOL_SOCKET, ZTS_SO_KEEPALIVE, &keepalive, sizeof(keepalive));
|
||||
return zts_bsd_setsockopt(fd, ZTS_SOL_SOCKET, ZTS_SO_KEEPALIVE, &keepalive, sizeof(keepalive));
|
||||
}
|
||||
|
||||
int zts_simple_get_keepalive(int fd)
|
||||
int zts_get_keepalive(int fd)
|
||||
{
|
||||
if (! transport_ok()) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
int err, optval = 0;
|
||||
zts_socklen_t optlen = sizeof(optval);
|
||||
if ((err = zts_getsockopt(fd, ZTS_SOL_SOCKET, ZTS_SO_KEEPALIVE, (void*)&optval, &optlen)) < 0) {
|
||||
if ((err = zts_bsd_getsockopt(fd, ZTS_SOL_SOCKET, ZTS_SO_KEEPALIVE, (void*)&optval, &optlen)) < 0) {
|
||||
return err;
|
||||
}
|
||||
return optval != 0;
|
||||
|
||||
@@ -1097,7 +1097,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_stats_get_all(void* jarg1)
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_socket(int jarg1, int jarg2, int jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_socket(int jarg1, int jarg2, int jarg3)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1107,12 +1107,12 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_socket(int jarg1, int jarg2, int jarg3)
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (int)jarg2;
|
||||
arg3 = (int)jarg3;
|
||||
result = (int)zts_socket(arg1, arg2, arg3);
|
||||
result = (int)zts_bsd_socket(arg1, arg2, arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_connect(int jarg1, zts_sockaddr* jarg2, unsigned short jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_connect(int jarg1, zts_sockaddr* jarg2, unsigned short jarg3)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1122,12 +1122,12 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_connect(int jarg1, zts_sockaddr* jarg2, un
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (zts_sockaddr*)jarg2;
|
||||
arg3 = (zts_socklen_t)jarg3;
|
||||
result = (int)zts_connect(arg1, (zts_sockaddr const*)arg2, arg3);
|
||||
result = (int)zts_bsd_connect(arg1, (zts_sockaddr const*)arg2, arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_connect(int jarg1, char* jarg2, int jarg3, int jarg4)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_connect(int jarg1, char* jarg2, int jarg3, int jarg4)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1139,12 +1139,12 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_connect(int jarg1, char* jarg2, int
|
||||
arg2 = (char*)jarg2;
|
||||
arg3 = (int)jarg3;
|
||||
arg4 = (int)jarg4;
|
||||
result = (int)zts_simple_connect(arg1, (char const*)arg2, arg3, arg4);
|
||||
result = (int)zts_connect(arg1, (char const*)arg2, arg3, arg4);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bind(int jarg1, zts_sockaddr* jarg2, unsigned short jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_bind(int jarg1, zts_sockaddr* jarg2, unsigned short jarg3)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1154,12 +1154,12 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_bind(int jarg1, zts_sockaddr* jarg2, unsig
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (zts_sockaddr*)jarg2;
|
||||
arg3 = (zts_socklen_t)jarg3;
|
||||
result = (int)zts_bind(arg1, (zts_sockaddr const*)arg2, arg3);
|
||||
result = (int)zts_bsd_bind(arg1, (zts_sockaddr const*)arg2, arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_bind(int jarg1, char* jarg2, int jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bind(int jarg1, char* jarg2, int jarg3)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1169,12 +1169,12 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_bind(int jarg1, char* jarg2, int ja
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (char*)jarg2;
|
||||
arg3 = (int)jarg3;
|
||||
result = (int)zts_simple_bind(arg1, (char const*)arg2, arg3);
|
||||
result = (int)zts_bind(arg1, (char const*)arg2, arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_listen(int jarg1, int jarg2)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_listen(int jarg1, int jarg2)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1182,12 +1182,12 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_listen(int jarg1, int jarg2)
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (int)jarg2;
|
||||
result = (int)zts_listen(arg1, arg2);
|
||||
result = (int)zts_bsd_listen(arg1, arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_accept(int jarg1, zts_sockaddr* jarg2, void* jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_accept(int jarg1, zts_sockaddr* jarg2, void* jarg3)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1197,12 +1197,12 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_accept(int jarg1, zts_sockaddr* jarg2, voi
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (zts_sockaddr*)jarg2;
|
||||
arg3 = (zts_socklen_t*)jarg3;
|
||||
result = (int)zts_accept(arg1, arg2, arg3);
|
||||
result = (int)zts_bsd_accept(arg1, arg2, arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_accept(int jarg1, char* jarg2, int jarg3, void* jarg4)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_accept(int jarg1, char* jarg2, int jarg3, void* jarg4)
|
||||
{
|
||||
int arg1;
|
||||
char* arg2 = (char*)0;
|
||||
@@ -1212,10 +1212,10 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_accept(int jarg1, char* jarg2, int
|
||||
arg2 = (char*)jarg2;
|
||||
arg3 = (int)jarg3;
|
||||
arg4 = (unsigned short*)jarg4;
|
||||
return zts_simple_accept(arg1, arg2, arg3, arg4);
|
||||
return zts_accept(arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_tcp_client(char* jarg1, int jarg2)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_tcp_client(char* jarg1, int jarg2)
|
||||
{
|
||||
int jresult;
|
||||
char* arg1 = (char*)0;
|
||||
@@ -1223,12 +1223,12 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_tcp_client(char* jarg1, int jarg2)
|
||||
int result;
|
||||
arg1 = (char*)jarg1;
|
||||
arg2 = (int)jarg2;
|
||||
result = (int)zts_simple_tcp_client((char const*)arg1, arg2);
|
||||
result = (int)zts_tcp_client((char const*)arg1, arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_tcp_server(char* jarg1, int jarg2, char* jarg3, int jarg4, void* jarg5)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_tcp_server(char* jarg1, int jarg2, char* jarg3, int jarg4, void* jarg5)
|
||||
{
|
||||
char* arg1 = (char*)0;
|
||||
int arg2;
|
||||
@@ -1240,10 +1240,10 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_tcp_server(char* jarg1, int jarg2,
|
||||
arg3 = (char*)jarg3;
|
||||
arg4 = (int)jarg4;
|
||||
arg5 = (unsigned short*)jarg5;
|
||||
return zts_simple_tcp_server((char const*)arg1, arg2, arg3, arg4, arg5);
|
||||
return zts_tcp_server((char const*)arg1, arg2, arg3, arg4, arg5);
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_udp_server(char* jarg1, int jarg2)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_udp_server(char* jarg1, int jarg2)
|
||||
{
|
||||
int jresult;
|
||||
char* arg1 = (char*)0;
|
||||
@@ -1251,23 +1251,23 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_udp_server(char* jarg1, int jarg2)
|
||||
int result;
|
||||
arg1 = (char*)jarg1;
|
||||
arg2 = (int)jarg2;
|
||||
result = (int)zts_simple_udp_server((char const*)arg1, arg2);
|
||||
result = (int)zts_udp_server((char const*)arg1, arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_udp_client(char* jarg1)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_udp_client(char* jarg1)
|
||||
{
|
||||
int jresult;
|
||||
char* arg1 = (char*)0;
|
||||
int result;
|
||||
arg1 = (char*)jarg1;
|
||||
result = (int)zts_simple_udp_client((char const*)arg1);
|
||||
result = (int)zts_udp_client((char const*)arg1);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_setsockopt(int jarg1, int jarg2, int jarg3, void* jarg4, unsigned short jarg5)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_setsockopt(int jarg1, int jarg2, int jarg3, void* jarg4, unsigned short jarg5)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1281,12 +1281,12 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_setsockopt(int jarg1, int jarg2, int jarg3
|
||||
arg3 = (int)jarg3;
|
||||
arg4 = (void*)jarg4;
|
||||
arg5 = (zts_socklen_t)jarg5;
|
||||
result = (int)zts_setsockopt(arg1, arg2, arg3, (void const*)arg4, arg5);
|
||||
result = (int)zts_bsd_setsockopt(arg1, arg2, arg3, (void const*)arg4, arg5);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_getsockopt(int jarg1, int jarg2, int jarg3, void* jarg4, void* jarg5)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_getsockopt(int jarg1, int jarg2, int jarg3, void* jarg4, void* jarg5)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1300,12 +1300,12 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_getsockopt(int jarg1, int jarg2, int jarg3
|
||||
arg3 = (int)jarg3;
|
||||
arg4 = (void*)jarg4;
|
||||
arg5 = (zts_socklen_t*)jarg5;
|
||||
result = (int)zts_getsockopt(arg1, arg2, arg3, arg4, arg5);
|
||||
result = (int)zts_bsd_getsockopt(arg1, arg2, arg3, arg4, arg5);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_getsockname(int jarg1, zts_sockaddr* jarg2, void* jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_getsockname(int jarg1, zts_sockaddr* jarg2, void* jarg3)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1315,12 +1315,12 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_getsockname(int jarg1, zts_sockaddr* jarg2
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (zts_sockaddr*)jarg2;
|
||||
arg3 = (zts_socklen_t*)jarg3;
|
||||
result = (int)zts_getsockname(arg1, arg2, arg3);
|
||||
result = (int)zts_bsd_getsockname(arg1, arg2, arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_getpeername(int jarg1, zts_sockaddr* jarg2, void* jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_getpeername(int jarg1, zts_sockaddr* jarg2, void* jarg3)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1330,23 +1330,23 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_getpeername(int jarg1, zts_sockaddr* jarg2
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (zts_sockaddr*)jarg2;
|
||||
arg3 = (zts_socklen_t*)jarg3;
|
||||
result = (int)zts_getpeername(arg1, arg2, arg3);
|
||||
result = (int)zts_bsd_getpeername(arg1, arg2, arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_close(int jarg1)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_close(int jarg1)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
result = (int)zts_close(arg1);
|
||||
result = (int)zts_bsd_close(arg1);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_select(int jarg1, void* jarg2, void* jarg3, void* jarg4, void* jarg5)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_select(int jarg1, void* jarg2, void* jarg3, void* jarg4, void* jarg5)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1360,12 +1360,12 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_select(int jarg1, void* jarg2, void* jarg3
|
||||
arg3 = (zts_fd_set*)jarg3;
|
||||
arg4 = (zts_fd_set*)jarg4;
|
||||
arg5 = (zts_timeval*)jarg5;
|
||||
result = (int)zts_select(arg1, arg2, arg3, arg4, arg5);
|
||||
result = (int)zts_bsd_select(arg1, arg2, arg3, arg4, arg5);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_fcntl(int jarg1, int jarg2, int jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_fcntl(int jarg1, int jarg2, int jarg3)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1375,12 +1375,12 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_fcntl(int jarg1, int jarg2, int jarg3)
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (int)jarg2;
|
||||
arg3 = (int)jarg3;
|
||||
result = (int)zts_fcntl(arg1, arg2, arg3);
|
||||
result = (int)zts_bsd_fcntl(arg1, arg2, arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_poll(void* jarg1, unsigned int jarg2, int jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_poll(void* jarg1, unsigned int jarg2, int jarg3)
|
||||
{
|
||||
int jresult;
|
||||
zts_pollfd* arg1 = (zts_pollfd*)0;
|
||||
@@ -1390,12 +1390,12 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_poll(void* jarg1, unsigned int jarg2, int
|
||||
arg1 = (zts_pollfd*)jarg1;
|
||||
arg2 = (zts_nfds_t)jarg2;
|
||||
arg3 = (int)jarg3;
|
||||
result = (int)zts_poll(arg1, arg2, arg3);
|
||||
result = (int)zts_bsd_poll(arg1, arg2, arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_ioctl(int jarg1, unsigned long jarg2, void* jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_ioctl(int jarg1, unsigned long jarg2, void* jarg3)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1405,12 +1405,12 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_ioctl(int jarg1, unsigned long jarg2, void
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (unsigned long)jarg2;
|
||||
arg3 = (void*)jarg3;
|
||||
result = (int)zts_ioctl(arg1, arg2, arg3);
|
||||
result = (int)zts_bsd_ioctl(arg1, arg2, arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_send(int jarg1, void* jarg2, unsigned long jarg3, int jarg4)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_send(int jarg1, void* jarg2, unsigned long jarg3, int jarg4)
|
||||
{
|
||||
int arg1;
|
||||
void* arg2 = (void*)0;
|
||||
@@ -1420,11 +1420,11 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_send(int jarg1, void* jarg2, unsigned long
|
||||
arg2 = (void*)jarg2;
|
||||
arg3 = (size_t)jarg3;
|
||||
arg4 = (int)jarg4;
|
||||
return zts_send(arg1, (void const*)arg2, arg3, arg4);
|
||||
return zts_bsd_send(arg1, (void const*)arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL
|
||||
CSharp_zts_sendto(int jarg1, void* jarg2, unsigned long jarg3, int jarg4, zts_sockaddr* jarg5, unsigned short jarg6)
|
||||
CSharp_zts_bsd_sendto(int jarg1, void* jarg2, unsigned long jarg3, int jarg4, zts_sockaddr* jarg5, unsigned short jarg6)
|
||||
{
|
||||
int arg1;
|
||||
void* arg2 = (void*)0;
|
||||
@@ -1438,7 +1438,7 @@ CSharp_zts_sendto(int jarg1, void* jarg2, unsigned long jarg3, int jarg4, zts_so
|
||||
arg4 = (int)jarg4;
|
||||
arg5 = (zts_sockaddr*)jarg5;
|
||||
arg6 = (zts_socklen_t)jarg6;
|
||||
return zts_sendto(arg1, (void const*)arg2, arg3, arg4, (zts_sockaddr const*)arg5, arg6);
|
||||
return zts_bsd_sendto(arg1, (void const*)arg2, arg3, arg4, (zts_sockaddr const*)arg5, arg6);
|
||||
}
|
||||
|
||||
SWIGEXPORT void* SWIGSTDCALL CSharp_new_zts_iovec()
|
||||
@@ -1451,7 +1451,7 @@ SWIGEXPORT void* SWIGSTDCALL CSharp_new_zts_iovec()
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_sendmsg(int jarg1, void* jarg2, int jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_sendmsg(int jarg1, void* jarg2, int jarg3)
|
||||
{
|
||||
int arg1;
|
||||
zts_msghdr* arg2 = (zts_msghdr*)0;
|
||||
@@ -1459,10 +1459,10 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_sendmsg(int jarg1, void* jarg2, int jarg3)
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (zts_msghdr*)jarg2;
|
||||
arg3 = (int)jarg3;
|
||||
return zts_sendmsg(arg1, (zts_msghdr const*)arg2, arg3);
|
||||
return zts_bsd_sendmsg(arg1, (zts_msghdr const*)arg2, arg3);
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_recv(int jarg1, void* jarg2, unsigned long jarg3, int jarg4)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_recv(int jarg1, void* jarg2, unsigned long jarg3, int jarg4)
|
||||
{
|
||||
int arg1;
|
||||
void* arg2 = (void*)0;
|
||||
@@ -1472,11 +1472,11 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_recv(int jarg1, void* jarg2, unsigned long
|
||||
arg2 = (void*)jarg2;
|
||||
arg3 = (size_t)jarg3;
|
||||
arg4 = (int)jarg4;
|
||||
return zts_recv(arg1, arg2, arg3, arg4);
|
||||
return zts_bsd_recv(arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL
|
||||
CSharp_zts_recvfrom(int jarg1, void* jarg2, unsigned long jarg3, int jarg4, zts_sockaddr* jarg5, void* jarg6)
|
||||
CSharp_zts_bsd_recvfrom(int jarg1, void* jarg2, unsigned long jarg3, int jarg4, zts_sockaddr* jarg5, void* jarg6)
|
||||
{
|
||||
int arg1;
|
||||
void* arg2 = (void*)0;
|
||||
@@ -1490,10 +1490,10 @@ CSharp_zts_recvfrom(int jarg1, void* jarg2, unsigned long jarg3, int jarg4, zts_
|
||||
arg4 = (int)jarg4;
|
||||
arg5 = (zts_sockaddr*)jarg5;
|
||||
arg6 = (zts_socklen_t*)jarg6;
|
||||
return zts_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6);
|
||||
return zts_bsd_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6);
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_recvmsg(int jarg1, void* jarg2, int jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_recvmsg(int jarg1, void* jarg2, int jarg3)
|
||||
{
|
||||
int arg1;
|
||||
zts_msghdr* arg2 = (zts_msghdr*)0;
|
||||
@@ -1501,10 +1501,10 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_recvmsg(int jarg1, void* jarg2, int jarg3)
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (zts_msghdr*)jarg2;
|
||||
arg3 = (int)jarg3;
|
||||
return zts_recvmsg(arg1, arg2, arg3);
|
||||
return zts_bsd_recvmsg(arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_read(int jarg1, void* jarg2, unsigned long jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_read(int jarg1, void* jarg2, unsigned long jarg3)
|
||||
{
|
||||
int arg1;
|
||||
void* arg2 = (void*)0;
|
||||
@@ -1512,10 +1512,10 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_read(int jarg1, void* jarg2, unsigned long
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (void*)jarg2;
|
||||
arg3 = (size_t)jarg3;
|
||||
return zts_read(arg1, arg2, arg3);
|
||||
return zts_bsd_read(arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_readv(int jarg1, void* jarg2, int jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_readv(int jarg1, void* jarg2, int jarg3)
|
||||
{
|
||||
int arg1;
|
||||
zts_iovec* arg2 = (zts_iovec*)0;
|
||||
@@ -1523,10 +1523,10 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_readv(int jarg1, void* jarg2, int jarg3)
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (zts_iovec*)jarg2;
|
||||
arg3 = (int)jarg3;
|
||||
return zts_readv(arg1, (zts_iovec const*)arg2, arg3);
|
||||
return zts_bsd_readv(arg1, (zts_iovec const*)arg2, arg3);
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_write(int jarg1, void* jarg2, unsigned long jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_write(int jarg1, void* jarg2, unsigned long jarg3)
|
||||
{
|
||||
int arg1;
|
||||
void* arg2 = (void*)0;
|
||||
@@ -1534,10 +1534,10 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_write(int jarg1, void* jarg2, unsigned lon
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (void*)jarg2;
|
||||
arg3 = (size_t)jarg3;
|
||||
return zts_write(arg1, (void const*)arg2, arg3);
|
||||
return zts_bsd_write(arg1, (void const*)arg2, arg3);
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_writev(int jarg1, void* jarg2, int jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_writev(int jarg1, void* jarg2, int jarg3)
|
||||
{
|
||||
int arg1;
|
||||
zts_iovec* arg2 = (zts_iovec*)0;
|
||||
@@ -1545,10 +1545,10 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_writev(int jarg1, void* jarg2, int jarg3)
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (zts_iovec*)jarg2;
|
||||
arg3 = (int)jarg3;
|
||||
return zts_writev(arg1, (zts_iovec const*)arg2, arg3);
|
||||
return zts_bsd_writev(arg1, (zts_iovec const*)arg2, arg3);
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_shutdown(int jarg1, int jarg2)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_bsd_shutdown(int jarg1, int jarg2)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1556,12 +1556,12 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_shutdown(int jarg1, int jarg2)
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (int)jarg2;
|
||||
result = (int)zts_shutdown(arg1, arg2);
|
||||
result = (int)zts_bsd_shutdown(arg1, arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_no_delay(int jarg1, int jarg2)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_set_no_delay(int jarg1, int jarg2)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1569,23 +1569,23 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_no_delay(int jarg1, int jarg2)
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (int)jarg2;
|
||||
result = (int)zts_simple_set_no_delay(arg1, arg2);
|
||||
result = (int)zts_set_no_delay(arg1, arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_get_no_delay(int jarg1)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_get_no_delay(int jarg1)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
result = (int)zts_simple_get_no_delay(arg1);
|
||||
result = (int)zts_get_no_delay(arg1);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_linger(int jarg1, int jarg2, int jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_set_linger(int jarg1, int jarg2, int jarg3)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1595,34 +1595,34 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_linger(int jarg1, int jarg2, in
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (int)jarg2;
|
||||
arg3 = (int)jarg3;
|
||||
result = (int)zts_simple_set_linger(arg1, arg2, arg3);
|
||||
result = (int)zts_set_linger(arg1, arg2, arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_get_linger_enabled(int jarg1)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_get_linger_enabled(int jarg1)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
result = (int)zts_simple_get_linger_enabled(arg1);
|
||||
result = (int)zts_get_linger_enabled(arg1);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_get_linger_value(int jarg1)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_get_linger_value(int jarg1)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
result = (int)zts_simple_get_linger_value(arg1);
|
||||
result = (int)zts_get_linger_value(arg1);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_reuse_addr(int jarg1, int jarg2)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_set_reuse_addr(int jarg1, int jarg2)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1630,23 +1630,23 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_reuse_addr(int jarg1, int jarg2
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (int)jarg2;
|
||||
result = (int)zts_simple_set_reuse_addr(arg1, arg2);
|
||||
result = (int)zts_set_reuse_addr(arg1, arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_get_reuse_addr(int jarg1)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_get_reuse_addr(int jarg1)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
result = (int)zts_simple_get_reuse_addr(arg1);
|
||||
result = (int)zts_get_reuse_addr(arg1);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_recv_timeout(int jarg1, int jarg2, int jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_set_recv_timeout(int jarg1, int jarg2, int jarg3)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1656,23 +1656,23 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_recv_timeout(int jarg1, int jar
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (int)jarg2;
|
||||
arg3 = (int)jarg3;
|
||||
result = (int)zts_simple_set_recv_timeout(arg1, arg2, arg3);
|
||||
result = (int)zts_set_recv_timeout(arg1, arg2, arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_get_recv_timeout(int jarg1)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_get_recv_timeout(int jarg1)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
result = (int)zts_simple_get_recv_timeout(arg1);
|
||||
result = (int)zts_get_recv_timeout(arg1);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_send_timeout(int jarg1, int jarg2, int jarg3)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_set_send_timeout(int jarg1, int jarg2, int jarg3)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1682,23 +1682,23 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_send_timeout(int jarg1, int jar
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (int)jarg2;
|
||||
arg3 = (int)jarg3;
|
||||
result = (int)zts_simple_set_send_timeout(arg1, arg2, arg3);
|
||||
result = (int)zts_set_send_timeout(arg1, arg2, arg3);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_get_send_timeout(int jarg1)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_get_send_timeout(int jarg1)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
result = (int)zts_simple_get_send_timeout(arg1);
|
||||
result = (int)zts_get_send_timeout(arg1);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_send_buf_size(int jarg1, int jarg2)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_set_send_buf_size(int jarg1, int jarg2)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1706,23 +1706,23 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_send_buf_size(int jarg1, int ja
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (int)jarg2;
|
||||
result = (int)zts_simple_set_send_buf_size(arg1, arg2);
|
||||
result = (int)zts_set_send_buf_size(arg1, arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_get_send_buf_size(int jarg1)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_get_send_buf_size(int jarg1)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
result = (int)zts_simple_get_send_buf_size(arg1);
|
||||
result = (int)zts_get_send_buf_size(arg1);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_recv_buf_size(int jarg1, int jarg2)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_set_recv_buf_size(int jarg1, int jarg2)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1730,23 +1730,23 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_recv_buf_size(int jarg1, int ja
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (int)jarg2;
|
||||
result = (int)zts_simple_set_recv_buf_size(arg1, arg2);
|
||||
result = (int)zts_set_recv_buf_size(arg1, arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_get_recv_buf_size(int jarg1)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_get_recv_buf_size(int jarg1)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
result = (int)zts_simple_get_recv_buf_size(arg1);
|
||||
result = (int)zts_get_recv_buf_size(arg1);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_ttl(int jarg1, int jarg2)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_set_ttl(int jarg1, int jarg2)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1754,23 +1754,23 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_ttl(int jarg1, int jarg2)
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (int)jarg2;
|
||||
result = (int)zts_simple_set_ttl(arg1, arg2);
|
||||
result = (int)zts_set_ttl(arg1, arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_get_ttl(int jarg1)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_get_ttl(int jarg1)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
result = (int)zts_simple_get_ttl(arg1);
|
||||
result = (int)zts_get_ttl(arg1);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_blocking(int jarg1, int jarg2)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_set_blocking(int jarg1, int jarg2)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1778,23 +1778,23 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_blocking(int jarg1, int jarg2)
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (int)jarg2;
|
||||
result = (int)zts_simple_set_blocking(arg1, arg2);
|
||||
result = (int)zts_set_blocking(arg1, arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_get_blocking(int jarg1)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_get_blocking(int jarg1)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
result = (int)zts_simple_get_blocking(arg1);
|
||||
result = (int)zts_get_blocking(arg1);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_keepalive(int jarg1, int jarg2)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_set_keepalive(int jarg1, int jarg2)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
@@ -1802,29 +1802,29 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_set_keepalive(int jarg1, int jarg2)
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (int)jarg2;
|
||||
result = (int)zts_simple_set_keepalive(arg1, arg2);
|
||||
result = (int)zts_set_keepalive(arg1, arg2);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_simple_get_keepalive(int jarg1)
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_get_keepalive(int jarg1)
|
||||
{
|
||||
int jresult;
|
||||
int arg1;
|
||||
int result;
|
||||
arg1 = (int)jarg1;
|
||||
result = (int)zts_simple_get_keepalive(arg1);
|
||||
result = (int)zts_get_keepalive(arg1);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
SWIGEXPORT void* SWIGSTDCALL CSharp_zts_gethostbyname(char* jarg1)
|
||||
SWIGEXPORT void* SWIGSTDCALL CSharp_zts_bsd_gethostbyname(char* jarg1)
|
||||
{
|
||||
void* jresult;
|
||||
char* arg1 = (char*)0;
|
||||
zts_hostent* result = 0;
|
||||
arg1 = (char*)jarg1;
|
||||
result = (zts_hostent*)zts_gethostbyname((char const*)arg1);
|
||||
result = (zts_hostent*)zts_bsd_gethostbyname((char const*)arg1);
|
||||
jresult = (void*)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
265
src/bindings/csharp/Socket.cs
Executable file → Normal file
265
src/bindings/csharp/Socket.cs
Executable file → Normal file
@@ -91,7 +91,7 @@ namespace ZeroTier.Sockets
|
||||
protocol = 0; // ?
|
||||
break;
|
||||
}
|
||||
if ((_fd = zts_socket(family, type, protocol)) < 0) {
|
||||
if ((_fd = zts_bsd_socket(family, type, protocol)) < 0) {
|
||||
throw new ZeroTier.Sockets.SocketException((int)_fd);
|
||||
}
|
||||
_socketFamily = addressFamily;
|
||||
@@ -129,11 +129,7 @@ namespace ZeroTier.Sockets
|
||||
if (remoteEndPoint == null) {
|
||||
throw new ArgumentNullException("remoteEndPoint");
|
||||
}
|
||||
int err = zts_simple_connect(
|
||||
_fd,
|
||||
remoteEndPoint.Address.ToString(),
|
||||
(ushort)remoteEndPoint.Port,
|
||||
_connectTimeout);
|
||||
int err = zts_connect(_fd, remoteEndPoint.Address.ToString(), (ushort)remoteEndPoint.Port, _connectTimeout);
|
||||
if (err < 0) {
|
||||
throw new ZeroTier.Sockets.SocketException(err, ZeroTier.Core.Node.ErrNo);
|
||||
}
|
||||
@@ -155,11 +151,11 @@ namespace ZeroTier.Sockets
|
||||
}
|
||||
int err = Constants.ERR_OK;
|
||||
if (localEndPoint.AddressFamily == AddressFamily.InterNetwork) {
|
||||
err = zts_simple_bind(_fd, "0.0.0.0", (ushort)localEndPoint.Port);
|
||||
err = zts_bind(_fd, "0.0.0.0", (ushort)localEndPoint.Port);
|
||||
}
|
||||
if (localEndPoint.AddressFamily == AddressFamily.InterNetworkV6) {
|
||||
// Todo: detect IPAddress.IPv6Any
|
||||
err = zts_simple_bind(_fd, "::", (ushort)localEndPoint.Port);
|
||||
err = zts_bind(_fd, "::", (ushort)localEndPoint.Port);
|
||||
}
|
||||
if (err < 0) {
|
||||
throw new ZeroTier.Sockets.SocketException((int)err);
|
||||
@@ -178,7 +174,7 @@ namespace ZeroTier.Sockets
|
||||
throw new ZeroTier.Sockets.SocketException((int)Constants.ERR_SOCKET);
|
||||
}
|
||||
int err = Constants.ERR_OK;
|
||||
if ((err = zts_listen(_fd, backlog)) < 0) {
|
||||
if ((err = zts_bsd_listen(_fd, backlog)) < 0) {
|
||||
// Invalid backlog value perhaps?
|
||||
throw new ZeroTier.Sockets.SocketException((int)Constants.ERR_SOCKET);
|
||||
}
|
||||
@@ -199,14 +195,14 @@ namespace ZeroTier.Sockets
|
||||
}
|
||||
IntPtr lpBuffer = Marshal.AllocHGlobal(ZeroTier.Constants.INET6_ADDRSTRLEN);
|
||||
int port = 0;
|
||||
int accepted_fd = zts_simple_accept(_fd, lpBuffer, ZeroTier.Constants.INET6_ADDRSTRLEN, ref port);
|
||||
int accepted_fd = zts_accept(_fd, lpBuffer, ZeroTier.Constants.INET6_ADDRSTRLEN, ref port);
|
||||
// Convert buffer to managed string
|
||||
string str = Marshal.PtrToStringAnsi(lpBuffer);
|
||||
Marshal.FreeHGlobal(lpBuffer);
|
||||
lpBuffer = IntPtr.Zero;
|
||||
IPEndPoint clientEndPoint = new IPEndPoint(IPAddress.Parse(str), port);
|
||||
Console.WriteLine("clientEndPoint = " + clientEndPoint.ToString());
|
||||
// Create new socket by providing file descriptor returned from zts_accept call.
|
||||
// Create new socket by providing file descriptor returned from zts_bsd_accept call.
|
||||
Socket clientSocket =
|
||||
new Socket(accepted_fd, _socketFamily, _socketType, _socketProtocol, _localEndPoint, clientEndPoint);
|
||||
return clientSocket;
|
||||
@@ -229,7 +225,7 @@ namespace ZeroTier.Sockets
|
||||
ztHow = Constants.O_RDWR;
|
||||
break;
|
||||
}
|
||||
zts_shutdown(_fd, ztHow);
|
||||
zts_bsd_shutdown(_fd, ztHow);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
@@ -237,17 +233,17 @@ namespace ZeroTier.Sockets
|
||||
if (_isClosed) {
|
||||
throw new ObjectDisposedException("Socket has already been closed");
|
||||
}
|
||||
zts_close(_fd);
|
||||
zts_bsd_close(_fd);
|
||||
_isClosed = true;
|
||||
}
|
||||
|
||||
public bool Blocking
|
||||
{
|
||||
get {
|
||||
return Convert.ToBoolean(zts_simple_get_blocking(_fd));
|
||||
return Convert.ToBoolean(zts_get_blocking(_fd));
|
||||
}
|
||||
set {
|
||||
zts_simple_set_blocking(_fd, Convert.ToInt32(value));
|
||||
zts_set_blocking(_fd, Convert.ToInt32(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +268,7 @@ namespace ZeroTier.Sockets
|
||||
int result = 0;
|
||||
int timeout_ms = (microSeconds / 1000);
|
||||
uint numfds = 1;
|
||||
if ((result = zts_poll(poll_fd_ptr, numfds, timeout_ms)) < 0) {
|
||||
if ((result = zts_bsd_poll(poll_fd_ptr, numfds, timeout_ms)) < 0) {
|
||||
throw new ZeroTier.Sockets.SocketException(result, ZeroTier.Core.Node.ErrNo);
|
||||
}
|
||||
poll_set = (zts_pollfd)Marshal.PtrToStructure(poll_fd_ptr, typeof(zts_pollfd));
|
||||
@@ -306,7 +302,7 @@ namespace ZeroTier.Sockets
|
||||
}
|
||||
int flags = 0;
|
||||
IntPtr bufferPtr = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0);
|
||||
return zts_send(_fd, bufferPtr, (uint)Buffer.ByteLength(buffer), (int)flags);
|
||||
return zts_bsd_send(_fd, bufferPtr, (uint)Buffer.ByteLength(buffer), (int)flags);
|
||||
}
|
||||
|
||||
public Int32 Receive(Byte[] buffer)
|
||||
@@ -322,7 +318,7 @@ namespace ZeroTier.Sockets
|
||||
}
|
||||
int flags = 0;
|
||||
IntPtr bufferPtr = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0);
|
||||
return zts_recv(_fd, bufferPtr, (uint)Buffer.ByteLength(buffer), (int)flags);
|
||||
return zts_bsd_recv(_fd, bufferPtr, (uint)Buffer.ByteLength(buffer), (int)flags);
|
||||
}
|
||||
|
||||
public int ReceiveTimeout
|
||||
@@ -490,11 +486,11 @@ namespace ZeroTier.Sockets
|
||||
[DllImport(
|
||||
"libzt",
|
||||
CharSet = CharSet.Ansi,
|
||||
EntryPoint = "CSharp_zts_gethostbyname")] public static extern global::System.IntPtr
|
||||
zts_gethostbyname(string jarg1);
|
||||
EntryPoint = "CSharp_zts_bsd_gethostbyname")] public static extern global::System.IntPtr
|
||||
zts_bsd_gethostbyname(string jarg1);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_select")]
|
||||
static extern int zts_select(
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_select")]
|
||||
static extern int zts_bsd_select(
|
||||
int jarg1,
|
||||
global::System.Runtime.InteropServices.HandleRef jarg2,
|
||||
global::System.Runtime.InteropServices.HandleRef jarg3,
|
||||
@@ -507,86 +503,86 @@ namespace ZeroTier.Sockets
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_get_protocol_stats")]
|
||||
static extern int zts_get_protocol_stats(int arg1, IntPtr arg2);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_socket")]
|
||||
static extern int zts_socket(int arg1, int arg2, int arg3);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_socket")]
|
||||
static extern int zts_bsd_socket(int arg1, int arg2, int arg3);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_connect")]
|
||||
static extern int zts_connect(int arg1, IntPtr arg2, ushort arg3);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_connect")]
|
||||
static extern int zts_bsd_connect(int arg1, IntPtr arg2, ushort arg3);
|
||||
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_connect_easy")]
|
||||
static extern int zts_connect_easy(int arg1, int arg2, string arg3, ushort arg4, int arg5);
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_bsd_connect_easy")]
|
||||
static extern int zts_bsd_connect_easy(int arg1, int arg2, string arg3, ushort arg4, int arg5);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bind")]
|
||||
static extern int zts_bind(int arg1, IntPtr arg2, ushort arg3);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_bind")]
|
||||
static extern int zts_bsd_bind(int arg1, IntPtr arg2, ushort arg3);
|
||||
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_bind_easy")]
|
||||
static extern int zts_bind_easy(int arg1, int arg2, string arg3, ushort arg4);
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_bsd_bind_easy")]
|
||||
static extern int zts_bsd_bind_easy(int arg1, int arg2, string arg3, ushort arg4);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_listen")]
|
||||
static extern int zts_listen(int arg1, int arg2);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_listen")]
|
||||
static extern int zts_bsd_listen(int arg1, int arg2);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_accept")]
|
||||
static extern int zts_accept(int arg1, IntPtr arg2, IntPtr arg3);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_accept")]
|
||||
static extern int zts_bsd_accept(int arg1, IntPtr arg2, IntPtr arg3);
|
||||
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_accept_easy")]
|
||||
static extern int zts_accept_easy(int arg1, IntPtr remoteAddrStr, int arg2, ref int arg3);
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_bsd_accept_easy")]
|
||||
static extern int zts_bsd_accept_easy(int arg1, IntPtr remoteAddrStr, int arg2, ref int arg3);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_setsockopt")]
|
||||
static extern int zts_setsockopt(int arg1, int arg2, int arg3, IntPtr arg4, ushort arg5);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_setsockopt")]
|
||||
static extern int zts_bsd_setsockopt(int arg1, int arg2, int arg3, IntPtr arg4, ushort arg5);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_getsockopt")]
|
||||
static extern int zts_getsockopt(int arg1, int arg2, int arg3, IntPtr arg4, IntPtr arg5);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_getsockopt")]
|
||||
static extern int zts_bsd_getsockopt(int arg1, int arg2, int arg3, IntPtr arg4, IntPtr arg5);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_getsockname")]
|
||||
static extern int zts_getsockname(int arg1, IntPtr arg2, IntPtr arg3);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_getsockname")]
|
||||
static extern int zts_bsd_getsockname(int arg1, IntPtr arg2, IntPtr arg3);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_getpeername")]
|
||||
static extern int zts_getpeername(int arg1, IntPtr arg2, IntPtr arg3);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_getpeername")]
|
||||
static extern int zts_bsd_getpeername(int arg1, IntPtr arg2, IntPtr arg3);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_close")]
|
||||
static extern int zts_close(int arg1);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_close")]
|
||||
static extern int zts_bsd_close(int arg1);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_fcntl")]
|
||||
static extern int zts_fcntl(int arg1, int arg2, int arg3);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_fcntl")]
|
||||
static extern int zts_bsd_fcntl(int arg1, int arg2, int arg3);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_poll")]
|
||||
static extern int zts_poll(IntPtr arg1, uint arg2, int arg3);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_poll")]
|
||||
static extern int zts_bsd_poll(IntPtr arg1, uint arg2, int arg3);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_ioctl")]
|
||||
static extern int zts_ioctl(int arg1, uint arg2, IntPtr arg3);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_ioctl")]
|
||||
static extern int zts_bsd_ioctl(int arg1, uint arg2, IntPtr arg3);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_send")]
|
||||
static extern int zts_send(int arg1, IntPtr arg2, uint arg3, int arg4);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_send")]
|
||||
static extern int zts_bsd_send(int arg1, IntPtr arg2, uint arg3, int arg4);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_sendto")]
|
||||
static extern int zts_sendto(int arg1, IntPtr arg2, uint arg3, int arg4, IntPtr arg5, ushort arg6);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_sendto")]
|
||||
static extern int zts_bsd_sendto(int arg1, IntPtr arg2, uint arg3, int arg4, IntPtr arg5, ushort arg6);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_sendmsg")]
|
||||
static extern int zts_sendmsg(int arg1, IntPtr arg2, int arg3);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_sendmsg")]
|
||||
static extern int zts_bsd_sendmsg(int arg1, IntPtr arg2, int arg3);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_recv")]
|
||||
static extern int zts_recv(int arg1, IntPtr arg2, uint arg3, int arg4);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_recv")]
|
||||
static extern int zts_bsd_recv(int arg1, IntPtr arg2, uint arg3, int arg4);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_recvfrom")]
|
||||
static extern int zts_recvfrom(int arg1, IntPtr arg2, uint arg3, int arg4, IntPtr arg5, IntPtr arg6);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_recvfrom")]
|
||||
static extern int zts_bsd_recvfrom(int arg1, IntPtr arg2, uint arg3, int arg4, IntPtr arg5, IntPtr arg6);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_recvmsg")]
|
||||
static extern int zts_recvmsg(int arg1, IntPtr arg2, int arg3);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_recvmsg")]
|
||||
static extern int zts_bsd_recvmsg(int arg1, IntPtr arg2, int arg3);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_read")]
|
||||
static extern int zts_read(int arg1, IntPtr arg2, uint arg3);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_read")]
|
||||
static extern int zts_bsd_read(int arg1, IntPtr arg2, uint arg3);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_readv")]
|
||||
static extern int zts_readv(int arg1, IntPtr arg2, int arg3);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_readv")]
|
||||
static extern int zts_bsd_readv(int arg1, IntPtr arg2, int arg3);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_write")]
|
||||
static extern int zts_write(int arg1, IntPtr arg2, uint arg3);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_write")]
|
||||
static extern int zts_bsd_write(int arg1, IntPtr arg2, uint arg3);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_writev")]
|
||||
static extern int zts_writev(int arg1, IntPtr arg2, int arg3);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_writev")]
|
||||
static extern int zts_bsd_writev(int arg1, IntPtr arg2, int arg3);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_shutdown")]
|
||||
static extern int zts_shutdown(int arg1, int arg2);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_shutdown")]
|
||||
static extern int zts_bsd_shutdown(int arg1, int arg2);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_set_no_delay")]
|
||||
static extern int zts_set_no_delay(int fd, int enabled);
|
||||
@@ -660,97 +656,102 @@ namespace ZeroTier.Sockets
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_errno_get")]
|
||||
static extern int zts_errno_get();
|
||||
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_simple_accept")]
|
||||
static extern int zts_simple_accept(int jarg1, IntPtr jarg2, int jarg3, ref int jarg4);
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_accept")]
|
||||
static extern int zts_accept(int jarg1, IntPtr jarg2, int jarg3, ref int jarg4);
|
||||
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_simple_tcp_client")]
|
||||
static extern int zts_simple_tcp_client(string jarg1, int jarg2);
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_tcp_client")]
|
||||
static extern int zts_tcp_client(string jarg1, int jarg2);
|
||||
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_simple_tcp_server")]
|
||||
static extern int zts_simple_tcp_server(
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_tcp_server")]
|
||||
static extern int zts_tcp_server(
|
||||
string jarg1,
|
||||
int jarg2,
|
||||
string jarg3,
|
||||
int jarg4,
|
||||
global::System.Runtime.InteropServices.HandleRef jarg5);
|
||||
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_simple_udp_server")]
|
||||
static extern int zts_simple_udp_server(string jarg1, int jarg2);
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_udp_server")]
|
||||
static extern int zts_udp_server(string jarg1, int jarg2);
|
||||
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_simple_udp_client")]
|
||||
static extern int zts_simple_udp_client(string jarg1);
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_udp_client")]
|
||||
static extern int zts_udp_client(string jarg1);
|
||||
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_simple_bind")]
|
||||
static extern int zts_simple_bind(int jarg1, string jarg2, int jarg3);
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_bind")]
|
||||
static extern int zts_bind(int jarg1, string jarg2, int jarg3);
|
||||
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_simple_connect")]
|
||||
static extern int zts_simple_connect(int jarg1, string jarg2, int jarg3, int jarg4);
|
||||
[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_connect")]
|
||||
static extern int zts_connect(int jarg1, string jarg2, int jarg3, int jarg4);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_stats_get_all")]
|
||||
static extern int zts_stats_get_all(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_set_no_delay")]
|
||||
static extern int zts_simple_set_no_delay(int jarg1, int jarg2);
|
||||
/*
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_set_no_delay")]
|
||||
static extern int zts_set_no_delay(int jarg1, int jarg2);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_get_no_delay")]
|
||||
static extern int zts_simple_get_no_delay(int jarg1);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_get_no_delay")]
|
||||
static extern int zts_get_no_delay(int jarg1);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_set_linger")]
|
||||
static extern int zts_simple_set_linger(int jarg1, int jarg2, int jarg3);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_set_linger")]
|
||||
static extern int zts_set_linger(int jarg1, int jarg2, int jarg3);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_get_linger_enabled")]
|
||||
static extern int zts_simple_get_linger_enabled(int jarg1);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_get_linger_enabled")]
|
||||
static extern int zts_get_linger_enabled(int jarg1);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_get_linger_value")]
|
||||
static extern int zts_simple_get_linger_value(int jarg1);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_get_linger_value")]
|
||||
static extern int zts_get_linger_value(int jarg1);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_set_reuse_addr")]
|
||||
static extern int zts_simple_set_reuse_addr(int jarg1, int jarg2);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_set_reuse_addr")]
|
||||
static extern int zts_set_reuse_addr(int jarg1, int jarg2);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_get_reuse_addr")]
|
||||
static extern int zts_simple_get_reuse_addr(int jarg1);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_get_reuse_addr")]
|
||||
static extern int zts_get_reuse_addr(int jarg1);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_set_recv_timeout")]
|
||||
static extern int zts_simple_set_recv_timeout(int jarg1, int jarg2, int jarg3);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_set_recv_timeout")]
|
||||
static extern int zts_set_recv_timeout(int jarg1, int jarg2, int jarg3);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_get_recv_timeout")]
|
||||
static extern int zts_simple_get_recv_timeout(int jarg1);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_get_recv_timeout")]
|
||||
static extern int zts_get_recv_timeout(int jarg1);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_set_send_timeout")]
|
||||
static extern int zts_simple_set_send_timeout(int jarg1, int jarg2, int jarg3);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_set_send_timeout")]
|
||||
static extern int zts_set_send_timeout(int jarg1, int jarg2, int jarg3);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_get_send_timeout")]
|
||||
static extern int zts_simple_get_send_timeout(int jarg1);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_get_send_timeout")]
|
||||
static extern int zts_get_send_timeout(int jarg1);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_set_send_buf_size")]
|
||||
static extern int zts_simple_set_send_buf_size(int jarg1, int jarg2);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_set_send_buf_size")]
|
||||
static extern int zts_set_send_buf_size(int jarg1, int jarg2);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_get_send_buf_size")]
|
||||
static extern int zts_simple_get_send_buf_size(int jarg1);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_get_send_buf_size")]
|
||||
static extern int zts_get_send_buf_size(int jarg1);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_set_recv_buf_size")]
|
||||
static extern int zts_simple_set_recv_buf_size(int jarg1, int jarg2);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_set_recv_buf_size")]
|
||||
static extern int zts_set_recv_buf_size(int jarg1, int jarg2);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_get_recv_buf_size")]
|
||||
static extern int zts_simple_get_recv_buf_size(int jarg1);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_get_recv_buf_size")]
|
||||
static extern int zts_get_recv_buf_size(int jarg1);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_set_ttl")]
|
||||
static extern int zts_simple_set_ttl(int jarg1, int jarg2);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_set_ttl")]
|
||||
static extern int zts_set_ttl(int jarg1, int jarg2);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_get_ttl")]
|
||||
static extern int zts_simple_get_ttl(int jarg1);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_get_ttl")]
|
||||
static extern int zts_get_ttl(int jarg1);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_set_blocking")]
|
||||
static extern int zts_simple_set_blocking(int jarg1, int jarg2);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_set_blocking")]
|
||||
static extern int zts_set_blocking(int jarg1, int jarg2);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_get_blocking")]
|
||||
static extern int zts_simple_get_blocking(int jarg1);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_get_blocking")]
|
||||
static extern int zts_get_blocking(int jarg1);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_set_keepalive")]
|
||||
static extern int zts_simple_set_keepalive(int jarg1, int jarg2);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_set_keepalive")]
|
||||
static extern int zts_set_keepalive(int jarg1, int jarg2);
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_simple_get_keepalive")]
|
||||
static extern int zts_simple_get_keepalive(int jarg1);
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_get_keepalive")]
|
||||
static extern int zts_get_keepalive(int jarg1);
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
[DllImport("libzt", EntryPoint = "CSharp_zts_util_delay")]
|
||||
public static extern void zts_util_delay(int jarg1);
|
||||
|
||||
@@ -59,54 +59,58 @@ JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1init(JNIEnv* en
|
||||
return rs != JNI_OK ? ZTS_ERR_GENERAL : ZTS_ERR_OK;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1socket(JNIEnv* env, jobject thisObj, jint family, jint type, jint protocol)
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1socket(
|
||||
JNIEnv* env,
|
||||
jobject thisObj,
|
||||
jint family,
|
||||
jint type,
|
||||
jint protocol)
|
||||
{
|
||||
int retval = zts_socket(family, type, protocol);
|
||||
int retval = zts_bsd_socket(family, type, protocol);
|
||||
return retval > -1 ? retval : -(zts_errno); // Encode lwIP errno into return value for JNI functions only
|
||||
}
|
||||
|
||||
/*
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1connect(JNIEnv* env, jobject thisObj, jint fd, jobject addr)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1connect(JNIEnv* env, jobject thisObj, jint fd, jobject addr)
|
||||
{
|
||||
struct zts_sockaddr_storage ss;
|
||||
zta2ss(env, &ss, addr);
|
||||
socklen_t addrlen = ss.ss_family == ZTS_AF_INET ? sizeof(struct zts_sockaddr_in) : sizeof(struct zts_sockaddr_in6);
|
||||
int retval = zts_connect(fd, (struct zts_sockaddr*)&ss, addrlen);
|
||||
int retval = zts_bsd_connect(fd, (struct zts_sockaddr*)&ss, addrlen);
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1bind(JNIEnv* env, jobject thisObj, jint fd, jobject addr)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1bind(JNIEnv* env, jobject thisObj, jint fd, jobject addr)
|
||||
{
|
||||
struct zts_sockaddr_storage ss;
|
||||
zta2ss(env, &ss, addr);
|
||||
zts_socklen_t addrlen =
|
||||
ss.ss_family == ZTS_AF_INET ? sizeof(struct zts_sockaddr_in) : sizeof(struct zts_sockaddr_in6);
|
||||
int retval = zts_bind(fd, (struct zts_sockaddr*)&ss, addrlen);
|
||||
int retval = zts_bsd_bind(fd, (struct zts_sockaddr*)&ss, addrlen);
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
*/
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1listen(JNIEnv* env, jobject thisObj, jint fd, int backlog)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1listen(JNIEnv* env, jobject thisObj, jint fd, int backlog)
|
||||
{
|
||||
int retval = zts_listen(fd, backlog);
|
||||
int retval = zts_bsd_listen(fd, backlog);
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1accept(JNIEnv* env, jobject thisObj, jint fd, jobject addr, jint port)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1accept(JNIEnv* env, jobject thisObj, jint fd, jobject addr, jint port)
|
||||
{
|
||||
struct zts_sockaddr_storage ss;
|
||||
zts_socklen_t addrlen = sizeof(struct zts_sockaddr_storage);
|
||||
int retval = zts_accept(fd, (zts_sockaddr*)&ss, &addrlen);
|
||||
int retval = zts_bsd_accept(fd, (zts_sockaddr*)&ss, &addrlen);
|
||||
ss2zta(env, &ss, addr);
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
/*
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1setsockopt(
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1setsockopt(
|
||||
JNIEnv* env,
|
||||
jobject thisObj,
|
||||
jint fd,
|
||||
@@ -138,15 +142,15 @@ JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1setsockopt(
|
||||
// Convert milliseconds from setSoTimeout() call to seconds and microseconds
|
||||
tv.tv_usec = optval_int * 1000;
|
||||
tv.tv_sec = optval_int / 1000000;
|
||||
retval = zts_setsockopt(fd, level, optname, &tv, sizeof(tv));
|
||||
retval = zts_bsd_setsockopt(fd, level, optname, &tv, sizeof(tv));
|
||||
}
|
||||
else {
|
||||
retval = zts_setsockopt(fd, level, optname, &optval_int, sizeof(optval_int));
|
||||
retval = zts_bsd_setsockopt(fd, level, optname, &optval_int, sizeof(optval_int));
|
||||
}
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1getsockopt(
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1getsockopt(
|
||||
JNIEnv* env,
|
||||
jobject thisObj,
|
||||
jint fd,
|
||||
@@ -166,12 +170,12 @@ JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1getsockopt(
|
||||
if (optname == SO_RCVTIMEO) {
|
||||
struct zts_timeval tv;
|
||||
optlen = sizeof(tv);
|
||||
retval = zts_getsockopt(fd, level, optname, &tv, &optlen);
|
||||
retval = zts_bsd_getsockopt(fd, level, optname, &tv, &optlen);
|
||||
// Convert seconds and microseconds back to milliseconds
|
||||
optval_int = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
|
||||
}
|
||||
else {
|
||||
retval = zts_getsockopt(fd, level, optname, &optval_int, &optlen);
|
||||
retval = zts_bsd_getsockopt(fd, level, optname, &optval_int, &optlen);
|
||||
}
|
||||
|
||||
if (optname == SO_BROADCAST || optname == SO_KEEPALIVE || optname == SO_REUSEADDR || optname == SO_REUSEPORT
|
||||
@@ -193,30 +197,31 @@ JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1getsockopt(
|
||||
*/
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1getsockname(JNIEnv* env, jobject thisObj, jint fd, jobject addr)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1getsockname(JNIEnv* env, jobject thisObj, jint fd, jobject addr)
|
||||
{
|
||||
struct zts_sockaddr_storage ss;
|
||||
zts_socklen_t addrlen = sizeof(struct zts_sockaddr_storage);
|
||||
int retval = zts_getsockname(fd, (struct zts_sockaddr*)&ss, &addrlen);
|
||||
int retval = zts_bsd_getsockname(fd, (struct zts_sockaddr*)&ss, &addrlen);
|
||||
ss2zta(env, &ss, addr);
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1getpeername(JNIEnv* env, jobject thisObj, jint fd, jobject addr)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1getpeername(JNIEnv* env, jobject thisObj, jint fd, jobject addr)
|
||||
{
|
||||
struct zts_sockaddr_storage ss;
|
||||
int retval = zts_getpeername(fd, (struct zts_sockaddr*)&ss, (zts_socklen_t*)sizeof(struct zts_sockaddr_storage));
|
||||
int retval =
|
||||
zts_bsd_getpeername(fd, (struct zts_sockaddr*)&ss, (zts_socklen_t*)sizeof(struct zts_sockaddr_storage));
|
||||
ss2zta(env, &ss, addr);
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1close(JNIEnv* env, jobject thisObj, jint fd)
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1close(JNIEnv* env, jobject thisObj, jint fd)
|
||||
{
|
||||
return zts_close(fd);
|
||||
return zts_bsd_close(fd);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1select(
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1select(
|
||||
JNIEnv* env,
|
||||
jobject thisObj,
|
||||
jint nfds,
|
||||
@@ -245,7 +250,7 @@ JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1select(
|
||||
e = &_exceptfds;
|
||||
ztfdset2fdset(env, nfds, exceptfds, &_exceptfds);
|
||||
}
|
||||
int retval = zts_select(nfds, r, w, e, &_timeout);
|
||||
int retval = zts_bsd_select(nfds, r, w, e, &_timeout);
|
||||
if (readfds) {
|
||||
fdset2ztfdset(env, nfds, &_readfds, readfds);
|
||||
}
|
||||
@@ -259,19 +264,19 @@ JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1select(
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1fcntl(JNIEnv* env, jobject thisObj, jint fd, jint cmd, jint flags)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1fcntl(JNIEnv* env, jobject thisObj, jint fd, jint cmd, jint flags)
|
||||
{
|
||||
int retval = zts_fcntl(fd, cmd, flags);
|
||||
int retval = zts_bsd_fcntl(fd, cmd, flags);
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
|
||||
JNIEXPORT int JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1ioctl(JNIEnv* env, jobject thisObj, jint fd, jlong request, jobject argp)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1ioctl(JNIEnv* env, jobject thisObj, jint fd, jlong request, jobject argp)
|
||||
{
|
||||
int retval = ZTS_ERR_OK;
|
||||
if (request == FIONREAD) {
|
||||
int bytesRemaining = 0;
|
||||
retval = zts_ioctl(fd, request, &bytesRemaining);
|
||||
retval = zts_bsd_ioctl(fd, request, &bytesRemaining);
|
||||
// set value in general object
|
||||
jclass c = env->GetObjectClass(argp);
|
||||
if (! c) {
|
||||
@@ -283,21 +288,21 @@ Java_com_zerotier_sdk_ZeroTierNative_zts_1ioctl(JNIEnv* env, jobject thisObj, ji
|
||||
if (request == FIONBIO) {
|
||||
// TODO: double check
|
||||
int meaninglessVariable = 0;
|
||||
retval = zts_ioctl(fd, request, &meaninglessVariable);
|
||||
retval = zts_bsd_ioctl(fd, request, &meaninglessVariable);
|
||||
}
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1send(JNIEnv* env, jobject thisObj, jint fd, jbyteArray buf, int flags)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1send(JNIEnv* env, jobject thisObj, jint fd, jbyteArray buf, int flags)
|
||||
{
|
||||
void* data = env->GetPrimitiveArrayCritical(buf, NULL);
|
||||
int retval = zts_send(fd, data, env->GetArrayLength(buf), flags);
|
||||
int retval = zts_bsd_send(fd, data, env->GetArrayLength(buf), flags);
|
||||
env->ReleasePrimitiveArrayCritical(buf, data, 0);
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1sendto(
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1sendto(
|
||||
JNIEnv* env,
|
||||
jobject thisObj,
|
||||
jint fd,
|
||||
@@ -310,21 +315,21 @@ JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1sendto(
|
||||
zta2ss(env, &ss, addr);
|
||||
zts_socklen_t addrlen =
|
||||
ss.ss_family == ZTS_AF_INET ? sizeof(struct zts_sockaddr_in) : sizeof(struct zts_sockaddr_in6);
|
||||
int retval = zts_sendto(fd, data, env->GetArrayLength(buf), flags, (struct zts_sockaddr*)&ss, addrlen);
|
||||
int retval = zts_bsd_sendto(fd, data, env->GetArrayLength(buf), flags, (struct zts_sockaddr*)&ss, addrlen);
|
||||
env->ReleasePrimitiveArrayCritical(buf, data, 0);
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1recv(JNIEnv* env, jobject thisObj, jint fd, jbyteArray buf, jint flags)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1recv(JNIEnv* env, jobject thisObj, jint fd, jbyteArray buf, jint flags)
|
||||
{
|
||||
void* data = env->GetPrimitiveArrayCritical(buf, NULL);
|
||||
int retval = zts_recv(fd, data, env->GetArrayLength(buf), flags);
|
||||
int retval = zts_bsd_recv(fd, data, env->GetArrayLength(buf), flags);
|
||||
env->ReleasePrimitiveArrayCritical(buf, data, 0);
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1recvfrom(
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1recvfrom(
|
||||
JNIEnv* env,
|
||||
jobject thisObj,
|
||||
jint fd,
|
||||
@@ -335,28 +340,28 @@ JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1recvfrom(
|
||||
zts_socklen_t addrlen = sizeof(struct zts_sockaddr_storage);
|
||||
struct zts_sockaddr_storage ss;
|
||||
void* data = env->GetPrimitiveArrayCritical(buf, NULL);
|
||||
int retval = zts_recvfrom(fd, data, env->GetArrayLength(buf), flags, (struct zts_sockaddr*)&ss, &addrlen);
|
||||
int retval = zts_bsd_recvfrom(fd, data, env->GetArrayLength(buf), flags, (struct zts_sockaddr*)&ss, &addrlen);
|
||||
env->ReleasePrimitiveArrayCritical(buf, data, 0);
|
||||
ss2zta(env, &ss, addr);
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1read(JNIEnv* env, jobject thisObj, jint fd, jbyteArray buf)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1read(JNIEnv* env, jobject thisObj, jint fd, jbyteArray buf)
|
||||
{
|
||||
void* data = env->GetPrimitiveArrayCritical(buf, NULL);
|
||||
int retval = zts_read(fd, data, env->GetArrayLength(buf));
|
||||
int retval = zts_bsd_read(fd, data, env->GetArrayLength(buf));
|
||||
env->ReleasePrimitiveArrayCritical(buf, data, 0);
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
|
||||
ssize_t zts_read_offset(int fd, void* buf, size_t offset, size_t len)
|
||||
ssize_t zts_bsd_read_offset(int fd, void* buf, size_t offset, size_t len)
|
||||
{
|
||||
char* cbuf = (char*)buf;
|
||||
return zts_read(fd, &(cbuf[offset]), len);
|
||||
return zts_bsd_read(fd, &(cbuf[offset]), len);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1read_1offset(
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1read_1offset(
|
||||
JNIEnv* env,
|
||||
jobject thisObj,
|
||||
jint fd,
|
||||
@@ -365,30 +370,34 @@ JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1read_1offset(
|
||||
jint len)
|
||||
{
|
||||
void* data = env->GetPrimitiveArrayCritical(buf, NULL);
|
||||
int retval = zts_read_offset(fd, data, offset, len);
|
||||
int retval = zts_bsd_read_offset(fd, data, offset, len);
|
||||
env->ReleasePrimitiveArrayCritical(buf, data, 0);
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1read_1length(
|
||||
JNIEnv* env,
|
||||
jobject thisObj,
|
||||
jint fd,
|
||||
jbyteArray buf,
|
||||
jint len)
|
||||
{
|
||||
void* data = env->GetPrimitiveArrayCritical(buf, NULL);
|
||||
int retval = zts_bsd_read(fd, data, len);
|
||||
env->ReleasePrimitiveArrayCritical(buf, data, 0);
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1read_1length(JNIEnv* env, jobject thisObj, jint fd, jbyteArray buf, jint len)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1write__IB(JNIEnv* env, jobject thisObj, jint fd, jbyteArray buf)
|
||||
{
|
||||
void* data = env->GetPrimitiveArrayCritical(buf, NULL);
|
||||
int retval = zts_read(fd, data, len);
|
||||
int retval = zts_bsd_write(fd, data, env->GetArrayLength(buf));
|
||||
env->ReleasePrimitiveArrayCritical(buf, data, 0);
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1write__IB(JNIEnv* env, jobject thisObj, jint fd, jbyteArray buf)
|
||||
{
|
||||
void* data = env->GetPrimitiveArrayCritical(buf, NULL);
|
||||
int retval = zts_write(fd, data, env->GetArrayLength(buf));
|
||||
env->ReleasePrimitiveArrayCritical(buf, data, 0);
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1write_1offset(
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1write_1offset(
|
||||
JNIEnv* env,
|
||||
jobject thisObj,
|
||||
jint fd,
|
||||
@@ -397,21 +406,22 @@ JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1write_1offset(
|
||||
jint len)
|
||||
{
|
||||
void* data = env->GetPrimitiveArrayCritical(&(buf[offset]), NULL); // PENDING: check?
|
||||
int retval = zts_write(fd, data, len);
|
||||
int retval = zts_bsd_write(fd, data, len);
|
||||
env->ReleasePrimitiveArrayCritical(buf, data, 0);
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1write_1byte(JNIEnv* env, jobject thisObj, jint fd, jbyte buf)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1write_1byte(JNIEnv* env, jobject thisObj, jint fd, jbyte buf)
|
||||
{
|
||||
int retval = zts_write(fd, &buf, 1);
|
||||
int retval = zts_bsd_write(fd, &buf, 1);
|
||||
return retval > -1 ? retval : -(zts_errno);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1shutdown(JNIEnv* env, jobject thisObj, int fd, int how)
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1shutdown(JNIEnv* env, jobject thisObj, int fd, int how)
|
||||
{
|
||||
return zts_shutdown(fd, how);
|
||||
return zts_bsd_shutdown(fd, how);
|
||||
}
|
||||
|
||||
void ztfdset2fdset(JNIEnv* env, int nfds, jobject src_ztfd_set, zts_fd_set* dest_fd_set)
|
||||
@@ -844,7 +854,7 @@ Java_com_zerotier_sdk_ZeroTierNative_zts_1moon_1deorbit(JNIEnv* jenv, jobject th
|
||||
return zts_moon_deorbit(moon_roots_id);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1connect(
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1connect(
|
||||
JNIEnv* jenv,
|
||||
jobject thisObj,
|
||||
jint fd,
|
||||
@@ -859,13 +869,13 @@ JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1connect
|
||||
if (! utf_string) {
|
||||
return ZTS_ERR_GENERAL;
|
||||
}
|
||||
int retval = zts_simple_connect(fd, utf_string, port, timeout_ms);
|
||||
int retval = zts_connect(fd, utf_string, port, timeout_ms);
|
||||
jenv->ReleaseStringUTFChars(ipstr, utf_string);
|
||||
return retval;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1bind(JNIEnv* jenv, jobject thisObj, jint fd, jstring ipstr, jint port)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1bind(JNIEnv* jenv, jobject thisObj, jint fd, jstring ipstr, jint port)
|
||||
{
|
||||
if (! ipstr) {
|
||||
return ZTS_ERR_ARG;
|
||||
@@ -874,12 +884,12 @@ Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1bind(JNIEnv* jenv, jobject thi
|
||||
if (! utf_string) {
|
||||
return ZTS_ERR_GENERAL;
|
||||
}
|
||||
int retval = zts_simple_bind(fd, utf_string, port);
|
||||
int retval = zts_bind(fd, utf_string, port);
|
||||
jenv->ReleaseStringUTFChars(ipstr, utf_string);
|
||||
return retval;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1accept(
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1accept(
|
||||
JNIEnv* jenv,
|
||||
jobject thisObj,
|
||||
int fd,
|
||||
@@ -895,7 +905,7 @@ JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1accept(
|
||||
if (! utf_string) {
|
||||
return ZTS_ERR_GENERAL;
|
||||
}
|
||||
int retval = zts_simple_bind(fd, utf_string, port);
|
||||
int retval = zts_bind(fd, utf_string, port);
|
||||
jenv->ReleaseStringUTFChars(ipstr, utf_string);
|
||||
return retval;
|
||||
|
||||
@@ -909,162 +919,149 @@ JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1accept(
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1udp_1client(JNIEnv* jenv, jobject thisObj, jstring remote_ipstr)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1udp_1client(JNIEnv* jenv, jobject thisObj, jstring remote_ipstr)
|
||||
{
|
||||
return ZTS_ERR_OK;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1set_1no_1delay(JNIEnv* jenv, jobject thisObj, jint fd, jint enabled)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1set_1no_1delay(JNIEnv* jenv, jobject thisObj, jint fd, jint enabled)
|
||||
{
|
||||
return zts_simple_set_no_delay(fd, enabled);
|
||||
return zts_set_no_delay(fd, enabled);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1get_1no_1delay(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
{
|
||||
return zts_get_no_delay(fd);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1get_1no_1delay(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1set_1linger(JNIEnv* jenv, jobject thisObj, jint fd, jint enabled, jint value)
|
||||
{
|
||||
return zts_simple_get_no_delay(fd);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1set_1linger(
|
||||
JNIEnv* jenv,
|
||||
jobject thisObj,
|
||||
jint fd,
|
||||
jint enabled,
|
||||
jint value)
|
||||
{
|
||||
return zts_simple_set_linger(fd, enabled, value);
|
||||
return zts_set_linger(fd, enabled, value);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1get_1linger_1enabled(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1get_1linger_1enabled(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
{
|
||||
return zts_simple_get_linger_enabled(fd);
|
||||
return zts_get_linger_enabled(fd);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1get_1linger_1value(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1get_1linger_1value(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
{
|
||||
return zts_simple_get_linger_value(fd);
|
||||
return zts_get_linger_value(fd);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1get_1pending_1data_1size(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1get_1pending_1data_1size(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
{
|
||||
return zts_simple_get_pending_data_size(fd);
|
||||
return zts_get_pending_data_size(fd);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1set_1reuse_1addr(JNIEnv* jenv, jobject thisObj, jint fd, jint enabled)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1set_1reuse_1addr(JNIEnv* jenv, jobject thisObj, jint fd, jint enabled)
|
||||
{
|
||||
return zts_simple_set_reuse_addr(fd, enabled);
|
||||
return zts_set_reuse_addr(fd, enabled);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1get_1reuse_1addr(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1get_1reuse_1addr(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
{
|
||||
return zts_simple_get_reuse_addr(fd);
|
||||
return zts_get_reuse_addr(fd);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1set_1recv_1timeout(
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1set_1recv_1timeout(
|
||||
JNIEnv* jenv,
|
||||
jobject thisObj,
|
||||
jint fd,
|
||||
jint seconds,
|
||||
jint microseconds)
|
||||
{
|
||||
return zts_simple_set_recv_timeout(fd, seconds, microseconds);
|
||||
return zts_set_recv_timeout(fd, seconds, microseconds);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1get_1recv_1timeout(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1get_1recv_1timeout(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
{
|
||||
return zts_simple_get_recv_timeout(fd);
|
||||
return zts_get_recv_timeout(fd);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1set_1send_1timeout(
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1set_1send_1timeout(
|
||||
JNIEnv* jenv,
|
||||
jobject thisObj,
|
||||
jint fd,
|
||||
jint seconds,
|
||||
jint microseconds)
|
||||
{
|
||||
return zts_simple_set_send_timeout(fd, seconds, microseconds);
|
||||
return zts_set_send_timeout(fd, seconds, microseconds);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1get_1send_1timeout(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1get_1send_1timeout(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
{
|
||||
return zts_simple_get_send_timeout(fd);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1set_1send_1buf_1size(
|
||||
JNIEnv* jenv,
|
||||
jobject thisObj,
|
||||
jint fd,
|
||||
jint size)
|
||||
{
|
||||
return zts_simple_set_send_buf_size(fd, size);
|
||||
return zts_get_send_timeout(fd);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1get_1send_1buf_1size(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1set_1send_1buf_1size(JNIEnv* jenv, jobject thisObj, jint fd, jint size)
|
||||
{
|
||||
return zts_simple_get_send_buf_size(fd);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1set_1recv_1buf_1size(
|
||||
JNIEnv* jenv,
|
||||
jobject thisObj,
|
||||
jint fd,
|
||||
jint size)
|
||||
{
|
||||
return zts_simple_set_recv_buf_size(fd, size);
|
||||
return zts_set_send_buf_size(fd, size);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1get_1recv_1buf_1size(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1get_1send_1buf_1size(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
{
|
||||
return zts_simple_get_recv_buf_size(fd);
|
||||
return zts_get_send_buf_size(fd);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1set_1ttl(JNIEnv* jenv, jobject thisObj, jint fd, jint ttl)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1set_1recv_1buf_1size(JNIEnv* jenv, jobject thisObj, jint fd, jint size)
|
||||
{
|
||||
return zts_simple_set_ttl(fd, ttl);
|
||||
return zts_set_recv_buf_size(fd, size);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1get_1ttl(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1get_1recv_1buf_1size(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
{
|
||||
return zts_simple_get_ttl(fd);
|
||||
return zts_get_recv_buf_size(fd);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1set_1blocking(JNIEnv* jenv, jobject thisObj, jint fd, jint enabled)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1set_1ttl(JNIEnv* jenv, jobject thisObj, jint fd, jint ttl)
|
||||
{
|
||||
return zts_simple_set_blocking(fd, enabled);
|
||||
return zts_set_ttl(fd, ttl);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1get_1ttl(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
{
|
||||
return zts_get_ttl(fd);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1get_1blocking(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1set_1blocking(JNIEnv* jenv, jobject thisObj, jint fd, jint enabled)
|
||||
{
|
||||
return zts_simple_get_blocking(fd);
|
||||
return zts_set_blocking(fd, enabled);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1get_1blocking(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
{
|
||||
return zts_get_blocking(fd);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1set_1keepalive(JNIEnv* jenv, jobject thisObj, jint fd, jint enabled)
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1set_1keepalive(JNIEnv* jenv, jobject thisObj, jint fd, jint enabled)
|
||||
{
|
||||
return zts_simple_set_keepalive(fd, enabled);
|
||||
return zts_set_keepalive(fd, enabled);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1simple_1get_1keepalive(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
JNIEXPORT jint JNICALL Java_com_zerotier_sdk_ZeroTierNative_zts_1get_1keepalive(JNIEnv* jenv, jobject thisObj, jint fd)
|
||||
{
|
||||
return zts_simple_get_keepalive(fd);
|
||||
return zts_get_keepalive(fd);
|
||||
}
|
||||
|
||||
struct hostent* Java_com_zerotier_sdk_ZeroTierNative_zts_1gethostbyname(JNIEnv* jenv, jobject thisObj, jstring name)
|
||||
struct hostent*
|
||||
Java_com_zerotier_sdk_ZeroTierNative_zts_1bsd_1gethostbyname(JNIEnv* jenv, jobject thisObj, jstring name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ZeroTierInputStream extends InputStream {
|
||||
that aspect of the socket but not actually close it and free resources. Resources
|
||||
will be properly freed when the socket implementation's close() is called or if
|
||||
both I/OStreams are closed separately */
|
||||
ZeroTierNative.zts_shutdown(zfd, ZeroTierNative.ZTS_SHUT_RD);
|
||||
ZeroTierNative.zts_bsd_shutdown(zfd, ZeroTierNative.ZTS_SHUT_RD);
|
||||
zfd = -1;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ZeroTierInputStream extends InputStream {
|
||||
Objects.requireNonNull(destStream, "destStream must not be null");
|
||||
int bytesTransferred = 0, bytesRead;
|
||||
byte[] buf = new byte[8192];
|
||||
while (((bytesRead = ZeroTierNative.zts_read(zfd, buf)) >= 0)) {
|
||||
while (((bytesRead = ZeroTierNative.zts_bsd_read(zfd, buf)) >= 0)) {
|
||||
destStream.write(buf, 0, bytesRead);
|
||||
bytesTransferred += bytesRead;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class ZeroTierInputStream extends InputStream {
|
||||
{
|
||||
byte[] buf = new byte[1];
|
||||
// Unlike a native read(), if nothing is read we should return -1
|
||||
int retval = ZeroTierNative.zts_read(zfd, buf);
|
||||
int retval = ZeroTierNative.zts_bsd_read(zfd, buf);
|
||||
if ((retval == 0) | (retval == -104) /* EINTR, from SO_RCVTIMEO */) {
|
||||
return -1;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class ZeroTierInputStream extends InputStream {
|
||||
{
|
||||
Objects.requireNonNull(destBuffer, "input byte array must not be null");
|
||||
// Unlike a native read(), if nothing is read we should return -1
|
||||
int retval = ZeroTierNative.zts_read(zfd, destBuffer);
|
||||
int retval = ZeroTierNative.zts_bsd_read(zfd, destBuffer);
|
||||
if ((retval == 0) | (retval == -104) /* EINTR, from SO_RCVTIMEO */) {
|
||||
return -1;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class ZeroTierInputStream extends InputStream {
|
||||
return 0;
|
||||
}
|
||||
// Unlike a native read(), if nothing is read we should return -1
|
||||
int retval = ZeroTierNative.zts_read_offset(zfd, destBuffer, offset, numBytes);
|
||||
int retval = ZeroTierNative.zts_bsd_read_offset(zfd, destBuffer, offset, numBytes);
|
||||
if ((retval == 0) | (retval == -104) /* EINTR, from SO_RCVTIMEO */) {
|
||||
return -1;
|
||||
}
|
||||
@@ -139,9 +139,9 @@ public class ZeroTierInputStream extends InputStream {
|
||||
*/
|
||||
public byte[] readAllBytes() throws IOException
|
||||
{
|
||||
int pendingDataSize = ZeroTierNative.zts_simple_get_pending_data_size(zfd);
|
||||
int pendingDataSize = ZeroTierNative.zts_get_pending_data_size(zfd);
|
||||
byte[] buf = new byte[pendingDataSize];
|
||||
int retval = ZeroTierNative.zts_read(zfd, buf);
|
||||
int retval = ZeroTierNative.zts_bsd_read(zfd, buf);
|
||||
if ((retval == 0) | (retval == -104) /* EINTR, from SO_RCVTIMEO */) {
|
||||
// No action needed
|
||||
}
|
||||
@@ -174,7 +174,7 @@ public class ZeroTierInputStream extends InputStream {
|
||||
if (numBytes == 0) {
|
||||
return 0;
|
||||
}
|
||||
int retval = ZeroTierNative.zts_read_offset(zfd, destBuffer, offset, numBytes);
|
||||
int retval = ZeroTierNative.zts_bsd_read_offset(zfd, destBuffer, offset, numBytes);
|
||||
if ((retval == 0) | (retval == -104) /* EINTR, from SO_RCVTIMEO */) {
|
||||
// No action needed
|
||||
}
|
||||
@@ -199,7 +199,8 @@ public class ZeroTierInputStream extends InputStream {
|
||||
int bufSize = (int)Math.min(2048, bytesRemaining);
|
||||
byte[] buf = new byte[bufSize];
|
||||
while (bytesRemaining > 0) {
|
||||
if ((bytesRead = ZeroTierNative.zts_read_length(zfd, buf, (int)Math.min(bufSize, bytesRemaining))) < 0) {
|
||||
if ((bytesRead = ZeroTierNative.zts_bsd_read_length(zfd, buf, (int)Math.min(bufSize, bytesRemaining)))
|
||||
< 0) {
|
||||
break;
|
||||
}
|
||||
bytesRemaining -= bytesRead;
|
||||
|
||||
@@ -473,20 +473,20 @@ public class ZeroTierNative {
|
||||
public static native int zts_moon_orbit(long moon_roots_id, long moon_seed);
|
||||
public static native int zts_moon_deorbit(long moon_roots_id);
|
||||
|
||||
// public static native int zts_socket(int family, int type, int protocol);
|
||||
// public static native int zts_connect(int fd, /*const*/ struct sockaddr* addr, socklen_t addrlen);
|
||||
// public static native int zts_bind(int fd, /*const*/ struct sockaddr* addr, socklen_t addrlen);
|
||||
// public static native int zts_listen(int fd, int backlog);
|
||||
// public static native int zts_accept(int fd, struct sockaddr* addr, socklen_t* addrlen);
|
||||
// public static native int zts_setsockopt(int fd, int level, int optname, /*const*/ void* optval, socklen_t
|
||||
// optlen); public static native int zts_getsockopt(int fd, int level, int optname, void* optval, socklen_t*
|
||||
// optlen); public static native int zts_getsockname(int fd, struct sockaddr* addr, socklen_t* addrlen); public
|
||||
// static native int zts_getpeername(int fd, struct sockaddr* addr, socklen_t* addrlen); public static native int
|
||||
// zts_close(int fd); public static native int zts_select(int nfds, fd_set* readfds, fd_set* writefds, fd_set*
|
||||
// exceptfds, struct timeval* timeout); public static native int zts_fcntl(int fd, int cmd, int flags); public
|
||||
// static native int zts_poll(struct pollfd* fds, nfds_t nfds, int timeout); public static native int zts_ioctl(int
|
||||
// fd, long request, void* argp); public static native int send(int fd, /*const*/ void* buf, size_t len, int
|
||||
// flags); public static native int sendto(int fd,
|
||||
// public static native int zts_bsd_socket(int family, int type, int protocol);
|
||||
// public static native int zts_bsd_connect(int fd, /*const*/ struct sockaddr* addr, socklen_t addrlen);
|
||||
// public static native int zts_bsd_bind(int fd, /*const*/ struct sockaddr* addr, socklen_t addrlen);
|
||||
// public static native int zts_bsd_listen(int fd, int backlog);
|
||||
// public static native int zts_bsd_accept(int fd, struct sockaddr* addr, socklen_t* addrlen);
|
||||
// public static native int zts_bsd_setsockopt(int fd, int level, int optname, /*const*/ void* optval, socklen_t
|
||||
// optlen); public static native int zts_bsd_getsockopt(int fd, int level, int optname, void* optval, socklen_t*
|
||||
// optlen); public static native int zts_bsd_getsockname(int fd, struct sockaddr* addr, socklen_t* addrlen); public
|
||||
// static native int zts_bsd_getpeername(int fd, struct sockaddr* addr, socklen_t* addrlen); public static native
|
||||
// int zts_bsd_close(int fd); public static native int zts_bsd_select(int nfds, fd_set* readfds, fd_set* writefds,
|
||||
// fd_set* exceptfds, struct timeval* timeout); public static native int zts_bsd_fcntl(int fd, int cmd, int flags);
|
||||
// public static native int zts_bsd_poll(struct pollfd* fds, nfds_t nfds, int timeout); public static native int
|
||||
// zts_bsd_ioctl(int fd, long request, void* argp); public static native int send(int fd, /*const*/ void* buf,
|
||||
// size_t len, int flags); public static native int sendto(int fd,
|
||||
// /*const*/ void* buf, size_t len, int flags, /*const*/ struct sockaddr* addr, socklen_t addrlen); public static
|
||||
// native int sendmsg(int fd, /*const*/ struct msghdr* msg, int flags); public static native int recv(int fd,
|
||||
// void* buf, size_t len, int flags); public static native int recvfrom(int fd, void* buf, size_t len, int flags,
|
||||
@@ -495,36 +495,36 @@ public class ZeroTierNative {
|
||||
// /*const*/ struct iovec* iov, int iovcnt); public static native int write(int fd, /*const*/ void* buf, size_t
|
||||
// len); public static native int writev(int fd, /*const*/ struct iovec* iov, int iovcnt); public static native int
|
||||
// shutdown(int fd, int how);
|
||||
public static native int zts_simple_connect(int fd, /*const*/ String ipstr, int port, int timeout_ms);
|
||||
public static native int zts_simple_bind(int fd, /*const*/ String ipstr, int port);
|
||||
// public static native int zts_simple_accept(int fd, String remote_addr, int len, int* port);
|
||||
public static native int zts_simple_tcp_client(/*const*/ String remote_ipstr, int remote_port);
|
||||
// public static native int zts_simple_tcp_server(/*const*/ String local_ipstr, int local_port, String remote_ipstr,
|
||||
public static native int zts_connect(int fd, /*const*/ String ipstr, int port, int timeout_ms);
|
||||
public static native int zts_bind(int fd, /*const*/ String ipstr, int port);
|
||||
// public static native int zts_accept(int fd, String remote_addr, int len, int* port);
|
||||
public static native int zts_tcp_client(/*const*/ String remote_ipstr, int remote_port);
|
||||
// public static native int zts_tcp_server(/*const*/ String local_ipstr, int local_port, String remote_ipstr,
|
||||
// int len, int* remote_port);
|
||||
public static native int zts_simple_udp_server(/*const*/ String local_ipstr, int local_port);
|
||||
public static native int zts_simple_udp_client(/*const*/ String remote_ipstr);
|
||||
public static native int zts_simple_set_no_delay(int fd, int enabled);
|
||||
public static native int zts_simple_get_no_delay(int fd);
|
||||
public static native int zts_simple_set_linger(int fd, int enabled, int value);
|
||||
public static native int zts_simple_get_linger_enabled(int fd);
|
||||
public static native int zts_simple_get_linger_value(int fd);
|
||||
public static native int zts_simple_get_pending_data_size(int fd);
|
||||
public static native int zts_simple_set_reuse_addr(int fd, int enabled);
|
||||
public static native int zts_simple_get_reuse_addr(int fd);
|
||||
public static native int zts_simple_set_recv_timeout(int fd, int seconds, int microseconds);
|
||||
public static native int zts_simple_get_recv_timeout(int fd);
|
||||
public static native int zts_simple_set_send_timeout(int fd, int seconds, int microseconds);
|
||||
public static native int zts_simple_get_send_timeout(int fd);
|
||||
public static native int zts_simple_set_send_buf_size(int fd, int size);
|
||||
public static native int zts_simple_get_send_buf_size(int fd);
|
||||
public static native int zts_simple_set_recv_buf_size(int fd, int size);
|
||||
public static native int zts_simple_get_recv_buf_size(int fd);
|
||||
public static native int zts_simple_set_ttl(int fd, int ttl);
|
||||
public static native int zts_simple_get_ttl(int fd);
|
||||
public static native int zts_simple_set_blocking(int fd, int enabled);
|
||||
public static native int zts_simple_get_blocking(int fd);
|
||||
public static native int zts_simple_set_keepalive(int fd, int enabled);
|
||||
public static native int zts_simple_get_keepalive(int fd);
|
||||
public static native int zts_udp_server(/*const*/ String local_ipstr, int local_port);
|
||||
public static native int zts_udp_client(/*const*/ String remote_ipstr);
|
||||
public static native int zts_set_no_delay(int fd, int enabled);
|
||||
public static native int zts_get_no_delay(int fd);
|
||||
public static native int zts_set_linger(int fd, int enabled, int value);
|
||||
public static native int zts_get_linger_enabled(int fd);
|
||||
public static native int zts_get_linger_value(int fd);
|
||||
public static native int zts_get_pending_data_size(int fd);
|
||||
public static native int zts_set_reuse_addr(int fd, int enabled);
|
||||
public static native int zts_get_reuse_addr(int fd);
|
||||
public static native int zts_set_recv_timeout(int fd, int seconds, int microseconds);
|
||||
public static native int zts_get_recv_timeout(int fd);
|
||||
public static native int zts_set_send_timeout(int fd, int seconds, int microseconds);
|
||||
public static native int zts_get_send_timeout(int fd);
|
||||
public static native int zts_set_send_buf_size(int fd, int size);
|
||||
public static native int zts_get_send_buf_size(int fd);
|
||||
public static native int zts_set_recv_buf_size(int fd, int size);
|
||||
public static native int zts_get_recv_buf_size(int fd);
|
||||
public static native int zts_set_ttl(int fd, int ttl);
|
||||
public static native int zts_get_ttl(int fd);
|
||||
public static native int zts_set_blocking(int fd, int enabled);
|
||||
public static native int zts_get_blocking(int fd);
|
||||
public static native int zts_set_keepalive(int fd, int enabled);
|
||||
public static native int zts_get_keepalive(int fd);
|
||||
// struct hostent* gethostbyname(/*const*/ String name);
|
||||
// public static native int zts_dns_set_server(uint8_t index, /*const*/ ip_addr* addr);
|
||||
// ZTS_API /*const*/ ip_addr* ZTCALL dns_get_server(uint8_t index);
|
||||
@@ -565,35 +565,35 @@ public class ZeroTierNative {
|
||||
// Socket API //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static native int zts_socket(int family, int type, int protocol);
|
||||
// public static native int zts_connect(int fd, ZeroTierSocketAddress addr);
|
||||
// public static native int zts_bind(int fd, ZeroTierSocketAddress addr);
|
||||
public static native int zts_listen(int fd, int backlog);
|
||||
public static native int zts_accept(int fd, ZeroTierSocketAddress addr);
|
||||
public static native int zts_bsd_socket(int family, int type, int protocol);
|
||||
// public static native int zts_bsd_connect(int fd, ZeroTierSocketAddress addr);
|
||||
// public static native int zts_bsd_bind(int fd, ZeroTierSocketAddress addr);
|
||||
public static native int zts_bsd_listen(int fd, int backlog);
|
||||
public static native int zts_bsd_accept(int fd, ZeroTierSocketAddress addr);
|
||||
|
||||
// public static native int zts_setsockopt(int fd, int level, int optname, ZeroTierSocketOptionValue optval);
|
||||
// public static native int zts_getsockopt(int fd, int level, int optname, ZeroTierSocketOptionValue optval);
|
||||
// public static native int zts_bsd_setsockopt(int fd, int level, int optname, ZeroTierSocketOptionValue optval);
|
||||
// public static native int zts_bsd_getsockopt(int fd, int level, int optname, ZeroTierSocketOptionValue optval);
|
||||
|
||||
public static native int zts_read(int fd, byte[] buf);
|
||||
public static native int zts_read_offset(int fd, byte[] buf, int offset, int len);
|
||||
public static native int zts_read_length(int fd, byte[] buf, int len);
|
||||
public static native int zts_recv(int fd, byte[] buf, int flags);
|
||||
public static native int zts_recvfrom(int fd, byte[] buf, int flags, ZeroTierSocketAddress addr);
|
||||
public static native int zts_bsd_read(int fd, byte[] buf);
|
||||
public static native int zts_bsd_read_offset(int fd, byte[] buf, int offset, int len);
|
||||
public static native int zts_bsd_read_length(int fd, byte[] buf, int len);
|
||||
public static native int zts_bsd_recv(int fd, byte[] buf, int flags);
|
||||
public static native int zts_bsd_recvfrom(int fd, byte[] buf, int flags, ZeroTierSocketAddress addr);
|
||||
|
||||
public static native int zts_write(int fd, byte[] buf);
|
||||
public static native int zts_write_byte(int fd, byte b);
|
||||
public static native int zts_write_offset(int fd, byte[] buf, int offset, int len);
|
||||
public static native int zts_sendto(int fd, byte[] buf, int flags, ZeroTierSocketAddress addr);
|
||||
public static native int zts_send(int fd, byte[] buf, int flags);
|
||||
public static native int zts_bsd_write(int fd, byte[] buf);
|
||||
public static native int zts_bsd_write_byte(int fd, byte b);
|
||||
public static native int zts_bsd_write_offset(int fd, byte[] buf, int offset, int len);
|
||||
public static native int zts_bsd_sendto(int fd, byte[] buf, int flags, ZeroTierSocketAddress addr);
|
||||
public static native int zts_bsd_send(int fd, byte[] buf, int flags);
|
||||
|
||||
public static native int zts_shutdown(int fd, int how);
|
||||
public static native int zts_close(int fd);
|
||||
public static native int zts_bsd_shutdown(int fd, int how);
|
||||
public static native int zts_bsd_close(int fd);
|
||||
|
||||
public static native boolean zts_getsockname(int fd, ZeroTierSocketAddress addr);
|
||||
public static native int zts_getpeername(int fd, ZeroTierSocketAddress addr);
|
||||
public static native int zts_fcntl(int sock, int cmd, int flag);
|
||||
// public static native int zts_ioctl(int fd, long request, ZeroTierIoctlArg arg);
|
||||
public static native int zts_select(
|
||||
public static native boolean zts_bsd_getsockname(int fd, ZeroTierSocketAddress addr);
|
||||
public static native int zts_bsd_getpeername(int fd, ZeroTierSocketAddress addr);
|
||||
public static native int zts_bsd_fcntl(int sock, int cmd, int flag);
|
||||
// public static native int zts_bsd_ioctl(int fd, long request, ZeroTierIoctlArg arg);
|
||||
public static native int zts_bsd_select(
|
||||
int nfds,
|
||||
ZeroTierFileDescriptorSet readfds,
|
||||
ZeroTierFileDescriptorSet writefds,
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ZeroTierOutputStream extends OutputStream {
|
||||
it and free resources. Resources will be properly freed when the
|
||||
socket implementation's native close() is called or if both I/OStreams
|
||||
are closed separately */
|
||||
ZeroTierNative.zts_shutdown(zfd, ZeroTierNative.ZTS_SHUT_WR);
|
||||
ZeroTierNative.zts_bsd_shutdown(zfd, ZeroTierNative.ZTS_SHUT_WR);
|
||||
zfd = -1;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ZeroTierOutputStream extends OutputStream {
|
||||
*/
|
||||
public void write(byte[] originBuffer) throws IOException
|
||||
{
|
||||
int bytesWritten = ZeroTierNative.zts_write(zfd, originBuffer);
|
||||
int bytesWritten = ZeroTierNative.zts_bsd_write(zfd, originBuffer);
|
||||
if (bytesWritten < 0) {
|
||||
throw new IOException("write(originBuffer[]), errno=" + bytesWritten);
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class ZeroTierOutputStream extends OutputStream {
|
||||
if ((offset + numBytes) > originBuffer.length) {
|
||||
throw new IndexOutOfBoundsException("(offset+numBytes) > originBuffer.length");
|
||||
}
|
||||
int bytesWritten = ZeroTierNative.zts_write_offset(zfd, originBuffer, offset, numBytes);
|
||||
int bytesWritten = ZeroTierNative.zts_bsd_write_offset(zfd, originBuffer, offset, numBytes);
|
||||
if (bytesWritten < 0) {
|
||||
throw new IOException("write(originBuffer[],offset,numBytes), errno=" + bytesWritten);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class ZeroTierOutputStream extends OutputStream {
|
||||
public void write(int d) throws IOException
|
||||
{
|
||||
byte lowByte = (byte)(d & 0xFF);
|
||||
int bytesWritten = ZeroTierNative.zts_write_byte(zfd, lowByte);
|
||||
int bytesWritten = ZeroTierNative.zts_bsd_write_byte(zfd, lowByte);
|
||||
if (bytesWritten < 0) {
|
||||
throw new IOException("write(d), errno=" + bytesWritten);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ZeroTierSocket {
|
||||
if (_zfd > -1) {
|
||||
throw new IOException("This socket has already been created (fd=" + _zfd + ")");
|
||||
}
|
||||
_zfd = ZeroTierNative.zts_socket(ZeroTierNative.ZTS_AF_INET, ZeroTierNative.ZTS_SOCK_STREAM, protocol);
|
||||
_zfd = ZeroTierNative.zts_bsd_socket(ZeroTierNative.ZTS_AF_INET, ZeroTierNative.ZTS_SOCK_STREAM, protocol);
|
||||
if (_zfd < 0) {
|
||||
throw new IOException("Error while creating socket (" + _zfd + ")");
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public class ZeroTierSocket {
|
||||
throw new IOException("Invalid address type. Socket is of type AF_INET6");
|
||||
}
|
||||
int err;
|
||||
if ((err = ZeroTierNative.zts_simple_connect(_zfd, remoteAddr.getHostAddress(), remotePort, 0)) < 0) {
|
||||
if ((err = ZeroTierNative.zts_connect(_zfd, remoteAddr.getHostAddress(), remotePort, 0)) < 0) {
|
||||
throw new IOException("Error while connecting to remote host (" + err + ")");
|
||||
}
|
||||
_isConnected = true;
|
||||
@@ -155,7 +155,7 @@ public class ZeroTierSocket {
|
||||
throw new IOException("Invalid address type. Socket is of type AF_INET6");
|
||||
}
|
||||
int err;
|
||||
if ((err = ZeroTierNative.zts_simple_bind(_zfd, localAddr.getHostAddress(), localPort)) < 0) {
|
||||
if ((err = ZeroTierNative.zts_bind(_zfd, localAddr.getHostAddress(), localPort)) < 0) {
|
||||
throw new IOException("Error while connecting to remote host (" + err + ")");
|
||||
}
|
||||
_localPort = localPort;
|
||||
@@ -190,7 +190,7 @@ public class ZeroTierSocket {
|
||||
throw new IOException("Invalid backlog value");
|
||||
}
|
||||
int err;
|
||||
if ((err = ZeroTierNative.zts_listen(_zfd, backlog)) < 0) {
|
||||
if ((err = ZeroTierNative.zts_bsd_listen(_zfd, backlog)) < 0) {
|
||||
throw new IOException("Error while putting socket into listening state (" + err + ")");
|
||||
}
|
||||
}
|
||||
@@ -207,7 +207,7 @@ public class ZeroTierSocket {
|
||||
}
|
||||
int accetpedFd = -1;
|
||||
ZeroTierSocketAddress addr = new ZeroTierSocketAddress();
|
||||
if ((accetpedFd = ZeroTierNative.zts_accept(_zfd, addr)) < 0) {
|
||||
if ((accetpedFd = ZeroTierNative.zts_bsd_accept(_zfd, addr)) < 0) {
|
||||
throw new IOException("Error while accepting connection (" + accetpedFd + ")");
|
||||
}
|
||||
return new ZeroTierSocket(_family, _type, _protocol, accetpedFd);
|
||||
@@ -223,7 +223,7 @@ public class ZeroTierSocket {
|
||||
if (_zfd < 0) {
|
||||
throw new IOException("Invalid socket (fd < 0)");
|
||||
}
|
||||
ZeroTierNative.zts_close(_zfd);
|
||||
ZeroTierNative.zts_bsd_close(_zfd);
|
||||
_isClosed = true;
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ public class ZeroTierSocket {
|
||||
if (_isClosed) {
|
||||
throw new SocketException("Error: ZeroTierSocket is closed");
|
||||
}
|
||||
return ZeroTierNative.zts_simple_get_keepalive(_zfd) == 1;
|
||||
return ZeroTierNative.zts_get_keepalive(_zfd) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,7 +298,7 @@ public class ZeroTierSocket {
|
||||
if (_isClosed) {
|
||||
throw new SocketException("Error: ZeroTierSocket is closed");
|
||||
}
|
||||
return ZeroTierNative.zts_simple_get_recv_buf_size(_zfd);
|
||||
return ZeroTierNative.zts_get_recv_buf_size(_zfd);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -311,7 +311,7 @@ public class ZeroTierSocket {
|
||||
if (_isClosed) {
|
||||
throw new SocketException("Error: ZeroTierSocket is closed");
|
||||
}
|
||||
return ZeroTierNative.zts_simple_get_send_buf_size(_zfd);
|
||||
return ZeroTierNative.zts_get_send_buf_size(_zfd);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,7 +324,7 @@ public class ZeroTierSocket {
|
||||
if (_isClosed) {
|
||||
throw new SocketException("Error: ZeroTierSocket is closed");
|
||||
}
|
||||
return ZeroTierNative.zts_simple_get_reuse_addr(_zfd) == 1;
|
||||
return ZeroTierNative.zts_get_reuse_addr(_zfd) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,7 +337,7 @@ public class ZeroTierSocket {
|
||||
if (_isClosed) {
|
||||
throw new SocketException("Error: ZeroTierSocket is closed");
|
||||
}
|
||||
return ZeroTierNative.zts_simple_get_linger_value(_zfd);
|
||||
return ZeroTierNative.zts_get_linger_value(_zfd);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -350,7 +350,7 @@ public class ZeroTierSocket {
|
||||
if (_isClosed) {
|
||||
throw new SocketException("Error: ZeroTierSocket is closed");
|
||||
}
|
||||
return ZeroTierNative.zts_simple_get_recv_timeout(_zfd);
|
||||
return ZeroTierNative.zts_get_recv_timeout(_zfd);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -363,7 +363,7 @@ public class ZeroTierSocket {
|
||||
if (_isClosed) {
|
||||
throw new SocketException("Error: ZeroTierSocket is closed");
|
||||
}
|
||||
return ZeroTierNative.zts_simple_get_no_delay(_zfd) == 1;
|
||||
return ZeroTierNative.zts_get_no_delay(_zfd) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -409,7 +409,7 @@ public class ZeroTierSocket {
|
||||
if (_inputHasBeenShutdown) {
|
||||
throw new SocketException("Error: ZeroTierSocket input has been shut down");
|
||||
}
|
||||
ZeroTierNative.zts_shutdown(_zfd, ZeroTierNative.ZTS_SHUT_RD);
|
||||
ZeroTierNative.zts_bsd_shutdown(_zfd, ZeroTierNative.ZTS_SHUT_RD);
|
||||
_inputHasBeenShutdown = true;
|
||||
}
|
||||
|
||||
@@ -429,7 +429,7 @@ public class ZeroTierSocket {
|
||||
if (_outputHasBeenShutdown) {
|
||||
throw new SocketException("Error: ZeroTierSocket output has been shut down");
|
||||
}
|
||||
ZeroTierNative.zts_shutdown(_zfd, ZeroTierNative.ZTS_SHUT_WR);
|
||||
ZeroTierNative.zts_bsd_shutdown(_zfd, ZeroTierNative.ZTS_SHUT_WR);
|
||||
_outputHasBeenShutdown = true;
|
||||
}
|
||||
|
||||
@@ -500,7 +500,7 @@ public class ZeroTierSocket {
|
||||
if (_isClosed) {
|
||||
throw new SocketException("Error: ZeroTierSocket is closed");
|
||||
}
|
||||
if (ZeroTierNative.zts_simple_set_keepalive(_zfd, (enabled ? 1 : 0)) != ZeroTierNative.ZTS_ERR_OK) {
|
||||
if (ZeroTierNative.zts_set_keepalive(_zfd, (enabled ? 1 : 0)) != ZeroTierNative.ZTS_ERR_OK) {
|
||||
throw new SocketException("Error: Could not set SO_KEEPALIVE");
|
||||
}
|
||||
}
|
||||
@@ -519,7 +519,7 @@ public class ZeroTierSocket {
|
||||
if (bufferSize <= 0) {
|
||||
throw new IllegalArgumentException("Error: bufferSize <= 0");
|
||||
}
|
||||
if (ZeroTierNative.zts_simple_set_recv_buf_size(_zfd, bufferSize) != ZeroTierNative.ZTS_ERR_OK) {
|
||||
if (ZeroTierNative.zts_set_recv_buf_size(_zfd, bufferSize) != ZeroTierNative.ZTS_ERR_OK) {
|
||||
throw new SocketException("Error: Could not set receive buffer size");
|
||||
}
|
||||
}
|
||||
@@ -535,7 +535,7 @@ public class ZeroTierSocket {
|
||||
if (_isClosed) {
|
||||
throw new SocketException("Error: ZeroTierSocket is closed");
|
||||
}
|
||||
if (ZeroTierNative.zts_simple_set_reuse_addr(_zfd, (enabled ? 1 : 0)) != ZeroTierNative.ZTS_ERR_OK) {
|
||||
if (ZeroTierNative.zts_set_reuse_addr(_zfd, (enabled ? 1 : 0)) != ZeroTierNative.ZTS_ERR_OK) {
|
||||
throw new SocketException("Error: Could not set SO_REUSEADDR");
|
||||
}
|
||||
}
|
||||
@@ -554,7 +554,7 @@ public class ZeroTierSocket {
|
||||
if (bufferSize <= 0) {
|
||||
throw new IllegalArgumentException("Error: bufferSize <= 0");
|
||||
}
|
||||
if (ZeroTierNative.zts_simple_set_send_buf_size(_zfd, bufferSize) != ZeroTierNative.ZTS_ERR_OK) {
|
||||
if (ZeroTierNative.zts_set_send_buf_size(_zfd, bufferSize) != ZeroTierNative.ZTS_ERR_OK) {
|
||||
throw new SocketException("Error: Could not set SO_SNDBUF");
|
||||
}
|
||||
}
|
||||
@@ -574,7 +574,7 @@ public class ZeroTierSocket {
|
||||
if (lingerTime < 0) {
|
||||
throw new IllegalArgumentException("Error: lingerTime < 0");
|
||||
}
|
||||
if (ZeroTierNative.zts_simple_set_linger(_zfd, (enabled ? 1 : 0), lingerTime) != ZeroTierNative.ZTS_ERR_OK) {
|
||||
if (ZeroTierNative.zts_set_linger(_zfd, (enabled ? 1 : 0), lingerTime) != ZeroTierNative.ZTS_ERR_OK) {
|
||||
throw new SocketException("Error: Could not set ZTS_SO_LINGER");
|
||||
}
|
||||
}
|
||||
@@ -594,7 +594,7 @@ public class ZeroTierSocket {
|
||||
throw new IllegalArgumentException("Error: SO_TIMEOUT < 0");
|
||||
}
|
||||
// TODO: This is incorrect
|
||||
if (ZeroTierNative.zts_simple_set_recv_timeout(_zfd, timeout, timeout) != ZeroTierNative.ZTS_ERR_OK) {
|
||||
if (ZeroTierNative.zts_set_recv_timeout(_zfd, timeout, timeout) != ZeroTierNative.ZTS_ERR_OK) {
|
||||
throw new SocketException("Error: Could not set SO_RCVTIMEO");
|
||||
}
|
||||
}
|
||||
@@ -610,7 +610,7 @@ public class ZeroTierSocket {
|
||||
if (_isClosed) {
|
||||
throw new SocketException("Error: ZeroTierSocket is closed");
|
||||
}
|
||||
if (ZeroTierNative.zts_simple_set_no_delay(_zfd, (enabled ? 1 : 0)) != ZeroTierNative.ZTS_ERR_OK) {
|
||||
if (ZeroTierNative.zts_set_no_delay(_zfd, (enabled ? 1 : 0)) != ZeroTierNative.ZTS_ERR_OK) {
|
||||
throw new SocketException("Error: Could not set TCP_NODELAY");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ int zts_py_setblocking(int fd, int block)
|
||||
{
|
||||
int new_flags, cur_flags, err = 0;
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS cur_flags = zts_fcntl(fd, F_GETFL, 0);
|
||||
Py_BEGIN_ALLOW_THREADS cur_flags = zts_bsd_fcntl(fd, F_GETFL, 0);
|
||||
|
||||
if (cur_flags < 0) {
|
||||
err = ZTS_ERR_SOCKET;
|
||||
@@ -44,7 +44,7 @@ int zts_py_setblocking(int fd, int block)
|
||||
}
|
||||
|
||||
if (new_flags != cur_flags) {
|
||||
err = zts_fcntl(fd, F_SETFL, new_flags);
|
||||
err = zts_bsd_fcntl(fd, F_SETFL, new_flags);
|
||||
}
|
||||
|
||||
done:
|
||||
@@ -57,7 +57,7 @@ int zts_py_getblocking(int fd)
|
||||
{
|
||||
int flags;
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS flags = zts_fcntl(fd, F_GETFL, 0);
|
||||
Py_BEGIN_ALLOW_THREADS flags = zts_bsd_fcntl(fd, F_GETFL, 0);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (flags < 0)
|
||||
@@ -103,7 +103,7 @@ PyObject* zts_py_accept(int fd)
|
||||
{
|
||||
struct zts_sockaddr_in addrbuf = { 0 };
|
||||
socklen_t addrlen = sizeof(addrbuf);
|
||||
int err = zts_accept(fd, (struct zts_sockaddr*)&addrbuf, &addrlen);
|
||||
int err = zts_bsd_accept(fd, (struct zts_sockaddr*)&addrbuf, &addrlen);
|
||||
char ipstr[ZTS_INET_ADDRSTRLEN] = { 0 };
|
||||
zts_inet_ntop(ZTS_AF_INET, &(addrbuf.sin_addr), ipstr, ZTS_INET_ADDRSTRLEN);
|
||||
PyObject* t;
|
||||
@@ -120,7 +120,7 @@ int zts_py_listen(int fd, int backlog)
|
||||
if (backlog < 0) {
|
||||
backlog = 128;
|
||||
}
|
||||
return zts_listen(fd, backlog);
|
||||
return zts_bsd_listen(fd, backlog);
|
||||
}
|
||||
|
||||
int zts_py_bind(int fd, int family, int type, PyObject* addr_obj)
|
||||
@@ -131,7 +131,7 @@ int zts_py_bind(int fd, int family, int type, PyObject* addr_obj)
|
||||
if (zts_py_tuple_to_sockaddr(family, addr_obj, (struct zts_sockaddr*)&addrbuf, &addrlen) != ZTS_ERR_OK) {
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
Py_BEGIN_ALLOW_THREADS err = zts_bind(fd, (struct zts_sockaddr*)&addrbuf, addrlen);
|
||||
Py_BEGIN_ALLOW_THREADS err = zts_bsd_bind(fd, (struct zts_sockaddr*)&addrbuf, addrlen);
|
||||
Py_END_ALLOW_THREADS return err;
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ int zts_py_connect(int fd, int family, int type, PyObject* addr_obj)
|
||||
if (zts_py_tuple_to_sockaddr(family, addr_obj, (struct zts_sockaddr*)&addrbuf, &addrlen) != ZTS_ERR_OK) {
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
Py_BEGIN_ALLOW_THREADS err = zts_connect(fd, (struct zts_sockaddr*)&addrbuf, addrlen);
|
||||
Py_BEGIN_ALLOW_THREADS err = zts_bsd_connect(fd, (struct zts_sockaddr*)&addrbuf, addrlen);
|
||||
Py_END_ALLOW_THREADS return err;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ PyObject* zts_py_recv(int fd, int len, int flags)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bytes_read = zts_recv(fd, PyBytes_AS_STRING(buf), len, flags);
|
||||
bytes_read = zts_bsd_recv(fd, PyBytes_AS_STRING(buf), len, flags);
|
||||
t = PyTuple_New(2);
|
||||
PyTuple_SetItem(t, 0, PyLong_FromLong(bytes_read));
|
||||
|
||||
@@ -187,7 +187,7 @@ int zts_py_send(int fd, PyObject* buf, int flags)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bytes_sent = zts_send(fd, output.buf, output.len, flags);
|
||||
bytes_sent = zts_bsd_send(fd, output.buf, output.len, flags);
|
||||
PyBuffer_Release(&output);
|
||||
|
||||
return bytes_sent;
|
||||
@@ -196,7 +196,7 @@ int zts_py_send(int fd, PyObject* buf, int flags)
|
||||
int zts_py_close(int fd)
|
||||
{
|
||||
int err;
|
||||
Py_BEGIN_ALLOW_THREADS err = zts_close(fd);
|
||||
Py_BEGIN_ALLOW_THREADS err = zts_bsd_close(fd);
|
||||
Py_END_ALLOW_THREADS return err;
|
||||
}
|
||||
|
||||
|
||||
1217
src/bindings/python/libzt.py
Normal file → Executable file
1217
src/bindings/python/libzt.py
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
@@ -46,7 +46,7 @@ class socket:
|
||||
# Only create native socket if no fd was provided. We may have
|
||||
# accepted a connection
|
||||
if sock_fd is None:
|
||||
self._fd = libzt.zts_socket(sock_family, sock_type, sock_proto)
|
||||
self._fd = libzt.zts_bsd_socket(sock_family, sock_type, sock_proto)
|
||||
|
||||
def has_dualstack_ipv6(self):
|
||||
"""Return whether libzt supports dual stack sockets: yes"""
|
||||
@@ -427,4 +427,4 @@ class socket:
|
||||
- ZTS_SHUT_WR - Shut down writing side of socket.
|
||||
- ZTS_SHUT_RDWR - Both ends of the socket.
|
||||
"""
|
||||
libzt.zts_shutdown(self._fd, how)
|
||||
libzt.zts_bsd_shutdown(self._fd, how)
|
||||
|
||||
23351
src/bindings/python/zt_wrap.cxx
Normal file
23351
src/bindings/python/zt_wrap.cxx
Normal file
File diff suppressed because it is too large
Load Diff
63
src/bindings/python/zt_wrap.h
Normal file
63
src/bindings/python/zt_wrap.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 4.0.2
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef SWIG_libzt_WRAP_H_
|
||||
#define SWIG_libzt_WRAP_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
class SwigDirector_PythonDirectorCallbackClass
|
||||
: public PythonDirectorCallbackClass
|
||||
, public Swig::Director {
|
||||
public:
|
||||
SwigDirector_PythonDirectorCallbackClass(PyObject* self);
|
||||
virtual void on_zerotier_event(zts_event_msg_t* msg);
|
||||
virtual ~SwigDirector_PythonDirectorCallbackClass();
|
||||
|
||||
/* Internal director utilities */
|
||||
public:
|
||||
bool swig_get_inner(const char* swig_protected_method_name) const
|
||||
{
|
||||
std::map<std::string, bool>::const_iterator iv = swig_inner.find(swig_protected_method_name);
|
||||
return (iv != swig_inner.end() ? iv->second : false);
|
||||
}
|
||||
void swig_set_inner(const char* swig_protected_method_name, bool swig_val) const
|
||||
{
|
||||
swig_inner[swig_protected_method_name] = swig_val;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable std::map<std::string, bool> swig_inner;
|
||||
|
||||
#if defined(SWIG_PYTHON_DIRECTOR_VTABLE)
|
||||
/* VTable implementation */
|
||||
PyObject* swig_get_method(size_t method_index, const char* method_name) const
|
||||
{
|
||||
PyObject* method = vtable[method_index];
|
||||
if (! method) {
|
||||
swig::SwigVar_PyObject name = SWIG_Python_str_FromChar(method_name);
|
||||
method = PyObject_GetAttr(swig_get_self(), name);
|
||||
if (! method) {
|
||||
std::string msg = "Method in class PythonDirectorCallbackClass doesn't exist, undefined ";
|
||||
msg += method_name;
|
||||
Swig::DirectorMethodException::raise(msg.c_str());
|
||||
}
|
||||
vtable[method_index] = method;
|
||||
}
|
||||
return method;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable swig::SwigVar_PyObject vtable[1];
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user