| < draft-ietf-core-yang-cbor-17.txt | draft-ietf-core-yang-cbor-18.txt > | |||
|---|---|---|---|---|
| Internet Engineering Task Force M. Veillette, Ed. | Internet Engineering Task Force M. Veillette, Ed. | |||
| Internet-Draft Trilliant Networks Inc. | Internet-Draft Trilliant Networks Inc. | |||
| Intended status: Standards Track I. Petrov, Ed. | Intended status: Standards Track I. Petrov, Ed. | |||
| Expires: 28 April 2022 Google Switzerland GmbH | Expires: 23 June 2022 Google Switzerland GmbH | |||
| A. Pelov | A. Pelov | |||
| Acklio | Acklio | |||
| C. Bormann | C. Bormann | |||
| Universität Bremen TZI | Universität Bremen TZI | |||
| M. Richardson | M. Richardson | |||
| Sandelman Software Works | Sandelman Software Works | |||
| 25 October 2021 | 20 December 2021 | |||
| CBOR Encoding of Data Modeled with YANG | CBOR Encoding of Data Modeled with YANG | |||
| draft-ietf-core-yang-cbor-17 | draft-ietf-core-yang-cbor-18 | |||
| Abstract | Abstract | |||
| Based on the Concise Binary Object Representation (CBOR, RFC 8949), | Based on the Concise Binary Object Representation (CBOR, RFC 8949), | |||
| this document defines encoding rules for representing configuration | this document defines encoding rules for representing configuration | |||
| data, state data, parameters and results of Remote Procedure Call | data, state data, parameters and results of Remote Procedure Call | |||
| (RPC) operations or actions, and notifications, defined using YANG | (RPC) operations or actions, and notifications, defined using YANG | |||
| (RFC 7950). | (RFC 7950). | |||
| Status of This Memo | Status of This Memo | |||
| skipping to change at page 1, line 41 ¶ | skipping to change at page 1, line 41 ¶ | |||
| Internet-Drafts are working documents of the Internet Engineering | Internet-Drafts are working documents of the Internet Engineering | |||
| Task Force (IETF). Note that other groups may also distribute | Task Force (IETF). Note that other groups may also distribute | |||
| working documents as Internet-Drafts. The list of current Internet- | working documents as Internet-Drafts. The list of current Internet- | |||
| Drafts is at https://datatracker.ietf.org/drafts/current/. | Drafts is at https://datatracker.ietf.org/drafts/current/. | |||
| Internet-Drafts are draft documents valid for a maximum of six months | Internet-Drafts are draft documents valid for a maximum of six months | |||
| and may be updated, replaced, or obsoleted by other documents at any | and may be updated, replaced, or obsoleted by other documents at any | |||
| time. It is inappropriate to use Internet-Drafts as reference | time. It is inappropriate to use Internet-Drafts as reference | |||
| material or to cite them other than as "work in progress." | material or to cite them other than as "work in progress." | |||
| This Internet-Draft will expire on 28 April 2022. | This Internet-Draft will expire on 23 June 2022. | |||
| Copyright Notice | Copyright Notice | |||
| Copyright (c) 2021 IETF Trust and the persons identified as the | Copyright (c) 2021 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 (https://trustee.ietf.org/ | Provisions Relating to IETF Documents (https://trustee.ietf.org/ | |||
| license-info) in effect on the date of publication of this document. | license-info) in effect on the date of publication of this document. | |||
| Please review these documents carefully, as they describe your rights | Please review these documents carefully, as they describe your rights | |||
| and restrictions with respect to this document. Code Components | and restrictions with respect to this document. Code Components | |||
| extracted from this document must include Simplified BSD License text | extracted from this document must include Revised BSD License text as | |||
| as described in Section 4.e of the Trust Legal Provisions and are | described in Section 4.e of the Trust Legal Provisions and are | |||
| provided without warranty as described in the Simplified BSD License. | provided without warranty as described in the Revised BSD License. | |||
| Table of Contents | Table of Contents | |||
| 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 | 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 | |||
| 2. Terminology and Notation . . . . . . . . . . . . . . . . . . 3 | 2. Terminology and Notation . . . . . . . . . . . . . . . . . . 3 | |||
| 3. Properties of the CBOR Encoding . . . . . . . . . . . . . . . 5 | 3. Properties of the CBOR Encoding . . . . . . . . . . . . . . . 5 | |||
| 3.1. CBOR diagnostic notation . . . . . . . . . . . . . . . . 6 | 3.1. CBOR diagnostic notation . . . . . . . . . . . . . . . . 6 | |||
| 3.2. YANG Schema Item iDentifier . . . . . . . . . . . . . . . 8 | 3.2. YANG Schema Item iDentifier . . . . . . . . . . . . . . . 8 | |||
| 3.3. Name . . . . . . . . . . . . . . . . . . . . . . . . . . 9 | 3.3. Name . . . . . . . . . . . . . . . . . . . . . . . . . . 9 | |||
| 4. Encoding of YANG Schema Node Instances . . . . . . . . . . . 10 | 4. Encoding of Representation Nodes . . . . . . . . . . . . . . 10 | |||
| 4.1. The 'leaf' . . . . . . . . . . . . . . . . . . . . . . . 10 | 4.1. The 'leaf' . . . . . . . . . . . . . . . . . . . . . . . 11 | |||
| 4.1.1. Using SIDs in keys . . . . . . . . . . . . . . . . . 11 | 4.1.1. Using SIDs in keys . . . . . . . . . . . . . . . . . 11 | |||
| 4.1.2. Using names in keys . . . . . . . . . . . . . . . . . 11 | 4.1.2. Using names in keys . . . . . . . . . . . . . . . . . 11 | |||
| 4.2. The 'container' and other nodes from the data tree . . . 12 | 4.2. The 'container' and other nodes from the data tree . . . 12 | |||
| 4.2.1. Using SIDs in keys . . . . . . . . . . . . . . . . . 13 | 4.2.1. Using SIDs in keys . . . . . . . . . . . . . . . . . 13 | |||
| 4.2.2. Using names in keys . . . . . . . . . . . . . . . . . 14 | 4.2.2. Using names in keys . . . . . . . . . . . . . . . . . 14 | |||
| 4.3. The 'leaf-list' . . . . . . . . . . . . . . . . . . . . . 15 | 4.3. The 'leaf-list' . . . . . . . . . . . . . . . . . . . . . 15 | |||
| 4.3.1. Using SIDs in keys . . . . . . . . . . . . . . . . . 15 | 4.3.1. Using SIDs in keys . . . . . . . . . . . . . . . . . 15 | |||
| 4.3.2. Using names in keys . . . . . . . . . . . . . . . . . 16 | 4.3.2. Using names in keys . . . . . . . . . . . . . . . . . 16 | |||
| 4.4. The 'list' and 'list' entries . . . . . . . . . . . . . . 16 | 4.4. The 'list' and 'list' entries . . . . . . . . . . . . . . 16 | |||
| 4.4.1. Using SIDs in keys . . . . . . . . . . . . . . . . . 17 | 4.4.1. Using SIDs in keys . . . . . . . . . . . . . . . . . 17 | |||
| skipping to change at page 3, line 11 ¶ | skipping to change at page 3, line 11 ¶ | |||
| 6.6. The 'enumeration' Type . . . . . . . . . . . . . . . . . 31 | 6.6. The 'enumeration' Type . . . . . . . . . . . . . . . . . 31 | |||
| 6.7. The 'bits' Type . . . . . . . . . . . . . . . . . . . . . 32 | 6.7. The 'bits' Type . . . . . . . . . . . . . . . . . . . . . 32 | |||
| 6.8. The 'binary' Type . . . . . . . . . . . . . . . . . . . . 34 | 6.8. The 'binary' Type . . . . . . . . . . . . . . . . . . . . 34 | |||
| 6.9. The 'leafref' Type . . . . . . . . . . . . . . . . . . . 34 | 6.9. The 'leafref' Type . . . . . . . . . . . . . . . . . . . 34 | |||
| 6.10. The 'identityref' Type . . . . . . . . . . . . . . . . . 35 | 6.10. The 'identityref' Type . . . . . . . . . . . . . . . . . 35 | |||
| 6.10.1. SIDs as identityref . . . . . . . . . . . . . . . . 35 | 6.10.1. SIDs as identityref . . . . . . . . . . . . . . . . 35 | |||
| 6.10.2. Name as identityref . . . . . . . . . . . . . . . . 36 | 6.10.2. Name as identityref . . . . . . . . . . . . . . . . 36 | |||
| 6.11. The 'empty' Type . . . . . . . . . . . . . . . . . . . . 36 | 6.11. The 'empty' Type . . . . . . . . . . . . . . . . . . . . 36 | |||
| 6.12. The 'union' Type . . . . . . . . . . . . . . . . . . . . 37 | 6.12. The 'union' Type . . . . . . . . . . . . . . . . . . . . 37 | |||
| 6.13. The 'instance-identifier' Type . . . . . . . . . . . . . 38 | 6.13. The 'instance-identifier' Type . . . . . . . . . . . . . 38 | |||
| 6.13.1. SIDs as instance-identifier . . . . . . . . . . . . 38 | 6.13.1. SIDs as instance-identifier . . . . . . . . . . . . 39 | |||
| 6.13.2. Names as instance-identifier . . . . . . . . . . . . 41 | 6.13.2. Names as instance-identifier . . . . . . . . . . . . 42 | |||
| 7. Content-Types . . . . . . . . . . . . . . . . . . . . . . . . 43 | 7. Content-Types . . . . . . . . . . . . . . . . . . . . . . . . 43 | |||
| 8. Security Considerations . . . . . . . . . . . . . . . . . . . 44 | 8. Security Considerations . . . . . . . . . . . . . . . . . . . 44 | |||
| 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 44 | 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 45 | |||
| 9.1. Media-Types Registry . . . . . . . . . . . . . . . . . . 44 | 9.1. Media-Types Registry . . . . . . . . . . . . . . . . . . 45 | |||
| 9.2. CoAP Content-Formats Registry . . . . . . . . . . . . . . 45 | 9.2. CoAP Content-Formats Registry . . . . . . . . . . . . . . 45 | |||
| 9.3. CBOR Tags Registry . . . . . . . . . . . . . . . . . . . 45 | 9.3. CBOR Tags Registry . . . . . . . . . . . . . . . . . . . 46 | |||
| 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 46 | 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 47 | |||
| 10.1. Normative References . . . . . . . . . . . . . . . . . . 46 | 10.1. Normative References . . . . . . . . . . . . . . . . . . 47 | |||
| 10.2. Informative References . . . . . . . . . . . . . . . . . 47 | 10.2. Informative References . . . . . . . . . . . . . . . . . 47 | |||
| Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 48 | Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 49 | |||
| Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 48 | Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 49 | |||
| 1. Introduction | 1. Introduction | |||
| The specification of the YANG 1.1 data modeling language [RFC7950] | The specification of the YANG 1.1 data modeling language [RFC7950] | |||
| defines an XML encoding for data instances, i.e., contents of | defines an XML encoding for data instances, i.e., contents of | |||
| configuration datastores, state data, RPC inputs and outputs, action | configuration datastores, state data, RPC inputs and outputs, action | |||
| inputs and outputs, and event notifications. | inputs and outputs, and event notifications. | |||
| An additional set of encoding rules has been defined in [RFC7951] | An additional set of encoding rules has been defined in [RFC7951] | |||
| based on the JavaScript Object Notation (JSON) Data Interchange | based on the JavaScript Object Notation (JSON) Data Interchange | |||
| skipping to change at page 4, line 31 ¶ | skipping to change at page 4, line 31 ¶ | |||
| * module | * module | |||
| * notification | * notification | |||
| * RPC | * RPC | |||
| * schema node | * schema node | |||
| * submodule | * submodule | |||
| The following terms are defined in [RFC8040]: | The following term is defined in [RFC8040]: | |||
| * yang-data extension | * yang-data extension | |||
| This specification also makes use of the following terminology: | The following term is defined in [RFC8791]: | |||
| * child: A schema node defined as a child node of a container, a | * YANG data structure | |||
| list, a case, a notification, an RPC input, an RPC output, an | ||||
| action input, or an action output. | This specification also makes use of the following terminology: | |||
| * YANG Schema Item iDentifier (YANG SID or simply SID): Unsigned | * YANG Schema Item iDentifier (YANG SID or simply SID): Unsigned | |||
| integer used to identify different YANG items. | integer used to identify different YANG items. | |||
| * delta: Difference between the current YANG SID and a reference | * delta: Difference between the current YANG SID and a reference | |||
| YANG SID. A reference YANG SID is defined for each context for | YANG SID. A reference YANG SID is defined for each context for | |||
| which deltas are used. | which deltas are used. | |||
| * absolute SID: YANG SID not encoded as a delta. This is usually | * absolute SID: YANG SID not encoded as a delta. This is usually | |||
| called out explicitly only in positions where normally a delta | called out explicitly only in positions where normally a delta | |||
| would be found. | would be found. | |||
| * representation tree: a YANG data tree, possibly enclosed by a | ||||
| representation of a schema node such as a YANG data structure, a | ||||
| notification, an RPC, or an action. | ||||
| * representation node: a node in a representation tree, i.e., a data | ||||
| tree node, or a representation of a schema node such as a YANG | ||||
| data structure, a notification, an RPC, or an action. | ||||
| * item: A schema node, an identity, a module, or a feature defined | * item: A schema node, an identity, a module, or a feature defined | |||
| using the YANG modeling language. | using the YANG modeling language. | |||
| * list entry: the data associated with a single element of a list. | * list entry: the data associated with a single entry of a list (see | |||
| Section 7.8 of [RFC7950]). | ||||
| * parent: The container, list, case, notification, RPC input, RPC | * parent (of a representation node): the schema node of the closest | |||
| output, action input or action output node in which a schema node | enclosing representation node in which a given representation node | |||
| is defined. | is defined. | |||
| 3. Properties of the CBOR Encoding | 3. Properties of the CBOR Encoding | |||
| This document defines CBOR encoding rules for YANG data trees and | This document defines CBOR encoding rules for YANG data trees and | |||
| their subtrees. | their subtrees. | |||
| An instance of a schema node such as container, list, notification, | A YANG data tree can be enclosed by a representation of a schema node | |||
| RPC input, RPC output, action input, or action output is serialized | such as a YANG data structure, a notification, an RPC, or an action; | |||
| using a CBOR map in which each child schema node is encoded using a | this is called a representation tree. The data tree nodes and the | |||
| key and a value. This specification supports two types of CBOR keys; | enclosing schema node representation, if any, are collectively called | |||
| YANG Schema Item iDentifier (YANG SID) as defined in Section 3.2 and | the representation nodes. | |||
| names as defined in Section 3.3. Each of these key types is encoded | ||||
| using a specific CBOR type which allows their interpretation during | ||||
| the deserialization process. Protocols or mechanisms implementing | ||||
| this specification can mandate the use of a specific key type. | ||||
| In order to minimize the size of the encoded data, the proposed | A representation node such as container, list entry, YANG data | |||
| mapping avoids any unnecessary meta-information beyond that directly | structure, notification, RPC input, RPC output, action input, or | |||
| provided by the CBOR basic generic data model (Section 2 of | action output is serialized using a CBOR map in which each schema | |||
| [RFC8949]). For instance, CBOR tags are used solely in the case of | node defined within is encoded using a key and a value. This | |||
| an absolute SID, anyxml schema nodes, or the union datatype, to | specification supports two types of CBOR keys; YANG Schema Item | |||
| distinguish explicitly the use of different YANG datatypes encoded | iDentifier (YANG SID) as defined in Section 3.2 and names as defined | |||
| using the same CBOR major type. | in Section 3.3. Each of these key types is encoded using a specific | |||
| CBOR type which allows their interpretation during the | ||||
| deserialization process. Protocols or mechanisms implementing this | ||||
| specification can mandate the use of a specific key type. | ||||
| In order to minimize the size of the encoded data, the mapping avoids | ||||
| any unnecessary meta-information beyond that directly provided by the | ||||
| CBOR basic generic data model (Section 2 of [RFC8949]). For | ||||
| instance, CBOR tags are used solely in the case of an absolute SID, | ||||
| anyxml data nodes, or the union datatype, to distinguish explicitly | ||||
| the use of different YANG datatypes encoded using the same CBOR major | ||||
| type. | ||||
| Unless specified otherwise by the protocol or mechanism implementing | Unless specified otherwise by the protocol or mechanism implementing | |||
| this specification, the indefinite length encoding as defined in | this specification, the indefinite length encoding as defined in | |||
| Section 3.2 of [RFC8949] SHALL be supported by the CBOR decoders | Section 3.2 of [RFC8949] SHALL be supported by the CBOR decoders | |||
| employed with YANG-CBOR. (This enables an implementation to begin | employed with YANG-CBOR. (This enables an implementation to begin | |||
| emitting an array or map before the number of entries in that | emitting an array or map before the number of entries in that | |||
| structure is known, possibly also avoiding excessive locking or race | structure is known, possibly also avoiding excessive locking or race | |||
| conditions. On the other hand, it deprives the receiver of the | conditions. On the other hand, it deprives the receiver of the | |||
| encoded data from advance announcement about some size information, | encoded data from advance announcement about some size information, | |||
| so a generator should choose indefinite length encoding only when | so a generator should choose indefinite length encoding only when | |||
| these benefits do accrue.) | these benefits do accrue.) | |||
| Data nodes implemented using a CBOR array, map, byte string, or text | Data nodes implemented using a CBOR array, map, byte string, or text | |||
| string can be instantiated but empty. In this case, they are encoded | string can be instantiated but empty. In this case, they are encoded | |||
| with a length of zero. | with a length of zero. | |||
| When schema nodes are serialized using the rules defined by this | When representation nodes are serialized using the rules defined by | |||
| specification as part of an application payload, the payload SHOULD | this specification as part of an application payload, the payload | |||
| include information that would allow a stateless way to identify each | SHOULD include information that would allow a stateless way to | |||
| node, such as the SID number associated with the node, SID delta from | identify each node, such as the SID number associated with the node, | |||
| another SID in the application payload, the namespace qualified name, | SID delta from another SID in the application payload, the namespace | |||
| or the instance-identifier. | qualified name, or the instance-identifier. | |||
| Examples in Section 4 include a root CBOR map with a single entry | Examples in Section 4 include a root CBOR map with a single entry | |||
| having a key set to either a namespace qualified name or a SID. This | having a key set to either a namespace qualified name or a SID. This | |||
| root CBOR map is provided only as a typical usage example and is not | root CBOR map is provided only as a typical usage example and is not | |||
| part of the present encoding rules. Only the value within this CBOR | part of the present encoding rules. Only the value within this CBOR | |||
| map is compulsory. | map is compulsory. | |||
| 3.1. CBOR diagnostic notation | 3.1. CBOR diagnostic notation | |||
| Within this document, CBOR binary contents are represented using an | Within this document, CBOR binary contents are represented using an | |||
| skipping to change at page 8, line 25 ¶ | skipping to change at page 8, line 25 ¶ | |||
| shortened to SIDs): | shortened to SIDs): | |||
| * identities | * identities | |||
| * data nodes | * data nodes | |||
| * RPCs and associated input(s) and output(s) | * RPCs and associated input(s) and output(s) | |||
| * actions and associated input(s) and output(s) | * actions and associated input(s) and output(s) | |||
| * YANG data structures | ||||
| * notifications and associated information | * notifications and associated information | |||
| * YANG modules and features | * YANG modules and features | |||
| Note that any structuring of modules into submodules is transparent | Note that any structuring of modules into submodules is transparent | |||
| to YANG-CBOR: SIDs are not allocated for the names of submodules, and | to YANG-CBOR: SIDs are not allocated for the names of submodules, and | |||
| any items within a submodule are effectively allocated SIDs as part | any items within a submodule are effectively allocated SIDs as part | |||
| of processing the module that includes them. | of processing the module that includes them. | |||
| To minimize their size, SIDs used as keys in CBOR maps are encoded | To minimize their size, SIDs used as keys in CBOR maps are encoded | |||
| using deltas, i.e., signed (negative or unsigned) integers that are | using deltas, i.e., signed (negative or unsigned) integers that are | |||
| added to the reference SID applying to the map. The reference SID of | added to the reference SID applying to the map. The reference SID of | |||
| an outermost map is zero, unless a different reference SID is | an outermost map is zero, unless a different reference SID is | |||
| unambiguously conferred from the environment in which the outermost | unambiguously conferred from the environment in which the outermost | |||
| map is used. The reference SID of a map that is most directly | map is used. The reference SID of a map that is most directly | |||
| embedded in a map entry with a name-based key is zero. For all other | embedded in a map entry with a name-based key is zero. For all other | |||
| maps, the reference SID is the SID computed for the map entry it is | maps, the reference SID is the SID computed for the map entry it is | |||
| most directly embedded in. (The embedding may be indirect if an | most directly embedded in. (The embedding may be indirect if an | |||
| array intervenes, e.g., in a YANG list) Where absolute SIDs are | array intervenes, e.g., in a YANG list.) Where absolute SIDs are | |||
| desired in map key positions where a bare integer implies a delta, | desired in map key positions where a bare integer implies a delta, | |||
| they may be encoded using CBOR tag 47 (as defined in Section 9.3). | they may be encoded using CBOR tag 47 (as defined in Section 9.3). | |||
| Thus, conversion from SIDs to deltas and back to SIDs is a stateless | Thus, conversion from SIDs to deltas and back to SIDs is a stateless | |||
| process solely based on the data serialized or deserialized combined | process solely based on the data serialized or deserialized combined | |||
| with, potentially, an outermost reference SID unambiguously conferred | with, potentially, an outermost reference SID unambiguously conferred | |||
| by the environment. | by the environment. | |||
| Mechanisms and processes used to assign SIDs to YANG items and to | Mechanisms and processes used to assign SIDs to YANG items and to | |||
| guarantee their uniqueness are outside the scope of the present | guarantee their uniqueness are outside the scope of the present | |||
| specification. If SIDs are to be used, the present specification is | specification. If SIDs are to be used, the present specification is | |||
| used in conjunction with a specification defining this management. | used in conjunction with a specification defining this management. | |||
| [I-D.ietf-core-sid] is the definitive way to assign SID values for | [I-D.ietf-core-sid] is the definitive way to assign SID values for | |||
| YANG modules managed by the IETF. With YANG modules managed by non- | YANG modules managed by the IETF. With YANG modules managed by non- | |||
| IETF entities, use of [I-D.ietf-core-sid] is RECOMMENDED. The | IETF entities, use of [I-D.ietf-core-sid] is RECOMMENDED. The | |||
| present specification has been designed to allow different methods of | present specification has been designed to allow different methods of | |||
| assignment to be used within separate domains. | assignment to be used within separate domains. | |||
| To provide implementations with a way to internally indicate the | ||||
| absence of a SID, the SID value 0 is reserved and will not be | ||||
| allocated; it is not used in interchange. | ||||
| 3.3. Name | 3.3. Name | |||
| This specification also supports the encoding of YANG item | This specification also supports the encoding of YANG item | |||
| identifiers as text strings, similar to those used by the JSON | identifiers as text strings, similar to those used by the JSON | |||
| Encoding of Data Modeled with YANG [RFC7951]. This approach can be | Encoding of Data Modeled with YANG [RFC7951]. This approach can be | |||
| used to avoid the management overhead associated with SID allocation. | used to avoid the management overhead associated with SID allocation. | |||
| The main drawback is the significant increase in size of the encoded | The main drawback is the significant increase in size of the encoded | |||
| data. | data. | |||
| YANG item identifiers implemented using names MUST be in one of the | YANG item identifiers implemented using names MUST be in one of the | |||
| following forms: | following forms: | |||
| * simple - the identifier of the YANG item (i.e., schema node or | * simple -- the identifier of the YANG item (i.e., schema node or | |||
| identity). | identity). | |||
| * namespace qualified - the identifier of the YANG item is prefixed | * namespace qualified -- the identifier of the YANG item is prefixed | |||
| with the name of the module in which this item is defined, | with the name of the module in which this item is defined, | |||
| separated by the colon character (":"). | separated by the colon character (":"). | |||
| The name of a module determines the namespace of all YANG items | The name of a module determines the namespace of all YANG items | |||
| defined in that module. If an item is defined in a submodule, then | defined in that module. If an item is defined in a submodule, then | |||
| the namespace qualified name uses the name of the main module to | the namespace qualified name uses the name of the main module to | |||
| which the submodule belongs. | which the submodule belongs. | |||
| ABNF syntax [RFC5234] of a name is shown in Figure 1, where the | ABNF syntax [RFC5234] of a name is shown in Figure 1, where the | |||
| production for "identifier" is defined in Section 14 of [RFC7950]. | production for "identifier" is defined in Section 14 of [RFC7950]. | |||
| name = [identifier ":"] identifier | name = [identifier ":"] identifier | |||
| Figure 1: ABNF Production for a simple or namespace qualified name | Figure 1: ABNF Production for a simple or namespace qualified name | |||
| A namespace qualified name MUST be used for all members of a top- | A namespace qualified name MUST be used for all members of a top- | |||
| level CBOR map and then also whenever the namespaces of the data node | level CBOR map and then also whenever the namespaces of the | |||
| and its parent node are different. In all other cases, the simple | representation node and its parent node are different. In all other | |||
| form of the name SHOULD be used. | cases, the simple form of the name SHOULD be used. | |||
| Definition example: | Definition example: | |||
| module example-foomod { | module example-foomod { | |||
| container top { | container top { | |||
| leaf foo { | leaf foo { | |||
| type uint8; | type uint8; | |||
| } | } | |||
| } | } | |||
| } | } | |||
| skipping to change at page 10, line 40 ¶ | skipping to change at page 10, line 47 ¶ | |||
| "foo": 54, | "foo": 54, | |||
| "example-barmod:bar": true | "example-barmod:bar": true | |||
| } | } | |||
| } | } | |||
| Both the 'top' container and the 'bar' leaf defined in a different | Both the 'top' container and the 'bar' leaf defined in a different | |||
| YANG module as its parent container are encoded as namespace | YANG module as its parent container are encoded as namespace | |||
| qualified names. The 'foo' leaf defined in the same YANG module as | qualified names. The 'foo' leaf defined in the same YANG module as | |||
| its parent container is encoded as simple name. | its parent container is encoded as simple name. | |||
| 4. Encoding of YANG Schema Node Instances | 4. Encoding of Representation Nodes | |||
| Schema node instances defined using the YANG modeling language are | Representation nodes defined using the YANG modeling language are | |||
| encoded using CBOR [RFC8949] based on the rules defined in this | encoded using CBOR [RFC8949] 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 [RFC8949]. | YANG [RFC7950] and CBOR [RFC8949]. | |||
| 4.1. The 'leaf' | 4.1. The 'leaf' | |||
| A 'leaf' MUST be encoded accordingly to its datatype using one of the | A 'leaf' MUST be encoded accordingly to its datatype using one of the | |||
| encoding rules specified in Section 6. | encoding rules specified in Section 6. | |||
| The following examples show the encoding of a 'hostname' leaf using a | The following examples show the encoding of a 'hostname' leaf using a | |||
| SID or a name. | SID or a name. | |||
| Definition example from [RFC7317]: | Definition example adapted from [RFC6991] and [RFC7317]: | |||
| typedef domain-name { | typedef domain-name { | |||
| type string { | type string { | |||
| pattern | ||||
| '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*' | ||||
| + '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)' | ||||
| + '|\.'; | ||||
| length "1..253"; | length "1..253"; | |||
| pattern '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9].) | ||||
| *([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.? | ||||
| )|\.'; | ||||
| } | } | |||
| } | } | |||
| leaf hostname { | leaf hostname { | |||
| type inet:domain-name; | type inet:domain-name; | |||
| } | } | |||
| 4.1.1. Using SIDs in keys | 4.1.1. Using SIDs in keys | |||
| As with all examples below, the delta in the outermost map assumes a | As with all examples below, the delta in the outermost map assumes a | |||
| skipping to change at page 12, line 13 ¶ | skipping to change at page 12, line 19 ¶ | |||
| CBOR encoding: | CBOR encoding: | |||
| A1 # map(1) | A1 # map(1) | |||
| 74 # text(20) | 74 # text(20) | |||
| 696574662D73797374656D3A686F73746E616D65 | 696574662D73797374656D3A686F73746E616D65 | |||
| 72 # text(18) | 72 # text(18) | |||
| 6D79686F73742E6578616D706C652E636F6D | 6D79686F73742E6578616D706C652E636F6D | |||
| 4.2. The 'container' and other nodes from the data tree | 4.2. The 'container' and other nodes from the data tree | |||
| Instances of containers, notification contents, RPC inputs, RPC | Instances of containers, YANG data structures, notification contents, | |||
| outputs, action inputs, and action outputs schema nodes MUST be | RPC inputs, RPC outputs, action inputs, and action outputs MUST be | |||
| encoded using a CBOR map data item (major type 5). The same encoding | encoded using a CBOR map data item (major type 5). The same encoding | |||
| is also used for the list entries in a list (Section 4.4). A map | is also used for the list entries in a list (Section 4.4). A map | |||
| consists of pairs of data items, with each pair consisting of a key | consists of pairs of data items, with each pair consisting of a key | |||
| and a value. Each key within the CBOR map is set to a schema node | and a value. Each key within the CBOR map is set to a schema node | |||
| identifier, each value is set to the value of this schema node | identifier, each value is set to the value of this representation | |||
| instance according to the instance datatype. | node according to the instance datatype. | |||
| This specification supports two types of CBOR map keys; SID as | This specification supports two types of CBOR map keys; SID as | |||
| defined in Section 3.2 and names as defined in Section 3.3. | defined in Section 3.2 and names as defined in Section 3.3. | |||
| The following examples show the encoding of a 'system-state' | The following examples show the encoding of a 'system-state' | |||
| container schema node instance using SIDs or names. | container representation instance using SIDs or names. | |||
| Definition example from [RFC7317]: | Definition example adapted from [RFC6991] and [RFC7317]: | |||
| typedef date-and-time { | typedef date-and-time { | |||
| type string { | type string { | |||
| pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-] | pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?' | |||
| \d{2}:\d{2})'; | + '(Z|[\+\-]\d{2}:\d{2})'; | |||
| } | } | |||
| } | } | |||
| container system-state { | container system-state { | |||
| container clock { | container clock { | |||
| leaf current-datetime { | leaf current-datetime { | |||
| type date-and-time; | type date-and-time; | |||
| } | } | |||
| skipping to change at page 13, line 14 ¶ | skipping to change at page 13, line 34 ¶ | |||
| 4.2.1. Using SIDs in keys | 4.2.1. Using SIDs in keys | |||
| In the context of containers and other nodes from the data tree, CBOR | In the context of containers and other nodes from the data tree, CBOR | |||
| map keys within inner CBOR maps can be encoded using deltas or | map keys within inner CBOR maps can be encoded using deltas or | |||
| absolute SIDs (tag 47). | absolute SIDs (tag 47). | |||
| Delta values are computed as follows: | Delta values are computed as follows: | |||
| * In the case of a 'container', deltas are equal to the SID of the | * In the case of a 'container', deltas are equal to the SID of the | |||
| current schema node minus the SID of the parent 'container'. | current representation node minus the SID of the parent | |||
| 'container'. | ||||
| * In the case of a 'list', deltas are equal to the SID of the | * In the case of a 'list', deltas are equal to the SID of the | |||
| current schema node minus the SID of the parent 'list'. | current representation node minus the SID of the parent 'list'. | |||
| * In the case of an 'RPC input' or 'RPC output', deltas are equal to | * In the case of an 'RPC input' or 'RPC output', deltas are equal to | |||
| the SID of the current schema node minus the SID of the 'RPC'. | the SID of the current representation node minus the SID of the | |||
| 'RPC'. | ||||
| * In the case of an 'action input' or 'action output', deltas are | * In the case of an 'action input' or 'action output', deltas are | |||
| equal to the SID of the current schema node minus the SID of the | equal to the SID of the current representation node minus the SID | |||
| 'action'. | of the 'action'. | |||
| * In the case of a 'notification content', deltas are equal to the | * In the case of a 'notification content', deltas are equal to the | |||
| SID of the current schema node minus the SID of the | SID of the current representation node minus the SID of the | |||
| 'notification'. | 'notification'. | |||
| CBOR diagnostic notation: | CBOR diagnostic notation: | |||
| { | { | |||
| 1720 : { / system-state (SID 1720) / | 1720 : { / system-state (SID 1720) / | |||
| 1 : { / clock (SID 1721) / | 1 : { / clock (SID 1721) / | |||
| 2 : "2015-10-02T14:47:24Z-05:00", / current-datetime(SID 1723)/ | 2 : "2015-10-02T14:47:24Z-05:00", / current-datetime(SID 1723)/ | |||
| 1 : "2015-09-15T09:12:58Z-05:00" / boot-datetime (SID 1722) / | 1 : "2015-09-15T09:12:58Z-05:00" / boot-datetime (SID 1722) / | |||
| } | } | |||
| skipping to change at page 14, line 23 ¶ | skipping to change at page 14, line 34 ¶ | |||
| 01 # unsigned(1) | 01 # unsigned(1) | |||
| 78 1A # text(26) | 78 1A # text(26) | |||
| 323031352D30392D31355430393A31323A35385A2D30353A3030 | 323031352D30392D31355430393A31323A35385A2D30353A3030 | |||
| Figure 2: System state clock encoding | Figure 2: System state clock encoding | |||
| 4.2.2. Using names in keys | 4.2.2. Using names in keys | |||
| CBOR map keys implemented using names MUST be encoded using a CBOR | CBOR map keys implemented using names MUST be encoded using a CBOR | |||
| text string data item (major type 3). A namespace-qualified name | text string data item (major type 3). A namespace-qualified name | |||
| MUST be used each time the namespace of a schema node and its parent | MUST be used each time the namespace of a representation node and its | |||
| differ. In all other cases, the simple form of the name MUST be | parent differ. In all other cases, the simple form of the name MUST | |||
| used. Names and namespaces are defined in Section 4 of [RFC7951]. | be used. Names and namespaces are defined in Section 4 of [RFC7951]. | |||
| The following example shows the encoding of a 'system' container | The following example shows the encoding of a 'system' container | |||
| schema node instance using names. | representation node instance using names. | |||
| CBOR diagnostic notation: | CBOR diagnostic notation: | |||
| { | { | |||
| "ietf-system:system-state" : { | "ietf-system:system-state" : { | |||
| "clock" : { | "clock" : { | |||
| "current-datetime" : "2015-10-02T14:47:24Z-05:00", | "current-datetime" : "2015-10-02T14:47:24Z-05:00", | |||
| "boot-datetime" : "2015-09-15T09:12:58Z-05:00" | "boot-datetime" : "2015-09-15T09:12:58Z-05:00" | |||
| } | } | |||
| } | } | |||
| skipping to change at page 15, line 28 ¶ | skipping to change at page 15, line 28 ¶ | |||
| 78 1A # text(26) | 78 1A # text(26) | |||
| 323031352D30392D31355430393A31323A35385A2D30353A3030 | 323031352D30392D31355430393A31323A35385A2D30353A3030 | |||
| 4.3. The 'leaf-list' | 4.3. The 'leaf-list' | |||
| A leaf-list MUST be encoded using a CBOR array data item (major type | A leaf-list MUST be encoded using a CBOR array data item (major type | |||
| 4). Each entry of this array MUST be encoded accordingly to its | 4). Each entry of this array MUST be encoded accordingly to its | |||
| datatype using one of the encoding rules specified in Section 6. | datatype using one of the encoding rules specified in Section 6. | |||
| The following example shows the encoding of the 'search' leaf-list | The following example shows the encoding of the 'search' leaf-list | |||
| schema node instance containing two entries, "ietf.org" and | representation node instance containing two entries, "ietf.org" and | |||
| "ieee.org". | "ieee.org". | |||
| Definition example [RFC7317]: | Definition example adapted from [RFC6991] and [RFC7317]: | |||
| typedef domain-name { | typedef domain-name { | |||
| type string { | type string { | |||
| pattern | ||||
| '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*' | ||||
| + '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)' | ||||
| + '|\.'; | ||||
| length "1..253"; | length "1..253"; | |||
| pattern '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9].) | ||||
| *([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.? | ||||
| )|\.'; | ||||
| } | } | |||
| } | } | |||
| leaf-list search { | leaf-list search { | |||
| type domain-name; | type domain-name; | |||
| ordered-by user; | ordered-by user; | |||
| } | } | |||
| 4.3.1. Using SIDs in keys | 4.3.1. Using SIDs in keys | |||
| skipping to change at page 16, line 46 ¶ | skipping to change at page 16, line 46 ¶ | |||
| 696565652E6F7267 # "ieee.org" | 696565652E6F7267 # "ieee.org" | |||
| 4.4. The 'list' and 'list' entries | 4.4. The 'list' and 'list' entries | |||
| A list or a subset of a list MUST be encoded using a CBOR array data | A list or a subset of a list MUST be encoded using a CBOR array data | |||
| item (major type 4). Each list entry within this CBOR array is | item (major type 4). Each list entry within this CBOR array is | |||
| encoded using a CBOR map data item (major type 5) based on the | encoded using a CBOR map data item (major type 5) based on the | |||
| encoding rules of a collection as defined in Section 4.2. | encoding rules of a collection as defined in Section 4.2. | |||
| It is important to note that this encoding rule also applies to a | It is important to note that this encoding rule also applies to a | |||
| 'list' schema node instance that has a single entry. | 'list' representation node instance that has a single entry. | |||
| The following examples show the encoding of a 'server' list using | The following examples show the encoding of a 'server' list using | |||
| SIDs or names. | SIDs or names. | |||
| Definition example from [RFC7317]: | Definition example from [RFC7317]: | |||
| list server { | list server { | |||
| key name; | key name; | |||
| leaf name { | leaf name { | |||
| skipping to change at page 21, line 48 ¶ | skipping to change at page 21, line 48 ¶ | |||
| 63 # text(3) | 63 # text(3) | |||
| 756470 # "udp" | 756470 # "udp" | |||
| A1 # map(1) | A1 # map(1) | |||
| 67 # text(7) | 67 # text(7) | |||
| 61646472657373 # "address" | 61646472657373 # "address" | |||
| 6A # text(10) | 6A # text(10) | |||
| 7461632E6E72632E6361 # "tac.nrc.ca" | 7461632E6E72632E6361 # "tac.nrc.ca" | |||
| 4.5. The 'anydata' | 4.5. The 'anydata' | |||
| An anydata serves as a container for an arbitrary set of schema nodes | An anydata serves as a container for an arbitrary set of | |||
| that otherwise appear as normal YANG-modeled data. An anydata schema | representation nodes that otherwise appear as normal YANG-modeled | |||
| node instance is encoded using the same rules as a container, i.e., | data. An anydata representation node instance is encoded using the | |||
| CBOR map. The requirement that anydata content can be modeled by | same rules as a container, i.e., CBOR map. The requirement that | |||
| YANG implies the following: | anydata content can be modeled by YANG implies the following: | |||
| * CBOR map keys of any inner schema nodes MUST be set to valid | * CBOR map keys of any inner representation nodes MUST be set to | |||
| deltas or names. | valid deltas or names. | |||
| * The CBOR array MUST contain either unique scalar values (as a | * 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). | |||
| * CBOR map values MUST follow the encoding rules of one of the | * CBOR map values MUST follow the encoding rules of one of the | |||
| datatypes listed in Section 4. | datatypes listed in Section 4. | |||
| The following example shows a possible use of an anydata. In this | The following example shows a possible use of an anydata. In this | |||
| example, an anydata is used to define a schema node containing a | example, an anydata is used to define a representation node | |||
| notification event; this schema node can be part of a YANG list to | containing a notification event; this representation node can be part | |||
| create an event logger. | of a YANG list to create an event logger. | |||
| Definition example: | Definition example: | |||
| module event-log { | module event-log { | |||
| ... | ... | |||
| anydata last-event; # SID 60123 | anydata last-event; # SID 60123 | |||
| } | } | |||
| This example also assumes the assistance of the following | This example also assumes the assistance of the following | |||
| notification. | notification. | |||
| skipping to change at page 23, line 21 ¶ | skipping to change at page 23, line 21 ¶ | |||
| } | } | |||
| } | } | |||
| CBOR encoding: | CBOR encoding: | |||
| A1 # map(1) | A1 # map(1) | |||
| 19 EADB # unsigned(60123) | 19 EADB # unsigned(60123) | |||
| A1 # map(1) | A1 # map(1) | |||
| 18 4D # unsigned(77) | 18 4D # unsigned(77) | |||
| A2 # map(2) | A2 # map(2) | |||
| 18 4E # unsigned(78) | 01 # unsigned(1) | |||
| 66 # text(6) | 66 # text(6) | |||
| 302F342F3231 # "0/4/21" | 302F342F3231 # "0/4/21" | |||
| 18 4F # unsigned(79) | 02 # unsigned(2) | |||
| 6A # text(10) | 6A # text(10) | |||
| 4F70656E2070696E2032 # "Open pin 2" | 4F70656E2070696E2032 # "Open pin 2" | |||
| In some implementations, it might be simpler to use the absolute SID | In some implementations, it might be simpler to use the absolute SID | |||
| encoding (tag 47) for the anydata root element. CBOR diagnostic | encoding (tag 47) for the anydata root element. CBOR diagnostic | |||
| notation: | notation: | |||
| { | { | |||
| 60123 : { / last-event (SID 60123) / | 60123 : { / last-event (SID 60123) / | |||
| 47(60200) : { / event-port-fault (SID 60200) / | 47(60200) : { / event-port-fault (SID 60200) / | |||
| skipping to change at page 24, line 10 ¶ | skipping to change at page 24, line 10 ¶ | |||
| "port-fault" : "Open pin 2" | "port-fault" : "Open pin 2" | |||
| } | } | |||
| } | } | |||
| } | } | |||
| CBOR encoding: | CBOR encoding: | |||
| A1 # map(1) | A1 # map(1) | |||
| 74 # text(20) | 74 # text(20) | |||
| 6576656E742D6C6F673A6C6173742D6576656E74 | 6576656E742D6C6F673A6C6173742D6576656E74 | |||
| A1 # map(1) | A1 # map(1) | |||
| 78 20 # text(32) | 78 1F # text(31) | |||
| 6578616D706C652D706F72743A206578616D7 | 6578616D706C652D706F72743A | |||
| 06C652D706F72742D6661756C74 | 6578616D706C652D706F72742D6661756C74 | |||
| A2 # map(2) | A2 # map(2) | |||
| 69 # text(9) | 69 # text(9) | |||
| 706F72742D6E616D65 # "port-name" | 706F72742D6E616D65 # "port-name" | |||
| 66 # text(6) | 66 # text(6) | |||
| 302F342F3231 # "0/4/21" | 302F342F3231 # "0/4/21" | |||
| 6A # text(10) | 6A # text(10) | |||
| 706F72742D6661756C74 # "port-fault" | 706F72742D6661756C74 # "port-fault" | |||
| 6A # text(10) | 6A # text(10) | |||
| 4F70656E2070696E2032 # "Open pin 2" | 4F70656E2070696E2032 # "Open pin 2" | |||
| 4.6. The 'anyxml' | 4.6. The 'anyxml' | |||
| An anyxml schema node is used to serialize an arbitrary CBOR content, | An anyxml representation node is used to serialize an arbitrary CBOR | |||
| i.e., its value can be any CBOR binary object. An anyxml value MAY | content, i.e., its value can be any CBOR binary object. An anyxml | |||
| contain CBOR data items tagged with one of the tags listed in | value MAY contain CBOR data items tagged with one of the tags listed | |||
| Section 9.3. The tags listed in Section 9.3 SHALL be supported. | in Section 9.3. The tags listed in Section 9.3 SHALL be supported. | |||
| The following example shows a valid CBOR encoded anyxml schema node | The following example shows a valid CBOR encoded anyxml | |||
| instance consisting of a CBOR array containing the CBOR simple values | representation node instance consisting of a CBOR array containing | |||
| 'true', 'null' and 'true'. | the CBOR simple values 'true', 'null' and 'true'. | |||
| Definition example from [RFC7951]: | Definition example from [RFC7951]: | |||
| module bar-module { | module bar-module { | |||
| ... | ... | |||
| anyxml bar; # SID 60000 | anyxml bar; # SID 60000 | |||
| } | } | |||
| 4.6.1. Using SIDs in keys | 4.6.1. Using SIDs in keys | |||
| skipping to change at page 25, line 36 ¶ | skipping to change at page 25, line 36 ¶ | |||
| F5 # primitive(21) | F5 # primitive(21) | |||
| F6 # primitive(22) | F6 # primitive(22) | |||
| F5 # primitive(21) | F5 # primitive(21) | |||
| 5. Encoding of 'yang-data' extension | 5. Encoding of 'yang-data' extension | |||
| The yang-data extension [RFC8040] is used to define data structures | The yang-data extension [RFC8040] is used to define data structures | |||
| in YANG that are not intended to be implemented as part of a | in YANG that are not intended to be implemented as part of a | |||
| datastore. | datastore. | |||
| The yang-data extension MUST be encoded using the encoding rules of | The yang-data extension will specify a container that MUST be encoded | |||
| nodes of data trees as defined in Section 4.2. | using the encoding rules of nodes of data trees as defined in | |||
| Section 4.2. | ||||
| Just like YANG containers, the yang-data extension can be encoded | Just like YANG containers, the yang-data extension can be encoded | |||
| using either SIDs or names. | using either SIDs or names. | |||
| Definition example from [I-D.ietf-core-comi] Appendix A: | Definition example from [I-D.ietf-core-comi] Appendix A: | |||
| module ietf-coreconf { | module ietf-coreconf { | |||
| ... | ... | |||
| import ietf-restconf { | import ietf-restconf { | |||
| skipping to change at page 27, line 30 ¶ | skipping to change at page 27, line 30 ¶ | |||
| 19 0400 # unsigned(1024) | 19 0400 # unsigned(1024) | |||
| A4 # map(4) | A4 # map(4) | |||
| 04 # unsigned(4) | 04 # unsigned(4) | |||
| 19 03F3 # unsigned(1011) | 19 03F3 # unsigned(1011) | |||
| 01 # unsigned(1) | 01 # unsigned(1) | |||
| 19 03FA # unsigned(1018) | 19 03FA # unsigned(1018) | |||
| 02 # unsigned(2) | 02 # unsigned(2) | |||
| 19 06CC # unsigned(1740) | 19 06CC # unsigned(1740) | |||
| 03 # unsigned(3) | 03 # unsigned(3) | |||
| 70 # text(16) | 70 # text(16) | |||
| 4D6178696D756D206578636565646564 | 4D6178696D756D206578636565646564 # "Maximum exceeded" | |||
| 5.2. Using names in keys | 5.2. Using names in keys | |||
| The yang-data extensions encoded using names are carried in a CBOR | The yang-data extensions encoded using names are carried in a CBOR | |||
| map containing a single item pair. The key of this item is set to | map containing a single item pair. The key of this item is set to | |||
| the namespace qualified name of the yang-data extension container; | the namespace qualified name of the yang-data extension container; | |||
| the value is set to the CBOR encoding of this container as defined in | the value is set to the CBOR encoding of this container as defined in | |||
| Section 3.3. | Section 3.3. | |||
| This example shows a serialization example of the yang-errors yang- | This example shows a serialization example of the yang-errors yang- | |||
| skipping to change at page 28, line 36 ¶ | skipping to change at page 28, line 36 ¶ | |||
| 6C # text(12) | 6C # text(12) | |||
| 6E6F742D696E2D72616E6765 # "not-in-range" | 6E6F742D696E2D72616E6765 # "not-in-range" | |||
| 6F # text(15) | 6F # text(15) | |||
| 6572726F722D646174612D6E6F6465 # "error-data-node" | 6572726F722D646174612D6E6F6465 # "error-data-node" | |||
| 73 # text(19) | 73 # text(19) | |||
| 74696D657A6F6E652D7574632D6F6666736574 | 74696D657A6F6E652D7574632D6F6666736574 | |||
| # "timezone-utc-offset" | # "timezone-utc-offset" | |||
| 6D # text(13) | 6D # text(13) | |||
| 6572726F722D6D657373616765 # "error-message" | 6572726F722D6D657373616765 # "error-message" | |||
| 70 # text(16) | 70 # text(16) | |||
| 4D6178696D756D206578636565646564 | 4D6178696D756D206578636565646564 # "Maximum exceeded" | |||
| 6. Representing YANG Data Types in CBOR | 6. Representing YANG Data Types in CBOR | |||
| The CBOR encoding of an instance of a leaf or leaf-list schema node | The CBOR encoding of an instance of a leaf or leaf-list | |||
| depends on the built-in type of that schema node. The following sub- | representation node depends on the built-in type of that | |||
| section defines the CBOR encoding of each built-in type supported by | representation node. The following sub-section defines the CBOR | |||
| YANG as listed in Section 4.2.4 of [RFC7950]. Each subsection shows | encoding of each built-in type supported by YANG as listed in | |||
| an example value assigned to a schema node instance of the discussed | Section 4.2.4 of [RFC7950]. Each subsection shows an example value | |||
| built-in type. | assigned to a representation node instance of the discussed built-in | |||
| type. | ||||
| 6.1. The unsigned integer Types | 6.1. The unsigned integer Types | |||
| Leafs of type uint8, uint16, uint32 and uint64 MUST be encoded using | Leafs of type uint8, uint16, uint32 and uint64 MUST be encoded using | |||
| a CBOR unsigned integer data item (major type 0). | a CBOR unsigned integer data item (major type 0). | |||
| The following example shows the encoding of an 'mtu' leaf schema node | The following example shows the encoding of an 'mtu' leaf | |||
| instance set to 1280 bytes. | representation node instance set to 1280 bytes. | |||
| Definition example from [RFC8344]: | Definition example from [RFC8344]: | |||
| leaf mtu { | leaf mtu { | |||
| type uint16 { | type uint16 { | |||
| range "68..max"; | range "68..max"; | |||
| } | } | |||
| } | } | |||
| CBOR diagnostic notation: 1280 | CBOR diagnostic notation: 1280 | |||
| CBOR encoding: 19 0500 | CBOR encoding: 19 0500 | |||
| 6.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 schema node instance set to -300 minutes. | leaf representation node 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 | |||
| 6.3. The 'decimal64' Type | 6.3. The 'decimal64' Type | |||
| Leafs of type decimal64 MUST be encoded using a decimal fraction as | Leafs of type decimal64 MUST be encoded using a decimal fraction as | |||
| defined in Section 3.4.4 of [RFC8949]. | defined in Section 3.4.4 of [RFC8949]. | |||
| The following example shows the encoding of a 'my-decimal' leaf | The following example shows the encoding of a 'my-decimal' leaf | |||
| schema node instance set to 2.57. | representation node instance set to 2.57. | |||
| Definition example from [RFC7317]: | Definition example from [RFC7317]: | |||
| leaf my-decimal { | leaf my-decimal { | |||
| type decimal64 { | type decimal64 { | |||
| fraction-digits 2; | fraction-digits 2; | |||
| range "1 .. 3.14 | 10 | 20..max"; | range "1 .. 3.14 | 10 | 20..max"; | |||
| } | } | |||
| } | } | |||
| CBOR diagnostic notation: 4([-2, 257]) | CBOR diagnostic notation: 4([-2, 257]) | |||
| CBOR encoding: C4 82 21 19 0101 | CBOR encoding: C4 82 21 19 0101 | |||
| 6.4. The 'string' Type | 6.4. The 'string' Type | |||
| Leafs of type string MUST be encoded using a CBOR text string data | Leafs of type string MUST be encoded using a CBOR text string data | |||
| item (major type 3). | item (major type 3). | |||
| The following example shows the encoding of a 'name' leaf schema node | The following example shows the encoding of a 'name' leaf | |||
| instance set to "eth0". | representation node instance set to "eth0". | |||
| Definition example from [RFC8343]: | Definition example from [RFC8343]: | |||
| leaf name { | leaf name { | |||
| type string; | type string; | |||
| } | } | |||
| CBOR diagnostic notation: "eth0" | CBOR diagnostic notation: "eth0" | |||
| CBOR encoding: 64 65746830 | CBOR encoding: 64 65746830 | |||
| 6.5. The 'boolean' Type | 6.5. The 'boolean' Type | |||
| Leafs of type boolean MUST be encoded using a CBOR simple value | Leafs of type boolean MUST be encoded using a CBOR simple value | |||
| 'true' (major type 7, additional information 21) or 'false' (major | 'true' (major type 7, additional information 21) or 'false' (major | |||
| type 7, additional information 20). | type 7, additional information 20). | |||
| The following example shows the encoding of an 'enabled' leaf schema | The following example shows the encoding of an 'enabled' leaf | |||
| node instance set to 'true'. | representation node 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 | |||
| skipping to change at page 31, line 15 ¶ | skipping to change at page 31, line 15 ¶ | |||
| 6.6. The 'enumeration' Type | 6.6. The 'enumeration' Type | |||
| Leafs of type enumeration MUST be encoded using a CBOR unsigned | Leafs of type enumeration MUST be encoded using a CBOR unsigned | |||
| integer (major type 0) or CBOR negative integer (major type 1), | integer (major type 0) or CBOR negative integer (major type 1), | |||
| depending on the actual value. Enumeration values are either | depending on the actual value. Enumeration values are either | |||
| explicitly assigned using the YANG statement 'value' or automatically | explicitly assigned using the YANG statement 'value' or automatically | |||
| assigned based on the algorithm defined in Section 9.6.4.2 of | assigned based on the algorithm defined in Section 9.6.4.2 of | |||
| [RFC7950]. | [RFC7950]. | |||
| The following example shows the encoding of an 'oper-status' leaf | The following example shows the encoding of an 'oper-status' leaf | |||
| schema node instance set to 'testing'. | representation node instance set to 'testing'. | |||
| Definition example from [RFC7317]: | Definition example from [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; } | |||
| skipping to change at page 31, line 37 ¶ | skipping to change at page 31, line 37 ¶ | |||
| 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 | |||
| Values of 'enumeration' types defined in a 'union' type MUST be | Values of 'enumeration' types defined in a 'union' type MUST be | |||
| encoded using a CBOR text string data item (major type 3) and MUST | encoded using a CBOR text string data item (major type 3) and MUST | |||
| contain one of the names assigned by 'enum' statements in YANG. The | contain one of the names assigned by 'enum' statements in YANG (see | |||
| encoding MUST be enclosed by the enumeration CBOR tag as specified in | also Section 6.12). The encoding MUST be enclosed by the enumeration | |||
| Section 9.3. | CBOR tag as specified in Section 9.3. | |||
| Definition example from [RFC7950]: | Definition example from [RFC7950]: | |||
| type union { | type union { | |||
| type int32; | type int32; | |||
| type enumeration { | type enumeration { | |||
| enum unbounded; | enum unbounded; | |||
| } | } | |||
| } | } | |||
| skipping to change at page 32, line 37 ¶ | skipping to change at page 32, line 37 ¶ | |||
| Within each byte, bits are assigned from least to most significant. | Within each byte, bits are assigned from least to most significant. | |||
| After the byte string, the offset is modified by the number of bytes | After the byte string, the offset is modified by the number of bytes | |||
| in the byte string multiplied by 8. Bytes with no bits set (zero | in the byte string multiplied by 8. Bytes with no bits set (zero | |||
| bytes) at the end of the byte string are never generated: If they | bytes) at the end of the byte string are never generated: If they | |||
| would occur at the end of the array, the zero bytes are simply | would occur at the end of the array, the zero bytes are simply | |||
| omitted; if they occur at the end of a byte string preceding an | omitted; if they occur at the end of a byte string preceding an | |||
| integer, the zero bytes are removed and the integer adjusted upwards | integer, the zero bytes are removed and the integer adjusted upwards | |||
| by the number of zero bytes removed. An example follows. | by the number of zero bytes removed. An example follows. | |||
| The following example shows the encoding of an 'alarm-state' leaf | The following example shows the encoding of an 'alarm-state' leaf | |||
| schema node instance with the 'critical' (position 3), 'warning' | representation node instance with the 'critical' (position 3), | |||
| (position 8) and 'indeterminate' (position 128) flags set. | 'warning' (position 8) and 'indeterminate' (position 128) flags set. | |||
| typedef alarm-state { | typedef alarm-state { | |||
| type bits { | type bits { | |||
| bit unknown; | bit unknown; | |||
| bit under-repair; | bit under-repair; | |||
| bit critical; | bit critical; | |||
| bit major; | bit major; | |||
| bit minor; | bit minor; | |||
| bit warning { | bit warning { | |||
| position 8; | position 8; | |||
| skipping to change at page 33, line 29 ¶ | skipping to change at page 33, line 29 ¶ | |||
| } | } | |||
| leaf alarm-state { | leaf alarm-state { | |||
| type alarm-state; | type alarm-state; | |||
| } | } | |||
| CBOR diagnostic notation: [h'0401', 14, h'01'] | CBOR diagnostic notation: [h'0401', 14, h'01'] | |||
| CBOR encoding: 83 42 0401 0E 41 01 | CBOR encoding: 83 42 0401 0E 41 01 | |||
| In a number of cases the array would only need to have one element - | In a number of cases the array would only need to have one element -- | |||
| a byte string with a few bytes inside. For this case, it is expected | a byte string with a few bytes inside. For this case, it is expected | |||
| to omit the array element and have only the byte array that would | to omit the array element and have only the byte array that would | |||
| have been inside. To illustrate this, let us consider the same | have been inside. To illustrate this, let us consider the same | |||
| example YANG definition, but this time encoding only 'under-repair' | example YANG definition, but this time encoding only 'under-repair' | |||
| and 'critical' flags. The result would be | and 'critical' flags. The result would be | |||
| CBOR diagnostic notation: h'06' | CBOR diagnostic notation: h'06' | |||
| CBOR encoding: 41 06 | CBOR encoding: 41 06 | |||
| Elements in the array MUST be either byte strings that do not end in | Elements in the array MUST be either byte strings that do not end in | |||
| a zero byte, or positive unsigned integers, where byte strings and | a zero byte, or positive unsigned integers, where byte strings and | |||
| integers MUST alternate, i.e., adjacent byte strings or adjacent | integers MUST alternate, i.e., adjacent byte strings or adjacent | |||
| integers are an error. An array with a single byte string MUST | integers are an error. An array with a single byte string MUST | |||
| instead be encoded as just that byte string. An array with a single | instead be encoded as just that byte string. An array with a single | |||
| positive integer is an error. | positive integer is an error. | |||
| To maintain compatibility with the encoding of overlapping unions in | Values of 'bits' types defined in a 'union' type MUST be encoded | |||
| XML, values of 'bits' types defined in a 'union' type MUST be encoded | ||||
| using a CBOR text string data item (major type 3) and MUST contain a | using a CBOR text string data item (major type 3) and MUST contain a | |||
| space-separated sequence of names of 'bits' that are set. The | space-separated sequence of names of 'bits' that are set (see also | |||
| encoding MUST be enclosed by the bits CBOR tag as specified in | Section 6.12). The encoding MUST be enclosed by the bits CBOR tag as | |||
| Section 9.3. | specified in Section 9.3. | |||
| The following example shows the encoding of an 'alarm-state' leaf | The following example shows the encoding of an 'alarm-state' leaf | |||
| schema node instance defined using a union type with the 'under- | representation node instance defined using a union type with the | |||
| repair' and 'critical' flags set. | 'under-repair' and 'critical' flags set. | |||
| Definition example: | Definition example: | |||
| leaf alarm-state-2 { | leaf alarm-state-2 { | |||
| type union { | type union { | |||
| type alarm-state; | type alarm-state; | |||
| type bits { | type bits { | |||
| bit extra-flag; | bit extra-flag; | |||
| } | } | |||
| } | } | |||
| skipping to change at page 34, line 30 ¶ | skipping to change at page 34, line 30 ¶ | |||
| CBOR diagnostic notation: 43("under-repair critical") | CBOR diagnostic notation: 43("under-repair critical") | |||
| CBOR encoding: D8 2B 75 756E6465722D72657061697220637269746963616C | CBOR encoding: D8 2B 75 756E6465722D72657061697220637269746963616C | |||
| 6.8. The 'binary' Type | 6.8. The 'binary' Type | |||
| Leafs of type binary MUST be encoded using a CBOR byte string data | Leafs of type binary MUST be encoded using a CBOR byte string data | |||
| item (major type 2). | item (major type 2). | |||
| The following example shows the encoding of an 'aes128-key' leaf | The following example shows the encoding of an 'aes128-key' leaf | |||
| schema node instance set to 0x1f1ce6a3f42660d888d92a4d8030476e. | representation node instance set to | |||
| 0x1f1ce6a3f42660d888d92a4d8030476e. | ||||
| Definition example: | Definition example: | |||
| leaf aes128-key { | leaf aes128-key { | |||
| type binary { | type binary { | |||
| length 16; | length 16; | |||
| } | } | |||
| } | } | |||
| CBOR diagnostic notation: h'1F1CE6A3F42660D888D92A4D8030476E' | CBOR diagnostic notation: h'1F1CE6A3F42660D888D92A4D8030476E' | |||
| CBOR encoding: 50 1F1CE6A3F42660D888D92A4D8030476E | CBOR encoding: 50 1F1CE6A3F42660D888D92A4D8030476E | |||
| 6.9. The 'leafref' Type | 6.9. The 'leafref' Type | |||
| Leafs of type leafref MUST be encoded using the rules of the schema | Leafs of type leafref MUST be encoded using the rules of the | |||
| node referenced by the 'path' YANG statement. | representation 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 schema node instance set to "eth1". | leaf representation node instance set to "eth1". | |||
| Definition example from [RFC8343]: | Definition example from [RFC8343]: | |||
| typedef interface-state-ref { | typedef interface-state-ref { | |||
| type leafref { | type leafref { | |||
| path "/interfaces-state/interface/name"; | path "/interfaces-state/interface/name"; | |||
| } | } | |||
| } | } | |||
| container interfaces-state { | container interfaces-state { | |||
| skipping to change at page 35, line 35 ¶ | skipping to change at page 35, line 37 ¶ | |||
| CBOR encoding: 64 65746831 | CBOR encoding: 64 65746831 | |||
| 6.10. The 'identityref' Type | 6.10. The 'identityref' Type | |||
| This specification supports two approaches for encoding identityref: | This specification supports two approaches for encoding identityref: | |||
| as a YANG Schema Item iDentifier as defined in Section 3.2, or as a | as a YANG Schema Item iDentifier as defined in Section 3.2, or as a | |||
| name as defined in Section 6.8 of [RFC7951]. | name as defined in Section 6.8 of [RFC7951]. | |||
| 6.10.1. SIDs as identityref | 6.10.1. SIDs as identityref | |||
| When schema nodes of type identityref are implemented using SIDs, | When representation nodes of type identityref are implemented using | |||
| they MUST be encoded using a CBOR unsigned integer data item (major | SIDs, they MUST be encoded using a CBOR unsigned integer data item | |||
| type 0). (Note that, as they are not used in the position of CBOR | (major type 0). (Note that, as they are not used in the position of | |||
| map keys, no delta mechanism is employed for SIDs used for | CBOR map keys, no delta mechanism is employed for SIDs used for | |||
| identityref.) | identityref.) | |||
| The following example shows the encoding of a 'type' leaf schema node | The following example shows the encoding of a 'type' leaf | |||
| instance set to the value 'iana-if-type:ethernetCsmacd' (SID 1880). | representation node instance set to the value 'iana-if- | |||
| type:ethernetCsmacd' (SID 1880). | ||||
| Definition example from [RFC7317]: | Definition example from [RFC7317]: | |||
| identity interface-type { | identity interface-type { | |||
| } | } | |||
| identity iana-interface-type { | identity iana-interface-type { | |||
| base interface-type; | base interface-type; | |||
| } | } | |||
| skipping to change at page 36, line 51 ¶ | skipping to change at page 36, line 51 ¶ | |||
| CBOR encoding: 78 1b | CBOR encoding: 78 1b | |||
| 69616E612D69662D747970653A65746865726E657443736D616364 | 69616E612D69662D747970653A65746865726E657443736D616364 | |||
| 6.11. The 'empty' Type | 6.11. The 'empty' Type | |||
| Leafs of type empty MUST be encoded using the CBOR null value (major | Leafs of type empty MUST be encoded using the CBOR null value (major | |||
| type 7, additional information 22). | type 7, additional information 22). | |||
| The following example shows the encoding of an 'is-router' leaf | The following example shows the encoding of an 'is-router' leaf | |||
| schema node instance when present. | representation node instance when present. | |||
| Definition example from [RFC8344]: | Definition example from [RFC8344]: | |||
| leaf is-router { | leaf is-router { | |||
| type empty; | type empty; | |||
| } | } | |||
| CBOR diagnostic notation: null | CBOR diagnostic notation: null | |||
| CBOR encoding: F6 | CBOR encoding: F6 | |||
| skipping to change at page 37, line 34 ¶ | skipping to change at page 37, line 34 ¶ | |||
| * enumeration | * enumeration | |||
| * identityref | * identityref | |||
| * instance-identifier | * instance-identifier | |||
| See Section 9.3 for the assigned value of these CBOR tags. | See Section 9.3 for the assigned value of these CBOR tags. | |||
| As mentioned in Section 6.6 and in Section 6.7, 'enumeration' and | As mentioned in Section 6.6 and in Section 6.7, 'enumeration' and | |||
| 'bits' are encoded as a CBOR text string data item (major type 3) | 'bits' are encoded as a CBOR text string data item (major type 3) | |||
| when defined within a 'union' type. | when defined within a 'union' type. (This adds considerable | |||
| complexity, but is necessary because of an idiosyncrasy of the YANG | ||||
| data model for unions; the workaround allows compatibility to be | ||||
| maintained with the encoding of overlapping unions in XML and JSON. | ||||
| See also Section 9.12 of [RFC7950].) | ||||
| The following example shows the encoding of an 'ip-address' leaf | The following example shows the encoding of an 'ip-address' leaf | |||
| schema node instance when set to "2001:db8:a0b:12f0::1". | representation node instance when set to "2001:db8:a0b:12f0::1". | |||
| Definition example from [RFC7317]: | Definition example (adapted from [RFC6991]): | |||
| 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])(%[\p{N} | '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}' | |||
| \p{L}]+)?'; | + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])' | |||
| + '(%[\p{N}\p{L}]+)?'; | ||||
| } | } | |||
| } | } | |||
| typedef ipv6-address { | typedef ipv6-address { | |||
| type string { | type string { | |||
| pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a | pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}' | |||
| -fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0 | + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|' | |||
| -9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0 | + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}' | |||
| -9]?[0-9])))(%[\p{N}\p{L}]+)?'; | + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))' | |||
| pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|((([^:]+:)*[^:]+) | + '(%[\p{N}\p{L}]+)?'; | |||
| ?::(([^:]+:)*[^:]+)?)(%.+)?'; | pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|' | |||
| + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)' | ||||
| + '(%.+)?'; | ||||
| } | } | |||
| } | } | |||
| typedef ip-address { | typedef ip-address { | |||
| type union { | type union { | |||
| type ipv4-address; | type ipv4-address; | |||
| type ipv6-address; | type ipv6-address; | |||
| } | } | |||
| } | } | |||
| skipping to change at page 38, line 50 ¶ | skipping to change at page 39, line 10 ¶ | |||
| 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 as defined in | identifier, one based on YANG Schema Item iDentifier as defined in | |||
| Section 3.2 and one based on names as defined in Section 3.3. | Section 3.2 and one based on names as defined in Section 3.3. | |||
| 6.13.1. SIDs as instance-identifier | 6.13.1. SIDs as instance-identifier | |||
| SIDs uniquely identify a schema node. In the case of a single | SIDs uniquely identify a schema node. In the case of a single | |||
| instance schema node, i.e., a schema node defined at the root of a | instance schema node, i.e., a schema node defined at the root of a | |||
| YANG module or submodule or schema nodes defined within a container, | YANG module or submodule or schema nodes defined within a container, | |||
| the SID is sufficient to identify this instance. (Note that no delta | the SID is sufficient to identify this instance (representation | |||
| mechanism is employed for SIDs used for identityref, see | node). (Note that no delta mechanism is employed for SIDs used for | |||
| Section 6.10.1.) | identityref, see Section 6.10.1.) | |||
| In the case of a schema node member of a YANG list, a SID is combined | ||||
| with the list key(s) to identify each instance within the YANG | ||||
| list(s). | ||||
| Single instance schema nodes MUST be encoded using a CBOR unsigned | In the case of a representation node that is an entry of a YANG list, | |||
| integer data item (major type 0) and set to the targeted schema node | a SID is combined with the list key(s) to identify each instance | |||
| SID. | within the YANG list(s). | |||
| Schema node members of a YANG list MUST be encoded using a CBOR array | Instance identifiers of single instance schema nodes MUST be encoded | |||
| data item (major type 4) containing the following entries: | using a CBOR unsigned integer data item (major type 0) and set to the | |||
| targeted schema node SID. | ||||
| Instance identifiers of representation node entries of a YANG list | ||||
| MUST be encoded using a CBOR array data item (major type 4) | ||||
| containing the following entries: | ||||
| * The first entry MUST be encoded as a CBOR unsigned integer data | * The first entry MUST be encoded as a CBOR unsigned integer data | |||
| item (major type 0) and set to the targeted schema node SID. | item (major type 0) and set to the targeted schema node SID. | |||
| * The following entries MUST contain the value of each key required | * The following entries MUST contain the value of each key required | |||
| to identify the instance of the targeted schema node. These keys | to identify the instance of the targeted schema node. These keys | |||
| MUST be ordered as defined in the 'key' YANG statement, starting | MUST be ordered as defined in the 'key' YANG statement, starting | |||
| from the top level list, and followed by each of the subordinate | from the top level list, and followed by each of the subordinate | |||
| list(s). | list(s). | |||
| skipping to change at page 40, line 4 ¶ | skipping to change at page 40, line 15 ¶ | |||
| container system { | container system { | |||
| leaf contact { | leaf contact { | |||
| type string; | type string; | |||
| } | } | |||
| leaf hostname { | leaf hostname { | |||
| type inet:domain-name; | type inet:domain-name; | |||
| } | } | |||
| } | } | |||
| CBOR diagnostic notation: 1741 | CBOR diagnostic notation: 1741 | |||
| CBOR encoding: 19 06CD | CBOR encoding: 19 06CD | |||
| *Second example:* | *Second example:* | |||
| This example aims to show how a schema node member of a YANG list is | This example aims to show how a representation node entry of a YANG | |||
| identified. It uses a somewhat arbitrarily modified YANG module | list is identified. It uses a somewhat arbitrarily modified YANG | |||
| version from [RFC7317] by adding country to the leafs and keys of | module version from [RFC7317] by adding country to the leafs and keys | |||
| authorized-key. | of authorized-key. | |||
| The following example shows the encoding of the 'reporting-entity' | The following example shows the encoding of the 'reporting-entity' | |||
| value referencing list instance "/system/authentication/user/ | value referencing list instance "/system/authentication/user/ | |||
| authorized-key/key-data" (which is assumed to have SID 1734) for user | authorized-key/key-data" (which is assumed to have SID 1734) for | |||
| name "bob" and authorized-key with name "admin" and country "france". | username "bob" and authorized-key with name "admin" and country | |||
| "france". | ||||
| list user { | list user { | |||
| key name; | key name; | |||
| leaf name { | leaf name { | |||
| type string; | type string; | |||
| } | } | |||
| leaf password { | leaf password { | |||
| type ianach:crypt-hash; | type ianach:crypt-hash; | |||
| skipping to change at page 41, line 18 ¶ | skipping to change at page 42, line 4 ¶ | |||
| 84 # array(4) | 84 # array(4) | |||
| 19 06C6 # unsigned(1734) | 19 06C6 # unsigned(1734) | |||
| 63 # text(3) | 63 # text(3) | |||
| 626F62 # "bob" | 626F62 # "bob" | |||
| 65 # text(5) | 65 # text(5) | |||
| 61646D696E # "admin" | 61646D696E # "admin" | |||
| 66 # text(6) | 66 # text(6) | |||
| 6672616E6365 # "france" | 6672616E6365 # "france" | |||
| *Third example:* | *Third example:* | |||
| The following example shows the encoding of the 'reporting-entity' | The following example shows the encoding of the 'reporting-entity' | |||
| value referencing the list instance "/system/authentication/user" | value referencing the list instance "/system/authentication/user" | |||
| (SID 1730) corresponding to user name "jack". | (SID 1730) corresponding to username "jack". | |||
| CBOR diagnostic notation: [1730, "jack"] | CBOR diagnostic notation: [1730, "jack"] | |||
| CBOR encoding: | CBOR encoding: | |||
| 82 # array(2) | 82 # array(2) | |||
| 19 06C2 # unsigned(1730) | 19 06C2 # unsigned(1730) | |||
| 64 # text(4) | 64 # text(4) | |||
| 6A61636B # "jack" | 6A61636B # "jack" | |||
| skipping to change at page 42, line 49 ¶ | skipping to change at page 43, line 35 ¶ | |||
| *Third example:* | *Third example:* | |||
| This example is described in Section 6.13.1. | This example is described in Section 6.13.1. | |||
| CBOR diagnostic notation: | CBOR diagnostic notation: | |||
| "/ietf-system:system/authentication/user[name='jack']" | "/ietf-system:system/authentication/user[name='jack']" | |||
| CBOR encoding: | CBOR encoding: | |||
| 78 33 | 78 34 # text(52) | |||
| 2F696574662D73797374656D3A73797374656D2F61757468656E74696361 | 2F696574662D73797374656D3A73797374656D2F61757468656E74696361 | |||
| 74696F6E2F757365725B6E616D653D27626F62275D | 74696F6E2F757365725B6E616D653D276A61636B275D | |||
| 7. Content-Types | 7. Content-Types | |||
| This specification defines the media-type application/yang-data+cbor, | This specification defines the media-type application/yang-data+cbor, | |||
| which can be used without parameters or with the parameter id=name or | which can be used without parameters or with the parameter id=name or | |||
| id=sid. | id=sid. | |||
| This media-type represents a CBOR YANG document containing one or | This media-type represents a YANG-CBOR document containing a | |||
| multiple data node values. If the media-type parameter id is | representation tree. If the media-type parameter id is present, | |||
| present, depending its value, each data node is identified by its | depending on its value, each representation node is identified by its | |||
| associated namespace qualified name as defined in Section 3.3 | associated namespace qualified name as defined in Section 3.3 | |||
| (id=name), by its associated YANG SID (represented as a SID delta or | (id=name), or by its associated YANG SID (represented as a SID delta | |||
| via tag 47) as defined in Section 3.2 (id=sid). If no id parameter | or via tag 47) as defined in Section 3.2 (id=sid), respectively. If | |||
| is given, both forms may be present. | no id parameter is given, both forms may be present. | |||
| The format of an application/yang-data+cbor representation is that of | The format of an application/yang-data+cbor representation is that of | |||
| a CBOR map, mapping names and/or SIDs (as defined above) into | a CBOR map, mapping names and/or SIDs (as defined above) into | |||
| instance values (using the rules defined in Section 4). | instance values (using the rules defined in Section 4). | |||
| It is not foreseen at this point that the valid set of values for the | It is not foreseen at this point that the valid set of values for the | |||
| id parameter will extend beyond name, sid, or being unset; if that | id parameter will extend beyond name, sid, or being unset; if that | |||
| does happen, any new value is foreseen to be of the form | does happen, any new value is foreseen to be of the form | |||
| [a-z][a-z0-9]*(-[a-z0-9]+)*. | [a-z][a-z0-9]*(-[a-z0-9]+)*. | |||
| skipping to change at page 46, line 35 ¶ | skipping to change at page 47, line 12 ¶ | |||
| Table 4: CBOR tags defined by this specification | Table 4: CBOR tags defined by this specification | |||
| // RFC Ed.: please replace RFC XXXX with RFC number and remove this | // RFC Ed.: please replace RFC XXXX with RFC number and remove this | |||
| note | note | |||
| 10. References | 10. References | |||
| 10.1. Normative References | 10.1. Normative References | |||
| [I-D.ietf-core-sid] | ||||
| Veillette, M., Pelov, A., Petrov, I., Bormann, C., and M. | ||||
| Richardson, "YANG Schema Item iDentifier (YANG SID)", Work | ||||
| in Progress, Internet-Draft, draft-ietf-core-sid-18, 18 | ||||
| November 2021, <https://www.ietf.org/archive/id/draft- | ||||
| ietf-core-sid-18.txt>. | ||||
| [IANA.cbor-tags] | [IANA.cbor-tags] | |||
| IANA, "Concise Binary Object Representation (CBOR) Tags", | IANA, "Concise Binary Object Representation (CBOR) Tags", | |||
| <https://www.iana.org/assignments/cbor-tags>. | <https://www.iana.org/assignments/cbor-tags>. | |||
| [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate | [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate | |||
| Requirement Levels", BCP 14, RFC 2119, | Requirement Levels", BCP 14, RFC 2119, | |||
| DOI 10.17487/RFC2119, March 1997, | DOI 10.17487/RFC2119, March 1997, | |||
| <https://www.rfc-editor.org/info/rfc2119>. | <https://www.rfc-editor.org/info/rfc2119>. | |||
| [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax | [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax | |||
| Specifications: ABNF", STD 68, RFC 5234, | Specifications: ABNF", STD 68, RFC 5234, | |||
| DOI 10.17487/RFC5234, January 2008, | DOI 10.17487/RFC5234, January 2008, | |||
| <https://www.rfc-editor.org/info/rfc5234>. | <https://www.rfc-editor.org/info/rfc5234>. | |||
| [RFC6241] Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed., | ||||
| and A. Bierman, Ed., "Network Configuration Protocol | ||||
| (NETCONF)", RFC 6241, DOI 10.17487/RFC6241, June 2011, | ||||
| <https://www.rfc-editor.org/info/rfc6241>. | ||||
| [RFC7950] Bjorklund, M., Ed., "The YANG 1.1 Data Modeling Language", | [RFC7950] Bjorklund, M., Ed., "The YANG 1.1 Data Modeling Language", | |||
| RFC 7950, DOI 10.17487/RFC7950, August 2016, | RFC 7950, DOI 10.17487/RFC7950, August 2016, | |||
| <https://www.rfc-editor.org/info/rfc7950>. | <https://www.rfc-editor.org/info/rfc7950>. | |||
| [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC | [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC | |||
| 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, | 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, | |||
| May 2017, <https://www.rfc-editor.org/info/rfc8174>. | May 2017, <https://www.rfc-editor.org/info/rfc8174>. | |||
| [RFC8610] Birkholz, H., Vigano, C., and C. Bormann, "Concise Data | [RFC8610] Birkholz, H., Vigano, C., and C. Bormann, "Concise Data | |||
| Definition Language (CDDL): A Notational Convention to | Definition Language (CDDL): A Notational Convention to | |||
| skipping to change at page 47, line 33 ¶ | skipping to change at page 48, line 12 ¶ | |||
| 10.2. Informative References | 10.2. Informative References | |||
| [I-D.ietf-core-comi] | [I-D.ietf-core-comi] | |||
| Veillette, M., Stok, P. V. D., Pelov, A., Bierman, A., and | Veillette, M., Stok, P. V. D., Pelov, A., Bierman, A., and | |||
| I. Petrov, "CoAP Management Interface (CORECONF)", Work in | I. Petrov, "CoAP Management Interface (CORECONF)", Work in | |||
| Progress, Internet-Draft, draft-ietf-core-comi-11, 17 | Progress, Internet-Draft, draft-ietf-core-comi-11, 17 | |||
| January 2021, <https://www.ietf.org/archive/id/draft-ietf- | January 2021, <https://www.ietf.org/archive/id/draft-ietf- | |||
| core-comi-11.txt>. | core-comi-11.txt>. | |||
| [I-D.ietf-core-sid] | [RFC6241] Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed., | |||
| Veillette, M., Pelov, A., Petrov, I., and C. Bormann, | and A. Bierman, Ed., "Network Configuration Protocol | |||
| "YANG Schema Item iDentifier (YANG SID)", Work in | (NETCONF)", RFC 6241, DOI 10.17487/RFC6241, June 2011, | |||
| Progress, Internet-Draft, draft-ietf-core-sid-16, 24 June | <https://www.rfc-editor.org/info/rfc6241>. | |||
| 2021, <https://www.ietf.org/archive/id/draft-ietf-core- | ||||
| sid-16.txt>. | [RFC6991] Schoenwaelder, J., Ed., "Common YANG Data Types", | |||
| RFC 6991, DOI 10.17487/RFC6991, July 2013, | ||||
| <https://www.rfc-editor.org/info/rfc6991>. | ||||
| [RFC7228] Bormann, C., Ersue, M., and A. Keranen, "Terminology for | [RFC7228] Bormann, C., Ersue, M., and A. Keranen, "Terminology for | |||
| Constrained-Node Networks", RFC 7228, | Constrained-Node Networks", RFC 7228, | |||
| DOI 10.17487/RFC7228, May 2014, | DOI 10.17487/RFC7228, May 2014, | |||
| <https://www.rfc-editor.org/info/rfc7228>. | <https://www.rfc-editor.org/info/rfc7228>. | |||
| [RFC7317] Bierman, A. and M. Bjorklund, "A YANG Data Model for | [RFC7317] Bierman, A. and M. Bjorklund, "A YANG Data Model for | |||
| System Management", RFC 7317, DOI 10.17487/RFC7317, August | System Management", RFC 7317, DOI 10.17487/RFC7317, August | |||
| 2014, <https://www.rfc-editor.org/info/rfc7317>. | 2014, <https://www.rfc-editor.org/info/rfc7317>. | |||
| skipping to change at page 48, line 22 ¶ | skipping to change at page 49, line 5 ¶ | |||
| <https://www.rfc-editor.org/info/rfc8259>. | <https://www.rfc-editor.org/info/rfc8259>. | |||
| [RFC8343] Bjorklund, M., "A YANG Data Model for Interface | [RFC8343] Bjorklund, M., "A YANG Data Model for Interface | |||
| Management", RFC 8343, DOI 10.17487/RFC8343, March 2018, | Management", RFC 8343, DOI 10.17487/RFC8343, March 2018, | |||
| <https://www.rfc-editor.org/info/rfc8343>. | <https://www.rfc-editor.org/info/rfc8343>. | |||
| [RFC8344] Bjorklund, M., "A YANG Data Model for IP Management", | [RFC8344] Bjorklund, M., "A YANG Data Model for IP Management", | |||
| RFC 8344, DOI 10.17487/RFC8344, March 2018, | RFC 8344, DOI 10.17487/RFC8344, March 2018, | |||
| <https://www.rfc-editor.org/info/rfc8344>. | <https://www.rfc-editor.org/info/rfc8344>. | |||
| [RFC8791] Bierman, A., Björklund, M., and K. Watsen, "YANG Data | ||||
| Structure Extensions", RFC 8791, DOI 10.17487/RFC8791, | ||||
| June 2020, <https://www.rfc-editor.org/info/rfc8791>. | ||||
| Acknowledgments | 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 Jürgen Schönwälder. | comments from Ladislav Lhotka and Jürgen Schönwälder. | |||
| skipping to change at page 49, line 4 ¶ | skipping to change at page 49, line 36 ¶ | |||
| Email: michel.veillette@trilliantinc.com | Email: michel.veillette@trilliantinc.com | |||
| Ivaylo Petrov (editor) | Ivaylo Petrov (editor) | |||
| Google Switzerland GmbH | Google Switzerland GmbH | |||
| Brandschenkestrasse 110 | Brandschenkestrasse 110 | |||
| CH-8002 Zurich | CH-8002 Zurich | |||
| Switzerland | Switzerland | |||
| Email: ivaylopetrov@google.com | Email: ivaylopetrov@google.com | |||
| Alexander Pelov | Alexander Pelov | |||
| Acklio | Acklio | |||
| 1137A avenue des Champs Blancs | 1137A avenue des Champs Blancs | |||
| 35510 Cesson-Sevigne | 35510 Cesson-Sevigne | |||
| France | France | |||
| Email: a@ackl.io | Email: a@ackl.io | |||
| Carsten Bormann | Carsten Bormann | |||
| Universität Bremen TZI | Universität Bremen TZI | |||
| Postfach 330440 | Postfach 330440 | |||
| D-28359 Bremen | D-28359 Bremen | |||
| Germany | Germany | |||
| Phone: +49-421-218-63921 | Phone: +49-421-218-63921 | |||
| Email: cabo@tzi.org | Email: cabo@tzi.org | |||
| Michael Richardson | Michael Richardson | |||
| Sandelman Software Works | Sandelman Software Works | |||
| Canada | ||||
| Email: mcr+ietf@sandelman.ca | Email: mcr+ietf@sandelman.ca | |||
| End of changes. 101 change blocks. | ||||
| 200 lines changed or deleted | 248 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/ | ||||