594b9d6ce0baecc408f2c2dfdd945fe6cdbb3cf8
[honeycomb.git] / v3po / api / src / main / yang / dot1q-types.yang
1 module dot1q-types {
2   namespace "urn:ieee:params:xml:ns:yang:dot1q-types";
3   prefix dot1q;
4
5   organization
6     "Cisco Systems, Inc.
7      Customer Service
8
9      Postal: 170 W Tasman Drive
10      San Jose, CA 95134
11
12      Tel: +1 1800 553-NETS
13
14      E-mail: cs-yang@cisco.com";
15
16   contact
17     "Robert Wilton - rwilton@cisco.com";
18
19   description
20     "This module contains a collection of generally useful YANG types
21      that are specific to 802.1Q VLANs that can be usefully shared
22      between multiple models.
23
24      Terms and Acronyms
25
26      802.1Q: IEEE 802.1Q VLANs
27
28      VLAN (vlan): Virtual Local Area Network
29      ";
30
31   revision 2015-06-26 {
32     description "Latest revision, changed namespace";
33
34     reference "Intended to be standardized IEEE 802.1";
35   }
36
37   typedef PCP {
38     type uint8 {
39       range "0..7";
40     }
41     description
42       "Priority Code Point. PCP is a 3-bit field that refers to the
43        class of service applied to an 802.1Q VLAN tagged frame.  The
44        field specifies a priority value between 0 and 7, these values
45        can be used by quality of service (QoS) to prioritize
46        different classes of traffic.";
47     reference "IEEE 802.1Q (2014)";
48   }
49
50   /*
51    * Defines what it means to be an 802.1Q VLAN Id, where values 0
52    * and 4095 are reserved.
53    */
54   typedef dot1q-vlan-id {
55     type uint16 {
56       range "1..4094";
57     }
58     description "An 802.1Q VLAN Identifier";
59     reference "IEEE 802.1Q (2014)";
60   }
61
62   /*
63    * Defines the supported IEEE 802.1Q types that can be used for
64    * VLAN tag matching.
65    */
66   identity dot1q-tag-vlan-type {
67     description "Base identity from which all 802.1Q VLAN tag types
68                  are derived from";
69   }
70
71   identity c-vlan {
72     base dot1q-tag-vlan-type;
73     description
74       "An 802.1Q Customer-VLAN tag, normally using the 0x8100
75        Ethertype";
76   }
77
78   identity s-vlan {
79     base dot1q-tag-vlan-type;
80     description
81       "An 802.1Q Service-VLAN tag, using the 0x88a8 Ethertype
82        originally introduced in 802.1ad, and incorporated into
83        802.1Q (2011)";
84   }
85
86   typedef dot1q-tag-type {
87     type identityref {
88       base "dot1q-tag-vlan-type";
89     }
90     description "Identifies a specific 802.1Q tag type";
91     reference "IEEE 802.1Q (2014)";
92   }
93
94   /*
95    * Defines the type used to represent ranges of VLAN Ids.
96    *
97    * Ideally we would model that as a list of VLAN Ids in YANG, but
98    * the model is easier to use if this is just represented as a
99    * string.
100    *
101    * This type is used to match an ordered list of VLAN Ids, or
102    * contiguous ranges of VLAN Ids.  Valid VLAN Ids must be in the
103    * range 1 to 4094, and included in the list in non overlapping
104    * ascending order.
105    *
106    * E.g. "1, 10-100, 50, 500-1000"
107    */
108   typedef dot1q-vlan-id-ranges {
109     type string {
110       pattern "([0-9]{1,4}(-[0-9]{1,4})?(,[0-9]{1,4}" +
111               "(-[0-9]{1,4})?)*)";
112     }
113     description "A list of VLAN Ids, or non overlapping VLAN ranges,
114                  in ascending order, between 1 and 4094";
115   }
116
117   /*
118    * A grouping which represents an 802.1Q VLAN tag, matching both
119    * the tag Ethertype and a single VLAN Id.  The PCP and DEI fields
120    * in the 802.1Q tag are ignored for tag matching purposes.
121    */
122   grouping dot1q-tag {
123     description "Grouping to allow configuration to identify a single
124                  802.1Q VLAN tag";
125     container dot1q-tag {
126       description "Identifies an 802.1Q VLAN tag with an explicit
127                    tag-type and a single VLAN Id";
128       leaf tag-type {
129         type dot1q-tag-type;
130         mandatory true;
131         description "VLAN tag type";
132       }
133       leaf vlan-id {
134         type dot1q-vlan-id;
135         mandatory true;
136         description "VLAN Id";
137       }
138     }
139   }
140
141   /*
142    * A grouping which represents an 802.1Q VLAN tag, matching both
143    * the tag Ethertype and a single VLAN Id or "any" to match on any
144    * VLAN Id.  The PCP and DEI fields in the 802.1Q tag are ignored
145    * for tag matching purposes.
146    */
147   grouping dot1q-tag-or-any {
148     description "Grouping to allow configuration to identify a single
149                  802.1Q VLAN tag or the 'any' value to match any VLAN
150                  Id not matched by a more specific VLAN Id match";
151     container dot1q-tag {
152       description "Identifies an 802.1Q VLAN tag with an explicit
153                    tag-type and a single VLAN Id, or 'any' VLAN Id";
154       leaf tag-type {
155         type dot1q-tag-type;
156         mandatory true;
157         description "VLAN tag type";
158       }
159       leaf vlan-id {
160         type union {
161           type dot1q-vlan-id;
162           type enumeration {
163             enum "any" {
164               value 4096;
165               description
166                 "Matches 'any' VLAN tag in the range 1 to 4094 that
167                  is not matched by a more specific VLAN Id match";
168             }
169           }
170         }
171         mandatory true;
172         description "VLAN Id or any";
173       }
174     }
175   }
176
177   /*
178    * A grouping which represents an 802.1Q tag that matches a range
179    * of VLAN Ids.  The PCP and DEI fields in the 802.1Q tag are
180    * ignored for tag matching purposes.
181    */
182   grouping dot1q-tag-ranges {
183     description "Grouping to allow configuration to identify an
184                  802.1Q VLAN tag that matches any VLAN Id within a
185                  set of non overlapping VLAN Id ranges";
186     container dot1q-tag {
187       description "Identifies an 802.1Q VLAN tag with an explicit
188                    tag-type and and a range of VLAN Ids";
189       leaf tag-type {
190         type dot1q-tag-type;
191         mandatory true;
192         description "VLAN tag type";
193       }
194       leaf vlan-ids {
195         type dot1q-vlan-id-ranges;
196         mandatory true;
197         description "VLAN Ids";
198       }
199     }
200   }
201
202   /*
203    * A grouping which represents an 802.1Q VLAN tag, matching both
204    * the tag Ethertype and a single VLAN Id, ordered list of ranges,
205    * or "any" to match on any VLAN Id.  The PCP and DEI fields in the
206    * 802.1Q tag are ignored for tag matching purposes.
207    */
208   grouping dot1q-tag-ranges-or-any {
209     description "Grouping to allow configuration to identify an
210                  802.1Q VLAN tag that matches any specific VLAN Id
211                  within a set of non overlapping VLAN Id ranges, or
212                  the 'any' value to match any VLAN Id";
213     container dot1q-tag {
214       description "Identifies an 802.1Q VLAN tag with an explicit
215                    tag-type, an ordered list of VLAN Id ranges, or
216                    'any' VLAN Id";
217       leaf tag-type {
218         type dot1q-tag-type;
219         mandatory true;
220         description "VLAN tag type";
221       }
222       leaf vlan-id {
223         type union {
224           type dot1q-vlan-id-ranges;
225           type enumeration {
226             enum "any" {
227               description "Matches 'any' VLAN tag in the range 1 to
228                            4094";
229             }
230           }
231         }
232         mandatory true;
233         description "VLAN Ids or any";
234       }
235     }
236   }
237 }