# include <string.h>
#endif
-#ifndef HAVE_INET_ATON
-# include <netinet/in.h>
-#endif
-
#include "compat.h"
-#ifndef HAVE_INET_ATON
-int bopm_inet_aton(const char *cp, struct in_addr *inp)
-{
- unsigned int a1, a2, a3, a4;
- unsigned long ret;
-
- if (strcmp(cp, "255.255.255.255") == 0)
- {
- inp->s_addr = (unsigned) -1;
- return 0;
- }
-
- if (sscanf(cp, "%u.%u.%u.%u", &a1, &a2, &a3, &a4) != 4 ||
- a1 > 255 || a2 > 255 || a3 > 255 || a4 > 255)
- {
- return 0;
- }
-
- ret = (a1 << 24) | (a2 << 16) | (a3 << 8) | a4;
-
- inp->s_addr = htonl(ret);
-
- if (inp->s_addr == (unsigned) -1)
- {
- return 0;
- }
- return 1;
-}
-#endif
-
/*
* strlcat and strlcpy were ripped from openssh 2.5.1p2
* They had the following Copyright info:
#ifndef COMPAT_H
#define COMPAT_H
-#ifndef INADDR_NONE
-#define INADDR_NONE 0xffffffff
-#endif
-
-#ifndef HAVE_INET_ATON
-#undef inet_aton
-#define inet_aton bopm_inet_aton
-extern int bopm_inet_aton(const char *cp, struct in_addr *inp);
-#endif
-
#ifndef HAVE_STRLCPY
extern size_t strlcpy(char *, const char *, size_t);
#endif
struct dnsbl_scan *ds;
- if (!inet_aton(ss->ip, &in))
+ if (inet_pton(AF_INET, ss->ip, &in) <= 0)
{
log_printf("DNSBL -> Invalid address '%s', ignoring.", ss->ip);
return;
#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>
/* glibc /etc/resolv.conf seems to allow ipv6 server names */
if (i6 < FDNS_MAX)
{
- if (inet_pton6(&buf[i], (char *)&addr6) != NULL)
+ if (inet_pton(AF_INET6, &buf[i], &addr6) > 0)
{
memcpy(&servers6[i6++],&addr6,sizeof(struct in6_addr));
continue;
#endif
if (i4 < FDNS_MAX)
{
- 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);
- }
+ if (inet_pton(AF_INET, &buf[i], &addr4) > 0)
+ memcpy(&servers4[i4++],&addr4,sizeof(struct in_addr));
}
}
}
#ifdef IPV6
if (i6 < FDNS_MAX)
{
- if (inet_pton(AF_INET6, buf, (char *)&addr6))
+ if (inet_pton(AF_INET6, buf, &addr6) > 0)
{
memcpy(&servers6[i6++], &addr6, sizeof(struct in6_addr));
continue;
#endif
if (i4 < FDNS_MAX)
{
- 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);
- }
+ if (inet_pton(AF_INET, buf, &addr4) > 0)
+ memcpy(&servers4[i4++],&addr4,sizeof(struct in_addr));
}
}
}
{ /* immediate A query */
static struct in_addr addr;
- if(inet_aton(name, &addr))
+ if (inet_pton(AF_INET, name, &addr) > 0)
return &addr;
return (struct in_addr *) firedns_resolveip(FDNS_QRY_A, name);
#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;
- 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))
+ if (inet_pton(AF_INET, IRCItem->vhost, &(IRC_LOCAL.in4.s_addr)) <= 0)
{
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, sizeof(struct in_addr));
- 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);
# include <string.h>
#endif
-#ifndef HAVE_INET_ATON
-# include <netinet/in.h>
-#endif
-
#include "compat.h"
#include "opm.h"
-
-
-#ifndef HAVE_INET_ATON
-/*
- * An implementation of inet_aton for those systems that don't have it
- * (Solaris, ...)
- */
-int libopm_inet_aton(const char *cp, struct in_addr *inp)
-{
- unsigned int a1, a2, a3, a4;
- unsigned long ret;
-
- if (strcmp(cp, "255.255.255.255") == 0) {
- inp->s_addr = (unsigned) -1;
- return 0;
- }
-
- if (sscanf(cp, "%u.%u.%u.%u", &a1, &a2, &a3, &a4) != 4 ||
- a1 > 255 || a2 > 255 || a3 > 255 || a4 > 255) {
- return 0;
- }
-
- ret = (a1 << 24) | (a2 << 16) | (a3 << 8) | a4;
-
- inp->s_addr = htonl(ret);
-
- if (inp->s_addr == (unsigned) -1) {
- return 0;
- }
- return 1;
-}
-#endif
#ifndef COMPAT_H
#define COMPAT_H
-#ifndef INADDR_NONE
-#define INADDR_NONE 0xffffffff
-#endif
-
-#ifndef HAVE_INET_ATON
-#undef inet_aton
-#define inet_aton libopm_inet_aton
-extern int libopm_inet_aton(const char *cp, struct in_addr *inp);
-#endif
#endif
break;
case OPM_TYPE_ADDRESS:
- {
- 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))
+ if (inet_pton(AF_INET, value, &(((opm_sockaddr *)config->vars[key])->sa4.sin_addr)) <= 0)
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));
scan_ip = (char *) libopm_config(scanner->config, OPM_CONFIG_SCAN_IP);
scan_port = *(int *) libopm_config(scanner->config, OPM_CONFIG_SCAN_PORT);
- if (inet_aton(scan_ip, &addr) == 0)
+ if (inet_pton(AF_INET, scan_ip, &addr) <= 0)
; /* handle error */
laddr = htonl(addr.s_addr);
scan_ip = (char *) libopm_config(scanner->config, OPM_CONFIG_SCAN_IP);
scan_port = *(int *) libopm_config(scanner->config, OPM_CONFIG_SCAN_PORT);
- if (inet_aton(scan_ip, &addr) == 0)
+ if (inet_pton(AF_INET, scan_ip, &addr) <= 0)
; /* handle error */
laddr = htonl(addr.s_addr);
#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 (getaddrinfo(ipstr, NULL, &hints, &res))
+ if (!inet_pton(AF_INET, ipstr, &(ip.sa4.sin_addr)))
{
log_printf("NEGCACHE -> Invalid IPv4 address '%s'", ipstr);
return;
}
- memcpy(&ip.sa4.sin_addr, &((struct sockaddr_in *)res->ai_addr)->sin_addr, sizeof(struct in_addr));
- 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)
{
- 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))
+ if (inet_pton(AF_INET, user[3], &(ip.sa4.sin_addr)) <= 0)
{
log_printf("SCAN -> Invalid IPv4 address '%s'!", user[3]);
return;
}
else
{
- memcpy(&ip.sa4.sin_addr, &((struct sockaddr_in *)res->ai_addr)->sin_addr, sizeof(struct in_addr));
- freeaddrinfo(res);
-
if (check_neg_cache(ip.sa4.sin_addr.s_addr))
{
if (OPT_DEBUG)