summaryrefslogtreecommitdiff
path: root/whois.c
diff options
context:
space:
mode:
authorMarco d'Itri <md@linux.it>2005-01-30 13:51:30 +0100
committerMarco d'Itri <md@linux.it>2013-03-30 02:31:31 +0100
commitc30d63196924e6f5d42a11bbbd545e11c379fb4b (patch)
treedbea38919dc135af32cc8abf7ffd32f3f56680cb /whois.c
parent58afbcd036c29483acfc91a94830c09365b151af (diff)
downloadwhois-c30d63196924e6f5d42a11bbbd545e11c379fb4b.tar.gz
Imported Debian version 4.7.0v4.7.0
Diffstat (limited to 'whois.c')
-rw-r--r--whois.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/whois.c b/whois.c
index 6167e43..a8c5829 100644
--- a/whois.c
+++ b/whois.c
@@ -341,36 +341,28 @@ const char *whichwhois(const char *s)
{
unsigned long ip;
unsigned int i;
+ char *colon;
/* IPv6 address */
- if (strchr(s, ':')) {
+ if ((colon = strchr(s, ':'))) {
unsigned long v6prefix, v6net;
- const struct ip6_del *ip6_assign;
+
+ /* RPSL hierarchical objects like AS8627:fltr-TRANSIT-OUT */
+ if (strncasecmp(s, "as", 2) == 0 && isasciidigit(s[2]))
+ return whereas(atoi(s + 2));
v6prefix = strtol(s, NULL, 16);
- if (v6prefix == 0) {
- /* RPSL hierarchical object like AS8627:fltr-TRANSIT-OUT */
- if (strncasecmp(s, "as", 2) == 0 && isasciidigit(s[2]))
- return whereas(atoi(s + 2));
- return "\x05";
- } else if (v6prefix == 0x3FFE) {
- return "whois.6bone.net";
- } else if (v6prefix == 0x2002) {
- return "\x0A";
- } else if (v6prefix == 0x2001) {
- v6net = strtol(s + 5, NULL, 16); /* second u16 */
- v6net = (v6net & 0xFE00) >> 8; /* first 7 bits */
- ip6_assign = ip6_assign_misc;
- } else if (v6prefix >= 0x2400 && v6prefix <= 0x3A00) {
- v6net = (v6prefix & 0xFC00) >> 8; /* first 6 bits */
- ip6_assign = ip6_assign_rirs;
- } else
- return "\x06";
-
- for (i = 0; ip6_assign[i].serv; i++)
- if (v6net == ip6_assign[i].net)
+ if (v6prefix == 0)
+ return "\x05"; /* unknown */
+
+ v6net = (v6prefix << 16) + strtol(colon + 1, NULL, 16);/* second u16 */
+
+ for (i = 0; ip6_assign[i].serv; i++) {
+ if ((v6net & (~0UL << (32 - ip6_assign[i].masklen)))
+ == ip6_assign[i].net)
return ip6_assign[i].serv;
+ }
return "\x06"; /* unknown allocation */
}