<?xml version="1.0" encoding="UTF-8"?>
  <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
  <!-- generated by https://github.com/cabo/kramdown-rfc2629 version 1.0.37 -->

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
]>

<?rfc strict="yes"?>
<?rfc toc="yes"?>
<?rfc tocdepth="4"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>

<rfc ipr="trust200902" docName="draft-veillette-core-yang-library-04" category="std">

  <front>
    <title>Constrained YANG Module Library</title>

    <author initials="M." surname="Veillette" fullname="Michel Veillette" role="editor">
      <organization>Trilliant Networks Inc.</organization>
      <address>
        <postal>
          <street>610 Rue du Luxembourg</street>
          <city>Granby</city>
          <region>Quebec</region>
          <code>J2J 2V2</code>
          <country>Canada</country>
        </postal>
        <email>michel.veillette@trilliantinc.com</email>
      </address>
    </author>
    <author initials="I." surname="Petrov" fullname="Ivaylo Petrov" role="editor">
      <organization>Acklio</organization>
      <address>
        <postal>
          <street>1137A avenue des Champs Blancs</street>
          <city>Cesson-Sevigne</city>
          <region>Bretagne</region>
          <code>35510</code>
          <country>France</country>
        </postal>
        <email>ivaylo@ackl.io</email>
      </address>
    </author>

    <date year="2019" month="March" day="29"/>

    <area>Applications and Real-Time Area (art)</area>
    <workgroup>Internet Engineering Task Force</workgroup>
    <keyword>YANG</keyword>

    <abstract>


<t>This document describes a constrained version of the YANG library that provides information about the YANG modules, datastores, and datastore schemas used by a constrained network management server (e.g., a CORECONF server).</t>



    </abstract>


  </front>

  <middle>


<section anchor="introduction" title="Introduction">

<t>There is a need for a standard mechanism to expose which YANG modules, datastores and datastore schemas are in use by a constrained network management server. This document defines the YANG module ‘ietf-constrained-yang-library’ that provides this information.</t>

<t>YANG module ‘ietf-constrained-yang-library’ shares the same data model and objectives as ‘ietf-yang-library’, only datatypes and mandatory requirements have been updated to minimize its size to allow its implementation by Constrained Nodes and/or Constrained Networks as defined by <xref target="RFC7228"/>. To review the list of objectives and proposed data model, please refer to <xref target="RFC8525"/> section 2 and 3.</t>

</section>
<section anchor="terminology-and-notation" title="Terminology and Notation">

<t>The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”,
“SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to
be interpreted as described in <xref target="RFC2119"/>.</t>

<t>The following terms are defined in <xref target="RFC7950"/>: client, deviation, feature, module, submodule and server.</t>

<t>The following term is defined in <xref target="I-D.ietf-core-sid"/>: YANG Schema Item iDentifier (SID).</t>

<t>The following terms are defined in <xref target="RFC8525"/>: YANG library and YANG library checksum.</t>

</section>
<section anchor="overview" title="Overview">

<t>The conceptual model of the YANG library is depicted in <xref target="model"/>.</t>

<figure title="Conceptual model of the YANG library" anchor="model"><artwork align="left"><![CDATA[
+-----------+
| datastore |
+-----------+
     |
     | has a
     V
+-----------+            +--------+                +------------+
| datastore |  union of  | module |  consists of   | modules +  |
|  schema   |----------->|  set   |--------------->| submodules |
+-----------+            +--------+                +------------+
]]></artwork></figure>

<t>It’s expected that most constrained network management servers have one datastore (e.g. a unified datastore). However, some servers may have multiples datastore as described by NMDA <xref target="RFC8342"/>. The YANG library data model supports both cases.</t>

<t>In this model, every datastore has an associated datastore schema, which is the union of module sets, which is a collection of modules. Multiple datastores may refer to the same datastore schema and individual datastore schemas may share module sets.</t>

<t>For each module, the YANG library provides:</t>

<t><list style="symbols">
  <t>the YANG module identifier (i.e. SID)</t>
  <t>its revision</t>
  <t>its list of submodules</t>
  <t>its list of imported modules</t>
  <t>its set of features and deviations</t>
