/* -*-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 --------------------------------------------------*
/*----- 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.
*
*/
#include <arpa/inet.h>
#include <netdb.h>
+#include <mLib/alloc.h>
#include <mLib/report.h>
#include <mLib/sel.h>
#include <mLib/selbuf.h>
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);