djbdnscurve6  38
djbdnscurve6
dnsip.c
Go to the documentation of this file.
1 #include "buffer.h"
2 #include "exit.h"
3 #include "logmsg.h"
4 #include "ip.h"
5 #include "dns.h"
6 
7 #define WHO "dnsip"
8 
9 static char seed[128];
10 
11 static stralloc fqdn;
12 static stralloc out;
13 
14 int main(int argc,char **argv)
15 {
16  int i;
17  char ip4str[IP4_FMT];
18  char ip6str[IP6_FMT];
19 
21 
22  if (*argv) ++argv;
23 
24  while (*argv) {
25  if (!stralloc_copys(&fqdn,*argv))
26  logmsg(WHO,111,FATAL,"out of memory");
27 
28  if ((i = dns_ip6(&out,&fqdn)) > 0) {
29  for (i = 0; i + 16 <= out.len; i += 16) {
30  if (ip6_isv4mapped(out.s + i)) continue;
31  buffer_put(buffer_1,ip6str,ip6_fmt(ip6str,out.s + i));
32  buffer_puts(buffer_1," ");
33  }
34  }
35 
36  if ((i = dns_ip4(&out,&fqdn)) > 0)
37  for (i = 0; i + 4 <= out.len; i += 4) {
38  buffer_put(buffer_1,ip4str,ip4_fmt(ip4str,out.s + i));
39  buffer_puts(buffer_1," ");
40  }
41 
42  ++argv;
43  buffer_puts(buffer_1,"\n");
44  }
45 
46  buffer_flush(buffer_1);
47  _exit(0);
48 }
int dns_ip4(stralloc *, stralloc *)
Definition: dns_ip.c:42
int dns_ip6(stralloc *, stralloc *)
Definition: dns_ip.c:134
void dns_random_init(const char *)
uint32 seed[32]
Definition: dnscache-conf.c:36
int main(int argc, char **argv)
Definition: dnsip.c:14
#define WHO
Definition: dnsip.c:7
char ip6str[IP6_FMT]
Definition: tinydns-edit.c:67
char ip4str[IP4_FMT]
Definition: tinydns-edit.c:66