draft-ietf-core-yang-cbor-10.txt   draft-ietf-core-yang-cbor-11.txt 
Internet Engineering Task Force M. Veillette, Ed. Internet Engineering Task Force M. Veillette, Ed.
Internet-Draft Trilliant Networks Inc. Internet-Draft Trilliant Networks Inc.
Intended status: Standards Track I. Petrov, Ed. Intended status: Standards Track I. Petrov, Ed.
Expires: October 10, 2019 A. Pelov Expires: March 12, 2020 A. Pelov
Acklio Acklio
April 08, 2019 September 09, 2019
CBOR Encoding of Data Modeled with YANG CBOR Encoding of Data Modeled with YANG
draft-ietf-core-yang-cbor-10 draft-ietf-core-yang-cbor-11
Abstract Abstract
This document defines encoding rules for serializing configuration This document defines encoding rules for serializing configuration
data, state data, RPC input and RPC output, Action input, Action data, state data, RPC input and RPC output, Action input, Action
output and notifications defined within YANG modules using the output, notifications and yang data template defined within YANG
Concise Binary Object Representation (CBOR) [RFC7049]. modules using the Concise Binary Object Representation (CBOR)
[RFC7049].
Status of This Memo Status of This Memo
This Internet-Draft is submitted in full conformance with the This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79. provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/. Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on October 10, 2019. This Internet-Draft will expire on March 12, 2020.
Copyright Notice Copyright Notice
Copyright (c) 2019 IETF Trust and the persons identified as the Copyright (c) 2019 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents Provisions Relating to IETF Documents
(https://trustee.ietf.org/license-info) in effect on the date of (https://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License. described in the Simplified BSD License.
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3
2. Terminology and Notation . . . . . . . . . . . . . . . . . . 3 2. Terminology and Notation . . . . . . . . . . . . . . . . . . 3
3. Properties of the CBOR Encoding . . . . . . . . . . . . . . . 4 3. Properties of the CBOR Encoding . . . . . . . . . . . . . . . 5
3.1. CBOR diagnostic notation . . . . . . . . . . . . . . . . 5 3.1. CBOR diagnostic notation . . . . . . . . . . . . . . . . 5
3.2. YANG Schema Item iDentifier (SID) . . . . . . . . . . . . 6 3.2. YANG Schema Item iDentifier (SID) . . . . . . . . . . . . 6
3.3. Name . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.3. Name . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4. Encoding of YANG Schema Node Instances . . . . . . . . . . . 9 4. Encoding of YANG Schema Node Instances . . . . . . . . . . . 9
4.1. The 'leaf' . . . . . . . . . . . . . . . . . . . . . . . 9 4.1. The 'leaf' . . . . . . . . . . . . . . . . . . . . . . . 9
4.2. The 'container' and other collections . . . . . . . . . . 9 4.1.1. Using SIDs in keys . . . . . . . . . . . . . . . . . 9
4.2.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . 10 4.1.2. Using names in keys . . . . . . . . . . . . . . . . . 9
4.2.2. Names as keys . . . . . . . . . . . . . . . . . . . . 11 4.2. The 'container' and other collections . . . . . . . . . . 10
4.2.1. Using SIDs in keys . . . . . . . . . . . . . . . . . 11
4.2.2. Using names in keys . . . . . . . . . . . . . . . . . 12
4.3. The 'leaf-list' . . . . . . . . . . . . . . . . . . . . . 13 4.3. The 'leaf-list' . . . . . . . . . . . . . . . . . . . . . 13
4.4. The 'list' and 'list' instance(s) . . . . . . . . . . . . 14 4.3.1. Using SIDs in keys . . . . . . . . . . . . . . . . . 14
4.4.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . 15 4.3.2. Using names in keys . . . . . . . . . . . . . . . . . 14
4.4.2. Names as keys . . . . . . . . . . . . . . . . . . . . 17 4.4. The 'list' and 'list' instance(s) . . . . . . . . . . . . 15
4.5. The 'anydata' . . . . . . . . . . . . . . . . . . . . . . 19 4.4.1. Using SIDs in keys . . . . . . . . . . . . . . . . . 16
4.6. The 'anyxml' . . . . . . . . . . . . . . . . . . . . . . 21 4.4.2. Using names in keys . . . . . . . . . . . . . . . . . 18
5. Encoding of YANG data templates . . . . . . . . . . . . . . . 22 4.5. The 'anydata' . . . . . . . . . . . . . . . . . . . . . . 20
5.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . . . 23 4.5.1. Using SIDs in keys . . . . . . . . . . . . . . . . . 21
5.2. Names as keys . . . . . . . . . . . . . . . . . . . . . . 24 4.5.2. Using names in keys . . . . . . . . . . . . . . . . . 22
6. Representing YANG Data Types in CBOR . . . . . . . . . . . . 25 4.6. The 'anyxml' . . . . . . . . . . . . . . . . . . . . . . 23
6.1. The unsigned integer Types . . . . . . . . . . . . . . . 25 4.6.1. Using SIDs in keys . . . . . . . . . . . . . . . . . 23
6.2. The integer Types . . . . . . . . . . . . . . . . . . . . 26 4.6.2. Using names in keys . . . . . . . . . . . . . . . . . 24
6.3. The 'decimal64' Type . . . . . . . . . . . . . . . . . . 26 5. Encoding of YANG data templates . . . . . . . . . . . . . . . 24
6.4. The 'string' Type . . . . . . . . . . . . . . . . . . . . 27 5.1. Using SIDs in keys . . . . . . . . . . . . . . . . . . . 25
6.5. The 'boolean' Type . . . . . . . . . . . . . . . . . . . 27 5.2. Using names in keys . . . . . . . . . . . . . . . . . . . 26
6.6. The 'enumeration' Type . . . . . . . . . . . . . . . . . 27 6. Representing YANG Data Types in CBOR . . . . . . . . . . . . 27
6.7. The 'bits' Type . . . . . . . . . . . . . . . . . . . . . 28 6.1. The unsigned integer Types . . . . . . . . . . . . . . . 27
6.8. The 'binary' Type . . . . . . . . . . . . . . . . . . . . 30 6.2. The integer Types . . . . . . . . . . . . . . . . . . . . 28
6.9. The 'leafref' Type . . . . . . . . . . . . . . . . . . . 30 6.3. The 'decimal64' Type . . . . . . . . . . . . . . . . . . 28
6.10. The 'identityref' Type . . . . . . . . . . . . . . . . . 31 6.4. The 'string' Type . . . . . . . . . . . . . . . . . . . . 29
6.10.1. SIDs as identityref . . . . . . . . . . . . . . . . 31 6.5. The 'boolean' Type . . . . . . . . . . . . . . . . . . . 29
6.10.2. Name as identityref . . . . . . . . . . . . . . . . 32 6.6. The 'enumeration' Type . . . . . . . . . . . . . . . . . 29
6.11. The 'empty' Type . . . . . . . . . . . . . . . . . . . . 32 6.7. The 'bits' Type . . . . . . . . . . . . . . . . . . . . . 30
6.12. The 'union' Type . . . . . . . . . . . . . . . . . . . . 33 6.8. The 'binary' Type . . . . . . . . . . . . . . . . . . . . 32
6.13. The 'instance-identifier' Type . . . . . . . . . . . . . 34 6.9. The 'leafref' Type . . . . . . . . . . . . . . . . . . . 32
6.13.1. SIDs as instance-identifier . . . . . . . . . . . . 34 6.10. The 'identityref' Type . . . . . . . . . . . . . . . . . 33
6.13.2. Names as instance-identifier . . . . . . . . . . . . 37 6.10.1. SIDs as identityref . . . . . . . . . . . . . . . . 33
7. Security Considerations . . . . . . . . . . . . . . . . . . . 39 6.10.2. Name as identityref . . . . . . . . . . . . . . . . 34
8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 39 6.11. The 'empty' Type . . . . . . . . . . . . . . . . . . . . 34
8.1. Tags Registry . . . . . . . . . . . . . . . . . . . . . . 39 6.12. The 'union' Type . . . . . . . . . . . . . . . . . . . . 35
9. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 40 6.13. The 'instance-identifier' Type . . . . . . . . . . . . . 36
10. References . . . . . . . . . . . . . . . . . . . . . . . . . 40 6.13.1. SIDs as instance-identifier . . . . . . . . . . . . 36
10.1. Normative References . . . . . . . . . . . . . . . . . . 40 6.13.2. Names as instance-identifier . . . . . . . . . . . . 39
10.2. Informative References . . . . . . . . . . . . . . . . . 40 7. Security Considerations . . . . . . . . . . . . . . . . . . . 41
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 41 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 41
8.1. CBOR Tags Registry . . . . . . . . . . . . . . . . . . . 41
9. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 41
10. References . . . . . . . . . . . . . . . . . . . . . . . . . 42
10.1. Normative References . . . . . . . . . . . . . . . . . . 42
10.2. Informative References . . . . . . . . . . . . . . . . . 42
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 43
1. Introduction 1. Introduction
The specification of the YANG 1.1 data modelling language [RFC7950] The specification of the YANG 1.1 data modeling language [RFC7950]
defines an XML encoding for data instances, i.e. contents of defines an XML encoding for data instances, i.e. contents of
configuration datastores, state data, RPC inputs and outputs, action configuration datastores, state data, RPC inputs and outputs, action
inputs and outputs, and event notifications. inputs and outputs, and event notifications.
A new set of encoding rules has been defined to allow the use of the A new set of encoding rules has been defined to allow the use of the
same data models in environments based on the JavaScript Object same data models in environments based on the JavaScript Object
Notation (JSON) Data Interchange Format [RFC7159]. This is Notation (JSON) Data Interchange Format [RFC8259]. This is
accomplished in the JSON Encoding of Data Modeled with YANG accomplished in the JSON Encoding of Data Modeled with YANG
specification [RFC7951]. specification [RFC7951].
The aim of this document is to define a set of encoding rules for the The aim of this document is to define a set of encoding rules for the
Concise Binary Object Representation (CBOR) [RFC7049]. The resulting Concise Binary Object Representation (CBOR) [RFC7049]. The resulting
encoding is more compact compared to XML and JSON and more suitable encoding is more compact compared to XML and JSON and more suitable
for Constrained Nodes and/or Constrained Networks as defined by for Constrained Nodes and/or Constrained Networks as defined by
[RFC7228]. [RFC7228].
2. Terminology and Notation 2. Terminology and Notation
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
document are to be interpreted as described in [RFC2119]. "OPTIONAL" in this document are to be interpreted as described in BCP
14 [RFC2119] [RFC8174] when, and only when, they appear in all
capitals, as shown here.
The following terms are defined in [RFC7950]: The following terms are defined in [RFC7950]:
o action o action
o anydata o anydata
o anyxml o anyxml
o data node o data node
skipping to change at page 5, line 8 skipping to change at page 5, line 23
a value. This specification supports two type of CBOR keys; YANG a value. This specification supports two type of CBOR keys; YANG
Schema Item iDentifier (SID) as defined in Section 3.2 and names as Schema Item iDentifier (SID) as defined in Section 3.2 and names as
defined in Section 3.3. Each of these key types is encoded using a defined in Section 3.3. Each of these key types is encoded using a
specific CBOR type which allows their interpretation during the specific CBOR type which allows their interpretation during the
deserialization process. Protocols or mechanisms implementing this deserialization process. Protocols or mechanisms implementing this
specification can mandate the use of a specific key type. specification can mandate the use of a specific key type.
In order to minimize the size of the encoded data, the proposed In order to minimize the size of the encoded data, the proposed
mapping avoids any unnecessary meta-information beyond those natively mapping avoids any unnecessary meta-information beyond those natively
supported by CBOR. For instance, CBOR tags are used solely in the supported by CBOR. For instance, CBOR tags are used solely in the
case of anyxml schema nodes and the union datatype to distinguish case of SID not encoded as delta, anyxml schema nodes and the union
explicitly the use of different YANG datatypes encoded using the same datatype to distinguish explicitly the use of different YANG
CBOR major type. datatypes encoded using the same CBOR major type.
Unless specified otherwise by the protocol or mechanism implementing Unless specified otherwise by the protocol or mechanism implementing
this specification, the infinite lengths encoding as defined in this specification, the indefinite lengths encoding as defined in
[RFC7049] section 2.2 SHALL be supported by CBOR decoders. [RFC7049] section 2.2 SHALL be supported by CBOR decoders.
Data nodes implemented using a CBOR array, map, byte string, and text Data nodes implemented using a CBOR array, map, byte string, and text
string can be instantiated but empty. In this case, they are encoded string can be instantiated but empty. In this case, they are encoded
with a length of zero. with a length of zero.
Application payloads carrying a value serialized using the rules Application payloads carrying a value serialized using the rules
defined by this specification (e.g. CoAP Content-Format) SHOULD defined by this specification (e.g. CoAP Content-Format) SHOULD
include the identifier (e.g. SID, namespace qualified name, include the identifier (e.g. SID, namespace qualified name,
instance-identifier) of this value. When SIDs are used as instance-identifier) of this value. When SIDs are used as
identifiers, the reference SID SHALL be included in the payload to identifiers, the reference SID SHALL be included in the payload to
allow stateless conversion of delta values to SIDs. Formats of these allow stateless conversion of delta values to SIDs.
application payloads are not defined by the current specification.
Examples in section Section 4 include a root CBOR map with a single
entry having a key set to either a namespace qualified name or a SID.
This root CBOR map is provided only as a typical usage example and is
not part of the present encoding rules. Only the value within this
CBOR map is compulsory.
3.1. CBOR diagnostic notation 3.1. CBOR diagnostic notation
Within this document, CBOR binary contents are represented using an Within this document, CBOR binary contents are represented using an
equivalent textual form called CBOR diagnostic notation as defined in equivalent textual form called CBOR diagnostic notation as defined in
[RFC7049] section 6. This notation is used strictly for [RFC7049] section 6. This notation is used strictly for
documentation purposes and is never used in the data serialization. documentation purposes and is never used in the data serialization.
Table 1 below provides a summary of this notation. Table 1 below provides a summary of this notation.
+----------+------+--------------------------+-----------+----------+ +----------+------+--------------------------+-----------+----------+
skipping to change at page 6, line 35 skipping to change at page 6, line 37
| | | curly braces | | 021901C8 | | | | curly braces | | 021901C8 |
| Boolean | 7/20 | false | false | F4 | | Boolean | 7/20 | false | false | F4 |
| | 7/21 | true | true | F5 | | | 7/21 | true | true | F5 |
| Null | 7/22 | null | null | F6 | | Null | 7/22 | null | null | F6 |
| Not | 7/23 | undefined | undefined | F7 | | Not | 7/23 | undefined | undefined | F7 |
| assigned | | | | | | assigned | | | | |
+----------+------+--------------------------+-----------+----------+ +----------+------+--------------------------+-----------+----------+
Table 1: CBOR diagnostic notation summary Table 1: CBOR diagnostic notation summary
The following extensions to the CBOR diagnostic notation are Note: CBOR binary contents shown in this specification are annotated
supported: with comments. These comments are delimited by slashes ("/") as
defined in [RFC8610] Appendix G.6.
o Any text within and including a pair of slashes is considered a
comment.
o Deltas are visualized as numbers preceded by a '+' or '-' sign.
The use of the '+' sign for positive deltas represents an
extension to the CBOR diagnostic notation as defined by [RFC7049]
section 6.
3.2. YANG Schema Item iDentifier (SID) 3.2. YANG Schema Item iDentifier (SID)
Some of the items defined in YANG [RFC7950] require the use of a Some of the items defined in YANG [RFC7950] require the use of a
unique identifier. In both NETCONF [RFC6241] and RESTCONF [RFC8040], unique identifier. In both NETCONF [RFC6241] and RESTCONF [RFC8040],
these identifiers are implemented using strings. To allow the these identifiers are implemented using strings. To allow the
implementation of data models defined in YANG in constrained devices implementation of data models defined in YANG in constrained devices
and constrained networks, a more compact method to identify YANG and constrained networks, a more compact method to identify YANG
items is required. This compact identifier, called YANG Schema Item items is required. This compact identifier, called YANG Schema Item
iDentifier (SID), is an unsigned integer. The following items are iDentifier (SID), is an unsigned integer. The following items are
skipping to change at page 7, line 20 skipping to change at page 7, line 17
o data nodes o data nodes
o RPCs and associated input(s) and output(s) o RPCs and associated input(s) and output(s)
o actions and associated input(s) and output(s) o actions and associated input(s) and output(s)
o notifications and associated information o notifications and associated information
o YANG modules, submodules and features o YANG modules, submodules and features
To minimize its size, in certain positions, SIDs are represented To minimize their size, SIDs used as keys in inner CBOR maps are
using a (signed) delta from a reference SID and the current SID. typically encoded using deltas. Conversion from SIDs to deltas and
Conversion from SIDs to deltas and back to SIDs are stateless back to SIDs are stateless processes solely based on the data
processes solely based on the data serialized or deserialized. serialized or deserialized. These SIDs may also be encoded as
absolute number when enclosed by CBOR tag 47.
Mechanisms and processes used to assign SIDs to YANG items and to Mechanisms and processes used to assign SIDs to YANG items and to
guarantee their uniqueness is outside the scope of the present guarantee their uniqueness are outside the scope of the present
specification. If SIDs are to be used, the present specification is specification. If SIDs are to be used, the present specification is
used in conjunction with a specification defining this management. used in conjunction with a specification defining this management.
One example for such a specification is under development as One example for such a specification is [I-D.ietf-core-sid].
[I-D.ietf-core-sid].
3.3. Name 3.3. Name
This specification also supports the encoding of YANG item This specification also supports the encoding of YANG item
identifiers as string, similar as those used by the JSON Encoding of identifiers as string, similar as those used by the JSON Encoding of
Data Modeled with YANG [RFC7951]. This approach can be used to avoid Data Modeled with YANG [RFC7951]. This approach can be used to avoid
the management overhead associated to SIDs allocation. The main the management overhead associated to SIDs allocation. The main
drawback is the significant increase is size of the encoded data. drawback is the significant increase in size of the encoded data.
YANG items identifiers implemented using names MUST be in one of the YANG item identifiers implemented using names MUST be in one of the
following forms: following forms:
o simple - the identifier of the YANG item (i.e. schema node or o simple - the identifier of the YANG item (i.e. schema node or
identity). identity).
o namespace qualified - the identifier of the YANG item is prefixed o namespace qualified - the identifier of the YANG item is prefixed
with the name of the module in which this item is defined, with the name of the module in which this item is defined,
separated by the colon character (":"). separated by the colon character (":").
The name of a module determines the namespace of all YANG items The name of a module determines the namespace of all YANG items
skipping to change at page 9, line 21 skipping to change at page 9, line 17
Schema node instances defined using the YANG modeling language are Schema node instances defined using the YANG modeling language are
encoded using CBOR [RFC7049] based on the rules defined in this encoded using CBOR [RFC7049] based on the rules defined in this
section. We assume that the reader is already familiar with both section. We assume that the reader is already familiar with both
YANG [RFC7950] and CBOR [RFC7049]. YANG [RFC7950] and CBOR [RFC7049].
4.1. The 'leaf' 4.1. The 'leaf'
A 'leaf' MUST be encoded accordingly to its datatype using one of the A 'leaf' MUST be encoded accordingly to its datatype using one of the
encoding rules specified in Section 6. encoding rules specified in Section 6.
The following examples shows the encoding of a 'hostname' leaf using
a SID or a name.
Definition example from [RFC7317]:
leaf hostname {
type inet:domain-name;
}
4.1.1. Using SIDs in keys
CBOR diagnostic notation:
{
1752 : "myhost.example.com" / hostname (SID 1752) /
}
CBOR encoding:
A1 # map(1)
19 06D8 # unsigned(1752)
72 # text(18)
6D79686F73742E6578616D706C652E636F6D # "myhost.example.com"
4.1.2. Using names in keys
CBOR diagnostic notation:
{
"ietf-system:hostname" : "myhost.example.com"
}
CBOR encoding:
A1 # map(1)
74 # text(20)
696574662D73797374656D3A686F73746E616D65
72 # text(18)
6D79686F73742E6578616D706C652E636F6D
4.2. The 'container' and other collections 4.2. The 'container' and other collections
Collections such as containers, list instances, notification Collections such as containers, list instances, notification
contents, rpc inputs, rpc outputs, action inputs and action outputs contents, rpc inputs, rpc outputs, action inputs and action outputs
MUST be encoded using a CBOR map data item (major type 5). A map is MUST be encoded using a CBOR map data item (major type 5). A map is
comprised of pairs of data items, with each data item consisting of a comprised of pairs of data items, with each data item consisting of a
key and a value. Each key within the CBOR map is set to a schema key and a value. Each key within the CBOR map is set to a schema
node identifier, each value is set to the value of this schema node node identifier, each value is set to the value of this schema node
instance according to the instance datatype. instance according to the instance datatype.
skipping to change at page 10, line 25 skipping to change at page 11, line 5
leaf current-datetime { leaf current-datetime {
type date-and-time; type date-and-time;
} }
leaf boot-datetime { leaf boot-datetime {
type date-and-time; type date-and-time;
} }
} }
} }
4.2.1. SIDs as keys 4.2.1. Using SIDs in keys
CBOR map keys implemented using SIDs MUST be encoded using a CBOR In the context of containers and other collections, CBOR map keys
unsigned integer (major type 0) or CBOR negative integer (major type within inner CBOR maps can be encoded using deltas or SIDs. In the
1), depending on the actual delta or to a SID preceded by the CBOR case of deltas, they MUST be encoded using a CBOR unsigned integer
tag 42. (major type 0) or CBOR negative integer (major type 1), depending on
the actual delta value. In the case of SID, they are encoded using
the SID value enclosed by CBOR tag 47 as defined in Section 8.1.
Delta values are computed as follows: Delta values are computed as follows:
o In the case of a 'container', deltas are equal to the SID of the o In the case of a 'container', deltas are equal to the SID of the
current schema node minus the SID of the parent 'container'. current schema node minus the SID of the parent 'container'.
o In the case of a 'list', deltas are equal to the SID of the o In the case of a 'list', deltas are equal to the SID of the
current schema node minus the SID of the parent 'list'. current schema node minus the SID of the parent 'list'.
o In the case of an 'rpc input' or 'rcp output', deltas are equal to o In the case of an 'rpc input' or 'rcp output', deltas are equal to
the SID of the current schema node minus the SID of the 'rpc'. the SID of the current schema node minus the SID of the 'rpc'.
o In the case of an 'action input' or 'action output', deltas are o In the case of an 'action input' or 'action output', deltas are
equal to the SID of the current schema node minus the SID of the equal to the SID of the current schema node minus the SID of the
'action'. 'action'.
o In the case of an 'notification content', deltas are equal to the o In the case of an 'notification content', deltas are equal to the
SID of the current schema node minus the SID of the SID of the current schema node minus the SID of the
'notification'. 'notification'.
This example assumes that the Media Type used to carry this container
consists of a CBOR map composed of the data node SID and data node
encoding. This root CBOR map is not part of the present encoding
rules and is not compulsory.
CBOR diagnostic notation: CBOR diagnostic notation:
{ {
1720 : { / system-state / 1720 : { / system-state (SID 1720) /
+1 : { / clock (SID 1721) / 1 : { / clock (SID 1721) /
+2 : "2015-10-02T14:47:24Z-05:00",/ current-datetime (SID 1723) / 2 : "2015-10-02T14:47:24Z-05:00", / current-datetime(SID 1723)/
+1 : "2015-09-15T09:12:58Z-05:00" / boot-datetime (SID 1722) / 1 : "2015-09-15T09:12:58Z-05:00" / boot-datetime (SID 1722) /
}
} }
} }
}
CBOR encoding: CBOR encoding:
A1 # map(1) A1 # map(1)
19 06B8 # unsigned(1720) 19 06B8 # unsigned(1720)
A1 # map(1) A1 # map(1)
01 # unsigned(1) 01 # unsigned(1)
A2 # map(2) A2 # map(2)
02 # unsigned(2) 02 # unsigned(2)
78 1A # text(26) 78 1A # text(26)
323031352D31302D30325431343A34373A32345A2D30353A3030 323031352D31302D30325431343A34373A32345A2D30353A3030
01 # unsigned(1) 01 # unsigned(1)
78 1A # text(26) 78 1A # text(26)
323031352D30392D31355430393A31323A35385A2D30353A3030 323031352D30392D31355430393A31323A35385A2D30353A3030
4.2.2. Names as keys Figure 2: System state clock encoding
4.2.2. Using names in keys
CBOR map keys implemented using names MUST be encoded using a CBOR CBOR map keys implemented using names MUST be encoded using a CBOR
text string data item (major type 3). A namespace-qualified name text string data item (major type 3). A namespace-qualified name
MUST be used each time the namespace of a schema node and its parent MUST be used each time the namespace of a schema node and its parent
differ. In all other cases, the simple form of the name MUST be differ. In all other cases, the simple form of the name MUST be
used. Names and namespaces are defined in [RFC7951] section 4. used. Names and namespaces are defined in [RFC7951] section 4.
The following example shows the encoding of a 'system' container The following example shows the encoding of a 'system' container
instance using names. instance using names.
skipping to change at page 12, line 25 skipping to change at page 12, line 52
leaf current-datetime { leaf current-datetime {
type date-and-time; type date-and-time;
} }
leaf boot-datetime { leaf boot-datetime {
type date-and-time; type date-and-time;
} }
} }
} }
This example assumes that the Media Type used to carry this container
consists of a CBOR map composed of the data node namespace qualified
name and data node encoding. This root CBOR map is not part of the
present encoding rules and is not compulsory.
CBOR diagnostic notation: CBOR diagnostic notation:
{ {
"ietf-system:system-state" : { "ietf-system:system-state" : {
"ietf-system:clock" : { "clock" : {
"current-datetime" : "2015-10-02T14:47:24Z-05:00", "current-datetime" : "2015-10-02T14:47:24Z-05:00",
"boot-datetime" : "2015-09-15T09:12:58Z-05:00" "boot-datetime" : "2015-09-15T09:12:58Z-05:00"
} }
} }
} }
CBOR encoding: CBOR encoding:
A1 # map(1) A1 # map(1)
78 18 # text(24) 78 18 # text(24)
696574662D73797374656D3A73797374656D2D7374617465 696574662D73797374656D3A73797374656D2D7374617465
A1 # map(1) A1 # map(1)
71 # text(17) 65 # text(5)
696574662D73797374656D3A636C6F636B 636C6F636B # "clock"
A2 # map(2) A2 # map(2)
70 # text(16) 70 # text(16)
63757272656E742D6461746574696D65 63757272656E742D6461746574696D65
78 1A # text(26) 78 1A # text(26)
323031352D31302D30325431343A34373A32345A2D30353A3030 323031352D31302D30325431343A34373A32345A2D30353A3030
6D # text(13) 6D # text(13)
626F6F742D6461746574696D65 626F6F742D6461746574696D65
78 1A # text(26) 78 1A # text(26)
323031352D30392D31355430393A31323A35385A2D30353A3030 323031352D30392D31355430393A31323A35385A2D30353A3030
skipping to change at page 13, line 46 skipping to change at page 14, line 19
*([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.? *([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?
)|\.'; )|\.';
} }
} }
leaf-list search { leaf-list search {
type domain-name; type domain-name;
ordered-by user; ordered-by user;
} }
CBOR diagnostic notation: [ "ietf.org", "ieee.org" ] 4.3.1. Using SIDs in keys
CBOR encoding: 82 68 696574662E6F7267 68 696565652E6F7267 CBOR diagnostic notation:
{
1746 : [ "ietf.org", "ieee.org" ] / search (SID 1746) /
}
CBOR encoding:
A1 # map(1)
19 06D2 # unsigned(1746)
82 # array(2)
68 # text(8)
696574662E6F7267 # "ietf.org"
68 # text(8)
696565652E6F7267 # "ieee.org"
4.3.2. Using names in keys
CBOR diagnostic notation:
{
"ietf-system:search" : [ "ietf.org", "ieee.org" ]
}
CBOR encoding:
A1 # map(1)
72 # text(18)
696574662D73797374656D3A736561726368 # "ietf-system:search"
82 # array(2)
68 # text(8)
696574662E6F7267 # "ietf.org"
68 # text(8)
696565652E6F7267 # "ieee.org"
4.4. The 'list' and 'list' instance(s) 4.4. The 'list' and 'list' instance(s)
A list or a subset of a list MUST be encoded using a CBOR array data A list or a subset of a list MUST be encoded using a CBOR array data
item (major type 4). Each list instance within this CBOR array is item (major type 4). Each list instance within this CBOR array is
encoded using a CBOR map data item (major type 5) based on the encoded using a CBOR map data item (major type 5) based on the
encoding rules of a collection as defined in Section 4.2. encoding rules of a collection as defined in Section 4.2.
It is important to note that this encoding rule also apply to a It is important to note that this encoding rule also apply to a
single 'list' instance. single 'list' instance.
skipping to change at page 15, line 42 skipping to change at page 16, line 42
leaf iburst { leaf iburst {
type boolean; type boolean;
default false; default false;
} }
leaf prefer { leaf prefer {
type boolean; type boolean;
default false; default false;
} }
} }
4.4.1. SIDs as keys 4.4.1. Using SIDs in keys
The encoding rules of each 'list' instance are defined in The encoding rules of each 'list' instance are defined in
Section 4.2.1. Deltas of list members are equal to the SID of the Section 4.2.1. Deltas of list members are equal to the SID of the
current schema node minus the SID of the 'list'. current schema node minus the SID of the 'list'.
This example assumes that the Media Type used to carry this list
consists of a CBOR map composed of the data node SID and data node
encoding. This root CBOR map is not part of the present encoding
rules and is not compulsory.
CBOR diagnostic notation: CBOR diagnostic notation:
{ {
1756 : [ / server (SID 1756) / 1756 : [ / server (SID 1756) /
{ {
+3 : "NRC TIC server", / name (SID 1759) / 3 : "NRC TIC server", / name (SID 1759) /
+5 : { / udp (SID 1761) / 5 : { / udp (SID 1761) /
+1 : "tic.nrc.ca", / address (SID 1762) / 1 : "tic.nrc.ca", / address (SID 1762) /
+2 : 123 / port (SID 1763) / 2 : 123 / port (SID 1763) /
}, },
+1 : 0, / association-type (SID 1757) / 1 : 0, / association-type (SID 1757) /
+2 : false, / iburst (SID 1758) / 2 : false, / iburst (SID 1758) /
+4 : true / prefer (SID 1760) / 4 : true / prefer (SID 1760) /
}, },
{ {
+3 : "NRC TAC server", / name (SID 1759) / 3 : "NRC TAC server", / name (SID 1759) /
+5 : { / udp (SID 1761) / 5 : { / udp (SID 1761) /
+1 : "tac.nrc.ca" / address (SID 1762) / 1 : "tac.nrc.ca" / address (SID 1762) /
} }
} }
] ]
} }
CBOR encoding: CBOR encoding:
A1 # map(1) A1 # map(1)
19 06DC # unsigned(1756) 19 06DC # unsigned(1756)
82 # array(2) 82 # array(2)
skipping to change at page 17, line 35 skipping to change at page 18, line 35
A2 # map(2) A2 # map(2)
03 # unsigned(3) 03 # unsigned(3)
6E # text(14) 6E # text(14)
4E52432054414320736572766572 # "NRC TAC server" 4E52432054414320736572766572 # "NRC TAC server"
05 # unsigned(5) 05 # unsigned(5)
A1 # map(1) A1 # map(1)
01 # unsigned(1) 01 # unsigned(1)
6A # text(10) 6A # text(10)
7461632E6E72632E6361 # "tac.nrc.ca" 7461632E6E72632E6361 # "tac.nrc.ca"
4.4.2. Names as keys 4.4.2. Using names in keys
The encoding rules of each 'list' instance are defined in The encoding rules of each 'list' instance are defined in
Section 4.2.2. Section 4.2.2.
This example assumes that the Media Type used to carry this container
consists of a CBOR map composed of the data node namespace qualified
name and data node encoding. This root CBOR map is not part of the
present encoding rules and is not compulsory.
CBOR diagnostic notation: CBOR diagnostic notation:
{ {
"ietf-system:server" : [ "ietf-system:server" : [
{ {
"name" : "NRC TIC server", "name" : "NRC TIC server",
"udp" : { "udp" : {
"address" : "tic.nrc.ca", "address" : "tic.nrc.ca",
"port" : 123 "port" : 123
}, },
skipping to change at page 20, line 41 skipping to change at page 21, line 41
notification example-port-fault { # SID 60200 notification example-port-fault { # SID 60200
leaf port-name { # SID 60201 leaf port-name { # SID 60201
type string; type string;
} }
leaf port-fault { # SID 60202 leaf port-fault { # SID 60202
type string; type string;
} }
} }
} }
This example assumes that the Media Type used to carry this anydata 4.5.1. Using SIDs in keys
consists of a CBOR map composed of the data node SID and data node
encoding. This root CBOR map is not part of the present encoding
rules and is not compulsory.
CBOR diagnostic notation: CBOR diagnostic notation:
{ {
60123 : { / last-event (SID=60123) / 60123 : { / last-event (SID 60123) /
+77 : { / event (SID=60200) / 77 : { / event (SID 60200) /
+1 : "0/4/21", / port-name (SID=60201) / 1 : "0/4/21", / port-name (SID 60201) /
+2 : "Open pin 2" / port-fault (SID=60202) / 2 : "Open pin 2" / port-fault (SID 60202) /
} }
} }
} }
CBOR encoding: CBOR encoding:
A1 # map(1) A1 # map(1)
19 EADB # unsigned(60123) 19 EADB # unsigned(60123)
A1 # map(1) A1 # map(1)
18 4D # unsigned(77) 18 4D # unsigned(77)
A2 # map(2) A2 # map(2)
18 4E # unsigned(78) 18 4E # unsigned(78)
66 # text(6) 66 # text(6)
302F342F3231 # "0/4/21" 302F342F3231 # "0/4/21"
skipping to change at page 21, line 33 skipping to change at page 22, line 23
302F342F3231 # "0/4/21" 302F342F3231 # "0/4/21"
18 4F # unsigned(79) 18 4F # unsigned(79)
6A # text(10) 6A # text(10)
4F70656E2070696E2032 # "Open pin 2" 4F70656E2070696E2032 # "Open pin 2"
In some implementations, it might be simpler to use the absolute SID In some implementations, it might be simpler to use the absolute SID
tag encoding for the anydata root element. The resulting encoding is tag encoding for the anydata root element. The resulting encoding is
as follow: as follow:
{ {
60123 : { / last-event (SID=60123) / 60123 : { / last-event (SID 60123) /
42(60200) : { / event (SID=60123) / 47(60200) : { / event (SID 60123) /
+1 : "0/4/21", / port-name (SID=60201) / 1 : "0/4/21", / port-name (SID 60201) /
+2 : "Open pin 2" / port-fault (SID=60202) / 2 : "Open pin 2" / port-fault (SID 60202) /
} }
} }
} }
4.5.2. Using names in keys
CBOR diagnostic notation:
{
"event-log:last-event" : {
"example-port: example-port-fault" : {
"port-name" : "0/4/21",
"port-fault" : "Open pin 2"
}
}
}
CBOR encoding:
A1 # map(1)
74 # text(20)
6576656E742D6C6F673A6C6173742D6576656E74
A1 # map(1)
78 20 # text(32)
6578616D706C652D706F72743A206578616D7
06C652D706F72742D6661756C74
A2 # map(2)
69 # text(9)
706F72742D6E616D65 # "port-name"
66 # text(6)
302F342F3231 # "0/4/21"
6A # text(10)
706F72742D6661756C74 # "port-fault"
6A # text(10)
4F70656E2070696E2032 # "Open pin 2"
4.6. The 'anyxml' 4.6. The 'anyxml'
An anyxml schema node is used to serialize an arbitrary CBOR content, An anyxml schema node is used to serialize an arbitrary CBOR content,
i.e., its value can be any CBOR binary object. anyxml value MAY i.e., its value can be any CBOR binary object. anyxml value MAY
contain CBOR data items tagged with one of the tag listed in contain CBOR data items tagged with one of the tag listed in
Section 8.1, these tags shall be supported. Section 8.1, these tags shall be supported.
The following example shows a valid CBOR encoded instance consisting The following example shows a valid CBOR encoded instance consisting
of a CBOR array containing the CBOR simple values 'true', 'null' and of a CBOR array containing the CBOR simple values 'true', 'null' and
'true'. 'true'.
Definition example from [RFC7951]: Definition example from [RFC7951]:
anyxml bar; module bar-module {
...
anyxml bar;
Note: This example assumes that the Media Type used to carry this 4.6.1. Using SIDs in keys
anyxml consists of a CBOR map composed of the data node SID and data
node encoding. This root CBOR map is not part of the present
encoding rules and is not compulsory.
CBOR diagnostic notation: CBOR diagnostic notation:
{ {
60000 : [true, null, true] / bar (SID 60000) / 60000 : [true, null, true] / bar (SID 60000) /
} }
CBOR encoding: CBOR encoding:
A1 # map(1) A1 # map(1)
19 EA60 # unsigned(60000) 19 EA60 # unsigned(60000)
83 # array(3) 83 # array(3)
F5 # primitive(21) F5 # primitive(21)
F6 # primitive(22) F6 # primitive(22)
F5 # primitive(21) F5 # primitive(21)
4.6.2. Using names in keys
CBOR diagnostic notation:
{
"bar-module:bar" : [true, null, true] / bar (SID 60000) /
}
CBOR encoding:
A1 # map(1)
6E # text(14)
6261722D6D6F64756C653A626172 # "bar-module:bar"
83 # array(3)
F5 # primitive(21)
F6 # primitive(22)
F5 # primitive(21)
5. Encoding of YANG data templates 5. Encoding of YANG data templates
YANG data templates are data structures defined in YANG but not YANG data templates are data structures defined in YANG but not
intended to be implemented as part of a datastore. YANG data intended to be implemented as part of a datastore. YANG data
templates are defined using the 'yang-data' extension as described by templates are defined using the 'yang-data' extension as described by
RFC 8040. [RFC8040].
YANG data templates SHOULD be encoded using the encoding rules of a YANG data templates MUST be encoded using the encoding rules of a
collection as defined in Section 4.2. collection as defined in Section 4.2.
Just like YANG containers, YANG data templates can be encoded using Just like YANG containers, YANG data templates can be encoded using
either SIDs or names. either SIDs or names.
Definition example from [I-D.ietf-core-comi]: Definition example from [I-D.ietf-core-comi]:
import ietf-restconf { import ietf-restconf {
prefix rc; prefix rc;
} }
skipping to change at page 23, line 30 skipping to change at page 25, line 30
} }
leaf error-data-node { leaf error-data-node {
type instance-identifier; type instance-identifier;
} }
leaf error-message { leaf error-message {
type string; type string;
} }
} }
} }
5.1. SIDs as keys 5.1. Using SIDs in keys
YANG template encoded using SIDs are carried in a CBOR map containing YANG template encoded using SIDs are carried in a CBOR map containing
a single item pair. The key of this item is set to the SID assigned a single item pair. The key of this item is set to the SID assigned
to the YANG template container, the value is set the CBOR encoding of to the YANG template container, the value is set the CBOR encoding of
this container as defined in Section 4.2. this container as defined in Section 4.2.
This example shows a serialization example of the yang-errors This example shows a serialization example of the yang-errors
template as defined in [I-D.ietf-core-comi] using SIDs as defined in template as defined in [I-D.ietf-core-comi] using SIDs as defined in
Section 3.2. Section 3.2.
CBOR diagnostic notation: CBOR diagnostic notation:
{ {
1024 : { / error (SID 1024) / 1024 : { / error (SID 1024) /
+4 : 1011, / error-tag (SID 1028) / 4 : 1011, / error-tag (SID 1028) /
/ = invalid-value (SID 1011) / / = invalid-value (SID 1011) /
+1 : 1018, / error-app-tag (SID 1025) / 1 : 1018, / error-app-tag (SID 1025) /
/ = not-in-range (SID 1018) / / = not-in-range (SID 1018) /
+2 : 1740, / error-data-node (SID 1026) / 2 : 1740, / error-data-node (SID 1026) /
/ = timezone-utc-offset (SID 1740) / / = timezone-utc-offset (SID 1740) /
+3 : "Maximum exceeded" / error-message (SID 1027) / 3 : "Maximum exceeded" / error-message (SID 1027) /
} }
} }
CBOR encoding: CBOR encoding:
A1 # map(1) A1 # map(1)
19 0400 # unsigned(1024) 19 0400 # unsigned(1024)
A4 # map(4) A4 # map(4)
04 # unsigned(4) 04 # unsigned(4)
19 03F3 # unsigned(1011) 19 03F3 # unsigned(1011)
01 # unsigned(1) 01 # unsigned(1)
19 03FA # unsigned(1018) 19 03FA # unsigned(1018)
02 # unsigned(2) 02 # unsigned(2)
19 06CC # unsigned(1740) 19 06CC # unsigned(1740)
03 # unsigned(3) 03 # unsigned(3)
70 # text(16) 70 # text(16)
4D6178696D756D206578636565646564 4D6178696D756D206578636565646564
5.2. Names as keys 5.2. Using names in keys
YANG template encoded using names are carried in a CBOR map YANG template encoded using names are carried in a CBOR map
containing a single item pair. The key of this item is set to the containing a single item pair. The key of this item is set to the
namespace qualified name of the YANG template container, the value is namespace qualified name of the YANG template container, the value is
set the CBOR encoding of this container as defined in Section 3.3. set the CBOR encoding of this container as defined in Section 3.3.
This example shows a serialization example of the yang-errors This example shows a serialization example of the yang-errors
template as defined in [I-D.ietf-core-comi] using names as defined template as defined in [I-D.ietf-core-comi] using names as defined
Section 3.3. Section 3.3.
skipping to change at page 25, line 6 skipping to change at page 27, line 6
{ {
"ietf-comi:error" : { "ietf-comi:error" : {
"error-tag" : "invalid-value", "error-tag" : "invalid-value",
"error-app-tag" : "not-in-range", "error-app-tag" : "not-in-range",
"error-data-node" : "timezone-utc-offset", "error-data-node" : "timezone-utc-offset",
"error-message" : "Maximum exceeded" "error-message" : "Maximum exceeded"
} }
} }
CBOR encoding: CBOR encoding:
A1 # map(1) A1 # map(1)
6F # text(15) 6F # text(15)
696574662D636F6D693A6572726F72 # "ietf-comi:error" 696574662D636F6D693A6572726F72 # "ietf-comi:error"
A4 # map(4) A4 # map(4)
69 # text(9) 69 # text(9)
6572726F722D746167 # "error-tag" 6572726F722D746167 # "error-tag"
6D # text(13) 6D # text(13)
696E76616C69642D76616C7565 # "invalid-value" 696E76616C69642D76616C7565 # "invalid-value"
6D # text(13) 6D # text(13)
6572726F722D6170702D746167 # "error-app-tag" 6572726F722D6170702D746167 # "error-app-tag"
6C # text(12) 6C # text(12)
6E6F742D696E2D72616E6765 # "not-in-range" 6E6F742D696E2D72616E6765 # "not-in-range"
6F # text(15) 6F # text(15)
6572726F722D646174612D6E6F6465 # "error-data-node" 6572726F722D646174612D6E6F6465 # "error-data-node"
73 # text(19) 73 # text(19)
74696D657A6F6E652D7574632D6F6666736574 # "timezone-utc-offset" 74696D657A6F6E652D7574632D6F6666736574
6D # text(13) # "timezone-utc-offset"
6572726F722D6D657373616765 # "error-message" 6D # text(13)
70 # text(16) 6572726F722D6D657373616765 # "error-message"
4D6178696D756D206578636565646564 70 # text(16)
4D6178696D756D206578636565646564
6. Representing YANG Data Types in CBOR 6. Representing YANG Data Types in CBOR
The CBOR encoding of an instance of a leaf or leaf-list schema node The CBOR encoding of an instance of a leaf or leaf-list schema node
depends on the built-in type of that schema node. The following sub- depends on the built-in type of that schema node. The following sub-
section defined the CBOR encoding of each built-in type supported by section defined the CBOR encoding of each built-in type supported by
YANG as listed in [RFC7950] section 4.2.4. Each subsection shows an YANG as listed in [RFC7950] section 4.2.4. Each subsection shows an
example value assigned to a schema node instance of the discussed example value assigned to a schema node instance of the discussed
built-in type. built-in type.
6.1. The unsigned integer Types 6.1. The unsigned integer Types
Leafs of type uint8, uint16, uint32 and uint64 MUST be encoded using Leafs of type uint8, uint16, uint32 and uint64 MUST be encoded using
a CBOR unsigned integer data item (major type 0). a CBOR unsigned integer data item (major type 0).
The following example shows the encoding of a 'mtu' leaf instance set The following example shows the encoding of a 'mtu' leaf instance set
to 1280 bytes. to 1280 bytes.
Definition example from [RFC7277]: Definition example from [RFC8344]:
leaf mtu { leaf mtu {
type uint16 { type uint16 {
range "68..max"; range "68..max";
} }
} }
CBOR diagnostic notation: 1280 CBOR diagnostic notation: 1280
CBOR encoding: 19 0500 CBOR encoding: 19 0500
skipping to change at page 27, line 13 skipping to change at page 29, line 13
CBOR encoding: C4 82 21 19 0101 CBOR encoding: C4 82 21 19 0101
6.4. The 'string' Type 6.4. The 'string' Type
Leafs of type string MUST be encoded using a CBOR text string data Leafs of type string MUST be encoded using a CBOR text string data
item (major type 3). item (major type 3).
The following example shows the encoding of a 'name' leaf instance The following example shows the encoding of a 'name' leaf instance
set to "eth0". set to "eth0".
Definition example from [RFC7223]: Definition example from [RFC8343]:
leaf name { leaf name {
type string; type string;
} }
CBOR diagnostic notation: "eth0" CBOR diagnostic notation: "eth0"
CBOR encoding: 64 65746830 CBOR encoding: 64 65746830
6.5. The 'boolean' Type 6.5. The 'boolean' Type
skipping to change at page 28, line 27 skipping to change at page 30, line 27
} }
CBOR diagnostic notation: 3 CBOR diagnostic notation: 3
CBOR encoding: 03 CBOR encoding: 03
To avoid overlap of 'value' defined in different 'enumeration' To avoid overlap of 'value' defined in different 'enumeration'
statements, 'enumeration' defined in a Leafs of type 'union' MUST be statements, 'enumeration' defined in a Leafs of type 'union' MUST be
encoded using a CBOR text string data item (major type 3) and MUST encoded using a CBOR text string data item (major type 3) and MUST
contain one of the names assigned by 'enum' statements in YANG. The contain one of the names assigned by 'enum' statements in YANG. The
encoding MUST be prefixed with the enumeration CBOR tag as specified encoding MUST be enclosed by the enumeration CBOR tag as specified in
in Section 8.1. Section 8.1.
Definition example from [RFC7950]: Definition example from [RFC7950]:
type union { type union {
type int32; type int32;
type enumeration { type enumeration {
enum "unbounded"; enum "unbounded";
} }
} }
skipping to change at page 29, line 36 skipping to change at page 31, line 36
} }
CBOR diagnostic notation: h'06' CBOR diagnostic notation: h'06'
CBOR encoding: 41 06 CBOR encoding: 41 06
To avoid overlap of 'bit' defined in different 'bits' statements, To avoid overlap of 'bit' defined in different 'bits' statements,
'bits' defined in a Leafs of type 'union' MUST be encoded using a 'bits' defined in a Leafs of type 'union' MUST be encoded using a
CBOR text string data item (major type 3) and MUST contain a space- CBOR text string data item (major type 3) and MUST contain a space-
separated sequence of names of 'bit' that are set. The encoding MUST separated sequence of names of 'bit' that are set. The encoding MUST
be prefixed with the bits CBOR tag as specified in Section 8.1. be enclosed by the bits CBOR tag as specified in Section 8.1.
The following example shows the encoding of an 'alarm-state' leaf The following example shows the encoding of an 'alarm-state' leaf
instance defined using a union type with the 'under-repair' and instance defined using a union type with the 'under-repair' and
'critical' flags set. 'critical' flags set.
Definition example: Definition example:
leaf alarm-state-2 { leaf alarm-state-2 {
type union { type union {
type alarm-state; type alarm-state;
skipping to change at page 30, line 36 skipping to change at page 32, line 36
CBOR encoding: 50 1F1CE6A3F42660D888D92A4D8030476E CBOR encoding: 50 1F1CE6A3F42660D888D92A4D8030476E
6.9. The 'leafref' Type 6.9. The 'leafref' Type
Leafs of type leafref MUST be encoded using the rules of the schema Leafs of type leafref MUST be encoded using the rules of the schema
node referenced by the 'path' YANG statement. node referenced by the 'path' YANG statement.
The following example shows the encoding of an 'interface-state-ref' The following example shows the encoding of an 'interface-state-ref'
leaf instance set to "eth1". leaf instance set to "eth1".
Definition example from [RFC7223]: Definition example from [RFC8343]:
typedef interface-state-ref { typedef interface-state-ref {
type leafref { type leafref {
path "/interfaces-state/interface/name"; path "/interfaces-state/interface/name";
} }
} }
container interfaces-state { container interfaces-state {
list interface { list interface {
key "name"; key "name";
skipping to change at page 33, line 5 skipping to change at page 35, line 5
69616E612D69662D747970653A65746865726E657443736D616364 69616E612D69662D747970653A65746865726E657443736D616364
6.11. The 'empty' Type 6.11. The 'empty' Type
Leafs of type empty MUST be encoded using the CBOR null value (major Leafs of type empty MUST be encoded using the CBOR null value (major
type 7, additional information 22). type 7, additional information 22).
The following example shows the encoding of a 'is-router' leaf The following example shows the encoding of a 'is-router' leaf
instance when present. instance when present.
Definition example from [RFC7277]: Definition example from [RFC8344]:
leaf is-router { leaf is-router {
type empty; type empty;
} }
CBOR diagnostic notation: null CBOR diagnostic notation: null
CBOR encoding: F6 CBOR encoding: F6
6.12. The 'union' Type 6.12. The 'union' Type
Leafs of type union MUST be encoded using the rules associated with Leafs of type union MUST be encoded using the rules associated with
one of the types listed. When used in a union, the following YANG one of the types listed. When used in a union, the following YANG
datatypes are prefixed by CBOR tag to avoid confusion between datatypes are enclosed by a CBOR tag to avoid confusion between
different YANG datatypes encoded using the same CBOR major type. different YANG datatypes encoded using the same CBOR major type.
o bits o bits
o enumeration o enumeration
o identityref o identityref
o instance-identifier o instance-identifier
skipping to change at page 39, line 20 skipping to change at page 41, line 20
YANG data modeling language. As such, this encoding does not YANG data modeling language. As such, this encoding does not
contribute any new security issues in addition of those identified contribute any new security issues in addition of those identified
for the specific protocol or context for which it is used. for the specific protocol or context for which it is used.
To minimize security risks, software on the receiving side SHOULD To minimize security risks, software on the receiving side SHOULD
reject all messages that do not comply to the rules of this document reject all messages that do not comply to the rules of this document
and reply with an appropriate error message to the sender. and reply with an appropriate error message to the sender.
8. IANA Considerations 8. IANA Considerations
8.1. Tags Registry 8.1. CBOR Tags Registry
This specification requires the assignment of CBOR tags for the This specification requires the assignment of CBOR tags for the
following YANG datatypes. These tags are added to the Tags Registry following YANG datatypes. These tags are added to the CBOR Tags
as defined in section 7.2 of [RFC7049]. Registry as defined in section 7.2 of [RFC7049].
+----+----------+---------------------+-----------------------------+ +-----+------------------+-----------------------------+-----------+
| Ta | Data | Semantics | Reference | | Tag | Data Item | Semantics | Reference |
| g | Item | | | +-----+------------------+-----------------------------+-----------+
+----+----------+---------------------+-----------------------------+ | 43 | byte string | YANG bits datatype | [this] |
| 42 | unsigned | YANG Schema Item | [draft-ietf-core-yang-cbor] | | | | ; see Section 6.7. | |
| | integer | iDentifier (sid); | | | 44 | unsigned integer | YANG enumeration datatype | [this] |
| | | see Section 3.2. | | | | | ;see Section 6.6. | |
| 43 | byte | YANG bits datatype; | [draft-ietf-core-yang-cbor] | | 45 | unsigned integer | YANG identityref datatype | [this] |
| | string | see Section 6.7. | | | | or text string | ; see Section 6.10. | |
| 44 | unsigned | YANG enumeration | [draft-ietf-core-yang-cbor] | | 46 | unsigned integer | YANG instance-identifier | [this] |
| | integer | datatype; see | | | | or text string | datatype; see Section 6.13. | [this] |
| | | Section 6.6. | | | | or array | | |
| 45 | unsigned | YANG identityref | [draft-ietf-core-yang-cbor] | | 47 | unsigned integer | YANG Schema Item iDentifier | |
| | integer | datatype; see | | | | | ; see Section 3.2. | [this] |
| | or text | Section 6.10. | | +-----+------------------+-----------------------------+-----------+
| | string | | |
| 46 | unsigned | YANG instance- | [draft-ietf-core-yang-cbor] |
| | integer | identifier | |
| | or text | datatype; see | |
| | string | Section 6.13. | |
| | or array | | |
+----+----------+---------------------+-----------------------------+
// RFC Ed.: replace [draft-ietf-core-yang-cbor] with RFC number and // RFC Ed.: replace [this] with RFC number and remove this note
remove this note
9. Acknowledgments 9. Acknowledgments
This document has been largely inspired by the extensive works done This document has been largely inspired by the extensive works done
by Andy Bierman and Peter van der Stok on [I-D.ietf-core-comi]. by Andy Bierman and Peter van der Stok on [I-D.ietf-core-comi].
[RFC7951] has also been a critical input to this work. The authors [RFC7951] has also been a critical input to this work. The authors
would like to thank the authors and contributors to these two drafts. would like to thank the authors and contributors to these two drafts.
The authors would also like to acknowledge the review, feedback, and The authors would also like to acknowledge the review, feedback, and
comments from Ladislav Lhotka and Juergen Schoenwaelder. comments from Ladislav Lhotka and Juergen Schoenwaelder.
10. References 10. References
10.1. Normative References 10.1. Normative References
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, Requirement Levels", BCP 14, RFC 2119,
DOI 10.17487/RFC2119, March 1997, DOI 10.17487/RFC2119, March 1997,
<https://www.rfc-editor.org/info/rfc2119>. <https://www.rfc-editor.org/info/rfc2119>.
[RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax
Specifications: ABNF", STD 68, RFC 5234,
DOI 10.17487/RFC5234, January 2008,
<https://www.rfc-editor.org/info/rfc5234>.
[RFC6241] Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed., [RFC6241] Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed.,
and A. Bierman, Ed., "Network Configuration Protocol and A. Bierman, Ed., "Network Configuration Protocol
(NETCONF)", RFC 6241, DOI 10.17487/RFC6241, June 2011, (NETCONF)", RFC 6241, DOI 10.17487/RFC6241, June 2011,
<https://www.rfc-editor.org/info/rfc6241>. <https://www.rfc-editor.org/info/rfc6241>.
[RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object
Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049,
October 2013, <https://www.rfc-editor.org/info/rfc7049>. October 2013, <https://www.rfc-editor.org/info/rfc7049>.
[RFC7950] Bjorklund, M., Ed., "The YANG 1.1 Data Modeling Language", [RFC7950] Bjorklund, M., Ed., "The YANG 1.1 Data Modeling Language",
RFC 7950, DOI 10.17487/RFC7950, August 2016, RFC 7950, DOI 10.17487/RFC7950, August 2016,
<https://www.rfc-editor.org/info/rfc7950>. <https://www.rfc-editor.org/info/rfc7950>.
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
May 2017, <https://www.rfc-editor.org/info/rfc8174>.
[RFC8610] Birkholz, H., Vigano, C., and C. Bormann, "Concise Data
Definition Language (CDDL): A Notational Convention to
Express Concise Binary Object Representation (CBOR) and
JSON Data Structures", RFC 8610, DOI 10.17487/RFC8610,
June 2019, <https://www.rfc-editor.org/info/rfc8610>.
10.2. Informative References 10.2. Informative References
[I-D.ietf-core-comi] [I-D.ietf-core-comi]
Veillette, M., Stok, P., Pelov, A., and A. Bierman, "CoAP Veillette, M., Stok, P., Pelov, A., Bierman, A., and I.
Management Interface", draft-ietf-core-comi-04 (work in Petrov, "CoAP Management Interface", draft-ietf-core-
progress), November 2018. comi-07 (work in progress), July 2019.
[I-D.ietf-core-sid] [I-D.ietf-core-sid]
Veillette, M., Pelov, A., and I. Petrov, "YANG Schema Item Veillette, M., Pelov, A., and I. Petrov, "YANG Schema Item
iDentifier (SID)", draft-ietf-core-sid-06 (work in iDentifier (SID)", draft-ietf-core-sid-07 (work in
progress), March 2019. progress), July 2019.
[RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data
Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March
2014, <https://www.rfc-editor.org/info/rfc7159>.
[RFC7223] Bjorklund, M., "A YANG Data Model for Interface
Management", RFC 7223, DOI 10.17487/RFC7223, May 2014,
<https://www.rfc-editor.org/info/rfc7223>.
[RFC7228] Bormann, C., Ersue, M., and A. Keranen, "Terminology for [RFC7228] Bormann, C., Ersue, M., and A. Keranen, "Terminology for
Constrained-Node Networks", RFC 7228, Constrained-Node Networks", RFC 7228,
DOI 10.17487/RFC7228, May 2014, DOI 10.17487/RFC7228, May 2014,
<https://www.rfc-editor.org/info/rfc7228>. <https://www.rfc-editor.org/info/rfc7228>.
[RFC7277] Bjorklund, M., "A YANG Data Model for IP Management",
RFC 7277, DOI 10.17487/RFC7277, June 2014,
<https://www.rfc-editor.org/info/rfc7277>.
[RFC7317] Bierman, A. and M. Bjorklund, "A YANG Data Model for [RFC7317] Bierman, A. and M. Bjorklund, "A YANG Data Model for
System Management", RFC 7317, DOI 10.17487/RFC7317, August System Management", RFC 7317, DOI 10.17487/RFC7317, August
2014, <https://www.rfc-editor.org/info/rfc7317>. 2014, <https://www.rfc-editor.org/info/rfc7317>.
[RFC7951] Lhotka, L., "JSON Encoding of Data Modeled with YANG", [RFC7951] Lhotka, L., "JSON Encoding of Data Modeled with YANG",
RFC 7951, DOI 10.17487/RFC7951, August 2016, RFC 7951, DOI 10.17487/RFC7951, August 2016,
<https://www.rfc-editor.org/info/rfc7951>. <https://www.rfc-editor.org/info/rfc7951>.
[RFC8040] Bierman, A., Bjorklund, M., and K. Watsen, "RESTCONF [RFC8040] Bierman, A., Bjorklund, M., and K. Watsen, "RESTCONF
Protocol", RFC 8040, DOI 10.17487/RFC8040, January 2017, Protocol", RFC 8040, DOI 10.17487/RFC8040, January 2017,
<https://www.rfc-editor.org/info/rfc8040>. <https://www.rfc-editor.org/info/rfc8040>.
[RFC8259] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data
Interchange Format", STD 90, RFC 8259,
DOI 10.17487/RFC8259, December 2017,
<https://www.rfc-editor.org/info/rfc8259>.
[RFC8343] Bjorklund, M., "A YANG Data Model for Interface
Management", RFC 8343, DOI 10.17487/RFC8343, March 2018,
<https://www.rfc-editor.org/info/rfc8343>.
[RFC8344] Bjorklund, M., "A YANG Data Model for IP Management",
RFC 8344, DOI 10.17487/RFC8344, March 2018,
<https://www.rfc-editor.org/info/rfc8344>.
[RFC8348] Bierman, A., Bjorklund, M., Dong, J., and D. Romascanu, "A [RFC8348] Bierman, A., Bjorklund, M., Dong, J., and D. Romascanu, "A
YANG Data Model for Hardware Management", RFC 8348, YANG Data Model for Hardware Management", RFC 8348,
DOI 10.17487/RFC8348, March 2018, DOI 10.17487/RFC8348, March 2018,
<https://www.rfc-editor.org/info/rfc8348>. <https://www.rfc-editor.org/info/rfc8348>.
Authors' Addresses Authors' Addresses
Michel Veillette (editor) Michel Veillette (editor)
Trilliant Networks Inc. Trilliant Networks Inc.
610 Rue du Luxembourg 610 Rue du Luxembourg
 End of changes. 73 change blocks. 
220 lines changed or deleted 340 lines changed or added

This html diff was produced by rfcdiff 1.47. The latest version is available from http://tools.ietf.org/tools/rfcdiff/