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