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