Thomas Vachuska | 8ca75a2 | 2017-08-24 16:12:59 -0700 | [diff] [blame] | 1 | module openconfig-inet-types { |
| 2 | |
| 3 | yang-version "1"; |
| 4 | namespace "http://openconfig.net/yang/types/inet"; |
| 5 | prefix "oc-inet"; |
| 6 | |
| 7 | import openconfig-extensions { prefix "oc-ext"; } |
| 8 | |
| 9 | organization |
| 10 | "OpenConfig working group"; |
| 11 | |
| 12 | contact |
| 13 | "OpenConfig working group |
| 14 | www.openconfig.net"; |
| 15 | |
| 16 | description |
| 17 | "This module contains a set of Internet address related |
| 18 | types for use in OpenConfig modules. |
| 19 | |
| 20 | Portions of this code were derived from IETF RFC 6021. |
| 21 | Please reproduce this note if possible. |
| 22 | |
| 23 | IETF code is subject to the following copyright and license: |
| 24 | Copyright (c) IETF Trust and the persons identified as authors of |
| 25 | the code. |
| 26 | All rights reserved. |
| 27 | |
| 28 | Redistribution and use in source and binary forms, with or without |
| 29 | modification, is permitted pursuant to, and subject to the license |
| 30 | terms contained in, the Simplified BSD License set forth in |
| 31 | Section 4.c of the IETF Trust's Legal Provisions Relating |
| 32 | to IETF Documents (http://trustee.ietf.org/license-info)."; |
| 33 | |
| 34 | oc-ext:openconfig-version "0.3.0"; |
| 35 | |
| 36 | revision 2017-07-06 { |
| 37 | description |
| 38 | "Add domain-name and host typedefs"; |
| 39 | reference "0.3.0"; |
| 40 | } |
| 41 | |
| 42 | revision 2017-04-03 { |
| 43 | description |
| 44 | "Add ip-version typedef."; |
| 45 | reference "0.2.0"; |
| 46 | } |
| 47 | |
| 48 | revision 2017-04-03 { |
| 49 | description |
| 50 | "Update copyright notice."; |
| 51 | reference "0.1.1"; |
| 52 | } |
| 53 | |
| 54 | revision 2017-01-26 { |
| 55 | description |
| 56 | "Initial module for inet types"; |
| 57 | reference "0.1.0"; |
| 58 | } |
| 59 | |
| 60 | // IPv4 and IPv6 types. |
| 61 | |
| 62 | typedef ipv4-address { |
| 63 | type string { |
| 64 | pattern '^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|' + |
| 65 | '25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4]' + |
| 66 | '[0-9]|25[0-5])$'; |
| 67 | } |
| 68 | description |
| 69 | "An IPv4 address in dotted quad notation using the default |
| 70 | zone."; |
| 71 | } |
| 72 | |
| 73 | typedef ipv4-address-zoned { |
| 74 | type string { |
| 75 | pattern '^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|' + |
| 76 | '25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4]' + |
| 77 | '[0-9]|25[0-5])(%[a-zA-Z0-9_]+)$'; |
| 78 | } |
| 79 | description |
| 80 | "An IPv4 address in dotted quad notation. This type allows |
| 81 | specification of a zone index to disambiguate identical |
| 82 | address values. For link-local addresses, the index is |
| 83 | typically the interface index or interface name."; |
| 84 | } |
| 85 | |
| 86 | typedef ipv6-address { |
| 87 | type string { |
| 88 | pattern |
| 89 | // Must support compression through different lengths |
| 90 | // therefore this regexp is complex. |
| 91 | '^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|' + |
| 92 | '([0-9a-fA-F]{1,4}:){1,7}:|' + |
| 93 | '([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|' + |
| 94 | '([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|' + |
| 95 | '([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|' + |
| 96 | '([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|' + |
| 97 | '([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|' + |
| 98 | '[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|' + |
| 99 | ':((:[0-9a-fA-F]{1,4}){1,7}|:)' + |
| 100 | ')$'; |
| 101 | } |
| 102 | description |
| 103 | "An IPv6 address represented as either a full address; shortened |
| 104 | or mixed-shortened formats, using the default zone."; |
| 105 | } |
| 106 | |
| 107 | typedef ipv6-address-zoned { |
| 108 | type string { |
| 109 | pattern |
| 110 | // Must support compression through different lengths |
| 111 | // therefore this regexp is complex. |
| 112 | '^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|' + |
| 113 | '([0-9a-fA-F]{1,4}:){1,7}:|' + |
| 114 | '([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|' + |
| 115 | '([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|' + |
| 116 | '([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|' + |
| 117 | '([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|' + |
| 118 | '([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|' + |
| 119 | '[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|' + |
| 120 | ':((:[0-9a-fA-F]{1,4}){1,7}|:)' + |
| 121 | ')(%[a-zA-Z0-9_]+)$'; |
| 122 | } |
| 123 | description |
| 124 | "An IPv6 address represented as either a full address; shortened |
| 125 | or mixed-shortened formats. This type allows specification of |
| 126 | a zone index to disambiguate identical address values. For |
| 127 | link-local addresses, the index is typically the interface |
| 128 | index or interface name."; |
| 129 | } |
| 130 | |
| 131 | typedef ipv4-prefix { |
| 132 | type string { |
| 133 | pattern '^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|' + |
| 134 | '25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4]' + |
| 135 | '[0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))$'; |
| 136 | } |
| 137 | description |
| 138 | "An IPv4 prefix represented in dotted quad notation followed by |
| 139 | a slash and a CIDR mask (0 <= mask <= 32)."; |
| 140 | } |
| 141 | |
| 142 | typedef ipv6-prefix { |
| 143 | type string { |
| 144 | pattern |
| 145 | '^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|' + |
| 146 | '([0-9a-fA-F]{1,4}:){1,7}:|' + |
| 147 | '([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}' + |
| 148 | '([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|' + |
| 149 | '([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|' + |
| 150 | '([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|' + |
| 151 | '([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|' + |
| 152 | '[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|' + |
| 153 | ':((:[0-9a-fA-F]{1,4}){1,7}|:)' + |
| 154 | ')/(12[0-8]|1[0-1][0-9]|[1-9][0-9]|[0-9])$'; |
| 155 | } |
| 156 | description |
| 157 | "An IPv6 prefix represented in full, shortened, or mixed |
| 158 | shortened format followed by a slash and CIDR mask |
| 159 | (0 <= mask <= 128)."; |
| 160 | } |
| 161 | |
| 162 | typedef ip-address { |
| 163 | type union { |
| 164 | type ipv4-address; |
| 165 | type ipv6-address; |
| 166 | } |
| 167 | description |
| 168 | "An IPv4 or IPv6 address with no prefix specified."; |
| 169 | } |
| 170 | |
| 171 | typedef ip-prefix { |
| 172 | type union { |
| 173 | type ipv4-prefix; |
| 174 | type ipv6-prefix; |
| 175 | } |
| 176 | description |
| 177 | "An IPv4 or IPv6 prefix."; |
| 178 | } |
| 179 | |
| 180 | typedef ip-version { |
| 181 | type enumeration { |
| 182 | enum UNKNOWN { |
| 183 | value 0; |
| 184 | description |
| 185 | "An unknown or unspecified version of the Internet |
| 186 | protocol."; |
| 187 | } |
| 188 | enum IPV4 { |
| 189 | value 4; |
| 190 | description |
| 191 | "The IPv4 protocol as defined in RFC 791."; |
| 192 | } |
| 193 | enum IPV6 { |
| 194 | value 6; |
| 195 | description |
| 196 | "The IPv6 protocol as defined in RFC 2460."; |
| 197 | } |
| 198 | } |
| 199 | description |
| 200 | "This value represents the version of the IP protocol. |
| 201 | Note that integer representation of the enumerated values |
| 202 | are not specified, and are not required to follow the |
| 203 | InetVersion textual convention in SMIv2."; |
| 204 | reference |
| 205 | "RFC 791: Internet Protocol |
| 206 | RFC 2460: Internet Protocol, Version 6 (IPv6) Specification |
| 207 | RFC 4001: Textual Conventions for Internet Network Addresses"; |
| 208 | } |
| 209 | |
| 210 | typedef domain-name { |
| 211 | type string { |
| 212 | length "1..253"; |
| 213 | pattern |
| 214 | '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*' + |
| 215 | '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)' + |
| 216 | '|\.'; |
| 217 | } |
| 218 | description |
| 219 | "The domain-name type represents a DNS domain name. |
| 220 | Fully quallified left to the models which utilize this type. |
| 221 | |
| 222 | Internet domain names are only loosely specified. Section |
| 223 | 3.5 of RFC 1034 recommends a syntax (modified in Section |
| 224 | 2.1 of RFC 1123). The pattern above is intended to allow |
| 225 | for current practice in domain name use, and some possible |
| 226 | future expansion. It is designed to hold various types of |
| 227 | domain names, including names used for A or AAAA records |
| 228 | (host names) and other records, such as SRV records. Note |
| 229 | that Internet host names have a stricter syntax (described |
| 230 | in RFC 952) than the DNS recommendations in RFCs 1034 and |
| 231 | 1123, and that systems that want to store host names in |
| 232 | schema nodes using the domain-name type are recommended to |
| 233 | adhere to this stricter standard to ensure interoperability. |
| 234 | |
| 235 | The encoding of DNS names in the DNS protocol is limited |
| 236 | to 255 characters. Since the encoding consists of labels |
| 237 | prefixed by a length bytes and there is a trailing NULL |
| 238 | byte, only 253 characters can appear in the textual dotted |
| 239 | notation. |
| 240 | |
| 241 | Domain-name values use the US-ASCII encoding. Their canonical |
| 242 | format uses lowercase US-ASCII characters. Internationalized |
| 243 | domain names MUST be encoded in punycode as described in RFC |
| 244 | 3492"; |
| 245 | } |
| 246 | |
| 247 | typedef host { |
| 248 | type union { |
| 249 | type ip-address; |
| 250 | type domain-name; |
| 251 | } |
| 252 | description |
| 253 | "The host type represents either an unzoned IP address or a DNS |
| 254 | domain name."; |
| 255 | } |
| 256 | |
| 257 | typedef as-number { |
| 258 | type uint32; |
| 259 | description |
| 260 | "A numeric identifier for an autonomous system (AS). An AS is a |
| 261 | single domain, under common administrative control, which forms |
| 262 | a unit of routing policy. Autonomous systems can be assigned a |
| 263 | 2-byte identifier, or a 4-byte identifier which may have public |
| 264 | or private scope. Private ASNs are assigned from dedicated |
| 265 | ranges. Public ASNs are assigned from ranges allocated by IANA |
| 266 | to the regional internet registries (RIRs)."; |
| 267 | reference |
| 268 | "RFC 1930 Guidelines for creation, selection, and registration |
| 269 | of an Autonomous System (AS) |
| 270 | RFC 4271 A Border Gateway Protocol 4 (BGP-4)"; |
| 271 | } |
| 272 | |
| 273 | typedef dscp { |
| 274 | type uint8 { |
| 275 | range "0..63"; |
| 276 | } |
| 277 | description |
| 278 | "A differentiated services code point (DSCP) marking within the |
| 279 | IP header."; |
| 280 | reference |
| 281 | "RFC 2474 Definition of the Differentiated Services Field |
| 282 | (DS Field) in the IPv4 and IPv6 Headers"; |
| 283 | } |
| 284 | |
| 285 | typedef ipv6-flow-label { |
| 286 | type uint32 { |
| 287 | range "0..1048575"; |
| 288 | } |
| 289 | description |
| 290 | "The IPv6 flow-label is a 20-bit value within the IPv6 header |
| 291 | which is optionally used by the source of the IPv6 packet to |
| 292 | label sets of packets for which special handling may be |
| 293 | required."; |
| 294 | reference |
| 295 | "RFC 2460 Internet Protocol, Version 6 (IPv6) Specification"; |
| 296 | } |
| 297 | |
| 298 | typedef port-number { |
| 299 | type uint16; |
| 300 | description |
| 301 | "A 16-bit port number used by a transport protocol such as TCP |
| 302 | or UDP."; |
| 303 | reference |
| 304 | "RFC 768 User Datagram Protocol |
| 305 | RFC 793 Transmission Control Protocol"; |
| 306 | } |
| 307 | |
| 308 | typedef uri { |
| 309 | type string; |
| 310 | description |
| 311 | "An ASCII-encoded Uniform Resource Identifier (URI) as defined |
| 312 | in RFC 3986."; |
| 313 | reference |
| 314 | "RFC 3986 Uniform Resource Identifier (URI): Generic Syntax"; |
| 315 | } |
| 316 | } |