</list></t>

<t>YANG module namespace and location are also supported, but their implementation is not recommended for constrained servers.</t>

<section anchor="tree-diagram" title="Tree diagram">

<t>The tree diagram of YANG module ietf-constrained-yang-library is provided below. This graphical representation of a YANG module is defined in <xref target="RFC8340"/>.</t>

<figure align="left"><artwork><![CDATA[
module: ietf-constrained-yang-library
  +--ro yang-library
     +--ro module-set* [index]
     |  +--ro index                 uint8
     |  +--ro module* [identifier]
     |  |  +--ro identifier    sid:sid
     |  |  +--ro revision?     revision-identifier
     |  |  +--ro namespace?    inet:uri
     |  |  +--ro location*     inet:uri
     |  |  +--ro submodule* [identifier]
     |  |  |  +--ro identifier    sid:sid
     |  |  |  +--ro revision?     revision-identifier
     |  |  |  +--ro location*     inet:uri
     |  |  +--ro feature*      sid:sid
     |  |  +--ro deviation*    -> ../../module/identifier
     |  +--ro import-only-module* [identifier revision]
     |     +--ro identifier    sid:sid
     |     +--ro revision      union
     |     +--ro namespace?    inet:uri
     |     +--ro location*     inet:uri
     |     +--ro submodule* [identifier]
     |        +--ro identifier    sid:sid
     |        +--ro revision?     revision-identifier
     |        +--ro location*     inet:uri
     +--ro schema* [index]
     |  +--ro index         uint8
     |  +--ro module-set*   -> ../../module-set/index
     +--ro datastore* [identifier]
     |  +--ro identifier    ds:datastore-ref
     |  +--ro schema        -> ../../schema/index
     +--ro checksum      binary

  notifications:
    +---n yang-library-update
       +--ro checksum    -> /yang-library/checksum
]]></artwork></figure>

</section>
<section anchor="major-differences-between-ietf-constrained-yang-library-and-ietf-yang-library" title="Major differences between ietf-constrained-yang-library and ietf-yang-library">

<t>The list of changes between the reference data model ‘ietf-yang-library’ and its constrained version ‘ietf-constrained-yang-library’ are listed below:</t>

<t><list style="symbols">
  <t>module-set ‘name’ and schema ‘name’ are implemented using an 8 bits unsigned integer and renamed ‘index’.</t>
  <t>module ‘name’, submodule ‘name’ and datastore ‘name’ are implemented using a SID (i.e. an unsigned integer) and renamed ‘identifier’.</t>
  <t>‘feature’ and ‘deviation’ are implemented using a SID (i.e. an unsigned integer).</t>
  <t>‘revision’ fields are implemented using a 4 bytes binary string.</t>
  <t>the mandatory requirement of the ‘namespace’ fields is removed, and implementation is not recommended. SIDs used by constrained devices and protocols don’t require namespaces.</t>
  <t>the implementation of the ‘location’ fields are not recommended, the use of the module SID as the handle to retrieve the associated YANG module is proposed instead.</t>
</list></t>

</section>
</section>
<section anchor="yang-module-ietf-constrained-yang-library" title="YANG Module “ietf-constrained-yang-library”">

<t>RFC Ed.: update the date below with the date of RFC publication
and remove this note.</t>

