Re: [Cbor] [dtn] BPv7 CDDL and CBOR tagging

Carsten Bormann <> Wed, 10 April 2019 08:58 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 2C95E120383; Wed, 10 Apr 2019 01:58:21 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -4.199
X-Spam-Status: No, score=-4.199 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id b32OkE8fGMlo; Wed, 10 Apr 2019 01:58:18 -0700 (PDT)
Received: from ( []) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by (Postfix) with ESMTPS id 331A71202BB; Wed, 10 Apr 2019 01:58:18 -0700 (PDT)
Received: from [] ( []) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by (Postfix) with ESMTPSA id 44fJ3C73lRzygC; Wed, 10 Apr 2019 10:58:15 +0200 (CEST)
Content-Type: text/plain; charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\))
From: Carsten Bormann <>
In-Reply-To: <>
Date: Wed, 10 Apr 2019 10:58:15 +0200
Cc: "Burleigh, Scott C (312B)" <>, "" <>,
X-Mao-Original-Outgoing-Id: 576579493.5323679-46df80c43ad0966b7ac4fb4acd68f1b1
Content-Transfer-Encoding: quoted-printable
Message-Id: <>
References: <> <> <> <> <>
To: Brian Sipos <>
X-Mailer: Apple Mail (2.3445.9.1)
Archived-At: <>
Subject: Re: [Cbor] [dtn] BPv7 CDDL and CBOR tagging
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Wed, 10 Apr 2019 08:58:23 -0000

(CBOR WG: replying on
as this is an interesting use case of specialization.)

Thanks!  This already looks pretty good (once I fix the three cases of line-wrapping).

> On Apr 10, 2019, at 04:17, Brian Sipos <>; wrote:
> The reference program can be tested as in:

For me, the tool has the problem that it can’t generate

 (block-type-specific-data .cbor ext-data-hop-count)

With the former being

block-type-specific-data = bstr / #6.24(bstr)

What you are trying to say is that the bstr in there conforms to “.cbor ext-data-hop-count”, but the tool is applying the .cbor to the choice, and its brain is too small for that.

I think some unraveling is required to properly address this.

I would probably define a generic for this (sorry for the long names):

optionally-tagged—embedded-cbor<T> = T / #6.24(T)

block-type-specific-data = optionally-tagged-embedded-cbor<bstr>

And then, e.g.:

$extension-block-structure /= [
 block-type-code: 7,
 optionally-tagged-embedded-cbor<(bstr .cbor ext-data-previous-node)>
 ? crc-value

OK, for readability maybe add

embedded-cbor-optionally-tagged<E> = optionally-tagged-embedded-cbor<bstr .cbor E>

and then 

$extension-block-structure /= [
 block-type-code: 7,
 ? crc-value

That is not wonderful, as it repeats the fact that the thing is optionally tagged “embedded CBOR” all over the individual block type definitions, but it starts enabling focus on the actual structure again.

(I’m still not entirely convinced that the tag 24 here is very useful, but I’m trying to play along the design.)

Grüße, Carsten

PS.: If I were writing this, I’d also add

extension-block-of<N, T> = [
 block-type-code: N,
 ? crc-value

And then just say

$extension-block-structure /= extension-block-of<7, ext-data-previous-node>

but how much abstraction to add is a matter of preference; this at least gets rid of the “sprinkle the structure all over the place” problem.