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