Constrained RESTful Environments T. Fossati Internet-Draft arm Intended status: Standards Track H. Birkholz Expires: 20 April 2023 Fraunhofer SIT 17 October 2022 Parametrized Content-Format for CoAP draft-fossati-core-parametrized-cf-01 Abstract This document specifies a "parametrized" CoAP Content-Format data item that allows supplementing a Content-Format with additional media type parameters. This document also defines two new CoAP Options, Parmetrized-Content- Format and Parametrized-Multi-Valued-Accept, that build upon the "parametrized" Content-Format data item to work around some of the limitations of the existing Accept and Content-Format Options. About This Document This note is to be removed before publishing as an RFC. The latest revision of this draft can be found at https://thomas- fossati.github.io/draft-coap-parametrized-cf/draft-fossati-core- parametrized-cf.html. Status information for this document may be found at https://datatracker.ietf.org/doc/draft-fossati-core- parametrized-cf/. Discussion of this document takes place on the Constrained RESTful Environments Working Group mailing list (mailto:core@ietf.org), which is archived at https://mailarchive.ietf.org/arch/browse/core/. Subscribe at https://www.ietf.org/mailman/listinfo/core/. Source for this draft and an issue tracker can be found at https://github.com/thomas-fossati/draft-coap-parametrized-cf. Status of This Memo This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet- Drafts is at https://datatracker.ietf.org/drafts/current/. Fossati & Birkholz Expires 20 April 2023 [Page 1] Internet-Draft Parametrized Content-Format for CoAP October 2022 Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." This Internet-Draft will expire on 20 April 2023. 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://trustee.ietf.org/ license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License. Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 2. Conventions and Definitions . . . . . . . . . . . . . . . . . 3 3. Parametrized Content-Format . . . . . . . . . . . . . . . . . 3 3.1. Requirements . . . . . . . . . . . . . . . . . . . . . . 4 3.2. Examples . . . . . . . . . . . . . . . . . . . . . . . . 5 4. Parametrized Content-Format Option . . . . . . . . . . . . . 5 5. Parametrized Multi-Valued Accept Option . . . . . . . . . . . 5 6. Security Considerations . . . . . . . . . . . . . . . . . . . 6 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 6 7.1. CoAP Option Numbers Registry . . . . . . . . . . . . . . 6 8. References . . . . . . . . . . . . . . . . . . . . . . . . . 7 8.1. Normative References . . . . . . . . . . . . . . . . . . 7 8.2. Informative References . . . . . . . . . . . . . . . . . 8 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 8 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 8 1. Introduction CoAP squashes the combination of a media type, media type parameters and content coding into a single Content-Format number. (For an example, see Table 2 in Section 2 of [STD96].) This number is carried in the Content-Format and Accept Options. Fossati & Birkholz Expires 20 April 2023 [Page 2] Internet-Draft Parametrized Content-Format for CoAP October 2022 Such compression strategy is ideal in cases where the set of possible parameters combinations is known upfront and has small cardinality. However, it lacks the flexibility to deal smoothly with situations where the number of combinations can grow unbounded. An example is [I-D.lundblade-rats-eat-media-type], in which the "profile" media type parameter can carry a number of different values that are constantly minted through a loosely regulated process. Another example is content negotiation of CoRAL [I-D.ietf-core-coral] profiles. To avoid the combinatorial explosion that derives from such premises, this document defines the "parametrized" Content-Format data item (Section 3) as a mechanism to enrich a given Content-Format with additional media type parameters. Two new CoAP Options that build upon such data item are also defined: * Parametrized-Content-Format (Section 4) * Parametrized-Multi-Valued-Accept (Section 5) The latter also works around the limited content negotiation capabilities of the CoAP Accept Option by allowing to accept more than one Content-Format per request. 2. Conventions and Definitions 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. In this document, the structure of data is specified in CDDL [RFC8610] [RFC9165]. The examples in Section 3.2 use CBOR diagnostic notation defined in Section 8 of [STD94] and Appendix G of [RFC8610]. 3. Parametrized Content-Format The Parametrized Content-Format is a CBOR [STD94] data item defined by the CDDL [RFC8610] in Figure 1. The first element in the tuple is the Content-Format identifier, followed by one or more name-value pairs representing the additional media type parameters. Fossati & Birkholz Expires 20 April 2023 [Page 3] Internet-Draft Parametrized Content-Format for CoAP October 2022 parametrized-content-format = [ content-format, + [ parameter-name, parameter-value ] ] content-format = 0..65535 parameter-name = textual / numeric parameter-value = any textual = text .abnf ("parameter-name" .det RFC6838-parameter-name) numeric = int RFC6838-parameter-name = ' parameter-name = restricted-name restricted-name = restricted-name-first *126restricted-name-chars restricted-name-first = ALPHA / DIGIT restricted-name-chars = ALPHA / DIGIT / "!" / "#" / "$" / "&" / "-" / "^" / "_" restricted-name-chars =/ "." ; Characters before first dot always ; specify a facet name restricted-name-chars =/ "+" ; Characters after last plus always ; specify a structured syntax suffix ALPHA = %x41-5A / %x61-7A ; A-Z / a-z DIGIT = %x30-39 ; 0-9 ' Figure 1: CDDL for the Parametrized Content-Format // TODO describe use of numeric identifiers for parameter name // aliasing (requires a new registry). 3.1. Requirements The list that follows details the semantic requirements that a Parametrized Content-Format data item must satisfy: * The intersection between the media parameters already encoded in the Content-Format identifier and the set of parameters carried in the name-value pairs of the Parametrized Content-Format MUST be empty. * Each name-value pair MUST be a registered parameter for the media type. Fossati & Birkholz Expires 20 April 2023 [Page 4] Internet-Draft Parametrized Content-Format for CoAP October 2022 If any of the conditions listed above is not met, the entire data item is considered invalid and MUST NOT be processed further. 3.2. Examples [ 65000, [ "p1", "a-string-value" ], [ "p2", 128 ] ] Figure 2: Content-Format with two paramters 4. Parametrized Content-Format Option +========+=+===+===+===+================+========+========+=========+ | Number |C| U | N | R | Name |Format | Length | Default | +========+=+===+===+===+================+========+========+=========+ | TBD24 | | | | | Parametrized |See | | none | | | | | | | Content-Format |Figure 3| | | | | | | | | Option | | | | +--------+-+---+---+---+----------------+--------+--------+---------+ Table 1: Parametrized Content-Format Option The Parametrized Content-Format Option carries a CBOR-encoded Parametrized Content-Format data item. pcf-option-fmt = bytes .cbor parametrized-content-format Figure 3: Parametrized Content-Format Option Format The semantic is identical to the Content-Format Option described in Section 5.10.3 of [RFC7252]. 5. Parametrized Multi-Valued Accept Option +========+===+===+===+===+==============+========+========+=========+ | Number | C | U | N | R |Name |Format | Length | Default | +========+===+===+===+===+==============+========+========+=========+ | TBD13 | x | | | |Parametrized |See | | none | | | | | | |Multi-Valued |Figure 4| | | | | | | | |Accept Option | | | | +--------+---+---+---+---+--------------+--------+--------+---------+ Table 2: Parametrized Multi-Valued Accept Option Fossati & Birkholz Expires 20 April 2023 [Page 5] Internet-Draft Parametrized Content-Format for CoAP October 2022 The Parametrized Multi-Valued Accept Option carries either a single CBOR-encoded pa-content-format data item or two or more pa-content- format items wrapped in a CBOR array. In turn, each pa-content- format can be either a plain Content-Format or a Parametrized Content-Format as described in Figure 4. pa-content-format = content-format / parametrized-content-format one-or-more = T / [ 2* T ] pmva-option-fmt = bytes .cbor one-or-more Figure 4: Parametrized Multi-Valued Accept Option Format The semantic is identical to the Accept Option described in Section 5.10.4 of [RFC7252], except for the ability to list more than one acceptable (parametrized) Content-Format, which is key to enable finer-grained content negotiation. The Content-Formats are listed in order of preference. If more than one match is found, the entry with the lowest index in the array MUST be selected. 6. Security Considerations The security considerations in Section 11.1 of [RFC7252] related to the parsing of protocol elements apply. The security considerations in Section 11.3 of [RFC7252] related to amplification risks apply. TODO expand 7. IANA Considerations // RFC Editor: please replace RFCthis with this RFC number and remove // this note. 7.1. CoAP Option Numbers Registry IANA is requested to add the entries from Table 3 to the CoAP Option Numbers sub-registry of the Constrained RESTful Environments (CoRE) Parameters [IANA.core-parameters] registry: Fossati & Birkholz Expires 20 April 2023 [Page 6] Internet-Draft Parametrized Content-Format for CoAP October 2022 +========+=========================================+============+ | Number | Name | Reference | +========+=========================================+============+ | TBD13 | Parametrized Multi-Valued Accept Option | Section 5 | | | | of RFCthis | +--------+-----------------------------------------+------------+ | TBD24 | Parametrized Content-Format Option | Section 4 | | | | of RFCthis | +--------+-----------------------------------------+------------+ Table 3: New Options This document suggests 13 (TBD13) and 24 (TBD24) as values to be assigned for the new option numbers. 8. References 8.1. Normative References [IANA.core-parameters] IANA, "Constrained RESTful Environments (CoRE) Parameters", 8 June 2012, . [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, . [RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained Application Protocol (CoAP)", RFC 7252, DOI 10.17487/RFC7252, June 2014, . [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017, . [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/RFC8610, June 2019, . [RFC9165] Bormann, C., "Additional Control Operators for the Concise Data Definition Language (CDDL)", RFC 9165, DOI 10.17487/RFC9165, December 2021, . Fossati & Birkholz Expires 20 April 2023 [Page 7] Internet-Draft Parametrized Content-Format for CoAP October 2022 [STD94] Bormann, C. and P. Hoffman, "Concise Binary Object Representation (CBOR)", STD 94, RFC 8949, DOI 10.17487/RFC8949, December 2020, . 8.2. Informative References [I-D.ietf-core-coral] Amsüss, C. and T. Fossati, "The Constrained RESTful Application Language (CoRAL)", Work in Progress, Internet- Draft, draft-ietf-core-coral-05, 7 March 2022, . [I-D.lundblade-rats-eat-media-type] Lundblade, L., Birkholz, H., and T. Fossati, "EAT Media Types", Work in Progress, Internet-Draft, draft-lundblade- rats-eat-media-type-00, 26 May 2022, . [STD96] Schaad, J., "CBOR Object Signing and Encryption (COSE): Structures and Process", STD 96, RFC 9052, DOI 10.17487/RFC9052, August 2022, . Acknowledgments Thank you Carsten Bormann, Christian Amsüss, and Marco Tiloca for the useful comments and suggestions. Authors' Addresses Thomas Fossati arm Email: thomas.fossati@arm.com Henk Birkholz Fraunhofer SIT Email: henk.birkholz@sit.fraunhofer.de Fossati & Birkholz Expires 20 April 2023 [Page 8]