BUG-4831: container should be presence
[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     typedef path-id {
42         type uint32;
43         description
44             "Identifier of a single path. The identifier does not
45              carry any semantic meaning beyond uniquely identifying
46              a path.";
47     }
48
49     grouping originator-id {
50         leaf originator {
51             type inet:ipv4-address;
52         }
53     }
54
55     grouping cluster-id {
56         leaf-list cluster {
57             type bgp-t:cluster-identifier;
58             ordered-by user;
59         }
60     }
61
62     notification open {
63         uses open-message;
64     }
65
66     grouping open-message {
67         description "Open Message";
68         reference "http://tools.ietf.org/html/rfc4271#section-4.2";
69         leaf version {
70             type protocol-version;
71             default 4;
72         }
73         leaf my-as-number {
74             type uint16;
75             default 23456;
76         }
77         leaf hold-timer {
78             type uint16;
79             mandatory true;
80         }
81         leaf bgp-identifier {
82             type inet:ipv4-address;
83             mandatory true;
84         }
85         list bgp-parameters {
86             list optional-capabilities {
87                 reference "http://tools.ietf.org/html/rfc5492#section-4";
88                 container c-parameters {
89                     container as4-bytes-capability {
90                         reference "http://tools.ietf.org/html/rfc6793";
91                         leaf as-number {
92                             type inet:as-number;
93                         }
94                     }
95                     container bgp-extended-message-capability {
96                         reference "https://www.ietf.org/archive/id/draft-ietf-idr-bgp-extended-messages-11.txt";
97                         presence "Indicates peer is able to send/receive 64K messages";
98                     }
99                 }
100             }
101         }
102     }
103
104     grouping path-attributes {
105         reference "http://tools.ietf.org/html/rfc4271#section-5";
106         container attributes {
107             container origin {
108                 reference "http://tools.ietf.org/html/rfc4271#section-5.1.1";
109                 leaf value {
110                     type bgp-t:bgp-origin;
111                     mandatory true;
112                 }
113             }
114             container as-path {
115                 reference "http://tools.ietf.org/html/rfc4271#section-5.1.2";
116                 list segments {
117                     uses bgp-t:as-path-segment;
118                 }
119             }
120             uses bgp-t:next-hop;
121             container multi-exit-disc {
122                 reference "http://tools.ietf.org/html/rfc4271#section-5.1.4";
123                 leaf med {
124                     type uint32;
125                 }
126             }
127             container local-pref {
128                 reference "http://tools.ietf.org/html/rfc4271#section-5.1.5";
129                 leaf pref {
130                     type uint32;
131                 }
132             }
133             container atomic-aggregate {
134                 reference "http://tools.ietf.org/html/rfc4271#section-5.1.6";
135                 presence "Atomic Aggregate attribute is present.";
136             }
137             container aggregator {
138                 uses bgp-t:bgp-aggregator;
139             }
140             list communities {
141                 uses bgp-t:community;
142             }
143             list extended-communities {
144                 uses bgp-t:extended-community;
145             }
146             container originator-id {
147                 uses originator-id;
148             }
149             container cluster-id {
150                 uses cluster-id;
151             }
152             container aigp {
153                 container aigp-tlv {
154                     leaf metric {
155                         type netc:accumulated-igp-metric;
156                     }
157                 }
158             }
159             list unrecognized-attributes {
160                 key type;
161                 leaf partial {
162                     type boolean;
163                     mandatory true;
164                 }
165                 leaf transitive {
166                     type boolean;
167                     mandatory true;
168                 }
169                 leaf type {
170                     type uint8;
171                     mandatory true;
172                 }
173                 leaf value {
174                     type binary {
175                         length 0..65535;
176                     }
177                     mandatory true;
178                 }
179             }
180         }
181     }
182
183     notification update {
184         uses update-message;
185     }
186
187     grouping update-message {
188         description "Update Message";
189         reference "http://tools.ietf.org/html/rfc4271#section-4.3";
190         uses path-attributes;
191         container withdrawn-routes {
192             leaf-list withdrawn-routes {
193                 type inet:ipv4-prefix;
194             }
195         }
196         container nlri {
197             leaf-list nlri {
198                 type inet:ipv4-prefix;
199             }
200         }
201     }
202
203     notification keepalive {
204         description "Keepalive Message";
205         reference "http://tools.ietf.org/html/rfc4271#section-4.4";
206     }
207
208     notification notify {
209         uses notify-message;
210     }
211
212     grouping notify-message {
213         description "Notification Message";
214         reference "http://tools.ietf.org/html/rfc4271#section-4.5";
215
216         leaf error-code {
217             type uint8;
218             mandatory true;
219         }
220         leaf error-subcode {
221             type uint8;
222             mandatory true;
223         }
224         leaf data {
225             type binary;
226         }
227     }
228 }