<?xml version="1.0"?>
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd'[
<!ENTITY RFC1213 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.1213.xml">
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC2863 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2863.xml">
<!ENTITY RFC2578 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2578.xml">
<!ENTITY RFC3410 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3410.xml">
<!ENTITY RFC3411 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3411.xml">
<!ENTITY RFC3414 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3414.xml">
<!ENTITY RFC3416 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3416.xml">
<!ENTITY RFC3418 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3418.xml">
<!ENTITY RFC3986 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3986.xml">
<!ENTITY RFC4088 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4088.xml">
<!ENTITY RFC4113 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4113.xml">
<!ENTITY RFC4291 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4291.xml">
<!ENTITY RFC4293 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4293.xml">
<!ENTITY RFC4944 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4944.xml">
<!ENTITY RFC6020 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6020.xml">
<!ENTITY RFC6241 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6241.xml">
<!ENTITY RFC6347 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6347.xml">
<!ENTITY RFC6643 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6643.xml">
<!ENTITY RFC6650 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6650.xml">
<!ENTITY RFC6775 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6775.xml">
<!ENTITY RFC6690 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6690.xml">
<!ENTITY RFC7049 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7049.xml">
<!ENTITY I-D.ietf-core-block SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-core-block.xml">
<!ENTITY I-D.ietf-core-coap SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-core-coap.xml">
<!ENTITY I-D.ietf-core-groupcomm SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-core-groupcomm.xml">
<!ENTITY I-D.ietf-core-interfaces SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-core-interfaces.xml">
<!ENTITY I-D.ietf-core-observe SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-core-observe.xml">
<!ENTITY I-D.ietf-json-rfc4627bis SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-json-rfc4627bis.xml">
<!ENTITY I-D.becker-core-coap-sms-gprs SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.becker-core-coap-sms-gprs">
<!ENTITY I-D.ersue-constrained-mgmt SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ersue-constrained-mgmt.xml">
<!ENTITY I-D.lhotka-netmod-yang-json SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.lhotka-netmod-yang-json.xml">
<!ENTITY I-D.schoenw-6lowpan-mib SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.schoenw-6lowpan-mib.xml">
<!ENTITY I-D.bierman-netconf-restconf SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.bierman-netconf-restconf.xml">
]>


<?rfc toc="yes"?>
<?rfc symrefs="yes" ?>

<rfc category="info" ipr="trust200902" docName="draft-vanderstok-core-comi-02">
  <front>
    <title abbrev="CoMI">CoAp Management Interfaces</title>
    <author initials="P." surname="van der Stok" fullname="Peter van der Stok">
      <organization abbrev="consultant">consultant</organization>
      <address>
        <phone>+31-492474673 (Netherlands), +33-966015248 (France)</phone>
        <email>consultancy@vanderstok.org</email>
        <uri>www.vanderstok.org</uri>
      </address>
    </author>
    <author initials="B." surname="Greevenbosch" fullname="Bert Greevenbosch">
        <organization abbrev="Huawei Technologies">Huawei Technologies Co., Ltd.</organization>
         <address>
              <postal>
                   <street>Huawei Industrial Base</street>
                   <street>Bantian, Longgang District</street>
                   <city>Shenzhen</city>
                   <code>518129</code>
                   <country>P.R. China</country>
               </postal>
               <email>bert.greevenbosch@huawei.com</email>
          </address>
      </author>

    <date day="9" month="January" year="2014"/>
    <area>Applications</area>
    <workgroup>core</workgroup>
    <abstract>
      <t>
         The draft describes an interface based on CoAP to manage constrained devices via MIBs.
     The proposed integration of CoAP with SNMP reduces the code- and application development complexity by accessing MIBs via a standard CoAP server.
     The payload of the MIB request is CBOR based on JSON. The mapping from SMI to CBOR is specified.
      </t>
    </abstract>
    <note title="Note">
      <t>
        Discussion and suggestions for improvement are requested,
        and should be sent to core@ietf.org.
      </t>
    </note>
  </front>
  <middle>

<section anchor="introduction" title="Introduction">
<t>
          The Constrained RESTful Environments (CoRE) working group aims at Machine to Machine (M2M) applications such as smart energy and building control.
</t>
<t>
Small M2M devices need to be managed in an automatic fashion to handle the large quantities of devices that are expected to be installed in future installations.
 The management protocol of choice for Internet is SNMP <xref target="RFC3410"/> as is testified by the large number of Management Information Base (MIB) <xref target="RFC3418"/>  specifications
 currently published <xref target="STD0001"/>. More recently, the NETCONF protocol <xref target="RFC6241"/> was developed with an
extended set of messages using XML <xref target="XML"/> as data format.
 The data syntax is specified with YANG <xref target="RFC6020"/> and a mapping from Yang to XML is specified.
In <xref target="RFC6643"/>  SMIv2 syntax is expressed in Yang.
Contrary to SNMP and also CoAP, NETCONF assumes persistent connections for example provided by SSH.
The NETCONF protocol provides operations to retrieve, configure, copy, and delete configuration data-stores.
Configuring data-stores distinguishes NETCONF from SNMP which operates on standardized MIBs.
</t>
<t>
The CoRE Management Interface (CoMI) is intended to work on standardized data-sets in a stateless client-server fashion and is thus closer to SNMP than to NETCONF. Standardized data sets promote interoperability between small devices and applications from different manufacturers.
Stateless communication is encouraged to keep communications simple and the amount of state information small in line with the design objectives
 of 6lowpan <xref target="RFC4944"/> <xref target="RFC6775"/>, RPL <xref target="RFC6650"/>, and CoAP <xref target="I-D.ietf-core-coap"/>.
</t>
<t>
The draft <xref target="I-D.bierman-netconf-restconf"/> describes a restful interface to NETCONF data stores and approaches the CoMI approach. CoMI uses SMI encoded in CBOR, and CoAP/UDP to access MIBs, where restconf uses YANG encoded in JSON and HTTP/TCP to access NETCONF data stores. CoMI is more low resource oriented than restconf is.
</t>
<t>
Currently, managed devices need to support two protocols: CoAP and SNMP.
When the MIB can be accessed with the CoAP protocol, the SNMP protocol can be replaced with the CoAP protocol.
This arrangement reduces the code complexity of the stack in the constrained device, and harmonizes applications development.
</t>
<t>
The objective of CoMI is to provide a CoAP based Function Set that reads and sets values of MIB variables in devices to (1) initialize parameter values at start-up, (2) acquire statistics during operation, and (3) maintain nodes by adjusting parameter values during operation.
</t><t>
The payload of CoMI is encoded in CBOR <xref target="RFC7049"/> which similar to JSON <xref target="JSON"/>,
but has a binary format and hence has more coding efficiency.
CoMI is intended for small devices. The JSON overhead can be prohibitive.
It is therefore chosen to transport CBOR in the payload.
CBOR, like BER used for SNMP, transports the data type in the payload. 
</t>

