Remove inet_ntoa, use inet_ntop
This commit is contained in:
parent
4472050fb8
commit
d4085f218e
16 changed files with 137 additions and 144 deletions
|
@ -207,7 +207,6 @@ if(HAVE_WINSOCK2_H)
|
|||
set(HAVE_GETHOSTNAME ON)
|
||||
set(HAVE_SELECT ON)
|
||||
set(HAVE_SOCKET ON)
|
||||
set(HAVE_INET_NTOA ON)
|
||||
set(HAVE_RECV ON)
|
||||
set(HAVE_SEND ON)
|
||||
set(HAVE_RECVFROM ON)
|
||||
|
@ -218,7 +217,6 @@ else(HAVE_WINSOCK2_H)
|
|||
check_function_exists(gethostname HAVE_GETHOSTNAME)
|
||||
check_function_exists(select HAVE_SELECT)
|
||||
check_function_exists(socket HAVE_SOCKET)
|
||||
check_function_exists(inet_ntoa HAVE_INET_NTOA)
|
||||
check_function_exists(recv HAVE_RECV)
|
||||
check_function_exists(send HAVE_SEND)
|
||||
check_function_exists(recvfrom HAVE_RECVFROM)
|
||||
|
|
|
@ -55,8 +55,6 @@
|
|||
#cmakedefine HAVE_SOCKET
|
||||
#cmakedefine HAVE_STRDUP
|
||||
#cmakedefine HAVE_STRTOUL
|
||||
#cmakedefine HAVE_INET_ATON
|
||||
#cmakedefine HAVE_INET_NTOA
|
||||
#cmakedefine HAVE_UNAME
|
||||
#cmakedefine HAVE_RECV
|
||||
#cmakedefine HAVE_SEND
|
||||
|
|
|
@ -87,6 +87,14 @@
|
|||
#include "anongame_infos.h"
|
||||
#include "topic.h"
|
||||
#include "i18n.h"
|
||||
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
# include <Ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#include "common/setup_after.h"
|
||||
|
||||
#ifdef WITH_LUA
|
||||
|
@ -275,9 +283,10 @@ namespace pvpgn
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (ipbanlist_check(inet_ntoa(caddr.sin_addr)) != 0)
|
||||
char addrstr[INET_ADDRSTRLEN] = { 0 };
|
||||
if (ipbanlist_check(inet_ntop(AF_INET, &(caddr.sin_addr), addrstr, sizeof(addrstr))) != 0)
|
||||
{
|
||||
eventlog(eventlog_level_info, __FUNCTION__, "[%d] connection from banned address %s denied (closing connection)", csocket, inet_ntoa(caddr.sin_addr));
|
||||
eventlog(eventlog_level_info, __FUNCTION__, "[%d] connection from banned address %s denied (closing connection)", csocket, addrstr);
|
||||
psock_close(csocket);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
|
||||
#include "compat/stdfileno.h"
|
||||
#include "compat/psock.h"
|
||||
#include "compat/inet_ntoa.h"
|
||||
#include "compat/pgetpid.h"
|
||||
#include "common/tracker.h"
|
||||
#include "common/eventlog.h"
|
||||
|
@ -39,6 +38,14 @@
|
|||
#include "common/util.h"
|
||||
#include "common/version.h"
|
||||
#include "common/bn_type.h"
|
||||
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
# include <Ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#include "common/setup_after.h"
|
||||
|
||||
using namespace pvpgn;
|
||||
|
@ -283,9 +290,11 @@ namespace {
|
|||
}
|
||||
else
|
||||
{
|
||||
char addrstr[INET_ADDRSTRLEN] = { 0 };
|
||||
inet_ntop(AF_INET, &(server->address), addrstr, sizeof(addrstr));
|
||||
if (prefs.XML_mode == 1)
|
||||
{
|
||||
std::fprintf(outfile, "<server>\n\t<address>%s</address>\n", inet_ntoa(server->address));
|
||||
std::fprintf(outfile, "<server>\n\t<address>%s</address>\n", addrstr);
|
||||
std::fprintf(outfile, "\t<port>%hu</port>\n", bn_short_nget(server->info.port));
|
||||
std::fprintf(outfile, "\t<location>%s</location>\n", server->info.server_location);
|
||||
std::fprintf(outfile, "\t<software>%s</software>\n", server->info.software);
|
||||
|
@ -305,7 +314,7 @@ namespace {
|
|||
}
|
||||
else
|
||||
{
|
||||
std::fprintf(outfile, "%s\n##\n", inet_ntoa(server->address));
|
||||
std::fprintf(outfile, "%s\n##\n", addrstr);
|
||||
std::fprintf(outfile, "%hu\n##\n", bn_short_nget(server->info.port));
|
||||
std::fprintf(outfile, "%s\n##\n", server->info.server_location);
|
||||
std::fprintf(outfile, "%s\n##\n", server->info.software);
|
||||
|
@ -410,6 +419,9 @@ namespace {
|
|||
list_append_data(serverlist_head, server);
|
||||
}
|
||||
|
||||
char addrstr2[INET_ADDRSTRLEN] = { 0 };
|
||||
inet_ntop(AF_INET, &(cliaddr.sin_addr), addrstr2, sizeof(addrstr2));
|
||||
|
||||
eventlog(eventlog_level_debug, __FUNCTION__,
|
||||
"Packet received from %s:"
|
||||
" packet_version=%u"
|
||||
|
@ -426,7 +438,7 @@ namespace {
|
|||
" uptime=%lu"
|
||||
" total_games=%lu"
|
||||
" total_logins=%lu",
|
||||
inet_ntoa(cliaddr.sin_addr),
|
||||
addrstr2,
|
||||
bn_short_nget(packet.packet_version),
|
||||
bn_int_nget(packet.flags),
|
||||
bn_short_nget(packet.port),
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "compat/termios.h"
|
||||
#include "compat/psock.h"
|
||||
#include "compat/inet_ntoa.h"
|
||||
#include "common/packet.h"
|
||||
#include "common/field_sizes.h"
|
||||
#include "common/util.h"
|
||||
|
@ -39,6 +38,14 @@
|
|||
# include "common/eventlog.h"
|
||||
#endif
|
||||
#include "client.h"
|
||||
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
# include <Ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#include "common/setup_after.h"
|
||||
|
||||
using namespace pvpgn;
|
||||
|
@ -177,7 +184,9 @@ extern int main(int argc, char * argv[])
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::printf("Connected to %s:%hu.\n", inet_ntoa(saddr.sin_addr), servport);
|
||||
char addrstr[INET_ADDRSTRLEN] = { 0 };
|
||||
inet_ntop(AF_INET, &(saddr.sin_addr), addrstr, sizeof(addrstr));
|
||||
std::printf("Connected to %s:%hu.\n", addrstr, servport);
|
||||
#ifdef CLIENTDEBUG
|
||||
eventlog_set(stderr);
|
||||
#endif
|
||||
|
|
|
@ -44,6 +44,14 @@
|
|||
# include "common/eventlog.h"
|
||||
#endif
|
||||
#include "client.h"
|
||||
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
# include <Ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#include "common/setup_after.h"
|
||||
|
||||
using namespace pvpgn;
|
||||
|
@ -419,7 +427,9 @@ extern int main(int argc, char * argv[])
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::printf("Connected to %s:%hu.\n", inet_ntoa(saddr.sin_addr), servport);
|
||||
char addrstr[INET_ADDRSTRLEN] = { 0 };
|
||||
inet_ntop(AF_INET, &(saddr.sin_addr), addrstr, sizeof(addrstr));
|
||||
std::printf("Connected to %s:%hu.\n", addrstr, servport);
|
||||
|
||||
#ifdef CLIENTDEBUG
|
||||
eventlog_set(stderr);
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "compat/termios.h"
|
||||
#include "compat/psock.h"
|
||||
#include "compat/inet_ntoa.h"
|
||||
#include "common/bnet_protocol.h"
|
||||
#include "common/util.h"
|
||||
#include "common/tag.h"
|
||||
|
@ -48,6 +47,14 @@
|
|||
*/
|
||||
#include "client_connect.h"
|
||||
#include "client.h"
|
||||
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
# include <Ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#include "common/setup_after.h"
|
||||
|
||||
|
||||
|
@ -697,7 +704,9 @@ extern int main(int argc, char * argv[])
|
|||
else
|
||||
{
|
||||
laddr.s_addr = htonl(val);
|
||||
std::printf(" Last login host: %s\n", inet_ntoa(laddr));
|
||||
char addrstr[INET_ADDRSTRLEN] = { 0 };
|
||||
inet_ntop(AF_INET, &(laddr), addrstr, sizeof(addrstr));
|
||||
std::printf(" Last login host: %s\n", addrstr);
|
||||
}
|
||||
|
||||
if (j < keys && (temp = packet_get_str_const(rpacket, strpos, 256)))
|
||||
|
@ -731,7 +740,9 @@ extern int main(int argc, char * argv[])
|
|||
else
|
||||
{
|
||||
laddr.s_addr = htonl(val);
|
||||
std::printf(" First login host: %s\n", inet_ntoa(laddr));
|
||||
char addrstr[INET_ADDRSTRLEN] = { 0 };
|
||||
inet_ntop(AF_INET, &(laddr), addrstr, sizeof(addrstr));
|
||||
std::printf(" First login host: %s\n", addrstr);
|
||||
}
|
||||
|
||||
if (j < keys && (temp = packet_get_str_const(rpacket, strpos, 256)))
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <ctime>
|
||||
|
||||
#include "compat/gethostname.h"
|
||||
#include "compat/inet_ntoa.h"
|
||||
#include "common/tag.h"
|
||||
#include "common/packet.h"
|
||||
#include "common/init_protocol.h"
|
||||
|
@ -38,6 +37,14 @@
|
|||
#endif
|
||||
#include "udptest.h"
|
||||
#include "client.h"
|
||||
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
# include <Ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#include "common/setup_after.h"
|
||||
|
||||
|
||||
|
@ -237,7 +244,9 @@ namespace pvpgn
|
|||
goto error_sd;
|
||||
}
|
||||
|
||||
std::printf("Connected to %s:%hu.\n", inet_ntoa(saddr->sin_addr), servport);
|
||||
char addrstr[INET_ADDRSTRLEN] = { 0 };
|
||||
inet_ntop(AF_INET, &(saddr->sin_addr), addrstr, sizeof(addrstr));
|
||||
std::printf("Connected to %s:%hu.\n", addrstr, servport);
|
||||
|
||||
#ifdef CLIENTDEBUG
|
||||
eventlog_set(stderr);
|
||||
|
|
|
@ -52,15 +52,17 @@ namespace pvpgn
|
|||
{
|
||||
static unsigned int curr = 0;
|
||||
static char temp[HACK_SIZE][64];
|
||||
struct sockaddr_in tsa;
|
||||
struct sockaddr_in tsa = { 0 };
|
||||
|
||||
curr = (curr + 1) % HACK_SIZE;
|
||||
|
||||
std::memset(&tsa, 0, sizeof(tsa));
|
||||
tsa.sin_family = PSOCK_AF_INET;
|
||||
tsa.sin_port = htons((unsigned short)0);
|
||||
tsa.sin_addr.s_addr = htonl(ipaddr);
|
||||
std::sprintf(temp[curr], "%.32s:%hu", inet_ntoa(tsa.sin_addr), port);
|
||||
|
||||
char addrstr[INET_ADDRSTRLEN] = { 0 };
|
||||
inet_ntop(AF_INET, &(tsa.sin_addr), addrstr, sizeof(addrstr));
|
||||
std::sprintf(temp[curr], "%.32s:%hu", addrstr, port);
|
||||
|
||||
return temp[curr];
|
||||
}
|
||||
|
@ -79,7 +81,10 @@ namespace pvpgn
|
|||
tsa.sin_family = PSOCK_AF_INET;
|
||||
tsa.sin_port = htons((unsigned short)0);
|
||||
tsa.sin_addr.s_addr = htonl(ipaddr);
|
||||
std::sprintf(temp[curr], "%.32s", inet_ntoa(tsa.sin_addr));
|
||||
|
||||
char addrstr[INET_ADDRSTRLEN] = { 0 };
|
||||
inet_ntop(AF_INET, &(tsa.sin_addr), addrstr, sizeof(addrstr));
|
||||
std::sprintf(temp[curr], "%.32s", addrstr);
|
||||
|
||||
return temp[curr];
|
||||
}
|
||||
|
@ -97,7 +102,10 @@ namespace pvpgn
|
|||
tsa.sin_family = PSOCK_AF_INET;
|
||||
tsa.sin_port = htons((unsigned short)0);
|
||||
tsa.sin_addr.s_addr = htonl(netipaddr);
|
||||
std::sprintf(temp[curr], "%.32s/0x%08x", inet_ntoa(tsa.sin_addr), netmask);
|
||||
|
||||
char addrstr[INET_ADDRSTRLEN] = { 0 };
|
||||
inet_ntop(AF_INET, &(tsa.sin_addr), addrstr, sizeof(addrstr));
|
||||
std::sprintf(temp[curr], "%.32s/0x%08x", addrstr, netmask);
|
||||
|
||||
return temp[curr];
|
||||
}
|
||||
|
@ -233,7 +241,8 @@ namespace pvpgn
|
|||
struct sockaddr_in tsa;
|
||||
|
||||
tsa.sin_addr.s_addr = htonl(defipaddr);
|
||||
hoststr = inet_ntoa(tsa.sin_addr);
|
||||
char addrstr[INET_ADDRSTRLEN] = { 0 };
|
||||
hoststr = inet_ntop(AF_INET, &(tsa.sin_addr), addrstr, sizeof(addrstr));
|
||||
}
|
||||
|
||||
if (!(hostname = host_lookup(hoststr, &ipaddr)))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
add_library(compat
|
||||
access.h gethostname.h gettimeofday.cpp gettimeofday.h inet_ntoa.cpp
|
||||
inet_ntoa.h mkdir.h mmap.cpp mmap.h netinet_in.h pdir.cpp pdir.h
|
||||
access.h gethostname.h gettimeofday.cpp gettimeofday.h
|
||||
mkdir.h mmap.cpp mmap.h netinet_in.h pdir.cpp pdir.h
|
||||
pgetopt.cpp pgetopt.h pgetpid.h psock.cpp psock.h read.h recv.h
|
||||
rename.h send.h snprintf.cpp snprintf.h socket.h statmacros.h
|
||||
stdfileno.h strcasecmp.cpp strcasecmp.h strdup.cpp strdup.h
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "common/setup_before.h"
|
||||
#ifndef HAVE_INET_NTOA
|
||||
#include "inet_ntoa.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstddef>
|
||||
|
||||
#ifdef HAVE_SYS_TYPES
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#include "common/setup_after.h"
|
||||
|
||||
|
||||
namespace pvpgn
|
||||
{
|
||||
|
||||
extern char const * inet_ntoa(struct in_addr const * addr)
|
||||
{
|
||||
static char buff[16];
|
||||
unsigned long val;
|
||||
|
||||
if (!addr)
|
||||
return NULL;
|
||||
|
||||
val = ntohl(addr->s_addr);
|
||||
std::sprintf(buff, "%u.%u.%u.%u",
|
||||
(val >> 24) & 0xff,
|
||||
(val >> 16) & 0xff,
|
||||
(val >> 8) & 0xff,
|
||||
(val)& 0xff);
|
||||
return buff;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
typedef int filenotempty; /* make ISO standard happy */
|
||||
#endif
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 1999 Ross Combs (rocombs@cs.nmsu.edu)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef INCLUDED_INET_NTOA_H
|
||||
#define INCLUDED_INET_NTOA_H
|
||||
|
||||
#ifndef HAVE_INET_NTOA
|
||||
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
|
||||
namespace pvpgn
|
||||
{
|
||||
|
||||
extern char const * inet_ntoa(struct in_addr const * addr);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -37,6 +37,14 @@
|
|||
#include "d2ladder.h"
|
||||
#include "d2charfile.h"
|
||||
#include "d2charlist.h"
|
||||
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
# include <Ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#include "common/setup_after.h"
|
||||
|
||||
|
||||
|
@ -327,7 +335,10 @@ static int on_client_creategamereq(t_connection * c, t_packet * packet)
|
|||
packet_append_string(gspacket,d2cs_conn_get_account(c));
|
||||
packet_append_string(gspacket,d2cs_conn_get_charname(c));
|
||||
addr.s_addr = htonl(d2cs_conn_get_addr(c));
|
||||
packet_append_string(gspacket,inet_ntoa(addr));
|
||||
|
||||
char addrstr[INET_ADDRSTRLEN] = { 0 };
|
||||
inet_ntop(AF_INET, &(addr), addrstr, sizeof(addrstr));
|
||||
packet_append_string(gspacket,addrstr);
|
||||
conn_push_outqueue(d2gs_get_connection(gs),gspacket);
|
||||
}
|
||||
packet_del_ref(gspacket);
|
||||
|
@ -415,7 +426,10 @@ static int on_client_joingamereq(t_connection * c, t_packet * packet)
|
|||
packet_append_string(gspacket,charname);
|
||||
packet_append_string(gspacket,account);
|
||||
addr.s_addr = htonl(d2cs_conn_get_addr(c));
|
||||
packet_append_string(gspacket,inet_ntoa(addr));
|
||||
|
||||
char addrstr[INET_ADDRSTRLEN] = { 0 };
|
||||
inet_ntop(AF_INET, &(addr), addrstr, sizeof(addrstr));
|
||||
packet_append_string(gspacket,addrstr);
|
||||
conn_push_outqueue(d2gs_get_connection(gs),gspacket);
|
||||
}
|
||||
packet_del_ref(gspacket);
|
||||
|
|
|
@ -41,6 +41,14 @@
|
|||
#include "handle_signal.h"
|
||||
#include "game.h"
|
||||
#include "d2ladder.h"
|
||||
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
# include <Ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#include "common/setup_after.h"
|
||||
|
||||
|
||||
|
@ -116,7 +124,13 @@ static int server_accept(int sock)
|
|||
if (csock<0) {
|
||||
eventlog(eventlog_level_error,__FUNCTION__,"error accept new connection");
|
||||
return -1;
|
||||
} else eventlog(eventlog_level_info,__FUNCTION__,"accept connection from %s",inet_ntoa(caddr.sin_addr));
|
||||
}
|
||||
else
|
||||
{
|
||||
char addrstr[INET_ADDRSTRLEN] = { 0 };
|
||||
inet_ntop(AF_INET, &(caddr.sin_addr), addrstr, sizeof(addrstr));
|
||||
eventlog(eventlog_level_info, __FUNCTION__, "accept connection from %s", addrstr);
|
||||
}
|
||||
|
||||
val=1;
|
||||
if (psock_setsockopt(csock, PSOCK_SOL_SOCKET, PSOCK_SO_KEEPALIVE, &val,sizeof(val))<0) {
|
||||
|
|
|
@ -37,6 +37,14 @@
|
|||
#include "charlock.h"
|
||||
#include "dbspacket.h"
|
||||
#include "handle_signal.h"
|
||||
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
# include <Ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#include "common/setup_after.h"
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -255,7 +263,9 @@ namespace pvpgn
|
|||
it->nCharsInWriteBuffer = 0;
|
||||
list_append_data(dbs_server_connection_list, it);
|
||||
in.s_addr = htonl(ipaddr);
|
||||
std::strncpy((char*)it->serverip, inet_ntoa(in), sizeof(it->serverip) - 1);
|
||||
char addrstr[INET_ADDRSTRLEN] = { 0 };
|
||||
inet_ntop(AF_INET, &(in), addrstr, sizeof(addrstr));
|
||||
std::strncpy((char*)it->serverip, addrstr, sizeof(it->serverip) - 1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -330,10 +340,12 @@ namespace pvpgn
|
|||
return;
|
||||
}
|
||||
|
||||
char addrstr[INET_ADDRSTRLEN] = { 0 };
|
||||
inet_ntop(AF_INET, &(sinRemote.sin_addr), addrstr, sizeof(addrstr));
|
||||
eventlog(eventlog_level_info, __FUNCTION__, "accepted connection from %s:%d , socket %d .",
|
||||
inet_ntoa(sinRemote.sin_addr), ntohs(sinRemote.sin_port), sd);
|
||||
addrstr, ntohs(sinRemote.sin_port), sd);
|
||||
eventlog_step(prefs_get_logfile_gs(), eventlog_level_info, __FUNCTION__, "accepted connection from %s:%d , socket %d .",
|
||||
inet_ntoa(sinRemote.sin_addr), ntohs(sinRemote.sin_port), sd);
|
||||
addrstr, ntohs(sinRemote.sin_port), sd);
|
||||
setsockopt_keepalive(sd);
|
||||
dbs_server_list_add_socket(sd, ntohl(sinRemote.sin_addr.s_addr));
|
||||
if (psock_ctl(sd, PSOCK_NONBLOCK) < 0) {
|
||||
|
|
|
@ -176,9 +176,6 @@
|
|||
/* Define if you have the index function. */
|
||||
/* #undef HAVE_INDEX */
|
||||
|
||||
/* Define if you have the inet_ntoa function. */
|
||||
#define HAVE_INET_NTOA 1
|
||||
|
||||
/* Define if you have the <inttypes.h> header file. */
|
||||
#ifdef __MINGW32__
|
||||
# define HAVE_INTTYPES_H 1
|
||||
|
|
Loading…
Reference in a new issue