39e51c1fedf2fc7cb80ded1c743a4922ce20da22
[bgpcep.git] / bgp / concepts / src / main / yang / bgp-types.yang
1 module bgp-types {
2         yang-version 1;
3         namespace "urn:opendaylight:params:xml:ns:yang:bgp-types";
4         prefix "bgp-t";
5
6         import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
7
8         organization "Cisco Systems, Inc.";
9         contact "Dana Kutenicsova <dkutenic@cisco.com>";
10
11         description
12                 "This module contains the base concepts contained in RFC4271 and RFC4760.
13
14                 Copyright (c)2013 Cisco Systems, Inc. All rights reserved.
15
16                 This program and the accompanying materials are made available
17                 under the terms of the Eclipse Public License v1.0 which
18                 accompanies this distribution, and is available at
19                 http://www.eclipse.org/legal/epl-v10.html";
20
21         revision "2013-09-19" {
22                 description
23                         "Initial revision.";
24                 reference "RFC4271, RFC4760";
25         }
26
27         typedef bgp-origin {
28                 reference "http://tools.ietf.org/html/rfc4271#section-5";
29                 description "Values of BGP Origin Path Attribute.";
30                 type enumeration {
31                         enum igp {
32                                 value 0;
33                         }
34                         enum egp {
35                                 value 1;
36                         }
37                         enum incomplete {
38                                 value 2;
39                         }
40                 }
41         }
42
43         identity address-family {
44                 reference "http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml#address-family-numbers-2";
45         }
46
47         identity ipv4-address-family {
48                 base address-family;
49         }
50
51         identity ipv6-address-family {
52                 base address-family;
53         }
54
55         identity subsequent-address-family {
56                 reference "http://tools.ietf.org/html/rfc4760#section-6";
57         }
58
59         identity unicast-subsequent-address-family {
60                 reference "http://tools.ietf.org/html/rfc4760#section-6";
61
62                 base subsequent-address-family;
63         }
64
65         identity mpls-labeled-vpn-subsequent-address-family {
66                 reference "http://tools.ietf.org/html/rfc4760#section-6";
67
68                 base subsequent-address-family;
69         }
70
71         typedef cluster-identifier {
72                 reference "http://tools.ietf.org/html/rfc4456#section-8";
73                 type binary {
74                         length "4";
75                 }
76         }
77
78         typedef short-as-number {
79                 type inet:as-number {
80                         range 0..65535;
81                 }
82         }
83
84         grouping bgp-aggregator {
85                 reference "http://tools.ietf.org/html/rfc4271#section-5.1.7";
86                 description "BGP Path Attribute AGGREGATOR.";
87                 leaf as-number {
88                         // We are acting as a NEW speaker, so only four bytes are allowed
89                         type inet:as-number;
90                 }
91                 leaf network-address {
92                         type inet:ipv4-address;
93                 }
94         }
95
96         grouping community {
97                 reference "https://tools.ietf.org/html/rfc1997";
98                 description "Community Path Attribute";
99                 leaf as-number {
100                         type inet:as-number;
101                 }
102                 leaf semantics {
103                         type uint16;
104                 }
105         }
106
107         grouping extended-community {
108                 leaf comm-type {
109                         type uint8;
110                 }
111                 leaf comm-sub-type {
112                         type uint8;
113                 }
114                 choice extended-community {
115                         case as-specific-extended-community-case {
116                                 container as-specific-extended-community {
117                                         when "../comm-type = 0 and ../comm-sub-type = 0 or ../comm-type = 40 and ../comm-sub-type = 0";
118                                         leaf transitive {
119                                                 type boolean;
120                                         }
121                                         leaf global-administrator {
122                                                 type short-as-number;
123                                         }
124                                         leaf local-administrator {
125                                                 type binary {
126                                                         length "4";
127                                                 }
128                                         }
129                                 }
130                         }
131                         case inet4-specific-extended-community-case {
132                                 container inet4-specific-extended-community {
133                                         when "../comm-type = 1 and ../comm-sub-type = 0 or ../comm-type = 41 and ../comm-sub-type = 0";
134                                         leaf transitive {
135                                                 type boolean;
136                                         }
137                                         leaf global-administrator {
138                                                 type inet:ipv4-address;
139                                         }
140                                         leaf local-administrator {
141                                                 type binary {
142                                                         length "2";
143                                                 }
144                                         }
145                                 }
146                         }
147                         case opaque-extended-community-case {
148                                 container opaque-extended-community {
149                                         when "../comm-type = 3 and ../comm-sub-type = 0 or ../comm-type = 43 and ../comm-sub-type = 0";
150                                         leaf transitive {
151                                                 type boolean;
152                                         }
153                                         leaf value {
154                                                 type binary {
155                                                         length "6";
156                                                 }
157                                         }
158                                 }
159                         }
160                         case route-target-extended-community-case {
161                                 container route-target-extended-community {
162                                         when "../comm-type = 1 and ../comm-sub-type = 2 or ../comm-type = 2 and ../comm-sub-type = 2 or ../comm-type = 3 and ../comm-sub-type = 2";
163                                         leaf global-administrator {
164                                                 type short-as-number;
165                                         }
166                                         leaf local-administrator {
167                                                 type binary {
168                                                         length "4";
169                                                 }
170                                         }
171                                 }
172                         }
173                         case route-origin-extended-community-case {
174                                 container route-origin-extended-community {
175                                         when "../comm-type = 1 and ../comm-sub-type = 3 or ../comm-type = 2 and ../comm-sub-type = 3 or ../comm-type = 3 and ../comm-sub-type = 3";
176                                         leaf global-administrator {
177                                                 type short-as-number;
178                                         }
179                                         leaf local-administrator {
180                                                 type binary {
181                                                         length "4";
182                                                 }
183                                         }
184                                 }
185                         }
186                 }
187         }
188
189         grouping next-hop {
190                 choice c-next-hop {
191                         case ipv4-next-hop-case {
192                                 container ipv4-next-hop {
193                                         reference "http://tools.ietf.org/html/rfc4271#section-5.1.3";
194                                         leaf global {
195                                                 type inet:ipv4-address;
196                                         }
197                                 }
198                         }
199                         case ipv6-next-hop-case {
200                                 container ipv6-next-hop {
201                                         reference "http://tools.ietf.org/html/rfc4760#section-3";
202                                         leaf global {
203                                                 type inet:ipv6-address;
204                                         }
205                                         leaf link-local {
206                                                 type inet:ipv6-address;
207                                         }
208                                 }
209                         }
210                 }
211         }
212
213         grouping as-path-segment {
214                 reference "http://tools.ietf.org/html/rfc4271#section-5.1.2";
215                 choice c-segment {
216                         case a-set-case {
217                                 container a-set {
218                                         leaf-list as-set {
219                                                 type inet:as-number;
220                                         }
221                                 }
222                         }
223                         case a-list-case {
224                                 container a-list {
225                                         list as-sequence {
226                                                 leaf as {
227                                                         type inet:as-number;
228                                                 }
229                                         }
230                                 }
231                         }
232                 }
233         }
234 }