<t>
The end goal of CoMI is to provide information exchange over the CoAP transport protocol in a uniform manner to
 approach the full management functionality as specified in <xref target="I-D.ersue-constrained-mgmt"/>.
</t>

<section anchor="terminology" title="Terminology">
<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>
Readers of this specification are required to be familiar with all the terms and concepts discussed in <xref target="RFC3410"/>, <xref target="RFC3416"/>, and <xref target="RFC2578"/>.
</t><t>
Core Management Interface (CoMI) specifies the profile of Function Sets which access MIBs with the purpose of managing the operation of constrained devices in a network.
</t>
<t>
  The following list defines the terms used in this document:
  <list style="hanging">
    <t hangText="Managing Entity:">
      An entity that manages one or more managed devices.   
      Within the CoMI framework,
      the managing entity acts as a CoAP client for CoMI.
    </t>
    <t hangText="Managed Device:">
      An entity that is being managed.
      The managed device acts as a CoAP server for CoMI.
    </t>
  </list>
</t>
<t>
  NOTE:
  It is assumed that the managed device is the most constrained entity.
  The managing entity might be more capable,
  however this is not necessarily the case.
</t>
<t>
  The following list contains the abbreviations used in this document.
  <list style="hanging">
    <t hangText="OID:">ASN.1 OBJECT-IDENTIFIER, which is used  to uniquely identify MIB objects in the managed device.</t>
  </list>
</t>
</section>

</section>

<section anchor="coap-interface" title="CoAP Interface">
<t>

In CoRE a group of links can constitute a Function Set. The format of the links is specified in <xref target="I-D.ietf-core-interfaces"/>.
  This note specifies a Management Function Set. CoMI end-points that implement the CoMI management protocol support
 at least one discoverable management resource of resource type (rt): core.mg, with path: /mg, where mg is short-hand for management.
The mg resource has two sub-resources accessible with the paths:
<list style="symbols">
<t>MIB with path /mg/mib and a CBOR content format. </t>
<t>XLAT with path /mg/xlat and CBOR content format. </t>
</list>

The mib resource provides access to the MIBs as described in <xref target="comiFS"/>. The xlat resource provides access to a string to CBOR identifier table as described in <xref target="STRING-CBOR"/>. The mib and xlat resources are introduced as sub resources to mg to permit later additions to CoMI mg resource.
</t><t>
The profile of the management function set, with IF=core.mg.mib, is shown in the table below, following the guidelines of <xref target="I-D.ietf-core-interfaces"/>:
</t>

  <texttable>
  <ttcol align="left">name</ttcol>
  <ttcol align="left">path</ttcol>
   <ttcol align="left">RT</ttcol>
  <ttcol align="left">Data Type</ttcol>

  <c> Management     </c>   <c> /mg </c> <c> core.mg </c> <c> n/a </c>
  <c> MIB     </c>   <c> /mg/mib </c> <c> core.mg.mib </c> <c> application/cbor </c>
<c> XLAT     </c>   <c> /mg/xlat </c> <c> core.mg.xlat </c> <c> application/cbor </c>
</texttable>

</section>

<section anchor="mibFS" title="MIB Function Set">
  <t>
The MIB Function Set provides a CoAP interface to perform equivalent functions to the ones provided by SNMP. <xref target="snmp-architecture"/> explains
the structure of SNMP Protocol Data Units (PDU), their transport, and the structure of the MIB modules. An excellent overview of the documents describing the SNMP/MIB architecture is provided in section 7 of <xref target="RFC3410"/>.
 </t>

<section anchor="snmp-architecture" title="SNMP/MIB architecture">
  <t>
The architecture of the Internet Standard management framework consists of:
<list style="symbols">
<t>A data definition language that is referred to as Structure of Management Information (SMI)<xref target="RFC2578"/>. </t>
<t>The Management Information Base (MIB) which contains the information to be managed and is defined for each specific function to be managed <xref target="RFC3418"/>. </t>
<t>A protocol definition referred to as Simple Network Management Protocol (SNMP) <xref target="RFC3416"/>. </t>
<t>Security and administration that provides SNMP message based security on the basis of the user-based security model <xref target="RFC3414"/>. </t>
<t>A management domain definition where a SNMP entity has access to a collection of management information called a "context" <xref target="RFC3411"/>.</t>
</list>
In addition <xref target="RFC4088"/> describes a URI scheme to refer to a specific MIB instance.
</t><t>
Separation in modules was motivated by the wish to respond to the evolution of Internet. The protocol part (SNMP) and data definition part (MIB) are independent of each other.
 The separation has enabled the progressive passage from SNMPv1 via SNMPv2 to SNMPv3. This draft leverages this separation to replace the SNMP protocol with a CoAP based protocol.
</t>

<section anchor="snmp" title="SNMP functions">
<t>
The SNMP protocol supports seven types of access supported by as many Protocol Data Unit (PDU) types:
<list style="symbols">

<t>Get Request, transmits a list of OBJECT-IDENTIFIERs to be paired with values. </t>
<t>GetNext Request, transmits a list of OBJECT-IDENTIFIERs to which lexicographic successors are returned for table traversal. </t>
<t>GetBulk Request, transmits a list of OBJECT-IDENTIFIERs and the maximum number of expected paired values. </t>
<t>Response, returns an error or the (OBJECT-IDENTIFIER, value) pairs for the OBJECT-IDENTIFIERs specified in Get, GetNext, GetBulk, Set, or Inform Requests. </t>
<t>Set Request, transmits a list of (OBJECT-IDENTIFIERs, value) pairs to be set in the specified MIB object. </t>
<t>Trap, sends an unconfirmed message with a list of (OBJECT-IDENTIFIERs, value) pairs to a notification requesting end-point. </t>
<t>Inform Request, sends a confirmed message with a list of (OBJECT-IDENTIFIERs, value) pairs to a notification requesting end-point. </t>
</list>
The binding of the notification to a destination is discussed in <xref target="MIB-trap"/>.
</t>
</section>

<section anchor="mib" title="MIB structure">

