Bug 2227 - API for RFC7311
[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         description "Open Message";
55         reference "http://tools.ietf.org/html/rfc4271#section-4.2";
56         leaf version {
57             type protocol-version;
58             default 4;
59         }
60         leaf my-as-number {
61             type uint16;
62             default 23456;
63         }
64         leaf hold-timer {
65             type uint16;
66             mandatory true;
67         }
68         leaf bgp-identifier {
69             type inet:ipv4-address;
70             mandatory true;
71         }
72         list bgp-parameters {
73             list optional-capabilities {
74                 reference "http://tools.ietf.org/html/rfc5492#section-4";
75                 choice c-parameters {
76                     case as4-bytes-case {
77                         container as4-bytes-capability {
78                             reference "http://tools.ietf.org/html/rfc6793";
79                             leaf as-number {
80                                 type inet:as-number;
81                             }
82                         }
83                     }
84                 }
85             }
86         }
87     }
88
89     grouping path-attributes {
90         reference "http://tools.ietf.org/html/rfc4271#section-5";
91         container origin {
92             reference "http://tools.ietf.org/html/rfc4271#section-5.1.1";
93             leaf value {
94                 type bgp-t:bgp-origin;
95                 mandatory true;
96             }
97         }
98         container as-path {
99             reference "http://tools.ietf.org/html/rfc4271#section-5.1.2";
100             list segments {
101                 uses bgp-t:as-path-segment;
102             }
103         }
104         uses bgp-t:next-hop;
105         container multi-exit-disc {
106             reference "http://tools.ietf.org/html/rfc4271#section-5.1.4";
107             leaf med {
108                 type uint32;
109             }
110         }
111         container local-pref {
112             reference "http://tools.ietf.org/html/rfc4271#section-5.1.5";
113             leaf pref {
114                 type uint32;
115             }
116         }
117         container atomic-aggregate {
118             reference "http://tools.ietf.org/html/rfc4271#section-5.1.6";
119             presence "Atomic Aggregate attribute is present.";
120         }
121         container aggregator {
122             uses bgp-t:bgp-aggregator;
123         }
124         list communities {
125             uses bgp-t:community;
126         }
127         list extended-communities {
128             uses bgp-t:extended-community;
129         }
130         container originator-id {
131             uses originator-id;
132         }
133         container cluster-id {
134             uses cluster-id;
135         }
136         container aigp {
137             container aigp-tlv {
138                 leaf metric {
139                     type netc:accumulated-igp-metric;
140                 }
141             }
142         }
143     }
144
145     notification update {
146         description "Update Message";
147         reference "http://tools.ietf.org/html/rfc4271#section-4.3";
148         container path-attributes {
149             reference "http://tools.ietf.org/html/rfc4271#section-5";
150             uses path-attributes;
151         }
152         container withdrawn-routes {
153             leaf-list withdrawn-routes {
154                 type inet:ipv4-prefix;
155             }
156         }
157         container nlri {
158             leaf-list nlri {
159                 type inet:ipv4-prefix;
160             }
161         }
162     }
163
164     notification keepalive {
165         description "Keepalive Message";
166         reference "http://tools.ietf.org/html/rfc4271#section-4.4";
167     }
168
169     notification notify {
170         description "Notification Message";
171         reference "http://tools.ietf.org/html/rfc4271#section-4.5";
172
173         leaf error-code {
174             type uint8;
175             mandatory true;
176         }
177         leaf error-subcode {
178             type uint8;
179             mandatory true;
180         }
181         leaf data {
182             type binary;
183         }
184     }
185 }