Looking for DNS/Operational experience
Chris Caputo
ccaputo at alt.net
Fri May 8 07:28:43 CEST 2009
On Fri, 8 May 2009, Steve Bertrand wrote:
> - any UNIX command-line tool to convert a compressed v6 addr into a
> reverse DNS entry
Not a complete command-line tool, but one could easily be made using this
function I wrote... (below)
(Have your main() function call inet_pton() and then call this function
with the result, along with the appropriate nibblecount.)
Let me know if it would be helpful to the community for me to write the
command-line tool for this. (You'll have to suggest the clever name for
it though.)
Chris
/*
Takes a in6_addr and returns a string in reverse DNS zone file format,
for the number of nibbles needed for the DNS zone.
So "2001:0DB8::1" in an in6_addr with a nibble count of 20 will return:
"1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0"
*/
char *
myV6rDNS(struct in6_addr *in6,
int nibblecount)
{
static char buf[32 * 2 + 1]; // 32 nibbles, 32 '.'s, 1 terminator
char hex[] = "0123456789abcdef";
int i = 0;
int nibble = 0;
memset(buf, 0, sizeof(buf));
while (nibble < nibblecount)
{
if (0 != i)
buf[i++] = '.';
if (nibble % 2)
buf[i++] = hex[in6->s6_addr[15 - nibble / 2] / 16];
else
buf[i++] = hex[in6->s6_addr[15 - nibble / 2] % 16];
nibble++;
}
return buf;
}
More information about the ipv6-ops
mailing list