<t>
A MIB module is composed of MIB objects. MIB objects are standardized by the IETF or by other relevant Standards Developing Organizations (SDO).
</t><t>
MIB objects have a descriptor and an identifier: OBJECT-IDENTIFIER (OID). The identifier, following the OSI hierarchy, is an ordered list of non-negative numbers <xref target="RFC2578"/>. OID values are unique. Each number in the list is referred as a sub-identifier. The descriptor is unique within a module. Different modules may contain the same descriptor. Consequently, a descriptor can be related to several OIDs.
</t><t>
Many instances of an object type exist within a management domain. Each instance can be identified within some scope or "context", where there are multiple such
contexts within the management domain. Often, a context is a
physical or logical device. A context is always defined as
a subset of a single SNMP entity. To identify an
individual item of management information within the management
domain, its contextName and contextEngineID must be identified in
addition to its object type and its instance. A default context is assumed when no context is specified.
</t><t>
A MIB object is usually a scalar object. A MIB object may have a tabular form with rows and columns. Such an object is composed of a sequence of rows, with each row composed of a sequence of typed values. The index is a subset (1-2 items) of the typed values in the row. An index value identifies the row in the table.
      </t>
      <t>
        In SMI,
        a table is constructed as a SEQUENCE OF its entries.
        For example,
        the IpAddrTable from <xref target="RFC4293"/> has the following definition:
      </t>
<figure><artwork align="left">
<![CDATA[
ipv6InterfaceTable OBJECT-TYPE
  SYNTAX                      SEQUENCE OF Ipv6InterfaceEntry
  MAX-ACCESS                  not-accessible
  STATUS                      current
  DESCRIPTION
    "The table containing per-interface IPv6-specific
    information."
::= { ip 30 }

ipv6InterfaceEntry OBJECT-TYPE
  SYNTAX                      Ipv6InterfaceEntry
  MAX-ACCESS                  not-accessible
  STATUS current
  DESCRIPTION
    "An entry containing IPv6-specific information for a given
    interface."
  INDEX { ipv6InterfaceIfIndex }
::= { ipv6InterfaceTable 1 }

Ipv6InterfaceEntry ::= SEQUENCE {
  ipv6InterfaceIfIndex        InterfaceIndex,
  ipv6InterfaceReasmMaxSize   Unsigned32,
  ipv6InterfaceIdentifier     Ipv6AddressIfIdentifierTC,
  ipv6InterfaceEnableStatus   INTEGER,
  ipv6InterfaceReachableTime  Unsigned32,
  ipv6InterfaceRetransmitTime Unsigned32,
  ipv6InterfaceForwarding     INTEGER
}
]]>
</artwork></figure>
      <t>
        The descriptor (name) of the MIB table is used for the name of the CoMI variable.
        However,
        there is no explicit mention of the names "ipv6InterfaceEntry" and "Ipv6InterfaceEntry".
        Instead,
        the value of the main CoMI variable consists of an array,
        each element of which contains 7 CoMI variables:
        one element for "ipv6InterfaceIfIndex", one for "ipv6InterfaceReasmMaxSize"
        and so on until "ipv6InterfaceForwarding".

</t>
</section>
</section>

<section anchor="comiFS" title="CoMI Function Set">
<t>
Two types of interfaces are supported by CoMI:
<list style="hanging"> 
<t hangText="single value"> Reading/Writing one MIB variable, specified in the URI with path /mg/mib/descriptor or with path /mg/mib/OID.
  </t>
<t hangText="multiple values"> Reading writing arrays or multiple MIB variables, specified in the payload. </t>
</list>

The examples in this section use a JSON payload with one or more entries describing the pair (descriptor, value), or (OID, value). The CBOR syntax of the payloads is specified in <xref target="mapping"/>.
</t>

<section anchor="single-MIB" title="Single MIB values">

<t>
A request to read the value of a MIB variable is sent with a confirmable CoAP GET message. The single MIB variable is specified in the URI path with the OID or descriptor suffixing the /mg/mib/ path name. When the descriptor is used to specify the MIB value, the same descriptor may be present in multiple module. To disambiguate the descriptor the "mod" uri-query attribute specifies the enveloping modules.
A request to set the value of a MIB variable is sent with a confirmable CoAP PUT message.
The Response is piggybacked to the CoAP ACK message corresponding with the Request.
</t><t>
TODO: for multicast send unconfirmed PUT
</t><t>
Using for example the same MIB from <xref target="RFC1213"/> as used in <xref target="RFC3416"/>, a request is sent to retrieve the value of sysUpTime specified in module SNMPv2-MIB. The answer to the request returns a (descriptor, value) pair.
</t><t>
For clarity of the examples, in this and all following examples the payload is expressed in JSON, although the operational payload is specified to be in CBOR, as described in <xref target="mapping"/>.
</t>

 <figure>
    <artwork align="left"><![CDATA[

REQ: GET example.com/mg/mib/sysUpTime?mod=SNMPv2-MIB

RES: 2.05 Content (Content-Format: application/json)
{
    "sysUpTime" : 123456
}
]]></artwork>
    </figure>
<t>
Another way to express the descriptor of the required value is by specifying the pair (descriptor or oid, null value) in the payload of the request message.
</t>

 <figure>
    <artwork align="left"><![CDATA[

REQ: GET example.com/mg/mib/(Content-Format: application/json)
{
    "SNMPv2-MIB.sysUpTime" : "null"
}

RES: 2.05 Content (Content-Format: application/json)
{
    "SNMPv2-MIB.sysUpTime" : 123456
}
]]></artwork>
    </figure>
<t>

The module name SNMPv2-MIB can be omitted when there is no possibility of ambiguity. The module.descriptor can of course be replaced with the corresponding oid.
</t><t>
In some cases it is necessary to determine the "context" by specifying a context name and a contextEngine identifier. The context can be specified in the URI with the uri-query attribute "con". Based on the example of figure 3 in section 3.3 of <xref target="RFC3411"/>, the context name, bridge1, and the context Engine Identifier, 800002b804616263, separated by an underscore, are specified in the following example:
</t>

 <figure>
    <artwork align="left"><![CDATA[

REQ: GET example.com/mg/mib/sysUPTime?con=bridge1_800002b804616263

RES: 2.05 Content (Content-Format: application/json)
{
    "sysUpTime" : 123456
}
]]></artwork>
    </figure>
<t>
The specified object can be a table. The returned payload is composed of all the rows associated with the table. Each row is returned as a set of (column name, value) pairs. For example the GET of the ipNetToMediaTable, sent by the managing entity, results in the following returned payload sent by the managed entity:
      </t>

