mirror of
https://github.com/rfc1036/whois.git
synced 2026-08-31 07:30:22 +00:00
Remove the inet_pton(3)-based parser
It has never worked and never will.
This commit is contained in:
parent
8a4023b315
commit
4be183d651
4
config.h
4
config.h
@ -60,10 +60,6 @@
|
||||
|
||||
/* FIXME: which systems lack this? */
|
||||
#define HAVE_GETTIMEOFDAY
|
||||
/* FIXME: disabled because it does not parse addresses with a netmask length.
|
||||
* The code using it needs to be either fixed or removed.
|
||||
#define HAVE_INET_PTON
|
||||
*/
|
||||
|
||||
/*
|
||||
* Please send patches to correctly ignore old releases which lack a RNG
|
||||
|
||||
37
whois.c
37
whois.c
@ -36,9 +36,6 @@
|
||||
#elif defined HAVE_LIBIDN
|
||||
#include <idna.h>
|
||||
#endif
|
||||
#ifdef HAVE_INET_PTON
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
/* Application-specific */
|
||||
#include "version.h"
|
||||
@ -541,12 +538,7 @@ char *guess_server(const char *s)
|
||||
return strdup(whereas32(as32));
|
||||
|
||||
/* smells like an IP? */
|
||||
#ifdef HAVE_INET_PTON
|
||||
if (inet_pton(AF_INET, s, &ip) > 0) {
|
||||
ip = ntohl(ip);
|
||||
#else
|
||||
if ((ip = myinet_aton(s))) {
|
||||
#endif
|
||||
for (i = 0; ip_assign[i].serv; i++)
|
||||
if ((ip & ip_assign[i].mask) == ip_assign[i].net)
|
||||
return strdup(ip_assign[i].serv);
|
||||
@ -1260,18 +1252,6 @@ void split_server_port(const char *const input,
|
||||
char *convert_6to4(const char *s)
|
||||
{
|
||||
char *new;
|
||||
|
||||
#ifdef HAVE_INET_PTON
|
||||
struct in6_addr ipaddr;
|
||||
unsigned char *ip;
|
||||
|
||||
if (inet_pton(AF_INET6, s, &ipaddr) <= 0)
|
||||
return strdup("0.0.0.0");
|
||||
|
||||
ip = (unsigned char *)&ipaddr;
|
||||
new = malloc(sizeof("255.255.255.255"));
|
||||
sprintf(new, "%d.%d.%d.%d", *(ip + 2), *(ip + 3), *(ip + 4), *(ip + 5));
|
||||
#else
|
||||
int items;
|
||||
unsigned int a, b;
|
||||
char c;
|
||||
@ -1290,7 +1270,6 @@ char *convert_6to4(const char *s)
|
||||
|
||||
new = malloc(sizeof("255.255.255.255"));
|
||||
sprintf(new, "%u.%u.%u.%u", a >> 8, a & 0xff, b >> 8, b & 0xff);
|
||||
#endif
|
||||
|
||||
return new;
|
||||
}
|
||||
@ -1298,19 +1277,6 @@ char *convert_6to4(const char *s)
|
||||
char *convert_teredo(const char *s)
|
||||
{
|
||||
char *new;
|
||||
|
||||
#ifdef HAVE_INET_PTON
|
||||
struct in6_addr ipaddr;
|
||||
unsigned char *ip;
|
||||
|
||||
if (inet_pton(AF_INET6, s, &ipaddr) <= 0)
|
||||
return strdup("0.0.0.0");
|
||||
|
||||
ip = (unsigned char *)&ipaddr;
|
||||
new = malloc(sizeof("255.255.255.255"));
|
||||
sprintf(new, "%d.%d.%d.%d", *(ip + 12) ^ 0xff, *(ip + 13) ^ 0xff,
|
||||
*(ip + 14) ^ 0xff, *(ip + 15) ^ 0xff);
|
||||
#else
|
||||
unsigned int a, b;
|
||||
|
||||
if (sscanf(s, "2001:%*[^:]:%*[^:]:%*[^:]:%*[^:]:%*[^:]:%x:%x", &a, &b) != 2)
|
||||
@ -1320,7 +1286,6 @@ char *convert_teredo(const char *s)
|
||||
b ^= 0xffff;
|
||||
new = malloc(sizeof("255.255.255.255"));
|
||||
sprintf(new, "%u.%u.%u.%u", a >> 8, a & 0xff, b >> 8, b & 0xff);
|
||||
#endif
|
||||
|
||||
return new;
|
||||
}
|
||||
@ -1361,7 +1326,6 @@ char *convert_inaddr(const char *s)
|
||||
return new;
|
||||
}
|
||||
|
||||
#ifndef HAVE_INET_PTON
|
||||
unsigned long myinet_aton(const char *s)
|
||||
{
|
||||
unsigned long a, b, c, d;
|
||||
@ -1377,7 +1341,6 @@ unsigned long myinet_aton(const char *s)
|
||||
return 0;
|
||||
return (a << 24) + (b << 16) + (c << 8) + d;
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned long asn32_to_long(const char *s)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user