draft-ietf-core-yang-cbor-08.txt   draft-ietf-core-yang-cbor-09.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 A. Pelov, Ed. Intended status: Standards Track I. Petrov, Ed.
Expires: September 26, 2019 Acklio Expires: October 4, 2019 A. Pelov
A. Somaraju
Tridonic GmbH & Co KG
R. Turner
Landis+Gyr
A. Minaburo
I. Petrov, Ed.
Acklio Acklio
March 25, 2019 April 02, 2019
CBOR Encoding of Data Modeled with YANG CBOR Encoding of Data Modeled with YANG
draft-ietf-core-yang-cbor-08 draft-ietf-core-yang-cbor-09
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 and notifications defined within YANG modules using the
Concise Binary Object Representation (CBOR) [RFC7049]. Concise Binary Object Representation (CBOR) [RFC7049].
Status of This Memo Status of This Memo
skipping to change at page 1, line 41 skipping to change at page 1, line 35
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 September 26, 2019. This Internet-Draft will expire on October 4, 2019.
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
2.1. YANG Schema Item iDentifier (SID) . . . . . . . . . . . . 5 3. Properties of the CBOR Encoding . . . . . . . . . . . . . . . 4
2.2. CBOR diagnostic notation . . . . . . . . . . . . . . . . 5 3.1. CBOR diagnostic notation . . . . . . . . . . . . . . . . 5
3. Properties of the CBOR Encoding . . . . . . . . . . . . . . . 6 3.2. YANG Schema Item iDentifier (SID) . . . . . . . . . . . . 6
4. Encoding of YANG Schema Node Instances . . . . . . . . . . . 7 3.3. Name . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.1. The 'leaf' . . . . . . . . . . . . . . . . . . . . . . . 7 4. Encoding of YANG Schema Node Instances . . . . . . . . . . . 9
4.2. The 'container' and other collections . . . . . . . . . . 8 4.1. The 'leaf' . . . . . . . . . . . . . . . . . . . . . . . 9
4.2.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . 8 4.2. The 'container' and other collections . . . . . . . . . . 9
4.2.2. Member names as keys . . . . . . . . . . . . . . . . 9 4.2.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . 10
4.3. The 'leaf-list' . . . . . . . . . . . . . . . . . . . . . 11 4.2.2. Names as keys . . . . . . . . . . . . . . . . . . . . 11
4.4. The 'list' and 'list' instance(s) . . . . . . . . . . . . 11 4.3. The 'leaf-list' . . . . . . . . . . . . . . . . . . . . . 13
4.4.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . 12 4.4. The 'list' and 'list' instance(s) . . . . . . . . . . . . 14
4.4.2. Member names as keys . . . . . . . . . . . . . . . . 14 4.4.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . 15
4.5. The 'anydata' . . . . . . . . . . . . . . . . . . . . . . 15 4.4.2. Names as keys . . . . . . . . . . . . . . . . . . . . 17
4.6. The 'anyxml' . . . . . . . . . . . . . . . . . . . . . . 17 4.5. The 'anydata' . . . . . . . . . . . . . . . . . . . . . . 19
5. Encoding of YANG data templates . . . . . . . . . . . . . . . 17 4.6. The 'anyxml' . . . . . . . . . . . . . . . . . . . . . . 21
5.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . . . 18 5. Encoding of YANG data templates . . . . . . . . . . . . . . . 22
5.2. Member names as keys . . . . . . . . . . . . . . . . . . 19 5.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . . . 23
6. Representing YANG Data Types in CBOR . . . . . . . . . . . . 20 5.2. Names as keys . . . . . . . . . . . . . . . . . . . . . . 24
6.1. The unsigned integer Types . . . . . . . . . . . . . . . 20 6. Representing YANG Data Types in CBOR . . . . . . . . . . . . 25
6.2. The integer Types . . . . . . . . . . . . . . . . . . . . 21 6.1. The unsigned integer Types . . . . . . . . . . . . . . . 25
6.3. The 'decimal64' Type . . . . . . . . . . . . . . . . . . 21 6.2. The integer Types . . . . . . . . . . . . . . . . . . . . 26
6.4. The 'string' Type . . . . . . . . . . . . . . . . . . . . 22 6.3. The 'decimal64' Type . . . . . . . . . . . . . . . . . . 26
6.5. The 'boolean' Type . . . . . . . . . . . . . . . . . . . 22 6.4. The 'string' Type . . . . . . . . . . . . . . . . . . . . 27
6.6. The 'enumeration' Type . . . . . . . . . . . . . . . . . 22 6.5. The 'boolean' Type . . . . . . . . . . . . . . . . . . . 27
6.7. The 'bits' Type . . . . . . . . . . . . . . . . . . . . . 23 6.6. The 'enumeration' Type . . . . . . . . . . . . . . . . . 27
6.8. The 'binary' Type . . . . . . . . . . . . . . . . . . . . 24 6.7. The 'bits' Type . . . . . . . . . . . . . . . . . . . . . 28
6.9. The 'leafref' Type . . . . . . . . . . . . . . . . . . . 24 6.8. The 'binary' Type . . . . . . . . . . . . . . . . . . . . 30
6.10. The 'identityref' Type . . . . . . . . . . . . . . . . . 25 6.9. The 'leafref' Type . . . . . . . . . . . . . . . . . . . 30
6.10.1. SIDs as identityref . . . . . . . . . . . . . . . . 25 6.10. The 'identityref' Type . . . . . . . . . . . . . . . . . 31
6.10.2. Name as identityref . . . . . . . . . . . . . . . . 26 6.10.1. SIDs as identityref . . . . . . . . . . . . . . . . 31
6.11. The 'empty' Type . . . . . . . . . . . . . . . . . . . . 26 6.10.2. Name as identityref . . . . . . . . . . . . . . . . 32
6.12. The 'union' Type . . . . . . . . . . . . . . . . . . . . 27 6.11. The 'empty' Type . . . . . . . . . . . . . . . . . . . . 32
6.13. The 'instance-identifier' Type . . . . . . . . . . . . . 28 6.12. The 'union' Type . . . . . . . . . . . . . . . . . . . . 33
6.13.1. SIDs as instance-identifier . . . . . . . . . . . . 28 6.13. The 'instance-identifier' Type . . . . . . . . . . . . . 34
6.13.2. Names as instance-identifier . . . . . . . . . . . . 31 6.13.1. SIDs as instance-identifier . . . . . . . . . . . . 34
7. Security Considerations . . . . . . . . . . . . . . . . . . . 32 6.13.2. Names as instance-identifier . . . . . . . . . . . . 37
8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 32 7. Security Considerations . . . . . . . . . . . . . . . . . . . 39
8.1. Tags Registry . . . . . . . . . . . . . . . . . . . . . . 32 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 39
9. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 33 8.1. Tags Registry . . . . . . . . . . . . . . . . . . . . . . 39
10. References . . . . . . . . . . . . . . . . . . . . . . . . . 33 9. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 39
10.1. Normative References . . . . . . . . . . . . . . . . . . 33 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 40
10.2. Informative References . . . . . . . . . . . . . . . . . 34 10.1. Normative References . . . . . . . . . . . . . . . . . . 40
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 34 10.2. Informative References . . . . . . . . . . . . . . . . . 40
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 41
1. Introduction 1. Introduction
The specification of the YANG 1.1 data modelling language [RFC7950] The specification of the YANG 1.1 data modelling 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
skipping to change at page 4, line 18 skipping to change at page 4, line 14
o notification o notification
o RPC o RPC
o schema node o schema node
o schema tree o schema tree
o submodule o submodule
The following terms are defined in [RFC7951]:
o member name
o name of an identity
o namespace-qualified
The following terms are defined in [RFC8040]: The following terms are defined in [RFC8040]:
o yang-data (YANG extension) o yang-data (YANG extension)
o YANG data template o YANG data template
This specification also makes use of the following terminology: This specification also makes use of the following terminology:
o child: A schema node defined within a collection such as a o child: A schema node defined within a collection such as a
container, a list, a case, a notification, an RPC input, an RPC container, a list, a case, a notification, an RPC input, an RPC
skipping to change at page 5, line 5 skipping to change at page 4, line 38
used. used.
o item: A schema node, an identity, a module, a submodule or a o item: A schema node, an identity, a module, a submodule or a
feature defined using the YANG modeling language. feature defined using the YANG modeling language.
o parent: The collection in which a schema node is defined. o parent: The collection in which a schema node is defined.
o YANG Schema Item iDentifier (SID): Unsigned integer used to o YANG Schema Item iDentifier (SID): Unsigned integer used to
identify different YANG items. identify different YANG items.
2.1. YANG Schema Item iDentifier (SID) 3. Properties of the CBOR Encoding
Some of the items defined in YANG [RFC7950] require the use of a
unique identifier. In both NETCONF [RFC6241] and RESTCONF [RFC8040],
these identifiers are implemented using names. To allow the
implementation of data models defined in YANG in constrained devices
and constrained networks, a more compact method to identify YANG
items is required. This compact identifier, called YANG Schema Item
iDentifier (SID), is encoded using an unsigned integer. The
following items are identified using SIDs:
o identities
o data nodes
o RPCs and associated input(s) and output(s) This document defines CBOR encoding rules for YANG schema trees and
their subtrees.
o actions and associated input(s) and output(s) A collection such as container, list instance, notification, RPC
input, RPC output, action input and action output is serialized using
a CBOR map in which each child schema node is encoded using a key and
a value. This specification supports two type of CBOR keys; YANG
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
specific CBOR type which allows their interpretation during the
deserialization process. Protocols or mechanisms implementing this
specification can mandate the use of a specific key type.
o notifications and associated information In order to minimize the size of the encoded data, the proposed
mapping avoids any unnecessary meta-information beyond those natively
supported by CBOR. For instance, CBOR tags are used solely in the
case of anyxml schema nodes and the union datatype to distinguish
explicitly the use of different YANG datatypes encoded using the same
CBOR major type.
o YANG modules, submodules and features Unless specified otherwise by the protocol or mechanism implementing
this specification, the infinite lengths encoding as defined in
[RFC7049] section 2.2 SHALL be supported by CBOR decoders.
To minimize its size, in certain positions, SIDs are represented Data nodes implemented using a CBOR array, map, byte string, and text
using a (signed) delta from a reference SID and the current SID. string can be instantiated but empty. In this case, they are encoded
Conversion from SIDs to deltas and back to SIDs are stateless with a length of zero.
processes solely based on the data serialized or deserialized.
Mechanisms and processes used to assign SIDs to YANG items and to Application payloads carrying a value serialized using the rules
guarantee their uniqueness is outside the scope of the present defined by this specification (e.g. CoAP Content-Format) SHOULD
specification. If SIDs are to be used, the present specification is include the identifier (e.g. SID, namespace qualified name,
used in conjunction with a specification defining this management. instance-identifier) of this value. When SIDs are used as
One example for such a specification is under development as identifiers, the reference SID SHALL be included in the payload to
[I-D.ietf-core-sid]. allow stateless conversion of delta values to SIDs. Formats of these
application payloads are not defined by the current specification.
2.2. 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.
+----------+------+--------------------------+-----------+----------+ +----------+------+--------------------------+-----------+----------+
| CBOR | CBOR | Diagnostic notation | Example | CBOR | | CBOR | CBOR | Diagnostic notation | Example | CBOR |
| content | type | | | encoding | | content | type | | | encoding |
skipping to change at page 6, line 46 skipping to change at page 6, line 46
supported: supported:
o Any text within and including a pair of slashes is considered a o Any text within and including a pair of slashes is considered a
comment. comment.
o Deltas are visualized as numbers preceded by a '+' or '-' sign. o Deltas are visualized as numbers preceded by a '+' or '-' sign.
The use of the '+' sign for positive deltas represents an The use of the '+' sign for positive deltas represents an
extension to the CBOR diagnostic notation as defined by [RFC7049] extension to the CBOR diagnostic notation as defined by [RFC7049]
section 6. section 6.
3. Properties of the CBOR Encoding 3.2. YANG Schema Item iDentifier (SID)
This document defines CBOR encoding rules for YANG schema trees and Some of the items defined in YANG [RFC7950] require the use of a
their subtrees. unique identifier. In both NETCONF [RFC6241] and RESTCONF [RFC8040],
these identifiers are implemented using strings. To allow the
implementation of data models defined in YANG in constrained devices
and constrained networks, a more compact method to identify YANG
items is required. This compact identifier, called YANG Schema Item
iDentifier (SID), is an unsigned integer. The following items are
identified using SIDs:
A collection such as container, list instance, notification, RPC o identities
input, RPC output, action input and action output is serialized using
a CBOR map in which each child schema node is encoded using a key and
a value. This specification supports two type of CBOR keys; YANG
Schema Item iDentifier (SID) as defined in Section 2.1 and member
names as defined in [RFC7951]. Each of these key types is encoded
using a specific CBOR type which allows their interpretation during
the deserialization process. Protocols or mechanisms implementing
this specification can mandate the use of a specific key type.
In order to minimize the size of the encoded data, the proposed o data nodes
mapping avoids any unnecessary meta-information beyond those natively
supported by CBOR. For instance, CBOR tags are used solely in the
case of anyxml schema nodes and the union datatype to distinguish
explicitly the use of different YANG datatypes encoded using the same
CBOR major type.
Unless specified otherwise by the protocol or mechanism implementing o RPCs and associated input(s) and output(s)
this specification, the infinite lengths encoding as defined in
[RFC7049] section 2.2 SHALL be supported by CBOR decoders.
Data nodes implemented using a CBOR array, map, byte string, and text o actions and associated input(s) and output(s)
string can be instantiated but empty. In this case, they are encoded
with a length of zero.
Application payloads carrying a value serialized using the rules o notifications and associated information
defined by this specification (e.g. CoAP Content-Format) SHOULD
include the identifier (e.g. SID, namespace-qualified member name, o YANG modules, submodules and features
instance-identifier) of this value. When SIDs are used as
identifiers, the reference SID SHALL be included in the payload to To minimize its size, in certain positions, SIDs are represented
allow stateless conversion of delta values to SIDs. Formats of these using a (signed) delta from a reference SID and the current SID.
application payloads are not defined by the current specification and Conversion from SIDs to deltas and back to SIDs are stateless
are not shown in the examples. processes solely based on the data serialized or deserialized.
Mechanisms and processes used to assign SIDs to YANG items and to
guarantee their uniqueness is outside the scope of the present
specification. If SIDs are to be used, the present specification is
used in conjunction with a specification defining this management.
One example for such a specification is under development as
[I-D.ietf-core-sid].
3.3. Name
This specification also supports the encoding of YANG item
identifiers as string, similar as those used by the JSON Encoding of
Data Modeled with YANG [RFC7951]. This approach can be used to avoid
the management overhead associated to SIDs allocation. The main
drawback is the significant increase is size of the encoded data.
YANG items identifiers implemented using names MUST be in one of the
following forms:
o simple - the identifier of the YANG item (i.e. schema node or
identity).
o namespace qualified - the identifier of the YANG item is prefixed
with the name of the module in which this item is defined,
separated by the colon character (":").
The name of a module determines the namespace of all YANG items
defined in that module. If an item is defined in a submodule, then
the namespace qualified name uses the name of the main module to
which the submodule belongs.
ABNF syntax [RFC5234] of a name is shown in Figure 1, where the
production for "identifier" is defined in Section 14 of [RFC7950].
name = [identifier ":"] identifier
Figure 1: ABNF Production for a simple or namespace qualified name
A namespace qualified name MUST be used for all members of a top-
level CBOR map and then also whenever the namespaces of the data node
and its parent node are different. In all other cases, the simple
form of the name SHOULD be used.
Definition example:
module example-foomod {
container top {
leaf foo {
type uint8;
}
}
}
module example-barmod {
import example-foomod {
prefix "foomod";
}
augment "/foomod:top" {
leaf bar {
type boolean;
}
}
}
A valid CBOR encoding of the 'top' container is as follow.
CBOR diagnostic notation:
{
"example-foomod:top": {
"foo": 54,
"example-barmod:bar": true
}
}
Both the 'top' container and the 'bar' leaf defined in a different
YANG module as its parent container are encoded as namespace
qualified names. The 'foo' leaf defined in the same YANG module as
its parent container is encoded as simple name.
4. Encoding of YANG Schema Node Instances 4. Encoding of YANG Schema Node Instances
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'
skipping to change at page 8, line 16 skipping to change at page 9, line 32
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.
This specification supports two type of CBOR keys; SID as defined in This specification supports two type of CBOR keys; SID as defined in
Section 2.1 and member names as defined in [RFC7951]. Section 3.2 and names as defined in Section 3.3.
The following examples shows the encoding of a 'system-state' The following examples shows the encoding of a 'system-state'
container instance using SIDs or member names. container instance using SIDs or names.
Definition example from [RFC7317]: Definition example from [RFC7317]:
typedef date-and-time { typedef date-and-time {
type string { type string {
pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-] pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-]
\d{2}:\d{2})'; \d{2}:\d{2})';
} }
} }
skipping to change at page 8, line 47 skipping to change at page 10, line 29
leaf boot-datetime { leaf boot-datetime {
type date-and-time; type date-and-time;
} }
} }
} }
4.2.1. SIDs as keys 4.2.1. SIDs as keys
CBOR map keys implemented using SIDs MUST be encoded using a CBOR CBOR map keys implemented using SIDs MUST be encoded using a CBOR
unsigned integer (major type 0) or CBOR negative integer (major type unsigned integer (major type 0) or CBOR negative integer (major type
1), depending on the actual delta value. Delta values are computed 1), depending on the actual delta or to a SID preceded by the CBOR
as follows: tag 99.
// RFC Ed.: replace 99 by the allocated CBOR tag.
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
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
SID of the current schema node minus the SID of the
'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:
{ / system-state (SID 1720) / {
+1 : { / clock (SID 1721) / 1720 : { / system-state /
+2 : "2015-10-02T14:47:24Z-05:00", / current-datetime (SID 1723)/ +1 : { / clock (SID 1721) /
+1 : "2015-09-15T09:12:58Z-05:00" / boot-datetime (SID 1722) / +2 : "2015-10-02T14:47:24Z-05:00",/ current-datetime (SID 1723) /
+1 : "2015-09-15T09:12:58Z-05:00" / boot-datetime (SID 1722) /
} }
} }
}
CBOR encoding: CBOR encoding:
A1 # map(1) A1 # map(1)
01 # unsigned(1) 19 06B8 # unsigned(1720)
A2 # map(2) A1 # map(1)
02 # unsigned(2) 01 # unsigned(1)
78 1A # text(26) A2 # map(2)
323031352d31302d30325431343a34373a32345a2d30353a3030 02 # unsigned(2)
01 # unsigned(1) 78 1A # text(26)
78 1a # text(26) 323031352D31302D30325431343A34373A32345A2D30353A3030
323031352d30392d31355430393a31323a35385a2d30353a3030 01 # unsigned(1)
78 1A # text(26)
323031352D30392D31355430393A31323A35385A2D30353A3030
4.2.2. Member names as keys 4.2.2. Names as keys
CBOR map keys implemented using member names MUST be encoded using a CBOR map keys implemented using names MUST be encoded using a CBOR
CBOR text string data item (major type 3). A namespace-qualified text string data item (major type 3). A namespace-qualified name
member name MUST be used each time the namespace of a schema node and MUST be used each time the namespace of a schema node and its parent
its parent differ. In all other cases, the simple form of the member differ. In all other cases, the simple form of the name MUST be
name MUST be used. Names and namespaces are defined in [RFC7951] used. Names and namespaces are defined in [RFC7951] section 4.
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.
Definition example from [RFC7317]: Definition example from [RFC7317]:
typedef date-and-time { typedef date-and-time {
type string { type string {
pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-] pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-]
\d{2}:\d{2})'; \d{2}:\d{2})';
skipping to change at page 10, line 25 skipping to change at page 12, line 25
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:clock" : { "ietf-system:system-state" : {
"current-datetime" : "2015-10-02T14:47:24Z-05:00", "ietf-system:clock" : {
"boot-datetime" : "2015-09-15T09:12:58Z-05:00" "current-datetime" : "2015-10-02T14:47:24Z-05:00",
"boot-datetime" : "2015-09-15T09:12:58Z-05:00"
}
} }
} }
CBOR encoding: CBOR encoding:
A1 # map(1) A1 # map(1)
71 # text(17) 78 18 # text(24)
696574662D73797374656D3A636C6F636B # "ietf-system:clock" 696574662D73797374656D3A73797374656D2D7374617465
A2 # map(2) A1 # map(1)
70 # text(16) 71 # text(17)
63757272656E742D6461746574696D65 # "current-datetime" 696574662D73797374656D3A636C6F636B
78 1A # text(26) A2 # map(2)
323031352D31302D30325431343A34373A32345A2D30353A3030 70 # text(16)
6D # text(13) 63757272656E742D6461746574696D65
626F6F742D6461746574696D65 # "boot-datetime" 78 1A # text(26)
78 1A # text(26) 323031352D31302D30325431343A34373A32345A2D30353A3030
323031352D30392D31355430393A31323A35385A2D30353A3030 6D # text(13)
626F6F742D6461746574696D65
78 1A # text(26)
323031352D30392D31355430393A31323A35385A2D30353A3030
4.3. The 'leaf-list' 4.3. The 'leaf-list'
A leaf-list MUST be encoded using a CBOR array data item (major type A leaf-list MUST be encoded using a CBOR array data item (major type
4). Each entry of this array MUST be encoded accordingly to its 4). Each entry of this array MUST be encoded accordingly to its
datatype using one of the encoding rules specified in Section 6. datatype using one of the encoding rules specified in Section 6.
The following example shows the encoding of the 'search' leaf-list The following example shows the encoding of the 'search' leaf-list
instance containing two entries, "ietf.org" and "ieee.org". instance containing two entries, "ietf.org" and "ieee.org".
skipping to change at page 11, line 45 skipping to change at page 14, line 16
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.
The following examples show the encoding of a 'server' list using The following examples show the encoding of a 'server' list using
SIDs or member names. SIDs or names.
Definition example from [RFC7317]: Definition example from [RFC7317]:
list server { list server {
key name; key name;
leaf name { leaf name {
type string; type string;
} }
choice transport { choice transport {
skipping to change at page 12, line 48 skipping to change at page 15, line 48
default false; default false;
} }
} }
4.4.1. SIDs as keys 4.4.1. SIDs as 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:
[ / server (SID 1756) / {
{ 1756 : [ / server (SID 1756) /
+3 : "NRC TIC server", / name (SID 1759) / {
+5 : { / udp (SID 1761) / +3 : "NRC TIC server", / name (SID 1759) /
+1 : "tic.nrc.ca", / address (SID 1762) / +5 : { / udp (SID 1761) /
+2 : 123 / port (SID 1763) / +1 : "tic.nrc.ca", / address (SID 1762) /
+2 : 123 / port (SID 1763) /
},
+1 : 0, / association-type (SID 1757) /
+2 : false, / iburst (SID 1758) /
+4 : true / prefer (SID 1760) /
}, },
+1 : 0, / association-type (SID 1757) / {
+2 : false, / iburst (SID 1758) / +3 : "NRC TAC server", / name (SID 1759) /
+4 : true / prefer (SID 1760) / +5 : { / udp (SID 1761) /
}, +1 : "tac.nrc.ca" / address (SID 1762) /
{ }
+3 : "NRC TAC server", / name (SID 1759) /
+5 : { / udp (SID 1761) /
+1 : "tac.nrc.ca" / address (SID 1762) /
} }
} ]
] }
CBOR encoding: CBOR encoding:
82 # array(2) A1 # map(1)
A5 # map(5) 19 06DC # unsigned(1756)
03 # unsigned(3) 82 # array(2)
6E # text(14) A5 # map(5)
4E52432054494320736572766572 # "NRC TIC server" 03 # unsigned(3)
05 # unsigned(5) 6E # text(14)
A2 # map(2) 4E52432054494320736572766572 # "NRC TIC server"
01 # unsigned(1) 05 # unsigned(5)
6A # text(10) A2 # map(2)
7469632E6E72632E6361 # "tic.nrc.ca" 01 # unsigned(1)
02 # unsigned(2) 6A # text(10)
18 7B # unsigned(123) 7469632E6E72632E6361 # "tic.nrc.ca"
01 # unsigned(1) 02 # unsigned(2)
00 # unsigned(0) 18 7B # unsigned(123)
02 # unsigned(2) 01 # unsigned(1)
F4 # primitive(20) 00 # unsigned(0)
04 # unsigned(4) 02 # unsigned(2)
F5 # primitive(21) F4 # primitive(20)
A2 # map(2) 04 # unsigned(4)
03 # unsigned(3) F5 # primitive(21)
6E # text(14) A2 # map(2)
4E52432054414320736572766572 # "NRC TAC server" 03 # unsigned(3)
05 # unsigned(5) 6E # text(14)
A1 # map(1) 4E52432054414320736572766572 # "NRC TAC server"
01 # unsigned(1) 05 # unsigned(5)
6A # text(10) A1 # map(1)
7461632E6E72632E6361 # "tac.nrc.ca" 01 # unsigned(1)
6A # text(10)
7461632E6E72632E6361 # "tac.nrc.ca"
4.4.2. Member names as keys 4.4.2. Names as 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:name" : "NRC TIC server", {
"ietf-system:udp" : { "name" : "NRC TIC server",
"address" : "tic.nrc.ca", "udp" : {
"port" : 123 "address" : "tic.nrc.ca",
"port" : 123
},
"association-type" : 0,
"iburst" : false,
"prefer" : true
}, },
"ietf-system:association-type" : 0, {
"ietf-system:iburst" : false, "name" : "NRC TAC server",
"ietf-system:prefer" : true "udp" : {
}, "address" : "tac.nrc.ca"
{ }
"ietf-system:name" : "NRC TAC server",
"ietf-system:udp" : {
"address" : "tac.nrc.ca"
} }
} ]
] }
CBOR encoding: CBOR encoding:
82 # array(2) A1 # map(1)
A5 # map(5) 72 # text(18)
70 # text(16) 696574662D73797374656D3A736572766572
696574662D73797374656D3A6E616D65 # "ietf-system:name" 82 # array(2)
6E # text(14) A5 # map(5)
4E52432054494320736572766572 # "NRC TIC server" 64 # text(4)
6F # text(15) 6E616D65 # "name"
696574662D73797374656D3A756470 # "ietf-system:udp" 6E # text(14)
4E52432054494320736572766572
63 # text(3)
756470 # "udp"
A2 # map(2)
67 # text(7)
61646472657373 # "address"
6A # text(10)
7469632E6E72632E6361 # "tic.nrc.ca"
64 # text(4)
706F7274 # "port"
18 7B # unsigned(123)
70 # text(16)
6173736F63696174696F6E2D74797065
00 # unsigned(0)
66 # text(6)
696275727374 # "iburst"
F4 # primitive(20)
66 # text(6)
707265666572 # "prefer"
F5 # primitive(21)
A2 # map(2) A2 # map(2)
67 # text(7)
61646472657373 # "address"
6A # text(10)
7469632E6E72632E6361 # "tic.nrc.ca"
64 # text(4) 64 # text(4)
706F7274 # "port" 6E616D65 # "name"
18 7B # unsigned(123) 6E # text(14)
78 1C # text(28) 4E52432054414320736572766572
696574662D73797374656D3A6173736F63696174696F6E2D74797065 63 # text(3)
00 # unsigned(0) 756470 # "udp"
72 # text(18) A1 # map(1)
696574662D73797374656D3A696275727374 # "ietf-system:iburst" 67 # text(7)
F4 # primitive(20) 61646472657373 # "address"
72 # text(18) 6A # text(10)
696574662D73797374656D3A707265666572 # "ietf-system:prefer" 7461632E6E72632E6361 # "tac.nrc.ca"
F5 # primitive(21)
A2 # map(2)
70 # text(16)
696574662D73797374656D3A6E616D65 # "ietf-system:name"
6E # text(14)
4E52432054414320736572766572 # "NRC TAC server"
6F # text(15)
696574662D73797374656D3A756470 # "ietf-system:udp"
A1 # map(1)
67 # text(7)
61646472657373 # "address"
6A # text(10)
7461632E6E72632E6361 # "tac.nrc.ca"
4.5. The 'anydata' 4.5. The 'anydata'
An anydata serves as a container for an arbitrary set of schema nodes An anydata serves as a container for an arbitrary set of schema nodes
that otherwise appear as normal YANG-modeled data. An anydata that otherwise appear as normal YANG-modeled data. An anydata
instance is encoded using the same rules as a container, i.e., CBOR instance is encoded using the same rules as a container, i.e., CBOR
map. The requirement that anydata content can be modeled by YANG map. The requirement that anydata content can be modeled by YANG
implies the following: implies the following:
o CBOR map keys of any inner schema nodes MUST be set to valid o CBOR map keys of any inner schema nodes MUST be set to valid
deltas or member names. deltas or names.
o The CBOR array MUST contain either unique scalar values (as a o The CBOR array MUST contain either unique scalar values (as a
leaf-list, see Section 4.3), or maps (as a list, see Section 4.4). leaf-list, see Section 4.3), or maps (as a list, see Section 4.4).
o CBOR map values MUST follow the encoding rules of one of the o CBOR map values MUST follow the encoding rules of one of the
datatypes listed in Section 4. datatypes listed in Section 4.
The following example shows a possible use of an anydata. In this The following example shows a possible use of an anydata. In this
example, an anydata is used to define a schema node containing a example, an anydata is used to define a schema node containing a
notification event, this schema node can be part of a YANG list to notification event, this schema node can be part of a YANG list to
create an event logger. create an event logger.
Definition example: Definition example:
module event-log { module event-log {
... ...
anydata event; # SID 60123 anydata last-event; # SID 60123
This example also assumes the assistance of the following This example also assumes the assistance of the following
notification. notification.
module example-port { module example-port {
... ...
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
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:
{ / event (SID=60123) / {
+78 : "0/4/21", / port-name (SID=60201) / 60123 : { / last-event (SID=60123) /
+79 : "Open pin 2" / port-fault (SID=60202) / +77 : { / event (SID=60200) /
+1 : "0/4/21", / port-name (SID=60201) /
+2 : "Open pin 2" / port-fault (SID=60202) /
}
}
} }
CBOR encoding: CBOR encoding:
A2 # map(2) A1 # map(1)
18 4E # unsigned(78) 19 EADB # unsigned(60123)
66 # text(6) A1 # map(1)
302F342F3231 # "0/4/21" 18 4D # unsigned(77)
18 4F # unsigned(79) A2 # map(2)
6A # text(10) 18 4E # unsigned(78)
4F70656E2070696E2032 # "Open pin 2" 66 # text(6)
302F342F3231 # "0/4/21"
18 4F # unsigned(79)
6A # text(10)
4F70656E2070696E2032 # "Open pin 2"
In some implementations, it might be simpler to use the absolute SID
tag encoding for the anydata root element. The resulting encoding is
as follow:
{
60123 : { / last-event (SID=60123) /
99(60200) : { / event (SID=60123) /
+1 : "0/4/21", / port-name (SID=60201) /
+2 : "Open pin 2" / port-fault (SID=60202) /
}
}
}
// RFC Ed.: replace 99 by the allocated CBOR tag.
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; anyxml bar;
CBOR diagnostic notation: [true, null, true] Note: This example assumes that the Media Type used to carry this
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 encoding: 83 f5 f6 f5 CBOR diagnostic notation:
{
60000 : [true, null, true] / bar (SID 60000) /
}
CBOR encoding:
A1 # map(1)
19 EA60 # unsigned(60000)
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. RFC 8040.
YANG data templates SHOULD be encoded using the encoding rules of a YANG data templates SHOULD be encoded using the encoding rules of a
collection as defined in Section 4.2. collection as defined in Section 4.2.
skipping to change at page 18, line 32 skipping to change at page 23, line 32
type instance-identifier; type instance-identifier;
} }
leaf error-message { leaf error-message {
type string; type string;
} }
} }
} }
5.1. SIDs as keys 5.1. SIDs as keys
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
to the YANG template container, the value is set the CBOR encoding of
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 using SIDs as CBOR map key. The reference SID of a YANG template as defined in [I-D.ietf-core-comi] using SIDs as defined in
data template is zero, this imply that the CBOR map keys of the top Section 3.2.
level members of the template are set to SIDs.
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) /
skipping to change at page 19, line 18 skipping to change at page 24, line 32
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. Member names as keys 5.2. Names as keys
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
namespace qualified name of the YANG template container, the value is
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 using member names as CBOR map key. template as defined in [I-D.ietf-core-comi] using names as defined
Section 3.3.
CBOR diagnostic notation: CBOR diagnostic notation:
{ {
"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"
} }
skipping to change at page 23, line 23 skipping to change at page 28, line 23
enum dormant { value 5; } enum dormant { value 5; }
enum not-present { value 6; } enum not-present { value 6; }
enum lower-layer-down { value 7; } enum lower-layer-down { value 7; }
} }
} }
CBOR diagnostic notation: 3 CBOR diagnostic notation: 3
CBOR encoding: 03 CBOR encoding: 03
To avoid overlap of 'value' defined in different 'enumeration'
statements, 'enumeration' defined in a Leafs of type 'union' MUST be
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
encoding MUST be prefixed with the enumeration CBOR tag as specified
in Section 8.1.
Definition example from [RFC7950]:
type union {
type int32;
type enumeration {
enum "unbounded";
}
}
CBOR diagnostic notation: 99("unbounded")
CBOR encoding: D8 63 69 756E626F756E646564
// RFC Ed.: update 99 and D8 63 with the enumerator CBOR tag
allocated.
6.7. The 'bits' Type 6.7. The 'bits' Type
Leafs of type bits MUST be encoded using a CBOR byte string data item Leafs of type bits MUST be encoded using a CBOR byte string data item
(major type 2). Bits position are either explicitly assigned using (major type 2). Bits position are either explicitly assigned using
the YANG statement 'position' or automatically assigned based on the the YANG statement 'position' or automatically assigned based on the
algorithm defined in [RFC7950] section 9.7.4.2. algorithm defined in [RFC7950] section 9.7.4.2.
Bits position 0 to 7 are assigned to the first byte within the byte Bits position 0 to 7 are assigned to the first byte within the byte
string, bits 8 to 15 to the second byte, and subsequent bytes are string, bits 8 to 15 to the second byte, and subsequent bytes are
assigned similarly. Within each byte, bits are assigned from least assigned similarly. Within each byte, bits are assigned from least
to most significant. to most significant.
The following example shows the encoding of a 'mybits' leaf instance The following example shows the encoding of an 'alarm-state' leaf
with the 'disable-nagle' and '10-Mb-only' flags set. instance with the 'under-repair' and 'critical' flags set.
Definition example from [RFC7950]: Definition example from [RFC8348]:
leaf mybits { typedef alarm-state {
type bits { type bits {
bit disable-nagle { bit unknown;
position 0; bit under-repair;
} bit critical;
bit auto-sense-speed { bit major;
position 1; bit minor;
} bit warning;
bit 10-Mb-only { bit indeterminate;
position 2; }
}
leaf alarm-state {
type alarm-state;
}
CBOR diagnostic notation: h'06'
CBOR encoding: 41 06
To avoid overlap of 'bit' defined in different 'bits' statements,
'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-
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.
The following example shows the encoding of an 'alarm-state' leaf
instance defined using a union type with the 'under-repair' and
'critical' flags set.
Definition example:
leaf alarm-state-2 {
type union {
type alarm-state;
type bits {
bit extra-flag;
} }
} }
} }
CBOR diagnostic notation: h'05'
CBOR encoding: 41 05 CBOR diagnostic notation: 99("under-repair critical")
CBOR encoding: D8 63 75 756E6465722D72657061697220637269746963616C
// RFC Ed.: update 99 and D8 63 with the bits CBOR tag allocated.
6.8. The 'binary' Type 6.8. The 'binary' Type
Leafs of type binary MUST be encoded using a CBOR byte string data Leafs of type binary MUST be encoded using a CBOR byte string data
item (major type 2). item (major type 2).
The following example shows the encoding of an 'aes128-key' leaf The following example shows the encoding of an 'aes128-key' leaf
instance set to 0x1f1ce6a3f42660d888d92a4d8030476e. instance set to 0x1f1ce6a3f42660d888d92a4d8030476e.
Definition example: Definition example:
skipping to change at page 25, line 30 skipping to change at page 31, line 30
} }
} }
CBOR diagnostic notation: "eth1" CBOR diagnostic notation: "eth1"
CBOR encoding: 64 65746831 CBOR encoding: 64 65746831
6.10. The 'identityref' Type 6.10. The 'identityref' Type
This specification supports two approaches for encoding identityref, This specification supports two approaches for encoding identityref,
a YANG Schema Item iDentifier (SID) as defined in Section 2.1 or a a YANG Schema Item iDentifier (SID) as defined in Section 3.2 or a
name as defined in [RFC7951] section 6.8. name as defined in [RFC7951] section 6.8.
6.10.1. SIDs as identityref 6.10.1. SIDs as identityref
When schema nodes of type identityref are implemented using SIDs, When schema nodes of type identityref are implemented using SIDs,
they MUST be encoded using a CBOR unsigned integer data item (major they MUST be encoded using a CBOR unsigned integer data item (major
type 0). (Note that no delta mechanism is employed for SIDs as type 0). (Note that no delta mechanism is employed for SIDs as
identityref.) identityref.)
The following example shows the encoding of a 'type' leaf instance The following example shows the encoding of a 'type' leaf instance
skipping to change at page 26, line 29 skipping to change at page 32, line 29
} }
} }
CBOR diagnostic notation: 1880 CBOR diagnostic notation: 1880
CBOR encoding: 19 0758 CBOR encoding: 19 0758
6.10.2. Name as identityref 6.10.2. Name as identityref
Alternatively, an identityref MAY be encoded using a name as defined Alternatively, an identityref MAY be encoded using a name as defined
in [RFC7951] section 6.8. When names are used, identityref MUST be in Section 3.3. When names are used, identityref MUST be encoded
encoded using a CBOR text string data item (major type 3). If the using a CBOR text string data item (major type 3). If the identity
identity is defined in different module than the leaf node containing is defined in different module than the leaf node containing the
the identityref value, the namespace-qualified form MUST be used. identityref data node, the namespace qualified form MUST be used.
Otherwise, both the simple and namespace-qualified forms are Otherwise, both the simple and namespace qualified forms are
permitted. Names and namespaces are defined in [RFC7951] section 4. permitted. Names and namespaces are defined in Section 3.3.
The following example shows the encoding of the identity 'iana-if- The following example shows the encoding of the identity 'iana-if-
type:ethernetCsmacd' using its name. This example is described in type:ethernetCsmacd' using its namespace qualified name. This
Section 6.10.1. example is described in Section 6.10.1.
CBOR diagnostic notation: "iana-if-type:ethernetCsmacd" CBOR diagnostic notation: "iana-if-type:ethernetCsmacd"
CBOR encoding: 78 1b CBOR encoding: 78 1b
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).
skipping to change at page 27, line 32 skipping to change at page 33, line 32
o bits o bits
o enumeration o enumeration
o identityref o identityref
o instance-identifier o instance-identifier
See Section 8.1 for the assigned value of these CBOR tags. See Section 8.1 for the assigned value of these CBOR tags.
As mentioned in Section 6.6 and in Section 6.7, 'enumeration' and
'bits' are encoded as CBOR text string data item (major type 3) when
defined within a 'union' type.
The following example shows the encoding of an 'ip-address' leaf The following example shows the encoding of an 'ip-address' leaf
instance when set to "2001:db8:a0b:12f0::1". instance when set to "2001:db8:a0b:12f0::1".
Definition example from [RFC7317]: Definition example from [RFC7317]:
typedef ipv4-address { typedef ipv4-address {
type string { type string {
pattern '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3} pattern '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}
([0-9][1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\p{N} ([0-9][1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\p{N}
\p{L}]+)?'; \p{L}]+)?';
skipping to change at page 28, line 43 skipping to change at page 34, line 43
} }
CBOR diagnostic notation: "2001:db8:a0b:12f0::1" CBOR diagnostic notation: "2001:db8:a0b:12f0::1"
CBOR encoding: 74 323030313A6462383A6130623A313266303A3A31 CBOR encoding: 74 323030313A6462383A6130623A313266303A3A31
6.13. The 'instance-identifier' Type 6.13. The 'instance-identifier' Type
This specification supports two approaches for encoding an instance- This specification supports two approaches for encoding an instance-
identifier, one based on YANG Schema Item iDentifier (SID) as defined identifier, one based on YANG Schema Item iDentifier (SID) as defined
in Section 2.1 and one based on names as defined in [RFC7951] section in Section 3.2 and one based on names as defined in Section 3.3.
6.11.
6.13.1. SIDs as instance-identifier 6.13.1. SIDs as instance-identifier
SIDs uniquely identify a schema node. In the case of a single SIDs uniquely identify a schema node. In the case of a single
instance schema node, i.e. a schema node defined at the root of a instance schema node, i.e. a schema node defined at the root of a
YANG module or submodule or schema nodes defined within a container, YANG module or submodule or schema nodes defined within a container,
the SID is sufficient to identify this instance. the SID is sufficient to identify this instance.
In the case of a schema node member of a YANG list, a SID is combined In the case of a schema node member of a YANG list, a SID is combined
with the list key(s) to identify each instance within the YANG with the list key(s) to identify each instance within the YANG
skipping to change at page 31, line 32 skipping to change at page 37, line 32
CBOR encoding: CBOR encoding:
82 # array(2) 82 # array(2)
19 06C2 # unsigned(1730) 19 06C2 # unsigned(1730)
64 # text(4) 64 # text(4)
6A61636B # "jack" 6A61636B # "jack"
6.13.2. Names as instance-identifier 6.13.2. Names as instance-identifier
The use of names as instance-identifier is defined in [RFC7951] An "instance-identifier" value is encoded as a string that is
section 6.11. The resulting xpath MUST be encoded using a CBOR text analogical to the lexical representation in XML encoding; see
string data item (major type 3). Section 9.13.2 in [RFC7950]. However, the encoding of namespaces in
instance-identifier values follows the rules stated in Section 3.3,
namely:
o The leftmost (top-level) data node name is always in the namespace
qualified form.
o Any subsequent data node name is in the namespace qualified form
if the node is defined in a module other than its parent node, and
the simple form is used otherwise. This rule also holds for node
names appearing in predicates.
For example,
/ietf-interfaces:interfaces/interface[name='eth0']/ietf-ip:ipv4/ip
is a valid instance-identifier value because the data nodes
"interfaces", "interface", and "name" are defined in the module
"ietf-interfaces", whereas "ipv4" and "ip" are defined in "ietf-ip".
The resulting xpath MUST be encoded using a CBOR text string data
item (major type 3).
*First example:* *First example:*
This example is described in Section 6.13.1. This example is described in Section 6.13.1.
CBOR diagnostic notation: "/ietf-system:system/contact" CBOR diagnostic notation: "/ietf-system:system/contact"
CBOR encoding: CBOR encoding:
78 1c 2F696574662D73797374656D3A73797374656D2F636F6E74616374 78 1c 2F696574662D73797374656D3A73797374656D2F636F6E74616374
skipping to change at page 33, line 8 skipping to change at page 39, line 29
8.1. Tags Registry 8.1. 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 Tags Registry
as defined in section 7.2 of [RFC7049]. as defined in section 7.2 of [RFC7049].
+-----+---------------------+---------------------------+-----------+ +-----+---------------------+---------------------------+-----------+
| Tag | Data Item | Semantics | Reference | | Tag | Data Item | Semantics | Reference |
+-----+---------------------+---------------------------+-----------+ +-----+---------------------+---------------------------+-----------+
| xx | SID | YANG Schema Item | RFC XXXX |
| | | iDentifier | |
| xx | bits | YANG bits datatype | RFC XXXX | | xx | bits | YANG bits datatype | RFC XXXX |
| xx | enumeration | YANG enumeration datatype | RFC XXXX | | xx | enumeration | YANG enumeration datatype | RFC XXXX |
| xx | identityref | YANG identityref datatype | RFC XXXX | | xx | identityref | YANG identityref datatype | RFC XXXX |
| xx | instance-identifier | YANG instance-identifier | RFC XXXX | | xx | instance-identifier | YANG instance-identifier | RFC XXXX |
| | | datatype | | | | | datatype | |
+-----+---------------------+---------------------------+-----------+ +-----+---------------------+---------------------------+-----------+
// RFC Ed.: update Tag values using allocated tags and remove this // RFC Ed.: update Tag values using allocated tags and remove this
note // RFC Ed.: replace XXXX with RFC number and remove this note note // RFC Ed.: replace XXXX with RFC number and remove this note
skipping to change at page 34, line 14 skipping to change at page 40, line 36
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., and A. Bierman, "CoAP
Management Interface", draft-ietf-core-comi-04 (work in Management Interface", draft-ietf-core-comi-04 (work in
progress), November 2018. progress), November 2018.
[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-05 (work in iDentifier (SID)", draft-ietf-core-sid-06 (work in
progress), December 2018. progress), March 2019.
[RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data [RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data
Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March
2014, <https://www.rfc-editor.org/info/rfc7159>. 2014, <https://www.rfc-editor.org/info/rfc7159>.
[RFC7223] Bjorklund, M., "A YANG Data Model for Interface [RFC7223] Bjorklund, M., "A YANG Data Model for Interface
Management", RFC 7223, DOI 10.17487/RFC7223, May 2014, Management", RFC 7223, DOI 10.17487/RFC7223, May 2014,
<https://www.rfc-editor.org/info/rfc7223>. <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
skipping to change at page 34, line 46 skipping to change at page 41, line 21
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>.
[RFC8348] Bierman, A., Bjorklund, M., Dong, J., and D. Romascanu, "A
YANG Data Model for Hardware Management", RFC 8348,
DOI 10.17487/RFC8348, March 2018,
<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
Granby, Quebec J2J 2V2 Granby, Quebec J2J 2V2
Canada Canada
Phone: +14503750556
Email: michel.veillette@trilliantinc.com Email: michel.veillette@trilliantinc.com
Alexander Pelov (editor) Ivaylo Petrov (editor)
Acklio Acklio
1137A avenue des Champs Blancs 1137A avenue des Champs Blancs
Cesson-Sevigne, Bretagne 35510 Cesson-Sevigne, Bretagne 35510
France France
Email: a@ackl.io Email: ivaylo@ackl.io
Abhinav Somaraju
Tridonic GmbH & Co KG
Farbergasse 15
Dornbirn, Vorarlberg 6850
Austria
Phone: +43664808926169
Email: abhinav.somaraju@tridonic.com
Randy Turner
Landis+Gyr
30000 Mill Creek Ave
Suite 100
Alpharetta, GA 30022
US
Phone: ++16782581292
Email: randy.turner@landisgyr.com
URI: http://www.landisgyr.com/
Ana Minaburo
Acklio
1137A avenue des Champs Blancs
Cesson-Sevigne, Bretagne 35510
France
Email: ana@ackl.io Alexander Pelov
Ivaylo Petrov (editor)
Acklio Acklio
1137A avenue des Champs Blancs 1137A avenue des Champs Blancs
Cesson-Sevigne, Bretagne 35510 Cesson-Sevigne, Bretagne 35510
France France
Email: ivaylo@ackl.io Email: a@ackl.io
 End of changes. 81 change blocks. 
336 lines changed or deleted 551 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/