<figure><artwork align="left">
<![CDATA[
REQ: GET example.com/mg/mib/ipNetToMediaTable

RES: 2.05 Content (Content-Format: application/json)
{
   "ipNetTOMediaTable" : [
     {
	"ipNetToMediaIfIndex" : 1,
	"ipNetToMediaPhysAddress" : "00:00::10:01:23:45",
	"ipNetToMediaNetAddress" : "10.0.0.51",
	"ipNetToMediaType" : "static"
	},
     {
	"ipNetToMediaIfIndex" : 1,
	"ipNetToMediaPhysAddress" : "00:00::10:54:32:10",
	"ipNetToMediaNetAddress" : "9.2.3.4",
	"ipNetToMediaType" : "dynamic"
      },
      {
	"ipNetToMediaIfIndex" : 2,
	"ipNetToMediaPhysAddress" : "00:00::10:98:76:54",
	"ipNetToMediaNetAddress" : "10.0.0.15",
	"ipNetToMediaType" : "dynamic"
      }
    ]
}
]]></artwork></figure>


<t>
It is possible that the size of the returned payload is too large to fit in a single message.
</t><t>
CoMI gives the possibility to send the contents of the objects in several fragments with a maximum size.
The "sz" link-format attribute <xref target="RFC6690"/> can be used to specify the expected maximum size of the mib resource in (identifier, value) pairs.
The returned data MUST terminate with a complete (identifier, value) pair.
</t><t>
  In the case that management data is bigger than the maximum supported payload size,
  the Block mechanism from <xref target="I-D.ietf-core-block"/> is used.
  Notice that the Block mechanism splits the data at fixed positions,
  such that individual data fields may become fragmented.
  Therefore,  assembly of multiple blocks may be required to process the complete data field.
</t>

</section>

<section anchor="multi-MIB" title="multi MIB values">
<t>
A request to read multiple MIB variables is done by expressing the pairs (MIB descriptor, null) in the payload of the GET request message. A request to set multiple MIB variables is done by expressing the pairs (MIB descriptor, null value) in the payload of the PUT request message. The key word _multiMIB is used as array name to signal that the payload contains multiple MIB values as separate _multiMIB array entries.
</t><t>
The following example shows a request that specifies to return the values of sysUpTime and ipNetToMediaTable:
</t>
<figure><artwork align="left">
<![CDATA[
REQ: GET example.com/mg/mib (Content-Format: application/json)
{
   "_multiMIB" : [
     { "sysUpTime" : "null"},
     { "ipNetToMediaTable" : "null" }
    ]
}

RES: 2.05 Content (Content-Format: application/json)
{
   "_multiMIB" : [
   { "sysUpTime" : 123456},
   { "ipNetTOMediaTable" : [
     {
	"ipNetToMediaIfIndex" : 1,
	"ipNetToMediaPhysAddress" : "00:00::10:01:23:45",
	"ipNetToMediaNetAddress" : "10.0.0.51",
	"ipNetToMediaType" : "static"
	},
     {
	"ipNetToMediaIfIndex" : 1,
	"ipNetToMediaPhysAddress" : "00:00::10:54:32:10",
	"ipNetToMediaNetAddress" : "9.2.3.4",
	"ipNetToMediaType" : "dynamic"
      },
      {
	"ipNetToMediaIfIndex" : 2,
	"ipNetToMediaPhysAddress" : "00:00::10:98:76:54",
	"ipNetToMediaNetAddress" : "10.0.0.15",
	"ipNetToMediaType" : "dynamic"
      }
    ]
    }
   ]
}
]]></artwork></figure>

</section>

<section anchor="table-row" title="Table row">
<t>
        The managing entity MAY be interested only in certain table entries.
One way to specify a row is to specify its row number in the URI with the "row" uri-query attribute. The specification of row=1 returns row 1 values of the ipNetToMediaTable in the example:
</t>

<figure><artwork align="left">
<![CDATA[
REQ: GET example.com/mg/mib/ipNetToMediaTable?row=1

RES: 2.05 Content (Content-Format: application/json)
{ "ipNetTOMediaTable" : [
     {
	"ipNetToMediaIfIndex" : 1,
	"ipNetToMediaPhysAddress" : "00:00::10:01:23:45",
	"ipNetToMediaNetAddress" : "10.0.0.51",
	"ipNetToMediaType" : "static"
	}
    ]
}
]]></artwork></figure>
      <t>

An alternative mode of selection is by specifying the value of the INDEX attributes.
        Towards this end,
        the managing entity can include the required entries in the payload of its "GET" request by specifying the values of the index attributes. The key word _indexMIB is used to specify the index value.
      </t>
      <t>
        For example,
        to obtain a table entry from ipNetToMediaTable, the rows are specified by specifying the index attributes: ipNetToMediaIfIndex and ipNetToMediaNetAddress.
        The managing entity could have sent a GET with the following payload:
      </t>

<figure><artwork align="left">
<![CDATA[
REQ: GET example.com/mg/mib/ipNetToMediaTable(Content-Format: application/json)

{ "_indexMIB" :
     {
      "ipNetToMediaIfIndex" : 1,
      "ipNetToMediaNetAddress" : "9.2.3.4"
     }
}

RES: 2.05 Content (Content-Format: application/json)
{ "ipNetTOMediaTable" : [
     {
	"ipNetToMediaIfIndex" : 1,
	"ipNetToMediaPhysAddress" : "00:00::10:01:23:45",
	"ipNetToMediaNetAddress" : "9.2.3.4",
	"ipNetToMediaType" : "static"
	}
    ]
}

]]></artwork></figure>
      
      <t>
        Constrained devices MAY support this kind of filtering.
        However, if they don't support it,
        they MUST ignore the payload in the GET request and handle the message as if the payload was empty.
      </t>
      <t>
        It is advised to keep MIBs for constrained entities as simple as possible,
        and therefore it would be best to avoid extensive tables.
</t><t>
TODO: Describe how the contents of the next lexicographical row can be returned.
</t>
</section>

<section anchor="error" title="Error returns">
<t>
When a variable with the specified name cannot be processed, CoAP Error code 5.01 is returned. In addition, a MIB specific error can be returned in the payload as specified in <xref target="ERRORS"/>.
</t>

</section>

</section>

</section>

