97c0291d0cb102479186af81c0913c3e0b8c957d
[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 2010-09-24; }
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     identity address-family {
45         reference "http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml#address-family-numbers-2";
46     }
47
48     identity ipv4-address-family {
49         base address-family;
50     }
51
52     identity ipv6-address-family {
53         base address-family;
54     }
55
56     identity subsequent-address-family {
57         reference "http://tools.ietf.org/html/rfc4760#section-6";
58     }
59
60     identity unicast-subsequent-address-family {
61         reference "http://tools.ietf.org/html/rfc4760#section-6";
62
63         base subsequent-address-family;
64     }
65
66     identity mpls-labeled-vpn-subsequent-address-family {
67         reference "http://tools.ietf.org/html/rfc4760#section-6";
68
69         base subsequent-address-family;
70     }
71
72     typedef cluster-identifier {
73         reference "http://tools.ietf.org/html/rfc4456#section-8";
74         type inet:ipv4-address;
75     }
76
77     typedef short-as-number {
78         type inet:as-number {
79             range 0..65535;
80         }
81     }
82
83     typedef route-distinguisher {
84         reference "https://tools.ietf.org/html/rfc4364#section-4.2";
85         type union {
86             type rd-ipv4;
87             type rd-as;
88         }
89     }
90
91     typedef rd-ipv4 {
92         type string {
93             /* IPv4 : 2B number */
94             pattern '((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
95                 + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))'
96                 + ':'
97                 + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
98                 + '[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|'
99                 + '65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])';
100         }
101     }
102
103     typedef rd-as {
104         type string {
105             /* 4B AS : 2B number */
106             pattern '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
107                 + '[1-9][0-9][0-9][0-9][0-9]|[1-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]|[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
109                 + '[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]|'
110                 + '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]|'
111                 + '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]|'
112                 + '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]|'
113                 + '42949672[0-8][0-9]|429496729[0-5])'
114                 + ':'
115                 + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
116                 + '[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|'
117                 + '65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])';
118         }
119     }
120
121     grouping bgp-aggregator {
122         reference "http://tools.ietf.org/html/rfc4271#section-5.1.7";
123         description "BGP Path Attribute AGGREGATOR.";
124         leaf as-number {
125             // We are acting as a NEW speaker, so only four bytes are allowed
126             type inet:as-number;
127         }
128         leaf network-address {
129             type inet:ipv4-address;
130         }
131     }
132
133     grouping community {
134         reference "https://tools.ietf.org/html/rfc1997";
135         description "Community Path Attribute";
136         leaf as-number {
137             type inet:as-number;
138         }
139         leaf semantics {
140             type uint16;
141         }
142     }
143
144     grouping route-ipv4-extended-community {
145         reference "http://tools.ietf.org/html/rfc4360";
146         leaf global-administrator {
147             type inet:ipv4-address;
148         }
149         leaf local-administrator {
150             type uint16;
151         }
152     }
153
154     grouping link-bandwidth-extended-community {
155         reference "https://tools.ietf.org/html/draft-ietf-idr-link-bandwidth-06#section-2";
156         description
157             "The Link Bandwidth extended community is optional non-transitive";
158
159         leaf bandwidth {
160             description "Bandwidth of the link";
161             mandatory true;
162             type netc:bandwidth;
163             units "bytes per second";
164         }
165     }
166
167     grouping extended-community {
168         leaf comm-type {
169             status deprecated;
170             type uint8;
171         }
172         leaf comm-sub-type {
173             status deprecated;
174             type uint8;
175         }
176         leaf transitive {
177             type boolean;
178         }
179         choice extended-community {
180             case as-specific-extended-community-case {
181                 container as-specific-extended-community {
182                     leaf transitive {
183                         status deprecated;
184                         type boolean;
185                     }
186                     leaf global-administrator {
187                         type short-as-number;
188                     }
189                     leaf local-administrator {
190                         type binary {
191                             length "4";
192                         }
193                     }
194                 }
195             }
196             case inet4-specific-extended-community-case {
197                 container inet4-specific-extended-community {
198                     leaf transitive {
199                         status deprecated;
200                         type boolean;
201                     }
202                     leaf global-administrator {
203                         type inet:ipv4-address;
204                     }
205                     leaf local-administrator {
206                         type binary {
207                             length "2";
208                         }
209                     }
210                 }
211             }
212             case opaque-extended-community-case {
213                 container opaque-extended-community {
214                     leaf transitive {
215                         status deprecated;
216                         type boolean;
217                     }
218                     leaf value {
219                         type binary {
220                             length "6";
221                         }
222                     }
223                 }
224             }
225             case route-target-extended-community-case {
226                 container route-target-extended-community {
227                     leaf global-administrator {
228                         type short-as-number;
229                     }
230                     leaf local-administrator {
231                         type binary {
232                             length "4";
233                         }
234                     }
235                 }
236             }
237             case route-origin-extended-community-case {
238                 container route-origin-extended-community {
239                     leaf global-administrator {
240                         type short-as-number;
241                     }
242                     leaf local-administrator {
243                         type binary {
244                             length "4";
245                         }
246                     }
247                 }
248             }
249             case route-target-ipv4-case {
250                 container route-target-ipv4 {
251                     reference "http://tools.ietf.org/html/rfc4360#section-4";
252                     uses route-ipv4-extended-community;
253                 }
254             }
255             case route-origin-ipv4-case {
256                 container route-origin-ipv4 {
257                     reference "http://tools.ietf.org/html/rfc4360#section-5";
258                     uses route-ipv4-extended-community;
259                 }
260             }
261             case link-bandwidth-case {
262                 container link-bandwidth-extended-community {
263                     uses link-bandwidth-extended-community;
264                 }
265             }
266         }
267     }
268
269     grouping next-hop {
270         choice c-next-hop {
271             case ipv4-next-hop-case {
272                 container ipv4-next-hop {
273                     reference "http://tools.ietf.org/html/rfc4271#section-5.1.3";
274                     leaf global {
275                         type inet:ipv4-address;
276                     }
277                 }
278             }
279             case ipv6-next-hop-case {
280                 container ipv6-next-hop {
281                     reference "http://tools.ietf.org/html/rfc4760#section-3";
282                     leaf global {
283                         type inet:ipv6-address;
284                     }
285                     leaf link-local {
286                         type inet:ipv6-address;
287                     }
288                 }
289             }
290         }
291     }
292
293     grouping as-path-segment {
294         reference "http://tools.ietf.org/html/rfc4271#section-5.1.2";
295         choice c-segment {
296         description "This model is obsolete and please use just leaf-lists as-sequence and as-set nested directly under as-path-segment.";
297             status obsolete;
298             case a-set-case {
299                 container a-set {
300                     leaf-list as-set {
301                         type inet:as-number;
302                     }
303                 }
304             }
305             case a-list-case {
306                 container a-list {
307                     list as-sequence {
308                         leaf as {
309                             type inet:as-number;
310                         }
311                     }
312                 }
313             }
314         }
315         leaf-list as-sequence {
316             type inet:as-number;
317             ordered-by user;
318             max-elements "255";
319         }
320         leaf-list as-set {
321             type inet:as-number;
322         }
323     }
324 }