1 module ietf-yang-types {
3 namespace "urn:ietf:params:xml:ns:yang:ietf-yang-types";
7 "IETF Network Modeling (NETMOD) Working Group";
10 "WG Web: <https://datatracker.ietf.org/wg/netmod/>
11 WG List: <mailto:netmod@ietf.org>
13 Editor: Juergen Schoenwaelder
14 <mailto:jschoenwaelder@constructor.university>";
17 "This module contains a collection of generally useful derived
20 The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL
21 NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'NOT RECOMMENDED',
22 'MAY', and 'OPTIONAL' in this document are to be interpreted as
23 described in BCP 14 (RFC 2119) (RFC 8174) when, and only when,
24 they appear in all capitals, as shown here.
26 Copyright (c) 2022 IETF Trust and the persons identified as
27 authors of the code. All rights reserved.
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 Revised BSD License
32 set forth in Section 4.c of the IETF Trust's Legal Provisions
33 Relating to IETF Documents
34 (https://trustee.ietf.org/license-info).
36 This version of this YANG module is part of RFC XXXX;
37 see the RFC itself for full legal notices.";
41 "This revision adds the following new data types:
42 - yang:date-with-zone-offset
44 - yang:time-with-zone-offset
56 The yang-identifier definition has been aligned with YANG 1.1.
57 Several pattern statements have been improved.";
59 "RFC XXXX: Common YANG Data Types";
64 "This revision adds the following new data types:
65 - yang:yang-identifier
70 "RFC 6991: Common YANG Data Types";
77 "RFC 6021: Common YANG Data Types";
80 /*** collection of counter and gauge types ***/
85 "The counter32 type represents a non-negative integer
86 that monotonically increases until it reaches a
87 maximum value of 2^32-1 (4294967295 decimal), when it
88 wraps around and starts increasing again from zero.
90 Counters have no defined 'initial' value, and thus, a
91 single value of a counter has (in general) no information
92 content. Discontinuities in the monotonically increasing
93 value normally occur at re-initialization of the
94 management system, and at other times as specified in the
95 description of a schema node using this type. If such
96 other times can occur, for example, the instantiation of
97 a schema node of type counter32 at times other than
98 re-initialization, then a corresponding schema node
99 should be defined, with an appropriate type, to indicate
100 the last discontinuity.
102 The counter32 type should not be used for configuration
103 schema nodes. A default statement SHOULD NOT be used in
104 combination with the type counter32.
106 In the value set and its semantics, this type is equivalent
107 to the Counter32 type of the SMIv2.";
109 "RFC 2578: Structure of Management Information Version 2
113 typedef zero-based-counter32 {
117 "The zero-based-counter32 type represents a counter32
118 that has the defined 'initial' value zero.
119 A schema node instance of this type will be set to zero (0)
120 on creation and will thereafter increase monotonically until
121 it reaches a maximum value of 2^32-1 (4294967295 decimal),
122 when it wraps around and starts increasing again from zero.
124 Provided that an application discovers a new schema node
125 instance of this type within the minimum time to wrap, it
126 can use the 'initial' value as a delta. It is important for
127 a management station to be aware of this minimum time and the
128 actual time between polls, and to discard data if the actual
129 time is too long or there is no defined minimum time.
131 In the value set and its semantics, this type is equivalent
132 to the ZeroBasedCounter32 textual convention of the SMIv2.";
134 "RFC 4502: Remote Network Monitoring Management Information
141 "The counter64 type represents a non-negative integer
142 that monotonically increases until it reaches a
143 maximum value of 2^64-1 (18446744073709551615 decimal),
144 when it wraps around and starts increasing again from zero.
146 Counters have no defined 'initial' value, and thus, a
147 single value of a counter has (in general) no information
148 content. Discontinuities in the monotonically increasing
149 value normally occur at re-initialization of the
150 management system, and at other times as specified in the
151 description of a schema node using this type. If such
152 other times can occur, for example, the instantiation of
153 a schema node of type counter64 at times other than
154 re-initialization, then a corresponding schema node
155 should be defined, with an appropriate type, to indicate
156 the last discontinuity.
158 The counter64 type should not be used for configuration
159 schema nodes. A default statement SHOULD NOT be used in
160 combination with the type counter64.
162 In the value set and its semantics, this type is equivalent
163 to the Counter64 type of the SMIv2.";
165 "RFC 2578: Structure of Management Information Version 2
169 typedef zero-based-counter64 {
173 "The zero-based-counter64 type represents a counter64 that
174 has the defined 'initial' value zero.
176 A schema node instance of this type will be set to zero (0)
177 on creation and will thereafter increase monotonically until
178 it reaches a maximum value of 2^64-1 (18446744073709551615
179 decimal), when it wraps around and starts increasing again
182 Provided that an application discovers a new schema node
183 instance of this type within the minimum time to wrap, it
184 can use the 'initial' value as a delta. It is important for
185 a management station to be aware of this minimum time and the
186 actual time between polls, and to discard data if the actual
187 time is too long or there is no defined minimum time.
189 In the value set and its semantics, this type is equivalent
190 to the ZeroBasedCounter64 textual convention of the SMIv2.";
192 "RFC 2856: Textual Conventions for Additional High Capacity
199 "The gauge32 type represents a non-negative integer, which
200 may increase or decrease, but shall never exceed a maximum
201 value, nor fall below a minimum value. The maximum value
202 cannot be greater than 2^32-1 (4294967295 decimal), and
203 the minimum value cannot be smaller than 0. The value of
204 a gauge32 has its maximum value whenever the information
205 being modeled is greater than or equal to its maximum
206 value, and has its minimum value whenever the information
207 being modeled is smaller than or equal to its minimum value.
208 If the information being modeled subsequently decreases
209 below (increases above) the maximum (minimum) value, the
210 gauge32 also decreases (increases).
212 In the value set and its semantics, this type is equivalent
213 to the Gauge32 type of the SMIv2.";
215 "RFC 2578: Structure of Management Information Version 2
222 "The gauge64 type represents a non-negative integer, which
223 may increase or decrease, but shall never exceed a maximum
224 value, nor fall below a minimum value. The maximum value
225 cannot be greater than 2^64-1 (18446744073709551615), and
226 the minimum value cannot be smaller than 0. The value of
227 a gauge64 has its maximum value whenever the information
228 being modeled is greater than or equal to its maximum
229 value, and has its minimum value whenever the information
230 being modeled is smaller than or equal to its minimum value.
231 If the information being modeled subsequently decreases
232 below (increases above) the maximum (minimum) value, the
233 gauge64 also decreases (increases).
235 In the value set and its semantics, this type is equivalent
236 to the CounterBasedGauge64 SMIv2 textual convention defined
239 "RFC 2856: Textual Conventions for Additional High Capacity
243 /*** collection of identifier-related types ***/
245 typedef object-identifier {
247 pattern '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9][0-9]*))))'
248 + '(\.(0|([1-9][0-9]*)))*';
251 "The object-identifier type represents administratively
252 assigned names in a registration-hierarchical-name tree.
254 Values of this type are denoted as a sequence of numerical
255 non-negative sub-identifier values. Each sub-identifier
256 value MUST NOT exceed 2^32-1 (4294967295). Sub-identifiers
257 are separated by single dots and without any intermediate
260 The ASN.1 standard restricts the value space of the first
261 sub-identifier to 0, 1, or 2. Furthermore, the value space
262 of the second sub-identifier is restricted to the range
263 0 to 39 if the first sub-identifier is 0 or 1. Finally,
264 the ASN.1 standard requires that an object identifier
265 has always at least two sub-identifiers. The pattern
266 captures these restrictions.
268 Although the number of sub-identifiers is not limited,
269 module designers should realize that there may be
270 implementations that stick with the SMIv2 limit of 128
273 This type is a superset of the SMIv2 OBJECT IDENTIFIER type
274 since it is not restricted to 128 sub-identifiers. Hence,
275 this type SHOULD NOT be used to represent the SMIv2 OBJECT
276 IDENTIFIER type; the object-identifier-128 type SHOULD be
279 "ISO9834-1: Information technology -- Open Systems
280 Interconnection -- Procedures for the operation of OSI
281 Registration Authorities: General procedures and top
282 arcs of the ASN.1 Object Identifier tree";
285 typedef object-identifier-128 {
286 type object-identifier {
287 pattern '[0-9]*(\.[0-9]*){1,127}';
290 "This type represents object-identifiers restricted to 128
293 In the value set and its semantics, this type is equivalent
294 to the OBJECT IDENTIFIER type of the SMIv2.";
296 "RFC 2578: Structure of Management Information Version 2
300 /*** collection of types related to date and time ***/
302 typedef date-and-time {
304 pattern '[0-9]{4}-(1[0-2]|0[1-9])-(0[1-9]|[1-2][0-9]|3[0-1])'
305 + 'T(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?'
306 + '(Z|[\+\-]((1[0-3]|0[0-9]):([0-5][0-9])|14:00))?';
309 "The date-and-time type is a profile of the ISO 8601
310 standard for representation of dates and times using the
311 Gregorian calendar. The profile is defined by the
312 date-time production in Section 5.6 of RFC 3339.
314 The date-and-time type is compatible with the dateTime XML
315 schema dateTime type with the following notable exceptions:
317 (a) The date-and-time type does not allow negative years.
319 (b) The time-offset -00:00 indicates that the date-and-time
320 value is reported in UTC and that the local time zone
321 reference point is unknown. The time-offsets +00:00 and Z
322 both indicate that the date-and-time value is reported in
323 UTC and that the local time reference point is UTC (see RFC
326 This type is not equivalent to the DateAndTime textual
327 convention of the SMIv2 since RFC 3339 uses a different
328 separator between full-date and full-time and provides
329 higher resolution of time-secfrac.
331 The canonical format for date-and-time values with a known time
332 zone uses a numeric time zone offset that is calculated using
333 the device's configured known offset to UTC time. A change of
334 the device's offset to UTC time will cause date-and-time values
335 to change accordingly. Such changes might happen periodically
336 in case a server follows automatically daylight saving time
337 (DST) time zone offset changes. The canonical format for
338 date-and-time values with an unknown time zone (usually
339 referring to the notion of local time) uses the time-offset
340 -00:00, i.e., date-and-time values must be reported in UTC.";
342 "RFC 3339: Date and Time on the Internet: Timestamps
343 RFC 2579: Textual Conventions for SMIv2
344 XSD-TYPES: XML Schema Definition Language (XSD) 1.1
348 typedef date-with-zone-offset {
350 pattern '[0-9]{4}-(1[0-2]|0[1-9])-(0[1-9]|[1-2][0-9]|3[0-1])'
351 + '(Z|[\+\-]((1[0-3]|0[0-9]):([0-5][0-9])|14:00))?';
354 "The date type represents a time-interval of the length
355 of a day, i.e., 24 hours.
357 The date type is compatible with the XML schema date
358 type with the following notable exceptions:
359 (a) The date type does not allow negative years.
361 (b) The time-offset -00:00 indicates that the date value is
362 reported in UTC and that the local time zone reference point
363 is unknown. The time-offsets +00:00 and Z both indicate that
364 the date value is reported in UTC and that the local time
365 reference point is UTC (see RFC 3339 section 4.3).
367 The canonical format for date values with a known time
368 zone uses a numeric time zone offset that is calculated using
369 the device's configured known offset to UTC time. A change of
370 the device's offset to UTC time will cause date values
371 to change accordingly. Such changes might happen periodically
372 in case a server follows automatically daylight saving time
373 (DST) time zone offset changes. The canonical format for
374 date values with an unknown time zone (usually referring
375 to the notion of local time) uses the time-offset -00:00,
376 i.e., date values must be reported in UTC.";
378 "RFC 3339: Date and Time on the Internet: Timestamps
379 XSD-TYPES: XML Schema Definition Language (XSD) 1.1
383 typedef date-no-zone {
384 type date-with-zone-offset {
385 pattern '[0-9]{4}-(1[0-2]|0[1-9])-(0[1-9]|[1-2][0-9]|3[0-1])';
388 "The date-no-zone type represents a date without the optional
389 time zone offset information.";
392 typedef time-with-zone-offset {
394 pattern '(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?'
395 + '(Z|[\+\-]((1[0-3]|0[0-9]):([0-5][0-9])|14:00))?';
398 "The time type represents an instance of time of zero-duration
399 that recurs every day.
401 The time type is compatible with the XML schema time
402 type with the following notable exception:
404 (a) The time-offset -00:00 indicates that the time value is
405 reported in UTC and that the local time zone reference point
406 is unknown. The time-offsets +00:00 and Z both indicate that
407 the time value is reported in UTC and that the local time
408 reference point is UTC (see RFC 3339 section 4.3).
410 The canonical format for time values with a known time
411 zone uses a numeric time zone offset that is calculated using
412 the device's configured known offset to UTC time. A change of
413 the device's offset to UTC time will cause time values
414 to change accordingly. Such changes might happen periodically
415 in case a server follows automatically daylight saving time
416 (DST) time zone offset changes. The canonical format for
417 time values with an unknown time zone (usually referring
418 to the notion of local time) uses the time-offset -00:00,
419 i.e., time values must be reported in UTC.";
421 "RFC 3339: Date and Time on the Internet: Timestamps
422 XSD-TYPES: XML Schema Definition Language (XSD) 1.1
426 typedef time-no-zone {
427 type time-with-zone-offset {
428 pattern '(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?';
431 "The time-no-zone type represents a time without the optional
432 time zone offset information.";
439 "A period of time, measured in units of hours.
441 The maximum time period that can be expressed is in the
442 range [-89478485 days 08:00:00 to 89478485 days 07:00:00].
444 This type should be range restricted in situations
445 where only non-negative time periods are desirable,
446 (i.e., range '0..max').";
453 "A period of time, measured in units of minutes.
455 The maximum time period that can be expressed is in the
456 range [-1491308 days 2:08:00 to 1491308 days 2:07:00].
458 This type should be range restricted in situations
459 where only non-negative time periods are desirable,
460 (i.e., range '0..max').";
467 "A period of time, measured in units of seconds.
469 The maximum time period that can be expressed is in the
470 range [-24855 days 03:14:08 to 24855 days 03:14:07].
472 This type should be range restricted in situations
473 where only non-negative time periods are desirable,
474 (i.e., range '0..max').";
477 typedef centiseconds32 {
479 units "centiseconds";
481 "A period of time, measured in units of 10^-2 seconds.
483 The maximum time period that can be expressed is in the
484 range [-248 days 13:13:56 to 248 days 13:13:56].
486 This type should be range restricted in situations
487 where only non-negative time periods are desirable,
488 (i.e., range '0..max').";
491 typedef milliseconds32 {
493 units "milliseconds";
495 "A period of time, measured in units of 10^-3 seconds.
497 The maximum time period that can be expressed is in the
498 range [-24 days 20:31:23 to 24 days 20:31:23].
500 This type should be range restricted in situations
501 where only non-negative time periods are desirable,
502 (i.e., range '0..max').";
505 typedef microseconds32 {
507 units "microseconds";
509 "A period of time, measured in units of 10^-6 seconds.
511 The maximum time period that can be expressed is in the
512 range [-00:35:47 to 00:35:47].
514 This type should be range restricted in situations
515 where only non-negative time periods are desirable,
516 (i.e., range '0..max').";
519 typedef microseconds64 {
521 units "microseconds";
523 "A period of time, measured in units of 10^-6 seconds.
525 The maximum time period that can be expressed is in the
526 range [-106751991 days 04:00:54 to 106751991 days 04:00:54].
528 This type should be range restricted in situations
529 where only non-negative time periods are desirable,
530 (i.e., range '0..max').";
533 typedef nanoseconds32 {
537 "A period of time, measured in units of 10^-9 seconds.
539 The maximum time period that can be expressed is in the
540 range [-00:00:02 to 00:00:02].
542 This type should be range restricted in situations
543 where only non-negative time periods are desirable,
544 (i.e., range '0..max').";
547 typedef nanoseconds64 {
551 "A period of time, measured in units of 10^-9 seconds.
553 The maximum time period that can be expressed is in the
554 range [-106753 days 23:12:44 to 106752 days 0:47:16].
556 This type should be range restricted in situations
557 where only non-negative time periods are desirable,
558 (i.e., range '0..max').";
564 "The timeticks type represents a non-negative integer that
565 represents the time, modulo 2^32 (4294967296 decimal), in
566 hundredths of a second between two epochs. When a schema
567 node is defined that uses this type, the description of
568 the schema node identifies both of the reference epochs.
570 In the value set and its semantics, this type is equivalent
571 to the TimeTicks type of the SMIv2.";
573 "RFC 2578: Structure of Management Information Version 2
580 "The timestamp type represents the value of an associated
581 timeticks schema node instance at which a specific occurrence
582 happened. The specific occurrence must be defined in the
583 description of any schema node defined using this type. When
584 the specific occurrence occurred prior to the last time the
585 associated timeticks schema node instance was zero, then the
586 timestamp value is zero.
588 Note that this requires all timestamp values to be reset to
589 zero when the value of the associated timeticks schema node
590 instance reaches 497+ days and wraps around to zero.
592 The associated timeticks schema node must be specified
593 in the description of any schema node using this type.
595 In the value set and its semantics, this type is equivalent
596 to the TimeStamp textual convention of the SMIv2.";
598 "RFC 2579: Textual Conventions for SMIv2";
601 /*** collection of generic address types ***/
603 typedef phys-address {
605 pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
608 "Represents media- or physical-level addresses represented
609 as a sequence octets, each octet represented by two hexadecimal
610 numbers. Octets are separated by colons. The canonical
611 representation uses lowercase characters.
613 In the value set and its semantics, this type is equivalent
614 to the PhysAddress textual convention of the SMIv2.";
616 "RFC 2579: Textual Conventions for SMIv2";
619 typedef mac-address {
621 pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
624 "The mac-address type represents an IEEE 802 MAC address.
625 The canonical representation uses lowercase characters.
627 In the value set and its semantics, this type is equivalent
628 to the MacAddress textual convention of the SMIv2.";
630 "IEEE 802: IEEE Standard for Local and Metropolitan Area
631 Networks: Overview and Architecture
632 RFC 2579: Textual Conventions for SMIv2";
635 /*** collection of XML-specific types ***/
640 "This type represents an XPATH 1.0 expression.
642 When a schema node is defined that uses this type, the
643 description of the schema node MUST specify the XPath
644 context in which the XPath expression is evaluated.";
646 "XPATH: XML Path Language (XPath) Version 1.0";
649 /*** collection of string types ***/
653 pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
656 "A hexadecimal string with octets represented as hex digits
657 separated by colons. The canonical representation uses
658 lowercase characters.";
663 pattern '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-'
664 + '[0-9a-fA-F]{4}-[0-9a-fA-F]{12}';
667 "A Universally Unique IDentifier in the string representation
668 defined in RFC 4122. The canonical representation uses
669 lowercase characters.
671 The following is an example of a UUID in string representation:
672 f81d4fae-7dec-11d0-a765-00a0c91e6bf6
675 "RFC 4122: A Universally Unique IDentifier (UUID) URN
679 typedef dotted-quad {
682 '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
683 + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
686 "An unsigned 32-bit number expressed in the dotted-quad
687 notation, i.e., four octets written as decimal numbers
688 and separated with the '.' (full stop) character.";
691 typedef language-tag {
694 "A language tag according to RFC 5646 (BCP 47). The
695 canonical representation uses lowercase characters.
697 Values of this type must be well-formed language tags,
698 in conformance with the definition of well-formed tags
699 in BCP 47. Implementations MAY further limit the values
700 they accept to those permitted by a 'validating'
701 processor, as defined in BCP 47.
703 The canonical representation of values of this type is
704 aligned with the SMIv2 LangTag textual convention for
705 language tags fitting the length constraints imposed
706 by the LangTag textual convention.";
708 "RFC 5646: Tags for Identifying Languages
709 RFC 5131: A MIB Textual Convention for Language Tags";
712 /*** collection of YANG specific types ***/
714 typedef yang-identifier {
717 pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*';
720 "A YANG identifier string as defined by the 'identifier'
721 rule in Section 14 of RFC 7950. An identifier must
722 start with an alphabetic character or an underscore
723 followed by an arbitrary sequence of alphabetic or
724 numeric characters, underscores, hyphens, or dots.
726 This definition conforms to YANG 1.1 defined in RFC
727 7950. An earlier version of this definition did exclude
728 all identifiers starting with any possible combination
729 of the lowercase or uppercase character sequence 'xml',
730 as required by YANG 1 defined in RFC 6020. If this type
731 is used in a YANG 1 context, then this restriction still
734 "RFC 7950: The YANG 1.1 Data Modeling Language
735 RFC 6020: YANG - A Data Modeling Language for the
736 Network Configuration Protocol (NETCONF)";