Re: [Cbor] CBOR-YANG representation of common types

Maria Matejka <maria.matejka@nic.cz> Tue, 14 November 2023 18:47 UTC

Return-Path: <maria.matejka@nic.cz>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 344BCC15C2A8 for <cbor@ietfa.amsl.com>; Tue, 14 Nov 2023 10:47:31 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.105
X-Spam-Level:
X-Spam-Status: No, score=-2.105 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=nic.cz
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id J1bQsFaewPvY for <cbor@ietfa.amsl.com>; Tue, 14 Nov 2023 10:47:27 -0800 (PST)
Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 8FB49C15C29E for <cbor@ietf.org>; Tue, 14 Nov 2023 10:47:24 -0800 (PST)
Received: from [IPV6:2001:1488:fffe:6:ffff:ffff:fffe:4] (unknown [IPv6:2001:1488:fffe:6:ffff:ffff:fffe:4]) by mail.nic.cz (Postfix) with ESMTPSA id B1C161C17F9; Tue, 14 Nov 2023 19:47:20 +0100 (CET)
Authentication-Results: mail.nic.cz; auth=pass smtp.auth=maria.matejka@nic.cz smtp.mailfrom=maria.matejka@nic.cz
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1699987641; bh=12m72EldUdTSq62yZy+7Tr7DCfrzX9ToSkT7MIMx7zk=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From:Reply-To: Subject:To:Cc; b=OlsPq8K1apggIJ2eJ2rxnKkIlloWTxloqut389lcjjAH9bgOTFC1N5zt5WbfJjUGR ZuDhUiKj9ZlMyuLp7h3qadqiOpXBfIzxsynrUV6wuuszxEnwJRbWmXY8WyvFdePiRh rk2jJaL9fU7ih5uNV2vbqNEd5wyEJjKwjkQicTm4=
Content-Type: multipart/alternative; boundary="------------aDg17sfyzN8HBDE7qj1B0u0i"
Message-ID: <ce42506f-49b8-4b5f-a92d-cf3142a29095@nic.cz>
Date: Tue, 14 Nov 2023 19:47:19 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Content-Language: en-US, cs
To: Carsten Bormann <cabo@tzi.org>
Cc: cbor@ietf.org, Kateřina Kubecová <katerina.kubecova@nic.cz>, vojtech.vilimek@nic.cz, Laurent Toutain <laurent.toutain@imt-atlantique.fr>
References: <77159997-0cc1-4b5d-9a1d-cc61f3d0be73@nic.cz> <D2E0DEDC-F078-4430-B54B-29BAFBAEDAD1@tzi.org>
From: Maria Matejka <maria.matejka@nic.cz>
In-Reply-To: <D2E0DEDC-F078-4430-B54B-29BAFBAEDAD1@tzi.org>
X-Virus-Scanned: clamav-milter 0.103.7 at mail
X-Virus-Status: Clean
X-Rspamd-Server: mail
X-Rspamd-Pre-Result: action=no action; module=multimap; Matched map: WHITELISTED_IP
X-Rspamd-Queue-Id: B1C161C17F9
X-Spamd-Bar: /
X-Spamd-Result: default: False [-0.10 / 20.00]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; ARC_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; FUZZY_BLOCKED(0.00)[rspamd.com]; WHITELISTED_IP(0.00)[2001:1488:fffe:6:ffff:ffff:fffe:4]; FROM_HAS_DN(0.00)[]; ASN(0.00)[asn:25192, ipnet:2001:1488::/32, country:CZ]
X-Rspamd-Action: no action
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/n3rzveXKkOul0jzt-C7ADDghggI>
Subject: Re: [Cbor] CBOR-YANG representation of common types
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 14 Nov 2023 18:47:31 -0000

Hello Carsten!