<section anchor="mapping" title="Mapping SMI to CoMI payload">
<t>
The SMI syntax is mapped to CBOR necessary for the transport of MIB data in the CoAP payload. This section first describes an additional data reduction technique by creating a table that maps string values to numbers used in CBOR encoded data.
</t><t>
 The section continues by describing the mapping from SMI to CBOR. The mapping is inspired by the mapping from SMI to JSON via YANG <xref target="RFC6020"/>, as described in 
<xref target="RFC6643"/> defining a mapping from SMI to YANG, and <xref target="I-D.lhotka-netmod-yang-json"/> defining a mapping from YANG to JSON.
  </t>
  <t>
    Notice that such conversion chain MAY be virtual only,
    as SMI could be converted directly to JSON by combining the rules from the above documents.
</t>

<section anchor="STRING-CBOR" title="Mapping strings to CBOR">
<t>
    Because descriptors may be rather long and may occur repeatedly,
    CoMI allows for association of a string with an integer,
    henceforth called "string number".
    The association between string and string number is done through a translation table, leveraging CBOR encoding.
  </t>
  <t>
    Using the notational convention from <xref target="notConv"/>,
    the CBOR data has the following syntax:
</t>
<figure><artwork align="left">
<![CDATA[
cBorMIB       : CBorMIB;

*CBorMIB {
  xlatTableID : uint;
  mibString   : map( uint, . );
}
]]></artwork></figure>
<t>
    The main structure consist of an array of two elements:
    "xlatTableID" and "mibString".
  </t>
  <t>
    The values of the MIB strings are stored in the "mibString" field.
    This field consist of integer-value pairs.
    The integers correspond to the string numbers,
    whereas the values contain the actual value of the associated string.
  </t>
  <t>
    The "xlatTableID" contains an integer that is used to indentify the translation table.
    The translation table can be acquired as follows:
  </t>
  <t>
    GET /mg/xlat/[xlatTableID]
  </t>
  <t>
    where "[xlatTableID]" is replaced by the the value of xlatId from the CBorMIB structure,
    encoded as a hexidecimal integer without leading zeros.
  </t><t>
The maintenance of the table is described in <xref target="CONV-TABLE"/>.
</t><t>
The use of the table is to initialize devices with the strings which will be frequently used, such as the strings of the descriptors in the MIB variables. The transmitted CBOR data will contain the string numbers and not the entire descriptor strings, leading to appreciable data reduction.
</t><t>
It is important that sender and receiver have identical versions of the table.
</t>
  <t>
    The translation table is serialized to the payload in the following fashion:
<figure><artwork align="left">
<![CDATA[
xlatTable     : XLatTable;

*XLatTable {
  xlatId      : uint;
  xlatData    : map( uint, tstr );
} 
]]></artwork></figure>
    where "xlatId" has the same value as "xlatId" in the CBorMIB structure,
    and "xlatData" is a CBOR map between the string number and associated variable descriptor.
  </t>
</section>

<section anchor="CBOR-mapping" title="Mapping SMI to CBOR">
  <section title="General overview">
  <t>
    Starting from the intermediate conversion from SMI to YANG as defined in <xref target="RFC6643"/>,
    This section defines how to convert the resulting YANG structure to CBOR <xref target="RFC7049"/>.
    The actual conversion code from SMI to YANG and subsequently YANG to CBOR MAY be direct conversion code from SMI to CBOR or a sequence of existing SMI to YANG conversion code followed by YANG to CBOR conversion code.
  </t>
  
  </section>
  <section title="Conversion from YANG datatypes to CBOR datatypes">
    <t>
      <xref target="YANG-CBOR"/> defines the mapping between YANG datatypes and CBOR datatypes.
    </t>
    <t>    
      Elements of types not in this table,
      and of which the type cannot be inferred from a type in this table,
      are ignored in the CBOR encoding by default.
      Examples include the "description" and "key" elements.
      However, conversion rules for some elements to CBOR MAY be defined elsewhere.
    </t>
  <texttable anchor="YANG-CBOR" title="Conversion of YANG datatypes to CBOR">
    <ttcol align="left">YANG type</ttcol>
    <ttcol align="left">CBOR type</ttcol>
    <ttcol align="left">Specification</ttcol>
    
    <c>int8, int16, int32, int64, uint16, uint32, uint64, decimal64</c>
    <c>unsigned int (major type 0) or negative int (mayor type 1)</c>
    <c>The CBOR integer type depends on the sign of the actual value.</c>
    
    <c>boolean</c>
    <c>either "true" (major type 7, simple value 21) or "false" (major type 7, simple value 20)</c>
    <c></c>
    
    <c>string</c>
    <c>text string (major type 3)</c>
    <c></c>
    
    <c>enumeration</c>
    <c>unsigned int (major type 0)</c>
    <c></c>
    
    <c>bits</c>
    <c>array of text strings</c>
    <c>Each text string contains the name of a bit value that is set.</c>
    
    <c>binary</c>
    <c>byte string (major type 2)</c>
    <c></c>
    
    <c>empty</c>
    <c>null (major type 7, simple value 22)</c>
    <c>TBD: This MAY not be applicable to true MIBs, as SNMP may not support empty variables...</c>
    
    <c>union</c>
    <c></c>
    <c>
      Similar ot the JSON transcription from <xref target="I-D.lhotka-netmod-yang-json"/>,
      the elements in a union MUST be determined using the procedure specified in section 9.12 of <xref target="RFC6020"/>.
    </c>
   
    <c>leaf-list</c>
    <c>array (major type 4)</c>
    <c>The array is encapsulated in the map associated with the descriptor.</c>
    
    <c>list</c>
    <c>map (major type 4)</c>
    <c>      
      Like the higher level map,
      the lower level map contains descriptor number - value pairs of the elements in the list.
    </c>
    
    <c>container</c>
    <c>map (major type 5)</c>
    <c>The map contains decriptor number - value pairs corresponding to the elements in the container.</c>
    
    <c>smiv2:oid</c>
    <c>array of integers</c>
    <c>
      Each integer contains an element of the OID,
      the first integer in the array corresponds to the most left element in the OID.
    </c>


  </texttable>    
  </section>
  <section title="Examples">
    <section title="ipNetToMediaTable to JSON/CBOR">
      <t>
        The YANG translation of the SMI specifying the ipNetToMediaTable yields:
</t>
<figure><artwork align="left">
<![CDATA[
container ipNetToMediaTable {
    list ipNetToMediaEntry {
       leaf ipNetToMediaIfIndex {
          type: int32;
       }
       leaf ipNetToPhysAddress {
          type: phys-address;
       }
       leaf ipNetToMediaNetAddress {
          type: ipv4-address;
       }
       leaf ipNetToMediaType {
          type: int32;
       }
    }
 }
]]></artwork></figure>
      <t>
        The coresponding JSON looks like:
