blob: fa57f75f2b10295f0357b2859ef79ac6851d1629 [file] [log] [blame]
Scott Bakerc9d3d842021-09-17 11:32:53 -07001module ietf-inet-types {
2
3 namespace "urn:ietf:params:xml:ns:yang:ietf-inet-types";
4 prefix "inet";
5
6 organization
7 "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
8
9 contact
10 "WG Web: <http://tools.ietf.org/wg/netmod/>
11 WG List: <mailto:netmod@ietf.org>
12
13 WG Chair: David Kessens
14 <mailto:david.kessens@nsn.com>
15
16 WG Chair: Juergen Schoenwaelder
17 <mailto:j.schoenwaelder@jacobs-university.de>
18
19 Editor: Juergen Schoenwaelder
20 <mailto:j.schoenwaelder@jacobs-university.de>";
21
22 description
23 "This module contains a collection of generally useful derived
24 YANG data types for Internet addresses and related things.
25
26 Copyright (c) 2013 IETF Trust and the persons identified as
27 authors of the code. All rights reserved.
28
29 Redistribution and use in source and binary forms, with or
30 without modification, is permitted pursuant to, and subject
31 to the license terms contained in, the Simplified BSD License
32 set forth in Section 4.c of the IETF Trust's Legal Provisions
33 Relating to IETF Documents
34 (http://trustee.ietf.org/license-info).
35
36 This version of this YANG module is part of RFC 6991; see
37 the RFC itself for full legal notices.";
38
39 revision 2013-07-15 {
40 description
41 "This revision adds the following new data types:
42 - ip-address-no-zone
43 - ipv4-address-no-zone
44 - ipv6-address-no-zone";
45 reference
46 "RFC 6991: Common YANG Data Types";
47 }
48
49 revision 2010-09-24 {
50 description
51 "Initial revision.";
52 reference
53 "RFC 6021: Common YANG Data Types";
54 }
55
56 /*** collection of types related to protocol fields ***/
57
58 typedef ip-version {
59 type enumeration {
60 enum unknown {
61 value "0";
62 description
63 "An unknown or unspecified version of the Internet
64 protocol.";
65 }
66 enum ipv4 {
67 value "1";
68 description
69 "The IPv4 protocol as defined in RFC 791.";
70 }
71 enum ipv6 {
72 value "2";
73 description
74 "The IPv6 protocol as defined in RFC 2460.";
75 }
76 }
77 description
78 "This value represents the version of the IP protocol.
79
80 In the value set and its semantics, this type is equivalent
81 to the InetVersion textual convention of the SMIv2.";
82 reference
83 "RFC 791: Internet Protocol
84 RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
85 RFC 4001: Textual Conventions for Internet Network Addresses";
86 }
87
88 typedef dscp {
89 type uint8 {
90 range "0..63";
91 }
92 description
93 "The dscp type represents a Differentiated Services Code Point
94 that may be used for marking packets in a traffic stream.
95 In the value set and its semantics, this type is equivalent
96 to the Dscp textual convention of the SMIv2.";
97 reference
98 "RFC 3289: Management Information Base for the Differentiated
99 Services Architecture
100 RFC 2474: Definition of the Differentiated Services Field
101 (DS Field) in the IPv4 and IPv6 Headers
102 RFC 2780: IANA Allocation Guidelines For Values In
103 the Internet Protocol and Related Headers";
104 }
105
106 typedef ipv6-flow-label {
107 type uint32 {
108 range "0..1048575";
109 }
110 description
111 "The ipv6-flow-label type represents the flow identifier or Flow
112 Label in an IPv6 packet header that may be used to
113 discriminate traffic flows.
114
115 In the value set and its semantics, this type is equivalent
116 to the IPv6FlowLabel textual convention of the SMIv2.";
117 reference
118 "RFC 3595: Textual Conventions for IPv6 Flow Label
119 RFC 2460: Internet Protocol, Version 6 (IPv6) Specification";
120 }
121
122 typedef port-number {
123 type uint16 {
124 range "0..65535";
125 }
126 description
127 "The port-number type represents a 16-bit port number of an
128 Internet transport-layer protocol such as UDP, TCP, DCCP, or
129 SCTP. Port numbers are assigned by IANA. A current list of
130 all assignments is available from <http://www.iana.org/>.
131
132 Note that the port number value zero is reserved by IANA. In
133 situations where the value zero does not make sense, it can
134 be excluded by subtyping the port-number type.
135 In the value set and its semantics, this type is equivalent
136 to the InetPortNumber textual convention of the SMIv2.";
137 reference
138 "RFC 768: User Datagram Protocol
139 RFC 793: Transmission Control Protocol
140 RFC 4960: Stream Control Transmission Protocol
141 RFC 4340: Datagram Congestion Control Protocol (DCCP)
142 RFC 4001: Textual Conventions for Internet Network Addresses";
143 }
144
145 /*** collection of types related to autonomous systems ***/
146
147 typedef as-number {
148 type uint32;
149 description
150 "The as-number type represents autonomous system numbers
151 which identify an Autonomous System (AS). An AS is a set
152 of routers under a single technical administration, using
153 an interior gateway protocol and common metrics to route
154 packets within the AS, and using an exterior gateway
155 protocol to route packets to other ASes. IANA maintains
156 the AS number space and has delegated large parts to the
157 regional registries.
158
159 Autonomous system numbers were originally limited to 16
160 bits. BGP extensions have enlarged the autonomous system
161 number space to 32 bits. This type therefore uses an uint32
162 base type without a range restriction in order to support
163 a larger autonomous system number space.
164
165 In the value set and its semantics, this type is equivalent
166 to the InetAutonomousSystemNumber textual convention of
167 the SMIv2.";
168 reference
169 "RFC 1930: Guidelines for creation, selection, and registration
170 of an Autonomous System (AS)
171 RFC 4271: A Border Gateway Protocol 4 (BGP-4)
172 RFC 4001: Textual Conventions for Internet Network Addresses
173 RFC 6793: BGP Support for Four-Octet Autonomous System (AS)
174 Number Space";
175 }
176
177 /*** collection of types related to IP addresses and hostnames ***/
178
179 typedef ip-address {
180 type union {
181 type inet:ipv4-address;
182 type inet:ipv6-address;
183 }
184 description
185 "The ip-address type represents an IP address and is IP
186 version neutral. The format of the textual representation
187 implies the IP version. This type supports scoped addresses
188 by allowing zone identifiers in the address format.";
189 reference
190 "RFC 4007: IPv6 Scoped Address Architecture";
191 }
192
193 typedef ipv4-address {
194 type string {
195 pattern
196 '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
197 + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
198 + '(%[\p{N}\p{L}]+)?';
199 }
200 description
201 "The ipv4-address type represents an IPv4 address in
202 dotted-quad notation. The IPv4 address may include a zone
203 index, separated by a % sign.
204
205 The zone index is used to disambiguate identical address
206 values. For link-local addresses, the zone index will
207 typically be the interface index number or the name of an
208 interface. If the zone index is not present, the default
209 zone of the device will be used.
210
211 The canonical format for the zone index is the numerical
212 format";
213 }
214
215 typedef ipv6-address {
216 type string {
217 pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
218 + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
219 + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
220 + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
221 + '(%[\p{N}\p{L}]+)?';
222 pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
223 + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
224 + '(%.+)?';
225 }
226 description
227 "The ipv6-address type represents an IPv6 address in full,
228 mixed, shortened, and shortened-mixed notation. The IPv6
229 address may include a zone index, separated by a % sign.
230
231 The zone index is used to disambiguate identical address
232 values. For link-local addresses, the zone index will
233 typically be the interface index number or the name of an
234 interface. If the zone index is not present, the default
235 zone of the device will be used.
236
237 The canonical format of IPv6 addresses uses the textual
238 representation defined in Section 4 of RFC 5952. The
239 canonical format for the zone index is the numerical
240 format as described in Section 11.2 of RFC 4007.";
241 reference
242 "RFC 4291: IP Version 6 Addressing Architecture
243 RFC 4007: IPv6 Scoped Address Architecture
244 RFC 5952: A Recommendation for IPv6 Address Text
245 Representation";
246 }
247
248 typedef ip-address-no-zone {
249 type union {
250 type inet:ipv4-address-no-zone;
251 type inet:ipv6-address-no-zone;
252 }
253 description
254 "The ip-address-no-zone type represents an IP address and is
255 IP version neutral. The format of the textual representation
256 implies the IP version. This type does not support scoped
257 addresses since it does not allow zone identifiers in the
258 address format.";
259 reference
260 "RFC 4007: IPv6 Scoped Address Architecture";
261 }
262
263 typedef ipv4-address-no-zone {
264 type inet:ipv4-address {
265 pattern '[0-9\.]*';
266 }
267 description
268 "An IPv4 address without a zone index. This type, derived from
269 ipv4-address, may be used in situations where the zone is
270 known from the context and hence no zone index is needed.";
271 }
272
273 typedef ipv6-address-no-zone {
274 type inet:ipv6-address {
275 pattern '[0-9a-fA-F:\.]*';
276 }
277 description
278 "An IPv6 address without a zone index. This type, derived from
279 ipv6-address, may be used in situations where the zone is
280 known from the context and hence no zone index is needed.";
281 reference
282 "RFC 4291: IP Version 6 Addressing Architecture
283 RFC 4007: IPv6 Scoped Address Architecture
284 RFC 5952: A Recommendation for IPv6 Address Text
285 Representation";
286 }
287
288 typedef ip-prefix {
289 type union {
290 type inet:ipv4-prefix;
291 type inet:ipv6-prefix;
292 }
293 description
294 "The ip-prefix type represents an IP prefix and is IP
295 version neutral. The format of the textual representations
296 implies the IP version.";
297 }
298
299 typedef ipv4-prefix {
300 type string {
301 pattern
302 '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
303 + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
304 + '/(([0-9])|([1-2][0-9])|(3[0-2]))';
305 }
306 description
307 "The ipv4-prefix type represents an IPv4 address prefix.
308 The prefix length is given by the number following the
309 slash character and must be less than or equal to 32.
310
311 A prefix length value of n corresponds to an IP address
312 mask that has n contiguous 1-bits from the most
313 significant bit (MSB) and all other bits set to 0.
314
315 The canonical format of an IPv4 prefix has all bits of
316 the IPv4 address set to zero that are not part of the
317 IPv4 prefix.";
318 }
319
320 typedef ipv6-prefix {
321 type string {
322 pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
323 + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
324 + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
325 + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
326 + '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
327 pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
328 + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
329 + '(/.+)';
330 }
331
332 description
333 "The ipv6-prefix type represents an IPv6 address prefix.
334 The prefix length is given by the number following the
335 slash character and must be less than or equal to 128.
336
337 A prefix length value of n corresponds to an IP address
338 mask that has n contiguous 1-bits from the most
339 significant bit (MSB) and all other bits set to 0.
340
341 The IPv6 address should have all bits that do not belong
342 to the prefix set to zero.
343
344 The canonical format of an IPv6 prefix has all bits of
345 the IPv6 address set to zero that are not part of the
346 IPv6 prefix. Furthermore, the IPv6 address is represented
347 as defined in Section 4 of RFC 5952.";
348 reference
349 "RFC 5952: A Recommendation for IPv6 Address Text
350 Representation";
351 }
352
353 /*** collection of domain name and URI types ***/
354
355 typedef domain-name {
356 type string {
PUSHP RAJba2e32f2021-11-02 10:39:24 +0000357 length "1..253";
Scott Bakerc9d3d842021-09-17 11:32:53 -0700358 pattern
359 '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*'
360 + '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)'
361 + '|\.';
Scott Bakerc9d3d842021-09-17 11:32:53 -0700362 }
363 description
364 "The domain-name type represents a DNS domain name. The
365 name SHOULD be fully qualified whenever possible.
366
367 Internet domain names are only loosely specified. Section
368 3.5 of RFC 1034 recommends a syntax (modified in Section
369 2.1 of RFC 1123). The pattern above is intended to allow
370 for current practice in domain name use, and some possible
371 future expansion. It is designed to hold various types of
372 domain names, including names used for A or AAAA records
373 (host names) and other records, such as SRV records. Note
374 that Internet host names have a stricter syntax (described
375 in RFC 952) than the DNS recommendations in RFCs 1034 and
376 1123, and that systems that want to store host names in
377 schema nodes using the domain-name type are recommended to
378 adhere to this stricter standard to ensure interoperability.
379
380 The encoding of DNS names in the DNS protocol is limited
381 to 255 characters. Since the encoding consists of labels
382 prefixed by a length bytes and there is a trailing NULL
383 byte, only 253 characters can appear in the textual dotted
384 notation.
385
386 The description clause of schema nodes using the domain-name
387 type MUST describe when and how these names are resolved to
388 IP addresses. Note that the resolution of a domain-name value
389 may require to query multiple DNS records (e.g., A for IPv4
390 and AAAA for IPv6). The order of the resolution process and
391 which DNS record takes precedence can either be defined
392 explicitly or may depend on the configuration of the
393 resolver.
394
395 Domain-name values use the US-ASCII encoding. Their canonical
396 format uses lowercase US-ASCII characters. Internationalized
397 domain names MUST be A-labels as per RFC 5890.";
398 reference
399 "RFC 952: DoD Internet Host Table Specification
400 RFC 1034: Domain Names - Concepts and Facilities
401 RFC 1123: Requirements for Internet Hosts -- Application
402 and Support
403 RFC 2782: A DNS RR for specifying the location of services
404 (DNS SRV)
405 RFC 5890: Internationalized Domain Names in Applications
406 (IDNA): Definitions and Document Framework";
407 }
408
409 typedef host {
410 type union {
411 type inet:ip-address;
412 type inet:domain-name;
413 }
414 description
415 "The host type represents either an IP address or a DNS
416 domain name.";
417 }
418
419 typedef uri {
420 type string;
421 description
422 "The uri type represents a Uniform Resource Identifier
423 (URI) as defined by STD 66.
424
425 Objects using the uri type MUST be in US-ASCII encoding,
426 and MUST be normalized as described by RFC 3986 Sections
427 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary
428 percent-encoding is removed, and all case-insensitive
429 characters are set to lowercase except for hexadecimal
430 digits, which are normalized to uppercase as described in
431 Section 6.2.2.1.
432
433 The purpose of this normalization is to help provide
434 unique URIs. Note that this normalization is not
435 sufficient to provide uniqueness. Two URIs that are
436 textually distinct after this normalization may still be
437 equivalent.
438
439 Objects using the uri type may restrict the schemes that
440 they permit. For example, 'data:' and 'urn:' schemes
441 might not be appropriate.
442
443 A zero-length URI is not a valid URI. This can be used to
444 express 'URI absent' where required.
445
446 In the value set and its semantics, this type is equivalent
447 to the Uri SMIv2 textual convention defined in RFC 5017.";
448 reference
449 "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
450 RFC 3305: Report from the Joint W3C/IETF URI Planning Interest
451 Group: Uniform Resource Identifiers (URIs), URLs,
452 and Uniform Resource Names (URNs): Clarifications
453 and Recommendations
454 RFC 5017: MIB Textual Conventions for Uniform Resource
455 Identifiers (URIs)";
456 }
457
458}