inet_aton to inet_pton

pull/10/head
yuqing 2016-05-17 21:21:29 +08:00
parent ce39cdd497
commit 094f3900c1
4 changed files with 17 additions and 14 deletions

View File

@ -1,6 +1,7 @@
Version 1.28 2016-05-14 Version 1.28 2016-05-17
* id generator support extra bits * id generator support extra bits
* change inet_aton to inet_pton
Version 1.27 2016-04-15 Version 1.27 2016-04-15
* add function fd_set_cloexec * add function fd_set_cloexec

View File

@ -122,7 +122,7 @@ static int conn_pool_get_key(const ConnectionInfo *conn, char *key, int *key_len
{ {
struct in_addr sin_addr; struct in_addr sin_addr;
if (inet_aton(conn->ip_addr, &sin_addr) == 0) if (inet_pton(AF_INET, conn->ip_addr, &sin_addr) == 0)
{ {
*key_len = 0; *key_len = 0;
return EINVAL; return EINVAL;

View File

@ -1886,8 +1886,10 @@ int load_allow_hosts(IniContext *pIniContext, \
for (i=0; i<*allow_ip_count; i++) for (i=0; i<*allow_ip_count; i++)
{ {
struct in_addr address; struct in_addr address;
char buff[INET_ADDRSTRLEN];
address.s_addr = (*allow_ip_addrs)[i]; address.s_addr = (*allow_ip_addrs)[i];
logDebug("%d. %s", i + 1, inet_ntoa(address)); logDebug("%d. %s", i + 1, inet_ntop(AF_INET, &address,
buff, sizeof(buff)));
} }
return 0; return 0;

View File

@ -465,7 +465,7 @@ int connectserverbyip(int sock, const char *server_ip, const short server_port)
addr.sin_family = PF_INET; addr.sin_family = PF_INET;
addr.sin_port = htons(server_port); addr.sin_port = htons(server_port);
result = inet_aton(server_ip, &addr.sin_addr); result = inet_pton(AF_INET, server_ip, &addr.sin_addr);
if (result == 0 ) if (result == 0 )
{ {
return EINVAL; return EINVAL;
@ -501,7 +501,7 @@ int connectserverbyip_nb_ex(int sock, const char *server_ip, \
addr.sin_family = PF_INET; addr.sin_family = PF_INET;
addr.sin_port = htons(server_port); addr.sin_port = htons(server_port);
result = inet_aton(server_ip, &addr.sin_addr); result = inet_pton(AF_INET, server_ip, &addr.sin_addr);
if (result == 0 ) if (result == 0 )
{ {
return EINVAL; return EINVAL;
@ -754,7 +754,7 @@ int socketBind(int sock, const char *bind_ipaddr, const int port)
} }
else else
{ {
if (inet_aton(bind_ipaddr, &bindaddr.sin_addr) == 0) if (inet_pton(AF_INET, bind_ipaddr, &bindaddr.sin_addr) == 0)
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, " \
"invalid ip addr %s", \ "invalid ip addr %s", \