</t>
<figure><artwork align="left">
<![CDATA[
{ 
"ipNetToMediaTable" : {
	"ipNetToMediaEntry" : [
		{
		"ipNetToMediaIfIndex" : 1.
		"ipNetToMediaPhysAddress" : "00:00::10:01:23:45",
		"ipNetToMediaNetAddress" : "10.0.0.51",
		"ipNetToMediaType" : "static"
		},
		{
		"ipNetToMediaIfIndex " : 1,
		"ipNetToMediaPhysAddress " : "00:00::10:54:32:10",
		"ipNetToMediaNetAddress" : "9.2.3.4",
		"ipNetToMediaType " : "dynamic"
		}
	]
	}
}
]]></artwork></figure>        
      <t>
        An example CBOR instance of the MIB can be found in <xref target="ExInterfaceIndex"/>. The names "ipNetToMediaTable", "ipNetToMediaEntry", and "ipNetToMediaIfIndex" are represented with the string numbers  00, 01, and 02 as described in <xref target="STRING-CBOR"/>.

</t>        
<figure anchor="ExInterfaceIndex" title="Example CBOR encoding for ifTable"><artwork align="left">
<![CDATA[
82                         # two element array
   19 43 A1                # translation table ID 43A1
   BF                      # indefinite length map
     00                    # descriptor number related to 
                           # ipNetToMediaTable
     BF                    # indefinite length map related to
                           # ipNetToMediaTable
        01                 # descriptor number related to
                           # ipNetToMediaEntry
        BF                 # map related to ipNetToMediaEntry
           02              # descriptor number associated with
                           # ipNetToMediaIfIndex
           1A 00 00 00 01  # associated value as 32-bit integer
           # ...
        FF
     FF
   FF
]]></artwork></figure>
<t>
The associated "descriptor string" to "string number" translation table is given in <xref target="XLAT_InterfaceIndex"/>.

      </t>
<figure anchor="XLAT_InterfaceIndex" title="Translation table for ifTable"><artwork align="left">
<![CDATA[
82                         # two element array
   19 43 A1                # translation table ID 43A1
   BF                      # indefinite length map
      00                   # descriptor number related to 
                           # ipNetToMediaTable
      72 69 70 50 65 74 57
      6F 51 65 64 61 57 61
      62 6C 65             # "ipNetToMediaTable"
      01                   # descriptor number related to
                           # ipNetToMediaEntry
      72 69 70 50 65 74 57
      6F 51 65 64 61 45 6E
      74 72 78 			       # "ipNetToMediaEntry"
      02                   # descriptor number related to
                           # ipNetToMediaIfIndex
      75 69 70 50 65 74 57
      6F 51 65 64 61 61 49
      66 49 6E 64 65 77    # "ipNetToMediaIfIndex"
      # ...
   FF
]]></artwork></figure>
      
    </section>
  </section>
  <section title="6LoWPAN MIB">
    <t>
      A MIB for 6LoWPAN is defined in <xref target="I-D.schoenw-6lowpan-mib"/>.
      The document also provides an example JSON representation in its Appendix A.
      <xref target="Ex6LOWPAN"/> shows the associated CBOR representation with string number, and <xref target="XLAT_6LOWPAN"/> shows the corresponding string to string number conversion table.
</t>
<!--
BERT: the below is the conversion from the JSON representation to CBOR.
It seems that Juergen has used a list with name "LOWPAN-MIB:LOWPAN-MIB"
to represent all 6LoWPAN MIB variables.
However, I cannot find which rule form the SMIv2 -> YANG draft he applied.
We may need to request his feedback on this.
-->
<figure anchor="Ex6LOWPAN" title="Example CBOR encoding for the 6LoWPAN MIB"><artwork align="left">
<![CDATA[
82                         # two element array
   1A 8B 47 88 F3          # translation table ID 8B4788F3
   BF                      # indefinite length map
     00                    # "LOWPAN-MIB:LOWPAN-MIB"
     BF                    # indefinite length map related to ifTable
        01                 # "lowpanReasmTimeout"
        14                 # 20
        02                 # "lowpanInReceives"
        18 2A              # 42
        03                 # "lowpanInHdrErrors"
        00                 # 0
        04                 # "lowpanInMeshReceives"
        08                 # 8
        05                 # "lowpanInMeshForwds"
        00                 # 0
        06                 # "lowpanInMeshDelivers"
        00                 # 0
        07                 # "lowpanInReasmReqds"
        16                 # 22
        08                 # "lowpanInReasmFails"
        02                 # 02
        09                 # "lowpanInReasmOKs"
        14                 # 20
        0A                 # "lowpanInCompReqds"
        10                 # 16
        0B                 # "lowpanInCompFails"
        02                 # 2
        0C                 # "lowpanInCompOKs"
        0E                 # 14
        0D                 # "lowpanInDiscards"
        01                 # 01
        0E                 # "lowpanInDelivers"
        0C                 # 12
        0F                 # "lowpanOutRequests"
        0C                 # 12
        10                 # "lowpanOutCompReqds"
        00                 # 0
        11                 # "lowpanOutCompFails"
        00                 # 0
        12                 # "lowpanOutCompOKs"
        00                 # 0
        13                 # "lowpanOutFragReqds"
        05                 # 5
        14                 # "lowpanOutFragFails"
        00                 # 0
        15                 # "lowpanOutFragOKs"
        05                 # 5
        16                 # "lowpanOutFragCreates"
        08                 # 8
        17                 # "lowpanOutMeshHopLimitExceeds"
        00                 # 0
        18 18              # "lowpanOutMeshNoRoutes"
        00                 # 0
        18 19              # "lowpanOutMeshRequests"
        00                 # 0
        18 1A              # "lowpanOutMeshForwds"
        00                 # 0
        18 1B              # "lowpanOutMeshTransmits"
        00                 # 0
        18 1C              # "lowpanOutDiscards"
        00                 # 0
        18 1D              # "lowpanOutTransmits"
        0F                 # 15
     FF
   FF
]]></artwork></figure>

