BUG-4552: Enhance LS-SR - discern protocols
[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-00.
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-00#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-00#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-00#section-2.3.4.2";
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-00#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-05#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-05#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-00#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-00#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-00#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-05#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 ero-flags {
177         leaf loose {
178             type boolean;
179         }
180     }
181
182     grouping ero-ipv4-address {
183         uses ero-flags;
184         leaf address {
185             type inet:ipv4-address;
186             mandatory true;
187         }
188     }
189
190     grouping ero-ipv6-address {
191         uses ero-flags;
192         leaf address {
193             type inet:ipv6-address;
194             mandatory true;
195         }
196     }
197
198     grouping ero-unnumbered {
199         uses ero-flags;
200         leaf router-id {
201             type uint32;
202         }
203         leaf interface-id {
204             type uint32;
205         }
206     }
207
208     grouping binding-sub-tlvs {
209         reference "https://tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-00#section-2.3.4";
210         choice binding-sub-tlv {
211             case prefix-sid-case {
212                 uses prefix-sid-tlv;
213             }
214             case sid-label-case {
215                 uses sid-label-index;
216             }
217             case ero-metric-case {
218                 leaf ero-metric {
219                     type netc:te-metric;
220                 }
221             }
222             case ipv4-ero-case {
223                 uses ero-ipv4-address;
224             }
225             case ipv6-ero-case {
226                 uses ero-ipv6-address;
227             }
228             case unnumbered-interface-id-ero-case {
229                 uses ero-unnumbered;
230             }
231             case ipv4-ero-backup-case {
232                 uses ero-ipv4-address;
233             }
234             case ipv6-ero-backup-case {
235                 uses ero-ipv6-address;
236             }
237             case unnumbered-interface-id-backup-ero-case {
238                 uses ero-unnumbered;
239             }
240         }
241     }
242
243     grouping isis-binding-flags {
244         reference "https://tools.ietf.org/html/draft-ietf-isis-segment-routing-extensions-05#section-2.4";
245         leaf address-family {
246             type boolean;
247         }
248         leaf mirror-context {
249             type boolean;
250         }
251         leaf spread-tlv {
252             type boolean;
253         }
254         leaf leaked-from-level-2 {
255             type boolean;
256         }
257         leaf attached-flag {
258             type boolean;
259         }
260     }
261
262     grouping ospf-binding-flags {
263         reference "https://tools.ietf.org/html/draft-ietf-ospf-segment-routing-extensions-05#section-6";
264         leaf mirroring {
265             type boolean;
266         }
267     }
268
269     grouping binding-sid-tlv {
270         reference "https://tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-00#section-2.3.3";
271         leaf weight {
272             type weight;
273         }
274         choice flags {
275             case isis-binding-flags-case {
276                 uses isis-binding-flags;
277             }
278             case ospf-binding-flags-case {
279                 uses ospf-binding-flags;
280             }
281         }
282         list binding-sub-tlvs {
283             uses binding-sub-tlvs;
284         }
285     }
286
287     grouping range-sub-tlvs {
288         choice range-sub-tlv {
289             case binding-sid-tlv-case {
290                 uses binding-sid-tlv;
291             }
292             case prefix-sid-tlv-case {
293                 uses prefix-sid-tlv;
294             }
295             case sid-label-tlv-case {
296                 uses sid-label-index;
297             }
298         }
299     }
300
301     grouping range-tlv {
302         reference "https://tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-00#section-2.3.2";
303         leaf inter-area {
304             type boolean;
305         }
306         leaf range-size {
307             type uint16;
308         }
309         list sub-tlvs {
310             uses range-sub-tlvs;
311         }
312     }
313 }