diff options
author | System Administrator <root@Mamadous-MacBook-Pro.local> | 2016-05-26 03:11:34 +0200 |
---|---|---|
committer | System Administrator <root@Mamadous-MacBook-Pro.local> | 2016-05-26 03:11:34 +0200 |
commit | ffcc3bed0ef69ee20c597212e4d108f87f351971 (patch) | |
tree | 02d995c2e407beb40babd73f0e0447ae7eae0d84 | |
parent | 587099ac479e27c910ae314fb258b99db8cc9895 (diff) | |
download | doubango-ffcc3bed0ef69ee20c597212e4d108f87f351971.zip doubango-ffcc3bed0ef69ee20c597212e4d108f87f351971.tar.gz |
Set default servname to 5060 when port is equal to zero
-rwxr-xr-x | tinyNET/src/tnet_utils.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/tinyNET/src/tnet_utils.c b/tinyNET/src/tnet_utils.c index 693f672..56a436a 100755 --- a/tinyNET/src/tnet_utils.c +++ b/tinyNET/src/tnet_utils.c @@ -1064,12 +1064,7 @@ tnet_socket_type_t tnet_get_type(const char* host, tnet_port_t port) const struct addrinfo *ptr = tsk_null; /* set the port: used as the default service */ - if (port) { - tsk_itoa(port, &srv); - } - else { - memset(srv, '\0', sizeof(srv)); - } + tsk_itoa(port ? port : 5060, &srv); // service must not be empty -> Android IPv6 issue memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; @@ -1118,6 +1113,7 @@ tnet_family_t tnet_get_family(const char* host, tnet_port_t port) tsk_itoa(port, &srv); } else { + TSK_DEBUG_WARN("Empty port may lead to getaddrinfo issue on Android"); memset(srv, '\0', sizeof(srv)); } @@ -1145,7 +1141,8 @@ done: tsk_bool_t tnet_is_ipv6(const char* host, tnet_port_t port) { - tnet_socket_type_t type = tnet_get_type(host, port); + // getaddrinfo with empty port fails on Android, set default port to 5060 + tnet_socket_type_t type = tnet_get_type(host, port ? port : 5060); return TNET_SOCKET_TYPE_IS_IPV6(type); } |