<figure anchor="XLAT_6LOWPAN" title="Translation table for the 6LoWPAN MIB"><artwork align="left">
<![CDATA[
82                         # two element array
   1A 8B 47 88 F3          # translation table ID 8B4788F3
   BF                      # indefinite length map
      00
      75                   # "LOWPAN-MIB:LOWPAN-MIB"
      01                   # 
      72 ...               # "lowpanReasmTimeout"
      02
      70 ...               # "lowpanInReceives"
      03
      71 ...               # "lowpanInHdrErrors"
      04
      74 ...               # "lowpanInMeshReceives"
      05
      72 ...               # "lowpanInMeshForwds"
      06
      74 ...               # "lowpanInMeshDelivers"
      07
      72 ...               # "lowpanInReasmReqds"
      08
      72 ...               # "lowpanInReasmFails"
      09
      70 ...               # "lowpanInReasmOKs"
      0A
      71 ...               # "lowpanInCompReqds"
      0B
      71 ...               # "lowpanInCompFails"
      0C
      6F ...               # "lowpanInCompOKs"
      0D
      70 ...               # "lowpanInDiscards"
      0E
      70 ...               # "lowpanInDelivers"
      0F
      71 ...               # "lowpanOutRequests"
      10
      72 ...               # "lowpanOutCompReqds"
      11
      72 ...               # "lowpanOutCompFails"
      12
      70 ...               # "lowpanOutCompOKs"
      13
      72 ...               # "lowpanOutFragReqds"
      14
      72 ...               # "lowpanOutFragFails"
      15
      70 ...               # "lowpanOutFragOKs"
      16
      74 ...               # "lowpanOutFragCreates"
      17
      78 1B ...            # "lowpanOutMeshHopLimitExceeds"
      18 18
      75 ...               # "lowpanOutMeshNoRoutes"
      18 19
      75 ...               # "lowpanOutMeshRequests"
      18 1A
      73 ...               # "lowpanOutMeshForwds"
      18 1B
      76 ...               # "lowpanOutMeshTransmits"
      18 1C
      71 ...               # "lowpanOutDiscards"
      18 1D
      72 ...               # "lowpanOutTransmits"
   FF
]]></artwork></figure>    
    <t>
      In this example,
      a GET to /mg/mib/lowpanOutFragFails would give:      
    </t>  
<figure><artwork align="left">
<![CDATA[
82                         # two element array
   1A 8B 47 88 F3          # translation table ID 8B4788F3
   BF                      # indefinite length map
     14                    # "lowpanOutFragFails"
     00                    # 0
   FF
]]></artwork></figure>    
  </section>  
</section>

</section>

<section anchor="discovery" title="MIB discovery">

<t>
MIB objects are discovered like resources with the standard CoAP resource discovery. Performing a GET on "/.well-known/core" with rt=core.mg.mib returns all MIB descriptors and all OIDs which are available on this device. For table objects there is no further possibility to discover the row descriptors.
For example, consider there are two MIB objects with descriptors "sysUpTime" and "ipNetToMediaTable" associated with OID 1.3.6.1.2.1.1.3  and 1.3.6.1.2.1.4.22
</t>

<figure>
  <artwork align="left"><![CDATA[
REQ: GET example.com/.well-known/core?rt=core.mg.mib

RES: 2.05 Content (Content-Format: application/text)
</mg/mib/sysUpTime>;rt="core.mg.mib";oid="1.3.6.1.2.1.1.3";mod="SNMPv2-MIB"
</mg/mib/ipNetToMediaTable>;rt="core.mg.mib";oid="1.3.6.1.2.1.4.22";mod="ipMIB"
]]></artwork></figure>
<t>
The link format attribute 'oid' is used to associate the name of the MIB resource with its OID.
  The OID is written as a string in its conventional form.
</t>
<t>
  Notice that a MIB variable normally is associated with a descriptor and an OID.
  The OID is unique,
  whereas the descriptor is unique in combination with the module name.
</t><t>
The "mod", "con", and "rt" attributes can be used to filter resource queries as specified in <xref target="RFC6690"/>.
</t>
</section>

<section anchor="MIB-trap" title="Trap functions">
<t>
  A trap can be set through the CoAP Observe <xref target="I-D.ietf-core-observe"/> function.
  As regular with Observe,
  the managing entity subscribes to the variable by sending a GET request with an "Observe" option.
</t><t>
TODO: Observe example
</t><t>
  In the registration request,
  the managing entity MAY include a "Response-To-Uri-Host" and optionally "Response-To-Uri-Port" option as defined in
  <xref target="I-D.becker-core-coap-sms-gprs"/>.
  In this case,
  the observations SHOULD be sent to the address and port indicated in these options.
  This can be useful when the managing entity wants the managed device to send the trap information to a multicast address.
</t>
</section>

<section anchor="MIB-access" title="MIB access management">
<t>
Two topics are relevant: (1) the definition of the destination of Notify messages, and (2) the creation and maintenance of "string to number" tables.
</t>
<section anchor="NOT-DEST" title="Notify destinations">
<t>
The destination of notifications need to be communicated to the applications sending them.
Draft <xref target="I-D.ietf-core-interfaces"/> describes the binding of end-points to end-points on remote devices.
The object with type "binding table" contains a sequence of bindings. The contents of bindings contains the methods, location, the interval specifications, and
the step value as suggested in <xref target="I-D.ietf-core-interfaces"/>.
The method "notify" has been added to the binding methods "poll", "obs" and "push", to cater for the binding of notification source to the receiver.
</t><t>
TODO: describe interface for NOTIFY destination definition. 
</t>
</section>
<section anchor="CONV-TABLE" title="Conversion tables">
<t>
POST is used to initialize a conversion table. At the arrival of the POST, all existing tables are removed and new tables as specified by the payload are created with the contents specified in the payload. When the payload of the POST is empty, no table is created.
</t><t>
PUT is used to create new entries in an existing table and overwrite existing entries. When the payload of the PUT contains a non existing table, a new table with the new identity is created. When the payload of the PUT contains a table with an already existing identifier, two possiblities exist:
<list style="hanging"> 
<t hangText="exiting string value"> the contents of the existing pair is overwritten with the pair in the payload.
  </t>
<t hangText="new string value"> A new pair is created in the table with the pair in the payload. </t>
</list>
  </t>
</section>
</section>
  
<section anchor="ERRORS" title="Error handling">
  <t>
    In case a request is received which cannot be processed properly,
    the managed entity MUST return an error message.
    This error message MUST contain a CoAP 4.xx or 5.xx response code,
    and SHOULD include additional information in the payload.
  </t>
  <t>
    Such an error message payload is encoded in CBOR,
    using the following structure:
  </t>