On 2023-11-14 19:02, Carsten Bormann wrote:
> Hi Maria,
>
> On 2023-11-14, at 17:54, Maria Matejka<maria.matejka=40nic.cz@dmarc.ietf.org>  wrote:
>> Dear CBOR WG,
>>
>> we're currently trying to embrace the CBOR described by YANG in BIRD interface and we're struggling with the representation of certain types like date, time, IP address or prefix. We would assume that if there is RFC 9164 or RFC 8943, we shall then encode dates or IP addresses in these defined formats in CBOR and they shall get converted between CBOR and JSON/XML appropriately. But I can't find any RFC on this, nor any implementation of CBOR-JSON convertor.
> These types are all defined as text string types in RFC 6991 etc. (and RFC 6991bis does not change anything about this).
> RFC 9254 defines a basic representation of YANG in CBOR, not trying to change this.
That's why I'm asking. It just doesn't seem to be coherent altogether, 
just per partes.
>> Thus, these questions arise:
>>
>> 	• Is there any discussion on this topic, regarding interoperability between CBOR and JSON/XML?
> This is a timely question.
> There definitely is discussion, as the representation of these types as a CBOR text string is inefficient (with respect to both space and CPU time).
>
>> 	• Is there any RFC on draft on this? If not, we're probably gonna create one. We need it
> Writing up a proposal is on my to do list.
> Right now I’m looking at:
>
>       typedef object-identifier {
>         type string {
>       typedef object-identifier-128 {
>         type object-identifier {
>           pattern '\d*(\.\d*){1,127}';
>       typedef date-and-time {
>         type string {
>       typedef phys-address {
>         type string {
>       typedef mac-address {
>         type string {
>       typedef hex-string {
>         type string {
>       typedef uuid {
>         type string {
>       typedef dotted-quad {
>         type string {
>       typedef ip-address {
>         type union {
>           type inet:ipv4-address;
>           type inet:ipv6-address;
>       typedef ipv4-address {
>         type string {
>       typedef ipv6-address {
>         type string {
>       typedef ip-address-no-zone {
>         type union {
>           type inet:ipv4-address-no-zone;
>           type inet:ipv6-address-no-zone;
>       typedef ipv4-address-no-zone {
>         type inet:ipv4-address {
>       typedef ipv6-address-no-zone {
>         type inet:ipv6-address {
>       typedef ip-prefix {
>         type union {
>           type inet:ipv4-prefix;
>           type inet:ipv6-prefix;
>         }
>       typedef ipv4-prefix {
>         type string {
>       typedef ipv6-prefix {
>         type string {
>
> This can use tags from RFC 8949, RFC 9164, RFC 9090; we probably need to discuss little details such as whether tag 23 can be used for hex-string.

These are the most needed, surely, at least for us. Anyway, other RFC's 
and drafts tend to define additional types as strings (yes, I'm looking 
at you, BGP YANG draft) so what I'd like to see, is not only explicit 
definition of these, but maybe also a future requirement or at least 
some extension of YANG itself, to allow for defining some type both as a 
string in JSON and XML, and as a specific format in CBOR, e.g. like this:

typedef ipv6-address-no-zone {
   type string { … };
   compact type {
     tag 54;
     blob;
   };
}

typedef ipv6-prefix {
   type string { … };
   compact type {
     tag 54;
     uint length;
     blob prefix;
   };
}

but it inevitably leads to weird problems where the CBOR representation 
is more structured and in fact is a grouping. I'm not sure yet how to 
handle this but I still refuse to believe that we're all screwed into 
the string representation, this way the other way around compared to the 
****** with SNMP MIBs.

In any case, if you happen to start writing this, please keep us 
informed. If we happen to go on this first, we'll tell you as well. 
Having this as a critical priority for us, it's even possible that you 
have the first draft here tomorrow. (Exaggerating, but not much.) What 
is the right platform to collaborate on?

>> 	• Is there any implementation of YANG-ed converter between CBOR and JSON? If not, we're probably gonna create one. We need it.
> Laurent Toutain has a tool that extracts from a YANG module the parameter information needed for such a YANG-CBOR ⬌ YANG-JSON converter today.
> This tool uses base types, so it cannot quite address the above list.
> But the idea should be transferable.

OK. Can't find that so we're probably going to make our own tool for the 
conversion or whatever. We need it anyway and it probably has to be 
really fast.

Have a nice day! Maria

-- 
Maria Matejka (she/her) | BIRD Team Leader | CZ.NIC, z.s.p.o.