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