]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/dnstap.proto
Meson: Separate test files from common files
[thirdparty/pdns.git] / pdns / dnstap.proto
1 // dnstap: flexible, structured event replication format for DNS software
2 //
3 // This file contains the protobuf schemas for the "dnstap" structured event
4 // replication format for DNS software.
5
6 // Written in 2013-2014 by Farsight Security, Inc.
7 //
8 // To the extent possible under law, the author(s) have dedicated all
9 // copyright and related and neighboring rights to this file to the public
10 // domain worldwide. This file is distributed without any warranty.
11 //
12 // You should have received a copy of the CC0 Public Domain Dedication along
13 // with this file. If not, see:
14 //
15 // <http://creativecommons.org/publicdomain/zero/1.0/>.
16
17 syntax = "proto2";
18 package dnstap;
19
20 // "Dnstap": this is the top-level dnstap type, which is a "union" type that
21 // contains other kinds of dnstap payloads, although currently only one type
22 // of dnstap payload is defined.
23 // See: https://developers.google.com/protocol-buffers/docs/techniques#union
24 message Dnstap {
25 // DNS server identity.
26 // If enabled, this is the identity string of the DNS server which generated
27 // this message. Typically this would be the same string as returned by an
28 // "NSID" (RFC 5001) query.
29 optional bytes identity = 1;
30
31 // DNS server version.
32 // If enabled, this is the version string of the DNS server which generated
33 // this message. Typically this would be the same string as returned by a
34 // "version.bind" query.
35 optional bytes version = 2;
36
37 // Extra data for this payload.
38 // This field can be used for adding an arbitrary byte-string annotation to
39 // the payload. No encoding or interpretation is applied or enforced.
40 optional bytes extra = 3;
41
42 // Identifies which field below is filled in.
43 enum Type {
44 MESSAGE = 1;
45 }
46 required Type type = 15;
47
48 // One of the following will be filled in.
49 optional Message message = 14;
50 }
51
52 // SocketFamily: the network protocol family of a socket. This specifies how
53 // to interpret "network address" fields.
54 enum SocketFamily {
55 INET = 1; // IPv4 (RFC 791)
56 INET6 = 2; // IPv6 (RFC 2460)
57 }
58
59 // SocketProtocol: the protocol used to transport a DNS message.
60 enum SocketProtocol {
61 UDP = 1; // DNS over UDP transport (RFC 1035 section 4.2.1)
62 TCP = 2; // DNS over TCP transport (RFC 1035 section 4.2.2)
63 DOT = 3; // DNS over TLS (RFC 7858)
64 DOH = 4; // DNS over HTTPS (RFC 8484)
65 DNSCryptUDP = 5; // DNSCrypt over UDP (https://dnscrypt.info/protocol)
66 DNSCryptTCP = 6; // DNSCrypt over TCP (https://dnscrypt.info/protocol)
67 }
68
69 // Policy: information about any name server operator policy
70 // applied to the processing of a DNS message.
71 message Policy {
72
73 // Match: what aspect of the message or message exchange
74 // triggered the application of the Policy.
75 enum Match {
76 QNAME = 1; // Name in question section of query
77 CLIENT_IP = 2; // Client IP address
78 RESPONSE_IP = 3; // Address in A/AAAA RRSet
79 NS_NAME = 4; // Authoritative name server, by name
80 NS_IP = 5; // Authoritative name server, by IP address
81 }
82
83 // The Action taken to implement the Policy.
84 enum Action {
85 NXDOMAIN = 1; // Respond with NXDOMAIN
86 NODATA = 2; // Respond with empty answer section
87 PASS = 3; // Do not alter the response (passthrough)
88 DROP = 4; // Do not respond.
89 TRUNCATE = 5; // Truncate UDP response, forcing TCP retry
90 LOCAL_DATA = 6; // Respond with local data from policy
91 }
92
93 // type: the type of policy applied, e.g. "RPZ" for a
94 // policy from a Response Policy Zone.
95 optional string type = 1;
96
97 // rule: the rule matched by the message.
98 //
99 // In a RPZ context, this is the owner name of the rule in
100 // the Reponse Policy Zone in wire format.
101 optional bytes rule = 2;
102
103 // action: the policy action taken in response to the
104 // rule match.
105 optional Action action = 3;
106
107 // match: the feature of the message exchange which matched the rule.
108 optional Match match = 4;
109
110 // The matched value. Format depends on the matched feature .
111 optional bytes value = 5;
112 }
113
114 // Message: a wire-format (RFC 1035 section 4) DNS message and associated
115 // metadata. Applications generating "Message" payloads should follow
116 // certain requirements based on the MessageType, see below.
117 message Message {
118
119 // There are eight types of "Message" defined that correspond to the
120 // four arrows in the following diagram, slightly modified from RFC 1035
121 // section 2:
122
123 // +---------+ +----------+ +--------+
124 // | | query | | query | |
125 // | Stub |-SQ--------CQ->| Recursive|-RQ----AQ->| Auth. |
126 // | Resolver| | Server | | Name |
127 // | |<-SR--------CR-| |<-RR----AR-| Server |
128 // +---------+ response | | response | |
129 // +----------+ +--------+
130
131 // Each arrow has two Type values each, one for each "end" of each arrow,
132 // because these are considered to be distinct events. Each end of each
133 // arrow on the diagram above has been marked with a two-letter Type
134 // mnemonic. Clockwise from upper left, these mnemonic values are:
135 //
136 // SQ: STUB_QUERY
137 // CQ: CLIENT_QUERY
138 // RQ: RESOLVER_QUERY
139 // AQ: AUTH_QUERY
140 // AR: AUTH_RESPONSE
141 // RR: RESOLVER_RESPONSE
142 // CR: CLIENT_RESPONSE
143 // SR: STUB_RESPONSE
144
145 // Two additional types of "Message" have been defined for the
146 // "forwarding" case where an upstream DNS server is responsible for
147 // further recursion. These are not shown on the diagram above, but have
148 // the following mnemonic values:
149
150 // FQ: FORWARDER_QUERY
151 // FR: FORWARDER_RESPONSE
152
153 // The "Message" Type values are defined below.
154
155 enum Type {
156 // AUTH_QUERY is a DNS query message received from a resolver by an
157 // authoritative name server, from the perspective of the authoritative
158 // name server.
159 AUTH_QUERY = 1;
160
161 // AUTH_RESPONSE is a DNS response message sent from an authoritative
162 // name server to a resolver, from the perspective of the authoritative
163 // name server.
164 AUTH_RESPONSE = 2;
165
166 // RESOLVER_QUERY is a DNS query message sent from a resolver to an
167 // authoritative name server, from the perspective of the resolver.
168 // Resolvers typically clear the RD (recursion desired) bit when
169 // sending queries.
170 RESOLVER_QUERY = 3;
171
172 // RESOLVER_RESPONSE is a DNS response message received from an
173 // authoritative name server by a resolver, from the perspective of
174 // the resolver.
175 RESOLVER_RESPONSE = 4;
176
177 // CLIENT_QUERY is a DNS query message sent from a client to a DNS
178 // server which is expected to perform further recursion, from the
179 // perspective of the DNS server. The client may be a stub resolver or
180 // forwarder or some other type of software which typically sets the RD
181 // (recursion desired) bit when querying the DNS server. The DNS server
182 // may be a simple forwarding proxy or it may be a full recursive
183 // resolver.
184 CLIENT_QUERY = 5;
185
186 // CLIENT_RESPONSE is a DNS response message sent from a DNS server to
187 // a client, from the perspective of the DNS server. The DNS server
188 // typically sets the RA (recursion available) bit when responding.
189 CLIENT_RESPONSE = 6;
190
191 // FORWARDER_QUERY is a DNS query message sent from a downstream DNS
192 // server to an upstream DNS server which is expected to perform
193 // further recursion, from the perspective of the downstream DNS
194 // server.
195 FORWARDER_QUERY = 7;
196
197 // FORWARDER_RESPONSE is a DNS response message sent from an upstream
198 // DNS server performing recursion to a downstream DNS server, from the
199 // perspective of the downstream DNS server.
200 FORWARDER_RESPONSE = 8;
201
202 // STUB_QUERY is a DNS query message sent from a stub resolver to a DNS
203 // server, from the perspective of the stub resolver.
204 STUB_QUERY = 9;
205
206 // STUB_RESPONSE is a DNS response message sent from a DNS server to a
207 // stub resolver, from the perspective of the stub resolver.
208 STUB_RESPONSE = 10;
209
210 // TOOL_QUERY is a DNS query message sent from a DNS software tool to a
211 // DNS server, from the perspective of the tool.
212 TOOL_QUERY = 11;
213
214 // TOOL_RESPONSE is a DNS response message received by a DNS software
215 // tool from a DNS server, from the perspective of the tool.
216 TOOL_RESPONSE = 12;
217
218 // UPDATE_QUERY is a DNS update query message received from a resolver
219 // by an authoritative name server, from the perspective of the
220 // authoritative name server.
221 UPDATE_QUERY = 13;
222
223 // UPDATE_RESPONSE is a DNS update response message sent from an
224 // authoritative name server to a resolver, from the perspective of the
225 // authoritative name server.
226 UPDATE_RESPONSE = 14;
227 }
228
229 // One of the Type values described above.
230 required Type type = 1;
231
232 // One of the SocketFamily values described above.
233 optional SocketFamily socket_family = 2;
234
235 // One of the SocketProtocol values described above.
236 optional SocketProtocol socket_protocol = 3;
237
238 // The network address of the message initiator.
239 // For SocketFamily INET, this field is 4 octets (IPv4 address).
240 // For SocketFamily INET6, this field is 16 octets (IPv6 address).
241 optional bytes query_address = 4;
242
243 // The network address of the message responder.
244 // For SocketFamily INET, this field is 4 octets (IPv4 address).
245 // For SocketFamily INET6, this field is 16 octets (IPv6 address).
246 optional bytes response_address = 5;
247
248 // The transport port of the message initiator.
249 // This is a 16-bit UDP or TCP port number, depending on SocketProtocol.
250 optional uint32 query_port = 6;
251
252 // The transport port of the message responder.
253 // This is a 16-bit UDP or TCP port number, depending on SocketProtocol.
254 optional uint32 response_port = 7;
255
256 // The time at which the DNS query message was sent or received, depending
257 // on whether this is an AUTH_QUERY, RESOLVER_QUERY, or CLIENT_QUERY.
258 // This is the number of seconds since the UNIX epoch.
259 optional uint64 query_time_sec = 8;
260
261 // The time at which the DNS query message was sent or received.
262 // This is the seconds fraction, expressed as a count of nanoseconds.
263 optional fixed32 query_time_nsec = 9;
264
265 // The initiator's original wire-format DNS query message, verbatim.
266 optional bytes query_message = 10;
267
268 // The "zone" or "bailiwick" pertaining to the DNS query message.
269 // This is a wire-format DNS domain name.
270 optional bytes query_zone = 11;
271
272 // The time at which the DNS response message was sent or received,
273 // depending on whether this is an AUTH_RESPONSE, RESOLVER_RESPONSE, or
274 // CLIENT_RESPONSE.
275 // This is the number of seconds since the UNIX epoch.
276 optional uint64 response_time_sec = 12;
277
278 // The time at which the DNS response message was sent or received.
279 // This is the seconds fraction, expressed as a count of nanoseconds.
280 optional fixed32 response_time_nsec = 13;
281
282 // The responder's original wire-format DNS response message, verbatim.
283 optional bytes response_message = 14;
284
285 // Operator policy applied to the processing of this message, if any.
286 optional Policy policy = 15;
287 }
288
289 // All fields except for 'type' in the Message schema are optional.
290 // It is recommended that at least the following fields be filled in for
291 // particular types of Messages.
292
293 // AUTH_QUERY:
294 // socket_family, socket_protocol
295 // query_address, query_port
296 // query_message
297 // query_time_sec, query_time_nsec
298
299 // AUTH_RESPONSE:
300 // socket_family, socket_protocol
301 // query_address, query_port
302 // query_time_sec, query_time_nsec
303 // response_message
304 // response_time_sec, response_time_nsec
305
306 // RESOLVER_QUERY:
307 // socket_family, socket_protocol
308 // query_message
309 // query_time_sec, query_time_nsec
310 // query_zone
311 // response_address, response_port
312
313 // RESOLVER_RESPONSE:
314 // socket_family, socket_protocol
315 // query_time_sec, query_time_nsec
316 // query_zone
317 // response_address, response_port
318 // response_message
319 // response_time_sec, response_time_nsec
320
321 // CLIENT_QUERY:
322 // socket_family, socket_protocol
323 // query_message
324 // query_time_sec, query_time_nsec
325
326 // CLIENT_RESPONSE:
327 // socket_family, socket_protocol
328 // query_time_sec, query_time_nsec
329 // response_message
330 // response_time_sec, response_time_nsec