Bug 3198 - Extract BGP messages content into groupings
[bgpcep.git] / bgp / parser-api / src / main / yang / bgp-message.yang
1 module bgp-message {
2     yang-version 1;
3     namespace "urn:opendaylight:params:xml:ns:yang:bgp-message";
4     prefix "bgp-msg";
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 network-concepts { prefix netc; revision-date 2013-11-25; }
9
10     organization "Cisco Systems, Inc.";
11     contact "Dana Kutenicsova <dkutenic@cisco.com>";
12
13     description
14         "This module contains the base data model of a BGP message.
15         It rolls up the definitions contained in RFC4271 and RFC4893.
16
17         Copyright (c)2013 Cisco Systems, Inc. All rights reserved.
18
19         This program and the accompanying materials are made available
20         under the terms of the Eclipse Public License v1.0 which
21         accompanies this distribution, and is available at
22         http://www.eclipse.org/legal/epl-v10.html";
23
24     revision "2013-09-19" {
25         description
26             "Split off basic types";
27     }
28
29     revision "2013-09-18" {
30         description
31             "Initial revision.";
32         reference "RFC4271, RFC4893";
33     }
34
35     typedef protocol-version {
36         type uint8 {
37             range 1..7;
38         }
39     }
40
41     grouping originator-id {
42         leaf originator {
43             type inet:ipv4-address;
44         }
45     }
46
47     grouping cluster-id {
48         leaf-list cluster {
49             type bgp-t:cluster-identifier;
50         }
51     }
52
53     notification open {
54         uses open-message;
55     }
56
57     grouping open-message {
58         description "Open Message";
59         reference "http://tools.ietf.org/html/rfc4271#section-4.2";
60         leaf version {
61             type protocol-version;
62             default 4;
63         }
64         leaf my-as-number {
65             type uint16;
66             default 23456;
67         }
68         leaf hold-timer {
69             type uint16;
70             mandatory true;
71         }
72         leaf bgp-identifier {
73             type inet:ipv4-address;
74             mandatory true;
75         }
76         list bgp-parameters {
77             list optional-capabilities {
78                 reference "http://tools.ietf.org/html/rfc5492#section-4";
79                 container c-parameters {
80                     container as4-bytes-capability {
81                         reference "http://tools.ietf.org/html/rfc6793";
82                         leaf as-number {
83                             type inet:as-number;
84                         }
85                     }
86                 }
87             }
88         }
89     }
90
91     grouping path-attributes {
92         reference "http://tools.ietf.org/html/rfc4271#section-5";
93         container attributes {
94             container origin {
95                 reference "http://tools.ietf.org/html/rfc4271#section-5.1.1";
96                 leaf value {
97                     type bgp-t:bgp-origin;
98                     mandatory true;
99                 }
100             }
101             container as-path {
102                 reference "http://tools.ietf.org/html/rfc4271#section-5.1.2";
103                 list segments {
104                     uses bgp-t:as-path-segment;
105                 }
106             }
107             uses bgp-t:next-hop;
108             container multi-exit-disc {
109                 reference "http://tools.ietf.org/html/rfc4271#section-5.1.4";
110                 leaf med {
111                     type uint32;
112                 }
113             }
114             container local-pref {
115                 reference "http://tools.ietf.org/html/rfc4271#section-5.1.5";
116                 leaf pref {
117                     type uint32;
118                 }
119             }
120             container atomic-aggregate {
121                 reference "http://tools.ietf.org/html/rfc4271#section-5.1.6";
122                 presence "Atomic Aggregate attribute is present.";
123             }
124             container aggregator {
125                 uses bgp-t:bgp-aggregator;
126             }
127             list communities {
128                 uses bgp-t:community;
129             }
130             list extended-communities {
131                 uses bgp-t:extended-community;
132             }
133             container originator-id {
134                 uses originator-id;
135             }
136             container cluster-id {
137                 uses cluster-id;
138             }
139             container aigp {
140                 container aigp-tlv {
141                     leaf metric {
142                         type netc:accumulated-igp-metric;
143                     }
144                 }
145             }
146             list unrecognized-attributes {
147                 key type;
148                 leaf partial {
149                     type boolean;
150                     mandatory true;
151                 }
152                 leaf transitive {
153                     type boolean;
154                     mandatory true;
155                 }
156                 leaf type {
157                     type uint8;
158                     mandatory true;
159                 }
160                 leaf value {
161                     type binary {
162                         length 0..65535;
163                     }
164                     mandatory true;
165                 }
166             }
167         }
168     }
169
170     notification update {
171         uses update-message;
172     }
173
174     grouping update-message {
175         description "Update Message";
176         reference "http://tools.ietf.org/html/rfc4271#section-4.3";
177         uses path-attributes;
178         container withdrawn-routes {
179             leaf-list withdrawn-routes {
180                 type inet:ipv4-prefix;
181             }
182         }
183         container nlri {
184             leaf-list nlri {
185                 type inet:ipv4-prefix;
186             }
187         }
188     }
189
190     notification keepalive {
191         description "Keepalive Message";
192         reference "http://tools.ietf.org/html/rfc4271#section-4.4";
193     }
194
195     notification notify {
196         uses notify-message;
197     }
198
199     grouping notify-message {
200         description "Notification Message";
201         reference "http://tools.ietf.org/html/rfc4271#section-4.5";
202
203         leaf error-code {
204             type uint8;
205             mandatory true;
206         }
207         leaf error-subcode {
208             type uint8;
209             mandatory true;
210         }
211         leaf data {
212             type binary;
213         }
214     }
215 }