djbdnscurve6 53
djbdnscurve6
Loading...
Searching...
No Matches
query.h
Go to the documentation of this file.
1#ifndef QUERY_H
2#define QUERY_H
3
4#include "dns.h"
5#include "uint_t.h"
6
7/* the following constants can be changed on own risk; defaults Y2018 with partial IPv6 support at provider */
8
9#define QUERY_MAXLEVEL 5 /* search depth */
10#define QUERY_MAXALIAS 16 /* glue depth */
11#define QUERY_MAXLOOP 100 /* queries per NS */
12#
13#define QUERY_MAXUDP 400 /* used by dnscache */
14#define QUERY_MAXTCP 40
15#define KEY_LEN 32
16
17/* byte patterns for well-known IP addresses and names in DNS messages */
18
19#define IP6_LOOPBACK_ARPA \
20"\0011\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\003ip6\004arpa\0"
21#define IP6_LOCALNET_ARPA \
22"\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\003ip6\004arpa\0"
23#define IP6_MULTICAST_ARPA \
24"\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\001f\001f\003ip6\004arpa\0"
25#define IP6_ALLNODESMULTICAST_ARPA \
26"\0011\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0012\0010\001f\001f\003ip6\004arpa\0"
27#define IP6_ALLROUTERSMULTICAST_ARPA \
28"\0012\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0010\0012\0010\001f\001f\003ip6\004arpa\0"
29
30#define IP6_LOOPBACK_OCTAL \
31"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001"
32#define IP6_UNSPECIFIED_OCTAL \
33"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
34#define IP6_MULTICASTPFX_OCTAL \
35"\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
36#define IP6_ALLNODES_OCTAL \
37"\377\002\000\000\000\000\000\000\000\000\000\000\000\000\000\001"
38#define IP6_ALLROUTERS_OCTAL \
39"\377\002\000\000\000\000\000\000\000\000\000\000\000\000\000\002"
40
41#define IP6_64PREFIX_OCTAL \
42"\000\144\377\233\000\000\000\000\000\000\000\000"
43
44#define IP4_LOCALHOST_ARPA \
45"\0010\0010\0010\0010\7in-addr\4arpa\0"
46#define IP4_LOOPBACK_ARPA \
47"\0011\0010\0010\003127\7in-addr\4arpa\0"
48
49#define IP4_LOOPBACK_OCTAL \
50"\177\0\0\1"
51#define IP4_LOCALHOST_OCTAL \
52"\0\0\0\0"
53
54// #define LOCALHOST IP4_LOOPBACK_OCTAL /* RFC 2606: .localhost (sec 2) */
55#define IP4_LOCALNET IP4_LOCALHOST_OCTAL
56#define IP6_LOCALNET IP6_UNSPECIFIED_OCTAL
57#define IP6_LOCALHOST IP6_LOOPBACK_OCTAL
58#define IP6_LOCALHOST_ARPA IP6_LOOPBACK_ARPA
59
60struct query {
61 unsigned int loop;
62 unsigned int level; /* query depth */
63 char *name[QUERY_MAXLEVEL]; /* query name */
64 char *control[QUERY_MAXLEVEL]; /* pointing inside name; flagusetxtformat */
65 char *ns[QUERY_MAXLEVEL][QUERY_MAXNS]; /* Name server's FQDN */
66 char servers[QUERY_MAXLEVEL][QUERY_MAXIPLEN]; /* Array of 16 byte IPs, zeroed at start */
67 char keys[QUERY_MAXLEVEL][QUERY_MAXNS * KEY_LEN]; /* a CNS has a 32 byte pubkey */
68 int flagnskeys[QUERY_MAXLEVEL]; /* presence of keys */
69 char ctx[QUERY_MAXLEVEL][QUERY_MAXNS]; /* XXX; query context */
70 char *alias[QUERY_MAXALIAS]; /* CNAME handling */
72 char ipv6[QUERY_MAXLEVEL]; /* ipv4/ipv6 switch */
73 char localip[16]; /* source IP, unique */
74 uint32 scope_id; /* source scope_id for LLU, unique */
75 char type[2]; /* query type, unique */
76 char class[2]; /* query class, unique */
77 uint32 byzg; /* Byzantinian Generals param: reliability of answer */
78 struct dns_transmit dt; /* transmission struct (dns.h) */
79};
80
81extern int query_start(struct query *,char *,char [2],char [2],char [16],uint32);
82// z, dn, type, class, local ip, scope_id
83extern int query_get(struct query *,iopause_fd *,struct taia *);
84extern void query_io(struct query *,iopause_fd *,struct taia *);
85
86extern void query_init(void);
87extern void query_forwardonly(void);
88
89#endif
#define QUERY_MAXIPLEN
Definition: dns.h:55
#define QUERY_MAXNS
Definition: dns.h:54
#define QUERY_MAXALIAS
Definition: query.h:10
void query_init(void)
Definition: query.c:22
#define KEY_LEN
Definition: query.h:15
void query_io(struct query *, iopause_fd *, struct taia *)
Definition: query.c:1222
#define QUERY_MAXLEVEL
Definition: query.h:9
int query_start(struct query *, char *, char[2], char[2], char[16], uint32)
Definition: query.c:1193
int query_get(struct query *, iopause_fd *, struct taia *)
Definition: query.c:1211
void query_forwardonly(void)
Definition: query.c:35
Definition: query.h:60
uint32 scope_id
Definition: query.h:74
char * name[QUERY_MAXLEVEL]
Definition: query.h:63
uint32 byzg
Definition: query.h:77
char localip[16]
Definition: query.h:73
char ipv6[QUERY_MAXLEVEL]
Definition: query.h:72
char * alias[QUERY_MAXALIAS]
Definition: query.h:70
char type[2]
Definition: query.h:75
unsigned int level
Definition: query.h:62
int flagnskeys[QUERY_MAXLEVEL]
Definition: query.h:68
char * control[QUERY_MAXLEVEL]
Definition: query.h:64
char keys[QUERY_MAXLEVEL][QUERY_MAXNS *KEY_LEN]
Definition: query.h:67
unsigned int loop
Definition: query.h:61
char servers[QUERY_MAXLEVEL][QUERY_MAXIPLEN]
Definition: query.h:66
char * ns[QUERY_MAXLEVEL][QUERY_MAXNS]
Definition: query.h:65
struct dns_transmit dt
Definition: query.h:78
uint32 aliasttl[QUERY_MAXALIAS]
Definition: query.h:71
char ctx[QUERY_MAXLEVEL][QUERY_MAXNS]
Definition: query.h:69