Skip to content
Snippets Groups Projects
Commit e574155e authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Don't use inet_ntop() on Windows as XP didn't include it

As reported by cadeon on Vertrauen, Synchronet v3.19 hasn't worked on Windows XP due to error:
'The procedure entry point inet_ntop could not be located in the dynamic link library WS2_32.dll'
parent 4c19e4fb
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
...@@ -5731,9 +5731,8 @@ NO_SSH: ...@@ -5731,9 +5731,8 @@ NO_SSH:
result = connect(new_node->passthru_socket, (struct sockaddr *)&tmp_addr, tmp_addr_len); result = connect(new_node->passthru_socket, (struct sockaddr *)&tmp_addr, tmp_addr_len);
if(result != 0) { if(result != 0) {
inet_ntop(tmp_addr.sin_family, &tmp_addr.sin_addr, addr_str, sizeof(addr_str));
lprintf(LOG_ERR,"Node %d !ERROR %d (%d) connecting to passthru socket: %s port %u" lprintf(LOG_ERR,"Node %d !ERROR %d (%d) connecting to passthru socket: %s port %u"
,new_node->cfg.node_num, result, ERROR_VALUE, addr_str, htons(tmp_addr.sin_port)); ,new_node->cfg.node_num, result, ERROR_VALUE, inet_ntoa(tmp_addr.sin_addr), htons(tmp_addr.sin_port));
close_socket(new_node->passthru_socket); close_socket(new_node->passthru_socket);
new_node->passthru_socket=INVALID_SOCKET; new_node->passthru_socket=INVALID_SOCKET;
close_socket(tmp_sock); close_socket(tmp_sock);
......
...@@ -151,19 +151,25 @@ struct in6_addr parseIPv6Address(const char* value) ...@@ -151,19 +151,25 @@ struct in6_addr parseIPv6Address(const char* value)
const char* IPv4AddressToStr(uint32_t addr, char* dest, size_t size) const char* IPv4AddressToStr(uint32_t addr, char* dest, size_t size)
{ {
const char* result; #if defined _WIN32
struct in_addr in_addr; int result;
in_addr.s_addr = htonl(addr); WSADATA wsaData;
#if defined(__BORLANDC__) || defined(__MINGW32__) SOCKADDR_IN sockaddr = {0};
result = inet_ntoa(in_addr); // deprecated function call sockaddr.sin_family = AF_INET;
if(result == NULL) sockaddr.sin_addr.s_addr = htonl(addr);
if(WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
return NULL; return NULL;
strncpy(dest, result, size); result = getnameinfo((SOCKADDR*)&sockaddr, sizeof(sockaddr), dest, size, NULL, 0, NI_NUMERICHOST);
result = dest; WSACleanup();
if(result != 0)
return NULL;
return dest;
#else #else
result = inet_ntop(AF_INET, &in_addr, dest, size); struct in_addr in_addr;
in_addr.s_addr = htonl(addr);
return inet_ntop(AF_INET, &in_addr, dest, size);
#endif #endif
return result;
} }
#if NETWRAP_TEST #if NETWRAP_TEST
...@@ -180,6 +186,7 @@ int main(int argc, char** argv) ...@@ -180,6 +186,7 @@ int main(int argc, char** argv)
if(argc>1) if(argc>1)
printf("%s\n", getHostNameByAddr(argv[1])); printf("%s\n", getHostNameByAddr(argv[1]));
return 0; return 0;
} }
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment