draft-ietf-core-yang-cbor-05.txt   draft-ietf-core-yang-cbor-06.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: February 9, 2018 Acklio Expires: August 11, 2018 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
August 08, 2017 February 07, 2018
CBOR Encoding of Data Modeled with YANG CBOR Encoding of Data Modeled with YANG
draft-ietf-core-yang-cbor-05 draft-ietf-core-yang-cbor-06
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
This Internet-Draft is submitted in full conformance with the This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79. provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://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 February 9, 2018. This Internet-Draft will expire on August 11, 2018.
Copyright Notice Copyright Notice
Copyright (c) 2017 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
(http://trustee.ietf.org/license-info) in effect on the date of (https://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License. described in the Simplified BSD License.
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3
2. Terminology and Notation . . . . . . . . . . . . . . . . . . 3 2. Terminology and Notation . . . . . . . . . . . . . . . . . . 3
2.1. YANG Schema Item iDentifier (SID) . . . . . . . . . . . . 4 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 Data Node Instances . . . . . . . . . . . . 7
4.1. The 'leaf' Data Node . . . . . . . . . . . . . . . . . . 7 4.1. The 'leaf' Data Node . . . . . . . . . . . . . . . . . . 7
4.2. The 'container' Data Node . . . . . . . . . . . . . . . . 7 4.2. The 'container' Data Node . . . . . . . . . . . . . . . . 7
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 . . . . . . . . . . . . . . . . 10
4.3. The 'leaf-list' Data Node . . . . . . . . . . . . . . . . 10 4.3. The 'leaf-list' Data Node . . . . . . . . . . . . . . . . 10
4.4. The 'list' Data Node . . . . . . . . . . . . . . . . . . 11 4.4. The 'list' Data Node . . . . . . . . . . . . . . . . . . 11
4.4.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . 11 4.4.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . 11
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' Data Node . . . . . . . . . . . . . . . . . 15
4.6. The 'anyxml' Data Node . . . . . . . . . . . . . . . . . 17 4.6. The 'anyxml' Data Node . . . . . . . . . . . . . . . . . 17
5. Representing YANG Data Types in CBOR . . . . . . . . . . . . 17 5. Encoding of YANG data templates . . . . . . . . . . . . . . . 17
5.1. The unsigned integer Types . . . . . . . . . . . . . . . 17 5.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . . . 18
5.2. The integer Types . . . . . . . . . . . . . . . . . . . . 18 5.2. Member names as keys . . . . . . . . . . . . . . . . . . 19
5.3. The 'decimal64' Type . . . . . . . . . . . . . . . . . . 18 6. Representing YANG Data Types in CBOR . . . . . . . . . . . . 20
5.4. The 'string' Type . . . . . . . . . . . . . . . . . . . . 18 6.1. The unsigned integer Types . . . . . . . . . . . . . . . 20
5.5. The 'boolean' Type . . . . . . . . . . . . . . . . . . . 19 6.2. The integer Types . . . . . . . . . . . . . . . . . . . . 21
5.6. The 'enumeration' Type . . . . . . . . . . . . . . . . . 19 6.3. The 'decimal64' Type . . . . . . . . . . . . . . . . . . 21
5.7. The 'bits' Type . . . . . . . . . . . . . . . . . . . . . 20 6.4. The 'string' Type . . . . . . . . . . . . . . . . . . . . 22
5.8. The 'binary' Type . . . . . . . . . . . . . . . . . . . . 21 6.5. The 'boolean' Type . . . . . . . . . . . . . . . . . . . 22
5.9. The 'leafref' Type . . . . . . . . . . . . . . . . . . . 21 6.6. The 'enumeration' Type . . . . . . . . . . . . . . . . . 22
5.10. The 'identityref' Type . . . . . . . . . . . . . . . . . 22 6.7. The 'bits' Type . . . . . . . . . . . . . . . . . . . . . 23
5.10.1. SIDs as identityref . . . . . . . . . . . . . . . . 22 6.8. The 'binary' Type . . . . . . . . . . . . . . . . . . . . 24
5.10.2. Name as identityref . . . . . . . . . . . . . . . . 23 6.9. The 'leafref' Type . . . . . . . . . . . . . . . . . . . 24
5.11. The 'empty' Type . . . . . . . . . . . . . . . . . . . . 23 6.10. The 'identityref' Type . . . . . . . . . . . . . . . . . 25
5.12. The 'union' Type . . . . . . . . . . . . . . . . . . . . 24 6.10.1. SIDs as identityref . . . . . . . . . . . . . . . . 25
5.13. The 'instance-identifier' Type . . . . . . . . . . . . . 25 6.10.2. Name as identityref . . . . . . . . . . . . . . . . 26
5.13.1. SIDs as instance-identifier . . . . . . . . . . . . 25 6.11. The 'empty' Type . . . . . . . . . . . . . . . . . . . . 26
5.13.2. Names as instance-identifier . . . . . . . . . . . . 28 6.12. The 'union' Type . . . . . . . . . . . . . . . . . . . . 27
6. Security Considerations . . . . . . . . . . . . . . . . . . . 29 6.13. The 'instance-identifier' Type . . . . . . . . . . . . . 28
7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 29 6.13.1. SIDs as instance-identifier . . . . . . . . . . . . 28
7.1. Tags Registry . . . . . . . . . . . . . . . . . . . . . . 29 6.13.2. Names as instance-identifier . . . . . . . . . . . . 31
8. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 29 7. Security Considerations . . . . . . . . . . . . . . . . . . . 32
9. References . . . . . . . . . . . . . . . . . . . . . . . . . 30 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 32
9.1. Normative References . . . . . . . . . . . . . . . . . . 30 8.1. Tags Registry . . . . . . . . . . . . . . . . . . . . . . 32
9.2. Informative References . . . . . . . . . . . . . . . . . 30 9. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 32
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 31 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 33
10.1. Normative References . . . . . . . . . . . . . . . . . . 33
10.2. Informative References . . . . . . . . . . . . . . . . . 33
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
same data models in environments based on the JavaScript Object same data models in environments based on the JavaScript Object
skipping to change at page 3, line 45 skipping to change at page 3, line 48
o action o action
o anydata o anydata
o anyxml o anyxml
o data node o data node
o data tree o data tree
o feature o datastore
o feature
o identity o identity
o module o module
o notification o notification
o RPC o RPC
o schema node o schema node
o schema tree o schema tree
o submodule o submodule
The following terms are defined in [RFC7951]: The following terms are defined in [RFC7951]:
skipping to change at page 4, line 20 skipping to change at page 4, line 26
o submodule o submodule
The following terms are defined in [RFC7951]: The following terms are defined in [RFC7951]:
o member name o member name
o name of an identity o name of an identity
o namespace-qualified o namespace-qualified
The following terms are defined in [RFC8040]:
o yang-data (YANG extension)
o YANG data template
This specification also makes use of the following terminology: This specification also makes use of the following terminology:
o child: A schema node defined within a collection such as a o child: A schema node defined within a collection such as a
container, a list, a case, a notification, an RPC input, an RPC container, a list, a case, a notification, an RPC input, an RPC
output, an action input, an action output. output, an action input, an action output.
o delta: Difference between the current SID and a reference SID. A o delta: Difference between the current SID and a reference SID. A
reference SID is defined for each context for which deltas are reference SID is defined for each context for which deltas are
used. used.
skipping to change at page 7, line 35 skipping to change at page 7, line 35
4. Encoding of YANG Data Node Instances 4. Encoding of YANG Data 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' Data 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 6.
4.2. The 'container' Data Node 4.2. The 'container' Data 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. Each key within the CBOR map is set to a data node value. Each key within the CBOR map is set to a data node
identifier, each value is set to the value of this data node instance identifier, each value is set to the value of this data node instance
according to the instance datatype. according to the instance datatype.
skipping to change at page 8, line 48 skipping to change at page 8, line 48
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 parent SID of the root For this first representation, we assume that the SID of the parent
container (i.e. 'system-state') is not available to the serializer. container (i.e. 'system-state') is not available to the serializer.
In this case, root data nodes are encoded using absolute SIDs. In this case, root data nodes are encoded using absolute SIDs.
CBOR diagnostic notation: CBOR diagnostic notation:
{ {
1717 : { / clock (SID 1717) / 1717 : { / clock (SID 1717) /
+2 : "2015-10-02T14:47:24Z-05:00", / current-datetime (SID 1719)/ +2 : "2015-10-02T14:47:24Z-05:00", / current-datetime (SID 1719)/
+1 : "2015-09-15T09:12:58Z-05:00" / boot-datetime (SID 1718) / +1 : "2015-09-15T09:12:58Z-05:00" / boot-datetime (SID 1718) /
} }
skipping to change at page 16, line 9 skipping to change at page 16, line 9
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 Keys of any inner data nodes MUST be set to valid deltas or member
names. 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 Values MUST follow the encoding rules of one of the datatypes
listed in Section 5. listed in Section 6.
The following example shows a possible use of anydata. In this The following example shows a possible use of anydata. In this
example, an anydata is used to define a data node containing a example, an anydata is used to define a data node containing a
notification event, this data node can be part of a YANG list to notification event, this data node can be part of a YANG list to
create an event logger. create an event logger.
Definition example: Definition example:
anydata event; anydata event;
skipping to change at page 17, line 10 skipping to change at page 17, line 10
302f342f3231 # "0/4/21" 302f342f3231 # "0/4/21"
19 0a2a # unsigned(2602) 19 0a2a # unsigned(2602)
6a # text(10) 6a # text(10)
4f70656e2070696e2032 # "Open pin 2" 4f70656e2070696e2032 # "Open pin 2"
4.6. The 'anyxml' Data Node 4.6. The 'anyxml' Data Node
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 7.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.
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. Representing YANG Data Types in CBOR 5. Encoding of YANG data templates
YANG data templates are data structures defined in YANG but not
intended to be implemented as part of a datastore. YANG data
templates are defined using the 'yang-data' extension as described by
RFC 8040.
The encoding rules defined for YANG containers in section 4.2 may be
used to serialize YANG data templates.
Definition example from [I-D.ietf-core-comi]:
import ietf-restconf {
prefix rc;
}
rc:yang-data yang-errors {
container error {
leaf error-tag {
type identityref {
base error-tag;
}
}
leaf error-app-tag {
type identityref {
base error-app-tag;
}
}
leaf error-data-node {
type instance-identifier;
}
leaf error-message {
type string;
}
}
}
Just like YANG containers, YANG data templates can be encoded using
either SIDs or names.
5.1. SIDs as keys
This example shows a serialization example of the yang-errors
template using SIDs as CBOR map key.
CBOR diagnostic notation:
{
1024 : { / error (SID 1024) /
+4 : 1011, / error-tag (SID 1028) /
/ = invalid-value (SID 1011) /
+1 : 1018, / error-app-tag (SID 1025) /
/ = not-in-range (SID 1018) /
+2 : 1740, / error-data-node (SID 1026) /
/ = timezone-utc-offset (SID 1740) /
+3 : "max value exceeded" / error-message (SID 1027) /
}
}
CBOR encoding:
A1 # map(1)
19 0400 # unsigned(1024)
A4 # map(4)
04 # unsigned(4)
19 03F3 # unsigned(1011)
01 # unsigned(1)
19 03FA # unsigned(1018)
02 # unsigned(2)
19 06CC # unsigned(1740)
03 # unsigned(3)
76 # text(22)
6D6178696D756D2076616C7565206578636565646564
5.2. Member names as keys
This example shows a serialization example of the yang-errors
template using member names as CBOR map key.
CBOR diagnostic notation:
{
"ietf-comi:error" : {
"error-tag" : "invalid-value",
"error-app-tag" : "not-in-range",
"error-data-node" : "timezone-utc-offset",
"error-message" : "max value exceeded"
}
}
CBOR encoding:
A1 # map(1)
6F # text(15)
696574662D636F6D693A6572726F72
A4 # map(4)
69 # text(9)
6572726F722D746167 # "error-tag"
6D # text(13)
696E76616C69642D76616C7565
6D # text(13)
6572726F722D6170702D746167
6C # text(12)
6E6F742D696E2D72616E6765
6F # text(15)
6572726F722D646174612D6E6F6465
73 # text(19)
74696D657A6F6E652D7574632D6F6666736574
6D # text(13)
6572726F722D6D657373616765
72 # text(18)
6D61782076616C7565206578636565646564
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 data node
depends on the built-in type of that data node. The following sub- depends on the built-in type of that data 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 data node instance of the discussed
built-in type. built-in type.
5.1. The unsigned integer Types 6.1. The unsigned integer Types
Leafs of type uint8, uint16, uint32 and uint64 MUST be encoded using Leafs of type uint8, uint16, uint32 and uint64 MUST be encoded using
a CBOR unsigned integer data item (major type 0). a CBOR unsigned integer data item (major type 0).
The following example shows the encoding of a 'mtu' leaf instance set The following example shows the encoding of a 'mtu' leaf instance set
to 1280 bytes. to 1280 bytes.
Definition example from [RFC7277]: Definition example from [RFC7277]:
leaf mtu { leaf mtu {
skipping to change at page 17, line 48 skipping to change at page 21, line 4
Definition example from [RFC7277]: Definition example from [RFC7277]:
leaf mtu { leaf mtu {
type uint16 { type uint16 {
range "68..max"; range "68..max";
} }
} }
CBOR diagnostic notation: 1280 CBOR diagnostic notation: 1280
CBOR encoding: 19 0500 CBOR encoding: 19 0500
5.2. The integer Types 6.2. The integer Types
Leafs of type int8, int16, int32 and int64 MUST be encoded using Leafs of type int8, int16, int32 and int64 MUST be encoded using
either CBOR unsigned integer (major type 0) or CBOR negative integer either CBOR unsigned integer (major type 0) or CBOR negative integer
(major type 1), depending on the actual value. (major type 1), depending on the actual value.
The following example shows the encoding of a 'timezone-utc-offset' The following example shows the encoding of a 'timezone-utc-offset'
leaf instance set to -300 minutes. leaf instance set to -300 minutes.
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
5.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
5.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]:
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 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 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).
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
5.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
instance set to 'testing'. instance set to 'testing'.
skipping to change at page 20, line 21 skipping to change at page 23, line 23
enum dormant { value 5; } enum dormant { value 5; }
enum not-present { value 6; } enum not-present { value 6; }
enum lower-layer-down { value 7; } enum lower-layer-down { value 7; }
} }
} }
CBOR diagnostic notation: 3 CBOR diagnostic notation: 3
CBOR encoding: 03 CBOR encoding: 03
5.7. The 'bits' Type 6.7. The 'bits' Type
Leafs of type bits MUST be encoded using a CBOR byte string data item Leafs of type bits MUST be encoded using a CBOR byte string data item
(major type 2). Bits position are either explicitly assigned using (major type 2). Bits position are either explicitly assigned using
the YANG statement 'position' or automatically assigned based on the the YANG statement 'position' or automatically assigned based on the
algorithm defined in [RFC7950] section 9.7.4.2. algorithm defined in [RFC7950] section 9.7.4.2.
Bits position 0 to 7 are assigned to the first byte within the byte Bits position 0 to 7 are assigned to the first byte within the byte
string, bits 8 to 15 to the second byte, and subsequent bytes are string, bits 8 to 15 to the second byte, and subsequent bytes are
assigned similarly. Within each byte, bits are assigned from least assigned similarly. Within each byte, bits are assigned from least
to most significant. to most significant.
skipping to change at page 20, line 51 skipping to change at page 24, line 4
position 0; position 0;
} }
bit auto-sense-speed { bit auto-sense-speed {
position 1; position 1;
} }
bit 10-Mb-only { bit 10-Mb-only {
position 2; position 2;
} }
} }
} }
CBOR diagnostic notation: h'05' CBOR diagnostic notation: h'05'
CBOR encoding: 41 05 CBOR encoding: 41 05
5.8. The 'binary' Type 6.8. The 'binary' Type
Leafs of type binary MUST be encoded using a CBOR byte string data Leafs of type binary MUST be encoded using a CBOR byte string data
item (major type 2). item (major type 2).
The following example shows the encoding of an 'aes128-key' leaf The following example shows the encoding of an 'aes128-key' leaf
instance set to 0x1f1ce6a3f42660d888d92a4d8030476e. instance set to 0x1f1ce6a3f42660d888d92a4d8030476e.
Definition example: Definition example:
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 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]:
typedef interface-state-ref { typedef interface-state-ref {
skipping to change at page 22, line 27 skipping to change at page 25, line 27
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 6.10. The 'identityref' Type
This specification supports two approaches for encoding identityref, This specification supports two approaches for encoding identityref,
a YANG Schema Item iDentifier (SID) as defined in Section 2.1 or a a YANG Schema Item iDentifier (SID) as defined in Section 2.1 or a
name as defined in [RFC7951] section 6.8. name as defined in [RFC7951] section 6.8.
5.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 1180).
Definition example from [RFC7317]: Definition example from [RFC7317]:
skipping to change at page 23, line 26 skipping to change at page 26, line 26
leaf type { leaf type {
type identityref { type identityref {
base interface-type; base interface-type;
} }
} }
CBOR diagnostic notation: 1180 CBOR diagnostic notation: 1180
CBOR encoding: 19 049c CBOR encoding: 19 049c
5.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 another 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 5.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
5.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
5.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 7.1 for more information about these CBOR tags. See Section 8.1 for more information about 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 25, line 39 skipping to change at page 28, 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 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.
5.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 data node. In the case of a single instance
data node, a data node defined at the root of a YANG module or data node, a data node defined at the root of a YANG module or
submodule or data nodes defined within a container, the SID is submodule or data nodes defined within a container, the SID is
sufficient to identify this instance. 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 data 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).
skipping to change at page 28, line 11 skipping to change at page 31, line 11
name "jack". name "jack".
CBOR diagnostic notation: [1726, "jack"] CBOR diagnostic notation: [1726, "jack"]
CBOR encoding: CBOR encoding:
82 # array(2) 82 # array(2)
19 06be # unsigned(1726) 19 06be # unsigned(1726)
64 # text(4) 64 # text(4)
6a61636b # "jack" 6a61636b # "jack"
5.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 5.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 2f20696574662d73797374656d3a73797374656d2f636f6e74616374
*Second example:* *Second example:*
This example is described in Section 5.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 65642d6b65795b6e616d653d2761646d696e275d2f6b65792d64617461
*Third example:* *Third example:*
This example is described in Section 5.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
6. 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.
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. IANA Considerations 8. IANA Considerations
7.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 | | 40 | bits | YANG bits datatype | RFC XXXX |
| 41 | enumeration | YANG enumeration datatype | RFC XXXX | | 41 | enumeration | YANG enumeration datatype | RFC XXXX |
| 42 | identityref | YANG identityref datatype | RFC XXXX | | 42 | identityref | YANG identityref datatype | RFC XXXX |
| 43 | instance-identifier | YANG instance-identifier | RFC XXXX | | 43 | 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 if needed and
remove this note // RFC Ed.: replace XXXX with RFC number and remove remove this note // RFC Ed.: replace XXXX with RFC number and remove
this note this note
8. 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.
9. References 10. References
9.1. Normative References 10.1. Normative References
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, Requirement Levels", BCP 14, RFC 2119,
DOI 10.17487/RFC2119, March 1997, DOI 10.17487/RFC2119, March 1997,
<http://www.rfc-editor.org/info/rfc2119>. <https://www.rfc-editor.org/info/rfc2119>.
[RFC6241] Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed., [RFC6241] Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed.,
and A. Bierman, Ed., "Network Configuration Protocol and A. Bierman, Ed., "Network Configuration Protocol
(NETCONF)", RFC 6241, DOI 10.17487/RFC6241, June 2011, (NETCONF)", RFC 6241, DOI 10.17487/RFC6241, June 2011,
<http://www.rfc-editor.org/info/rfc6241>. <https://www.rfc-editor.org/info/rfc6241>.
[RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object
Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049,
October 2013, <http://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,
<http://www.rfc-editor.org/info/rfc7950>. <https://www.rfc-editor.org/info/rfc7950>.
9.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-01 (work in Management Interface", draft-ietf-core-comi-02 (work in
progress), July 2017. progress), December 2017.
[I-D.ietf-core-sid] [I-D.ietf-core-sid]
Veillette, M., Pelov, A., Turner, R., Minaburo, A., and A. Veillette, M. and A. Pelov, "YANG Schema Item iDentifier
Somaraju, "YANG Schema Item iDentifier (SID)", draft-ietf- (SID)", draft-ietf-core-sid-03 (work in progress),
core-sid-01 (work in progress), May 2017. December 2017.
[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, <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,
<http://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
Constrained-Node Networks", RFC 7228, Constrained-Node Networks", RFC 7228,
DOI 10.17487/RFC7228, May 2014, DOI 10.17487/RFC7228, May 2014,
<http://www.rfc-editor.org/info/rfc7228>. <https://www.rfc-editor.org/info/rfc7228>.
[RFC7277] Bjorklund, M., "A YANG Data Model for IP Management", [RFC7277] Bjorklund, M., "A YANG Data Model for IP Management",
RFC 7277, DOI 10.17487/RFC7277, June 2014, RFC 7277, DOI 10.17487/RFC7277, June 2014,
<http://www.rfc-editor.org/info/rfc7277>. <https://www.rfc-editor.org/info/rfc7277>.
[RFC7317] Bierman, A. and M. Bjorklund, "A YANG Data Model for [RFC7317] Bierman, A. and M. Bjorklund, "A YANG Data Model for
System Management", RFC 7317, DOI 10.17487/RFC7317, August System Management", RFC 7317, DOI 10.17487/RFC7317, August
2014, <http://www.rfc-editor.org/info/rfc7317>. 2014, <https://www.rfc-editor.org/info/rfc7317>.
[RFC7951] Lhotka, L., "JSON Encoding of Data Modeled with YANG", [RFC7951] Lhotka, L., "JSON Encoding of Data Modeled with YANG",
RFC 7951, DOI 10.17487/RFC7951, August 2016, RFC 7951, DOI 10.17487/RFC7951, August 2016,
<http://www.rfc-editor.org/info/rfc7951>. <https://www.rfc-editor.org/info/rfc7951>.
[RFC8040] Bierman, A., Bjorklund, M., and K. Watsen, "RESTCONF [RFC8040] Bierman, A., Bjorklund, M., and K. Watsen, "RESTCONF
Protocol", RFC 8040, DOI 10.17487/RFC8040, January 2017, Protocol", RFC 8040, DOI 10.17487/RFC8040, January 2017,
<http://www.rfc-editor.org/info/rfc8040>. <https://www.rfc-editor.org/info/rfc8040>.
Authors' Addresses Authors' Addresses
Michel Veillette (editor) Michel Veillette (editor)
Trilliant Networks Inc. Trilliant Networks Inc.
610 Rue du Luxembourg 610 Rue du Luxembourg
Granby, Quebec J2J 2V2 Granby, Quebec J2J 2V2
Canada Canada
Phone: +14503750556 Phone: +14503750556
 End of changes. 63 change blocks. 
87 lines changed or deleted 210 lines changed or added

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