RFC 9254: Encoding of Data Modeled with YANG in the Concise Binary Object Representation (CBOR)
- M. Veillette, Ed.,
- I. Petrov, Ed.,
- A. Pelov,
- C. Bormann,
- M. Richardson
Abstract
YANG (RFC 7950) is a data modeling language used to model configuration data, state data, parameters and results of Remote Procedure Call (RPC) operations or actions, and notifications.¶
This document defines encoding rules for YANG in the Concise Binary Object Representation (CBOR) (RFC 8949).¶
Status of This Memo
This is an Internet Standards Track document.¶
This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 7841.¶
Information about the current status of this document, any
errata, and how to provide feedback on it may be obtained at
https://
Copyright Notice
Copyright (c) 2022 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(https://
1. Introduction
The specification of the YANG 1.1 data modeling language [RFC7950] defines an XML encoding for data instances, i.e., contents of configuration datastores, state data, RPC inputs and outputs, action inputs and outputs, and event notifications.¶
An additional set of encoding rules has been defined in [RFC7951] based on "The JavaScript Object Notation (JSON) Data Interchange Format" [RFC8259].¶
The aim of this document is to define a set of encoding rules for the Concise Binary Object Representation (CBOR) [RFC8949], collectively called "YANG-CBOR". The resulting encoding is more compact compared to XML and JSON and more suitable for constrained nodes and/or constrained networks, as defined by [RFC7228].¶
2. Terminology and Notation
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.¶
SID values (and the SID deltas computed from them) shown in the examples are example values; these examples do not allocate the SIDs shown for specific items in the modules.¶
The following terms are defined in [RFC7950]:¶
The following term is defined in [RFC8040]:¶
The following term is defined in [RFC8791]:¶
This specification also makes use of the following terminology:¶
- YANG Schema Item iDentifier (or "YANG SID" or simply "SID"):
- 63-bit unsigned integer used to identify different YANG items.¶
- delta:
- Difference between the current YANG SID and a reference YANG SID. A reference YANG SID is defined for each context for which deltas are used.¶
- absolute SID:
- A YANG SID that is not encoded as a delta. This is usually called out explicitly only in positions where normally a delta 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 using the YANG modeling language.¶
- list entry:
- The data associated with a single entry of a list (see Section 7.8 of [RFC7950]).¶
- container-like instance:
- An instance of a container, a YANG data structure, notification contents, RPC input, RPC output, action input, or action output (Section 4.2); a list entry in a list (Section 4.4); or an anydata node (Section 4.5).¶
- parent (of a representation node):
- The schema node of the closest enclosing representation node in which a given representation node is defined.¶
3. Properties of the CBOR Encoding
This document defines CBOR encoding rules for YANG data trees and their subtrees.¶
A YANG data tree can be enclosed by a representation of a schema node, such as a YANG data structure, a notification, an RPC, or an action; this is called a representation tree. The data tree nodes and the enclosing schema node representation, if any, are collectively called the representation nodes.¶
A representation node, such as a container, list entry, YANG data structure, notification, RPC input, RPC output, action input, action output, or anydata node, is serialized using a CBOR map in which each schema node defined within is encoded using a key and a value. This specification supports two types of CBOR keys: YANG Schema Item iDentifier (YANG SID), as defined in Section 3.2, and names, as defined in Section 3.3. Each of these key types is encoded using a specific CBOR type that allows their interpretation during the deserialization process. Protocols or mechanisms implementing this specification can mandate the use of a specific key type or allow the generator to choose freely per key.¶
In order to minimize the size of the encoded data, the
mapping avoids any unnecessary meta
Unless specified otherwise by the protocol or mechanism implementing this specification, the indefinite length encoding, as defined in Section 3.2 of [RFC8949], SHALL be supported by the CBOR decoders employed with YANG-CBOR. (This enables an implementation to begin emitting an array or map before the number of entries in that structure is known, possibly also avoiding excessive locking or race conditions. On the other hand, it deprives the receiver of the encoded data from advance announcement about some size information, so a generator should choose indefinite length encoding only when these benefits do accrue.)¶
Data nodes implemented using a CBOR array, map, byte string, or text string can be instantiated but empty. In this case, they are encoded with a length of zero.¶
When representation nodes are serialized using the rules defined by this specification as part of an application payload, the payload SHOULD include information that would allow each node to be identified in a stateless way, for instance, the SID number associated with the node, the SID delta from another SID in the application payload, the namespace
Examples in Section 4 include a root CBOR map with a single entry having a key set to either a namespace
3.1. CBOR Diagnostic Notation
Within this document, CBOR binary contents are represented using an equivalent textual form called CBOR diagnostic notation, as defined in Section 8 of [RFC8949]. This notation is used strictly for documentation purposes and is never used in the data serialization. Table 1 below provides a summary of this notation.¶
Note: CBOR binary contents shown in this specification are annotated with comments. These comments are delimited by slashes ("/"), as defined in Appendix G.6 of [RFC8610].¶
3.2. YANG Schema Item iDentifier
Some of the items defined in YANG [RFC7950] require the use of a unique identifier. In both the Network Configuration Protocol (NETCONF) [RFC6241] and RESTCONF [RFC8040], these identifiers are implemented using text strings. To allow the implementation of data models defined in YANG in constrained devices and constrained networks, a more compact method to identify YANG items is required. This compact identifier, called "YANG Schema Item iDentifier", is an unsigned integer limited to 63 bits of range (i.e., 0
To minimize their size, SIDs used as keys in CBOR maps are encoded using deltas, i.e., signed (negative or unsigned) integers that are added to the reference SID applying to the map. The reference SID of an outermost map is zero, unless a different reference SID is unambiguously conferred from the environment in which the outermost 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 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 array intervenes, e.g., in a YANG list.) Where absolute SIDs are desired in map key positions (where a bare integer implies a delta), they need to be identified as absolute SID values by using CBOR tag number 47 (as defined in Section 4.2.1).¶
Thus, conversion from SIDs to deltas and back to SIDs is a stateless process solely based on the data serialized or deserialized combined with, potentially, an outermost reference SID unambiguously conferred by the environment.¶
Mechanisms and processes used to assign SIDs to YANG items and to guarantee their uniqueness are outside the scope of the present specification. If SIDs are to be used, the present specification is used in conjunction with a specification defining this management. A related document, i.e., [CORE-SID], is intended to serve as the definitive way to assign SID values for YANG modules managed by the IETF and recommends itself for YANG modules managed by non-IETF entities, as well. The present specification has been designed to allow different methods of 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
This specification also supports the encoding of YANG item identifiers as text strings, similar to those used by the JSON encoding of data modeled with YANG [RFC7951]. This approach can be used to avoid the management overhead associated with SID allocation. The main drawback is the significant increase in size of the encoded data.¶
YANG item identifiers implemented using names MUST be in one of the following forms:¶
The name of a module determines the namespace of all YANG items defined in that module. If an item is defined in a submodule, then the namespace
ABNF syntax [RFC5234] of a name is shown in Figure 1, where the production for "identifier" is defined in Section 14 of [RFC7950].¶
A namespace
Definition example:¶
A valid CBOR encoding of the 'top' container is as follows.¶
CBOR diagnostic notation:¶
Both the 'top' container and the 'bar' leaf defined in a different YANG module as its parent container are encoded as namespace
4. Encoding of Representation Nodes
Representation nodes defined using the YANG modeling language are encoded using CBOR [RFC8949], based on the rules defined in this section. We assume that the reader is already familiar with both YANG [RFC7950] and CBOR [RFC8949].¶
4.1. The 'leaf'
A 'leaf' MUST be encoded accordingly to its datatype using one of the encoding rules specified in Section 6.¶
The following examples show the encoding of a 'hostname' leaf using a SID or a name.¶
Definition example adapted from [RFC6991] and [RFC7317]:¶
4.1.1. Using SIDs in Keys
As with all examples below, the delta in the outermost map assumes a reference YANG SID (current schema node) of 0.¶
CBOR diagnostic notation:¶
CBOR encoding:¶
4.2. The 'container' and Other Nodes from the Data Tree
Instances of containers, YANG data structures, notification contents, RPC inputs, RPC outputs, action inputs, and action outputs MUST be 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) and for anydata nodes (Section 4.5). Collectively, we speak of these instances as "container-like instances".¶
A map 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 identifier, and each value is set to the value of this representation node according to the instance datatype.¶
This specification supports two types of CBOR map keys: SID, as defined in Section 3.2, and names, as defined in Section 3.3.¶
The following examples show the encoding of a 'system-state' container representation instance using SIDs or names.¶
Definition example adapted from [RFC6991] and [RFC7317]:¶
4.2.1. Using SIDs in Keys
In the context of containers and other nodes from the data tree, CBOR map keys within inner CBOR maps can be encoded using deltas (bare integers) or absolute SIDs (tagged with tag number 47).¶
Delta values are computed as follows:¶
CBOR diagnostic notation:¶
CBOR encoding:¶
4.2.2. Using Names in Keys
CBOR map keys implemented using names MUST be encoded using a CBOR
text string data item (major type 3). A namespace
The following example shows the encoding of a 'system' container representation node instance using names.¶
CBOR diagnostic notation:¶
CBOR encoding:¶
4.3. The 'leaf-list'
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 datatype using one of the encoding rules specified in Section 6.¶
The following example shows the encoding of the 'search' leaf-list representation node instance containing two entries: "ietf.org" and "ieee.org".¶
4.4. The 'list' and the 'list' Entries
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 encoded using a CBOR map data item (major type 5) based on the encoding rules of a container-like instance, as defined in Section 4.2.¶
It is important to note that this encoding rule also applies to a 'list' representation node instance that has a single entry.¶
The following examples show the encoding of a 'server' list using SIDs or names.¶
Definition example adapted from [RFC7317]:¶
4.4.1. Using SIDs in Keys
The encoding rules of each 'list' entry are defined in Section 4.2.1.¶
CBOR diagnostic notation:¶
CBOR encoding:¶
4.4.2. Using Names in Keys
The encoding rules of each 'list' entry are defined in Section 4.2.2.¶
CBOR diagnostic notation:¶
CBOR encoding:¶
4.5. The 'anydata'
An anydata node serves as a container for an arbitrary set of representation nodes that otherwise appear as normal YANG-modeled data. An anydata representation node instance is encoded using the same rules as a container, i.e., using a CBOR map data item (major type 5) based on the encoding rules of a container-like instance, as defined in Section 4.2.¶
The following example shows a possible use of an anydata node. In this example, an anydata node is used to define a representation node containing a notification event; this representation node can be part of a YANG list to create an event logger.¶
Definition example:¶
This example also assumes the assistance of the following notification.¶
4.5.1. Using SIDs in Keys
CBOR diagnostic notation:¶
CBOR encoding:¶
In some implementations
4.6. The 'anyxml'
An anyxml representation node is used to serialize an arbitrary CBOR content, i.e., its value can be any CBOR binary object. (The "xml" in the name is a misnomer that only applied to YANG-XML [RFC7950].) An anyxml value MAY contain CBOR data items tagged with one of the tags listed in Section 9.3. The tags listed in Section 9.3 SHALL be supported.¶
The following example shows a valid CBOR-encoded anyxml representation node instance consisting of a CBOR array containing the CBOR simple values 'true', 'null', and 'true'.¶
5. Encoding of the 'yang-data' Extension
The yang-data extension [RFC8040] is used to define data structures in YANG that are not intended to be implemented as part of a datastore.¶
The yang-data extension will specify a container that MUST be encoded 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 using either SIDs or names.¶
Definition example adapted from Appendix A of [CORE-COMI]:¶
5.1. Using SIDs in Keys
The yang-data extensions encoded using SIDs are carried in a CBOR map containing a single item pair. The key of this item is set to the SID assigned to the yang-data extension container; the value is set to the CBOR encoding of this container, as defined in Section 4.2.¶
This example shows a serialization example of the yang-errors yang-data extension, as defined in [CORE-COMI], using SIDs, as defined in Section 3.2.¶
CBOR diagnostic notation:¶
CBOR encoding:¶
5.2. Using Names in Keys
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 the namespace
This example shows a serialization example of the yang-errors yang-data extension, as defined in [CORE-COMI], using names, as defined Section 3.3.¶
CBOR diagnostic notation:¶
CBOR encoding:¶
6. Representing YANG Data Types in CBOR
The CBOR encoding of an instance of a leaf or leaf-list representation node depends on the built-in type of that representation node. The following subsection defines the CBOR encoding of each built-in type supported by YANG, as listed in Section 4.2.4 of [RFC7950]. Each subsection shows an example value assigned to a representation node instance of the discussed built-in type.¶
6.1. The Unsigned Integer Types
Leafs of type uint8, uint16, uint32, and uint64 MUST be encoded using a CBOR unsigned integer data item (major type 0).¶
The following example shows the encoding of an 'mtu' leaf representation node instance set to 1280 bytes.¶
Definition example adapted from [RFC8344]:¶
CBOR diagnostic notation: 1280¶
CBOR encoding: 19 0500¶
6.2. The Integer Types
Leafs of type int8, int16, int32, and int64 MUST be encoded using either a CBOR unsigned integer (major type 0) or a CBOR negative integer (major type 1), depending on the actual value.¶
The following example shows the encoding of a 'timezone
Definition example adapted from [RFC7317]:¶
CBOR diagnostic notation: -300¶
CBOR encoding: 39 012B¶
6.3. The 'decimal64' Type
Leafs of type decimal64 MUST be encoded using a decimal fraction, as defined in Section 3.4.4 of [RFC8949].¶
The following example shows the encoding of a 'my-decimal' leaf representation node instance set to 2.57.¶
Definition example adapted from [RFC7317]:¶
CBOR diagnostic notation: 4([-2, 257])¶
CBOR encoding: C4 82 21 19 0101¶
6.4. The 'string' Type
Leafs of type string MUST be encoded using a CBOR text string data item (major type 3).¶
The following example shows the encoding of a 'name' leaf representation node instance set to "eth0".¶
Definition example adapted from [RFC8343]:¶
CBOR diagnostic notation: "eth0"¶
CBOR encoding: 64 65746830¶
6.5. The 'boolean' Type
Leafs of type boolean MUST be encoded using a CBOR simple value 'true' (major type 7, additional information 21) or 'false' (major type 7, additional information 20).¶
The following example shows the encoding of an 'enabled' leaf representation node instance set to 'true'.¶
Definition example adapted from [RFC7317]:¶
CBOR diagnostic notation: true¶
CBOR encoding: F5¶
6.6. The 'enumeration' Type
Leafs of type enumeration MUST be encoded using a CBOR unsigned integer (major type 0) or CBOR negative integer (major type 1), depending on the actual value, or exceptionally as a tagged text string (see below). Enumeration values are either explicitly assigned using the YANG statement 'value' or automatically assigned based on the algorithm defined in Section 9.6.4.2 of [RFC7950].¶
The following example shows the encoding of an 'oper-status' leaf representation node instance set to 'testing'.¶
Definition example adapted from [RFC7317]:¶
CBOR diagnostic notation: 3¶
CBOR encoding: 03¶
Values of 'enumeration' types defined in a 'union' type MUST be encoded using a CBOR text string data item (major type 3) and MUST contain one of the names assigned by 'enum' statements in YANG (see also Section 6.12). The encoding MUST be enclosed by the enumeration CBOR tag, as specified in Section 9.3.¶
Definition example adapted from [RFC7950]:¶
CBOR diagnostic notation: 44("unbounded")¶
CBOR encoding: D8 2C 69 756E626F756E646
6.7. The 'bits' Type
Keeping in mind that bit positions are either explicitly assigned using the YANG statement 'position' or automatically assigned based on the algorithm defined in Section 9.7.4.2 of [RFC7950], each element of type bits could be seen as a set of bit positions (or offsets from position 0) that have a value of either 1, which represents the bit being set, or 0, which represents that the bit is not set.¶
Leafs of type bits MUST be encoded either using a CBOR array (major type 4) or byte string (major type 2) or exceptionally as a tagged text string (see below). In case CBOR array representation is used, each element is either (1) a positive integer (major type 0 with value 0 being disallowed) that can be used to calculate the offset of the next byte string or (2) a byte string (major type 2) that carries the information regarding whether certain bits are set or not. The initial offset value is 0, and each unsigned integer modifies the offset value of the next byte string by the integer value multiplied by 8. For example, if the bit offset is 0 and there is an integer with value 5, the first byte of the byte string that follows will represent bit positions 40 to 47, with both ends included. If the byte string has a second byte, it will carry information about bits 48 to 55, and so on. Within each byte, bits are assigned from least to most significant. 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 bytes) at the end of the byte string are never generated. If they 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 integer, the zero bytes are removed and the integer is adjusted upwards by the number of zero bytes that were removed. An example follows.¶
The following example shows the encoding of an 'alarm-state' leaf representation node instance with the 'critical' (position 2), 'warning' (position 8), and 'indeterminate' (position 128) flags set.¶
CBOR diagnostic notation: [h'0401', 14, h'01']¶
CBOR encoding: 83 42 0401 0E 41 01¶
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 REQUIRED to omit the array element and have only the byte array that would have been inside. To illustrate this, let us consider the same example YANG definition but this time encoding only 'under-repair' and 'critical' flags. The result would be¶
CBOR diagnostic notation: h'06'¶
CBOR encoding: 41 06¶
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 integers MUST alternate, i.e., adjacent byte strings or adjacent 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 positive integer is an error. Note that a recipient can handle trailing zero bytes in the byte strings using the normal rules without any issue, so an implementation MAY silently accept them.¶
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 space-separated sequence of names of 'bits' that are set (see also Section 6.12). The encoding MUST be enclosed by the bits CBOR tag, as specified in Section 9.3.¶
The following example shows the encoding of an 'alarm-state' leaf representation node instance defined using a union type with the 'under-repair' and 'critical' flags set.¶
Definition example:¶
CBOR diagnostic notation: 43
CBOR encoding: D8 2B 75 756E6465722D726
6.8. The 'binary' Type
Leafs of type binary MUST be encoded using a CBOR byte string data item (major type 2).¶
The following example shows the encoding of an 'aes128-key' leaf representation node
instance set to 0x1f1ce6a3f4266
Definition example:¶
CBOR diagnostic notation: h'1F1CE6A3F4266
CBOR encoding: 50 1F1CE6A3F42660D
6.9. The 'leafref' Type
Leafs of type leafref MUST be encoded using the rules of the representation node referenced by the 'path' YANG statement.¶
The following example shows the encoding of an 'interface
Definition example adapted from [RFC8343]:¶
CBOR diagnostic notation: "eth1"¶
CBOR encoding: 64 65746831¶
6.10. The 'identityref' Type
This specification supports two approaches for encoding identityref: as a YANG Schema Item iDentifier, as defined in Section 3.2, or as a name, as defined in Section 6.8 of [RFC7951]. See Section 6.12 for an exceptional case when this representation needs to be tagged.¶
6.10.1. SIDs as 'identityref'
When representation nodes of type identityref are implemented using SIDs, they MUST be encoded using a CBOR unsigned integer data item (major type 0). (Note that, as they are not used in the position of CBOR map keys, no delta mechanism is employed for SIDs used for identityref.)¶
The following example shows the encoding of a 'type' leaf representation node instance set to the value 'iana
Definition example adapted from [RFC7317]:¶
CBOR diagnostic notation: 1880¶
CBOR encoding: 19 0758¶
6.10.2. Name as 'identityref'
Alternatively, an identityref MAY be encoded using a name, as defined in Section 3.3. When names are used, identityref MUST be encoded using a CBOR text string data item (major type 3). If the identity is defined in a different module than the leaf node containing the identityref data node, the namespace
The following example shows the encoding of the identity 'iana
CBOR diagnostic notation: "iana
CBOR encoding: 78 1B 69616E612D69662
6.11. The 'empty' Type
Leafs of type empty MUST be encoded using the CBOR null value (major type 7, additional information 22).¶
The following example shows the encoding of an 'is-router' leaf representation node instance when present.¶
Definition example adapted from [RFC8344]:¶
CBOR diagnostic notation: null¶
CBOR encoding: F6¶
6.12. The 'union' Type
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 datatypes are enclosed by a CBOR tag to avoid confusion between different YANG datatypes encoded using the same CBOR major type.¶
See Section 9.3 for the assigned value of these CBOR tags.¶
As mentioned in Sections 6.6 and in 6.7, 'enumeration' and 'bits' are encoded as a CBOR text string data item (major type 3) 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 work-around 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 representation node instance when set to "2001
Definition example adapted from [RFC6991]:¶
CBOR diagnostic notation: "2001
CBOR encoding: 74 323030313A64623
6.13. The 'instance-identifier' Type
This specification supports two approaches for encoding an instance
6.13.1. SIDs as 'instance-identifier'
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 YANG module or submodule or schema nodes defined within a container, the SID is sufficient to identify this instance (representation node). (Note that no delta mechanism is employed for SIDs used for identityref, see Section 6.10.1.)¶
In the case of a representation node that is an entry of a YANG list, a SID is combined with the list key(s) to identify each instance within the YANG list(s).¶
Instance
Instance
Examples within this section assume the definition of a schema node of type 'instance
Definition example adapted from [RFC7950]:¶
First example:¶
The following example shows the encoding of the 'reporting
Definition example adapted from [RFC7317]:¶
CBOR diagnostic notation: 1741¶
CBOR encoding: 19 06CD¶
Second example:¶
This example aims to show how a representation node entry of a YANG list is identified.
It uses a somewhat arbitrarily modified YANG module version from [RFC7317] by
adding country to the leafs and keys of authorized-key.¶
The following example shows the encoding of the 'reporting
CBOR diagnostic notation: [1734, "bob", "admin", "france"]¶
CBOR encoding:¶
Third example:¶
The following example shows the encoding of the 'reporting
CBOR diagnostic notation: [1730, "jack"]¶
CBOR encoding:¶
6.13.2. Names as 'instance-identifier'
An 'instance
For example,¶
/ietf
is a valid instance
The resulting XML Path Language (XPath) MUST be encoded using a CBOR text string data item (major type 3).¶
First example:¶
This example is described in Section 6.13.1.¶
CBOR diagnostic notation: "
CBOR encoding:¶
Second example:¶
This example is described in Section 6.13.1.¶
CBOR diagnostic notation (the line break is inserted for exposition only):¶
CBOR encoding:¶
Third example:¶
This example is described in Section 6.13.1.¶
CBOR diagnostic notation:¶
CBOR encoding:¶
7. Content-Types
This specification defines the media type
application, which can be used without parameters or
with the id parameter set to either name or sid.¶
This media type represents a YANG-CBOR document containing a representation tree.
If the media type parameter id is present,
depending on its value,
each representation node is identified by its associated namespaceid=name), or by its associated YANG SID
(represented, e.g., in CBOR map keys as a SID delta or via tag number 47), as defined in Section 3.2
(id=sid), respectively.
If no id parameter is given, both forms may be present.¶
The format of an application representation is that
of a CBOR map, mapping names, and/or SIDs (as defined above) into
instance values (using the rules defined in Section 4).¶
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 does happen, any new value is foreseen to be of the form
[a.¶
In summary, this document defines three content-types, which are intended for use by different classes of applications:¶
All three content-types are based on the same representation mechanisms, parts of which are simply not used in the first and second cases.¶
How the use of one of these content-types is selected in a transfer
protocol is outside the scope of this specification.
The last paragraph of Section 5.2 of [RFC8040] discusses how to
indicate and request the usage of specific content-types in RESTCONF.
Similar mechanisms are available in the Constrained Application Protocol (CoAP) [RFC7252] using the
Content-Format and Accept Options; [CORE-COMI] demonstrates specifics on
how Content-Format may be used to indicate the id=sid case.¶
8. Security Considerations
The security considerations of [RFC8949] and [RFC7950] apply.¶
This document defines an alternative encoding for data modeled in the YANG data modeling language. As such, this encoding does not contribute any new security issues in addition to those identified for the specific protocol or context for which it is used.¶
To minimize security risks, software on the receiving side SHOULD reject all messages that do not comply to the rules of this document and reply with an appropriate error message to the sender.¶
For instance, when the id parameter to the media type is used, it is
important to properly reject identifiers of the other type to avoid
scenarios where different implementations interpret a given content in
different ways.¶
When SIDs are in use, the interpretation of encoded data not only relies on having the right YANG modules but also on having the right SID mapping information. Management and evolution of that mapping information therefore requires the same care as the management and evolution of the YANG modules themselves. The procedures in [CORE-SID] are being defined with this in mind.¶
9. IANA Considerations
9.1. Media Types Registry
IANA has added the following media type to the "Media Types" registry [IANA.media-types].¶
- Type name:
- application¶
- Subtype name:
- yang-data+cbor¶
- Required parameters:
- N/A¶
- Optional parameters:
- id (see Section 7 of RFC 9254)¶
- Encoding considerations:
- binary (CBOR)¶
- Security considerations:
- see Section 8 of RFC 9254¶
- Interoperability considerations:
- N/A¶
- Published specification:
- RFC 9254¶
- Applications that use this media type:
- applications that need a concise and efficient representation of YANG-modeled data¶
- Fragment identifier considerations:
- The syntax and semantics of
fragment identifiers specified for "application
/yang -data+cbor" is as specified for "application /cbor" . (At publication of this document, there is no fragment identification syntax defined for "application /cbor" .) ¶ - Additional information:
- Magic number(s):
- N/A¶
- File extension(s):
- N/A¶
- Macintosh file type code(s):
- N/A¶
- Person & email address to contact for further information:
- CORE WG mailing list (core@ietf.org) or IETF Applications and Real-Time Area (art@ietf.org)¶
- Intended usage:
- COMMON¶
- Restrictions on usage:
- N/A¶
- Author:
- CoRE WG¶
- Change controller:
- IETF¶
9.2. CoAP Content-Formats Registry
IANA has added the following Content-Formats to the "CoAP Content-Formats" subregistry,
within the "Constrained RESTful Environments (CoRE) Parameters"
registry [IANA
9.3. CBOR Tags Registry
IANA has allocated the following CBOR tag numbers in the "CBOR Tags" registry [IANA.cbor-tags] defined in Section 9.2 of [RFC8949].¶
10. References
10.1. Normative References
-
IANA, "Concise Binary Object Representation (CBOR) Tags", <https://
www >..iana .org /assignments /cbor -tags - [IANA
.core -parameters] -
IANA, "Constrained RESTful Environments (CoRE) Parameters", <https://
www >..iana .org /assignments /core -parameters / - [IANA
.media -types] -
IANA, "Media Types", <https://
www >..iana .org /assignments /media -types / - [RFC2119]
-
Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10
.17487 , , <https:///RFC2119 www >..rfc -editor .org /info /rfc2119 - [RFC5234]
-
Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", STD 68, RFC 5234, DOI 10
.17487 , , <https:///RFC5234 www >..rfc -editor .org /info /rfc5234 - [RFC7950]
-
Bjorklund, M., Ed., "The YANG 1.1 Data Modeling Language", RFC 7950, DOI 10
.17487 , , <https:///RFC7950 www >..rfc -editor .org /info /rfc7950 - [RFC7951]
-
Lhotka, L., "JSON Encoding of Data Modeled with YANG", RFC 7951, DOI 10
.17487 , , <https:///RFC7951 www >..rfc -editor .org /info /rfc7951 - [RFC8040]
-
Bierman, A., Bjorklund, M., and K. Watsen, "RESTCONF Protocol", RFC 8040, DOI 10
.17487 , , <https:///RFC8040 www >..rfc -editor .org /info /rfc8040 - [RFC8174]
-
Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10
.17487 , , <https:///RFC8174 www >..rfc -editor .org /info /rfc8174 - [RFC8259]
-
Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10
.17487 , , <https:///RFC8259 www >..rfc -editor .org /info /rfc8259 - [RFC8610]
-
Birkholz, H., Vigano, C., and C. Bormann, "Concise Data Definition Language (CDDL): A Notational Convention to Express Concise Binary Object Representation (CBOR) and JSON Data Structures", RFC 8610, DOI 10
.17487 , , <https:///RFC8610 www >..rfc -editor .org /info /rfc8610 - [RFC8791]
-
Bierman, A., Björklund, M., and K. Watsen, "YANG Data Structure Extensions", RFC 8791, DOI 10
.17487 , , <https:///RFC8791 www >..rfc -editor .org /info /rfc8791 - [RFC8949]
-
Bormann, C. and P. Hoffman, "Concise Binary Object Representation (CBOR)", STD 94, RFC 8949, DOI 10
.17487 , , <https:///RFC8949 www >..rfc -editor .org /info /rfc8949
10.2. Informative References
- [CORE-COMI]
-
Veillette, M., Ed., van der Stok, P., Ed., Pelov, A., Bierman, A., and I. Petrov, Ed., "CoAP Management Interface (CORECONF)", Work in Progress, Internet-Draft, draft
-ietf , , <https://-core -comi -11 datatracker >..ietf .org /doc /html /draft -ietf -core -comi -11 - [CORE-SID]
-
Veillette, M., Ed., Pelov, A., Ed., Petrov, I., Ed., Bormann, C., and M. Richardson, "YANG Schema Item iDentifier (YANG SID)", Work in Progress, Internet-Draft, draft
-ietf , , <https://-core -sid -18 datatracker >..ietf .org /doc /html /draft -ietf -core -sid -18 - [RFC6241]
-
Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed., and A. Bierman, Ed., "Network Configuration Protocol (NETCONF)", RFC 6241, DOI 10
.17487 , , <https:///RFC6241 www >..rfc -editor .org /info /rfc6241 - [RFC6991]
-
Schoenwaelder, J., Ed., "Common YANG Data Types", RFC 6991, DOI 10
.17487 , , <https:///RFC6991 www >..rfc -editor .org /info /rfc6991 - [RFC7228]
-
Bormann, C., Ersue, M., and A. Keranen, "Terminology for Constrained
-Node , RFC 7228, DOI 10Networks" .17487 , , <https:///RFC7228 www >..rfc -editor .org /info /rfc7228 - [RFC7252]
-
Shelby, Z., Hartke, K., and C. Bormann, "The Constrained Application Protocol (CoAP)", RFC 7252, DOI 10
.17487 , , <https:///RFC7252 www >..rfc -editor .org /info /rfc7252 - [RFC7317]
-
Bierman, A. and M. Bjorklund, "A YANG Data Model for System Management", RFC 7317, DOI 10
.17487 , , <https:///RFC7317 www >..rfc -editor .org /info /rfc7317 - [RFC8343]
-
Bjorklund, M., "A YANG Data Model for Interface Management", RFC 8343, DOI 10
.17487 , , <https:///RFC8343 www >..rfc -editor .org /info /rfc8343 - [RFC8344]
-
Bjorklund, M., "A YANG Data Model for IP Management", RFC 8344, DOI 10
.17487 , , <https:///RFC8344 www >..rfc -editor .org /info /rfc8344
Acknowledgments
This document has been largely inspired by the extensive work done by Andy Bierman and Peter van der Stok on [CORE-COMI]. [RFC7951] has also been a critical input to this work. The authors would like to thank the authors and contributors of these two documents.¶
The authors would also like to acknowledge the review, feedback, and comments from Ladislav Lhotka and Jürgen Schönwälder and from the Document Shepherd Marco Tiloca. Extensive comments helped us further improve the document in the IESG review process; the authors would like to call out specifically the feedback and guidance by the responsible AD Francesca Palombini and the significant improvements suggested by IESG members Benjamin Kaduk and Rob Wilton.¶