BUG-45 : More progress on BGP models.
[bgpcep.git] / bgp / parser-api / src / main / yang / bgp-linkstate.yang
1 module bgp-linkstate {
2         yang-version 1;
3         namespace "urn:opendaylight:params:xml:ns:yang:bgp-linkstate";
4         prefix "bgp-ls";
5
6         import  ietf-inet-types {
7                 prefix inet;
8                 revision-date 2010-09-24;
9         }
10         import bgp-message { prefix bgp-msg;}
11         import bgp-multiprotocol { prefix bgp-mp;}
12
13         organization "Cisco Systems, Inc.";
14         contact "Dana Kutenicsova <dkutenic@cisco.com>";
15
16         description
17                 "This module contains the base data model of a BGP message.
18                 It rolls up the definitions contained in RFC4271
19                 and draft-ietf-idr-ls-distribution-03.
20
21                 Copyright (c)2013 Cisco Systems, Inc. All rights reserved.
22
23                 This program and the accompanying materials are made available
24                 under the terms of the Eclipse Public License v1.0 which
25                 accompanies this distribution, and is available at
26                 http://www.eclipse.org/legal/epl-v10.html";
27
28         revision "2013-09-18" {
29                 description
30                         "Initial revision.";
31                 reference "draft-ietf-idr-ls-distribution-03";
32         }
33
34         typedef nlri-type {
35                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2";
36                 type enumeration {
37                         enum node {
38                                 value 1;
39                         }
40                         enum link {
41                                 value 2;
42                         }
43                         enum ipv4-prefix {
44                                 value 3;
45                         }
46                         enum ipv6-prefix {
47                                 value 4;
48                         }
49                 }
50         }
51
52         typedef protocol-id {
53                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2";
54                 type enumeration {
55                         enum unknown {
56                                 value 0;
57                         }
58                         enum isis-level1 {
59                                 value 1;
60                         }
61                         enum isis-level2 {
62                                 value 2;
63                         }
64                         enum ospf {
65                                 value 3;
66                         }
67                         enum direct {
68                                 value 4;
69                         }
70                         enum static {
71                                 value 5;
72                         }
73                 }
74         }
75
76         typedef ospf-route-type {
77                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.3.1";
78                 type enumeration {
79                         enum intra-area {
80                                 value 1;
81                         }
82                         enum inter-area {
83                                 value 2;
84                         }
85                         enum external1 {
86                                 value 3;
87                         }
88                         enum external2 {
89                                 value 4;
90                         }
91                         enum nssa1 {
92                                 value 5;
93                         }
94                         enum nssa2 {
95                                 value 6;
96                         }
97                 }
98         }
99
100         typedef route-distinguisher {
101                 type uint64;
102         }
103
104         typedef identifier {
105                 type uint64;
106         }
107
108         typedef domain-identifier {
109                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
110                 type binary {
111                         length "4";
112                 }
113         }
114
115         typedef area-identifier {
116                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
117                 type binary {
118                         length "4";
119                 }
120         }
121
122         // concepts
123         typedef iso-system-identifier {
124                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
125                 type binary {
126                         length "6";
127                 }
128         }
129
130         typedef ipv4-interface-identifier {
131                 reference "http://tools.ietf.org/html/rfc5305#section-3.2";
132                 type inet:ipv4-address;
133         }
134
135         typedef ipv6-interface-identifier {
136                 reference "http://tools.ietf.org/html/rfc6119#section-4.2";
137                 type inet:ipv6-address;
138         }
139
140         typedef ospf-interface-identifier {
141                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
142                 type binary {
143                         length "4";
144                 }
145         }
146
147         typedef topology-identifier {
148                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.5";
149                 type uint16 {
150                         range "0..4095";
151                 }
152         }
153
154
155         grouping isis-router-identifier {
156                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
157                 leaf iso-system-id {
158                         type iso-system-identifier;
159                         mandatory true;
160                 }
161         }
162
163         grouping isis-lan-identifier {
164                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
165                 container is-is-router-identifier {
166                         uses isis-router-identifier;
167                 }
168                 leaf psn {
169                         type uint8 {
170                                 range "1..255";
171                         }
172                         mandatory true;
173                 }
174         }
175
176         grouping ospf-router-identifier {
177                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
178                 leaf ospf-router-id {
179                         type binary {
180                                 length "4";
181                         }
182                         mandatory true;
183                 }
184         }
185
186         grouping ospf-v2-lan-identifier {
187                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
188                 uses ospf-router-identifier;
189                 leaf ipv4-address {
190                         type ipv4-interface-identifier;
191                         mandatory true;
192                 }
193         }
194
195         grouping ospf-v3-lan-identifier {
196                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.2.1.4";
197                 uses ospf-router-identifier;
198                 leaf lan-interface {
199                         type ospf-interface-identifier;
200                         mandatory true;
201                 }
202         }
203
204         grouping node-identifier {
205                 leaf as-number {
206                         type inet:as-number;
207                 }
208                 leaf area-id {
209                         type area-identifier;
210                 }
211                 leaf domain-id {
212                         type domain-identifier;
213                 }
214                 choice router-identifier {
215                         case isis-node {
216                                 container isis-node {
217                                         uses isis-router-identifier;
218                                 }
219                         }
220
221                         case isis-pseudonode {
222                                 container isis-pseudonode {
223                                         uses isis-lan-identifier;
224                                 }
225                         }
226
227                         case ospf-node {
228                                 container ospf-node {
229                                         uses ospf-router-identifier;
230                                 }
231                         }
232
233                         case ospf-pseudonode {
234                                 container ospf-pseudonode {
235                                         uses ospf-v3-lan-identifier;
236                                 }
237                         }
238                 }
239         }
240
241         augment "/bgp-msg:update/bgp-msg:path-attributes/bgp-mp:mp-reach-nlri/bgp-mp:nlri/bgp-mp:nlri-type" {
242                 case linkstate {
243                         leaf nlri-type {
244                                 type nlri-type;
245                         }
246                         leaf distinguisher {
247                                 type route-distinguisher;
248                         }
249                         container ls-nlri {
250                                 leaf protocol-id {
251                                         type protocol-id;
252                                 }
253                                 leaf identifier {
254                                         type identifier;
255                                 }
256                                 container local-node-descriptors {
257                                         uses node-identifier;
258                                 }
259                                 container remote-node-descriptors {
260                                         when "../nlri-type = link";
261                                         uses node-identifier;
262                                 }
263                                 container Link-Descriptors {
264                                         when "../nlri-type = link";
265                                         leaf ipv4-interface-address {
266                                                 type ipv4-interface-identifier;
267                                         }
268                                         leaf ipv6-interface-address {
269                                                 type ipv6-interface-identifier;
270                                         }
271                                         leaf ipv4-neighbor-address {
272                                                 type ipv4-interface-identifier;
273                                         }
274                                         leaf ipv6-neighbor-address {
275                                                 type ipv6-interface-identifier;
276                                         }
277                                         leaf multi-topology-id {
278                                                 type topology-identifier;
279                                         }
280                                 }
281                                 container prefix-descriptors {
282                                         when "../nlri-type = 'ipv4-prefix' or ../nlri-type = 'ipv6-prefix'";
283                                         leaf multi-topology-id {
284                                                 type topology-identifier;
285                                         }
286                                         leaf ospf-route-type {
287                                                 when "../rotocol-id = 'ospf'";
288                                                 type ospf-route-type;
289                                         }
290                                         leaf ip-reachability-information {
291                                                 type inet:ip-prefix;
292                                         }
293                                 }
294                         }
295                 }
296         }
297
298         typedef node-flag-bits {
299                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.1.1";
300                 type bits {
301                         bit overload {
302                                 position 0;
303                         }
304                         bit attached {
305                                 position 1;
306                         }
307                         bit external {
308                                 position 2;
309                         }
310                         bit abr {
311                                 position 3;
312                         }
313                 }
314         }
315
316         typedef isis-area-identifier {
317                 reference "https://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.1.2";
318                 type binary {
319                         length "20";
320                 }
321         }
322
323         typedef ipv4-router-identifier {
324                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.1.4";
325                 type inet:ipv4-address;
326         }
327
328         typedef ipv6-router-identifier {
329                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.1.4";
330                 type inet:ipv6-address;
331         }
332
333         grouping node-state {
334                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.1";
335                 leaf topology-identifier {
336                         type topology-identifier;
337                 }
338                 leaf node-flags {
339                         type node-flag-bits;
340                 }
341                 leaf-list isis-area-id {
342                         type isis-area-identifier;
343                 }
344                 leaf dynamic-hostname {
345                         type string;
346                 }
347                 leaf ipv4-router-id {
348                         type ipv4-router-identifier;
349                 }
350                 leaf ipv6-router-id {
351                         type ipv6-router-identifier;
352                 }
353         }
354
355         typedef link-protection-type {
356                 reference "http://tools.ietf.org/html/rfc5307#section-1.2";
357                 type enumeration {
358                         enum extra-traffix {
359                                 value 1;
360                         }
361                         enum unprotected {
362                                 value 2;
363                         }
364                         enum shared {
365                                 value 4;
366                         }
367                         enum dedicated-1to1 {
368                                 value 8;
369                         }
370                         enum dedicated-1plus1 {
371                                 value 16;
372                         }
373                         enum enhanced {
374                                 value 32;
375                         }
376                 }
377         }
378
379         // linkstate
380         typedef mpls-protocol-mask {
381                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.2.2";
382                 type bits {
383                         bit ldp {
384                                 position 0;
385                         }
386                         bit rsvpte {
387                                 position 1;
388                         }
389                 }
390         }
391
392         // concepts
393         typedef igp-metric {
394                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.2.3";
395                 type uint32 {
396                         range "1..16777215";
397                 }
398         }
399
400         typedef shared-risk-link-group {
401                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.2.4";
402                 type uint32;
403         }
404
405         // FIXME: to double
406         // concepts
407         typedef bandwidth {
408                 type decimal64 {
409                         fraction-digits 2;
410                 }
411         }
412
413         typedef administrative-group {
414                 type uint32;
415         }
416
417         grouping unreserved-bandwidth {
418                 leaf priority {
419                         type uint8 {
420                                 range "0..7";
421                         }
422                 }
423                 leaf bandwidth {
424                         type bandwidth;
425                 }
426         }
427
428         grouping link-state {
429                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.2";
430                 leaf local-ipv4-router-id {
431                         type ipv4-router-identifier;
432                 }
433                 leaf local-ipv6-router-id {
434                         type ipv6-router-identifier;
435                 }
436                 leaf remote-ipv4-router-id {
437                         type ipv4-router-identifier;
438                 }
439                 leaf remote-ipv6-router-id {
440                         type ipv6-router-identifier;
441                 }
442                 leaf mpls-protocol {
443                         type mpls-protocol-mask;
444                 }
445                 leaf metric {
446                         type igp-metric;
447                 }
448                 leaf-list shared-risk-link-groups {
449                         type shared-risk-link-group;
450                 }
451                 leaf link-name {
452                         type string;
453                 }
454                 leaf max-link-bandwidth {
455                         type bandwidth;
456                 }
457                 leaf max-reservable-bandwidth {
458                         type bandwidth;
459                 }
460                 list unreserved-bandwidth {
461                         key "priority";
462                         uses unreserved-bandwidth;
463                 }
464                 leaf link-protection {
465                         type link-protection-type;
466                 }
467                 leaf admin-group {
468                         type administrative-group;
469                 }
470         }
471
472         typedef route-tag {
473                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.3.2";
474                 type binary {
475                         length "4";
476                 }
477         }
478
479         typedef extended-route-tag {
480                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.3.3";
481                 type binary {
482                         length "8";
483                 }
484         }
485
486         // concepts
487         typedef metric {
488                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.3.4";
489                 type uint32;
490         }
491
492         grouping igp-bits {
493                 reference "http://tools.ietf.org/html/draft-ietf-idr-ls-distribution-03#section-3.3.3.1";
494                 leaf up-down {
495                         type bits {
496                                 bit up-down {
497                                         position 0;
498                                 }
499                         }
500                 }
501         }
502
503         grouping prefix-state {
504                 container igp-bits {
505                         uses igp-bits;
506                 }
507                 leaf-list route-tags {
508                         type route-tag;
509                 }
510                 leaf-list extended-tags {
511                         type extended-route-tag;
512                 }
513                 leaf prefix-metric {
514                         type metric;
515                 }
516                 leaf ospf-forwarding-address {
517                         type inet:ipv4-address;
518                 }
519         }
520
521         augment "/bgp-msg:update/bgp-msg:path-attributes" {
522                 container linkstate-path-attribute {
523                         choice link-state-attribute {
524                                 case node-attributes {
525                                         when "../../nlri-type = node";
526                                         uses node-state;
527                                 }
528                                 case link-attributes {
529                                         when "../../nlri-type = link";
530                                         uses link-state;
531                                 }
532                                 case prefix-attributes {
533                                         when "../nlri-type = 'ipv4-prefix' or ../nlri-type = 'ipv6-prefix'";
534                                         uses prefix-state;
535                                 }
536                         }
537                 }
538         }
539 }