1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include <unistd.h>
#include "buffer.h"
#include "dnsresolv.h"
#include "exit.h"
#include "ip.h"
#include "logmsg.h"
#include "str.h"
#include "stralloc.h"
#include "dns.h"
#define WHO "dnsptr"
stralloc out = {0};
char ip4[4];
char ip6[16];
int main(int argc, char **argv)
{
if (!argv[1]) logmsg(WHO, 100, USAGE, "dnsptr ipv4 || ipv6 (compactified)");
DNS_INIT
if (str_chr(argv[1], ':') < str_len(argv[1])) {
if (!ip6_scan(argv[1], ip6)) logmsg(WHO, 111, FATAL, "wrong IPv6 format");
if (dns_name6(&out, ip6) > 0) buffer_put(buffer_1, out.s, out.len);
} else {
if (!ip4_scan(argv[1], ip4)) logmsg(WHO, 111, FATAL, "wrong IPv4 format");
if (dns_name4(&out, ip4) > 0) buffer_put(buffer_1, out.s, out.len);
}
buffer_putsflush(buffer_1, "\n");
_exit(0);
}
|