BUG-608 : added prefix-sid tlv
[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";
4     prefix "bgp-sr";
5
6     import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
7     import bgp-types { prefix bgp-t; revision-date 2013-09-19; }
8     import rsvp { prefix rsvp; revision-date 2013-08-20; }
9     import network-concepts { prefix netc; revision-date 2013-11-25; }
10
11     organization "Cisco Systems, Inc.";
12     contact "Dana Kutenicsova <dkutenic@cisco.com>";
13
14     description
15         "This module contains the base data concepts contained
16         in draft-ietf-isis-segment-routing-extensions.
17
18         Copyright (c)2015 Cisco Systems, Inc. All rights reserved.
19
20         This program and the accompanying materials are made available
21         under the terms of the Eclipse Public License v1.0 which
22         accompanies this distribution, and is available at
23         http://www.eclipse.org/legal/epl-v10.html";
24
25     revision "2015-02-06" {
26         description
27             "Initial revision.";
28     }
29
30     typedef algorithm {
31         reference "https://tools.ietf.org/html/draft-ietf-isis-segment-routing-extensions-02#section-2.1";
32         type enumeration {
33             enum shortest-path-first {
34                 value 0;
35             }
36         }
37     }
38
39     typedef adjacency-flags {
40         reference "https://tools.ietf.org/html/draft-ietf-isis-segment-routing-extensions-02#section-2.2.1";
41         type bits {
42             bit address-family {
43                 position 0;
44             }
45             bit backup {
46                 position 1;
47             }
48             bit value {
49                 position 2;
50             }
51             bit local {
52                 position 3;
53             }
54             bit set-flag {
55                 position 4;
56             }
57         }
58     }
59
60     typedef sid-label {
61         reference "https://tools.ietf.org/html/draft-ietf-isis-segment-routing-extensions-02#section-2.3";
62         type uint64;
63     }
64
65     typedef weight {
66         reference "https://tools.ietf.org/html/draft-ietf-isis-segment-routing-extensions-02#section-2.4.2";
67         type uint8;
68     }
69
70     grouping ero-ip-address {
71         leaf loose {
72             type boolean;
73             mandatory true;
74         }
75         leaf address {
76             type inet:ip-address;
77             mandatory true;
78         }
79     }
80
81     grouping ero-unnumbered {
82         leaf loose {
83             type boolean;
84             mandatory true;
85         }
86         leaf router-id {
87             type binary {
88                 length 20;
89             }
90             mandatory true;
91         }
92         leaf interface-id {
93             type uint32;
94             mandatory true;
95         }
96     }
97
98     grouping sid-sub-tlvs {
99         description "SubTlvs for SID Label Tlv";
100         reference "https://tools.ietf.org/html/draft-ietf-isis-segment-routing-extensions-02#section-2.4";
101
102         choice subtlv-type {
103             case sid-label-case {
104                 leaf sid {
105                     type sid-label;
106                 }
107             }
108             case ero-metric-case {
109                 leaf ero-metric {
110                     type netc:te-metric;
111                 }
112             }
113             case ip4-ero-case {
114                 uses ero-ip-address;
115             }
116             case ipv6-ero-case {
117                 uses ero-ip-address;
118             }
119             case unnumbered-ero-case {
120                 uses ero-unnumbered;
121             }
122             case ip4-ero-backup-case {
123                 uses ero-ip-address;
124             }
125             case ipv6-ero-backup-case {
126                 uses ero-ip-address;
127             }
128             case unnumbered-ero-backup-case {
129                 uses ero-unnumbered;
130             }
131         }
132     }
133
134     grouping sid-label-binding {
135         reference "https://tools.ietf.org/html/draft-ietf-isis-segment-routing-extensions-02#section-2.4";
136         leaf sid-label-flags {
137             type bits {
138                 bit address-family {
139                     position 0;
140                 }
141                 bit mirror-context {
142                     position 1;
143                 }
144             }
145         }
146         leaf weight {
147             type weight;
148         }
149         leaf value-range {
150             type uint16;
151         }
152         leaf fec-prefix {
153             type inet:ip-prefix;
154         }
155         list sub-tlvs {
156             uses sid-sub-tlvs;
157             ordered-by user;
158         }
159     }
160
161     grouping adjacency-segment-identifier {
162         reference "https://tools.ietf.org/html/draft-ietf-isis-segment-routing-extensions-02#section-2.2.1";
163         leaf adj-flags {
164             type adjacency-flags;
165         }
166         leaf adj-weight {
167             type weight;
168         }
169         leaf adj-sid {
170             type sid-label;
171         }
172     }
173
174     grouping lan-adjacency-segment-identifier {
175         reference "https://tools.ietf.org/html/draft-ietf-isis-segment-routing-extensions-02#section-2.2.2";
176         leaf lan-flags {
177             type adjacency-flags;
178         }
179         leaf lan-weight {
180             type weight;
181         }
182         leaf lan-iso-system-id {
183             type netc:iso-system-identifier;
184         }
185         leaf lan-sid {
186             type sid-label;
187         }
188     }
189
190     grouping sr-capabilities {
191         reference "https://tools.ietf.org/html/draft-ietf-isis-segment-routing-extensions-02#section-3.1";
192         leaf cap-flags {
193             type bits {
194                 bit ipv4 {
195                     position 0;
196                 }
197                 bit ipv6 {
198                     position 1;
199                 }
200             }
201         }
202         leaf cap-value-range {
203             type uint32 {
204                 range "0..16777215";
205             }
206         }
207         leaf sid {
208             type sid-label;
209         }
210     }
211
212     grouping sr-algorithm {
213         reference "https://tools.ietf.org/html/draft-ietf-isis-segment-routing-extensions-02#section-3.2";
214         leaf-list algorithm {
215             type algorithm;
216         }
217     }
218
219     grouping prefix-sid {
220         reference "https://tools.ietf.org/html/draft-ietf-isis-segment-routing-extensions-02#section-2.1";
221         leaf prefix-sid-flags {
222             type bits {
223                 bit readvertisement {
224                     position 0;
225                 }
226                 bit node-sid {
227                     position 1;
228                 }
229                 bit no-php {
230                     position 2;
231                 }
232                 bit explicit-null {
233                     position 3;
234                 }
235                 bit value {
236                     position 4;
237                 }
238                 bit local {
239                     position 5;
240                 }
241             }
242         }
243         leaf algorithm {
244             type algorithm;
245         }
246         leaf sid {
247             type sid-label;
248         }
249     }
250 }