Slight re-org of C API naming convention

This commit is contained in:
Joseph Henry
2021-05-05 16:19:27 -07:00
parent 85b861da2f
commit 9151f4471c
25 changed files with 24963 additions and 1518 deletions

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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,

View File

@@ -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);
}

View File

@@ -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");
}
}