X-Git-Url: https://git.distorted.org.uk/~mdw/fwd/blobdiff_plain/e82f7154f65062d9ac8b9677862774498b331058..667fb920a9ace885b3ac2dc8277d104930bd2727:/bres.c diff --git a/bres.c b/bres.c index d04d15f..14541a4 100644 --- a/bres.c +++ b/bres.c @@ -1,10 +1,10 @@ /* -*-c-*- * - * $Id: bres.c,v 1.1 1999/07/01 08:56:23 mdw Exp $ + * $Id: bres.c,v 1.3 1999/07/26 23:27:22 mdw Exp $ * * Background reverse name resolution * - * (c) 1999 Mark Wooding + * (c) 1999 Straylight/Edgeware */ /*----- Licensing notice --------------------------------------------------* @@ -29,8 +29,14 @@ /*----- Revision history --------------------------------------------------* * * $Log: bres.c,v $ - * Revision 1.1 1999/07/01 08:56:23 mdw - * Initial revision + * Revision 1.3 1999/07/26 23:27:22 mdw + * Change copyright notice. + * + * Revision 1.2 1999/07/03 13:56:04 mdw + * Perform a forward resolution to verify result of reverse lookup. + * + * Revision 1.1.1.1 1999/07/01 08:56:23 mdw + * Initial revision. * */ @@ -52,6 +58,7 @@ #include #include +#include #include #include #include @@ -166,9 +173,26 @@ static void child(int rfd, int cfd) continue; h = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET); - if (h) - p = h->h_name; - else + if (h) { + char **pp; + + p = xstrdup(h->h_name); + h = gethostbyname(p); + free(p); + p = 0; + if (h) { + for (pp = h->h_addr_list; *pp; pp++) { + struct in_addr a; + memcpy(&a, *pp, sizeof(a)); + if (a.s_addr == addr.s_addr) { + p = h->h_name; + break; + } + } + } + } + + if (!p) p = inet_ntoa(addr); fprintf(fp, "%s\n", p); fflush(fp);