module openconfig-inet-types { yang-version "1"; namespace "http://openconfig.net/yang/types/inet"; prefix "oc-inet"; import openconfig-extensions { prefix "oc-ext"; } organization "OpenConfig working group"; contact "OpenConfig working group www.openconfig.net"; description "This module contains a set of Internet address related types for use in OpenConfig modules."; oc-ext:openconfig-version "0.1.0"; revision 2017-01-26 { description "Initial module for inet types"; reference "0.1.0"; } // IPv4 and IPv6 types. typedef ipv4-address { type string { pattern '^(([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])$'; } description "An IPv4 address in dotted quad notation."; } typedef ipv6-address { type string { pattern // Must support compression through different lengths // therefore this regexp is complex. '^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|' + '([0-9a-fA-F]{1,4}:){1,7}:|' + '([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}' + '([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|' + '([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|' + '([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|' + '([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|' + '[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|' + ':((:[0-9a-fA-F]{1,4}){1,7}|:)' + ')$'; } description "An IPv6 address represented as either a full address; shortened or mixed-shortened formats."; } typedef ipv4-prefix { type string { pattern '^(([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]))$'; } description "An IPv4 prefix represented in dotted quad notation followed by a slash and a CIDR mask (0 <= mask <= 32)."; } typedef ipv6-prefix { type string { pattern '^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|' + '([0-9a-fA-F]{1,4}:){1,7}:|' + '([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}' + '([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|' + '([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|' + '([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|' + '([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|' + '[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|' + ':((:[0-9a-fA-F]{1,4}){1,7}|:)' + ')/(12[0-8]|1[0-1][0-9]|[1-9][0-9]|[0-9])$'; } description "An IPv6 prefix represented in full, shortened, or mixed shortened format followed by a slash and CIDR mask (0 <= mask <= 128)."; } typedef ip-address { type union { type ipv4-address; type ipv6-address; } description "An IPv4 or IPv6 address with no prefix specified."; } typedef ip-prefix { type union { type ipv4-prefix; type ipv6-prefix; } description "An IPv4 or IPv6 prefix."; } typedef as-number { type uint32; description "A numeric identifier for an autonomous system (AS). An AS is a single domain, under common administrative control, which forms a unit of routing policy. Autonomous systems can be assigned a 2-byte identifier, or a 4-byte identifier which may have public or private scope. Private ASNs are assigned from dedicated ranges. Public ASNs are assigned from ranges allocated by IANA to the regional internet registries (RIRs)."; reference "RFC 1930 Guidelines for creation, selection, and registration of an Autonomous System (AS) RFC 4271 A Border Gateway Protocol 4 (BGP-4)"; } typedef dscp { type uint8 { range "0..63"; } description "A differentiated services code point (DSCP) marking within the IP header."; reference "RFC 2474 Definition of the Differentiated Services Field (DS Field) in the IPv4 and IPv6 Headers"; } typedef ipv6-flow-label { type uint32 { range "0..1048575"; } description "The IPv6 flow-label is a 20-bit value within the IPv6 header which is optionally used by the source of the IPv6 packet to label sets of packets for which special handling may be required."; reference "RFC 2460 Internet Protocol, Version 6 (IPv6) Specification"; } typedef port-number { type uint16; description "A 16-bit port number used by a transport protocol such as TCP or UDP."; reference "RFC 768 User Datagram Protocol RFC 793 Transmission Control Protocol"; } typedef uri { type string; description "An ASCII-encoded Uniform Resource Identifier (URI) as defined in RFC 3986."; reference "RFC 3986 Uniform Resource Identifier (URI): Generic Syntax"; } }