Upgrade ietf-{inet,yang}-types to 2013-07-15
[bgpcep.git] / bgp / concepts / src / main / yang / bgp-types.yang
1 module bgp-types {
2     yang-version 1;
3     namespace "urn:opendaylight:params:xml:ns:yang:bgp-types";
4     prefix "bgp-t";
5
6     import ietf-inet-types { prefix inet; revision-date 2013-07-15; }
7     import network-concepts { prefix netc; revision-date 2013-11-25; }
8
9     organization "Cisco Systems, Inc.";
10     contact "Dana Kutenicsova <dkutenic@cisco.com>";
11
12     description
13         "This module contains the base concepts contained in RFC4271 and RFC4760.
14
15         Copyright (c)2013 Cisco Systems, Inc. All rights reserved.
16
17         This program and the accompanying materials are made available
18         under the terms of the Eclipse Public License v1.0 which
19         accompanies this distribution, and is available at
20         http://www.eclipse.org/legal/epl-v10.html";
21
22     revision "2013-09-19" {
23         description
24             "Initial revision.";
25         reference "RFC4271, RFC4760";
26     }
27
28     typedef bgp-origin {
29         reference "http://tools.ietf.org/html/rfc4271#section-5";
30         description "Values of BGP Origin Path Attribute.";
31         type enumeration {
32             enum igp {
33                 value 0;
34             }
35             enum egp {
36                 value 1;
37             }
38             enum incomplete {
39                 value 2;
40             }
41         }
42     }
43
44     typedef bgp-id {
45         description "BGP identifier";
46         type inet:ipv4-address;
47     }
48
49     identity address-family {
50         reference "http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml#address-family-numbers-2";
51     }
52
53     identity ipv4-address-family {
54         base address-family;
55     }
56
57     identity ipv6-address-family {
58         base address-family;
59     }
60
61     identity subsequent-address-family {
62         reference "http://tools.ietf.org/html/rfc4760#section-6";
63     }
64
65     identity unicast-subsequent-address-family {
66         reference "http://tools.ietf.org/html/rfc4760#section-6";
67
68         base subsequent-address-family;
69     }
70
71     identity mpls-labeled-vpn-subsequent-address-family {
72         reference "http://tools.ietf.org/html/rfc4760#section-6";
73
74         base subsequent-address-family;
75     }
76
77     typedef cluster-identifier {
78         reference "http://tools.ietf.org/html/rfc4456#section-8";
79         type inet:ipv4-address;
80     }
81
82     typedef short-as-number {
83         type inet:as-number {
84             range 0..65535;
85         }
86     }
87
88     typedef route-distinguisher {
89         reference "https://tools.ietf.org/html/rfc4364#section-4.2";
90         type union {
91             type rd-two-octet-as;
92             type rd-ipv4;
93             type rd-as;
94         }
95     }
96
97     typedef rd-two-octet-as {
98         type string {
99             /* 2B AS : 4B number */
100             pattern '0:'
101                 + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
102                 + '[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|'
103                 + '65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])'
104                 + ':'
105                 + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
106                 + '[1-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9]|'
107                 + '[1-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
108                 + '[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-3][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
109                 + '4[0-1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|42[0-8][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
110                 + '429[0-3][0-9][0-9][0-9][0-9][0-9][0-9]|4294[0-8][0-9][0-9][0-9][0-9][0-9]|'
111                 + '42949[0-5][0-9][0-9][0-9][0-9]|429496[0-6][0-9][0-9][0-9]|4294967[0-1][0-9][0-9]|'
112                 + '42949672[0-8][0-9]|429496729[0-5])';
113         }
114     }
115
116     typedef rd-ipv4 {
117         type string {
118             /* IPv4 : 2B number */
119             pattern '((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
120                 + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))'
121                 + ':'
122                 + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
123                 + '[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|'
124                 + '65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])';
125         }
126     }
127
128     typedef rd-as {
129         type string {
130             /* 4B AS : 2B number */
131             pattern '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
132                 + '[1-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9]|'
133                 + '[1-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
134                 + '[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-3][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
135                 + '4[0-1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|42[0-8][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
136                 + '429[0-3][0-9][0-9][0-9][0-9][0-9][0-9]|4294[0-8][0-9][0-9][0-9][0-9][0-9]|'
137                 + '42949[0-5][0-9][0-9][0-9][0-9]|429496[0-6][0-9][0-9][0-9]|4294967[0-1][0-9][0-9]|'
138                 + '42949672[0-8][0-9]|429496729[0-5])'
139                 + ':'
140                 + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
141                 + '[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|'
142                 + '65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])';
143         }
144     }
145
146     typedef encapsulation-tunnel-type {
147         reference "http://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml#tunnel-types";
148         type enumeration {
149             enum l2tpv3-over-ip {
150                 value 1;
151             }
152             enum gre {
153                 value 2;
154             }
155             enum transmit-tunnel-endpoint {
156                 value 3;
157             }
158             enum ipsec-tunnel-mode {
159                 value 4;
160             }
161             enum ip-in-ip-ipsec-transport-mode {
162                 value 5;
163             }
164             enum mpls-in-ip-tunnel-ipsec-transport-mode {
165                 value 6;
166             }
167             enum ip-in-ip {
168                 value 7;
169             }
170             enum vxlan {
171                 value 8;
172             }
173             enum nvgre {
174                 value 9;
175             }
176             enum mpls {
177                 value 10;
178             }
179             enum mpls-in-gre {
180                 value 11;
181             }
182             enum vxlan-gpe {
183                 value 12;
184             }
185             enum mpls-in-udp {
186                 value 13;
187             }
188             enum ipv6-tunnel {
189                 value 14;
190             }
191         }
192     }
193
194     grouping bgp-aggregator {
195         reference "http://tools.ietf.org/html/rfc4271#section-5.1.7";
196         description "BGP Path Attribute AGGREGATOR.";
197         leaf as-number {
198             // We are acting as a NEW speaker, so only four bytes are allowed
199             type inet:as-number;
200         }
201         leaf network-address {
202             type inet:ipv4-address;
203         }
204     }
205
206     grouping community {
207         reference "https://tools.ietf.org/html/rfc1997";
208         description "Community Path Attribute";
209         leaf as-number {
210             type inet:as-number;
211         }
212         leaf semantics {
213             type uint16;
214         }
215     }
216
217     grouping route-ipv4-extended-community {
218         reference "http://tools.ietf.org/html/rfc4360";
219         leaf global-administrator {
220             type inet:ipv4-address;
221         }
222         leaf local-administrator {
223             type uint16;
224         }
225     }
226
227     grouping link-bandwidth-extended-community {
228         reference "https://tools.ietf.org/html/draft-ietf-idr-link-bandwidth-06#section-2";
229         description
230             "The Link Bandwidth extended community is optional non-transitive";
231
232         leaf bandwidth {
233             description "Bandwidth of the link";
234             mandatory true;
235             type netc:bandwidth;
236             units "bytes per second";
237         }
238     }
239
240     grouping as-4-spec-common {
241         container as-4-specific-common {
242             leaf as-number {
243                 description "Carries a 4-octet Autonomous System (AS) number";
244                 reference "https://tools.ietf.org/html/rfc5668#section-2";
245
246                 mandatory true;
247                 type inet:as-number;
248             }
249
250             leaf local-administrator {
251                 type uint16;
252                 mandatory true;
253             }
254         }
255     }
256
257     grouping encapsulation-extended-community {
258         reference "https://tools.ietf.org/html/rfc5512#section-4.5";
259         description "BGP Encapsulation extended community";
260
261         leaf tunnel-type {
262             description "Tunnel type specifying the encapsulation protocol";
263             mandatory true;
264             type encapsulation-tunnel-type;
265         }
266     }
267
268     grouping extended-community {
269         leaf transitive {
270             type boolean;
271         }
272         choice extended-community {
273             case as-specific-extended-community-case {
274                 container as-specific-extended-community {
275                     leaf global-administrator {
276                         type short-as-number;
277                     }
278                     leaf local-administrator {
279                         type binary {
280                             length "4";
281                         }
282                     }
283                 }
284             }
285             case inet4-specific-extended-community-case {
286                 container inet4-specific-extended-community {
287                     leaf global-administrator {
288                         type inet:ipv4-address;
289                     }
290                     leaf local-administrator {
291                         type binary {
292                             length "2";
293                         }
294                     }
295                 }
296             }
297             case opaque-extended-community-case {
298                 container opaque-extended-community {
299                     leaf value {
300                         type binary {
301                             length "6";
302                         }
303                     }
304                 }
305             }
306             case route-target-extended-community-case {
307                 container route-target-extended-community {
308                     leaf global-administrator {
309                         type short-as-number;
310                     }
311                     leaf local-administrator {
312                         type binary {
313                             length "4";
314                         }
315                     }
316                 }
317             }
318             case route-origin-extended-community-case {
319                 container route-origin-extended-community {
320                     leaf global-administrator {
321                         type short-as-number;
322                     }
323                     leaf local-administrator {
324                         type binary {
325                             length "4";
326                         }
327                     }
328                 }
329             }
330             case route-target-ipv4-case {
331                 container route-target-ipv4 {
332                     reference "http://tools.ietf.org/html/rfc4360#section-4";
333                     uses route-ipv4-extended-community;
334                 }
335             }
336             case route-origin-ipv4-case {
337                 container route-origin-ipv4 {
338                     reference "http://tools.ietf.org/html/rfc4360#section-5";
339                     uses route-ipv4-extended-community;
340                 }
341             }
342             case link-bandwidth-case {
343                 container link-bandwidth-extended-community {
344                     uses link-bandwidth-extended-community;
345                 }
346             }
347             case as-4-generic-spec-extended-community-case {
348                 container as-4-generic-spec-extended-community {
349                     reference "https://www.ietf.org/archive/id/draft-ietf-idr-as4octet-extcomm-generic-subtype-08.txt";
350                     uses as-4-spec-common;
351                 }
352             }
353             case as-4-route-target-extended-community-case {
354                 container as-4-route-target-extended-community {
355                     reference "https://tools.ietf.org/html/rfc5668";
356                     uses as-4-spec-common;
357                 }
358             }
359             case as-4-route-origin-extended-community-case {
360                 container as-4-route-origin-extended-community {
361                     reference "https://tools.ietf.org/html/rfc5668";
362                     uses as-4-spec-common;
363                 }
364             }
365             case encapsulation-case {
366                 container encapsulation-extended-community {
367                     uses encapsulation-extended-community;
368                 }
369             }
370         }
371     }
372
373     grouping next-hop {
374         choice c-next-hop {
375             default empty-next-hop-case;
376             case ipv4-next-hop-case {
377                 container ipv4-next-hop {
378                     reference "http://tools.ietf.org/html/rfc4271#section-5.1.3";
379                     leaf global {
380                         type inet:ipv4-address;
381                     }
382                 }
383             }
384             case ipv6-next-hop-case {
385                 container ipv6-next-hop {
386                     reference "http://tools.ietf.org/html/rfc4760#section-3";
387                     leaf global {
388                         type inet:ipv6-address;
389                     }
390                     leaf link-local {
391                         type inet:ipv6-address;
392                     }
393                 }
394             }
395             case empty-next-hop-case {
396                 leaf empty-next-hop {
397                     type empty;
398                 }
399             }
400         }
401     }
402
403     grouping as-path-segment {
404         reference "http://tools.ietf.org/html/rfc4271#section-5.1.2";
405         leaf-list as-sequence {
406             type inet:as-number;
407             ordered-by user;
408             max-elements "255";
409         }
410         leaf-list as-set {
411             type inet:as-number;
412         }
413     }
414 }