Update Android network features.
This commit is contained in:
parent
68cf4ff791
commit
f019daef63
|
@ -15,10 +15,17 @@ OBJS = \
|
||||||
tnet_socket.o\
|
tnet_socket.o\
|
||||||
tnet_transport.o\
|
tnet_transport.o\
|
||||||
tnet_transport_poll.o\
|
tnet_transport_poll.o\
|
||||||
tnet_transport_win32.o\
|
tnet_utils.o
|
||||||
tnet_utils.o\
|
###################
|
||||||
\
|
## DHCP
|
||||||
dns/tnet_dns.o\
|
###################
|
||||||
|
OBJS += dhcp/tnet_dhcp.o\
|
||||||
|
dhcp/tnet_dhcp_message.o\
|
||||||
|
dhcp/tnet_dhcp_option.o
|
||||||
|
###################
|
||||||
|
## DDNS
|
||||||
|
###################
|
||||||
|
OBJS += dns/tnet_dns.o\
|
||||||
dns/tnet_dns_a.o\
|
dns/tnet_dns_a.o\
|
||||||
dns/tnet_dns_aaaa.o\
|
dns/tnet_dns_aaaa.o\
|
||||||
dns/tnet_dns_cname.o\
|
dns/tnet_dns_cname.o\
|
||||||
|
@ -31,15 +38,22 @@ OBJS = \
|
||||||
dns/tnet_dns_rr.o\
|
dns/tnet_dns_rr.o\
|
||||||
dns/tnet_dns_soa.o\
|
dns/tnet_dns_soa.o\
|
||||||
dns/tnet_dns_srv.o\
|
dns/tnet_dns_srv.o\
|
||||||
dns/tnet_dns_txt.o\
|
dns/tnet_dns_txt.o
|
||||||
\
|
###################
|
||||||
ice/tnet_ice.o\
|
## ICE
|
||||||
\
|
###################
|
||||||
stun/tnet_stun.o\
|
OBJS += ice/tnet_ice.o
|
||||||
|
|
||||||
|
###################
|
||||||
|
## STUN
|
||||||
|
###################
|
||||||
|
OBJS += stun/tnet_stun.o\
|
||||||
stun/tnet_stun_attribute.o\
|
stun/tnet_stun_attribute.o\
|
||||||
stun/tnet_stun_message.o\
|
stun/tnet_stun_message.o
|
||||||
\
|
###################
|
||||||
turn/tnet_turn.o\
|
## TURN
|
||||||
|
###################
|
||||||
|
OBJS += turn/tnet_turn.o\
|
||||||
turn/tnet_turn_attribute.o\
|
turn/tnet_turn_attribute.o\
|
||||||
turn/tnet_turn_message.o
|
turn/tnet_turn_message.o
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ tnet_fd_t tnet_transport_connectto(const tnet_transport_handle_t *handle, const
|
||||||
{
|
{
|
||||||
TNET_PRINT_LAST_ERROR();
|
TNET_PRINT_LAST_ERROR();
|
||||||
|
|
||||||
tnet_sockfd_close(&fd);
|
//--tnet_sockfd_close(&fd);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ size_t tnet_transport_sendto(const tnet_transport_handle_t *handle, tnet_fd_t fr
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((numberOfBytesSent = sendto(from, buf, size, 0, to, sizeof(*to))) == 0)
|
if((numberOfBytesSent = sendto(from, buf, size, 0, to, sizeof(*to))) <= 0)
|
||||||
{
|
{
|
||||||
TNET_PRINT_LAST_ERROR();
|
TNET_PRINT_LAST_ERROR();
|
||||||
goto bail;
|
goto bail;
|
||||||
|
|
|
@ -70,8 +70,8 @@ void tnet_getlasterror(tnet_error_t *error)
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
//strerror(errno);
|
//FIXME: use strerror(errno);
|
||||||
memcpy(*error, "Unknown error.", sizeof("Unknown error"));
|
sprintf(*error, "Network error (%d).", err);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
#define RUN_TEST_ALL 0
|
#define RUN_TEST_ALL 0
|
||||||
#define RUN_TEST_SOCKETS 0 /* FIXME: Android */
|
#define RUN_TEST_SOCKETS 0 /* FIXME: Android */
|
||||||
#define RUN_TEST_TRANSPORT 0
|
#define RUN_TEST_TRANSPORT 1
|
||||||
#define RUN_TEST_AUTH 0
|
#define RUN_TEST_AUTH 0
|
||||||
#define RUN_TEST_STUN 0
|
#define RUN_TEST_STUN 0
|
||||||
#define RUN_TEST_NAT 0
|
#define RUN_TEST_NAT 0
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="$(OutDir)\tinySAK.lib $(OutDir)\tinyNET.lib"
|
AdditionalDependencies="$(OutDir)\tinySAK.lib $(OutDir)\tinyNET.lib ws2_32.lib"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
|
@ -395,6 +395,10 @@
|
||||||
RelativePath=".\test_transport.h"
|
RelativePath=".\test_transport.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\tnet_dhcp.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\ReadMe.txt"
|
RelativePath=".\ReadMe.txt"
|
||||||
|
|
|
@ -21,7 +21,23 @@
|
||||||
*/
|
*/
|
||||||
#ifndef TNET_TEST_TRANSPORT_H
|
#ifndef TNET_TEST_TRANSPORT_H
|
||||||
#define TNET_TEST_TRANSPORT_H
|
#define TNET_TEST_TRANSPORT_H
|
||||||
#define REMOTE_IP /*"2a01:e35:8632:7050:6122:2706:2124:32cb"*/ "192.168.0.15"
|
|
||||||
|
#define REMOTE_IP4 "192.168.0.15"
|
||||||
|
#define REMOTE_IP6 "2a01:e35:8632:7050:6122:2706:2124:32cb"
|
||||||
|
#define REMOTE_IP REMOTE_IP4
|
||||||
|
|
||||||
|
#if defined(ANDROID) /* FIXME */
|
||||||
|
# define LOCAL_IP4 "10.0.2.15"
|
||||||
|
#else
|
||||||
|
# define LOCAL_IP4 TNET_SOCKET_HOST_ANY
|
||||||
|
#endif
|
||||||
|
#define LOCAL_IP6 TNET_SOCKET_HOST_ANY
|
||||||
|
|
||||||
|
#if /*defined(ANDROID)*/1
|
||||||
|
# define LOCAL_PORT TNET_SOCKET_PORT_ANY
|
||||||
|
#else
|
||||||
|
# define LOCAL_PORT TNET_SOCKET_PORT_ANY
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SIP_MESSAGE \
|
#define SIP_MESSAGE \
|
||||||
"REGISTER sip:micromethod.com SIP/2.0\r\n" \
|
"REGISTER sip:micromethod.com SIP/2.0\r\n" \
|
||||||
|
@ -137,8 +153,8 @@ int test_transport_udp_ipv4(tnet_transport_handle_t *transport)
|
||||||
/*while(1)*/{
|
/*while(1)*/{
|
||||||
char* message = 0;
|
char* message = 0;
|
||||||
tnet_transport_get_ip_n_port(transport, fd, &ip, &port);
|
tnet_transport_get_ip_n_port(transport, fd, &ip, &port);
|
||||||
//memset(ip, '\0', 46);
|
//memset(ip, 0, sizeof(ip));
|
||||||
//memcpy(ip, "fe80::225:4bff:fe8d:84bb", strlen("fe80::225:4bff:fe8d:84bb"));
|
//memcpy(ip, "192.168.0.12", 12);
|
||||||
tsk_sprintf(&message, SIP_MESSAGE, "UDP", ip, port, port, ip, port, "udp");
|
tsk_sprintf(&message, SIP_MESSAGE, "UDP", ip, port, port, ip, port, "udp");
|
||||||
|
|
||||||
if(!tnet_transport_send(transport, fd, message, strlen(message)))
|
if(!tnet_transport_send(transport, fd, message, strlen(message)))
|
||||||
|
@ -161,17 +177,20 @@ void test_transport()
|
||||||
|
|
||||||
|
|
||||||
#if TEST_UDP
|
#if TEST_UDP
|
||||||
tnet_transport_handle_t *udp = TNET_TRANSPORT_CREATE(TNET_SOCKET_HOST_ANY, TNET_SOCKET_PORT_ANY, tnet_socket_type_udp_ipv4, "UDP/IPV4 TRANSPORT");
|
tnet_transport_handle_t *udp = TNET_TRANSPORT_CREATE(LOCAL_IP4, LOCAL_PORT, tnet_socket_type_udp_ipv4, "UDP/IPV4 TRANSPORT");
|
||||||
test_transport_udp_ipv4(udp);
|
test_transport_udp_ipv4(udp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TEST_TCP
|
#if TEST_TCP
|
||||||
tnet_transport_handle_t *tcp = TNET_TRANSPORT_CREATE(TNET_SOCKET_HOST_ANY, TNET_SOCKET_PORT_ANY, tnet_socket_type_tcp_ipv4, "TCP/IPV4 TRANSPORT");
|
tnet_transport_handle_t *tcp = TNET_TRANSPORT_CREATE(LOCAL_IP4, LOCAL_PORT, tnet_socket_type_tcp_ipv4, "TCP/IPV4 TRANSPORT");
|
||||||
test_transport_tcp_ipv4(tcp);
|
test_transport_tcp_ipv4(tcp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ANDROID)
|
||||||
|
tsk_thread_sleep(1000);
|
||||||
|
#else
|
||||||
getchar();
|
getchar();
|
||||||
//tsk_thread_sleep(2000);
|
#endif
|
||||||
|
|
||||||
#if TEST_UDP
|
#if TEST_UDP
|
||||||
TSK_OBJECT_SAFE_FREE(udp);
|
TSK_OBJECT_SAFE_FREE(udp);
|
||||||
|
@ -180,7 +199,6 @@ void test_transport()
|
||||||
#if TEST_TCP
|
#if TEST_TCP
|
||||||
tnet_transport_shutdown(tcp);
|
tnet_transport_shutdown(tcp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -474,6 +474,22 @@
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="dhcp"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\dhcp\tnet_dhcp.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\dhcp\tnet_dhcp_message.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\dhcp\tnet_dhcp_option.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="include"
|
Name="include"
|
||||||
|
@ -618,6 +634,22 @@
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="dhcp"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\dhcp\tnet_dhcp.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\dhcp\tnet_dhcp_message.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\dhcp\tnet_dhcp_option.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="smc"
|
Name="smc"
|
||||||
|
|
Loading…
Reference in New Issue