Code clean up
[bgpcep.git] / bgp / extensions / inet / src / main / yang / bgp-inet.yang
1 module bgp-inet {
2     yang-version 1;
3     namespace "urn:opendaylight:params:xml:ns:yang:bgp-inet";
4     prefix "bgp-inet";
5
6     import bgp-rib { prefix bgp-rib; revision-date 2018-03-29; }
7     import bgp-multiprotocol { prefix bgp-mp; revision-date 2018-03-29; }
8     import ietf-inet-types { prefix inet; revision-date 2013-07-15; }
9     import bgp-message { prefix bgp-msg; revision-date 2018-03-29; }
10     import bmp-monitor { prefix bmp-mon; revision-date 2018-03-29; }
11
12     organization "Cisco Systems, Inc.";
13     contact "Dana Kutenicsova <dkutenic@cisco.com>";
14
15     description
16         "This module contains the concept of IPv4 and IPv6 routes,
17         split from bgp-rib and bgp-multiprotocol models.
18
19         Copyright (c)2015 Cisco Systems, Inc. All rights reserved.
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 "2018-03-29" {
26         description "Add support for add-path for all afi/safi.";
27     }
28
29     revision "2017-12-07" {
30         description "Add support for add-path in base BGP NLRI.";
31     }
32
33     revision "2015-03-05" {
34             description
35                     "Initial revision.";
36     }
37
38     grouping ipv6-prefix {
39         leaf prefix {
40             type inet:ipv6-prefix;
41         }
42     }
43
44     grouping ipv4-prefixes {
45         container destination-ipv4 {
46             list ipv4-prefixes {
47                 uses bgp-msg:ipv4-prefix-and-path-id;
48             }
49         }
50     }
51
52     grouping ipv6-prefixes {
53         container destination-ipv6 {
54             list ipv6-prefixes {
55                 uses ipv6-prefix;
56                 uses bgp-msg:path-id-grouping;
57             }
58         }
59     }
60
61     grouping ipv4-routes {
62         container ipv4-routes {
63             list ipv4-route {
64                 key "route-key path-id";
65                 uses bgp-rib:route;
66                 leaf prefix {
67                     type inet:ipv4-prefix;
68                 }
69             }
70         }
71     }
72
73     grouping ipv6-bgp-prefix-sid-tlv {
74         reference "https://tools.ietf.org/html/draft-ietf-idr-bgp-prefix-sid-02#section-4.2";
75         leaf process-ipv6-head-ability {
76             description "S flag position 0. If set then it means that the BGP speaker is capable of processing the
77                 IPv6 Segment Routing Header.";
78             type boolean;
79             default "true";
80         }
81     }
82
83     grouping ipv6-routes {
84         container ipv6-routes {
85             list ipv6-route {
86                 key "route-key path-id";
87                 uses ipv6-prefix;
88
89                 uses bgp-rib:route {
90                     augment "attributes/bgp-prefix-sid/bgp-prefix-sid-tlvs/bgp-prefix-sid-tlv" {
91                         case ipv6-sid-tlv {
92                             uses ipv6-bgp-prefix-sid-tlv;
93                         }
94                     }
95                 }
96             }
97         }
98     }
99
100     augment "/bgp-msg:update/bgp-msg:attributes/bgp-mp:mp-reach-nlri/bgp-mp:advertized-routes/bgp-mp:destination-type" {
101         case destination-ipv4-case {
102             when "../../afi = ipv4";
103             uses ipv4-prefixes;
104         }
105         case destination-ipv6-case {
106             when "../../afi = ipv6";
107             uses ipv6-prefixes;
108         }
109     }
110
111     augment "/bgp-msg:update/bgp-msg:attributes/bgp-mp:mp-unreach-nlri/bgp-mp:withdrawn-routes/bgp-mp:destination-type" {
112         case destination-ipv4-case {
113             when "../../afi = ipv4";
114             uses ipv4-prefixes;
115         }
116         case destination-ipv6-case {
117             when "../../afi = ipv6";
118             uses ipv6-prefixes;
119         }
120     }
121
122     augment "/bgp-rib:application-rib/bgp-rib:tables/bgp-rib:routes" {
123         case ipv4-routes-case {
124             uses ipv4-routes;
125         }
126
127         case ipv6-routes-case {
128             uses ipv6-routes;
129         }
130     }
131
132     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:loc-rib/bgp-rib:tables/bgp-rib:routes" {
133         case ipv4-routes-case {
134             uses ipv4-routes;
135         }
136
137         case ipv6-routes-case {
138             uses ipv6-routes;
139         }
140     }
141
142     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:peer/bgp-rib:adj-rib-in/bgp-rib:tables/bgp-rib:routes" {
143         case ipv4-routes-case {
144             uses ipv4-routes;
145         }
146
147         case ipv6-routes-case {
148             uses ipv6-routes;
149         }
150     }
151
152     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:peer/bgp-rib:effective-rib-in/bgp-rib:tables/bgp-rib:routes" {
153         case ipv4-routes-case {
154             uses ipv4-routes;
155         }
156
157         case ipv6-routes-case {
158             uses ipv6-routes;
159         }
160     }
161
162     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:peer/bgp-rib:adj-rib-out/bgp-rib:tables/bgp-rib:routes" {
163         case ipv4-routes-case {
164             uses ipv4-routes;
165         }
166
167         case ipv6-routes-case {
168             uses ipv6-routes;
169         }
170     }
171
172     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" {
173         case ipv4-routes-case {
174             uses ipv4-routes;
175         }
176
177         case ipv6-routes-case {
178             uses ipv6-routes;
179         }
180     }
181
182     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" {
183         case ipv4-routes-case {
184             uses ipv4-routes;
185         }
186
187         case ipv6-routes-case {
188             uses ipv6-routes;
189         }
190     }
191
192     augment "/bgp-msg:update/bgp-msg:attributes/bgp-msg:bgp-prefix-sid/bgp-msg:bgp-prefix-sid-tlvs/bgp-msg:bgp-prefix-sid-tlv" {
193         case ipv6-sid-tlv {
194             uses ipv6-bgp-prefix-sid-tlv;
195         }
196     }
197 }
198