<figure align="left"><artwork><![CDATA[
<CODE BEGINS> file "ietf-constrained-yang-library@2019-03-28.yang"
module ietf-constrained-yang-library {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-constrained-yang-library";
  prefix "yanglib";

  // RFC Ed.: update ietf-core-sid reference.
    
  import ietf-sid-file {
    prefix sid;
    reference "I-D.ietf-core-sid";
  }
  import ietf-inet-types {
    prefix inet;
    reference "RFC 6991: Common YANG Data Types.";
  }
  import ietf-datastores {
    prefix ds;
    reference "RFC 8342: Network Management Datastore Architecture (NMDA).";
  }
  
  organization
    "IETF NETCONF (Network Configuration) Working Group";

  contact
    "WG Web:   <http://datatracker.ietf.org/wg/core/>
    
     WG List:  <mailto:core@ietf.org>

     WG Chair: Carsten Bormann 
               <mailto:cabo@tzi.org>

     WG Chair: Jaime Jimenez 
               <mailto:jaime.jimenez@ericsson.com>

     Editor:   Michel Veillette
               <mailto:michel.veillette@trilliantinc.com>";

  description
    "This module provides information about the YANG modules,
     datastores, and datastore schemas implemented by a constrained
     network management server.

     Copyright (c) 2018 IETF Trust and the persons identified as
     authors of the code.  All rights reserved.

     Redistribution and use in source and binary forms, with or
     without modification, is permitted pursuant to, and subject
     to the license terms contained in, the Simplified BSD License
     set forth in Section 4.c of the IETF Trust's Legal Provisions
     Relating to IETF Documents
     (http://trustee.ietf.org/license-info).

     This version of this YANG module is part of RFC XXXX; see
     the RFC itself for full legal notices.";

  // RFC Ed.: update reference.

  revision 2019-03-28 {
    description
      "Second revision.";
    reference
      "[I-D.veillette-core-yang-library]  Constrained YANG Module Library";
  }

  revision 2018-09-21 {
    description
      "Initial revision.";
    reference
      "[I-D.veillette-core-yang-library]  Constrained YANG Module Library";
  }
  
  /*
   * Typedefs
   */

  typedef revision-identifier {
    type binary {
      length "4";
    }
    description
      "Revision date encoded as a binary string, each nibble representing
       a digit of the of revision date. For example, revision 2018-09-21
       is encoded as 0x20 0x18 0x09 0x21.";
  }

  /*
   * Groupings
   */

  grouping module-identification-leafs {
    description
      "Parameters for identifying YANG modules and submodules.";

    leaf identifier {
      type sid:sid;
      mandatory true;
      description
        "SID assigned to this module or submodule.";
    }
    leaf revision {
      type revision-identifier;
      description
        "The YANG module or submodule revision date.  If no revision
         statement is present in the YANG module or submodule, this
         leaf is not instantiated.";
    }
  }

  grouping location-leaf-list {
    description
      "Common location leaf list parameter for modules and
       submodules.";

    leaf-list location {
      type inet:uri;
      description
        "Contains a URL that represents the YANG schema resource
         for this module or submodule.

         This leaf is present in the model to keep the alignment with
         'ietf-yang-library'. Support of this leaf in constrained
         devices is not necessarily required, nor expected. It is
         recommended that clients used the module or sub-module SID
         as the handle used to retrieve the corresponding YANG module";
    }
  }

  grouping implementation-parameters {
    description
      "Parameters for describing the implementation of a module.";

    leaf-list feature {
      type sid:sid;
      description
        "List of all YANG feature names from this module that are
         supported by the server, regardless whether they are defined
         in the module or any included submodule.";
    }
    leaf-list deviation {
      type leafref {
        path "../../module/identifier";
      }
      description
        "List of all YANG deviation modules used by this server to
         modify the conformance of the module associated with this
         entry.  Note that the same module can be used for deviations
         for multiple modules, so the same entry MAY appear within
         multiple 'module' entries.

         This reference MUST NOT (directly or indirectly)
         refer to the module being deviated.

         Robust clients may want to make sure that they handle a
         situation where a module deviates itself (directly or
         indirectly) gracefully.";
    }
  }

  grouping module-set-parameters {
    description
      "A set of parameters that describe a module set.";

    leaf index {
      type uint8;
      description
        "An arbitrary number assigned of the module set.";
    }
    list module {
      key "identifier";
      description
        "An entry in this list represents a module implemented by the
         server, as per RFC 7950 section 5.6.5, with a particular set
         of supported features and deviations.";
      reference
        "RFC 7950: The YANG 1.1 Data Modeling Language.";

      uses module-identification-leafs;

      leaf namespace {
        type inet:uri;
        description
          "The XML namespace identifier for this module.
           This leaf is present in the model to keep the alignment 
           with 'ietf-yang-library'. Support of this leaf in
           constrained devices is not required, nor expected.";
      }

      uses location-leaf-list;

      list submodule {
        key "identifier";
        description
          "Each entry represents one submodule within the parent
           module.";
        uses module-identification-leafs;
        uses location-leaf-list;
      }

      uses implementation-parameters;
    }
    list import-only-module {
      key "identifier revision";
      description
        "An entry in this list indicates that the server imports
         reusable definitions from the specified revision of the
         module, but does not implement any protocol accessible
         objects from this revision.

         Multiple entries for the same module name MAY exist.  This
         can occur if multiple modules import the same module, but
         specify different revision-dates in the import statements.";

      leaf identifier {
        type sid:sid;
        description
          "The YANG module name.";
      }
      leaf revision {
        type union {
          type revision-identifier;
          type string {
            length 0;
          }
        }
        description
          "The YANG module revision date.";
      }
      leaf namespace {
        type inet:uri;
        description
          "The XML namespace identifier for this module.
           This leaf is present in the model to keep the alignment 
           with 'ietf-yang-library'. Support of this leaf in
           constrained devices is not required, nor expected.";
      }

      uses location-leaf-list;

      list submodule {
        key "identifier";
        description
          "Each entry represents one submodule within the
           parent module.";

        uses module-identification-leafs;
        uses location-leaf-list;
      }
    }
  }

  grouping yang-library-parameters {
    description
      "The YANG library data structure is represented as a grouping
       so it can be reused in configuration or another monitoring
       data structure.";

    list module-set {
      key index;
      description
        "A set of modules that may be used by one or more schemas.

         A module set does not have to be referentially complete,
         i.e., it may define modules that contain import statements
         for other modules not included in the module set.";

      uses module-set-parameters;
    }

    list schema {
      key "index";
      description
        "A datastore schema that may be used by one or more
         datastores.

         The schema must be valid and referentially complete, i.e.,
         it must contain modules to satisfy all used import
         statements for all modules specified in the schema.";

      leaf index {
        type uint8;
        description
          "An arbitrary reference number assigned to the schema.";
      }
      leaf-list module-set {
        type leafref {
          path "../../module-set/index";
        }
        description
          "A set of module-sets that are included in this schema.
           If a non import-only module appears in multiple module
           sets, then the module revision and the associated features
           and deviations must be identical.";
      }
    }

    list datastore {
      key "identifier";
      description
        "A datastore supported by this server.

         Each datastore indicates which schema it supports.

         The server MUST instantiate one entry in this list per
         specific datastore it supports.

         Each datstore entry with the same datastore schema SHOULD
         reference the same schema.";

      leaf identifier {
        type ds:datastore-ref;
        description
          "The identity of the datastore.";
      }
      leaf schema {
        type leafref {
          path "../../schema/index";
        }
        mandatory true;
        description
          "A reference to the schema supported by this datastore.
           All non import-only modules of the schema are implemented
           with their associated features and deviations.";
      }
    }
  }

  /*
   * Top-level container
   */

  container yang-library {
    config false;
    description
      "Container holding the entire YANG library of this server.";

    uses yang-library-parameters;

    leaf checksum {
      type binary;
      mandatory true;
      description
        "A server-generated checksum or digest of the contents of the
         'yang-library' tree.  The server MUST change the value of
         this leaf if the information represented by the
         'yang-library' tree, except 'yang-library/checksum', has
         changed.";
    }
  }

  /*
   * Notifications
   */

  notification yang-library-update {
    description
      "Generated when any YANG library information on the
       server has changed.";

    leaf checksum {
      type leafref {
        path "/yanglib:yang-library/yanglib:checksum";
      }
      mandatory true;
      description
        "Contains the YANG library checksum or digest for the updated
         YANG library at the time the notification is generated.";
    }
  }
}
<CODE ENDS>
]]></artwork></figure>

</section>
<section anchor="iana-considerations" title="IANA Considerations">

<section anchor="yang-module-registry" title="YANG Module Registry">

<t>This document registers one YANG module in the YANG Module Names registry <xref target="RFC7950"/>.</t>

<t>name:         ietf-constrained-yang-library</t>

<t>namespace:    urn:ietf:params:xml:ns:yang:ietf-constrained-yang-library</t>

<t>prefix:       lib</t>

<t>reference:    RFC XXXX</t>

<t>// RFC Ed.: replace XXXX with RFC number and remove this note</t>

</section>
</section>
<section anchor="security-considerations" title="Security Considerations">

<t>Some of the readable data nodes in this YANG module may be considered sensitive or vulnerable in some network environments.  It is thus important to control read access to these data nodes.</t>

<t>Specifically, the ‘module’ list may help an attacker to identify the server capabilities and server implementations with known bugs. Server vulnerabilities may be specific to particular modules, module revisions, module features, or even module deviations.  This information is included in each module entry.  For example, if a particular operation on a particular data node is known to cause a server to crash or significantly degrade device performance, then the module list information will help an attacker to identify server implementations with such a defect, in order to launch a denial of service attack on these devices.</t>

</section>
<section anchor="acknowledgments" title="Acknowledgments">

<t>The YANG module defined by this memo have been derived from an already existing YANG module, ietf-yang-library <xref target="RFC8525"/>, we will like to thanks to the authors of this YANG module. A special thank also to Andy Bierman for his initial recommendations for the creation of this YANG module.</t>

</section>


  </middle>

  <back>

    <references title='Normative References'>





<reference  anchor='RFC2119' target='https://www.rfc-editor.org/info/rfc2119'>
<front>
<title>Key words for use in RFCs to Indicate Requirement Levels</title>
<author initials='S.' surname='Bradner' fullname='S. Bradner'><organization /></author>
<date year='1997' month='March' />
<abstract><t>In many standards track documents several words are used to signify the requirements in the specification.  These words are often capitalized. This document defines these words as they should be interpreted in IETF documents.  This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t></abstract>
</front>
<seriesInfo name='BCP' value='14'/>
<seriesInfo name='RFC' value='2119'/>
<seriesInfo name='DOI' value='10.17487/RFC2119'/>
</reference>



<reference  anchor='RFC7228' target='https://www.rfc-editor.org/info/rfc7228'>
<front>
<title>Terminology for Constrained-Node Networks</title>
<author initials='C.' surname='Bormann' fullname='C. Bormann'><organization /></author>
<author initials='M.' surname='Ersue' fullname='M. Ersue'><organization /></author>
<author initials='A.' surname='Keranen' fullname='A. Keranen'><organization /></author>
<date year='2014' month='May' />
<abstract><t>The Internet Protocol Suite is increasingly used on small devices with severe constraints on power, memory, and processing resources, creating constrained-node networks.  This document provides a number of basic terms that have been useful in the standardization work for constrained-node networks.</t></abstract>
</front>
<seriesInfo name='RFC' value='7228'/>
<seriesInfo name='DOI' value='10.17487/RFC7228'/>
</reference>



<reference  anchor='RFC7950' target='https://www.rfc-editor.org/info/rfc7950'>
<front>
<title>The YANG 1.1 Data Modeling Language</title>
<author initials='M.' surname='Bjorklund' fullname='M. Bjorklund' role='editor'><organization /></author>
<date year='2016' month='August' />
<abstract><t>YANG is a data modeling language used to model configuration data, state data, Remote Procedure Calls, and notifications for network management protocols.  This document describes the syntax and semantics of version 1.1 of the YANG language.  YANG version 1.1 is a maintenance release of the YANG language, addressing ambiguities and defects in the original specification.  There are a small number of backward incompatibilities from YANG version 1.  This document also specifies the YANG mappings to the Network Configuration Protocol (NETCONF).</t></abstract>
</front>
<seriesInfo name='RFC' value='7950'/>
<seriesInfo name='DOI' value='10.17487/RFC7950'/>
</reference>



<reference  anchor='RFC8340' target='https://www.rfc-editor.org/info/rfc8340'>
<front>
<title>YANG Tree Diagrams</title>
<author initials='M.' surname='Bjorklund' fullname='M. Bjorklund'><organization /></author>
<author initials='L.' surname='Berger' fullname='L. Berger' role='editor'><organization /></author>
<date year='2018' month='March' />
<abstract><t>This document captures the current syntax used in YANG module tree diagrams.  The purpose of this document is to provide a single location for this definition.  This syntax may be updated from time to time based on the evolution of the YANG language.</t></abstract>
</front>
<seriesInfo name='BCP' value='215'/>
<seriesInfo name='RFC' value='8340'/>
<seriesInfo name='DOI' value='10.17487/RFC8340'/>
</reference>



<reference  anchor='RFC8342' target='https://www.rfc-editor.org/info/rfc8342'>
<front>
<title>Network Management Datastore Architecture (NMDA)</title>
<author initials='M.' surname='Bjorklund' fullname='M. Bjorklund'><organization /></author>
<author initials='J.' surname='Schoenwaelder' fullname='J. Schoenwaelder'><organization /></author>
<author initials='P.' surname='Shafer' fullname='P. Shafer'><organization /></author>
<author initials='K.' surname='Watsen' fullname='K. Watsen'><organization /></author>
<author initials='R.' surname='Wilton' fullname='R. Wilton'><organization /></author>
<date year='2018' month='March' />
<abstract><t>Datastores are a fundamental concept binding the data models written in the YANG data modeling language to network management protocols such as the Network Configuration Protocol (NETCONF) and RESTCONF. This document defines an architectural framework for datastores based on the experience gained with the initial simpler model, addressing requirements that were not well supported in the initial model.  This document updates RFC 7950.</t></abstract>
</front>
<seriesInfo name='RFC' value='8342'/>
<seriesInfo name='DOI' value='10.17487/RFC8342'/>
</reference>



<reference  anchor='RFC8525' target='https://www.rfc-editor.org/info/rfc8525'>
<front>
<title>YANG Library</title>
<author initials='A.' surname='Bierman' fullname='A. Bierman'><organization /></author>
<author initials='M.' surname='Bjorklund' fullname='M. Bjorklund'><organization /></author>
<author initials='J.' surname='Schoenwaelder' fullname='J. Schoenwaelder'><organization /></author>
<author initials='K.' surname='Watsen' fullname='K. Watsen'><organization /></author>
<author initials='R.' surname='Wilton' fullname='R. Wilton'><organization /></author>
<date year='2019' month='March' />
<abstract><t>This document describes a YANG library that provides information about the YANG modules, datastores, and datastore schemas used by a network management server.  Simple caching mechanisms are provided to allow clients to minimize retrieval of this information.  This version of the YANG library supports the Network Management Datastore Architecture (NMDA) by listing all datastores supported by a network management server and the schema that is used by each of these datastores.</t></abstract>
</front>
<seriesInfo name='RFC' value='8525'/>
<seriesInfo name='DOI' value='10.17487/RFC8525'/>
</reference>




    </references>

    <references title='Informative References'>





<reference anchor='I-D.ietf-core-sid'>
<front>
<title>YANG Schema Item iDentifier (SID)</title>

<author initials='M' surname='Veillette' fullname='Michel Veillette'>
    <organization />
</author>

<author initials='A' surname='Pelov' fullname='Alexander Pelov'>
    <organization />
</author>

<author initials='I' surname='Petrov' fullname='Ivaylo Petrov'>
    <organization />
</author>

<date month='March' day='28' year='2019' />

<abstract><t>YANG Schema Item iDentifiers (SID) are globally unique 64-bit unsigned numbers used to identify YANG items.  This document defines the semantics, the registration, and assignment processes of SIDs. To enable the implementation of these processes, this document also defines a file format used to persist and publish assigned SIDs.</t></abstract>

</front>

<seriesInfo name='Internet-Draft' value='draft-ietf-core-sid-06' />
<format type='TXT'
        target='http://www.ietf.org/internet-drafts/draft-ietf-core-sid-06.txt' />
</reference>




    </references>




  </back>
</rfc>

