chiark
/
gitweb
/
~mdw
/
fwd
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
afd7451
)
Perform a forward resolution to verify result of reverse lookup.
author
mdw
<mdw>
Sat, 3 Jul 1999 13:56:04 +0000
(13:56 +0000)
committer
mdw
<mdw>
Sat, 3 Jul 1999 13:56:04 +0000
(13:56 +0000)
bres.c
patch
|
blob
|
blame
|
history
diff --git
a/bres.c
b/bres.c
index d04d15f632c33eb388361f8860edc36cddbe2067..0d09f3b0ce006ff1975c71d38cce0db28e61b507 100644
(file)
--- a/
bres.c
+++ b/
bres.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: bres.c,v 1.
1 1999/07/01 08:56:23
mdw Exp $
+ * $Id: bres.c,v 1.
2 1999/07/03 13:56:04
mdw Exp $
*
* Background reverse name resolution
*
*
* Background reverse name resolution
*
@@
-29,8
+29,11
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: bres.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: bres.c,v $
- * Revision 1.1 1999/07/01 08:56:23 mdw
- * Initial revision
+ * 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
+55,7
@@
#include <arpa/inet.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <netdb.h>
+#include <mLib/alloc.h>
#include <mLib/report.h>
#include <mLib/sel.h>
#include <mLib/selbuf.h>
#include <mLib/report.h>
#include <mLib/sel.h>
#include <mLib/selbuf.h>
@@
-166,9
+170,26
@@
static void child(int rfd, int cfd)
continue;
h = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET);
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);
p = inet_ntoa(addr);
fprintf(fp, "%s\n", p);
fflush(fp);