BUG-2823: Simplify AS_PATH encoding
[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 inet:ipv4-address;
74     }
75
76     typedef short-as-number {
77         type inet:as-number {
78             range 0..65535;
79         }
80     }
81
82     grouping bgp-aggregator {
83         reference "http://tools.ietf.org/html/rfc4271#section-5.1.7";
84         description "BGP Path Attribute AGGREGATOR.";
85         leaf as-number {
86             // We are acting as a NEW speaker, so only four bytes are allowed
87             type inet:as-number;
88         }
89         leaf network-address {
90             type inet:ipv4-address;
91         }
92     }
93
94     grouping community {
95         reference "https://tools.ietf.org/html/rfc1997";
96         description "Community Path Attribute";
97         leaf as-number {
98             type inet:as-number;
99         }
100         leaf semantics {
101             type uint16;
102         }
103     }
104
105     grouping extended-community {
106         leaf comm-type {
107             type uint8;
108         }
109         leaf comm-sub-type {
110             type uint8;
111         }
112         choice extended-community {
113             case as-specific-extended-community-case {
114                 container as-specific-extended-community {
115                     when "../comm-type = 0 and ../comm-sub-type = 0 or ../comm-type = 40 and ../comm-sub-type = 0";
116                     leaf transitive {
117                         type boolean;
118                     }
119                     leaf global-administrator {
120                         type short-as-number;
121                     }
122                     leaf local-administrator {
123                         type binary {
124                             length "4";
125                         }
126                     }
127                 }
128             }
129             case inet4-specific-extended-community-case {
130                 container inet4-specific-extended-community {
131                     when "../comm-type = 1 and ../comm-sub-type = 0 or ../comm-type = 41 and ../comm-sub-type = 0";
132                     leaf transitive {
133                         type boolean;
134                     }
135                     leaf global-administrator {
136                         type inet:ipv4-address;
137                     }
138                     leaf local-administrator {
139                         type binary {
140                             length "2";
141                         }
142                     }
143                 }
144             }
145             case opaque-extended-community-case {
146                 container opaque-extended-community {
147                     when "../comm-type = 3 and ../comm-sub-type = 0 or ../comm-type = 43 and ../comm-sub-type = 0";
148                     leaf transitive {
149                         type boolean;
150                     }
151                     leaf value {
152                         type binary {
153                             length "6";
154                         }
155                     }
156                 }
157             }
158             case route-target-extended-community-case {
159                 container route-target-extended-community {
160                     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";
161                     leaf global-administrator {
162                         type short-as-number;
163                     }
164                     leaf local-administrator {
165                         type binary {
166                             length "4";
167                         }
168                     }
169                 }
170             }
171             case route-origin-extended-community-case {
172                 container route-origin-extended-community {
173                     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";
174                     leaf global-administrator {
175                         type short-as-number;
176                     }
177                     leaf local-administrator {
178                         type binary {
179                             length "4";
180                         }
181                     }
182                 }
183             }
184         }
185     }
186
187     grouping next-hop {
188         choice c-next-hop {
189             case ipv4-next-hop-case {
190                 container ipv4-next-hop {
191                     reference "http://tools.ietf.org/html/rfc4271#section-5.1.3";
192                     leaf global {
193                         type inet:ipv4-address;
194                     }
195                 }
196             }
197             case ipv6-next-hop-case {
198                 container ipv6-next-hop {
199                     reference "http://tools.ietf.org/html/rfc4760#section-3";
200                     leaf global {
201                         type inet:ipv6-address;
202                     }
203                     leaf link-local {
204                         type inet:ipv6-address;
205                     }
206                 }
207             }
208         }
209     }
210
211     grouping as-path-segment {
212         reference "http://tools.ietf.org/html/rfc4271#section-5.1.2";
213         choice c-segment {
214         description "This model is obsolete and please use just leaf-lists as-sequence and as-set nested directly under as-path-segment.";
215             status obsolete;
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         leaf-list as-sequence {
234             type inet:as-number;
235             ordered-by user;
236             max-elements "255";
237         }
238         leaf-list as-set {
239             type inet:as-number;
240         }
241     }
242 }