Parametrized Content-Format for CoAP
Internet-Draft draft-fossati-core-parametrized-cf-00
Thomas Fossati
arm
thomas.fossati@arm.com
Henk Birkholz
Fraunhofer SIT
henk.birkholz@sit.fraunhofer.de
10 June 2022
Applications and Real-Time
Constrained RESTful Environments
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
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/.
Source for this draft and an issue tracker can be found at https://github.com/thomas-fossati/draft-coap-parametrized-cf.
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 Section 16.10 of [RFC8152].) This number is carried in the Content-Format and Accept Options.
This compression strategy is ideal in cases where the set of possible 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.
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.
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.
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 zero or more name-value pairs representing the additional media type parameters.
The name-value pairs are optional to support the case where the Parametrized Content-Format is used in Parametrized Multi-Valued Accept Option (Section 5).
CDDL for the Parametrized Content-Format

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
'

TODO describe use of numeric identifiers as alias for parameter names (requires a new registry).
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.
If any of the conditions listed above is not met, the entire data item is considered invalid and MUST NOT be processed further.
Examples
Example #1

[
  65000,
  [ "p1", "a-string-value" ],
  [ "p2", 128 ]
]

Parametrized Content-Format Option
Parametrized Content-Format Option
Number | C | U | N | R | Name | Format | Length | Default
TBD24 | | | | | Parametrized Content-Format Option | See Figure 3 | | none
The Parametrized Content-Format Option carries a CBOR-encoded Parametrized Content-Format data item.
Parametrized Content-Format Option Format

pcf-option-fmt = bytes .cbor parametrized-content-format

The semantic is identical to the Content-Format Option described in Section 5.10.3 of [RFC7252].
Parametrized Multi-Valued Accept Option
Parametrized Multi-Valued Accept Option
Number | C | U | N | R | Name | Format | Length | Default
TBD13 | x | | | | Parametrized Multi-Valued Accept Option | See Figure 4 | | none
The Parametrized Multi-Valued Accept Option carries a single CBOR-encoded Parametrized Content-Format data item or two or more Parametrized Content-Format data items as a CBOR array.
Parametrized Multi-Valued Accept Option Format

one-or-more<T> = T / [ 2* T ]

pmva-option-fmt = bytes .cbor one-or-more<parametrized-content-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.
Security Considerations
TODO Security
IANA Considerations
TODO IANA
References
Normative References
[RFC7252]

The Constrained Application Protocol (CoAP)
Z. Shelby
K. Hartke
C. Bormann
June 2014
RFC 7252
DOI 10.17487/RFC7252
[RFC8610]

Concise Data Definition Language (CDDL): A Notational Convention to Express Concise Binary Object Representation (CBOR) and JSON Data Structures
H. Birkholz
C. Vigano
C. Bormann
June 2019
RFC 8610
DOI 10.17487/RFC8610
[RFC8949]

Concise Binary Object Representation (CBOR)
C. Bormann
P. Hoffman
December 2020
STD 94
RFC 8949
DOI 10.17487/RFC8949
[RFC2119]

Key words for use in RFCs to Indicate Requirement Levels
S. Bradner
March 1997
BCP 14
RFC 2119
DOI 10.17487/RFC2119
[RFC8174]

Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words
B. Leiba
May 2017
BCP 14
RFC 8174
DOI 10.17487/RFC8174
Informative References
[RFC8152]

CBOR Object Signing and Encryption (COSE)
J. Schaad
July 2017
RFC 8152
DOI 10.17487/RFC8152
[I-D.lundblade-rats-eat-media-type]

EAT Media Types
Laurence Lundblade
Security Theory LLC
Henk Birkholz
Fraunhofer Institute for Secure Information Technology
Thomas Fossati
arm
26 May 2022
Internet-Draft draft-lundblade-rats-eat-media-type-00
Acknowledgments
TODO acknowledge.