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