domain/base/iana/
opt.rs

1//! DNS EDNS0 pption codes.
2
3//------------ OptionCode ----------------------------------------------------
4
5int_enum! {
6    /// DNS EDNS0 option codes.
7    ///
8    /// The record data of [OPT] records is a sequence of options. The type of
9    /// each of these options is given through a 16 bit value called *option
10    /// code.*
11    ///
12    /// The currently assigned option codes can be found in the
13    /// [IANA registry]. The type is complete as of 2019-12-23.
14    ///
15    /// [OPT]: ../../opt/index.html
16    /// [IANA registry]: http://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-11
17    =>
18    OptionCode, u16;
19
20    /// Long-Lived Queries (LLQ, 1).
21    ///
22    /// Long-Lived Queries is a protocol developed by Apple for change
23    /// notifications. It is now being replaced by DNS Push Notifications.
24    /// The LLQ options is used in LLQ messages.
25    ///
26    /// This option code and the LLQ option are defined in a upcoming RFC,
27    /// currently [draft-sekar-dns-llq].
28    ///
29    /// [draft-sekar-dns-llq]: https://datatracker.ietf.org/doc/draft-sekar-dns-llq/
30    (Llq => 1, b"LLQ")
31
32    /// Update lease (UL, 2).
33    ///
34    /// This option was proposed in a draft as a way to state lease times for
35    /// registrations made via DNS UPDATE. Its draft, [draft-sekar-dns-ul],
36    /// has since expired. The code is considered ‘on hold.’
37    ///
38    /// [draft-sekar-dns-ul]: http://files.dns-sd.org/draft-sekar-dns-ul.txt
39    (Ul => 2, b"UL")
40
41    /// Name server identifier (NSID, 3).
42    ///
43    /// The NSID option allows a name server to include an indentifier in an
44    /// answer for diagnostic purposes. The options in defined in [RFC 5001].
45    ///
46    /// [RFC 5001]: https://tools.ietf.org/html/rfc5001
47    (Nsid => 3, b"NSID")
48
49    /// DNSSEC algorithm understood (DAU, 5).
50    ///
51    /// The DAU option allows a validating resolver to signal a queried server
52    /// which DNSSEC signing algorithms it understands. The option is defined
53    /// in [RFC 6975].
54    ///
55    /// [RFC 6075]: https://tools.ietf.org/html/rfc6975
56    (Dau => 5, b"DAU")
57
58    /// DS hash understood (DHU, 6).
59    ///
60    /// The DHU option allows a validating resolver to signal a queried server
61    /// which DS hash algorithms it understands. The option is defined
62    /// in [RFC 6975].
63    ///
64    /// [RFC 6075]: https://tools.ietf.org/html/rfc6975
65    (Dhu => 6, b"DHU")
66
67    /// NSEC3 hash understood (N3U, 7).
68    ///
69    /// The DHU option allows a validating resolver to signal a queried server
70    /// which NSEC3 hash algorithms it understands. The option is defined
71    /// in [RFC 6975].
72    ///
73    /// [RFC 6075]: https://tools.ietf.org/html/rfc6975
74    (N3u => 7, b"N3U")
75
76    /// EDNS client subnet (8),
77    ///
78    /// The EDSN client subnet option allows a resolver to identify the IP
79    /// address subnet it queries from so that a server can determine the best
80    /// answer. This option is defined in [RFC 7871].
81    ///
82    /// [RFC 7871]: https://tools.ietf.org/html/rfc7871
83    (ClientSubnet => 8, b"edns-client-subnet")
84
85    /// Expire (9).
86    ///
87    /// The expire option allows a secondary to maintain the correct expiry
88    /// time for a zone when transferring from a server other than the
89    /// primary. The option is defined in [RFC 7314].
90    ///
91    /// [RFC 7314]: https://tools.ietf.org/html/rfc7314
92    (Expire => 9, b"EDNS EXPIRE")
93
94    /// DNS Cookie (10).
95    ///
96    /// The cookie option allows clients and server to exchange session
97    /// cookies as a mechanism for protecting agains denial-of-service and
98    /// amplification attacks. The option is defined in [RFC 7873].
99    ///
100    /// [RFC 7873]: https://tools.ietf.org/html/rfc7873
101    (Cookie => 10, b"COOKIE")
102
103    /// edns-tcp-keepalive (11).
104    ///
105    /// This option allows DNS servers to signal to a client for how long they
106    /// may hold open a TCP connection. The option is defined in [RFC 7828].
107    ///
108    /// [RFC 7828]: https://tools.ietf.org/html/rfc7828
109    (TcpKeepalive => 11, b"edns-tcp-keepalive")
110
111    /// Padding (12).
112    ///
113    /// The padding option allows clients and servers to pad their messages
114    /// with extra data to make it harder to guess content based on length.
115    /// The option is defined in [RFC 7830].
116    ///
117    /// [RFC 7830]: https://tools.ietf.org/html/rfc7830
118    (Padding => 12, b"Padding")
119
120    /// CHAIN query requests (13).
121    ///
122    /// The CHAIN query requests option allows a security-aware resolver to
123    /// all ask a server to include records necessary for DNSSEC validation of
124    /// the answer. The option is defined in [RFC 7901].
125    ///
126    /// [RFC 7901]: https://tools.ietf.org/html/rfc7901
127    (Chain => 13, b"CHAIN")
128
129    /// EDNS key tag (14).
130    ///
131    /// The key tag option allows a client to signal to a server which DNSSEC
132    /// key they would use to validate an asnwer. The option is defined in
133    /// [RFC 8145].
134    ///
135    /// [RFC 8145]: https://tools.ietf.org/html/rfc8145
136    (KeyTag => 14, b"edns-key-tag")
137
138    /// Extended DNS Error (15).
139    ///
140    /// This option allows the server to return additional information
141    /// about the cause of DNS errors. It does not change the
142    /// processing of RCODEs. The option is defined in [RFC 8914].
143    ///
144    /// [RFC 8914]: https://tools.ietf.org/html/rfc8914
145    (ExtendedError => 15, b"Extended DNS Error")
146
147    /// EDNS client tag (16).
148    ///
149    /// The client tag option allows a client to send arbitrary additional
150    /// data to a server. The option is defined in the now expired
151    /// [draft-bellis-dnsop-edns-tags].
152    ///
153    /// [draft-bellis-dnsop-edns-tags]: https://datatracker.ietf.org/doc/draft-bellis-dnsop-edns-tags/
154    (ClientTag => 16, b"EDNS-Client-Tag")
155
156    /// EDNS server tag (16).
157    ///
158    /// The client tag option allows a server to send arbitrary additional
159    /// data to a client. The option is defined in the now expired
160    /// [draft-bellis-dnsop-edns-tags].
161    ///
162    /// [draft-bellis-dnsop-edns-tags]: https://datatracker.ietf.org/doc/draft-bellis-dnsop-edns-tags/
163    (ServerTag => 17, b"EDNS-Server-Tag")
164
165    /// DeviceID (26946).
166    ///
167    /// Ths option is used by the [Cisco Umbrella network device API].
168    ///
169    /// [Cisco Umbrella network device API]: https://docs.umbrella.com/developer/networkdevices-api/identifying-dns-traffic2
170    (DeviceId => 26946, b"DeviceId")
171}
172
173int_enum_str_with_decimal!(OptionCode, u16, "unknown option code");
174
175//============ Tests =========================================================
176
177#[cfg(test)]
178mod test {
179    #[cfg(feature = "serde")]
180    #[test]
181    fn ser_de() {
182        use super::OptionCode;
183        use serde_test::{assert_tokens, Configure, Token};
184
185        assert_tokens(
186            &OptionCode::ServerTag.readable(),
187            &[Token::Str("EDNS-Server-Tag")],
188        );
189        assert_tokens(
190            &OptionCode::Int(10_000).readable(),
191            &[Token::U16(10_000)],
192        );
193        assert_tokens(&OptionCode::ServerTag.compact(), &[Token::U16(17)]);
194        assert_tokens(
195            &OptionCode::Int(10_000).compact(),
196            &[Token::U16(10_000)],
197        );
198    }
199}