BUG-5024: Update BGP LS to conform RFC 7752
[bgpcep.git] / bgp / linkstate / src / main / yang / bgp-segment-routing.yang
1 module bgp-segment-routing {
2     yang-version 1;
3     namespace "urn:opendaylight:params:xml:ns:yang:bgp-segment-routing-ext";
4     prefix "bgp-sr";
5
6     import network-concepts { prefix netc; revision-date 2013-11-25; }
7     import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
8
9     organization "Cisco Systems, Inc.";
10     contact "Iveta Halanova <ihalanov@cisco.com>";
11
12     description
13         "This module contains the base data concepts contained
14         in draft-gredler-idr-bgp-ls-segment-routing-ext-02.
15
16         Copyright (c)2015 Cisco Systems, Inc. All rights reserved.
17
18         This program and the accompanying materials are made available
19         under the terms of the Eclipse Public License v1.0 which
20         accompanies this distribution, and is available at
21         http://www.eclipse.org/legal/epl-v10.html";
22
23     revision "2015-10-14" {
24         description
25             "Initial revision.";
26     }
27
28     typedef algorithm {
29         reference "https://tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-02#section-2.1.2";
30         type enumeration {
31             enum shortest-path-first {
32                 value 0;
33             }
34             enum strict-shortest-path-first {
35                 value 1;
36             }
37         }
38     }
39
40     typedef weight {
41         reference "https://tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-02#section-2.2";
42         type uint8;
43     }
44
45     grouping sid-label-index {
46         reference "https://tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-02#section-2.3.4";
47         choice sid-label-index {
48             case local-label-case {
49                 leaf local-label {
50                     type netc:mpls-label;
51                 }
52             }
53             case ipv6-address-case {
54                 leaf ipv6-address {
55                     type inet:ipv6-address;
56                 }
57             }
58             case sid-case {
59                 leaf sid {
60                     type uint32;
61                 }
62             }
63         }
64     }
65
66     grouping sr-capabilities-tlv {
67         reference "https://tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-02#section-2.1.1";
68         leaf mpls-ipv4 {
69             type boolean;
70         }
71         leaf mpls-ipv6 {
72             type boolean;
73         }
74         leaf sr-ipv6 {
75             type boolean;
76         }
77         leaf range-size {
78             type uint32 {
79                 range "0..16777215";
80             }
81         }
82         uses sid-label-index;
83     }
84
85     grouping sr-algorithms-tlv {
86         leaf-list algorithms {
87             type algorithm;
88         }
89     }
90
91     grouping ospf-adj-flags {
92         reference "https://tools.ietf.org/html/draft-ietf-ospf-segment-routing-extensions-08#section-7.1";
93         leaf backup {
94             type boolean;
95         }
96         leaf set {
97             type boolean;
98         }
99     }
100
101     grouping adj-flags {
102         choice flags {
103             case ospf-adj-flags-case {
104                 uses ospf-adj-flags;
105             }
106             case isis-adj-flags-case {
107                 reference "https://tools.ietf.org/html/draft-ietf-isis-segment-routing-extensions-06#section-2.2.1";
108                 uses ospf-adj-flags;
109                 leaf address-family {
110                     type boolean;
111                 }
112             }
113         }
114     }
115
116     grouping adj-sid-tlv {
117         reference "https://tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-02#section-2.2.1";
118         uses adj-flags;
119         leaf weight {
120             type weight;
121         }
122         uses sid-label-index;
123     }
124
125     grouping lan-adj-sid-tlv {
126         reference "https://tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-02#section-2.2.2";
127         uses adj-flags;
128         leaf weight {
129             type weight;
130         }
131         leaf iso-system-id {
132             type netc:iso-system-identifier;
133         }
134         leaf neighbor-id {
135             type inet:ipv4-address;
136         }
137         uses sid-label-index;
138     }
139
140     grouping prefix-flags {
141         leaf no-php {
142             type boolean;
143         }
144         leaf explicit-null {
145             type boolean;
146         }
147     }
148
149     grouping prefix-sid-tlv {
150         reference "https://tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-02#section-2.3.1";
151         choice flags {
152             case isis-prefix-flags-case {
153                 reference "https://tools.ietf.org/html/draft-ietf-ospf-segment-routing-extensions-08#section-5";
154                 uses prefix-flags;
155                 leaf readvertisement {
156                     type boolean;
157                 }
158                 leaf node-sid {
159                     type boolean;
160                 }
161             }
162             case ospf-prefix-flags-case {
163                 reference "https://tools.ietf.org/html/draft-ietf-ospf-segment-routing-extensions-05#section-5";
164                 uses prefix-flags;
165                 leaf mapping-server {
166                     type boolean;
167                 }
168             }
169         }
170         leaf algorithm {
171             type algorithm;
172         }
173         uses sid-label-index;
174     }
175
176     grouping ipv6-prefix-sid-tlv {
177         reference "https://tools.ietf.org/html/draft-previdi-isis-ipv6-prefix-sid-02#page-2";
178         leaf algorithm {
179             type algorithm;
180         }
181     }
182
183     grouping ero-flags {
184         leaf loose {
185             type boolean;
186         }
187     }
188
189     grouping ero-ipv4-address {
190         uses ero-flags;
191         leaf address {
192             type inet:ipv4-address;
193             mandatory true;
194         }
195     }
196
197     grouping ero-ipv6-address {
198         uses ero-flags;
199         leaf address {
200             type inet:ipv6-address;
201             mandatory true;
202         }
203     }
204
205     grouping ero-unnumbered {
206         uses ero-flags;
207         leaf router-id {
208             type uint32;
209         }
210         leaf interface-id {
211             type uint32;
212         }
213     }
214
215     grouping binding-sub-tlvs {
216         reference "https://tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-02#section-2.3.4";
217         choice binding-sub-tlv {
218             case prefix-sid-case {
219                 uses prefix-sid-tlv;
220             }
221             case ipv6-prefix-sid-case {
222                 uses ipv6-prefix-sid-tlv;
223             }
224             case sid-label-case {
225                 uses sid-label-index;
226             }
227             case ero-metric-case {
228                 leaf ero-metric {
229                     type netc:te-metric;
230                 }
231             }
232             case ipv4-ero-case {
233                 uses ero-ipv4-address;
234             }
235             case ipv6-ero-case {
236                 uses ero-ipv6-address;
237             }
238             case unnumbered-interface-id-ero-case {
239                 uses ero-unnumbered;
240             }
241             case ipv4-ero-backup-case {
242                 uses ero-ipv4-address;
243             }
244             case ipv6-ero-backup-case {
245                 uses ero-ipv6-address;
246             }
247             case unnumbered-interface-id-backup-ero-case {
248                 uses ero-unnumbered;
249             }
250         }
251     }
252
253     grouping isis-binding-flags {
254         reference "https://tools.ietf.org/html/draft-ietf-isis-segment-routing-extensions-06#section-2.4";
255         leaf address-family {
256             type boolean;
257         }
258         leaf mirror-context {
259             type boolean;
260         }
261         leaf spread-tlv {
262             type boolean;
263         }
264         leaf leaked-from-level-2 {
265             type boolean;
266         }
267         leaf attached-flag {
268             type boolean;
269         }
270     }
271
272     grouping ospf-binding-flags {
273         reference "https://tools.ietf.org/html/draft-ietf-ospf-segment-routing-extensions-08#section-6";
274         leaf mirroring {
275             type boolean;
276         }
277     }
278
279     grouping binding-sid-tlv {
280         reference "https://tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-02#section-2.3.3";
281         leaf weight {
282             type weight;
283         }
284         choice flags {
285             case isis-binding-flags-case {
286                 uses isis-binding-flags;
287             }
288             case ospf-binding-flags-case {
289                 uses ospf-binding-flags;
290             }
291         }
292         list binding-sub-tlvs {
293             uses binding-sub-tlvs;
294         }
295     }
296
297     grouping range-sub-tlvs {
298         choice range-sub-tlv {
299             case binding-sid-tlv-case {
300                 uses binding-sid-tlv;
301             }
302             case prefix-sid-tlv-case {
303                 uses prefix-sid-tlv;
304             }
305             case ipv6-prefix-sid-tlv-case {
306                 uses ipv6-prefix-sid-tlv;
307             }
308             case sid-label-tlv-case {
309                 uses sid-label-index;
310             }
311         }
312     }
313
314     grouping range-tlv {
315         reference "https://tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-02#section-2.3.2";
316         leaf inter-area {
317             type boolean;
318         }
319         leaf range-size {
320             type uint16;
321         }
322         list sub-tlvs {
323             uses range-sub-tlvs;
324         }
325     }
326 }