djbdnscurve6  38
djbdnscurve6
serverok.c
Go to the documentation of this file.
1 #include <sys/types.h>
2 #include <sys/stat.h>
3 #include "ip.h"
4 #include "byte.h"
5 #include "stralloc.h"
6 #include "serverok.h"
7 
8 static char fncurve[4 + IPFMT];
9 static char fnserver[4 + IPFMT];
10 
11 /* -1 no curve server
12  1 ommitt server */
13 
14 int serverok(char ip[16])
15 {
16  struct stat st;
17 
18  fncurve[0] = fnserver[0] = 'i';
19  fncurve[1] = fnserver[1] = 'p';
20  fncurve[2] = fnserver[2] = '/';
21  fncurve[3] = '-';
22  fnserver[3] = '%';
23 
24  if (byte_equal(ip,12,V4mappedprefix)) {
25  fncurve[4 + ip4_fmt(fncurve + 4,ip + 12)] = 0;
26  fnserver[4 + ip4_fmt(fnserver + 4,ip + 12)] = 0;
27  } else {
28  fncurve[4 + ip6_fmt(fncurve + 4,ip)] = 0;
29  fnserver[4 + ip6_fmt(fnserver + 4,ip)] = 0;
30  }
31 
32  if (stat(fncurve,&st) == 0) return -1;
33  if (stat(fnserver,&st) == 0) return 1;
34 
35  return 0;
36 }
char ip[16]
Definition: axfrdns.c:126
int serverok(char ip[16])
Definition: serverok.c:14