Code clean up
[bgpcep.git] / bgp / mvpn / src / main / yang / bgp-mvpn.yang
1 module bgp-mvpn {
2     yang-version 1;
3     namespace "urn:opendaylight:params:xml:ns:yang:bgp:mvpn";
4     prefix "bgp-mvpn";
5
6     import bgp-types { prefix bgp-t; revision-date 2018-03-29; }
7     import ietf-inet-types { prefix inet; revision-date 2013-07-15; }
8     import pmsi-tunnel { prefix pmsi; revision-date 2018-03-29; }
9     import bgp-rib { prefix bgp-rib; revision-date 2018-03-29; }
10     import yang-ext { prefix ext; revision-date "2013-07-09"; }
11     import network-concepts { prefix netc; revision-date 2013-11-25; }
12
13     organization "AT&T Services, Inc.";
14
15     contact "Claudio D. Gasparini <claudio.gasparini@pantheon.tech>";
16
17     description
18         "This module contains the base data model of a BGP message.
19         It rolls up the definitions contained in RFC6513, RFC6514, RFC6515.
20
21         Copyright (c) 2018 AT&T Intellectual Property. 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 2018-04-17 {
29         description "Initial version";
30     }
31
32     identity mcast-vpn-subsequent-address-family {
33         description "SAFI 5 MCAST-VPN";
34         reference "https://www.iana.org/assignments/safi-namespace/safi-namespace.xhtml";
35
36         base bgp-t:subsequent-address-family;
37     }
38
39     typedef nlri-type {
40         reference "https://tools.ietf.org/html/rfc6514#section-4";
41         type enumeration {
42             enum intra-as-i-pmsi-a-d {
43                 value 1;
44             }
45             enum inter-as-i-pmsi-a-d {
46                 value 2;
47             }
48             enum s-pmsi-a-d {
49                 value 3;
50             }
51             enum leaf-a-d {
52                 value 4;
53             }
54             enum source-active-a-d {
55                 value 5;
56             }
57             enum shared-tree-join {
58                 value 6;
59             }
60             enum source-tree-join {
61                 value 7;
62             }
63         }
64     }
65
66     grouping source-as-grouping {
67         leaf source-as {
68             type inet:as-number;
69             mandatory true;
70         }
71     }
72
73     grouping multicast-source-rd-grouping {
74         uses bgp-t:route-distinguisher-grouping;
75
76         leaf multicast-source {
77             type inet:ip-address;
78             mandatory true;
79         }
80     }
81
82     grouping multicast-group-opaque-grouping {
83         choice multicast-group {
84             case c-g-address-case {
85                 leaf c-g-address {
86                     type inet:ip-address;
87                 }
88             }
89
90             case ldp-mp-opaque-value-case {
91                 container ldp-mp-opaque-value {
92                     uses pmsi:opaque;
93                 }
94             }
95         }
96     }
97
98     grouping intra-as-i-pmsi-a-d-grouping {
99         container intra-as-i-pmsi-a-d {
100
101             description "https://tools.ietf.org/html/rfc6514#section-4.1";
102
103             uses bgp-t:route-distinguisher-grouping;
104             uses bgp-t:orig-route-ip-grouping;
105         }
106     }
107
108     grouping inter-as-i-pmsi-a-d-grouping {
109         container inter-as-i-pmsi-a-d {
110             description "https://tools.ietf.org/html/rfc6514#section-4.2";
111
112             uses bgp-t:route-distinguisher-grouping;
113             uses source-as-grouping;
114         }
115     }
116
117     grouping s-pmsi-a-d-grouping {
118         container s-pmsi-a-d {
119             description "https://tools.ietf.org/html/rfc6514#section-4.3";
120
121             uses multicast-source-rd-grouping;
122             uses multicast-group-opaque-grouping;
123             uses bgp-t:orig-route-ip-grouping;
124         }
125     }
126
127     grouping leaf-a-d-grouping {
128         container leaf-a-d {
129             description "https://tools.ietf.org/html/rfc6514#section-4.4";
130
131             choice leaf-a-d-route-key {
132                 case inter-as-i-pmsi-a-d-case {
133                     uses inter-as-i-pmsi-a-d-grouping;
134                 }
135                 case s-pmsi-a-d-case {
136                     uses s-pmsi-a-d-grouping;
137                 }
138                 mandatory true;
139             }
140             uses bgp-t:orig-route-ip-grouping;
141         }
142     }
143
144     grouping source-active-a-d-grouping {
145         container source-active-a-d {
146             description "https://tools.ietf.org/html/rfc6514#section-4.5";
147
148             uses multicast-source-rd-grouping;
149             leaf multicast-group {
150                 type inet:ip-address;
151                 mandatory true;
152             }
153         }
154     }
155
156     grouping c-multicast-grouping {
157         container c-multicast {
158             description "https://tools.ietf.org/html/rfc6514#section-4.6";
159
160             uses multicast-source-rd-grouping;
161             uses source-as-grouping;
162             uses multicast-group-opaque-grouping;
163         }
164     }
165
166     grouping mvpn {
167         reference "https://tools.ietf.org/html/rfc6514#section-4";
168         description "The MCAST-VPN NLRI is carried in BGP [RFC4271] using BGP
169             Multiprotocol Extensions [RFC4760] with an Address Family Identifier
170             (AFI) of 1 or 2 and a Subsequent AFI (SAFI) of MCAST-VPN.";
171
172         choice mvpn-choice {
173             case intra-as-i-pmsi-a-d-case {
174                 uses intra-as-i-pmsi-a-d-grouping;
175             }
176             case inter-as-i-pmsi-a-d-case {
177                 uses inter-as-i-pmsi-a-d-grouping;
178             }
179             case s-pmsi-a-d-case {
180                 uses s-pmsi-a-d-grouping;
181             }
182             case leaf-a-d-case {
183                 uses leaf-a-d-grouping;
184             }
185             case source-active-a-d-case {
186                 uses source-active-a-d-grouping;
187             }
188             case shared-tree-join-case {
189                 container shared-tree-join {
190                     uses c-multicast-grouping;
191                 }
192             }
193             case source-tree-join-case {
194                 container source-tree-join {
195                     uses c-multicast-grouping;
196                 }
197             }
198             mandatory true;
199         }
200     }
201
202     grouping pe-distinguisher-labels-attribute {
203         container pe-distinguisher-labels-attribute {
204             list pe-distinguisher-label-attribute {
205                 leaf pe-address  {
206                     type inet:ip-address;
207                     mandatory true;
208                 }
209                 leaf mpls-label {
210                     type netc:mpls-label;
211                     mandatory true;
212                 }
213             }
214         }
215     }
216
217     grouping bgp-rib-route {
218         uses pmsi:bgp-rib-route {
219             augment "attributes" {
220                 ext:augment-identifier pe-distinguisher-labels-attribute-augmentation;
221                 uses pe-distinguisher-labels-attribute;
222             }
223         }
224     }
225
226     grouping mvpn-bgp-rib-route {
227         uses mvpn;
228         uses bgp-rib-route;
229     }
230
231     grouping mvpn-routes {
232         list mvpn-route {
233             key "route-key path-id";
234             uses mvpn-bgp-rib-route;
235         }
236     }
237 }