d4914f4fd89b327bea137fb28286a7523a5da8e5
[honeycomb.git] / nsh / api / src / main / yang / vpp-nsh.yang
1 module vpp-nsh {
2   yang-version 1;
3   namespace "urn:opendaylight:params:xml:ns:yang:vpp:nsh";
4   prefix "vpp-nsh";
5
6   revision "2016-06-24" {
7     description "Initial revision of vpp-nsh model";
8   }
9
10   import iana-if-type {
11     prefix "ianaift";
12   }
13   import ietf-interfaces {
14     prefix "if";
15   }
16   import ietf-yang-types {
17     prefix "yang";
18   }
19   import ietf-inet-types {
20     prefix "inet";
21   }
22   import yang-ext {
23     prefix "ext";
24   }
25   import v3po {
26     prefix "v3po";
27   }
28   /*
29    * Defines the supported next protocols that can be used for
30    * NSH next-protocol field.
31    */
32   identity next-protocol {
33     description "Base identity from which all nsh next protocols
34                  are derived from";
35   }
36
37   identity ipv4 {
38     base next-protocol;
39     description
40       "Support ipv4 to act as next protocol";
41   }
42
43   identity ipv6 {
44     base next-protocol;
45     description
46       "Support ipv6 to act as next protocol";
47   }
48
49   identity ethernet {
50     base next-protocol;
51     description
52       "Support ethernet to act as next protocol";
53   }
54
55   typedef nsh-next-protocol {
56     type identityref {
57       base "next-protocol";
58     }
59     description "Identifies a specific next protocol for nsh";
60   }
61
62   /*
63    * Defines the supported nsh header action.
64    */
65   identity action-type {
66     description "nsh header action type";
67   }
68
69   identity swap {
70     base "action-type";
71     description "swap action type";
72   }
73
74   identity push {
75     base "action-type";
76     description "push action type";
77   }
78
79   identity pop {
80     base "action-type";
81     description "pop action type";
82   }
83
84   typedef nsh-action-type {
85     type identityref {
86       base "action-type";
87     }
88   }
89
90   /*
91    * Defines the supported encap type.
92    */
93   identity encap-type {
94     description "encap type";
95   }
96
97   identity vxlan-gpe {
98     base "encap-type";
99     description "vxlan-gpe encap type";
100   }
101
102   identity vxlan {
103     base "encap-type";
104     description "vxlan encap type";
105   }
106
107   typedef nsh-encap-type {
108     type identityref {
109       base "encap-type";
110     }
111   }
112
113   /*
114    * Defines the supported MD-types.
115    */
116   identity md-type {
117     description "md type";
118   }
119
120   identity md-type1 {
121     base "md-type";
122     description "nsh md-type1";
123   }
124
125   identity md-type2 {
126     base "md-type";
127     description "nsh md-type2";
128   }
129
130   typedef nsh-md-type {
131     type identityref {
132       base "md-type";
133     }
134   }
135
136   grouping nsh-md-type1-attributes {
137     leaf c1 {
138       type uint32;
139     }
140     leaf c2 {
141       type uint32;
142     }
143     leaf c3 {
144       type uint32;
145     }
146     leaf c4 {
147       type uint32;
148     }
149   }
150
151   grouping nsh-md-type2-attributes {
152       leaf type {
153       type uint32;
154     }
155   }
156
157   grouping nsh-entry-base-attributes {
158     leaf name {
159       type string;
160       description "NSH Entry Name";
161     }
162     leaf nsp {
163       type uint32 {
164         range "0..16777215";
165       }
166     }
167     leaf nsi {
168       type uint8 {
169         range "1..255";
170       }
171     }
172     leaf md-type {
173       type nsh-md-type;
174     }
175     leaf version {
176       type uint8;
177     }
178     leaf length {
179       type uint8;
180     }
181     leaf next-protocol {
182       type nsh-next-protocol;
183     }
184   }
185
186   grouping nsh-map-base-attributes {
187     leaf name {
188       type string;
189       description "NSH Map Name";
190     }
191     leaf nsp {
192       type uint32 {
193         range "0..16777215";
194       }
195     }
196     leaf nsi {
197       type uint8 {
198         range "1..255";
199       }
200     }
201     leaf mapped-nsp {
202       type uint32 {
203         range "0..16777215";
204       }
205     }
206     leaf mapped-nsi {
207       type uint8 {
208         range "1..255";
209       }
210     }
211     leaf nsh-action {
212       type nsh-action-type;
213       default "swap";
214     }
215     leaf encap-type {
216       type nsh-encap-type;
217     }
218     leaf encap-if-name {
219       type string;
220       description "Interface Name";
221     }
222   }
223
224   container vpp-nsh {
225     description
226     "NSH config data";
227
228     container nsh-entries {
229       list nsh-entry {
230         key "name";
231
232         uses nsh-entry-base-attributes;
233
234         description
235           "nsh-entry configuration";
236       }
237     }
238
239     container nsh-maps {
240       list nsh-map {
241         key "name";
242
243         uses nsh-map-base-attributes;
244
245         description
246           "nsh-map configuration";
247       }
248     }
249   }
250
251   augment /vpp-nsh/nsh-entries/nsh-entry {
252     ext:augment-identifier nsh-md-type-1-augment;
253     when "/md-type = 'vpp-nsh:md-type1' ";
254     uses nsh-md-type1-attributes;
255   }
256
257   augment /vpp-nsh/nsh-entries/nsh-entry {
258     ext:augment-identifier nsh-md-type-2-augment;
259     when "/md-type = 'vpp-nsh:md-type2' ";
260     uses nsh-md-type2-attributes;
261   }
262
263   container vpp-nsh-state {
264     config false;
265
266     description
267       "NSH operational data";
268
269     container nsh-entries {
270       list nsh-entry {
271         key "name";
272
273         uses nsh-entry-base-attributes;
274
275         description
276           "nsh-entry operational data";
277       }
278     }
279
280     container nsh-maps {
281       list nsh-map {
282         key "name";
283
284         uses nsh-map-base-attributes;
285
286         description
287           "nsh-map operational data";
288       }
289     }
290   }
291
292   augment /vpp-nsh-state/nsh-entries/nsh-entry {
293     ext:augment-identifier nsh-md-type-1-state-augment;
294     when "/md-type = 'vpp-nsh:md-type1' ";
295     uses nsh-md-type1-attributes;
296   }
297
298   augment /vpp-nsh-state/nsh-entries/nsh-entry {
299     ext:augment-identifier nsh-md-type-2-state-augment;
300     when "/md-type = 'vpp-nsh:md-type2' ";
301     uses nsh-md-type2-attributes;
302   }
303 }