< draft-ietf-core-yang-cbor-00.txt   draft-ietf-core-yang-cbor-01.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: October 30, 2016 Acklio Expires: December 25, 2016 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
April 28, 2016 June 23, 2016
CBOR Encoding of Data Modeled with YANG CBOR Encoding of Data Modeled with YANG
draft-ietf-core-yang-cbor-00 draft-ietf-core-yang-cbor-01
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 http://datatracker.ietf.org/drafts/current/. Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on October 30, 2016. This Internet-Draft will expire on December 25, 2016.
Copyright Notice Copyright Notice
Copyright (c) 2016 IETF Trust and the persons identified as the Copyright (c) 2016 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
(http://trustee.ietf.org/license-info) in effect on the date of (http://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 . . . . . . . . . . . . . . . . . . . . . . . . 2 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
2. Terminology and Notation . . . . . . . . . . . . . . . . . . 3 2. Terminology and Notation . . . . . . . . . . . . . . . . . . 3
2.1. CBOR diagnostic notation . . . . . . . . . . . . . . . . 4 2.1. CBOR diagnostic notation . . . . . . . . . . . . . . . . 4
3. Properties of the CBOR Encoding . . . . . . . . . . . . . . . 5 3. Properties of the CBOR Encoding . . . . . . . . . . . . . . . 5
4. Encoding of YANG Schema Node Instances . . . . . . . . . . . 6 4. Encoding of YANG Schema Node Instances . . . . . . . . . . . 6
4.1. The "leaf" Schema Node . . . . . . . . . . . . . . . . . 6 4.1. The 'leaf' Schema Node . . . . . . . . . . . . . . . . . 6
4.2. The "container" Schema Node . . . . . . . . . . . . . . . 6 4.2. The 'container' Schema Node . . . . . . . . . . . . . . . 6
4.3. The "leaf-list" Schema Node . . . . . . . . . . . . . . . 9 4.3. The 'leaf-list' Schema Node . . . . . . . . . . . . . . . 10
4.4. The "list" Schema Node . . . . . . . . . . . . . . . . . 10 4.4. The 'list' Schema Node . . . . . . . . . . . . . . . . . 10
4.5. The "anydata" Schema Node . . . . . . . . . . . . . . . . 16 4.5. The 'anydata' Schema Node . . . . . . . . . . . . . . . . 16
4.6. The "anyxml" Schema Node . . . . . . . . . . . . . . . . 17 4.6. The 'anyxml' Schema Node . . . . . . . . . . . . . . . . 17
5. Representing YANG Data Types in CBOR . . . . . . . . . . . . 17 5. Representing YANG Data Types in CBOR . . . . . . . . . . . . 17
5.1. The unsigned integer Types . . . . . . . . . . . . . . . 17 5.1. The unsigned integer Types . . . . . . . . . . . . . . . 17
5.2. The integer Types . . . . . . . . . . . . . . . . . . . . 17 5.2. The integer Types . . . . . . . . . . . . . . . . . . . . 17
5.3. The "decimal64" Type . . . . . . . . . . . . . . . . . . 18 5.3. The 'decimal64' Type . . . . . . . . . . . . . . . . . . 18
5.4. The "string" Type . . . . . . . . . . . . . . . . . . . . 18 5.4. The 'string' Type . . . . . . . . . . . . . . . . . . . . 18
5.5. The "boolean" Type . . . . . . . . . . . . . . . . . . . 19 5.5. The 'boolean' Type . . . . . . . . . . . . . . . . . . . 19
5.6. The "enumeration" Type . . . . . . . . . . . . . . . . . 19 5.6. The 'enumeration' Type . . . . . . . . . . . . . . . . . 19
5.7. The "bits" Type . . . . . . . . . . . . . . . . . . . . . 19 5.7. The 'bits' Type . . . . . . . . . . . . . . . . . . . . . 19
5.8. The "binary" Type . . . . . . . . . . . . . . . . . . . . 20 5.8. The 'binary' Type . . . . . . . . . . . . . . . . . . . . 20
5.9. The "leafref" Type . . . . . . . . . . . . . . . . . . . 20 5.9. The 'leafref' Type . . . . . . . . . . . . . . . . . . . 21
5.10. The "identityref" Type . . . . . . . . . . . . . . . . . 21 5.10. The 'identityref' Type . . . . . . . . . . . . . . . . . 21
5.11. The "empty" Type . . . . . . . . . . . . . . . . . . . . 22 5.11. The 'empty' Type . . . . . . . . . . . . . . . . . . . . 23
5.12. The "union" Type . . . . . . . . . . . . . . . . . . . . 23 5.12. The 'union' Type . . . . . . . . . . . . . . . . . . . . 23
5.13. The "instance-identifier" Type . . . . . . . . . . . . . 23 5.13. The 'instance-identifier' Type . . . . . . . . . . . . . 24
6. Security Considerations . . . . . . . . . . . . . . . . . . . 28 6. Security Considerations . . . . . . . . . . . . . . . . . . . 29
7. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 28 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 29
8. References . . . . . . . . . . . . . . . . . . . . . . . . . 29 7.1. Tags Registry . . . . . . . . . . . . . . . . . . . . . . 29
8.1. Normative References . . . . . . . . . . . . . . . . . . 29 8. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 30
8.2. Informative References . . . . . . . . . . . . . . . . . 29 9. References . . . . . . . . . . . . . . . . . . . . . . . . . 30
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 30 9.1. Normative References . . . . . . . . . . . . . . . . . . 30
9.2. Informative References . . . . . . . . . . . . . . . . . 31
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 31
1. Introduction 1. Introduction
The specification of the YANG 1.1 data modelling language The specification of the YANG 1.1 data modelling language
[I-D.ietf-netmod-rfc6020bis] defines only an XML encoding for data [I-D.ietf-netmod-rfc6020bis] defines only an XML encoding for data
instances, i.e. contents of configuration datastores, state data, RPC instances, i.e. contents of configuration datastores, state data, RPC
inputs and outputs, action inputs and outputs, and event inputs and outputs, action inputs and outputs, and event
notifications. 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 5, line 9 skipping to change at page 5, 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.
+----------+------+--------------------------+-----------+----------+ +----------+------+--------------------------+-----------+----------+
| 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 or | 18 7b |
| integer | | | | | | integer | | | +123 | |
| 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 |
skipping to change at page 5, line 33 skipping to change at page 5, line 33
| 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 | | | | |
+----------+------+--------------------------+-----------+----------+ +----------+------+--------------------------+-----------+----------+
Within this document, comments are allowed in CBOR diagnostic The following extensions to the CBOR diagnostic notation are
notation. Any characters after a Pound sign ('#') outside of a supported:
string, up to the end of the line, are treated as a comment.
o Comments can be added to the end of each line. Any characters
after a Pound sign ('#') outside of a string, up to the end of the
line, are treated as a comment.
o Deltas are represented as positive numbers (e.g. +123).
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 Basic schema nodes such as leaf, leaf-list, list, anydata and anyxml
can be encoded standalone. In this case, only the value of this can be encoded standalone. In this case, only the value of this
schema node is encoded in CBOR. Identification of this value need to schema node is encoded in CBOR. Identification of this value need to
be provided by some external means when needed. be provided by some external means when needed.
skipping to change at page 6, line 4 skipping to change at page 6, line 11
can be encoded standalone. In this case, only the value of this can be encoded standalone. In this case, only the value of this
schema node is encoded in CBOR. Identification of this value need to schema node is encoded in CBOR. Identification of this value need to
be provided by some external means when needed. be provided by some external means when needed.
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 three type of keys; SID as a value. This specification supports three type of keys; SID as
defined in [I-D.somaraju-core-sid], member names as defined in defined in [I-D.somaraju-core-sid], member names as defined in
[I-D.ietf-netmod-yang-json] and YANG hash as defined by [I-D.ietf-netmod-yang-json] and YANG hash as defined by
[I-D.vanderstok-core-comi]. Each of these key type is encoded using [I-D.vanderstok-core-comi]. Each of these key type is encoded using
a specific CBOR type which allows their interpretation during the a specific CBOR type which allows their interpretation during the
deserialization process. The end user of this mapping specification deserialization process. The end user of this mapping specification
can mandate the use of a specific key type or a specific subset of can mandate the use of a specific key type or a specific subset of
key types. key types.
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 does not make use of any meta-information beyond those mapping avoid any unnecessary meta-information beyond those natively
natively supported by CBOR. For instance, CBOR tags are not used for supported by CBOR. For instance, CBOR tags are used sorely in the
any of the proposed mapping. It is expected that entities generating case of the union datatype to distinguish explicitly the use of
and decoding CBOR contents have enough knowledge about the different YANG datatypes encoded using the same CBOR major type.
information processed in order to perform the expected task without
the need of such extra meta-information. The CoAP Content-Format It is expected that entities generating and decoding CBOR contents
Option, or an HTTP Content-Type header field, conveys that the data have enough knowledge about the information processed in order to
is YANG-encoded CBOR in the first place. perform the expected task without the need of such extra meta-
information. The CoAP Content-Format Option, or an HTTP Content-Type
header field, conveys that the data is YANG-encoded CBOR in the first
place.
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 [I-D.ietf-netmod-rfc6020bis] and CBOR [RFC7049]. YANG [I-D.ietf-netmod-rfc6020bis] and CBOR [RFC7049].
4.1. The "leaf" Schema Node 4.1. The 'leaf' Schema Node
Leafs MUST be encoded based on the encoding rules specified in Leafs MUST be encoded based on the encoding rules specified in
Section 5. Section 5.
4.2. The "container" Schema Node 4.2. The 'container' Schema Node
Collections such as containers, list instances, notifications, RPC Collections such as containers, list instances, notifications, RPC
inputs, RPC outputs, action inputs and action outputs MUST be encoded inputs, RPC outputs, action inputs and action outputs MUST be encoded
using a CBOR map data item (major type 5). A map is comprised of 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 key and a pairs of data items, with each data item consisting of a key and a
value. This specification supports three type of keys; SID as value. Each key within the CBOR map is set to a data node
defined in [I-D.somaraju-core-sid], member names as defined in identifier, each value is set to the value of this data node
instance.
This specification supports three type of keys; SID as defined in
[I-D.somaraju-core-sid], member names as defined in
[I-D.ietf-netmod-yang-json] and YANG hash as defined by [I-D.ietf-netmod-yang-json] and YANG hash as defined by
[I-D.vanderstok-core-comi]. [I-D.vanderstok-core-comi].
*SIDs as keys* *SIDs as keys*
Keys implemented using SIDs MUST be encoded using a CBOR unsigned Keys implemented using SIDs MUST be encoded using a CBOR unsigned
integer (major type 0) and set to the delta value of the associated integer (major type 0) or CBOR signed integer (major type 1),
SID. Delta values are computed as follows: depending on the actual value. Keys are set to 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 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 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 the context of use of this container, the delta is set to the SID
of the current schema node (a parent with SID equal to zero is of the current schema node (a parent with SID equal to zero is
assumed). assumed).
o Delta values may result in a negative number, clients and servers o Delta values may result in a negative number, clients and servers
MUST support negative deltas. MUST support negative deltas.
skipping to change at page 8, line 4 skipping to change at page 8, line 26
container clock { container clock {
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;
} }
} }
} }
*SIDs example* *SIDs example*
This example is encoded using the SIDs defined in [I-D.somaraju-core- This example is encoded using the SIDs defined in
sid] Appendix C. [I-D.somaraju-core-sid] Appendix C.
CBOR diagnostic notation: CBOR diagnostic notation:
{ {
1708 : { # clock 1708 : { # clock
2 : "2015-10-02T14:47:24Z-05:00", # current-datetime, SID 1710 +2 : "2015-10-02T14:47:24Z-05:00", # current-datetime, SID 1710
1 : "2015-09-15T09:12:58Z-05:00" # boot-datetime, SID 1709 +1 : "2015-09-15T09:12:58Z-05:00" # boot-datetime, SID 1709
} }
} }
CBOR encoding: CBOR encoding:
a1 # map(1) a1 # map(1)
19 06ac # unsigned(1708) 19 06ac # unsigned(1708)
a2 # map(2) a2 # map(2)
02 # unsigned(2) 02 # unsigned(2)
78 1a # text(26) 78 1a # text(26)
skipping to change at page 9, line 44 skipping to change at page 10, line 18
a2 # map(2) a2 # map(2)
44 # bytes(4) 44 # bytes(4)
047c468b 047c468b
78 1a # text(26) 78 1a # text(26)
323031352d31302d30325431343a34373a32345a2d30353a3030 323031352d31302d30325431343a34373a32345a2d30353a3030
44 # bytes(4) 44 # bytes(4)
2fe1a167 2fe1a167
78 1a # text(26) 78 1a # text(26)
323031352d30392d31355430393a31323a35385a2d30353a3030 323031352d30392d31355430393a31323a35385a2d30353a3030
4.3. The "leaf-list" Schema Node 4.3. The 'leaf-list' Schema Node
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 using the rules defined
by the YANG type specified. by the YANG type specified.
Definition example [RFC7317]: Definition example [RFC7317]:
typedef domain-name { typedef domain-name {
type string { type string {
length "1..253"; length "1..253";
skipping to change at page 10, line 23 skipping to change at page 10, line 44
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" Schema Node 4.4. The 'list' Schema Node
A list MUST be encoded using a CBOR array data item (major type 4). A list MUST be encoded using a CBOR array data item (major type 4).
Each entry of this array is encoded using a CBOR map data item (major Each list instance within this CBOR array is encoded using a CBOR map
type 5) based on the same rules as a YANG container, see Section 4.2. data item (major type 5) based on the same rules as a YANG container
as defined in Section 4.2.
Definition example [RFC7317]: Definition example [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 9 skipping to change at page 12, line 9
of this parent SID based on its context. In these cases, delta of this parent SID based on its context. In these cases, delta
encoding can be performed based on this parent SID which minimizes encoding can be performed based on this parent SID which minimizes
the size of the encoded data. the size of the encoded data.
CBOR diagnostic notation: CBOR diagnostic notation:
[ [
{ {
1746 : "NRC TIC server", # name 1746 : "NRC TIC server", # name
1748 : { # udp 1748 : { # udp
1 : "tic.nrc.ca", # address, SID 1749 +1 : "tic.nrc.ca", # address, SID 1749
2 : 123 # port, SID 1750 +2 : 123 # port, SID 1750
}, },
1744 : 0, # association-type 1744 : 0, # association-type
1745 : false, # iburst 1745 : false, # iburst
1747 : true # prefer 1747 : true # prefer
}, },
{ {
1746 : "NRC TAC server", # name 1746 : "NRC TAC server", # name
1748 : { # udp 1748 : { # udp
1 : "tac.nrc.ca" # address, SID 1749 +1 : "tac.nrc.ca" # address, SID 1749
} }
} }
] ]
CBOR encoding: CBOR encoding:
82 # array(2) 82 # array(2)
a5 # map(5) a5 # map(5)
19 06d2 # unsigned(1746) 19 06d2 # unsigned(1746)
6e # text(14) 6e # text(14)
skipping to change at page 16, line 43 skipping to change at page 16, line 43
6e # text(14) 6e # text(14)
4e52432054414320736572766572 # "NRC TAC server" 4e52432054414320736572766572 # "NRC TAC server"
44 # bytes(4) 44 # bytes(4)
11889c84 11889c84
a1 # map(1) a1 # map(1)
44 # bytes(4) 44 # bytes(4)
3158c529 3158c529
6a # text(10) 6a # text(10)
7461632e6e72632e6361 # "tac.nrc.ca" 7461632e6e72632e6361 # "tac.nrc.ca"
4.5. The "anydata" Schema Node 4.5. The 'anydata' Schema Node
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 MUST be set to valid SIDs, member names or YANG hashes. This o Keys MUST be set to valid SIDs, member names or YANG hashes. This
rule applies to the key of the anydata node and the key of any rule applies to the key of the anydata node and the key of any
inner schema node. inner schema node.
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 Values MUST follow the encoding rules of one of the datatypes
listed in Section 5. listed in Section 5.
4.6. The "anyxml" Schema Node 4.6. The 'anyxml' Schema Node
An anyxml instance is encoded as a CBOR key/value pair. The key of An anyxml instance is encoded as a CBOR key/value pair. The key of
the anyxml schema node MUST be a valid SID, member name or YANG hash the anyxml schema node MUST be a valid SID, member name or YANG hash
but the value is unrestricted, i.e., the value can be any CBOR but the value is unrestricted, i.e., the value can be any CBOR
encoded content. encoded content.
5. Representing YANG Data Types in CBOR 5. Representing YANG Data Types in CBOR
5.1. The unsigned integer Types 5.1. The unsigned integer Types
skipping to change at page 18, line 15 skipping to change at page 18, line 15
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
5.3. The "decimal64" Type 5.3. The 'decimal64' Type
Leafs of type decimal64 MUST be encoded using either CBOR unsigned f type decimal64 MUST be encoded using either CBOR unsigned integer
integer (major type 0) or CBOR signed integer (major type 1), (major type 0) or CBOR signed integer (major type 1), depending on
depending on the actual value. The position of the decimal point is the actual value. Leafs oThe position of the decimal point is
defined by the fraction-digits YANG statement and is not available in defined by the fraction-digits YANG statement and is not available in
the CBOR encoding. the CBOR encoding.
Definition example [RFC7317]: Definition example [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: 257 (Represents decimal value 2.57) CBOR diagnostic notation: 257 (Represents decimal value 2.57)
CBOR encoding: 19 0101 CBOR encoding: 19 0101
5.4. The "string" Type 5.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).
Definition example [RFC7223]: Definition example [RFC7223]:
leaf name { leaf name {
type string; type string;
} }
CBOR diagnostic notation: "eth0" CBOR diagnostic notation: "eth0"
CBOR encoding: 64 65746830 CBOR encoding: 64 65746830
5.5. The "boolean" Type 5.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 true (major type
7, additional information 21) or false data item (major type 7, 7, additional information 21) or false data item (major type 7,
additional information 20). additional information 20).
Definition example [RFC7317]: Definition example [RFC7317]:
leaf enabled { leaf enabled {
type boolean; type boolean;
} }
CBOR diagnostic notation: true CBOR diagnostic notation: true
CBOR encoding: f5 CBOR encoding: f5
5.6. The "enumeration" Type 5.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 data item (major type 0). integer (major type 0) or CBOR signed integer (major type 1),
depending on the actual value. Enumeration values are either
explicitly assigned using the YANG statement 'value' or automatically
assigned based on the algorithm defined in
[I-D.ietf-netmod-rfc6020bis] section 9.6.4.2.
Definition example [RFC7317]: Definition example [RFC7317]:
leaf oper-status { leaf oper-status {
type enumeration { type enumeration {
enum up { value 1; } enum up { value 1; }
enum down { value 2; } enum down { value 2; }
enum testing { value 3; } enum testing { value 3; }
enum unknown { value 4; } enum unknown { value 4; }
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 (Represents enumeration value "testing") CBOR diagnostic notation: 3 (Represents enumeration value 'testing')
CBOR encoding: 03 CBOR encoding: 03
5.7. The "bits" Type 5.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 0 to 7 are assigned to the first byte (major type 2). Bits position are either explicitly assigned using
within the byte string, bits 8 to 15 to the second byte, and the YANG statement 'position' or automatically assigned based on the
subsequent bytes are assigned similarly. Within each byte, bits are algorithm defined in [I-D.ietf-netmod-rfc6020bis] section 9.7.4.2.
assigned from least to most significant.
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
assigned similarly. Within each byte, bits are assigned from least
to most significant.
Definition example [I-D.ietf-netmod-rfc6020bis]: Definition example [I-D.ietf-netmod-rfc6020bis]:
leaf mybits { leaf mybits {
type bits { type bits {
bit disable-nagle { bit disable-nagle {
position 0; position 0;
} }
bit auto-sense-speed { bit auto-sense-speed {
position 1; position 1;
skipping to change at page 20, line 24 skipping to change at page 20, line 33
position 2; position 2;
} }
} }
} }
CBOR diagnostic notation: h'05' (Represents bits disable-nagle and CBOR diagnostic notation: h'05' (Represents bits disable-nagle and
10-Mb-only set) 10-Mb-only set)
CBOR encoding: 41 05 CBOR encoding: 41 05
5.8. The "binary" Type 5.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).
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
5.9. The "leafref" Type 5.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.
Definition example [RFC7223]: Definition example [RFC7223]:
typedef interface-state-ref { typedef interface-state-ref {
type leafref { type leafref {
path "/interfaces-state/interface/name"; path "/interfaces-state/interface/name";
} }
} }
container interfaces-state { container interfaces-state {
skipping to change at page 21, line 27 skipping to change at page 21, line 34
leaf-list higher-layer-if { leaf-list higher-layer-if {
type interface-state-ref; type interface-state-ref;
} }
} }
} }
CBOR diagnostic notation: "eth1" CBOR diagnostic notation: "eth1"
CBOR encoding: 64 65746831 CBOR encoding: 64 65746831
5.10. The "identityref" Type 5.10. The 'identityref' Type
This specification supports two approaches for encoding identityref, This specification supports two approaches for encoding identityref,
a SID as defined in [I-D.somaraju-core-sid] or a name as defined in a SID as defined in [I-D.somaraju-core-sid] or a name as defined in
[I-D.ietf-netmod-yang-json] section 6.8. [I-D.ietf-netmod-yang-json] section 6.8.
*SIDs as identityref* *SIDs as identityref*
SIDs are globally unique and may be used as identityref. This SIDs are globally unique and can be used as identityref. This
approach is both compact and simple to implement. When SIDs are approach is both compact and simple to implement. When SIDs are
used, identityref MUST be encoded using a CBOR unsigned integer data used, identityref MUST be encoded using a CBOR unsigned integer data
item (major type 0) and set to a SID allocated from a registered SID item (major type 0) or CBOR signed integer (major type 1), depending
range. on the actual value. The value represents the delta between the SID
of the identity assigned to the leaf and the SID of the base identity
defined for this leaf.
*Name as identityref* *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 [I-D.ietf-netmod-yang-json] section 6.8. When names are used, in [I-D.ietf-netmod-yang-json] section 6.8. When names are used,
identityref MUST be encoded using a CBOR text string data item (major identityref MUST be encoded using a CBOR text string data item (major
type 3). If the identity is defined in another module than the leaf type 3). If the identity is defined in another module than the leaf
node containing the identityref value, the namespace-qualified form node containing the identityref value, the namespace-qualified form
MUST be used. Otherwise, both the simple and namespace-qualified MUST be used. Otherwise, both the simple and namespace-qualified
forms are permitted. forms are permitted.
Definition example [RFC7223]: Definition example [RFC7317]:
identity interface-type { identity radius-authentication-type {
description
"Base identity for RADIUS authentication types.";
} }
identity iana-interface-type { identity radius-chap {
base interface-type; base radius-authentication-type;
} }
identity ethernetCsmacd { identity radius-pap {
base iana-interface-type; base radius-authentication-type;
} }
leaf type { leaf authentication-type {
type identityref { type identityref {
base interface-type; base radius-authentication-type;
} }
} }
*SIDs as identityref* *SIDs as identityref*
Assuming that the identity "iana-if-type:ethernetCsmacd" has been This example represents the encoding of identity "radius-pap" (SID
assigned to the SID value 1179. 1705) assuming the base identity "radius-authentication-type" (SID
1703).
CBOR diagnostic notation: 1179 CBOR diagnostic notation: 2
CBOR encoding: 19 049b CBOR encoding: 02
*Name as identityref* *Name as identityref*
CBOR diagnostic notation: "iana-if-type:ethernetCsmacd" CBOR diagnostic notation: "ietf-system:radius-pap"
CBOR encoding: 78 1b CBOR encoding: 76 696574662d73797374656d3a7261646975732d706170
69616e612d69662d747970653a65746865726e657443736d616364
5.11. The "empty" Type 5.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).
Definition example [RFC7277]: Definition example [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
5.12. The "union" Type 5.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. one of the types listed. When used in a union, the following YANG
datatypes are prefixed by CBOR tag to avoid confusion between
different YANG datatypes encoded using the same CBOR major type.
o bits
o decimal64
o enumeration
o identityref
o instance-identifier
o leafref (Only when the datatype of the leaf referenced using the
'path' YANG statement require a CBOR tag)
See Section 7.1 for more information about these CBOR tags.
Definition example [RFC7317]: Definition example [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 23, line 46 skipping to change at page 24, line 39
} }
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
5.13. The "instance-identifier" Type 5.13. The 'instance-identifier' Type
This specification supports three approaches for encoding an This specification supports three approaches for encoding an
instance-identifier, one based on SIDs as defined in [I-D.somaraju- instance-identifier, one based on SIDs as defined in
core-sid], one based on names as defined in [I-D.somaraju-core-sid], one based on names as defined in
[I-D.ietf-netmod-yang-json] section 6.13 and one based on YANG hashes [I-D.ietf-netmod-yang-json] section 6.13 and one based on YANG hashes
as defined in [I-D.vanderstok-core-comi]. as defined in [I-D.vanderstok-core-comi].
*SIDs as instance-identifier* *SIDs as instance-identifier*
SIDs uniquely identify a data node. For a single instance data node, SIDs uniquely identify a data node. For a single instance data node,
the SID is sufficient to identify this instance. For a multi- the SID is sufficient to identify this instance. For a multi-
instance data node, a SID is combined with the list key(s) to instance data node, a SID is combined with the list key(s) to
identify each instance of this data node within the YANG list(s). identify each instance of this data node within the YANG list(s).
skipping to change at page 24, line 24 skipping to change at page 25, line 17
SID. SID.
Multi-instances data nodes MUST be encoded using a CBOR array data Multi-instances data nodes MUST be encoded using a CBOR array data
item (major type 4) containing the following entries: 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 data 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 data 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).
When SIDs identify a YANG list, the presence of the key(s) for this
list is optional. When the key(s) are present, the targeted instance
within this list is selected. When the key(s) are absent, the entire
YANG list is selected.
*Names as instance-identifier* *Names as instance-identifier*
The use of names as instance-identifier is defined in The use of names as instance-identifier is defined in
[I-D.ietf-netmod-yang-json] section 6.11. The resulting xpath MUST [I-D.ietf-netmod-yang-json] section 6.11. The resulting xpath MUST
be encoded using a CBOR text string data item (major type 3). be encoded using a CBOR text string data item (major type 3).
*YANG hashes as instance-identifier* *YANG hashes as instance-identifier*
When YANG hashes are used, xpath can be compressed based on the When YANG hashes are used, xpath can be compressed based on the
method defined by [I-D.vanderstok-core-comi] sections 4.1.4.1 and method defined by [I-D.vanderstok-core-comi] sections 4.1.4.1 and
4.1.4.2. 4.1.4.2. The resulting hash MUST be encoded using a CBOR byte string
data item (major type 2).
Definition example [RFC7317]: Definition example [RFC7317]:
container system { container system {
leaf contact { leaf contact {
type string; type string;
} }
leaf hostname { leaf hostname {
skipping to change at page 28, line 37 skipping to change at page 29, line 37
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.
To minimize security risks, software on the receiving side SHOULD To minimize security risks, software on the receiving side SHOULD
reject all messages that do not comply to the rules of this document reject all messages that do not comply to the rules of this document
and reply with an appropriate error message to the sender. and reply with an appropriate error message to the sender.
7. Acknowledgments 7. IANA Considerations
7.1. Tags Registry
This specification requires the assignment of CBOR tags for the
following YANG datatypes. These tags are added to the Tags Registry
as defined in section 7.2 of [RFC7049].
+-----+---------------------+---------------------------+-----------+
| Tag | Data Item | Semantics | Reference |
+-----+---------------------+---------------------------+-----------+
| 40 | bits | YANG bits datatype | RFC XXXX |
| 41 | decimal64 | YANG decimal64 datatype | RFC XXXX |
| 42 | enumeration | YANG enumeration datatype | RFC XXXX |
| 43 | identityref | YANG identityref datatype | RFC XXXX |
| 44 | instance-identifier | YANG instance-identifier | RFC XXXX |
| | | datatype | |
+-----+---------------------+---------------------------+-----------+
// RFC Ed.: update Tag values using allocated tags if needed and
remove this note // RFC Ed.: replace XXXX with RFC number and remove
this note
8. 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.vanderstok-core-comi]. by Andy Bierman and Peter van der Stok on [I-D.vanderstok-core-comi].
[I-D.ietf-netmod-yang-json] has also been a critical input to this [I-D.ietf-netmod-yang-json] has also been a critical input to this
work. The authors would like to thank the authors and contributors work. The authors would like to thank the authors and contributors
to these two drafts. 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.
8. References 9. References
8.1. Normative References 9.1. Normative References
[I-D.ietf-netmod-rfc6020bis] [I-D.ietf-netmod-rfc6020bis]
Bjorklund, M., "The YANG 1.1 Data Modeling Language", Bjorklund, M., "The YANG 1.1 Data Modeling Language",
draft-ietf-netmod-rfc6020bis-11 (work in progress), draft-ietf-netmod-rfc6020bis-14 (work in progress), June
February 2016. 2016.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, Requirement Levels", BCP 14, RFC 2119,
DOI 10.17487/RFC2119, March 1997, DOI 10.17487/RFC2119, March 1997,
<http://www.rfc-editor.org/info/rfc2119>. <http://www.rfc-editor.org/info/rfc2119>.
[RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object
Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049,
October 2013, <http://www.rfc-editor.org/info/rfc7049>. October 2013, <http://www.rfc-editor.org/info/rfc7049>.
8.2. Informative References 9.2. Informative References
[I-D.ietf-netmod-yang-json] [I-D.ietf-netmod-yang-json]
Lhotka, L., "JSON Encoding of Data Modeled with YANG", Lhotka, L., "JSON Encoding of Data Modeled with YANG",
draft-ietf-netmod-yang-json-09 (work in progress), March draft-ietf-netmod-yang-json-10 (work in progress), March
2016. 2016.
[I-D.somaraju-core-sid]
Somaraju, A., Veillette, M., Pelov, A., Turner, R., and A.
Minaburo, "Structure Identifier (SID)", draft-somaraju-
core-sid-00 (work in progress), March 2016.
[I-D.vanderstok-core-comi] [I-D.vanderstok-core-comi]
Stok, P. and A. Bierman, "CoAP Management Interface", Stok, P. and A. Bierman, "CoAP Management Interface",
draft-vanderstok-core-comi-09 (work in progress), March draft-vanderstok-core-comi-09 (work in progress), March
2016. 2016.
[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, <http://www.rfc-editor.org/info/rfc7159>. 2014, <http://www.rfc-editor.org/info/rfc7159>.
[RFC7223] Bjorklund, M., "A YANG Data Model for Interface [RFC7223] Bjorklund, M., "A YANG Data Model for Interface
 End of changes. 66 change blocks. 
117 lines changed or deleted 185 lines changed or added

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