blob: ac0c4678c238f53c07be85f70cd521665adad6a1 [file] [log] [blame]
Thomas Vachuska6655bee2017-08-24 16:12:59 -07001module openconfig-vlan-types {
2
3 yang-version "1";
4
5 // namespace
6 namespace "http://openconfig.net/yang/vlan-types";
7
8 prefix "oc-vlan-types";
9
10 // import some basic types
11 import openconfig-extensions { prefix oc-ext; }
12
13 // meta
14 organization "OpenConfig working group";
15
16 contact
17 "OpenConfig working group
18 netopenconfig@googlegroups.com";
19
20 description
21 "This module defines configuration and state variables for VLANs,
22 in addition to VLAN parameters associated with interfaces";
23
24 oc-ext:openconfig-version "2.0.0";
25
26 revision "2017-07-14" {
27 description
28 "Move top-level vlan data to network-instance; Update
29 identities to comply to style guide; fixed pattern
30 quoting; corrected trunk vlan types; added TPID config to
31 base interface.";
32 reference "2.0.0";
33 }
34
35 revision "2016-05-26" {
36 description
37 "OpenConfig public release";
38 reference "1.0.2";
39 }
40
41 // extension statements
42
43 // feature statements
44
45 // identity statements
46
47 identity TPID_TYPES {
48 description
49 "Base identity for TPID values that can override the VLAN
50 ethertype value";
51 }
52
53 identity TPID_0X8100 {
54 base TPID_TYPES;
55 description
56 "Default TPID value for 802.1q single-tagged VLANs.";
57 }
58
59 identity TPID_0X8A88 {
60 base TPID_TYPES;
61 description
62 "TPID value for 802.1ad provider bridging, Q-in-Q,
63 or stacked VLANs";
64 }
65
66 identity TPID_0X9100 {
67 base TPID_TYPES;
68 description
69 "Alternate TPID value";
70 }
71
72 identity TPID_0X9200 {
73 base TPID_TYPES;
74 description
75 "Alternate TPID value";
76 }
77
78 // typedef statements
79
80 // TODO: typedefs should be defined in a vlan-types.yang file.
81 typedef vlan-id {
82 type uint16 {
83 range 1..4094;
84 }
85 description
86 "Type definition representing a single-tagged VLAN";
87 }
88
89 typedef vlan-range {
90 type string {
91 // range specified as [lower]..[upper]
92 pattern '^(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
93 '[1-9][0-9]{1,2}|[1-9])\.\.(409[0-4]|' +
94 '40[0-8][0-9]|[1-3][0-9]{3}|[1-9][0-9]{1,2}|' +
95 '[1-9])$';
96 }
97 description
98 "Type definition representing a range of single-tagged
99 VLANs. A range is specified as x..y where x and y are
100 valid VLAN IDs (1 <= vlan-id <= 4094). The range is
101 assumed to be inclusive, such that any VLAN-ID matching
102 x <= VLAN-ID <= y falls within the range.";
103 }
104
105 typedef qinq-id {
106 type string {
107 pattern
108 '^(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
109 '[1-9][0-9]{1,2}|[1-9])\.' +
110 '((409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
111 '[1-9][0-9]{1,2}|[1-9])|\*)$';
112 }
113 description
114 "Type definition representing a single double-tagged/QinQ VLAN
115 identifier. The format of a QinQ VLAN-ID is x.y where X is the
116 'outer' VLAN identifier, and y is the 'inner' VLAN identifier.
117 Both x and y must be valid VLAN IDs (1 <= vlan-id <= 4094)
118 with the exception that y may be equal to a wildcard (*). In
119 cases where y is set to the wildcard, this represents all inner
120 VLAN identifiers where the outer VLAN identifier is equal to
121 x";
122 }
123
124 typedef qinq-id-range {
125 type union {
126 type string {
127 // match cases where the range is specified as x..y.z
128 pattern
129 '^(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
130 '[1-9][0-9]{1,2}|[1-9])\.\.' +
131 '(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
132 '[1-9][0-9]{1,2}|[1-9])\.' +
133 '((409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
134 '[1-9][0-9]{1,2}|[1-9])|\*)$';
135 }
136 type string {
137 // match cases where the range is specified as x.y..z
138 pattern
139 '^(\*|(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
140 '[1-9][0-9]{1,2}|[1-9]))\.' +
141 '(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
142 '[1-9][0-9]{1,2}|[1-9])\.\.' +
143 '(409[0-4]|40[0-8][0-9]|[1-3][0-9]{3}|' +
144 '[1-9][0-9]{1,2}|[1-9])$';
145 }
146 }
147 description
148 "A type definition representing a range of double-tagged/QinQ
149 VLAN identifiers. The format of a QinQ VLAN-ID range can be
150 specified in three formats. Where the range is outer VLAN IDs
151 the range is specified as x..y.z. In this case outer VLAN
152 identifiers meeting the criteria x <= outer-vlan-id <= y are
153 accepted iff the inner VLAN-ID is equal to y - or any inner-tag
154 if the wildcard is specified. Alternatively the range can be
155 specified as x.y..z. In this case only VLANs with an
156 outer-vlan-id qual to x are accepted (x may again be the
157 wildcard). Inner VLANs are accepted if they meet the inequality
158 y <= inner-vlan-id <= z.";
159 }
160
161 typedef vlan-mode-type {
162 type enumeration {
163 enum ACCESS {
164 description "Access mode VLAN interface (No 802.1q header)";
165 }
166 enum TRUNK {
167 description "Trunk mode VLAN interface";
168 }
169 }
170 description
171 "VLAN interface mode (trunk or access)";
172 }
173
174 typedef vlan-ref {
175 type union {
176 type vlan-id;
177 type string;
178 // TODO: string should be changed to leafref to reference
179 // an existing VLAN. this is not allowed in YANG 1.0 but
180 // is expected to be in YANG 1.1.
181 // type leafref {
182 // path "vlan:vlans/vlan:vlan/vlan:config/vlan:name";
183 // }
184 }
185 description
186 "Reference to a VLAN by name or id";
187 }
188
189}