#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <netdb.h>
#include <sys/poll.h>
#include <sys/time.h>
#include <netinet/in.h>
#endif
if (i4 < FDNS_MAX)
{
- if (inet_aton(&buf[i], &addr4))
- {
- memcpy(&servers4[i4++],&addr4,sizeof(struct in_addr));
- }
- }
+ struct addrinfo hints, *res;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
+
+ if (!getaddrinfo(&buf[i], NULL, &hints, &res))
+ {
+ memcpy(&servers4[i4++], &((struct sockaddr_in *)res->ai_addr)->sin_addr, sizeof(struct in_addr));
+ freeaddrinfo(res);
+ }
+ }
}
}
}
#endif
if (i4 < FDNS_MAX)
{
- if (inet_pton(AF_INET, buf, (char *)&addr4))
- memcpy(&servers4[i4++],&addr4,sizeof(struct in_addr));
+ struct addrinfo hints, *res;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
+
+ if (!getaddrinfo(&buf[i], NULL, &hints, &res))
+ {
+ memcpy(&servers4[i4++], &((struct sockaddr_in *)res->ai_addr)->sin_addr, sizeof(struct in_addr));
+ freeaddrinfo(res);
+ }
}
}
}
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <netdb.h>
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
/* Bind */
if (!EmptyString(IRCItem->vhost))
{
+ struct addrinfo hints, *res;
int bindret = 0;
- if (!inet_pton(AF_INET, IRCItem->vhost, &(IRC_LOCAL.in4.s_addr)))
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
+
+ if (getaddrinfo(IRCItem->vhost, NULL, &hints, &res))
{
log_printf("IRC -> bind(): %s is an invalid address", IRCItem->vhost);
exit(EXIT_FAILURE);
}
+ memcpy(&IRC_LOCAL.in4.s_addr, &((struct sockaddr_in *)res->ai_addr)->sin_addr, res->ai_addrlen);
+ freeaddrinfo(res);
+
bsaddr.sa4.sin_addr.s_addr = IRC_LOCAL.in4.s_addr;
bsaddr.sa4.sin_family = AF_INET;
bsaddr.sa4.sin_port = htons(0);
break;
case OPM_TYPE_ADDRESS:
- if( inet_pton(AF_INET, value, &( ((opm_sockaddr *)config->vars[key])->sa4.sin_addr))
- <= 0)
- return OPM_ERR_BADVALUE; /* return appropriate err code */
- break;
+ {
+ struct addrinfo hints, *res;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
+
+ if (getaddrinfo(value, NULL, &hints, &res))
+ return OPM_ERR_BADVALUE; /* return appropriate err code */
+
+ memcpy(&(((opm_sockaddr *)config->vars[key])->sa4.sin_addr), &((struct sockaddr_in *)res->ai_addr)->sin_addr, sizeof(struct in_addr));
+ freeaddrinfo(res);
+ break;
+ }
case OPM_TYPE_STRINGLIST:
node = libopm_node_create(libopm_xstrdup(value));
#ifdef STDC_HEADERS
#include <stdlib.h>
#endif
+#include <string.h>
#ifdef TIME_WITH_SYS_TIME
#include <sys/time.h>
# endif
#endif
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+
#include "inet.h"
#include "irc.h"
#include "negcache.h"
{
struct bopm_sockaddr ip;
struct cnode *n;
+ struct addrinfo hints, *res;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
- if (!inet_pton(AF_INET, ipstr, &(ip.sa4.sin_addr)))
+ if (getaddrinfo(ipstr, NULL, &hints, &res))
{
log_printf("NEGCACHE -> Invalid IPv4 address '%s'", ipstr);
return;
}
+ memcpy(&ip.sa4.sin_addr, &((struct sockaddr_in *)res->ai_addr)->sin_addr, res->ai_addrlen);
+ freeaddrinfo(res);
+
n = nc_insert(nc_head, ip.sa4.sin_addr.s_addr);
if (n)
#include <errno.h>
#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+
#ifdef HAVE_SYS_POLL_H
# include <sys/poll.h>
#endif
/* Check negcache before anything */
if (OptionsItem->negcache > 0)
{
- if (!inet_pton(AF_INET, user[3], &(ip.sa4.sin_addr)))
+ struct addrinfo hints, *res;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
+
+ if (getaddrinfo(user[3], NULL, &hints, &res))
{
log_printf("SCAN -> Invalid IPv4 address '%s'!", user[3]);
return;
}
else
{
+ memcpy(&ip.sa4.sin_addr, &((struct sockaddr_in *)res->ai_addr)->sin_addr, res->ai_addrlen);
+ freeaddrinfo(res);
+
if (check_neg_cache(ip.sa4.sin_addr.s_addr))
{
if (OPT_DEBUG)