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