Re: [core] Comments on draft-ietf-core-yang-cbor-00

Ladislav Lhotka <lhotka@nic.cz> Sat, 21 May 2016 07:45 UTC

Return-Path: <lhotka@nic.cz>
X-Original-To: core@ietfa.amsl.com
Delivered-To: core@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 362B212B035 for <core@ietfa.amsl.com>; Sat, 21 May 2016 00:45:00 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.9
X-Spam-Level:
X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Wm4Bb8bZk0DS for <core@ietfa.amsl.com>; Sat, 21 May 2016 00:44:58 -0700 (PDT)
Received: from trail.lhotka.name (trail.lhotka.name [77.48.224.143]) by ietfa.amsl.com (Postfix) with ESMTP id 7B6BD12B01D for <core@ietf.org>; Sat, 21 May 2016 00:44:57 -0700 (PDT)
Received: from localhost (unknown [172.29.2.202]) by trail.lhotka.name (Postfix) with ESMTPSA id 3C1451CC030D; Sat, 21 May 2016 09:44:56 +0200 (CEST)
From: Ladislav Lhotka <lhotka@nic.cz>
To: Andy Bierman <andy@yumaworks.com>, Core <core@ietf.org>
In-Reply-To: <CABCOCHRRACvVXx2S_hZm2TxbvP48aO4Q4REkh0LFjmHkMkZ1Vg@mail.gmail.com>
References: <CABCOCHRRACvVXx2S_hZm2TxbvP48aO4Q4REkh0LFjmHkMkZ1Vg@mail.gmail.com>
User-Agent: Notmuch/0.22 (http://notmuchmail.org) Emacs/24.4.51.2 (x86_64-apple-darwin14.0.0)
Date: Sat, 21 May 2016 09:44:55 +0200
Message-ID: <m2y473svm0.fsf@nic.cz>
MIME-Version: 1.0
Content-Type: text/plain
Archived-At: <http://mailarchive.ietf.org/arch/msg/core/lbJlYnwSKO4yD8wHHt1U2lmgbN4>
Subject: Re: [core] Comments on draft-ietf-core-yang-cbor-00
X-BeenThere: core@ietf.org
X-Mailman-Version: 2.1.17
Precedence: list
List-Id: "Constrained RESTful Environments \(CoRE\) Working Group list" <core.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/core>, <mailto:core-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/core/>
List-Post: <mailto:core@ietf.org>
List-Help: <mailto:core-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/core>, <mailto:core-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sat, 21 May 2016 07:45:00 -0000

Andy Bierman <andy@yumaworks.com> writes:
>
> 5.12.  The "union" Type
>
>    Leafs of type union MUST be encoded using the rules associated with
>    one of the types listed.
>
> C10) This does not really work because so many YANG types use
> the same CBOR major encoding

The receiving side will resolve the union type by the first union member
type that matches the CBOR-encoded value. It's the same as in JSON encoding.

>
>    type union {
>       type int32;
>       type enumeration {
>         enum A { value -5; }
>         enum B { value 3; }
>       }
>       type bits {
>         bit X { position 1; }
>         bit Y { position 3; }
>       }
>       type decimal64 {
>         fraction-digits 2;
>       }
>    }
>
> How do I know if '3' is for int32, enum B or bit Y?

If it's major type 0 or 1, it will be int32 in this case because int32 is the
first applicable member type.

> How do I know 103 is really decimal64 "1.03" and not
> an int32 "103"?

If it's major type 0 or 1, then it will be again int32. However, 2147483648
would become 21474836.48 because that integer doesn't fit the int32 range.

Lada

-- 
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C