Update Android network features.

This commit is contained in:
bossiel 2010-02-05 02:34:32 +00:00
parent 68cf4ff791
commit f019daef63
7 changed files with 93 additions and 25 deletions

View File

@ -15,10 +15,17 @@ OBJS = \
tnet_socket.o\
tnet_transport.o\
tnet_transport_poll.o\
tnet_transport_win32.o\
tnet_utils.o\
\
dns/tnet_dns.o\
tnet_utils.o
###################
## DHCP
###################
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_aaaa.o\
dns/tnet_dns_cname.o\
@ -31,15 +38,22 @@ OBJS = \
dns/tnet_dns_rr.o\
dns/tnet_dns_soa.o\
dns/tnet_dns_srv.o\
dns/tnet_dns_txt.o\
\
ice/tnet_ice.o\
\
stun/tnet_stun.o\
dns/tnet_dns_txt.o
###################
## ICE
###################
OBJS += ice/tnet_ice.o
###################
## STUN
###################
OBJS += stun/tnet_stun.o\
stun/tnet_stun_attribute.o\
stun/tnet_stun_message.o\
\
turn/tnet_turn.o\
stun/tnet_stun_message.o
###################
## TURN
###################
OBJS += turn/tnet_turn.o\
turn/tnet_turn_attribute.o\
turn/tnet_turn_message.o

View File

@ -179,7 +179,7 @@ tnet_fd_t tnet_transport_connectto(const tnet_transport_handle_t *handle, const
{
TNET_PRINT_LAST_ERROR();
tnet_sockfd_close(&fd);
//--tnet_sockfd_close(&fd);
goto bail;
}
}
@ -231,7 +231,7 @@ size_t tnet_transport_sendto(const tnet_transport_handle_t *handle, tnet_fd_t fr
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();
goto bail;

View File

@ -70,8 +70,8 @@ void tnet_getlasterror(tnet_error_t *error)
0);
}
#else
//strerror(errno);
memcpy(*error, "Unknown error.", sizeof("Unknown error"));
//FIXME: use strerror(errno);
sprintf(*error, "Network error (%d).", err);
#endif
}

View File

@ -42,7 +42,7 @@
#define RUN_TEST_ALL 0
#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_STUN 0
#define RUN_TEST_NAT 0

View File

@ -66,7 +66,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(OutDir)\tinySAK.lib $(OutDir)\tinyNET.lib"
AdditionalDependencies="$(OutDir)\tinySAK.lib $(OutDir)\tinyNET.lib ws2_32.lib"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
@ -395,6 +395,10 @@
RelativePath=".\test_transport.h"
>
</File>
<File
RelativePath=".\tnet_dhcp.h"
>
</File>
</Filter>
<File
RelativePath=".\ReadMe.txt"

View File

@ -21,7 +21,23 @@
*/
#ifndef 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 \
"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)*/{
char* message = 0;
tnet_transport_get_ip_n_port(transport, fd, &ip, &port);
//memset(ip, '\0', 46);
//memcpy(ip, "fe80::225:4bff:fe8d:84bb", strlen("fe80::225:4bff:fe8d:84bb"));
//memset(ip, 0, sizeof(ip));
//memcpy(ip, "192.168.0.12", 12);
tsk_sprintf(&message, SIP_MESSAGE, "UDP", ip, port, port, ip, port, "udp");
if(!tnet_transport_send(transport, fd, message, strlen(message)))
@ -161,17 +177,20 @@ void test_transport()
#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);
#endif
#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);
#endif
#if defined(ANDROID)
tsk_thread_sleep(1000);
#else
getchar();
//tsk_thread_sleep(2000);
#endif
#if TEST_UDP
TSK_OBJECT_SAFE_FREE(udp);
@ -180,7 +199,6 @@ void test_transport()
#if TEST_TCP
tnet_transport_shutdown(tcp);
#endif
}

View File

@ -474,6 +474,22 @@
>
</File>
</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
Name="include"
@ -618,6 +634,22 @@
>
</File>
</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
Name="smc"