Jim Klimov <jimklimov@...> wrote:
> Okay, so here goes the third version of the un-bracketer :)
I was reading it and it seemed a bit overkill to me to do the
a.b.c.d -> d.c.b.a.in-addr.arpa transformation on your own. That adds
many lines and still fail to support IPv6. Is your system able to use
getnameinfo(), which is part of POSIX1?
Here is a sample proram to test, with both IPv4 or IPv6 addresses. It
even works if you supply a DNS address.
#include <stdio.h>
#include <err.h>
#include <sysexits.h>
#include <netdb.h>
int
main(argc, argv)
int argc;
char **argv;
{
char *addr;
struct addrinfo *res;
char hbuf[NI_MAXHOST];
int rc;
if (argc != 2)
errx(EX_USAGE, "%s IP", argv[0]);
addr = argv[1];
rc = getaddrinfo(addr, NULL, NULL, &res);
if (rc != 0)
errx(EX_OSERR, "failed parsing %s: %s",
addr, gai_strerror(rc));
rc = getnameinfo(res->ai_addr, res->ai_addrlen,
hbuf, sizeof(hbuf), NULL, 0, NI_NAMEREQD);
if (rc != 0)
errx(EX_OSERR, "failed resolving %s: %s",
addr, gai_strerror(rc));
freeaddrinfo(res);
printf("%s => %s\n", addr, hbuf);
return 0;
}
--
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
manu@...Message
Re: [milter-greylist] Submitter DNS name resolution and forgery detection [1 Attachment]
2013-08-14 by manu@...
Attachments
- No local attachments were found for this message.