idnits 2.17.1 draft-ietf-core-yang-cbor-05.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The abstract seems to contain references ([RFC7049]), which it shouldn't. Please replace those with straight textual mentions of the documents in question. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (August 08, 2017) is 2445 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Missing Reference: '-2' is mentioned on line 791, but not defined -- Looks like a reference, but probably isn't: '257' on line 791 == Missing Reference: '0-9' is mentioned on line 1057, but not defined == Missing Reference: '1-9' is mentioned on line 1048, but not defined == Missing Reference: '0-4' is mentioned on line 1057, but not defined == Missing Reference: '0-5' is mentioned on line 1057, but not defined == Missing Reference: '0-9a-fA-F' is mentioned on line 1056, but not defined -- Looks like a reference, but probably isn't: '01' on line 1057 ** Obsolete normative reference: RFC 7049 (Obsoleted by RFC 8949) == Outdated reference: A later version (-17) exists of draft-ietf-core-comi-01 == Outdated reference: A later version (-24) exists of draft-ietf-core-sid-01 -- Obsolete informational reference (is this intentional?): RFC 7159 (Obsoleted by RFC 8259) -- Obsolete informational reference (is this intentional?): RFC 7223 (Obsoleted by RFC 8343) -- Obsolete informational reference (is this intentional?): RFC 7277 (Obsoleted by RFC 8344) Summary: 2 errors (**), 0 flaws (~~), 9 warnings (==), 6 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Internet Engineering Task Force M. Veillette, Ed. 3 Internet-Draft Trilliant Networks Inc. 4 Intended status: Standards Track A. Pelov, Ed. 5 Expires: February 9, 2018 Acklio 6 A. Somaraju 7 Tridonic GmbH & Co KG 8 R. Turner 9 Landis+Gyr 10 A. Minaburo 11 Acklio 12 August 08, 2017 14 CBOR Encoding of Data Modeled with YANG 15 draft-ietf-core-yang-cbor-05 17 Abstract 19 This document defines encoding rules for serializing configuration 20 data, state data, RPC input and RPC output, Action input, Action 21 output and notifications defined within YANG modules using the 22 Concise Binary Object Representation (CBOR) [RFC7049]. 24 Status of This Memo 26 This Internet-Draft is submitted in full conformance with the 27 provisions of BCP 78 and BCP 79. 29 Internet-Drafts are working documents of the Internet Engineering 30 Task Force (IETF). Note that other groups may also distribute 31 working documents as Internet-Drafts. The list of current Internet- 32 Drafts is at http://datatracker.ietf.org/drafts/current/. 34 Internet-Drafts are draft documents valid for a maximum of six months 35 and may be updated, replaced, or obsoleted by other documents at any 36 time. It is inappropriate to use Internet-Drafts as reference 37 material or to cite them other than as "work in progress." 39 This Internet-Draft will expire on February 9, 2018. 41 Copyright Notice 43 Copyright (c) 2017 IETF Trust and the persons identified as the 44 document authors. All rights reserved. 46 This document is subject to BCP 78 and the IETF Trust's Legal 47 Provisions Relating to IETF Documents 48 (http://trustee.ietf.org/license-info) in effect on the date of 49 publication of this document. Please review these documents 50 carefully, as they describe your rights and restrictions with respect 51 to this document. Code Components extracted from this document must 52 include Simplified BSD License text as described in Section 4.e of 53 the Trust Legal Provisions and are provided without warranty as 54 described in the Simplified BSD License. 56 Table of Contents 58 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 59 2. Terminology and Notation . . . . . . . . . . . . . . . . . . 3 60 2.1. YANG Schema Item iDentifier (SID) . . . . . . . . . . . . 4 61 2.2. CBOR diagnostic notation . . . . . . . . . . . . . . . . 5 62 3. Properties of the CBOR Encoding . . . . . . . . . . . . . . . 6 63 4. Encoding of YANG Data Node Instances . . . . . . . . . . . . 7 64 4.1. The 'leaf' Data Node . . . . . . . . . . . . . . . . . . 7 65 4.2. The 'container' Data Node . . . . . . . . . . . . . . . . 7 66 4.2.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . 8 67 4.2.2. Member names as keys . . . . . . . . . . . . . . . . 10 68 4.3. The 'leaf-list' Data Node . . . . . . . . . . . . . . . . 10 69 4.4. The 'list' Data Node . . . . . . . . . . . . . . . . . . 11 70 4.4.1. SIDs as keys . . . . . . . . . . . . . . . . . . . . 11 71 4.4.2. Member names as keys . . . . . . . . . . . . . . . . 14 72 4.5. The 'anydata' Data Node . . . . . . . . . . . . . . . . . 15 73 4.6. The 'anyxml' Data Node . . . . . . . . . . . . . . . . . 17 74 5. Representing YANG Data Types in CBOR . . . . . . . . . . . . 17 75 5.1. The unsigned integer Types . . . . . . . . . . . . . . . 17 76 5.2. The integer Types . . . . . . . . . . . . . . . . . . . . 18 77 5.3. The 'decimal64' Type . . . . . . . . . . . . . . . . . . 18 78 5.4. The 'string' Type . . . . . . . . . . . . . . . . . . . . 18 79 5.5. The 'boolean' Type . . . . . . . . . . . . . . . . . . . 19 80 5.6. The 'enumeration' Type . . . . . . . . . . . . . . . . . 19 81 5.7. The 'bits' Type . . . . . . . . . . . . . . . . . . . . . 20 82 5.8. The 'binary' Type . . . . . . . . . . . . . . . . . . . . 21 83 5.9. The 'leafref' Type . . . . . . . . . . . . . . . . . . . 21 84 5.10. The 'identityref' Type . . . . . . . . . . . . . . . . . 22 85 5.10.1. SIDs as identityref . . . . . . . . . . . . . . . . 22 86 5.10.2. Name as identityref . . . . . . . . . . . . . . . . 23 87 5.11. The 'empty' Type . . . . . . . . . . . . . . . . . . . . 23 88 5.12. The 'union' Type . . . . . . . . . . . . . . . . . . . . 24 89 5.13. The 'instance-identifier' Type . . . . . . . . . . . . . 25 90 5.13.1. SIDs as instance-identifier . . . . . . . . . . . . 25 91 5.13.2. Names as instance-identifier . . . . . . . . . . . . 28 92 6. Security Considerations . . . . . . . . . . . . . . . . . . . 29 93 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 29 94 7.1. Tags Registry . . . . . . . . . . . . . . . . . . . . . . 29 95 8. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 29 96 9. References . . . . . . . . . . . . . . . . . . . . . . . . . 30 97 9.1. Normative References . . . . . . . . . . . . . . . . . . 30 98 9.2. Informative References . . . . . . . . . . . . . . . . . 30 99 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 31 101 1. Introduction 103 The specification of the YANG 1.1 data modelling language [RFC7950] 104 defines an XML encoding for data instances, i.e. contents of 105 configuration datastores, state data, RPC inputs and outputs, action 106 inputs and outputs, and event notifications. 108 A new set of encoding rules has been defined to allow the use of the 109 same data models in environments based on the JavaScript Object 110 Notation (JSON) Data Interchange Format [RFC7159]. This is 111 accomplished in the JSON Encoding of Data Modeled with YANG 112 specification [RFC7951]. 114 The aim of this document is to define a set of encoding rules for the 115 Concise Binary Object Representation (CBOR) [RFC7049]. The resulting 116 encoding is more compact compared to XML and JSON and more suitable 117 for Constrained Nodes and/or Constrained Networks as defined by 118 [RFC7228]. 120 2. Terminology and Notation 122 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 123 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 124 document are to be interpreted as described in [RFC2119]. 126 The following terms are defined in [RFC7950]: 128 o action 130 o anydata 132 o anyxml 134 o data node 136 o data tree 138 o feature 140 o identity 142 o module 144 o notification 145 o RPC 147 o schema node 149 o schema tree 151 o submodule 153 The following terms are defined in [RFC7951]: 155 o member name 157 o name of an identity 159 o namespace-qualified 161 This specification also makes use of the following terminology: 163 o child: A schema node defined within a collection such as a 164 container, a list, a case, a notification, an RPC input, an RPC 165 output, an action input, an action output. 167 o delta: Difference between the current SID and a reference SID. A 168 reference SID is defined for each context for which deltas are 169 used. 171 o item: A schema node, an identity, a module, a submodule or a 172 feature defined using the YANG modeling language. 174 o parent: The collection in which a schema node is defined. 176 o YANG Schema Item iDentifier (SID): Unsigned integer used to 177 identify different YANG items. 179 2.1. YANG Schema Item iDentifier (SID) 181 Some of the items defined in YANG [RFC7950] require the use of a 182 unique identifier. In both NETCONF [RFC6241] and RESTCONF [RFC8040], 183 these identifiers are implemented using names. To allow the 184 implementation of data models defined in YANG in constrained devices 185 and constrained networks, a more compact method to identify YANG 186 items is required. This compact identifier, called YANG Schema Item 187 iDentifier (SID), is encoded using an unsigned integer. The 188 following items are identified using SIDs: 190 o identities 192 o data nodes 193 o RPCs and associated input(s) and output(s) 195 o actions and associated input(s) and output(s) 197 o notifications and associated information 199 o YANG modules, submodules and features 201 To minimize its size, in certain positions, SIDs are represented 202 using a (signed) delta from a reference SID and the current SID. 203 Conversion from SIDs to deltas and back to SIDs are stateless 204 processes solely based on the data serialized or deserialized. 206 Mechanisms and processes used to assign SIDs to YANG items and to 207 guarantee their uniqueness is outside the scope of the present 208 specification. If SIDs are to be used, the present specification is 209 used in conjunction with a specification defining this management. 210 One example for such a specification is under development as 211 [I-D.ietf-core-sid]. 213 2.2. CBOR diagnostic notation 215 Within this document, CBOR binary contents are represented using an 216 equivalent textual form called CBOR diagnostic notation as defined in 217 [RFC7049] section 6. This notation is used strictly for 218 documentation purposes and is never used in the data serialization. 219 Table 1 below provides a summary of this notation. 221 +----------+------+--------------------------+-----------+----------+ 222 | CBOR | CBOR | Diagnostic notation | Example | CBOR | 223 | content | type | | | encoding | 224 +----------+------+--------------------------+-----------+----------+ 225 | Unsigned | 0 | Decimal digits | 123 | 18 7b | 226 | integer | | | | | 227 | Negative | 1 | Decimal digits prefixed | -123 | 38 7a | 228 | integer | | by a minus sign | | | 229 | Byte | 2 | Hexadecimal value | h'f15c' | 42 f15c | 230 | string | | enclosed between single | | | 231 | | | quotes and prefixed by | | | 232 | | | an 'h' | | | 233 | Text | 3 | String of Unicode | "txt" | 63 | 234 | string | | characters enclosed | | 747874 | 235 | | | between double quotes | | | 236 | Array | 4 | Comma-separated list of | [ 1, 2 ] | 82 01 02 | 237 | | | values within square | | | 238 | | | brackets | | | 239 | Map | 5 | Comma-separated list of | { 1: 123, | a2 | 240 | | | key : value pairs within | 2: 456 } | 01187b | 241 | | | curly braces | | 021901c8 | 242 | Boolean | 7/20 | false | false | f4 | 243 | | 7/21 | true | true | f5 | 244 | Null | 7/22 | null | null | f6 | 245 | Not | 7/23 | undefined | undefined | f7 | 246 | assigned | | | | | 247 +----------+------+--------------------------+-----------+----------+ 249 Table 1: CBOR diagnostic notation summary 251 The following extensions to the CBOR diagnostic notation are 252 supported: 254 o Any text within and including a pair of slashes is considered a 255 comment. 257 o Deltas are visualized as numbers preceded by a '+' or '-' sign. 258 The use of the '+' sign for positive deltas represents an 259 extension to the CBOR diagnostic notation as defined by [RFC7049] 260 section 6. 262 3. Properties of the CBOR Encoding 264 This document defines CBOR encoding rules for YANG schema trees and 265 their subtrees. 267 Basic schema nodes such as leaf, leaf-list, list, anydata and anyxml 268 can be encoded standalone. In this case, only the value of this 269 schema node is encoded in CBOR. Identification of this value needs 270 to be provided by some external means when required. 272 A collection such as container, list instance, notification, RPC 273 input, RPC output, action input and action output is serialized using 274 a CBOR map in which each child schema node is encoded using a key and 275 a value. This specification supports two type of CBOR keys; YANG 276 Schema Item iDentifier (SID) as defined in Section 2.1 and member 277 names as defined in [RFC7951]. Each of these key types is encoded 278 using a specific CBOR type which allows their interpretation during 279 the deserialization process. The end user of this mapping 280 specification (e.g. RESTCONF [RFC8040], CoMI [I-D.ietf-core-comi]) 281 can mandate the use of a specific key type. 283 In order to minimize the size of the encoded data, the proposed 284 mapping avoids any unnecessary meta-information beyond those natively 285 supported by CBOR. For instance, CBOR tags are used solely in the 286 case of anyxml data nodes and the union datatype to distinguish 287 explicitly the use of different YANG datatypes encoded using the same 288 CBOR major type. 290 4. Encoding of YANG Data Node Instances 292 Schema node instances defined using the YANG modeling language are 293 encoded using CBOR [RFC7049] based on the rules defined in this 294 section. We assume that the reader is already familiar with both 295 YANG [RFC7950] and CBOR [RFC7049]. 297 4.1. The 'leaf' Data Node 299 Leafs MUST be encoded based on the encoding rules specified in 300 Section 5. 302 4.2. The 'container' Data Node 304 Collections such as containers, list instances, notifications, RPC 305 inputs, RPC outputs, action inputs and action outputs MUST be encoded 306 using a CBOR map data item (major type 5). A map is comprised of 307 pairs of data items, with each data item consisting of a key and a 308 value. Each key within the CBOR map is set to a data node 309 identifier, each value is set to the value of this data node instance 310 according to the instance datatype. 312 This specification supports two type of CBOR keys; SID as defined in 313 Section 2.1 encoded as deltas and member names as defined in 314 [RFC7951] encoded using CBOR text strings. The use of CBOR byte 315 strings for keys is reserved for future extensions. 317 4.2.1. SIDs as keys 319 Keys implemented using SIDs MUST be encoded using a CBOR unsigned 320 integer (major type 0) or CBOR negative integer (major type 1), 321 depending on the actual value. Keys are represented as the delta of 322 the associated SID, delta values are computed as follows: 324 o The delta value is equal to the SID of the current schema node 325 minus the SID of the parent schema node. When no parent exists in 326 the context of use of this container, the delta is set to the SID 327 of the current schema node (i.e., a parent with SID equal to zero 328 is assumed). 330 o Delta values may result in a negative number, clients and servers 331 MUST support both unsigned and negative deltas. 333 The following example shows the encoding of a 'system-state' 334 container instance with a single child, a clock container. The clock 335 container container has two children, a 'current-datetime' leaf and a 336 'boot-datetime' leaf. 338 Definition example from [RFC7317]: 340 typedef date-and-time { 341 type string { 342 pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-] 343 \d{2}:\d{2})'; 344 } 345 } 347 container system-state { 349 container clock { 350 leaf current-datetime { 351 type date-and-time; 352 } 354 leaf boot-datetime { 355 type date-and-time; 356 } 357 } 358 } 360 For this first representation, we assume that parent SID of the root 361 container (i.e. 'system-state') is not available to the serializer. 362 In this case, root data nodes are encoded using absolute SIDs. 364 CBOR diagnostic notation: 366 { 367 1717 : { / clock (SID 1717) / 368 +2 : "2015-10-02T14:47:24Z-05:00", / current-datetime (SID 1719)/ 369 +1 : "2015-09-15T09:12:58Z-05:00" / boot-datetime (SID 1718) / 370 } 371 } 373 CBOR encoding: 375 a1 # map(1) 376 19 06b5 # unsigned(1717) 377 a2 # map(2) 378 02 # unsigned(2) 379 78 1a # text(26) 380 323031352d31302d30325431343a34373a32345a2d30353a3030 381 01 # unsigned(1) 382 78 1a # text(26) 383 323031352d30392d31355430393a31323a35385a2d30353a3030 385 On the other hand, if the serializer is aware of the parent SID, 1716 386 in the case 'system-state' container, root data nodes are encoded 387 using deltas. 389 CBOR diagnostic notation: 391 { 392 +1 : { / clock (SID 1717) / 393 +2 : "2015-10-02T14:47:24Z-05:00", / current-datetime (SID 1719)/ 394 +1 : "2015-09-15T09:12:58Z-05:00" / boot-datetime (SID 1718) / 395 } 396 } 398 CBOR encoding: 400 a1 # map(1) 401 01 # unsigned(1) 402 a2 # map(2) 403 02 # unsigned(2) 404 78 1a # text(26) 405 323031352d31302d30325431343a34373a32345a2d30353a3030 406 01 # unsigned(1) 407 78 1a # text(26) 408 323031352d30392d31355430393a31323a35385a2d30353a3030 410 4.2.2. Member names as keys 412 Keys implemented using member names MUST be encoded using a CBOR text 413 string data item (major type 3). A namespace-qualified member name 414 MUST be used for all members of a top-level collection, and then also 415 whenever the namespaces of the schema node and its parent are 416 different. In all other cases, the simple form of the member name 417 MUST be used. Names and namespaces are defined in [RFC7951] section 418 4. 420 The following example shows the encoding of a 'system' container 421 instance using names. This example is described in Section 4.2.1. 423 CBOR diagnostic notation: 425 { 426 "ietf-system:clock" : { 427 "current-datetime" : "2015-10-02T14:47:24Z-05:00", 428 "boot-datetime" : "2015-09-15T09:12:58Z-05:00" 429 } 430 } 432 CBOR encoding: 434 a1 # map(1) 435 71 # text(17) 436 696574662d73797374656d3a636c6f636b # "ietf-system:clock" 437 a2 # map(2) 438 70 # text(16) 439 63757272656e742d6461746574696d65 # "current-datetime" 440 78 1a # text(26) 441 323031352d31302d30325431343a34373a32345a2d30353a3030 442 6d # text(13) 443 626f6f742d6461746574696d65 # "boot-datetime" 444 78 1a # text(26) 445 323031352d30392d31355430393a31323a35385a2d30353a3030 447 4.3. The 'leaf-list' Data Node 449 A leaf-list MUST be encoded using a CBOR array data item (major type 450 4). Each entry of this array MUST be encoded using the rules defined 451 by the YANG type specified. 453 The following example shows the encoding a 'search' leaf-list 454 instance containing the two entries, "ietf.org" and "ieee.org". 456 Definition example [RFC7317]: 458 typedef domain-name { 459 type string { 460 length "1..253"; 461 pattern '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9].) 462 *([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.? 463 )|\.'; 464 } 465 } 467 leaf-list search { 468 type domain-name; 469 ordered-by user; 470 } 472 CBOR diagnostic notation: [ "ietf.org", "ieee.org" ] 474 CBOR encoding: 82 68 696574662e6f7267 68 696565652e6f7267 476 4.4. The 'list' Data Node 478 A list MUST be encoded using a CBOR array data item (major type 4). 479 Each list instance within this CBOR array is encoded using a CBOR map 480 data item (major type 5) based on the same rules as a YANG container 481 as defined in Section 4.2. 483 4.4.1. SIDs as keys 485 The following example show the encoding of a 'server' list instance 486 using SIDs. It is important to note that the protocol or method 487 using this mapping may carry a parent SID or may have the knowledge 488 of this parent SID based on its context. In these cases, delta 489 encoding can be performed based on this parent SID which minimizes 490 the size of the encoded data. 492 Definition example from [RFC7317]: 494 list server { 495 key name; 497 leaf name { 498 type string; 499 } 500 choice transport { 501 case udp { 502 container udp { 503 leaf address { 504 type host; 505 mandatory true; 506 } 507 leaf port { 508 type port-number; 509 } 510 } 511 } 512 } 513 leaf association-type { 514 type enumeration { 515 enum server; 516 enum peer; 517 enum pool; 518 } 519 default server; 520 } 521 leaf iburst { 522 type boolean; 523 default false; 524 } 525 leaf prefer { 526 type boolean; 527 default false; 528 } 529 } 531 CBOR diagnostic notation: 533 [ 534 { 535 1755 : "NRC TIC server", / name (SID 1755) / 536 1757 : { / udp (SID 1757) / 537 +1 : "tic.nrc.ca", / address (SID 1758) / 538 +2 : 123 / port (SID 1759) / 539 }, 540 1753 : 0, / association-type (SID 1753) / 541 1754 : false, / iburst (SID 1754) / 542 1756 : true / prefer (SID 1756) / 543 }, 544 { 545 1755 : "NRC TAC server", / name (SID 1755) / 546 1757 : { / udp (SID 1757) / 547 +1 : "tac.nrc.ca" / address (SID 1758) / 548 } 549 } 550 ] 552 CBOR encoding: 554 82 # array(2) 555 a5 # map(5) 556 19 06db # unsigned(1755) 557 6e # text(14) 558 4e52432054494320736572766572 # "NRC TIC server" 559 19 06dd # unsigned(1757) 560 a2 # map(2) 561 01 # unsigned(1) 562 6a # text(10) 563 7469632e6e72632e6361 # "tic.nrc.ca" 564 02 # unsigned(2) 565 18 7b # unsigned(123) 566 19 06d9 # unsigned(1753) 567 00 # unsigned(0) 568 19 06da # unsigned(1754) 569 f4 # primitive(20) 570 19 06dc # unsigned(1756) 571 f5 # primitive(21) 572 a2 # map(2) 573 19 06db # unsigned(1755) 574 6e # text(14) 575 4e52432054414320736572766572 # "NRC TAC server" 576 19 06dd # unsigned(1757) 577 a1 # map(1) 578 01 # unsigned(1) 579 6a # text(10) 580 7461632e6e72632e6361 # "tac.nrc.ca" 582 4.4.2. Member names as keys 584 The following example shows the encoding of a 'server' list instance 585 using names. This example is described in Section 4.4.1. 587 CBOR diagnostic notation: 589 [ 590 { 591 "ietf-system:name" : "NRC TIC server", 592 "ietf-system:udp" : { 593 "address" : "tic.nrc.ca", 594 "port" : 123 595 }, 596 "ietf-system:association-type" : 0, 597 "ietf-system:iburst" : false, 598 "ietf-system:prefer" : true 599 }, 600 { 601 "ietf-system:name" : "NRC TAC server", 602 "ietf-system:udp" : { 603 "address" : "tac.nrc.ca" 604 } 605 } 606 ] 608 CBOR encoding: 610 82 # array(2) 611 a5 # map(5) 612 70 # text(16) 613 696574662d73797374656d3a6e616d65 # "ietf-system:name" 614 6e # text(14) 615 4e52432054494320736572766572 # "NRC TIC server" 616 6f # text(15) 617 696574662d73797374656d3a756470 # "ietf-system:udp" 618 a2 # map(2) 619 67 # text(7) 620 61646472657373 # "address" 621 6a # text(10) 622 7469632e6e72632e6361 # "tic.nrc.ca" 623 64 # text(4) 624 706f7274 # "port" 625 18 7b # unsigned(123) 626 78 1c # text(28) 627 696574662d73797374656d3a6173736f63696174696f6e2d74797065 628 00 # unsigned(0) 629 72 # text(18) 630 696574662d73797374656d3a696275727374 # "ietf-system:iburst" 631 f4 # primitive(20) 632 72 # text(18) 633 696574662d73797374656d3a707265666572 # "ietf-system:prefer" 634 f5 # primitive(21) 635 a2 # map(2) 636 70 # text(16) 637 696574662d73797374656d3a6e616d65 # "ietf-system:name" 638 6e # text(14) 639 4e52432054414320736572766572 # "NRC TAC server" 640 6f # text(15) 641 696574662d73797374656d3a756470 # "ietf-system:udp" 642 a1 # map(1) 643 67 # text(7) 644 61646472657373 # "address" 645 6a # text(10) 646 7461632e6e72632e6361 # "tac.nrc.ca" 648 4.5. The 'anydata' Data Node 650 An anydata serves as a container for an arbitrary set of schema nodes 651 that otherwise appear as normal YANG-modeled data. An anydata 652 instance is encoded using the same rules as a container, i.e., CBOR 653 map. The requirement that anydata content can be modeled by YANG 654 implies the following: 656 o Keys of any inner data nodes MUST be set to valid deltas or member 657 names. 659 o The CBOR array MUST contain either unique scalar values (as a 660 leaf-list, see Section 4.3), or maps (as a list, see Section 4.4). 662 o Values MUST follow the encoding rules of one of the datatypes 663 listed in Section 5. 665 The following example shows a possible use of anydata. In this 666 example, an anydata is used to define a data node containing a 667 notification event, this data node can be part of a YANG list to 668 create an event logger. 670 Definition example: 672 anydata event; 674 This example also assumes the assistance of the following 675 notification. 677 module example-port { 678 ... 680 notification example-port-fault { # SID 2600 681 leaf port-name { # SID 2601 682 type string; 683 } 684 leaf port-fault { # SID 2601 685 type string; 686 } 687 } 688 } 690 CBOR diagnostic notation: 692 { 693 2601 : "0/4/21", / port-name / 694 2602 : "Open pin 2" / port-fault / 695 } 697 CBOR encoding: 699 a2 # map(2) 700 19 0a29 # unsigned(2601) 701 66 # text(6) 702 302f342f3231 # "0/4/21" 703 19 0a2a # unsigned(2602) 704 6a # text(10) 705 4f70656e2070696e2032 # "Open pin 2" 707 4.6. The 'anyxml' Data Node 709 An anyxml schema node is used to serialize an arbitrary CBOR content, 710 i.e., its value can be any CBOR binary object. anyxml value may 711 contain CBOR data items tagged with one of the tag listed in 712 Section 7.1, these tags shall be supported. 714 The following example shows a valid CBOR encoded instance. 716 Definition example from [RFC7951]: 718 anyxml bar; 720 CBOR diagnostic notation: [true, null, true] 722 CBOR encoding: 83 f5 f6 f5 724 5. Representing YANG Data Types in CBOR 726 The CBOR encoding of an instance of a leaf or leaf-list data node 727 depends on the built-in type of that data node. The following sub- 728 section defined the CBOR encoding of each built-in type supported by 729 YANG as listed in [RFC7950] section 4.2.4. Each subsection shows an 730 example value assigned to a data node instance of the discussed 731 built-in type. 733 5.1. The unsigned integer Types 735 Leafs of type uint8, uint16, uint32 and uint64 MUST be encoded using 736 a CBOR unsigned integer data item (major type 0). 738 The following example shows the encoding of a 'mtu' leaf instance set 739 to 1280 bytes. 741 Definition example from [RFC7277]: 743 leaf mtu { 744 type uint16 { 745 range "68..max"; 746 } 747 } 749 CBOR diagnostic notation: 1280 751 CBOR encoding: 19 0500 753 5.2. The integer Types 755 Leafs of type int8, int16, int32 and int64 MUST be encoded using 756 either CBOR unsigned integer (major type 0) or CBOR negative integer 757 (major type 1), depending on the actual value. 759 The following example shows the encoding of a 'timezone-utc-offset' 760 leaf instance set to -300 minutes. 762 Definition example from [RFC7317]: 764 leaf timezone-utc-offset { 765 type int16 { 766 range "-1500 .. 1500"; 767 } 768 } 770 CBOR diagnostic notation: -300 772 CBOR encoding: 39 012b 774 5.3. The 'decimal64' Type 776 Leafs of type decimal64 MUST be encoded using a decimal fraction as 777 defined in [RFC7049] section 2.4.3. 779 The following example shows the encoding of a 'my-decimal' leaf 780 instance set to 2.57. 782 Definition example from [RFC7317]: 784 leaf my-decimal { 785 type decimal64 { 786 fraction-digits 2; 787 range "1 .. 3.14 | 10 | 20..max"; 788 } 789 } 791 CBOR diagnostic notation: 4([-2, 257]) 793 CBOR encoding: c4 82 21 19 0101 795 5.4. The 'string' Type 797 Leafs of type string MUST be encoded using a CBOR text string data 798 item (major type 3). 800 The following example shows the encoding of a 'name' leaf instance 801 set to "eth0". 803 Definition example from [RFC7223]: 805 leaf name { 806 type string; 807 } 809 CBOR diagnostic notation: "eth0" 811 CBOR encoding: 64 65746830 813 5.5. The 'boolean' Type 815 Leafs of type boolean MUST be encoded using a CBOR true (major type 816 7, additional information 21) or false data item (major type 7, 817 additional information 20). 819 The following example shows the encoding of an 'enabled' leaf 820 instance set to 'true'. 822 Definition example from [RFC7317]: 824 leaf enabled { 825 type boolean; 826 } 828 CBOR diagnostic notation: true 830 CBOR encoding: f5 832 5.6. The 'enumeration' Type 834 Leafs of type enumeration MUST be encoded using a CBOR unsigned 835 integer (major type 0) or CBOR negative integer (major type 1), 836 depending on the actual value. Enumeration values are either 837 explicitly assigned using the YANG statement 'value' or automatically 838 assigned based on the algorithm defined in [RFC7950] section 9.6.4.2. 840 The following example shows the encoding of an 'oper-status' leaf 841 instance set to 'testing'. 843 Definition example from [RFC7317]: 845 leaf oper-status { 846 type enumeration { 847 enum up { value 1; } 848 enum down { value 2; } 849 enum testing { value 3; } 850 enum unknown { value 4; } 851 enum dormant { value 5; } 852 enum not-present { value 6; } 853 enum lower-layer-down { value 7; } 854 } 855 } 857 CBOR diagnostic notation: 3 859 CBOR encoding: 03 861 5.7. The 'bits' Type 863 Leafs of type bits MUST be encoded using a CBOR byte string data item 864 (major type 2). Bits position are either explicitly assigned using 865 the YANG statement 'position' or automatically assigned based on the 866 algorithm defined in [RFC7950] section 9.7.4.2. 868 Bits position 0 to 7 are assigned to the first byte within the byte 869 string, bits 8 to 15 to the second byte, and subsequent bytes are 870 assigned similarly. Within each byte, bits are assigned from least 871 to most significant. 873 The following example shows the encoding of a 'mybits' leaf instance 874 with the 'disable-nagle' and '10-Mb-only' flags set. 876 Definition example from [RFC7950]: 878 leaf mybits { 879 type bits { 880 bit disable-nagle { 881 position 0; 882 } 883 bit auto-sense-speed { 884 position 1; 885 } 886 bit 10-Mb-only { 887 position 2; 888 } 889 } 890 } 892 CBOR diagnostic notation: h'05' 893 CBOR encoding: 41 05 895 5.8. The 'binary' Type 897 Leafs of type binary MUST be encoded using a CBOR byte string data 898 item (major type 2). 900 The following example shows the encoding of an 'aes128-key' leaf 901 instance set to 0x1f1ce6a3f42660d888d92a4d8030476e. 903 Definition example: 905 leaf aes128-key { 906 type binary { 907 length 16; 908 } 909 } 911 CBOR diagnostic notation: h'1f1ce6a3f42660d888d92a4d8030476e' 913 CBOR encoding: 50 1f1ce6a3f42660d888d92a4d8030476e 915 5.9. The 'leafref' Type 917 Leafs of type leafref MUST be encoded using the rules of the schema 918 node referenced by the 'path' YANG statement. 920 The following example shows the encoding of an 'interface-state-ref' 921 leaf instance set to "eth1". 923 Definition example from [RFC7223]: 925 typedef interface-state-ref { 926 type leafref { 927 path "/interfaces-state/interface/name"; 928 } 929 } 931 container interfaces-state { 932 list interface { 933 key "name"; 934 leaf name { 935 type string; 936 } 937 leaf-list higher-layer-if { 938 type interface-state-ref; 939 } 940 } 941 } 943 CBOR diagnostic notation: "eth1" 945 CBOR encoding: 64 65746831 947 5.10. The 'identityref' Type 949 This specification supports two approaches for encoding identityref, 950 a YANG Schema Item iDentifier (SID) as defined in Section 2.1 or a 951 name as defined in [RFC7951] section 6.8. 953 5.10.1. SIDs as identityref 955 When schema nodes of type identityref are implemented using SIDs, 956 they MUST be encoded using a CBOR unsigned integer data item (major 957 type 0). (Note that no delta mechanism is employed for SIDs as 958 identityref.) 960 The following example shows the encoding of a 'type' leaf instance 961 set to the value 'iana-if-type:ethernetCsmacd' (SID 1180). 963 Definition example from [RFC7317]: 965 identity interface-type { 966 } 968 identity iana-interface-type { 969 base interface-type; 970 } 972 identity ethernetCsmacd { 973 base iana-interface-type; 974 } 976 leaf type { 977 type identityref { 978 base interface-type; 979 } 980 } 982 CBOR diagnostic notation: 1180 984 CBOR encoding: 19 049c 986 5.10.2. Name as identityref 988 Alternatively, an identityref may be encoded using a name as defined 989 in [RFC7951] section 6.8. When names are used, identityref MUST be 990 encoded using a CBOR text string data item (major type 3). If the 991 identity is defined in another module than the leaf node containing 992 the identityref value, the namespace-qualified form MUST be used. 993 Otherwise, both the simple and namespace-qualified forms are 994 permitted. Names and namespaces are defined in [RFC7951] section 4. 996 The following example shows the encoding of the identity 'iana-if- 997 type:ethernetCsmacd' using its name. This example is described in 998 Section 5.10.1. 1000 CBOR diagnostic notation: "iana-if-type:ethernetCsmacd" 1002 CBOR encoding: 78 1b 1003 69616e612d69662d747970653a65746865726e657443736d616364 1005 5.11. The 'empty' Type 1007 Leafs of type empty MUST be encoded using the CBOR null value (major 1008 type 7, additional information 22). 1010 The following example shows the encoding of a 'is-router' leaf 1011 instance when present. 1013 Definition example from [RFC7277]: 1015 leaf is-router { 1016 type empty; 1017 } 1019 CBOR diagnostic notation: null 1021 CBOR encoding: f6 1023 5.12. The 'union' Type 1025 Leafs of type union MUST be encoded using the rules associated with 1026 one of the types listed. When used in a union, the following YANG 1027 datatypes are prefixed by CBOR tag to avoid confusion between 1028 different YANG datatypes encoded using the same CBOR major type. 1030 o bits 1032 o enumeration 1034 o identityref 1036 o instance-identifier 1038 See Section 7.1 for more information about these CBOR tags. 1040 The following example shows the encoding of an 'ip-address' leaf 1041 instance when set to "2001:db8:a0b:12f0::1". 1043 Definition example from [RFC7317]: 1045 typedef ipv4-address { 1046 type string { 1047 pattern '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3} 1048 ([0-9][1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\p{N} 1049 \p{L}]+)?'; 1050 } 1051 } 1053 typedef ipv6-address { 1054 type string { 1055 pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a 1056 -fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0 1057 -9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0 1058 -9]?[0-9])))(%[\p{N}\p{L}]+)?'; 1059 pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|((([^:]+:)*[^:]+) 1060 ?::(([^:]+:)*[^:]+)?)(%.+)?'; 1061 } 1062 } 1064 typedef ip-address { 1065 type union { 1066 type ipv4-address; 1067 type ipv6-address; 1068 } 1069 } 1071 leaf address { 1072 type inet:ip-address; 1073 } 1075 CBOR diagnostic notation: "2001:db8:a0b:12f0::1" 1077 CBOR encoding: 74 323030313a6462383a6130623a313266303a3a31 1079 5.13. The 'instance-identifier' Type 1081 This specification supports two approaches for encoding an instance- 1082 identifier, one based on YANG Schema Item iDentifier (SID) as defined 1083 in Section 2.1 and one based on names as defined in [RFC7951] section 1084 6.11. 1086 5.13.1. SIDs as instance-identifier 1088 SIDs uniquely identify a data node. In the case of a single instance 1089 data node, a data node defined at the root of a YANG module or 1090 submodule or data nodes defined within a container, the SID is 1091 sufficient to identify this instance. 1093 In the case of a data node member of a YANG list, a SID is combined 1094 with the list key(s) to identify each instance within the YANG 1095 list(s). 1097 Single instance data nodes MUST be encoded using a CBOR unsigned 1098 integer data item (major type 0) and set to the targeted data node 1099 SID. 1101 Data nodes member of a YANG list MUST be encoded using a CBOR array 1102 data item (major type 4) containing the following entries: 1104 o The first entry MUST be encoded as a CBOR unsigned integer data 1105 item (major type 0) and set to the targeted data node SID. 1107 o The following entries MUST contain the value of each key required 1108 to identify the instance of the targeted data node. These keys 1109 MUST be ordered as defined in the 'key' YANG statement, starting 1110 from top level list, and follow by each of the subordinate 1111 list(s). 1113 *First example:* 1115 The following example shows the encoding of a leaf instance of type 1116 instance-identifier which identifies the data node "/system/contact" 1117 (SID 1737). 1119 Definition example from [RFC7317]: 1121 container system { 1123 leaf contact { 1124 type string; 1125 } 1127 leaf hostname { 1128 type inet:domain-name; 1129 } 1130 } 1132 CBOR diagnostic notation: 1737 1134 CBOR encoding: 19 06c9 1136 *Second example:* 1138 The following example shows the encoding of a leaf instance of type 1139 instance-identifier which identify the data node instance 1140 "/system/authentication/user/authorized-key/key-data" (SID 1730) for 1141 user name "bob" and authorized-key "admin". 1143 Definition example from [RFC7317]: 1145 list user { 1146 key name; 1148 leaf name { 1149 type string; 1150 } 1151 leaf password { 1152 type ianach:crypt-hash; 1153 } 1155 list authorized-key { 1156 key name; 1158 leaf name { 1159 type string; 1160 } 1161 leaf algorithm { 1162 type string; 1163 } 1164 leaf key-data { 1165 type binary; 1166 } 1167 } 1169 CBOR diagnostic notation: [1730, "bob", "admin"] 1171 CBOR encoding: 1173 83 # array(3) 1174 19 06c2 # unsigned(1730) 1175 63 # text(3) 1176 626f62 # "bob" 1177 65 # text(5) 1178 61646d696e # "admin" 1180 *Third example:* 1182 The following example shows the encoding of a leaf instance of type 1183 instance-identifier which identify the list instance 1184 "/system/authentication/user" (SID 1726) corresponding to the user 1185 name "jack". 1187 CBOR diagnostic notation: [1726, "jack"] 1188 CBOR encoding: 1190 82 # array(2) 1191 19 06be # unsigned(1726) 1192 64 # text(4) 1193 6a61636b # "jack" 1195 5.13.2. Names as instance-identifier 1197 The use of names as instance-identifier is defined in [RFC7951] 1198 section 6.11. The resulting xpath MUST be encoded using a CBOR text 1199 string data item (major type 3). 1201 *First example:* 1203 This example is described in Section 5.13.1. 1205 CBOR diagnostic notation: "/ietf-system:system/contact" 1207 CBOR encoding: 1209 78 1c 2f20696574662d73797374656d3a73797374656d2f636f6e74616374 1211 *Second example:* 1213 This example is described in Section 5.13.1. 1215 CBOR diagnostic notation: 1217 "/ietf-system:system/authentication/user[name='bob']/authorized-key 1218 [name='admin']/key-data" 1220 CBOR encoding: 1222 78 59 1223 2f696574662d73797374656d3a73797374656d2f61757468656e74696361 1224 74696f6e2f757365725b6e616d653d27626f62275d2f617574686f72697a 1225 65642d6b65795b6e616d653d2761646d696e275d2f6b65792d64617461 1227 *Third example:* 1229 This example is described in Section 5.13.1. 1231 CBOR diagnostic notation: 1233 "/ietf-system:system/authentication/user[name='bob']" 1235 CBOR encoding: 1237 78 33 1238 2f696574662d73797374656d3a73797374656d2f61757468656e74696361 1239 74696f6e2f757365725b6e616d653d27626f62275d 1241 6. Security Considerations 1243 The security considerations of [RFC7049] and [RFC7950] apply. 1245 This document defines an alternative encoding for data modeled in the 1246 YANG data modeling language. As such, this encoding does not 1247 contribute any new security issues in addition of those identified 1248 for the specific protocol or context for which it is used. 1250 To minimize security risks, software on the receiving side SHOULD 1251 reject all messages that do not comply to the rules of this document 1252 and reply with an appropriate error message to the sender. 1254 7. IANA Considerations 1256 7.1. Tags Registry 1258 This specification requires the assignment of CBOR tags for the 1259 following YANG datatypes. These tags are added to the Tags Registry 1260 as defined in section 7.2 of [RFC7049]. 1262 +-----+---------------------+---------------------------+-----------+ 1263 | Tag | Data Item | Semantics | Reference | 1264 +-----+---------------------+---------------------------+-----------+ 1265 | 40 | bits | YANG bits datatype | RFC XXXX | 1266 | 41 | enumeration | YANG enumeration datatype | RFC XXXX | 1267 | 42 | identityref | YANG identityref datatype | RFC XXXX | 1268 | 43 | instance-identifier | YANG instance-identifier | RFC XXXX | 1269 | | | datatype | | 1270 +-----+---------------------+---------------------------+-----------+ 1272 // RFC Ed.: update Tag values using allocated tags if needed and 1273 remove this note // RFC Ed.: replace XXXX with RFC number and remove 1274 this note 1276 8. Acknowledgments 1278 This document has been largely inspired by the extensive works done 1279 by Andy Bierman and Peter van der Stok on [I-D.ietf-core-comi]. 1280 [RFC7951] has also been a critical input to this work. The authors 1281 would like to thank the authors and contributors to these two drafts. 1283 The authors would also like to acknowledge the review, feedback, and 1284 comments from Ladislav Lhotka and Juergen Schoenwaelder. 1286 9. References 1288 9.1. Normative References 1290 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1291 Requirement Levels", BCP 14, RFC 2119, 1292 DOI 10.17487/RFC2119, March 1997, 1293 . 1295 [RFC6241] Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed., 1296 and A. Bierman, Ed., "Network Configuration Protocol 1297 (NETCONF)", RFC 6241, DOI 10.17487/RFC6241, June 2011, 1298 . 1300 [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object 1301 Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, 1302 October 2013, . 1304 [RFC7950] Bjorklund, M., Ed., "The YANG 1.1 Data Modeling Language", 1305 RFC 7950, DOI 10.17487/RFC7950, August 2016, 1306 . 1308 9.2. Informative References 1310 [I-D.ietf-core-comi] 1311 Veillette, M., Stok, P., Pelov, A., and A. Bierman, "CoAP 1312 Management Interface", draft-ietf-core-comi-01 (work in 1313 progress), July 2017. 1315 [I-D.ietf-core-sid] 1316 Veillette, M., Pelov, A., Turner, R., Minaburo, A., and A. 1317 Somaraju, "YANG Schema Item iDentifier (SID)", draft-ietf- 1318 core-sid-01 (work in progress), May 2017. 1320 [RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data 1321 Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March 1322 2014, . 1324 [RFC7223] Bjorklund, M., "A YANG Data Model for Interface 1325 Management", RFC 7223, DOI 10.17487/RFC7223, May 2014, 1326 . 1328 [RFC7228] Bormann, C., Ersue, M., and A. Keranen, "Terminology for 1329 Constrained-Node Networks", RFC 7228, 1330 DOI 10.17487/RFC7228, May 2014, 1331 . 1333 [RFC7277] Bjorklund, M., "A YANG Data Model for IP Management", 1334 RFC 7277, DOI 10.17487/RFC7277, June 2014, 1335 . 1337 [RFC7317] Bierman, A. and M. Bjorklund, "A YANG Data Model for 1338 System Management", RFC 7317, DOI 10.17487/RFC7317, August 1339 2014, . 1341 [RFC7951] Lhotka, L., "JSON Encoding of Data Modeled with YANG", 1342 RFC 7951, DOI 10.17487/RFC7951, August 2016, 1343 . 1345 [RFC8040] Bierman, A., Bjorklund, M., and K. Watsen, "RESTCONF 1346 Protocol", RFC 8040, DOI 10.17487/RFC8040, January 2017, 1347 . 1349 Authors' Addresses 1351 Michel Veillette (editor) 1352 Trilliant Networks Inc. 1353 610 Rue du Luxembourg 1354 Granby, Quebec J2J 2V2 1355 Canada 1357 Phone: +14503750556 1358 Email: michel.veillette@trilliantinc.com 1360 Alexander Pelov (editor) 1361 Acklio 1362 2bis rue de la Chataigneraie 1363 Cesson-Sevigne, Bretagne 35510 1364 France 1366 Email: a@ackl.io 1368 Abhinav Somaraju 1369 Tridonic GmbH & Co KG 1370 Farbergasse 15 1371 Dornbirn, Vorarlberg 6850 1372 Austria 1374 Phone: +43664808926169 1375 Email: abhinav.somaraju@tridonic.com 1376 Randy Turner 1377 Landis+Gyr 1378 30000 Mill Creek Ave 1379 Suite 100 1380 Alpharetta, GA 30022 1381 US 1383 Phone: ++16782581292 1384 Email: randy.turner@landisgyr.com 1385 URI: http://www.landisgyr.com/ 1387 Ana Minaburo 1388 Acklio 1389 2bis rue de la chataigneraie 1390 Cesson-Sevigne, Bretagne 35510 1391 France 1393 Email: ana@ackl.io