Bump versions by x.y.(z+1)
[bgpcep.git] / bgp / flowspec / src / main / yang / bgp-flowspec.yang
1 module bgp-flowspec {
2     yang-version 1;
3     namespace "urn:opendaylight:params:xml:ns:yang:bgp-flowspec";
4     prefix "bgp-fs";
5
6     import ietf-inet-types { prefix inet; revision-date 2013-07-15; }
7     import bgp-message { prefix bgp-msg; revision-date 2013-09-19; }
8     import bgp-multiprotocol { prefix bgp-mp; revision-date 2013-09-19; }
9     import bgp-rib { prefix bgp-rib; revision-date 2013-09-25; }
10     import bgp-types { prefix bgp-t; revision-date 2013-09-19; }
11     import network-concepts { prefix netc; revision-date 2013-11-25; }
12     import bmp-monitor { prefix bmp-mon; revision-date 2015-05-12; }
13
14     organization "Cisco Systems, Inc.";
15     contact "Dana Kutenicsova <dkutenic@cisco.com>";
16
17     description
18         "This module contains the base data model of a BGP flow specification.
19         It rolls up the definitions contained in RFC5575.
20
21         Copyright (c)2015 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 "2015-08-07" {
29         description
30             "IPv6 support";
31         reference "https://tools.ietf.org/html/draft-ietf-idr-flow-spec-v6-06";
32     }
33
34     revision "2015-01-14" {
35         description
36             "Initial revision.";
37         reference "http://tools.ietf.org/html/rfc5575";
38     }
39
40     identity flowspec-subsequent-address-family {
41         description "SAFI 133 for dissemination of unicast flow specification rules.";
42         reference "http://tools.ietf.org/html/rfc5575#section-11";
43
44         base bgp-t:subsequent-address-family;
45     }
46
47     identity flowspec-l3vpn-subsequent-address-family {
48         description "SAFI 134 for dissemination of L3VPN flow specification rules";
49         reference "http://tools.ietf.org/html/rfc5575#section-11";
50
51         base bgp-t:subsequent-address-family;
52     }
53
54     typedef fragment {
55         reference "http://tools.ietf.org/html/rfc5575#section-4";
56         type bits {
57             bit last {
58                 position 4;
59             }
60             bit first {
61                 position 5;
62             }
63             bit is-a {
64                 position 6;
65             }
66             bit do-not {
67                 position 7;
68             }
69         }
70     }
71
72     typedef dscp {
73         reference "https://tools.ietf.org/html/rfc2474#section-3";
74         type uint8 {
75             range "0..63";
76         }
77     }
78
79     typedef numeric-operand {
80         reference "http://tools.ietf.org/html/rfc5575#section-4";
81         type bits {
82             bit end-of-list {
83                 position 0;
84             }
85             bit and-bit {
86                 position 1;
87             }
88             bit less-than {
89                 position 5;
90             }
91             bit greater-than {
92                 position 6;
93             }
94             bit equals {
95                 position 7;
96             }
97         }
98     }
99
100     typedef bitmask-operand {
101         reference "http://tools.ietf.org/html/rfc5575#section-4";
102         type bits {
103             bit end-of-list {
104                 position 0;
105             }
106             bit and-bit {
107                 position 1;
108             }
109             bit not {
110                 position 6;
111             }
112             bit match {
113                 position 7;
114             }
115         }
116     }
117
118     grouping numeric-two-byte-value {
119         reference "http://tools.ietf.org/html/rfc5575#section-4";
120         leaf op {
121             type numeric-operand;
122         }
123         leaf value {
124             type uint16;
125         }
126     }
127
128     grouping numeric-one-byte-value {
129         reference "http://tools.ietf.org/html/rfc5575#section-4";
130         leaf op {
131             type numeric-operand;
132         }
133         leaf value {
134             type uint8;
135         }
136     }
137
138     grouping bitmask-two-byte-value {
139         reference "http://tools.ietf.org/html/rfc5575#section-4";
140         leaf op {
141             type bitmask-operand;
142         }
143         leaf value {
144             type uint16;
145         }
146     }
147
148     grouping dscp-value {
149         reference "http://tools.ietf.org/html/rfc5575#section-4";
150         leaf op {
151             type numeric-operand;
152         }
153         leaf value {
154             type dscp;
155         }
156     }
157
158     grouping fragment-value {
159         reference "http://tools.ietf.org/html/rfc5575#section-4";
160         leaf op {
161             type bitmask-operand;
162         }
163         leaf value {
164             type fragment;
165         }
166     }
167
168     grouping flowspec-destination {
169         reference "http://tools.ietf.org/html/rfc5575#section-4";
170         list flowspec {
171             choice flowspec-type {
172                 case port-case {
173                     list ports {
174                         uses numeric-two-byte-value;
175                     }
176                 }
177                 case destination-port-case {
178                     list destination-ports {
179                         uses numeric-two-byte-value;
180                     }
181                 }
182                 case source-port-case {
183                     list source-ports {
184                         uses numeric-two-byte-value;
185                     }
186                 }
187                 case icmp-type-case {
188                     list types {
189                         uses numeric-one-byte-value;
190                     }
191                 }
192                 case icmp-code-case {
193                     list codes {
194                         uses numeric-one-byte-value;
195                     }
196                 }
197                 case tcp-flags-case {
198                     list tcp-flags {
199                         uses bitmask-two-byte-value;
200                     }
201                 }
202                 case packet-length-case {
203                     list packet-lengths {
204                         uses numeric-two-byte-value;
205                     }
206                 }
207                 case dscp-case {
208                     list dscps {
209                         uses dscp-value;
210                     }
211                 }
212                 case fragment-case {
213                     list fragments {
214                         uses fragment-value;
215                     }
216                 }
217             }
218         }
219         uses bgp-msg:path-id-grouping;
220     }
221
222     grouping flowspec-destination-group-ipv4 {
223         reference "http://tools.ietf.org/html/rfc5575#section-4";
224         uses flowspec-destination {
225             augment "flowspec/flowspec-type" {
226                 case destination-prefix-case {
227                     leaf destination-prefix {
228                         type inet:ipv4-prefix;
229                     }
230                 }
231                 case source-prefix-case {
232                     leaf source-prefix {
233                         type inet:ipv4-prefix;
234                     }
235                 }
236                 case protocol-ip-case {
237                     list protocol-ips {
238                         uses numeric-one-byte-value;
239                     }
240                 }
241             }
242         }
243     }
244
245     grouping flow-label-value {
246         reference "https://tools.ietf.org/html/draft-ietf-idr-flow-spec-v6-06#section-3";
247         leaf op {
248             type numeric-operand;
249         }
250         leaf value {
251             type uint32;
252         }
253     }
254
255     grouping flowspec-destination-group-ipv6 {
256         reference "https://tools.ietf.org/html/draft-ietf-idr-flow-spec-v6-06#section-3.1";
257         uses flowspec-destination {
258             augment "flowspec/flowspec-type" {
259                 case destination-ipv6-prefix-case {
260                     leaf destination-prefix {
261                         type inet:ipv6-prefix;
262                     }
263                 }
264                 case source-ipv6-prefix-case {
265                     leaf source-prefix {
266                         type inet:ipv6-prefix;
267                     }
268                 }
269                 case next-header-case {
270                     list next-headers {
271                         uses numeric-one-byte-value;
272                     }
273                 }
274                 case flow-label-case {
275                     list flow-label {
276                         uses flow-label-value;
277                     }
278                 }
279             }
280         }
281     }
282
283     grouping flowspec-destination-ipv4 {
284         container destination-flowspec {
285             uses flowspec-destination-group-ipv4;
286         }
287     }
288
289     grouping flowspec-destination-ipv6 {
290         container destination-flowspec {
291             uses flowspec-destination-group-ipv6;
292         }
293     }
294
295     grouping flowspec-l3vpn-rd {
296         reference "https://tools.ietf.org/html/rfc5575#section-8";
297         leaf route-distinguisher {
298             type bgp-t:route-distinguisher;
299         }
300     }
301
302     grouping flowspec-l3vpn-destination-ipv4 {
303         container destination-flowspec-l3vpn-ipv4 {
304             uses flowspec-l3vpn-rd;
305             uses flowspec-destination-group-ipv4;
306         }
307     }
308
309     grouping flowspec-l3vpn-destination-ipv6 {
310         container destination-flowspec-l3vpn-ipv6 {
311             uses flowspec-l3vpn-rd;
312             uses flowspec-destination-group-ipv6;
313         }
314     }
315
316     augment "/bgp-msg:update/bgp-msg:attributes/bgp-mp:mp-reach-nlri/bgp-mp:advertized-routes/bgp-mp:destination-type" {
317         case destination-flowspec-case {
318             uses flowspec-destination-ipv4;
319         }
320         case destination-flowspec-ipv6-case {
321             uses flowspec-destination-ipv6;
322         }
323         case destination-flowspec-l3vpn-ipv4-case {
324             uses flowspec-l3vpn-destination-ipv4;
325         }
326         case destination-flowspec-l3vpn-ipv6-case {
327             uses flowspec-l3vpn-destination-ipv6;
328         }
329     }
330
331     augment "/bgp-msg:update/bgp-msg:attributes/bgp-mp:mp-unreach-nlri/bgp-mp:withdrawn-routes/bgp-mp:destination-type" {
332         case destination-flowspec-case {
333             uses flowspec-destination-ipv4;
334         }
335         case destination-flowspec-ipv6-case {
336             uses flowspec-destination-ipv6;
337         }
338         case destination-flowspec-l3vpn-ipv4-case {
339             uses flowspec-l3vpn-destination-ipv4;
340         }
341         case destination-flowspec-l3vpn-ipv6-case {
342             uses flowspec-l3vpn-destination-ipv6;
343         }
344     }
345
346     grouping traffic-rate-extended-community {
347         container traffic-rate-extended-community {
348             leaf informative-as {
349                 type bgp-t:short-as-number;
350             }
351             leaf local-administrator {
352                 type netc:bandwidth;
353             }
354         }
355     }
356
357     grouping traffic-action-extended-community {
358         container traffic-action-extended-community {
359             leaf sample {
360                 type boolean;
361                 default false;
362             }
363             leaf terminal-action {
364                 type boolean;
365                 default false;
366             }
367         }
368     }
369
370     grouping redirect-extended-community {
371         container redirect-extended-community {
372             leaf global-administrator {
373                 type bgp-t:short-as-number;
374             }
375             leaf local-administrator {
376                 type binary {
377                     length "4";
378                 }
379             }
380         }
381     }
382
383     grouping redirect-ipv4-extended-community {
384         reference "http://tools.ietf.org/html/rfc7674";
385         container redirect-ipv4 {
386             uses bgp-t:route-ipv4-extended-community;
387         }
388     }
389
390     grouping redirect-ipv6-extended-community {
391         container redirect-ipv6 {
392             leaf global-administrator {
393                 type inet:ipv6-address;
394             }
395             leaf local-administrator {
396                 type uint16;
397             }
398         }
399     }
400
401     grouping redirect-as4-extended-community {
402         reference "http://tools.ietf.org/html/rfc7674";
403         container redirect-as4 {
404             leaf global-administrator {
405                 type inet:as-number;
406             }
407             leaf local-administrator {
408                 type uint16;
409             }
410         }
411     }
412
413     grouping traffic-marking-extended-community {
414         container traffic-marking-extended-community {
415             leaf global-administrator {
416                 type dscp;
417             }
418         }
419     }
420
421     grouping redirect-ip-nh-extended-community {
422         reference "https://tools.ietf.org/html/draft-ietf-idr-flowspec-redirect-ip-02";
423         container redirect-ip-nh-extended-community {
424             leaf next-hop-address {
425                 type inet:ip-address;
426             }
427             leaf copy {
428                 type boolean;
429             }
430         }
431     }
432
433     grouping bgp-rib-route {
434         uses bgp-rib:route {
435             augment "attributes/extended-communities/extended-community" {
436                 case traffic-rate-extended-community-case {
437                     uses traffic-rate-extended-community;
438                 }
439                 case traffic-action-extended-community-case {
440                     uses traffic-action-extended-community;
441                 }
442                 case redirect-extended-community-case {
443                     uses redirect-extended-community;
444                 }
445                 case traffic-marking-extended-community-case {
446                     uses traffic-marking-extended-community;
447                 }
448                 case redirect-ipv4-extended-community-case {
449                     uses redirect-ipv4-extended-community;
450                 }
451                 case redirect-ipv6-extended-community-case {
452                     uses redirect-ipv6-extended-community;
453                 }
454                 case redirect-as4-extended-community-case {
455                     uses redirect-as4-extended-community;
456                 }
457                 case redirect-ip-nh-extended-community-case {
458                     uses redirect-ip-nh-extended-community;
459                 }
460             }
461         }
462     }
463
464     grouping flowspec-ipv4-route-list {
465         leaf route-key {
466             description
467                 "The sole function of this leaf
468                 to act as the key in the list.
469                 Its format does not form the
470                 API contract of this model.";
471             type string;
472         }
473         uses flowspec-destination-group-ipv4;
474         uses bgp-rib-route;
475     }
476
477     grouping flowspec-ipv4-route {
478         list flowspec-route {
479             key "route-key path-id";
480             uses flowspec-ipv4-route-list;
481         }
482     }
483
484     grouping flowspec-l3vpn-ipv4-route {
485         list flowspec-l3vpn-route {
486             key "route-key path-id";
487             uses flowspec-ipv4-route-list;
488             uses flowspec-l3vpn-rd;
489         }
490     }
491
492     grouping flowspec-ipv6-route-list {
493         uses flowspec-destination-group-ipv6;
494         uses bgp-rib-route;
495         leaf route-key {
496             description
497                 "The sole function of this leaf
498                 to act as the key in the list.
499                 Its format does not form the
500                 API contract of this model.";
501             type string;
502         }
503     }
504
505     grouping flowspec-ipv6-route {
506         list flowspec-route {
507             key "route-key path-id";
508             uses flowspec-ipv6-route-list;
509         }
510     }
511
512     grouping flowspec-l3vpn-ipv6-route {
513         list flowspec-l3vpn-route {
514             key "route-key path-id";
515             uses flowspec-ipv6-route-list;
516             uses flowspec-l3vpn-rd;
517         }
518     }
519
520     grouping flowspec-routes {
521         container flowspec-routes {
522             uses flowspec-ipv4-route;
523         }
524     }
525
526     grouping flowspec-ipv6-routes {
527         container flowspec-ipv6-routes {
528             uses flowspec-ipv6-route;
529         }
530     }
531
532     grouping flowspec-l3vpn-ipv4-routes {
533         container flowspec-l3vpn-ipv4-routes {
534             uses flowspec-l3vpn-ipv4-route;
535         }
536     }
537
538     grouping flowspec-l3vpn-ipv6-routes {
539         container flowspec-l3vpn-ipv6-routes {
540             uses flowspec-l3vpn-ipv6-route;
541         }
542     }
543
544     augment "/bgp-msg:update/bgp-msg:attributes/bgp-msg:extended-communities/bgp-msg:extended-community" {
545         reference "https://tools.ietf.org/html/rfc5575#section-7";
546         case traffic-rate-extended-community-case {
547             uses traffic-rate-extended-community;
548         }
549         case traffic-action-extended-community-case {
550             uses traffic-action-extended-community;
551         }
552         case redirect-extended-community-case {
553             uses redirect-extended-community;
554         }
555         case traffic-marking-extended-community-case {
556             uses traffic-marking-extended-community;
557         }
558         case redirect-ipv4-extended-community-case {
559             uses redirect-ipv4-extended-community;
560         }
561         case redirect-ipv6-extended-community-case {
562             uses redirect-ipv6-extended-community;
563         }
564         case redirect-as4-extended-community-case {
565             uses redirect-as4-extended-community;
566         }
567         case redirect-ip-nh-extended-community-case {
568             uses redirect-ip-nh-extended-community;
569         }
570     }
571
572     augment "/bgp-rib:application-rib/bgp-rib:tables/bgp-rib:routes" {
573         case flowspec-routes-case {
574             uses flowspec-routes;
575         }
576         case flowspec-ipv6-routes-case {
577             uses flowspec-ipv6-routes;
578         }
579         case flowspec-l3vpn-ipv4-routes-case {
580             uses flowspec-l3vpn-ipv4-routes;
581         }
582         case flowspec-l3vpn-ipv6-routes-case {
583             uses flowspec-l3vpn-ipv6-routes;
584         }
585     }
586
587     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:loc-rib/bgp-rib:tables/bgp-rib:routes" {
588         case flowspec-routes-case {
589             uses flowspec-routes;
590         }
591         case flowspec-ipv6-routes-case {
592             uses flowspec-ipv6-routes;
593         }
594         case flowspec-l3vpn-ipv4-routes-case {
595             uses flowspec-l3vpn-ipv4-routes;
596         }
597         case flowspec-l3vpn-ipv6-routes-case {
598             uses flowspec-l3vpn-ipv6-routes;
599         }
600     }
601
602     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:peer/bgp-rib:adj-rib-in/bgp-rib:tables/bgp-rib:routes" {
603         case flowspec-routes-case {
604             uses flowspec-routes;
605         }
606         case flowspec-ipv6-routes-case {
607             uses flowspec-ipv6-routes;
608         }
609         case flowspec-l3vpn-ipv4-routes-case {
610             uses flowspec-l3vpn-ipv4-routes;
611         }
612         case flowspec-l3vpn-ipv6-routes-case {
613             uses flowspec-l3vpn-ipv6-routes;
614         }
615     }
616
617     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:peer/bgp-rib:effective-rib-in/bgp-rib:tables/bgp-rib:routes" {
618         case flowspec-routes-case {
619             uses flowspec-routes;
620         }
621         case flowspec-ipv6-routes-case {
622             uses flowspec-ipv6-routes;
623         }
624         case flowspec-l3vpn-ipv4-routes-case {
625             uses flowspec-l3vpn-ipv4-routes;
626         }
627         case flowspec-l3vpn-ipv6-routes-case {
628             uses flowspec-l3vpn-ipv6-routes;
629         }
630     }
631
632     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:peer/bgp-rib:adj-rib-out/bgp-rib:tables/bgp-rib:routes" {
633         case flowspec-routes-case {
634             uses flowspec-routes;
635         }
636         case flowspec-ipv6-routes-case {
637             uses flowspec-ipv6-routes;
638         }
639         case flowspec-l3vpn-ipv4-routes-case {
640             uses flowspec-l3vpn-ipv4-routes;
641         }
642         case flowspec-l3vpn-ipv6-routes-case {
643             uses flowspec-l3vpn-ipv6-routes;
644         }
645     }
646
647     augment "/bmp-mon:bmp-monitor/bmp-mon:monitor/bmp-mon:router/bmp-mon:peer/bmp-mon:pre-policy-rib/bmp-mon:tables/bmp-mon:routes" {
648         case flowspec-routes-case {
649             uses flowspec-routes;
650         }
651         case flowspec-ipv6-routes-case {
652             uses flowspec-ipv6-routes;
653         }
654         case flowspec-l3vpn-ipv4-routes-case {
655             uses flowspec-l3vpn-ipv4-routes;
656         }
657         case flowspec-l3vpn-ipv6-routes-case {
658             uses flowspec-l3vpn-ipv6-routes;
659         }
660     }
661
662     augment "/bmp-mon:bmp-monitor/bmp-mon:monitor/bmp-mon:router/bmp-mon:peer/bmp-mon:post-policy-rib/bmp-mon:tables/bmp-mon:routes" {
663         case flowspec-routes-case {
664             uses flowspec-routes;
665         }
666         case flowspec-ipv6-routes-case {
667             uses flowspec-ipv6-routes;
668         }
669         case flowspec-l3vpn-ipv4-routes-case {
670             uses flowspec-l3vpn-ipv4-routes;
671         }
672         case flowspec-l3vpn-ipv6-routes-case {
673             uses flowspec-l3vpn-ipv6-routes;
674         }
675     }
676
677 }