YANG revision dates mass-update
[bgpcep.git] / bmp / bmp-api / src / main / yang / bmp-message.yang
1 module bmp-message {
2     yang-version 1;
3     namespace "urn:opendaylight:params:xml:ns:yang:bmp-message";
4     prefix "bmp-msg";
5
6     import bgp-message { prefix bgp-msg; revision-date 2020-01-20; }
7     import bgp-multiprotocol { prefix bgp-mp; revision-date 2018-03-29; }
8     import ietf-inet-types { prefix inet; revision-date 2013-07-15; }
9     import ietf-yang-types { prefix yang; revision-date 2013-07-15; }
10     import bgp-types { prefix bgp-t; revision-date 2020-01-20; }
11
12     organization "Cisco Systems, Inc.";
13     contact "Milos Fabian <milfabia@cisco.com>";
14
15     description
16         "This module contains the base data model of a BMP messages.
17         It rolls up the definitions contained in RFC7854.
18
19         Copyright (c)2015 Cisco Systems, Inc. All rights reserved.
20
21         This program and the accompanying materials are made available
22         under the terms of the Eclipse Public License v1.0 which
23         accompanies this distribution, and is available at
24         http://www.eclipse.org/legal/epl-v10.html";
25
26    reference
27         "https://tools.ietf.org/html/rfc7854";
28
29     revision 2020-01-20 {
30         description "Update to use -no-zone-adresses";
31     }
32
33     revision "2018-03-29" {
34         description "Add support for add-path for all afi/safi.";
35     }
36
37     revision "2017-12-07" {
38         description "Add support for add-path in base BGP NLRI.";
39     }
40
41     revision "2015-05-12" {
42         description
43             "Initial revision.";
44     }
45
46     typedef reason {
47         type enumeration {
48             enum administratively-closed {
49                 value 0;
50                 description
51                     "Session administratively closed.";
52             }
53             enum unspecified {
54                 value 1;
55                 description
56                     "Unspecified reason.";
57             }
58             enum out-of-resources {
59                 value 2;
60                 description
61                     "Out of resources. The router has exhausted
62                      resources available for the BMP session.";
63             }
64             enum redundant-connection {
65                 value 3;
66                 description
67                     "Redundant connection. The router has determined
68                      that this connection is redundant with another one.";
69             }
70             enum permanently-closed {
71                 value 4;
72                 description
73                     "Session permanently administratively closed,
74                      will not be re-initiated.  Monitoring station should reduce
75                      (potentially to 0) the rate at which it attempts
76                      reconnection to the monitored router.";
77             }
78         }
79     }
80
81     typedef adj-rib-in-type {
82         type enumeration {
83             enum pre-policy {
84                 value 0;
85             }
86             enum post-policy {
87                 value 1;
88             }
89         }
90         description
91             "If set to 1, indicates that the message reflects
92              the post-policy Adj-RIB-In (i.e., it reflects the application
93              of inbound policy).  It is set to 0 if the message reflects the
94              pre-policy Adj-RIB-In.";
95     }
96
97     typedef peer-type {
98         type enumeration {
99             enum global {
100                 value 0;
101                 description "Global Instance Peer.";
102             }
103             enum l3vpn {
104                 value 1;
105                 description "RD Instance Peer.";
106             }
107             enum local {
108                 value 2;
109                 description "Local Instance Peer";
110             }
111         }
112     }
113
114     typedef mirror-information-code {
115         type enumeration {
116             enum errored-pdu {
117                 value 0;
118             }
119             enum message-lost {
120                 value 1;
121             }
122         }
123     }
124
125     grouping tlv {
126         description
127             "Common marker for all BMP TLVs.";
128     }
129
130     grouping string-tlv {
131         container string-tlv {
132             uses tlv;
133             leaf string-info {
134                 type string;
135             }
136             description
137                 "Type = 0: String. The Information field contains a free-form
138                  UTF-8 string whose length is given by the Information Length
139                  field. Inclusion of this TLV is optional.
140                  Multiple String TLVs MAY be included in the message.";
141         }
142     }
143
144     grouping description-tlv {
145         container description-tlv {
146             uses tlv;
147             leaf description {
148                 type string;
149                 mandatory true;
150             }
151             description
152                 "Type = 1: sysDescr. The Information field contains an ASCII
153                  string whose value MUST be set to be equal to the value of the
154                  sysDescr MIB-II [RFC1213] object.  Inclusion of this TLV is
155                  mandatory.";
156         }
157     }
158
159     grouping name-tlv {
160         container name-tlv {
161             uses tlv;
162             leaf name {
163                 type string;
164                 mandatory true;
165             }
166             description
167                 "Type = 2: sysName. The Information field contains a ASCII
168                  string whose value MUST be set to be equal to the value of the
169                  sysName MIB-II [RFC1213] object.  Inclusion of this TLV is
170                  mandatory.";
171         }
172     }
173
174     grouping string-informations {
175         list string-information {
176             uses string-tlv;
177         }
178     }
179
180     grouping initiation-tlvs {
181         uses string-informations;
182         uses description-tlv;
183         uses name-tlv;
184         description
185             "TLVs containing information about the monitored router";
186     }
187
188     grouping reason-tlv {
189         container reason-tlv {
190             uses tlv;
191             leaf reason {
192                 type reason;
193                 mandatory true;
194             }
195             description
196                 "Type = 1: Reason. The Information field contains a two-byte
197                  code indicating the reason the connection was terminated.  Some
198                  reasons may have further TLVs associated with them.  Inclusion
199                  of this TLV is not optional.";
200         }
201     }
202
203     grouping termination-tlvs {
204         uses string-informations;
205         uses reason-tlv;
206         description
207             "TLVs containing information about the reason for the
208              termination.";
209     }
210
211     grouping mirror-information-tlv {
212         container mirror-information-tlv {
213             uses tlv;
214             leaf code {
215                 type mirror-information-code;
216             }
217             description
218                 "Type = 1: Information. A two-byte code that provides information
219                  about the mirrored message or message stream.";
220         }
221     }
222
223     grouping mirror-pdu-tlvs {
224        container pdu-update-tlv {
225            uses tlv;
226            uses bgp-msg:update-message;
227        }
228        container pdu-open-tlv {
229            uses tlv;
230            uses bgp-msg:open-message;
231        }
232        description
233            "BGP Message.  A BGP PDU.  This PDU may or may not be an
234            Update message.  If the BGP Message TLV occurs in the Route
235            Mirroring message, it MUST occur last in the list of TLVs.";
236     }
237
238     grouping mirror-tlvs {
239         uses mirror-information-tlv;
240         uses mirror-pdu-tlvs;
241     }
242
243     grouping mirror {
244         container tlvs {
245             uses mirror-tlvs;
246         }
247     }
248
249     grouping count-tlv {
250         uses tlv;
251         leaf count {
252             type yang:counter32;
253         }
254     }
255
256     grouping gauge-tlv {
257         uses tlv;
258         leaf count {
259             type yang:gauge64;
260         }
261     }
262
263     grouping afi-safi-gauge-tlv {
264         uses tlv;
265         uses bgp-mp:bgp-table-type;
266         leaf count {
267             type yang:gauge64;
268         }
269     }
270
271     grouping stat-tlvs {
272         container rejected-prefixes-tlv {
273             uses count-tlv;
274             description
275                 "Stat Type = 0: (32-bit Counter) Number of prefixes rejected by
276                  inbound policy.";
277         }
278         container duplicate-prefix-advertisements-tlv {
279             uses count-tlv;
280             description
281                 "Stat Type = 1: (32-bit Counter) Number of (known) duplicate prefix
282                  advertisements.";
283         }
284         container duplicate-withdraws-tlv {
285             uses count-tlv;
286             description
287                 "Stat Type = 2: (32-bit Counter) Number of (known) duplicate
288                  withdraws.";
289         }
290         container invalidated-cluster-list-loop-tlv {
291             uses count-tlv;
292             description
293                 "Stat Type = 3: (32-bit Counter) Number of updates invalidated due
294                  to CLUSTER_LIST loop.";
295         }
296         container invalidated-as-path-loop-tlv {
297             uses count-tlv;
298             description
299                 "Stat Type = 4: (32-bit Counter) Number of updates invalidated due
300                  to AS_PATH loop.";
301         }
302         container invalidated-originator-id-tlv {
303             uses count-tlv;
304             description
305                 "Stat Type = 5: (32-bit Counter) Number of updates invalidated due
306                  to ORIGINATOR_ID.";
307         }
308         container invalidated-as-confed-loop-tlv {
309             uses count-tlv;
310             description
311                 "Stat Type = 6: (32-bit Counter) Number of updates invalidated due
312                  to AS_CONFED loop.";
313         }
314         container adj-ribs-in-routes-tlv {
315             uses gauge-tlv;
316             description
317                 "Stat Type = 7: (64-bit Gauge) Number of routes in Adj-RIBs-In.";
318         }
319         container loc-rib-routes-tlv {
320             uses gauge-tlv;
321             description
322                 "Stat Type = 8: (64-bit Gauge) Number of routes in Loc-RIB.";
323         }
324         description
325             "Each counter is encoded as a TLV.";
326         container per-afi-safi-adj-rib-in-tlv {
327             uses afi-safi-gauge-tlv;
328             description
329                 "Stat Type = 9: Number of routes in per-AFI/SAFI Adj-RIB-In.  The
330                  value is structured as: AFI (2 bytes), SAFI (1 byte), followed by
331                  a 64-bit Gauge.";
332         }
333         container per-afi-safi-loc-rib-tlv {
334             uses afi-safi-gauge-tlv;
335             description
336                 "Stat Type = 10: Number of routes in per-AFI/SAFI Loc-RIB.  The
337                 value is structured as: AFI (2 bytes), SAFI (1 byte), followed by
338                 a 64-bit Gauge.";
339         }
340         container updates-treated-as-withdraw-tlv {
341             uses count-tlv;
342             description
343                 "Stat Type = 11: (32-bit Counter) Number of updates subjected to
344                 treat-as-withdraw treatment. ";
345         }
346         container prefixes-treated-as-withdraw-tlv {
347             uses count-tlv;
348             description
349                 "Stat Type = 12: (32-bit Counter) Number of prefixes subjected to
350                 treat-as-withdraw treatment. ";
351         }
352         container duplicate-updates-tlv {
353             uses count-tlv;
354             description
355             "Stat Type = 13: (32-bit Counter) Number of duplicate update
356             messages received. ";
357         }
358     }
359
360     grouping timestamp {
361         leaf timestamp-sec {
362             type yang:timestamp;
363             default 0;
364             description
365                 "Timestamp with seconds precision.";
366         }
367         leaf timestamp-micro {
368             type yang:timestamp;
369             default 0;
370             description
371                 "Timestamp with microseconds precision.";
372         }
373         description
374             "The time when the encapsulated routes were received
375              (one may also think of this as the time when they were installed
376              in the Adj-RIB-In), expressed in seconds and microseconds since
377              midnight (zero hour), January 1, 1970 (UTC).  If zero, the time is
378              unavailable.  Precision of the timestamp is implementation-
379              dependent.";
380     }
381
382     grouping peer {
383         leaf type {
384             type peer-type;
385             mandatory true;
386         }
387         leaf peer-distinguisher {
388             type union {
389                 type bgp-t:route-distinguisher;
390                 type binary {
391                     length 8;
392                 }
393             }
394             description
395                 "This field is present to distinguish peers that
396                  belong to one address domain from the other.";
397         }
398         leaf address {
399             type inet:ip-address-no-zone;
400             mandatory true;
401             description
402                 "The remote IP address associated with the TCP
403                  session over which the encapsulated PDU was received.  It is 4
404                  bytes long if an IPv4 address is carried in this field (with most
405                  significant bytes zero filled) and 16 bytes long if an IPv6
406                  address is carried in this field.";
407         }
408         leaf as {
409             type inet:as-number;
410             mandatory true;
411             description
412                 "The Autonomous System number of the peer from which the
413                  encapsulated PDU was received.  If a 16 bit AS number is stored in
414                  this field [RFC4893], it should be padded with zeroes in the most
415                  significant bits.";
416         }
417         leaf bgp-id {
418             type inet:ipv4-address-no-zone;
419             mandatory true;
420             description
421                 "The BGP Identifier of the peer from which the
422                  encapsulated PDU was received.";
423         }
424     }
425
426     grouping peer-header {
427         container peer-header {
428             uses peer;
429             uses timestamp;
430             leaf adj-rib-in-type {
431                 type adj-rib-in-type;
432                 mandatory true;
433             }
434             leaf ipv4 {
435                 type boolean;
436                 mandatory true;
437                 description
438                     "Indicates if peer's address is IPv4. If set to false address is IPv6.";
439             }
440         }
441         description
442             "The per-peer header follows the common header for most BMP messages.
443               The rest of the data in a BMP message is dependent on the Message
444               Type field in the common header.";
445         reference
446             "https://tools.ietf.org/html/rfc7854#section-4.2";
447     }
448
449     grouping stat {
450         container tlvs {
451             uses stat-tlvs;
452         }
453     }
454
455     grouping open-msg {
456         uses bgp-msg:open-message {
457             augment "bgp-parameters/optional-capabilities/c-parameters" {
458                 uses bgp-mp:mp-capabilities;
459             }
460         }
461     }
462
463     grouping peer-up {
464         leaf local-address {
465             type inet:ip-address-no-zone;
466             mandatory true;
467             description
468                 "The local IP address associated with the peering
469                  TCP session.";
470         }
471         leaf local-port {
472             type inet:port-number;
473             mandatory true;
474             description
475                 "The local port number associated with the peering TCP
476                  session.";
477         }
478         leaf remote-port {
479             type inet:port-number;
480             mandatory true;
481             description
482                 "The remote port number associated with the peering
483                  TCP session.";
484         }
485         container sent-open {
486             uses open-msg;
487             description
488                 "The full OPEN message transmitted by the
489                  monitored router to its peer.";
490         }
491         container received-open {
492             uses open-msg;
493             description
494                 "The full OPEN message received by the
495                  monitored router from its peer.";
496         }
497         container information {
498             uses string-informations;
499         }
500     }
501
502     grouping peer-down {
503         leaf local-system-closed {
504             type boolean;
505             mandatory true;
506             description
507                 "If set true, the local system closed the session.
508                  Otherwise the remote system closed the session.";
509         }
510         choice data {
511             container notification {
512                 uses bgp-msg:notify-message;
513                 description
514                     "BGP PDU containing the BGP
515                      NOTIFICATION message as received from the peer.";
516             }
517             leaf fsm-event-code {
518                 type uint16;
519                 default 0;
520                 description
521                     "Containing the code corresponding to the FSM Event which caused
522                      the system to close the session.
523                      Two bytes both set to zero are used to indicate that no relevant
524                      Event code is defined.";
525             }
526         }
527     }
528
529     grouping initiation {
530         container tlvs {
531             uses initiation-tlvs;
532         }
533     }
534
535     grouping termination {
536         container tlvs {
537             uses termination-tlvs;
538         }
539     }
540
541     notification initiation-message {
542         uses initiation;
543         description
544             "The initiation message provides a means for the monitored router to
545              inform the monitoring station of its vendor, software version, and so on.";
546         reference
547             "https://tools.ietf.org/html/rfc7854#section-4.3";
548     }
549
550     notification termination-message {
551         uses termination;
552         description
553             "The termination message provides a way for a monitored router to
554              indicate why it is terminating a session.";
555         reference
556             "https://tools.ietf.org/html/rfc7854#section-4.5";
557     }
558
559     notification route-monitoring-message {
560         uses peer-header;
561         container update {
562             uses bgp-msg:update-message;
563         }
564         description
565             "Route Monitoring messages are used for initial synchronization of
566              ADJ-RIBs-In.  They are also used for ongoing monitoring of received
567              advertisements and withdraws.";
568         reference
569             "https://tools.ietf.org/html/rfc7854#section-4.6";
570     }
571
572     notification route-mirroring-message {
573         uses peer-header;
574         uses mirror;
575         description
576             "Route Mirroring messages are used for verbatim duplication of
577              messages as received.";
578         reference
579             "https://tools.ietf.org/html/rfc7854#section-4.7";
580     }
581
582     notification stats-reports-message {
583         uses peer-header;
584         uses stat;
585         description
586             "These messages contain information that could be used by the
587              monitoring station to observe interesting events that occur on the
588              router.";
589         reference
590             "https://tools.ietf.org/html/rfc7854#section-4.8";
591     }
592
593     notification peer-down-notification {
594         uses peer-header;
595         uses peer-down;
596         description
597             "This message is used to indicate that a peering session was
598              terminated.";
599         reference
600             "https://tools.ietf.org/html/rfc7854#section-4.9";
601     }
602
603     notification peer-up-notification {
604         uses peer-header;
605         uses peer-up;
606         description
607             "The Peer Up message is used to indicate that a peering session has
608              come up (i.e., has transitioned into ESTABLISHED state).";
609         reference
610             "https://tools.ietf.org/html/rfc7854#section-4.10";
611     }
612 }