djbdnscurve6  38
djbdnscurve6
dnsipq.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 "dnsipq"
8 
9 static char seed[128];
10 
11 static stralloc in;
12 static stralloc fqdn;
13 static stralloc out;
14 char ip4[IP4_FMT];
15 char ip6[IP6_FMT];
16 
17 int main(int argc,char **argv)
18 {
19  int i;
20 
22 
23  if (*argv) ++argv;
24 
25  while (*argv) {
26  if (!stralloc_copys(&in,*argv))
27  logmsg(WHO,111,FATAL,"out of memory");
28 
29  buffer_put(buffer_1,fqdn.s,fqdn.len);
30 
31  if (dns_ip6_qualify(&out,&fqdn,&in) < 0)
32  logmsg(WHO,111,FATAL,B("unable to find IP6 address for: ",*argv));
33 
34  for (i = 0; i + 16 <= out.len; i += 16) {
35  if (ip6_isv4mapped(out.s+i)) continue;
36  buffer_put(buffer_1,ip6,ip6_fmt(ip6,out.s + i));
37  buffer_puts(buffer_1," ");
38  }
39  buffer_puts(buffer_1,"\n");
40 
41  if (dns_ip4_qualify(&out,&fqdn,&in) < 0)
42  logmsg(WHO,111,FATAL,B("unable to find IP address for: ",*argv));
43 
44  for (i = 0; i + 4 <= out.len; i += 4) {
45  buffer_put(buffer_1,ip4,ip4_fmt(ip4,out.s + i));
46  buffer_puts(buffer_1," ");
47  }
48  buffer_puts(buffer_1,"\n");
49 
50  ++argv;
51  }
52 
53  buffer_flush(buffer_1);
54  _exit(0);
55 }
int dns_ip4_qualify(stralloc *, stralloc *, const stralloc *)
Definition: dns_ipq.c:109
int dns_ip6_qualify(stralloc *, stralloc *, const stralloc *)
Definition: dns_ipq.c:157
void dns_random_init(const char *)
uint32 seed[32]
Definition: dnscache-conf.c:36
int main(int argc, char **argv)
Definition: dnsipq.c:17
char ip4[IP4_FMT]
Definition: dnsipq.c:14
char ip6[IP6_FMT]
Definition: dnsipq.c:15
#define WHO
Definition: dnsipq.c:7