<figure><artwork align="left">
<![CDATA[
errorMsg     : ErrorMsg;

*ErrorMsg {
  errorCode  : uint;
  ?errorText : tstr;
}
]]></artwork></figure>
  <t>
    The variable "errorCode" has one of the values from the table below,
    and the OPTIONAL "errorText" field contains a human readible explanation of the error.
  </t>
  
    <texttable>
      <ttcol align="left">CoMI Error Code</ttcol>
      <ttcol align="left">CoAP Error Code</ttcol>
      <ttcol align="left">Description</ttcol>
      
      <c>0</c>
      <c>4.00</c>
      <c>General error</c>

      <c>1</c>
      <c>4.00</c>
      <c>Malformed CBOR data</c>
      
      <c>2</c>
      <c>4.00</c>
      <c>Incorrect CBOR datatype</c>
      
      <c>3</c>
      <c>4.00</c>
      <c>Unknown MIB variable</c>
      
      <c>4</c>
      <c>4.00</c>
      <c>Unknown translation table</c>

      <c>5</c>
      <c>4.05</c>
      <c>Attempt to write read-only variable</c>

  	<c>0..2</c>
      <c>5.01</c>
      <c>Access exceptions</c>

	<c>0..18</c>
	<c>5.00</c>
	<c> SMI error status </c>
    </texttable>

<t>
The CoAP error code 5.01 is associted with the exceptions defined in <xref target="RFC3416"/> and CoAP error code 5.00 is associated with the error-status defined in <xref target="RFC3416"/>.
</t>
  
</section>

<section title="Security Considerations">
<t>
TODO: follows CoAP security provisioning.
</t>

</section>

<section  title="IANA Considerations">  
  <t>
    'rt="core.mg.mib"' needs registration with IANA.
  </t>
  <t>
    Content types to be registered:
    <list style="symbols">
      <t>application/comi+json</t>
      <t>application/comi+cbor</t>
    </list>
  </t>
</section>

<section title="Acknowledgements">
<t>
Mehmet Ersue and Bert Wijnen explained the encoding aspects of PDUs transported under SNMP. Carsten Bormann has given feedback on the use of CBOR. Juergen Schoenwalder has commented on inconsistencies and missing aspects of SNMP in earlier versions of the draft.
The draft has benefited from comments by Thomas Watteyne, Dee Denteneer, Esko Dijk, and Michael van Hartskamp.
The CBOR encoding borrows extensively from Ladislav Lhotka's description on conversion from YANG to JSON.
</t>
</section>

<section title="Changelog">
<t>
Changes from version 00 to version 01
<list style="symbols">
<t> Focus on MIB only</t>
<t> Introduced CBOR, JSON, removed BER </t>
<t> defined mappings from SMI to xx </t>
<t> Introduced the concept of addressable table rows </t>
</list>
</t>
<t>
Changes from version 01 to version 02
<list style="symbols">
<t> Focus on CBOR, used JSON for examples, removed XML and EXI</t>
<t> added uri-query attributes mod and con to specify modules and contexts </t>
<t> Definition of CBOR string conversion tables for data reduction </t>
<t> use of Block for multiple fragments </t>
<t> Error returns generalized </t>
<t> SMI - YANG - CBOR conversion </t>
</list>
</t>
</section>

</middle>
  <back>
    <references title="Normative References">
      &RFC2119;
      &RFC6020;
      &RFC7049;
      &I-D.becker-core-coap-sms-gprs;
      &I-D.ietf-core-block;
      &I-D.ietf-core-coap;
      &I-D.ietf-core-observe;
      &I-D.ietf-json-rfc4627bis;
      &I-D.lhotka-netmod-yang-json;
    </references>
    <references title="Informative References">
	    &RFC1213;
      &RFC2578;
      &RFC2863;
      &RFC3410;
	    &RFC3411;
      &RFC3414;
      &RFC3416;
      &RFC3418;
	    &RFC3986;
	    &RFC4088;
      &RFC4113;
      &RFC4291;
      &RFC4293;
      &RFC4944;
      &RFC6241;
      &RFC6347;
      &RFC6643;
      &RFC6650;
      &RFC6690;
      &RFC6775;            
      &I-D.ietf-core-groupcomm;
      &I-D.ietf-core-interfaces;
      &I-D.ersue-constrained-mgmt;
      &I-D.schoenw-6lowpan-mib;
	 &I-D.bierman-netconf-restconf;
       <reference anchor="STD0001">
        <front>
          <title>Official Internet Protocols Standard</title>
    <author />
        <date />
          </front>
          <seriesInfo name="Web" value="http://www.rfc-editor.org/rfcxx00.html"/>
        </reference>
  <reference anchor="XML">
        <front>
          <title>Extensible Markup Language (XML)</title>
        <author />
        <date />
          </front>
          <seriesInfo name="Web" value="http://www.w3.org/xml"/>
        </reference>
  <reference anchor="JSON">
        <front>
          <title>JavaScript Object Notation (JSON)</title>
	  <author />
        <date />
          </front>
          <seriesInfo name="Web" value="http://www.json.org"/>
        </reference>

    </references>




<section title="Notational Convention for CBOR data" anchor="notConv">
  <t>
    To express CBOR structures <xref target="RFC7049"/>,
    this document uses the following conventions:
  </t>
  <t>
    A declaration of a CBOR variable has the form:
<figure><artwork align="left"><![CDATA[
   name : datatype;
]]></artwork></figure>
    where "name" is the name of the variable,
    and "datatype" its CBOR datatype.
  </t>
  <t>
    The name of the variable has no encoding in the CBOR data.
  </t>
  <t>
    "datatype" can be a CBOR primitive such as:
    <list style="hanging">    
      <t hangText="tstr:">A text string (major type 3)</t>
      <t hangText="uint:">An unsigned integer (major type 0)</t>
      <t hangText="map(x,y):">
        A map (major type 5), where each first element of a pair is of datatype x, and each second element of datatype y.
        A '.' character for either x or y means that all datatypes for that element are valid.
      </t>
    </list>
  </t>
  <t>
    A datatype can also be a CBOR structure,
    in which case the variable's "datatype" field contains the name of the CBOR structure.
    Such CBOR structure is defined by a character sequence consisting of first its name,
    then a '{' character,
    then its subfields
    and finally a '}' character.
  </t>
  <t>
    A CBOR structure can be encapsulated in an array,
    in which case its name in its definition is preceeded by a '*' character.
    Otherwise the structure is just a grouping of fields,
    but without actual encoding of such grouping.
  </t>
  <t>
    The name of an optional field is preceded by a '?' character.
    This means,
    that the field may be omitted if not required.
  </t>
</section>

  </back>

</rfc>
