Slight re-org of C API naming convention
This commit is contained in:
@@ -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