ee58fa3ab0042120d5607b8713d21fa0ba845895
[scp/oam/modeling.git] / data-model / draft / ietf-yang-types@2013-07-15.yang
1 module ietf-yang-types {
2
3   namespace "urn:ietf:params:xml:ns:yang:ietf-yang-types";
4   prefix "yang";
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.
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       - yang-identifier
43       - hex-string
44       - uuid
45       - dotted-quad";
46     reference
47      "RFC 6991: Common YANG Data Types";
48   }
49
50   revision 2010-09-24 {
51     description
52      "Initial revision.";
53     reference
54      "RFC 6021: Common YANG Data Types";
55   }
56
57   /*** collection of counter and gauge types ***/
58
59   typedef counter32 {
60     type uint32;
61     description
62      "The counter32 type represents a non-negative integer
63       that monotonically increases until it reaches a
64       maximum value of 2^32-1 (4294967295 decimal), when it
65       wraps around and starts increasing again from zero.
66
67       Counters have no defined 'initial' value, and thus, a
68       single value of a counter has (in general) no information
69       content.  Discontinuities in the monotonically increasing
70       value normally occur at re-initialization of the
71       management system, and at other times as specified in the
72       description of a schema node using this type.  If such
73       other times can occur, for example, the creation of
74       a schema node of type counter32 at times other than
75       re-initialization, then a corresponding schema node
76       should be defined, with an appropriate type, to indicate
77       the last discontinuity.
78
79       The counter32 type should not be used for configuration
80       schema nodes.  A default statement SHOULD NOT be used in
81       combination with the type counter32.
82
83       In the value set and its semantics, this type is equivalent
84       to the Counter32 type of the SMIv2.";
85     reference
86      "RFC 2578: Structure of Management Information Version 2
87                 (SMIv2)";
88   }
89
90   typedef zero-based-counter32 {
91     type yang:counter32;
92     default "0";
93     description
94      "The zero-based-counter32 type represents a counter32
95       that has the defined 'initial' value zero.
96
97       A schema node of this type will be set to zero (0) on creation
98       and will thereafter increase monotonically until it reaches
99       a maximum value of 2^32-1 (4294967295 decimal), when it
100       wraps around and starts increasing again from zero.
101
102       Provided that an application discovers a new schema node
103       of this type within the minimum time to wrap, it can use the
104       'initial' value as a delta.  It is important for a management
105       station to be aware of this minimum time and the actual time
106       between polls, and to discard data if the actual time is too
107       long or there is no defined minimum time.
108
109       In the value set and its semantics, this type is equivalent
110       to the ZeroBasedCounter32 textual convention of the SMIv2.";
111     reference
112       "RFC 4502: Remote Network Monitoring Management Information
113                  Base Version 2";
114   }
115
116   typedef counter64 {
117     type uint64;
118     description
119      "The counter64 type represents a non-negative integer
120       that monotonically increases until it reaches a
121       maximum value of 2^64-1 (18446744073709551615 decimal),
122       when it wraps around and starts increasing again from zero.
123
124       Counters have no defined 'initial' value, and thus, a
125       single value of a counter has (in general) no information
126       content.  Discontinuities in the monotonically increasing
127       value normally occur at re-initialization of the
128       management system, and at other times as specified in the
129       description of a schema node using this type.  If such
130       other times can occur, for example, the creation of
131       a schema node of type counter64 at times other than
132       re-initialization, then a corresponding schema node
133       should be defined, with an appropriate type, to indicate
134       the last discontinuity.
135
136       The counter64 type should not be used for configuration
137       schema nodes.  A default statement SHOULD NOT be used in
138       combination with the type counter64.
139
140       In the value set and its semantics, this type is equivalent
141       to the Counter64 type of the SMIv2.";
142     reference
143      "RFC 2578: Structure of Management Information Version 2
144                 (SMIv2)";
145   }
146
147   typedef zero-based-counter64 {
148     type yang:counter64;
149     default "0";
150     description
151      "The zero-based-counter64 type represents a counter64 that
152       has the defined 'initial' value zero.
153
154       A schema node of this type will be set to zero (0) on creation
155       and will thereafter increase monotonically until it reaches
156       a maximum value of 2^64-1 (18446744073709551615 decimal),
157       when it wraps around and starts increasing again from zero.
158
159       Provided that an application discovers a new schema node
160       of this type within the minimum time to wrap, it can use the
161       'initial' value as a delta.  It is important for a management
162       station to be aware of this minimum time and the actual time
163       between polls, and to discard data if the actual time is too
164       long or there is no defined minimum time.
165
166       In the value set and its semantics, this type is equivalent
167       to the ZeroBasedCounter64 textual convention of the SMIv2.";
168     reference
169      "RFC 2856: Textual Conventions for Additional High Capacity
170                 Data Types";
171   }
172
173   typedef gauge32 {
174     type uint32;
175     description
176      "The gauge32 type represents a non-negative integer, which
177       may increase or decrease, but shall never exceed a maximum
178       value, nor fall below a minimum value.  The maximum value
179       cannot be greater than 2^32-1 (4294967295 decimal), and
180       the minimum value cannot be smaller than 0.  The value of
181       a gauge32 has its maximum value whenever the information
182       being modeled is greater than or equal to its maximum
183       value, and has its minimum value whenever the information
184       being modeled is smaller than or equal to its minimum value.
185       If the information being modeled subsequently decreases
186       below (increases above) the maximum (minimum) value, the
187       gauge32 also decreases (increases).
188
189       In the value set and its semantics, this type is equivalent
190       to the Gauge32 type of the SMIv2.";
191     reference
192      "RFC 2578: Structure of Management Information Version 2
193                 (SMIv2)";
194   }
195
196   typedef gauge64 {
197     type uint64;
198     description
199      "The gauge64 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^64-1 (18446744073709551615), and
203       the minimum value cannot be smaller than 0.  The value of
204       a gauge64 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       gauge64 also decreases (increases).
211
212       In the value set and its semantics, this type is equivalent
213       to the CounterBasedGauge64 SMIv2 textual convention defined
214       in RFC 2856";
215     reference
216      "RFC 2856: Textual Conventions for Additional High Capacity
217                 Data Types";
218   }
219
220   /*** collection of identifier-related types ***/
221
222   typedef object-identifier {
223     type string {
224       pattern '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))'
225             + '(\.(0|([1-9]\d*)))*';
226     }
227     description
228      "The object-identifier type represents administratively
229       assigned names in a registration-hierarchical-name tree.
230
231       Values of this type are denoted as a sequence of numerical
232       non-negative sub-identifier values.  Each sub-identifier
233       value MUST NOT exceed 2^32-1 (4294967295).  Sub-identifiers
234       are separated by single dots and without any intermediate
235       whitespace.
236
237       The ASN.1 standard restricts the value space of the first
238       sub-identifier to 0, 1, or 2.  Furthermore, the value space
239       of the second sub-identifier is restricted to the range
240       0 to 39 if the first sub-identifier is 0 or 1.  Finally,
241       the ASN.1 standard requires that an object identifier
242       has always at least two sub-identifiers.  The pattern
243       captures these restrictions.
244
245       Although the number of sub-identifiers is not limited,
246       module designers should realize that there may be
247       implementations that stick with the SMIv2 limit of 128
248       sub-identifiers.
249
250       This type is a superset of the SMIv2 OBJECT IDENTIFIER type
251       since it is not restricted to 128 sub-identifiers.  Hence,
252       this type SHOULD NOT be used to represent the SMIv2 OBJECT
253       IDENTIFIER type; the object-identifier-128 type SHOULD be
254       used instead.";
255     reference
256      "ISO9834-1: Information technology -- Open Systems
257       Interconnection -- Procedures for the operation of OSI
258       Registration Authorities: General procedures and top
259       arcs of the ASN.1 Object Identifier tree";
260   }
261
262   typedef object-identifier-128 {
263     type object-identifier {
264       pattern '\d*(\.\d*){1,127}';
265     }
266     description
267      "This type represents object-identifiers restricted to 128
268       sub-identifiers.
269
270       In the value set and its semantics, this type is equivalent
271       to the OBJECT IDENTIFIER type of the SMIv2.";
272     reference
273      "RFC 2578: Structure of Management Information Version 2
274                 (SMIv2)";
275   }
276
277   typedef yang-identifier {
278     type string {
279       length "1..max";
280       pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*';
281       pattern '.|..|[^xX].*|.[^mM].*|..[^lL].*';
282     }
283     description
284       "A YANG identifier string as defined by the 'identifier'
285        rule in Section 12 of RFC 6020.  An identifier must
286        start with an alphabetic character or an underscore
287        followed by an arbitrary sequence of alphabetic or
288        numeric characters, underscores, hyphens, or dots.
289
290        A YANG identifier MUST NOT start with any possible
291        combination of the lowercase or uppercase character
292        sequence 'xml'.";
293     reference
294       "RFC 6020: YANG - A Data Modeling Language for the Network
295                  Configuration Protocol (NETCONF)";
296   }
297
298   /*** collection of types related to date and time***/
299
300   typedef date-and-time {
301     type string {
302       pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?'
303             + '(Z|[\+\-]\d{2}:\d{2})';
304     }
305     description
306      "The date-and-time type is a profile of the ISO 8601
307       standard for representation of dates and times using the
308       Gregorian calendar.  The profile is defined by the
309       date-time production in Section 5.6 of RFC 3339.
310
311       The date-and-time type is compatible with the dateTime XML
312       schema type with the following notable exceptions:
313
314       (a) The date-and-time type does not allow negative years.
315
316       (b) The date-and-time time-offset -00:00 indicates an unknown
317           time zone (see RFC 3339) while -00:00 and +00:00 and Z
318           all represent the same time zone in dateTime.
319
320       (c) The canonical format (see below) of data-and-time values
321           differs from the canonical format used by the dateTime XML
322           schema type, which requires all times to be in UTC using
323           the time-offset 'Z'.
324
325       This type is not equivalent to the DateAndTime textual
326       convention of the SMIv2 since RFC 3339 uses a different
327       separator between full-date and full-time and provides
328       higher resolution of time-secfrac.
329
330       The canonical format for date-and-time values with a known time
331       zone uses a numeric time zone offset that is calculated using
332       the device's configured known offset to UTC time.  A change of
333       the device's offset to UTC time will cause date-and-time values
334       to change accordingly.  Such changes might happen periodically
335       in case a server follows automatically daylight saving time
336       (DST) time zone offset changes.  The canonical format for
337       date-and-time values with an unknown time zone (usually
338       referring to the notion of local time) uses the time-offset
339       -00:00.";
340     reference
341      "RFC 3339: Date and Time on the Internet: Timestamps
342       RFC 2579: Textual Conventions for SMIv2
343       XSD-TYPES: XML Schema Part 2: Datatypes Second Edition";
344   }
345
346   typedef timeticks {
347     type uint32;
348     description
349      "The timeticks type represents a non-negative integer that
350       represents the time, modulo 2^32 (4294967296 decimal), in
351       hundredths of a second between two epochs.  When a schema
352       node is defined that uses this type, the description of
353       the schema node identifies both of the reference epochs.
354
355       In the value set and its semantics, this type is equivalent
356       to the TimeTicks type of the SMIv2.";
357     reference
358      "RFC 2578: Structure of Management Information Version 2
359                 (SMIv2)";
360   }
361
362   typedef timestamp {
363     type yang:timeticks;
364     description
365      "The timestamp type represents the value of an associated
366       timeticks schema node at which a specific occurrence
367       happened.  The specific occurrence must be defined in the
368       description of any schema node defined using this type.  When
369       the specific occurrence occurred prior to the last time the
370       associated timeticks attribute was zero, then the timestamp
371       value is zero.  Note that this requires all timestamp values
372       to be reset to zero when the value of the associated timeticks
373       attribute reaches 497+ days and wraps around to zero.
374
375       The associated timeticks schema node must be specified
376       in the description of any schema node using this type.
377
378       In the value set and its semantics, this type is equivalent
379       to the TimeStamp textual convention of the SMIv2.";
380     reference
381      "RFC 2579: Textual Conventions for SMIv2";
382   }
383
384   /*** collection of generic address types ***/
385
386   typedef phys-address {
387     type string {
388       pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
389     }
390
391     description
392      "Represents media- or physical-level addresses represented
393       as a sequence octets, each octet represented by two hexadecimal
394       numbers.  Octets are separated by colons.  The canonical
395       representation uses lowercase characters.
396
397       In the value set and its semantics, this type is equivalent
398       to the PhysAddress textual convention of the SMIv2.";
399     reference
400      "RFC 2579: Textual Conventions for SMIv2";
401   }
402
403   typedef mac-address {
404     type string {
405       pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
406     }
407     description
408      "The mac-address type represents an IEEE 802 MAC address.
409       The canonical representation uses lowercase characters.
410
411       In the value set and its semantics, this type is equivalent
412       to the MacAddress textual convention of the SMIv2.";
413     reference
414      "IEEE 802: IEEE Standard for Local and Metropolitan Area
415                 Networks: Overview and Architecture
416       RFC 2579: Textual Conventions for SMIv2";
417   }
418
419   /*** collection of XML-specific types ***/
420
421   typedef xpath1.0 {
422     type string;
423     description
424      "This type represents an XPATH 1.0 expression.
425
426       When a schema node is defined that uses this type, the
427       description of the schema node MUST specify the XPath
428       context in which the XPath expression is evaluated.";
429     reference
430      "XPATH: XML Path Language (XPath) Version 1.0";
431   }
432
433   /*** collection of string types ***/
434
435   typedef hex-string {
436     type string {
437       pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
438     }
439     description
440      "A hexadecimal string with octets represented as hex digits
441       separated by colons.  The canonical representation uses
442       lowercase characters.";
443   }
444
445   typedef uuid {
446     type string {
447       pattern '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-'
448             + '[0-9a-fA-F]{4}-[0-9a-fA-F]{12}';
449     }
450     description
451      "A Universally Unique IDentifier in the string representation
452       defined in RFC 4122.  The canonical representation uses
453       lowercase characters.
454
455       The following is an example of a UUID in string representation:
456       f81d4fae-7dec-11d0-a765-00a0c91e6bf6
457       ";
458     reference
459      "RFC 4122: A Universally Unique IDentifier (UUID) URN
460                 Namespace";
461   }
462
463   typedef dotted-quad {
464     type string {
465       pattern
466         '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
467       + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
468     }
469     description
470       "An unsigned 32-bit number expressed in the dotted-quad
471        notation, i.e., four octets written as decimal numbers
472        and separated with the '.' (full stop) character.";
473   }
474 }