16aca6f4a7b1f9c1be1a3db2b6a599685f11419a
[yangtools.git] / yang / yang-parser-impl / src / test / resources / bugs / identity-ietf-routing-test / ietf-routing@2016-11-04.yang
1 module ietf-routing {
2
3   yang-version "1.1";
4
5   namespace "urn:ietf:params:xml:ns:yang:ietf-routing";
6
7   prefix "rt";
8
9   import ietf-yang-types {
10     prefix "yang";
11   }
12
13   import ietf-interfaces {
14     prefix "if";
15   }
16
17   organization
18     "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
19
20   contact
21     "WG Web:   <https://datatracker.ietf.org/wg/netmod/>
22      WG List:  <mailto:netmod@ietf.org>
23      WG Chair: Lou Berger
24                <mailto:lberger@labn.net>
25      WG Chair: Kent Watsen
26                <mailto:kwatsen@juniper.net>
27      Editor:   Ladislav Lhotka
28                <mailto:lhotka@nic.cz>
29      Editor:   Acee Lindem
30                <mailto:acee@cisco.com>";
31
32   description
33     "This YANG module defines essential components for the management
34      of a routing subsystem.
35      Copyright (c) 2016 IETF Trust and the persons identified as
36      authors of the code.  All rights reserved.
37      Redistribution and use in source and binary forms, with or
38      without modification, is permitted pursuant to, and subject to
39      the license terms contained in, the Simplified BSD License set
40      forth in Section 4.c of the IETF Trust's Legal Provisions
41      Relating to IETF Documents
42      (http://trustee.ietf.org/license-info).
43      The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL
44      NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'MAY', and
45      'OPTIONAL' in the module text are to be interpreted as described
46      in RFC 2119.
47      This version of this YANG module is part of RFC 8022;
48      see the RFC itself for full legal notices.";
49
50   revision 2016-11-04 {
51     description
52       "Initial revision.";
53     reference
54       "RFC 8022: A YANG Data Model for Routing Management";
55   }
56
57   /* Features */
58
59   feature multiple-ribs {
60     description
61       "This feature indicates that the server supports user-defined
62        RIBs.
63        Servers that do not advertise this feature SHOULD provide
64        exactly one system-controlled RIB per supported address family
65        and make it also the default RIB.  This RIB then appears as an
66        entry of the list /routing-state/ribs/rib.";
67   }
68
69   feature router-id {
70     description
71       "This feature indicates that the server supports configuration
72        of an explicit 32-bit router ID that is used by some routing
73        protocols.
74        Servers that do not advertise this feature set a router ID
75        algorithmically, usually to one of the configured IPv4
76        addresses.  However, this algorithm is implementation
77        specific.";
78   }
79
80   /* Identities */
81
82   identity address-family {
83     description
84       "Base identity from which identities describing address
85        families are derived.";
86   }
87
88   identity ipv4 {
89     base address-family;
90     description
91       "This identity represents IPv4 address family.";
92   }
93
94   identity ipv6 {
95     base address-family;
96     description
97       "This identity represents IPv6 address family.";
98   }
99
100   identity control-plane-protocol {
101     description
102       "Base identity from which control-plane protocol identities are
103        derived.";
104   }
105
106   identity routing-protocol {
107     base control-plane-protocol;
108     description
109       "Identity from which Layer 3 routing protocol identities are
110        derived.";
111   }
112
113   identity direct {
114     base routing-protocol;
115     description
116       "Routing pseudo-protocol that provides routes to directly
117        connected networks.";
118   }
119
120   identity static {
121     base routing-protocol;
122     description
123       "Static routing pseudo-protocol.";
124   }
125
126   /* Type Definitions */
127
128   typedef route-preference {
129     type uint32;
130     description
131       "This type is used for route preferences.";
132   }
133
134   /* Groupings */
135
136   grouping address-family {
137     description
138       "This grouping provides a leaf identifying an address
139        family.";
140     leaf address-family {
141       type identityref {
142         base address-family;
143       }
144       mandatory "true";
145       description
146         "Address family.";
147     }
148   }
149
150   grouping router-id {
151     description
152       "This grouping provides router ID.";
153     leaf router-id {
154       type yang:dotted-quad;
155       description
156         "A 32-bit number in the form of a dotted quad that is used by
157          some routing protocols identifying a router.";
158       reference
159         "RFC 2328: OSPF Version 2.";
160     }
161   }
162
163   grouping special-next-hop {
164     description
165       "This grouping provides a leaf with an enumeration of special
166        next hops.";
167     leaf special-next-hop {
168       type enumeration {
169         enum blackhole {
170           description
171             "Silently discard the packet.";
172         }
173         enum unreachable {
174           description
175             "Discard the packet and notify the sender with an error
176              message indicating that the destination host is
177              unreachable.";
178         }
179         enum prohibit {
180           description
181             "Discard the packet and notify the sender with an error
182              message indicating that the communication is
183              administratively prohibited.";
184         }
185         enum receive {
186           description
187             "The packet will be received by the local system.";
188         }
189       }
190       description
191         "Options for special next hops.";
192     }
193   }
194
195   grouping next-hop-content {
196     description
197       "Generic parameters of next hops in static routes.";
198     choice next-hop-options {
199       mandatory "true";
200       description
201         "Options for next hops in static routes.
202          It is expected that further cases will be added through
203          augments from other modules.";
204       case simple-next-hop {
205         description
206           "This case represents a simple next hop consisting of the
207            next-hop address and/or outgoing interface.
208            Modules for address families MUST augment this case with a
209            leaf containing a next-hop address of that address
210            family.";
211         leaf outgoing-interface {
212           type if:interface-ref;
213           description
214             "Name of the outgoing interface.";
215         }
216       }
217       case special-next-hop {
218         uses special-next-hop;
219       }
220       case next-hop-list {
221         container next-hop-list {
222           description
223             "Container for multiple next-hops.";
224           list next-hop {
225             key "index";
226             description
227               "An entry of a next-hop list.
228                Modules for address families MUST augment this list
229                with a leaf containing a next-hop address of that
230                address family.";
231             leaf index {
232               type string;
233               description
234                 "A user-specified identifier utilized to uniquely
235                  reference the next-hop entry in the next-hop list.
236                  The value of this index has no semantic meaning
237                  other than for referencing the entry.";
238             }
239             leaf outgoing-interface {
240               type if:interface-ref;
241               description
242                 "Name of the outgoing interface.";
243             }
244           }
245         }
246       }
247     }
248   }
249
250   grouping next-hop-state-content {
251     description
252       "Generic parameters of next hops in state data.";
253     choice next-hop-options {
254       mandatory "true";
255       description
256         "Options for next hops in state data.
257          It is expected that further cases will be added through
258          augments from other modules, e.g., for recursive
259          next hops.";
260       case simple-next-hop {
261         description
262           "This case represents a simple next hop consisting of the
263            next-hop address and/or outgoing interface.
264            Modules for address families MUST augment this case with a
265            leaf containing a next-hop address of that address
266            family.";
267         leaf outgoing-interface {
268           type if:interface-state-ref;
269           description
270             "Name of the outgoing interface.";
271         }
272       }
273       case special-next-hop {
274         uses special-next-hop;
275       }
276       case next-hop-list {
277         container next-hop-list {
278           description
279             "Container for multiple next hops.";
280           list next-hop {
281             description
282               "An entry of a next-hop list.
283                Modules for address families MUST augment this list
284                with a leaf containing a next-hop address of that
285                address family.";
286             leaf outgoing-interface {
287               type if:interface-state-ref;
288               description
289                 "Name of the outgoing interface.";
290             }
291           }
292         }
293       }
294     }
295   }
296
297   grouping route-metadata {
298     description
299       "Common route metadata.";
300     leaf source-protocol {
301       type identityref {
302         base routing-protocol;
303       }
304       mandatory "true";
305       description
306         "Type of the routing protocol from which the route
307          originated.";
308     }
309     leaf active {
310       type empty;
311       description
312         "Presence of this leaf indicates that the route is preferred
313          among all routes in the same RIB that have the same
314          destination prefix.";
315     }
316     leaf last-updated {
317       type yang:date-and-time;
318       description
319         "Time stamp of the last modification of the route.  If the
320          route was never modified, it is the time when the route was
321          inserted into the RIB.";
322     }
323   }
324
325   /* State data */
326
327   container routing-state {
328     config "false";
329     description
330       "State data of the routing subsystem.";
331     uses router-id {
332       description
333         "Global router ID.
334          It may be either configured or assigned algorithmically by
335          the implementation.";
336     }
337     container interfaces {
338       description
339         "Network-layer interfaces used for routing.";
340       leaf-list interface {
341         type if:interface-state-ref;
342         description
343           "Each entry is a reference to the name of a configured
344            network-layer interface.";
345       }
346     }
347     container control-plane-protocols {
348       description
349         "Container for the list of routing protocol instances.";
350       list control-plane-protocol {
351         key "type name";
352         description
353           "State data of a control-plane protocol instance.
354            An implementation MUST provide exactly one
355            system-controlled instance of the 'direct'
356            pseudo-protocol.  Instances of other control-plane
357            protocols MAY be created by configuration.";
358         leaf type {
359           type identityref {
360             base control-plane-protocol;
361           }
362           description
363             "Type of the control-plane protocol.";
364         }
365         leaf name {
366           type string;
367           description
368             "The name of the control-plane protocol instance.
369              For system-controlled instances this name is persistent,
370              i.e., it SHOULD NOT change across reboots.";
371         }
372       }
373     }
374     container ribs {
375       description
376         "Container for RIBs.";
377       list rib {
378         key "name";
379         min-elements "1";
380         description
381           "Each entry represents a RIB identified by the 'name' key.
382            All routes in a RIB MUST belong to the same address
383            family.
384            An implementation SHOULD provide one system-controlled
385            default RIB for each supported address family.";
386         leaf name {
387           type string;
388           description
389             "The name of the RIB.";
390         }
391         uses address-family;
392         leaf default-rib {
393           if-feature "multiple-ribs";
394           type boolean;
395           default "true";
396           description
397             "This flag has the value of 'true' if and only if the RIB
398              is the default RIB for the given address family.
399              By default, control-plane protocols place their routes
400              in the default RIBs.";
401         }
402         container routes {
403           description
404             "Current content of the RIB.";
405           list route {
406             description
407               "A RIB route entry.  This data node MUST be augmented
408                with information specific for routes of each address
409                family.";
410             leaf route-preference {
411               type route-preference;
412               description
413                 "This route attribute, also known as administrative
414                  distance, allows for selecting the preferred route
415                  among routes with the same destination prefix.  A
416                  smaller value means a more preferred route.";
417             }
418             container next-hop {
419               description
420                 "Route's next-hop attribute.";
421               uses next-hop-state-content;
422             }
423             uses route-metadata;
424           }
425         }
426         action active-route {
427           description
428             "Return the active RIB route that is used for the
429              destination address.
430              Address-family-specific modules MUST augment input
431              parameters with a leaf named 'destination-address'.";
432           output {
433             container route {
434               description
435                 "The active RIB route for the specified destination.
436                  If no route exists in the RIB for the destination
437                  address, no output is returned.
438                  Address-family-specific modules MUST augment this
439                  container with appropriate route contents.";
440               container next-hop {
441                 description
442                   "Route's next-hop attribute.";
443                 uses next-hop-state-content;
444               }
445               uses route-metadata;
446             }
447           }
448         }
449       }
450     }
451   }
452
453   /* Configuration Data */
454
455   container routing {
456     description
457       "Configuration parameters for the routing subsystem.";
458     uses router-id {
459       if-feature "router-id";
460       description
461         "Configuration of the global router ID.  Routing protocols
462          that use router ID can use this parameter or override it
463          with another value.";
464     }
465     container control-plane-protocols {
466       description
467         "Configuration of control-plane protocol instances.";
468       list control-plane-protocol {
469         key "type name";
470         description
471           "Each entry contains configuration of a control-plane
472            protocol instance.";
473         leaf type {
474           type identityref {
475             base control-plane-protocol;
476           }
477           description
478             "Type of the control-plane protocol - an identity derived
479              from the 'control-plane-protocol' base identity.";
480         }
481         leaf name {
482           type string;
483           description
484             "An arbitrary name of the control-plane protocol
485              instance.";
486         }
487         leaf description {
488           type string;
489           description
490             "Textual description of the control-plane protocol
491              instance.";
492         }
493         container static-routes {
494           when "derived-from-or-self(../type, 'rt:static')" {
495             description
496               "This container is only valid for the 'static' routing
497                protocol.";
498           }
499           description
500             "Configuration of the 'static' pseudo-protocol.
501              Address-family-specific modules augment this node with
502              their lists of routes.";
503         }
504       }
505     }
506     container ribs {
507       description
508         "Configuration of RIBs.";
509       list rib {
510         key "name";
511         description
512           "Each entry contains configuration for a RIB identified by
513            the 'name' key.
514            Entries having the same key as a system-controlled entry
515            of the list /routing-state/ribs/rib are used for
516            configuring parameters of that entry.  Other entries
517            define additional user-controlled RIBs.";
518         leaf name {
519           type string;
520           description
521             "The name of the RIB.
522              For system-controlled entries, the value of this leaf
523              must be the same as the name of the corresponding entry
524              in state data.
525              For user-controlled entries, an arbitrary name can be
526              used.";
527         }
528         uses address-family {
529           description
530             "Address family of the RIB.
531              It is mandatory for user-controlled RIBs.  For
532              system-controlled RIBs it can be omitted; otherwise, it
533              must match the address family of the corresponding state
534              entry.";
535           refine "address-family" {
536             mandatory "false";
537           }
538         }
539         leaf description {
540           type string;
541           description
542             "Textual description of the RIB.";
543         }
544       }
545     }
546   }
547 }