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, "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, "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, "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, "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, "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, "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    (CLIENT_SUBNET => 8, "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, "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, "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    (TCP_KEEPALIVE => 11, "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, "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, "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    (KEY_TAG => 14, "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    (EXTENDED_ERROR => 15, "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    (CLIENT_TAG => 16, "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    (SERVER_TAG => 17, "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    (DEVICE_ID => 26946, "DeviceId")
171}
172
173int_enum_str_with_decimal!(OptionCode, u16, "unknown option code");
174int_enum_zonefile_fmt_with_decimal!(OptionCode);
175
176//============ Tests =========================================================
177
178#[cfg(test)]
179mod test {
180    #[cfg(feature = "serde")]
181    #[test]
182    fn ser_de() {
183        use super::OptionCode;
184        use serde_test::{assert_tokens, Configure, Token};
185
186        assert_tokens(
187            &OptionCode::SERVER_TAG.readable(),
188            &[Token::Str("EDNS-Server-Tag")],
189        );
190        assert_tokens(&OptionCode(10_000).readable(), &[Token::U16(10_000)]);
191        assert_tokens(&OptionCode::SERVER_TAG.compact(), &[Token::U16(17)]);
192        assert_tokens(&OptionCode(10_000).compact(), &[Token::U16(10_000)]);
193    }
194}