draft-ietf-core-yang-cbor-06.txt   draft-ietf-core-yang-cbor-07.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 A. Pelov, Ed.
Expires: August 11, 2018 Acklio Expires: March 18, 2019 Acklio
A. Somaraju A. Somaraju
Tridonic GmbH & Co KG Tridonic GmbH & Co KG
R. Turner R. Turner
Landis+Gyr Landis+Gyr
A. Minaburo A. Minaburo
Acklio Acklio
February 07, 2018 September 14, 2018
CBOR Encoding of Data Modeled with YANG CBOR Encoding of Data Modeled with YANG
draft-ietf-core-yang-cbor-06 draft-ietf-core-yang-cbor-07
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 40 skipping to change at page 1, line 40
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 August 11, 2018. This Internet-Draft will expire on March 18, 2019.
Copyright Notice Copyright Notice
Copyright (c) 2018 IETF Trust and the persons identified as the Copyright (c) 2018 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
skipping to change at page 2, line 18 skipping to change at page 2, line 18
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 2.1. YANG Schema Item iDentifier (SID) . . . . . . . . . . . . 5
2.2. CBOR diagnostic notation . . . . . . . . . . . . . . . . 5 2.2. CBOR diagnostic notation . . . . . . . . . . . . . . . . 5
3. Properties of the CBOR Encoding . . . . . . . . . . . . . . . 6 3. Properties of the CBOR Encoding . . . . . . . . . . . . . . . 6
4. Encoding of YANG Data Node Instances . . . . . . . . . . . . 7 4. Encoding of YANG Schema Node Instances . . . . . . . . . . . 7
4.1. The 'leaf' Data Node . . . . . . . . . . . . . . . . . . 7 4.1. The 'leaf' . . . . . . . . . . . . . . . . . . . . . . . 7
4.2. The 'container' Data Node . . . . . . . . . . . . . . . . 7 4.2. The 'container' and other collections . . . . . . . . . . 8
4.2.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . 8 4.2.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . 8
4.2.2. Member names as keys . . . . . . . . . . . . . . . . 10 4.2.2. Member names as keys . . . . . . . . . . . . . . . . 9
4.3. The 'leaf-list' Data Node . . . . . . . . . . . . . . . . 10 4.3. The 'leaf-list' . . . . . . . . . . . . . . . . . . . . . 11
4.4. The 'list' Data Node . . . . . . . . . . . . . . . . . . 11 4.4. The 'list' and 'list' instance(s) . . . . . . . . . . . . 11
4.4.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . 11 4.4.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . 12
4.4.2. Member names as keys . . . . . . . . . . . . . . . . 14 4.4.2. Member names as keys . . . . . . . . . . . . . . . . 14
4.5. The 'anydata' Data Node . . . . . . . . . . . . . . . . . 15 4.5. The 'anydata' . . . . . . . . . . . . . . . . . . . . . . 15
4.6. The 'anyxml' Data Node . . . . . . . . . . . . . . . . . 17 4.6. The 'anyxml' . . . . . . . . . . . . . . . . . . . . . . 17
5. Encoding of YANG data templates . . . . . . . . . . . . . . . 17 5. Encoding of YANG data templates . . . . . . . . . . . . . . . 17
5.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . . . 18 5.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . . . 18
5.2. Member names as keys . . . . . . . . . . . . . . . . . . 19 5.2. Member names as keys . . . . . . . . . . . . . . . . . . 19
6. Representing YANG Data Types in CBOR . . . . . . . . . . . . 20 6. Representing YANG Data Types in CBOR . . . . . . . . . . . . 20
6.1. The unsigned integer Types . . . . . . . . . . . . . . . 20 6.1. The unsigned integer Types . . . . . . . . . . . . . . . 20
6.2. The integer Types . . . . . . . . . . . . . . . . . . . . 21 6.2. The integer Types . . . . . . . . . . . . . . . . . . . . 21
6.3. The 'decimal64' Type . . . . . . . . . . . . . . . . . . 21 6.3. The 'decimal64' Type . . . . . . . . . . . . . . . . . . 21
6.4. The 'string' Type . . . . . . . . . . . . . . . . . . . . 22 6.4. The 'string' Type . . . . . . . . . . . . . . . . . . . . 22
6.5. The 'boolean' Type . . . . . . . . . . . . . . . . . . . 22 6.5. The 'boolean' Type . . . . . . . . . . . . . . . . . . . 22
6.6. The 'enumeration' Type . . . . . . . . . . . . . . . . . 22 6.6. The 'enumeration' Type . . . . . . . . . . . . . . . . . 22
skipping to change at page 3, line 5 skipping to change at page 3, line 5
6.10.1. SIDs as identityref . . . . . . . . . . . . . . . . 25 6.10.1. SIDs as identityref . . . . . . . . . . . . . . . . 25
6.10.2. Name as identityref . . . . . . . . . . . . . . . . 26 6.10.2. Name as identityref . . . . . . . . . . . . . . . . 26
6.11. The 'empty' Type . . . . . . . . . . . . . . . . . . . . 26 6.11. The 'empty' Type . . . . . . . . . . . . . . . . . . . . 26
6.12. The 'union' Type . . . . . . . . . . . . . . . . . . . . 27 6.12. The 'union' Type . . . . . . . . . . . . . . . . . . . . 27
6.13. The 'instance-identifier' Type . . . . . . . . . . . . . 28 6.13. The 'instance-identifier' Type . . . . . . . . . . . . . 28
6.13.1. SIDs as instance-identifier . . . . . . . . . . . . 28 6.13.1. SIDs as instance-identifier . . . . . . . . . . . . 28
6.13.2. Names as instance-identifier . . . . . . . . . . . . 31 6.13.2. Names as instance-identifier . . . . . . . . . . . . 31
7. Security Considerations . . . . . . . . . . . . . . . . . . . 32 7. Security Considerations . . . . . . . . . . . . . . . . . . . 32
8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 32 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 32
8.1. Tags Registry . . . . . . . . . . . . . . . . . . . . . . 32 8.1. Tags Registry . . . . . . . . . . . . . . . . . . . . . . 32
9. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 32 9. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 33
10. References . . . . . . . . . . . . . . . . . . . . . . . . . 33 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 33
10.1. Normative References . . . . . . . . . . . . . . . . . . 33 10.1. Normative References . . . . . . . . . . . . . . . . . . 33
10.2. Informative References . . . . . . . . . . . . . . . . . 33 10.2. Informative References . . . . . . . . . . . . . . . . . 34
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 34 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 34
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
skipping to change at page 6, line 9 skipping to change at page 6, line 9
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 |
+----------+------+--------------------------+-----------+----------+ +----------+------+--------------------------+-----------+----------+
| Unsigned | 0 | Decimal digits | 123 | 18 7b | | Unsigned | 0 | Decimal digits | 123 | 18 7B |
| integer | | | | | | integer | | | | |
| Negative | 1 | Decimal digits prefixed | -123 | 38 7a | | Negative | 1 | Decimal digits prefixed | -123 | 38 7A |
| integer | | by a minus sign | | | | integer | | by a minus sign | | |
| Byte | 2 | Hexadecimal value | h'f15c' | 42 f15c | | Byte | 2 | Hexadecimal value | h'F15C' | 42 f15C |
| string | | enclosed between single | | | | string | | enclosed between single | | |
| | | quotes and prefixed by | | | | | | quotes and prefixed by | | |
| | | an 'h' | | | | | | an 'h' | | |
| Text | 3 | String of Unicode | "txt" | 63 | | Text | 3 | String of Unicode | "txt" | 63 |
| string | | characters enclosed | | 747874 | | string | | characters enclosed | | 747874 |
| | | between double quotes | | | | | | between double quotes | | |
| Array | 4 | Comma-separated list of | [ 1, 2 ] | 82 01 02 | | Array | 4 | Comma-separated list of | [ 1, 2 ] | 82 01 02 |
| | | values within square | | | | | | values within square | | |
| | | brackets | | | | | | brackets | | |
| Map | 5 | Comma-separated list of | { 1: 123, | a2 | | Map | 5 | Comma-separated list of | { 1: 123, | a2 |
| | | key : value pairs within | 2: 456 } | 01187b | | | | key : value pairs within | 2: 456 } | 01187B |
| | | 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 The following extensions to the CBOR diagnostic notation are
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.
skipping to change at page 6, line 51 skipping to change at page 6, line 51
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. Properties of the CBOR Encoding
This document defines CBOR encoding rules for YANG schema trees and This document defines CBOR encoding rules for YANG schema trees and
their subtrees. their subtrees.
Basic schema nodes such as leaf, leaf-list, list, anydata and anyxml
can be encoded standalone. In this case, only the value of this
schema node is encoded in CBOR. Identification of this value needs
to be provided by some external means when required.
A collection such as container, list instance, notification, RPC A collection such as container, list instance, notification, RPC
input, RPC output, action input and action output is serialized using 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 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 a value. This specification supports two type of CBOR keys; YANG
Schema Item iDentifier (SID) as defined in Section 2.1 and member Schema Item iDentifier (SID) as defined in Section 2.1 and member
names as defined in [RFC7951]. Each of these key types is encoded names as defined in [RFC7951]. Each of these key types is encoded
using a specific CBOR type which allows their interpretation during using a specific CBOR type which allows their interpretation during
the deserialization process. The end user of this mapping the deserialization process. Protocols or mechanisms implementing
specification (e.g. RESTCONF [RFC8040], CoMI [I-D.ietf-core-comi]) this specification can mandate the use of a specific key type.
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 data nodes and the union datatype to distinguish case of anyxml schema nodes and the union datatype to distinguish
explicitly the use of different YANG datatypes encoded using the same explicitly the use of different YANG datatypes encoded using the same
CBOR major type. CBOR major type.
4. Encoding of YANG Data Node Instances 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.
Data nodes implemented using a CBOR array, map, byte string, and text
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
defined by this specification (e.g. CoAP Content-Format) SHOULD
include the identifier (e.g. SID, namespace-qualified member name,
instance-identifier) of this value. When SIDs are used as
identifiers, the reference SID SHALL be included in the payload to
allow stateless conversion of delta values to SIDs. Formats of these
application payloads are not defined by the current specification and
are not shown in the examples.
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' Data Node 4.1. The 'leaf'
Leafs MUST be encoded based on the encoding rules specified in A 'leaf' MUST be encoded accordingly to its datatype using one of the
Section 6. encoding rules specified in Section 6.
4.2. The 'container' Data Node 4.2. The 'container' and other collections
Collections such as containers, list instances, notifications, RPC Collections such as containers, list instances, notification
inputs, RPC outputs, action inputs and action outputs MUST be encoded contents, rpc inputs, rpc outputs, action inputs and action outputs
using a CBOR map data item (major type 5). A map is comprised of MUST be encoded using a CBOR map data item (major type 5). A map is
pairs of data items, with each data item consisting of a key and a comprised of pairs of data items, with each data item consisting of a
value. Each key within the CBOR map is set to a data node key and a value. Each key within the CBOR map is set to a schema
identifier, each value is set to the value of this data node instance node identifier, each value is set to the value of this schema node
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 encoded as deltas and member names as defined in Section 2.1 and member names as defined in [RFC7951].
[RFC7951] encoded using CBOR text strings. The use of CBOR byte
strings for keys is reserved for future extensions.
4.2.1. SIDs as keys
Keys implemented using SIDs MUST be encoded using a CBOR unsigned
integer (major type 0) or CBOR negative integer (major type 1),
depending on the actual value. Keys are represented as the delta of
the associated SID, delta values are computed as follows:
o The delta value is equal to the SID of the current schema node
minus the SID of the parent schema node. When no parent exists in
the context of use of this container, the delta is set to the SID
of the current schema node (i.e., a parent with SID equal to zero
is assumed).
o Delta values may result in a negative number, clients and servers
MUST support both unsigned and negative deltas.
The following example shows the encoding of a 'system-state' The following examples shows the encoding of a 'system-state'
container instance with a single child, a clock container. The clock container instance using SIDs or member names.
container container has two children, a 'current-datetime' leaf and a
'boot-datetime' leaf.
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 48 skipping to change at page 8, line 43
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;
} }
} }
} }
For this first representation, we assume that the SID of the parent 4.2.1. SIDs as keys
container (i.e. 'system-state') is not available to the serializer.
In this case, root data nodes are encoded using absolute SIDs.
CBOR diagnostic notation:
{ CBOR map keys implemented using SIDs MUST be encoded using a CBOR
1717 : { / clock (SID 1717) / unsigned integer (major type 0) or CBOR negative integer (major type
+2 : "2015-10-02T14:47:24Z-05:00", / current-datetime (SID 1719)/ 1), depending on the actual delta value. Delta values are computed
+1 : "2015-09-15T09:12:58Z-05:00" / boot-datetime (SID 1718) / as follows:
}
}
CBOR encoding: 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'.
a1 # map(1) o In the case of an 'rpc input' or 'rcp output', deltas are equal to
19 06b5 # unsigned(1717) the SID of the current schema node minus the SID of the 'rpc'.
a2 # map(2)
02 # unsigned(2)
78 1a # text(26)
323031352d31302d30325431343a34373a32345a2d30353a3030
01 # unsigned(1)
78 1a # text(26)
323031352d30392d31355430393a31323a35385a2d30353a3030
On the other hand, if the serializer is aware of the parent SID, 1716 o In the case of an 'action input' or 'action output', deltas are
in the case 'system-state' container, root data nodes are encoded equal to the SID of the current schema node minus the SID of the
using deltas. 'action'.
CBOR diagnostic notation: CBOR diagnostic notation:
{ { / system-state (SID 1720) /
+1 : { / clock (SID 1717) / +1 : { / clock (SID 1721) /
+2 : "2015-10-02T14:47:24Z-05:00", / current-datetime (SID 1719)/ +2 : "2015-10-02T14:47:24Z-05:00", / current-datetime (SID 1723)/
+1 : "2015-09-15T09:12:58Z-05:00" / boot-datetime (SID 1718) / +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) 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. Member names as keys 4.2.2. Member names as keys
Keys implemented using member names MUST be encoded using a CBOR text CBOR map keys implemented using member names MUST be encoded using a
string data item (major type 3). A namespace-qualified member name CBOR text string data item (major type 3). A namespace-qualified
MUST be used for all members of a top-level collection, and then also member name MUST be used each time the namespace of a schema node and
whenever the namespaces of the schema node and its parent are its parent differ. In all other cases, the simple form of the member
different. In all other cases, the simple form of the member name name MUST be used. Names and namespaces are defined in [RFC7951]
MUST be used. Names and namespaces are defined in [RFC7951] section section 4.
4.
The following example shows the encoding of a 'system' container The following example shows the encoding of a 'system' container
instance using names. This example is described in Section 4.2.1. instance using names.
Definition example from [RFC7317]:
typedef date-and-time {
type string {
pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-]
\d{2}:\d{2})';
}
}
container system-state {
container clock {
leaf current-datetime {
type date-and-time;
}
leaf boot-datetime {
type date-and-time;
}
}
}
CBOR diagnostic notation: CBOR diagnostic notation:
{ {
"ietf-system:clock" : { "ietf-system: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)
71 # text(17) 71 # text(17)
696574662d73797374656d3a636c6f636b # "ietf-system:clock" 696574662D73797374656D3A636C6F636B # "ietf-system:clock"
a2 # map(2) A2 # map(2)
70 # text(16) 70 # text(16)
63757272656e742d6461746574696d65 # "current-datetime" 63757272656E742D6461746574696D65 # "current-datetime"
78 1a # text(26) 78 1A # text(26)
323031352d31302d30325431343a34373a32345a2d30353a3030 323031352D31302D30325431343A34373A32345A2D30353A3030
6d # text(13) 6D # text(13)
626f6f742d6461746574696d65 # "boot-datetime" 626F6F742D6461746574696D65 # "boot-datetime"
78 1a # text(26) 78 1A # text(26)
323031352d30392d31355430393a31323a35385a2d30353a3030 323031352D30392D31355430393A31323A35385A2D30353A3030
4.3. The 'leaf-list' Data Node 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 using the rules defined 4). Each entry of this array MUST be encoded accordingly to its
by the YANG type specified. datatype using one of the encoding rules specified in Section 6.
The following example shows the encoding a 'search' leaf-list The following example shows the encoding of the 'search' leaf-list
instance containing the two entries, "ietf.org" and "ieee.org". instance containing two entries, "ietf.org" and "ieee.org".
Definition example [RFC7317]: Definition example [RFC7317]:
typedef domain-name { typedef domain-name {
type string { type string {
length "1..253"; length "1..253";
pattern '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9].) pattern '((([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]\.? *([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" ] CBOR diagnostic notation: [ "ietf.org", "ieee.org" ]
CBOR encoding: 82 68 696574662e6f7267 68 696565652e6f7267 CBOR encoding: 82 68 696574662E6F7267 68 696565652E6F7267
4.4. The 'list' Data Node 4.4. The 'list' and 'list' instance(s)
A list MUST be encoded using a CBOR array data item (major type 4). A list or a subset of a list MUST be encoded using a CBOR array data
Each list instance within this CBOR array is encoded using a CBOR map item (major type 4). Each list instance within this CBOR array is
data item (major type 5) based on the same rules as a YANG container encoded using a CBOR map data item (major type 5) based on the
as defined in Section 4.2. encoding rules of a collection as defined in Section 4.2.
4.4.1. SIDs as keys It is important to note that this encoding rule also apply to a
single 'list' instance.
The following example show the encoding of a 'server' list instance The following examples show the encoding of a 'server' list using
using SIDs. It is important to note that the protocol or method SIDs or member names.
using this mapping may carry a parent SID or may have the knowledge
of this parent SID based on its context. In these cases, delta
encoding can be performed based on this parent SID which minimizes
the size of the encoded data.
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 42 skipping to change at page 12, 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
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
current schema node minus the SID of the 'list'.
CBOR diagnostic notation: CBOR diagnostic notation:
[ [ / server (SID 1756) /
{ {
1755 : "NRC TIC server", / name (SID 1755) / +3 : "NRC TIC server", / name (SID 1759) /
1757 : { / udp (SID 1757) / +5 : { / udp (SID 1761) /
+1 : "tic.nrc.ca", / address (SID 1758) / +1 : "tic.nrc.ca", / address (SID 1762) /
+2 : 123 / port (SID 1759) / +2 : 123 / port (SID 1763) /
}, },
1753 : 0, / association-type (SID 1753) / +1 : 0, / association-type (SID 1757) /
1754 : false, / iburst (SID 1754) / +2 : false, / iburst (SID 1758) /
1756 : true / prefer (SID 1756) / +4 : true / prefer (SID 1760) /
}, },
{ {
1755 : "NRC TAC server", / name (SID 1755) / +3 : "NRC TAC server", / name (SID 1759) /
1757 : { / udp (SID 1757) / +5 : { / udp (SID 1761) /
+1 : "tac.nrc.ca" / address (SID 1758) / +1 : "tac.nrc.ca" / address (SID 1762) /
} }
} }
] ]
CBOR encoding: CBOR encoding:
82 # array(2) 82 # array(2)
a5 # map(5) A5 # map(5)
19 06db # unsigned(1755) 03 # unsigned(3)
6e # text(14) 6E # text(14)
4e52432054494320736572766572 # "NRC TIC server" 4E52432054494320736572766572 # "NRC TIC server"
19 06dd # unsigned(1757) 05 # unsigned(5)
a2 # map(2) A2 # map(2)
01 # unsigned(1) 01 # unsigned(1)
6a # text(10) 6A # text(10)
7469632e6e72632e6361 # "tic.nrc.ca" 7469632E6E72632E6361 # "tic.nrc.ca"
02 # unsigned(2) 02 # unsigned(2)
18 7b # unsigned(123) 18 7B # unsigned(123)
19 06d9 # unsigned(1753) 01 # unsigned(1)
00 # unsigned(0) 00 # unsigned(0)
19 06da # unsigned(1754) 02 # unsigned(2)
f4 # primitive(20) F4 # primitive(20)
19 06dc # unsigned(1756) 04 # unsigned(4)
f5 # primitive(21) F5 # primitive(21)
a2 # map(2) A2 # map(2)
19 06db # unsigned(1755) 03 # unsigned(3)
6e # text(14) 6E # text(14)
4e52432054414320736572766572 # "NRC TAC server" 4E52432054414320736572766572 # "NRC TAC server"
19 06dd # unsigned(1757) 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. Member names as keys 4.4.2. Member names as keys
The following example shows the encoding of a 'server' list instance The encoding rules of each 'list' instance are defined in
using names. This example is described in Section 4.4.1. Section 4.2.2.
CBOR diagnostic notation: CBOR diagnostic notation:
[ [
{ {
"ietf-system:name" : "NRC TIC server", "ietf-system:name" : "NRC TIC server",
"ietf-system:udp" : { "ietf-system:udp" : {
"address" : "tic.nrc.ca", "address" : "tic.nrc.ca",
"port" : 123 "port" : 123
}, },
skipping to change at page 15, line 5 skipping to change at page 15, line 5
{ {
"ietf-system:name" : "NRC TAC server", "ietf-system:name" : "NRC TAC server",
"ietf-system:udp" : { "ietf-system:udp" : {
"address" : "tac.nrc.ca" "address" : "tac.nrc.ca"
} }
} }
] ]
CBOR encoding: CBOR encoding:
82 # array(2) 82 # array(2)
a5 # map(5) A5 # map(5)
70 # text(16) 70 # text(16)
696574662d73797374656d3a6e616d65 # "ietf-system:name" 696574662D73797374656D3A6E616D65 # "ietf-system:name"
6e # text(14) 6E # text(14)
4e52432054494320736572766572 # "NRC TIC server" 4E52432054494320736572766572 # "NRC TIC server"
6f # text(15) 6F # text(15)
696574662d73797374656d3a756470 # "ietf-system:udp" 696574662D73797374656D3A756470 # "ietf-system:udp"
a2 # map(2) A2 # map(2)
67 # text(7) 67 # text(7)
61646472657373 # "address" 61646472657373 # "address"
6a # text(10) 6A # text(10)
7469632e6e72632e6361 # "tic.nrc.ca" 7469632E6E72632E6361 # "tic.nrc.ca"
64 # text(4) 64 # text(4)
706f7274 # "port" 706F7274 # "port"
18 7b # unsigned(123) 18 7B # unsigned(123)
78 1c # text(28) 78 1C # text(28)
696574662d73797374656d3a6173736f63696174696f6e2d74797065 696574662D73797374656D3A6173736F63696174696F6E2D74797065
00 # unsigned(0) 00 # unsigned(0)
72 # text(18) 72 # text(18)
696574662d73797374656d3a696275727374 # "ietf-system:iburst" 696574662D73797374656D3A696275727374 # "ietf-system:iburst"
f4 # primitive(20) F4 # primitive(20)
72 # text(18) 72 # text(18)
696574662d73797374656d3a707265666572 # "ietf-system:prefer" 696574662D73797374656D3A707265666572 # "ietf-system:prefer"
f5 # primitive(21) F5 # primitive(21)
a2 # map(2) A2 # map(2)
70 # text(16) 70 # text(16)
696574662d73797374656d3a6e616d65 # "ietf-system:name" 696574662D73797374656D3A6E616D65 # "ietf-system:name"
6e # text(14) 6E # text(14)
4e52432054414320736572766572 # "NRC TAC server" 4E52432054414320736572766572 # "NRC TAC server"
6f # text(15) 6F # text(15)
696574662d73797374656d3a756470 # "ietf-system:udp" 696574662D73797374656D3A756470 # "ietf-system:udp"
a1 # map(1) A1 # map(1)
67 # text(7) 67 # text(7)
61646472657373 # "address" 61646472657373 # "address"
6a # text(10) 6A # text(10)
7461632e6e72632e6361 # "tac.nrc.ca" 7461632E6E72632E6361 # "tac.nrc.ca"
4.5. The 'anydata' Data Node 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 Keys of any inner data nodes MUST be set to valid deltas or member o CBOR map keys of any inner schema nodes MUST be set to valid
names. deltas or member 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 Values MUST follow the encoding rules of one of the datatypes o CBOR map values MUST follow the encoding rules of one of the
listed in Section 6. datatypes listed in Section 4.
The following example shows a possible use of anydata. In this The following example shows a possible use of an anydata. In this
example, an anydata is used to define a data node containing a example, an anydata is used to define a schema node containing a
notification event, this data 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:
anydata event; module event-log {
...
anydata 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 2600 notification example-port-fault { # SID 60200
leaf port-name { # SID 2601 leaf port-name { # SID 60201
type string; type string;
} }
leaf port-fault { # SID 2601 leaf port-fault { # SID 60202
type string; type string;
} }
} }
} }
CBOR diagnostic notation: CBOR diagnostic notation:
{ { / event (SID=60123) /
2601 : "0/4/21", / port-name / +78 : "0/4/21", / port-name (SID=60201) /
2602 : "Open pin 2" / port-fault / +79 : "Open pin 2" / port-fault (SID=60202) /
} }
CBOR encoding: CBOR encoding:
a2 # map(2) A2 # map(2)
19 0a29 # unsigned(2601) 18 4E # unsigned(78)
66 # text(6) 66 # text(6)
302f342f3231 # "0/4/21" 302F342F3231 # "0/4/21"
19 0a2a # unsigned(2602) 18 4F # unsigned(79)
6a # text(10) 6A # text(10)
4f70656e2070696e2032 # "Open pin 2" 4F70656E2070696E2032 # "Open pin 2"
4.6. The 'anyxml' Data Node 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. The following example shows a valid CBOR encoded instance consisting
of a CBOR array containing the CBOR simple values 'true', 'null' and
'true'.
Definition example from [RFC7951]: Definition example from [RFC7951]:
anyxml bar; anyxml bar;
CBOR diagnostic notation: [true, null, true] CBOR diagnostic notation: [true, null, true]
CBOR encoding: 83 f5 f6 f5 CBOR encoding: 83 f5 f6 f5
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.
The encoding rules defined for YANG containers in section 4.2 may be YANG data templates SHOULD be encoded using the encoding rules of a
used to serialize YANG data templates. collection as defined in Section 4.2.
Just like YANG containers, YANG data templates can be encoded using
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;
} }
rc:yang-data yang-errors { rc:yang-data yang-errors {
container error { container error {
leaf error-tag { leaf error-tag {
skipping to change at page 18, line 30 skipping to change at page 18, 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;
} }
} }
} }
Just like YANG containers, YANG data templates can be encoded using
either SIDs or names.
5.1. SIDs as keys 5.1. SIDs as keys
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. template using SIDs as CBOR map key. The reference SID of a YANG
data template is zero, this imply that the CBOR map keys of the top
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) /
/ = timezone-utc-offset (SID 1740) / / = timezone-utc-offset (SID 1740) /
+3 : "max value 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)
76 # text(22) 70 # text(16)
6D6178696D756D2076616C7565206578636565646564 4D6178696D756D206578636565646564
5.2. Member names as keys 5.2. Member names as keys
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 using member names as CBOR map key.
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" : "max value exceeded" "error-message" : "Maximum exceeded"
} }
} }
CBOR encoding: CBOR encoding:
A1 # map(1) A1 # map(1)
6F # text(15) 6F # text(15)
696574662D636F6D693A6572726F72 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 696E76616C69642D76616C7565 # "invalid-value"
6D # text(13) 6D # text(13)
6572726F722D6170702D746167 6572726F722D6170702D746167 # "error-app-tag"
6C # text(12) 6C # text(12)
6E6F742D696E2D72616E6765 6E6F742D696E2D72616E6765 # "not-in-range"
6F # text(15) 6F # text(15)
6572726F722D646174612D6E6F6465 6572726F722D646174612D6E6F6465 # "error-data-node"
73 # text(19) 73 # text(19)
74696D657A6F6E652D7574632D6F6666736574 74696D657A6F6E652D7574632D6F6666736574 # "timezone-utc-offset"
6D # text(13) 6D # text(13)
6572726F722D6D657373616765 6572726F722D6D657373616765 # "error-message"
72 # text(18) 70 # text(16)
6D61782076616C7565206578636565646564 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 data node The CBOR encoding of an instance of a leaf or leaf-list schema node
depends on the built-in type of that data 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 data 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.
skipping to change at page 21, line 25 skipping to change at page 21, line 25
Definition example from [RFC7317]: Definition example from [RFC7317]:
leaf timezone-utc-offset { leaf timezone-utc-offset {
type int16 { type int16 {
range "-1500 .. 1500"; range "-1500 .. 1500";
} }
} }
CBOR diagnostic notation: -300 CBOR diagnostic notation: -300
CBOR encoding: 39 012b CBOR encoding: 39 012B
6.3. The 'decimal64' Type 6.3. The 'decimal64' Type
Leafs of type decimal64 MUST be encoded using a decimal fraction as Leafs of type decimal64 MUST be encoded using a decimal fraction as
defined in [RFC7049] section 2.4.3. defined in [RFC7049] section 2.4.3.
The following example shows the encoding of a 'my-decimal' leaf The following example shows the encoding of a 'my-decimal' leaf
instance set to 2.57. instance set to 2.57.
Definition example from [RFC7317]: Definition example from [RFC7317]:
leaf my-decimal { leaf my-decimal {
type decimal64 { type decimal64 {
fraction-digits 2; fraction-digits 2;
range "1 .. 3.14 | 10 | 20..max"; range "1 .. 3.14 | 10 | 20..max";
} }
} }
CBOR diagnostic notation: 4([-2, 257]) CBOR diagnostic notation: 4([-2, 257])
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 [RFC7223]:
skipping to change at page 22, line 25 skipping to change at page 22, line 25
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
Leafs of type boolean MUST be encoded using a CBOR true (major type Leafs of type boolean MUST be encoded using a CBOR simple value
7, additional information 21) or false data item (major type 7, 'true' (major type 7, additional information 21) or 'false' (major
additional information 20). type 7, additional information 20).
The following example shows the encoding of an 'enabled' leaf The following example shows the encoding of an 'enabled' leaf
instance set to 'true'. instance set to 'true'.
Definition example from [RFC7317]: Definition example from [RFC7317]:
leaf enabled { leaf enabled {
type boolean; type boolean;
} }
CBOR diagnostic notation: true CBOR diagnostic notation: true
CBOR encoding: f5 CBOR encoding: F5
6.6. The 'enumeration' Type 6.6. The 'enumeration' Type
Leafs of type enumeration MUST be encoded using a CBOR unsigned Leafs of type enumeration MUST be encoded using a CBOR unsigned
integer (major type 0) or CBOR negative integer (major type 1), integer (major type 0) or CBOR negative integer (major type 1),
depending on the actual value. Enumeration values are either depending on the actual value. Enumeration values are either
explicitly assigned using the YANG statement 'value' or automatically explicitly assigned using the YANG statement 'value' or automatically
assigned based on the algorithm defined in [RFC7950] section 9.6.4.2. assigned based on the algorithm defined in [RFC7950] section 9.6.4.2.
The following example shows the encoding of an 'oper-status' leaf The following example shows the encoding of an 'oper-status' leaf
skipping to change at page 24, line 24 skipping to change at page 24, line 24
instance set to 0x1f1ce6a3f42660d888d92a4d8030476e. instance set to 0x1f1ce6a3f42660d888d92a4d8030476e.
Definition example: Definition example:
leaf aes128-key { leaf aes128-key {
type binary { type binary {
length 16; length 16;
} }
} }
CBOR diagnostic notation: h'1f1ce6a3f42660d888d92a4d8030476e' CBOR diagnostic notation: h'1F1CE6A3F42660D888D92A4D8030476E'
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 [RFC7223]:
skipping to change at page 25, line 41 skipping to change at page 25, line 41
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
set to the value 'iana-if-type:ethernetCsmacd' (SID 1180). set to the value 'iana-if-type:ethernetCsmacd' (SID 1880).
Definition example from [RFC7317]: Definition example from [RFC7317]:
identity interface-type { identity interface-type {
} }
identity iana-interface-type { identity iana-interface-type {
base interface-type; base interface-type;
} }
identity ethernetCsmacd { identity ethernetCsmacd {
base iana-interface-type; base iana-interface-type;
} }
leaf type { leaf type {
type identityref { type identityref {
base interface-type; base interface-type;
} }
} }
CBOR diagnostic notation: 1180 CBOR diagnostic notation: 1880
CBOR encoding: 19 049c 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 [RFC7951] section 6.8. When names are used, identityref MUST be
encoded using a CBOR text string data item (major type 3). If the encoded using a CBOR text string data item (major type 3). If the
identity is defined in another module than the leaf node containing identity is defined in different module than the leaf node containing
the identityref value, the namespace-qualified form MUST be used. the identityref value, 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 [RFC7951] section 4.
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 name. This example is described in
Section 6.10.1. 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).
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 [RFC7277]:
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 prefixed by 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
See Section 8.1 for more information about these CBOR tags. See Section 8.1 for the assigned value of these CBOR tags.
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}
skipping to change at page 28, line 37 skipping to change at page 28, line 37
type ipv6-address; type ipv6-address;
} }
} }
leaf address { leaf address {
type inet:ip-address; type inet:ip-address;
} }
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 2.1 and one based on names as defined in [RFC7951] section
6.11. 6.11.
6.13.1. SIDs as instance-identifier 6.13.1. SIDs as instance-identifier
SIDs uniquely identify a data node. In the case of a single instance SIDs uniquely identify a schema node. In the case of a single
data node, a data node defined at the root of a YANG module or instance schema node, i.e. a schema node defined at the root of a
submodule or data nodes defined within a container, the SID is YANG module or submodule or schema nodes defined within a container,
sufficient to identify this instance. the SID is sufficient to identify this instance.
In the case of a data 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
list(s). list(s).
Single instance data nodes MUST be encoded using a CBOR unsigned Single instance schema nodes MUST be encoded using a CBOR unsigned
integer data item (major type 0) and set to the targeted data node integer data item (major type 0) and set to the targeted schema node
SID. SID.
Data nodes member of a YANG list MUST be encoded using a CBOR array Schema nodes member of a YANG list MUST be encoded using a CBOR array
data item (major type 4) containing the following entries: data item (major type 4) containing the following entries:
o The first entry MUST be encoded as a CBOR unsigned integer data o The first entry MUST be encoded as a CBOR unsigned integer data
item (major type 0) and set to the targeted data node SID. item (major type 0) and set to the targeted schema node SID.
o The following entries MUST contain the value of each key required o The following entries MUST contain the value of each key required
to identify the instance of the targeted data node. These keys to identify the instance of the targeted schema node. These keys
MUST be ordered as defined in the 'key' YANG statement, starting MUST be ordered as defined in the 'key' YANG statement, starting
from top level list, and follow by each of the subordinate from top level list, and follow by each of the subordinate
list(s). list(s).
Examples within this section assume the definition of a schema node
of type 'instance-identifier':
Definition example from [RFC7950]:
container system {
...
leaf reporting-entity {
type instance-identifier;
}
leaf contact { type string; }
leaf hostname { type inet:domain-name; } } ~~~~
*First example:* *First example:*
The following example shows the encoding of a leaf instance of type The following example shows the encoding of the 'reporting-entity'
instance-identifier which identifies the data node "/system/contact" value referencing data node instance "/system/contact" (SID 1741).
(SID 1737).
Definition example from [RFC7317]: Definition example from [RFC7317]:
container system { container system {
leaf contact { leaf contact {
type string; type string;
} }
leaf hostname { leaf hostname {
type inet:domain-name; type inet:domain-name;
} }
} }
CBOR diagnostic notation: 1737 CBOR diagnostic notation: 1741
CBOR encoding: 19 06c9 CBOR encoding: 19 06CD
*Second example:* *Second example:*
The following example shows the encoding of a leaf instance of type The following example shows the encoding of the 'reporting-entity'
instance-identifier which identify the data node instance value referencing list instance "/system/authentication/user/
"/system/authentication/user/authorized-key/key-data" (SID 1730) for authorized-key/key-data" (SID 1734) for user name "bob" and
user name "bob" and authorized-key "admin". authorized-key "admin".
Definition example from [RFC7317]: Definition example from [RFC7317]:
list user { list user {
key name; key name;
leaf name { leaf name {
type string; type string;
} }
leaf password { leaf password {
skipping to change at page 30, line 32 skipping to change at page 31, line 4
leaf name { leaf name {
type string; type string;
} }
leaf algorithm { leaf algorithm {
type string; type string;
} }
leaf key-data { leaf key-data {
type binary; type binary;
} }
} }
CBOR diagnostic notation: [1734, "bob", "admin"]
CBOR diagnostic notation: [1730, "bob", "admin"]
CBOR encoding: CBOR encoding:
83 # array(3) 83 # array(3)
19 06c2 # unsigned(1730) 19 06C6 # unsigned(1734)
63 # text(3) 63 # text(3)
626f62 # "bob" 626F62 # "bob"
65 # text(5) 65 # text(5)
61646d696e # "admin" 61646D696E # "admin"
*Third example:* *Third example:*
The following example shows the encoding of a leaf instance of type The following example shows the encoding of the 'reporting-entity'
instance-identifier which identify the list instance value referencing the list instance "/system/authentication/user"
"/system/authentication/user" (SID 1726) corresponding to the user (SID 1730) corresponding to user name "jack".
name "jack".
CBOR diagnostic notation: [1730, "jack"]
CBOR diagnostic notation: [1726, "jack"]
CBOR encoding: CBOR encoding:
82 # array(2) 82 # array(2)
19 06be # unsigned(1726) 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] The use of names as instance-identifier is defined in [RFC7951]
section 6.11. The resulting xpath MUST be encoded using a CBOR text section 6.11. The resulting xpath MUST be encoded using a CBOR text
string data item (major type 3). 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 2f20696574662d73797374656d3a73797374656d2f636f6e74616374 78 1c 2F696574662D73797374656D3A73797374656D2F636F6E74616374
*Second example:* *Second example:*
This example is described in Section 6.13.1. This example is described in Section 6.13.1.
CBOR diagnostic notation: CBOR diagnostic notation:
"/ietf-system:system/authentication/user[name='bob']/authorized-key "/ietf-system:system/authentication/user[name='bob']/authorized-key
[name='admin']/key-data" [name='admin']/key-data"
CBOR encoding: CBOR encoding:
78 59 78 59
2f696574662d73797374656d3a73797374656d2f61757468656e74696361 2F696574662D73797374656D3A73797374656D2F61757468656E74696361
74696f6e2f757365725b6e616d653d27626f62275d2f617574686f72697a 74696F6E2F757365725B6E616D653D27626F62275D2F617574686F72697A
65642d6b65795b6e616d653d2761646d696e275d2f6b65792d64617461 65642D6B65790D0A5B6E616D653D2761646D696E275D2F6B65792D64617461
*Third example:* *Third example:*
This example is described in Section 6.13.1. This example is described in Section 6.13.1.
CBOR diagnostic notation: CBOR diagnostic notation:
"/ietf-system:system/authentication/user[name='bob']" "/ietf-system:system/authentication/user[name='bob']"
CBOR encoding: CBOR encoding:
78 33 78 33
2f696574662d73797374656d3a73797374656d2f61757468656e74696361 2F696574662D73797374656D3A73797374656D2F61757468656E74696361
74696f6e2f757365725b6e616d653d27626f62275d 74696F6E2F757365725B6E616D653D27626F62275D
7. Security Considerations 7. Security Considerations
The security considerations of [RFC7049] and [RFC7950] apply. The security considerations of [RFC7049] and [RFC7950] apply.
This document defines an alternative encoding for data modeled in the This document defines an alternative encoding for data modeled in the
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.
skipping to change at page 32, line 33 skipping to change at page 33, line 8
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 |
+-----+---------------------+---------------------------+-----------+ +-----+---------------------+---------------------------+-----------+
| 40 | bits | YANG bits datatype | RFC XXXX | | xx | bits | YANG bits datatype | RFC XXXX |
| 41 | enumeration | YANG enumeration datatype | RFC XXXX | | xx | enumeration | YANG enumeration datatype | RFC XXXX |
| 42 | identityref | YANG identityref datatype | RFC XXXX | | xx | identityref | YANG identityref datatype | RFC XXXX |
| 43 | 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 if needed and // RFC Ed.: update Tag values using allocated tags and remove this
remove this note // RFC Ed.: replace XXXX with RFC number and remove note // RFC Ed.: replace XXXX with RFC number and remove this note
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.
skipping to change at page 33, line 31 skipping to change at page 34, line 9
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>.
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-02 (work in Management Interface", draft-ietf-core-comi-03 (work in
progress), December 2017. progress), June 2018.
[I-D.ietf-core-sid] [I-D.ietf-core-sid]
Veillette, M. and A. Pelov, "YANG Schema Item iDentifier Veillette, M. and A. Pelov, "YANG Schema Item iDentifier
(SID)", draft-ietf-core-sid-03 (work in progress), (SID)", draft-ietf-core-sid-04 (work in progress), June
December 2017. 2018.
[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
 End of changes. 114 change blocks. 
345 lines changed or deleted 366 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/