Re: [netmod] [core] CBOR YANG encoding of union & bits [draft-ietf-core-yang-cbor-12]

Andy Bierman <andy@yumaworks.com> Fri, 08 May 2020 17:56 UTC

Return-Path: <andy@yumaworks.com>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id DF5F33A0E8E for <netmod@ietfa.amsl.com>; Fri, 8 May 2020 10:56:37 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.887
X-Spam-Level:
X-Spam-Status: No, score=-1.887 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, SPF_HELO_NONE=0.001, T_SPF_PERMERROR=0.01, URIBL_BLOCKED=0.001] autolearn=unavailable autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=yumaworks-com.20150623.gappssmtp.com
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 BKpWpzpWJArz for <netmod@ietfa.amsl.com>; Fri, 8 May 2020 10:56:34 -0700 (PDT)
Received: from mail-yb1-xb32.google.com (mail-yb1-xb32.google.com [IPv6:2607:f8b0:4864:20::b32]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 96DD93A0E8C for <netmod@ietf.org>; Fri, 8 May 2020 10:56:34 -0700 (PDT)
Received: by mail-yb1-xb32.google.com with SMTP id f5so1363961ybo.4 for <netmod@ietf.org>; Fri, 08 May 2020 10:56:34 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yumaworks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EQcA9Mn4lpEA96JwwtWqPgf/r9Ggb3M4mHHa9oo7GSg=; b=cCNnCg9S1FunBEKSt3NZBXbWtOfhL7YWADdyy5IX6L5mfV2Sy9Qm/feQNZcrmuChmH L16cNU4JWEu9XfF6zLqrOtG4hWiaB6izrCPF8t4AAHNOE7nbfaytj+WbHCbWvF4JhzGl O2a4puMgVV33Nu8UZ2MPhVPfBJS22kFDco2qtRvQ7CzlQ3cggvjbTa9SJ5BddPaQ+Adp RxkyvG2eLRtbGnpw3/Tpk/UkDUKsSYnlT9lH9OFeE4heI3wCbAKV3OUddYMNUMicy0Om ID+vQgFeXDI7rn0hE2jeWnlCKsc0L8o85GSAyn3t3EQqw7nnzFgaOgjNINwW/Vx2PRPw g6cA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EQcA9Mn4lpEA96JwwtWqPgf/r9Ggb3M4mHHa9oo7GSg=; b=gA62ycmbXvpNA1LEX/1uuEy1DKFZr7KdlsDdb+YcOOto6+HhKkG00bhlJkghNvAdDR BMPNyTkzxupg99836To6djhY4dW9fkDuLhLSvHcTxbAd/Za+2XNQ6T/dAuambnVvCTCc Hcaq4GcQyCHfGJagTcWf7BTxHcTFSU6fRXF9uLN3NhRdT5vzzjoEosjFny8Xi/nQWoxk 21Lye1swUuUVdXBZly7n4wyrpCUL+Y5OHJFdzHQfy1ycKj8MeWW5ZHRcYTlFMyNnWmEv dgrUfXVIRv52QcSmzIyCMuia8DX8VGA+ka+KA5AO6pFPVQv0YNP6qbMCT5tJKbm+UjN9 GNXw==
X-Gm-Message-State: AGi0PubBA73Zn3fKlHElMOJUHJR+oI6jUiiyVQLbXw6fGOjzzNu35cqh oRAruTEprcQiCz43OSwK17VWemJ86YdgdEJ8eF6jvg==
X-Google-Smtp-Source: APiQypL8d/Hf3O+vw92qp4rteT+mMrAQVLfMoxdN6JL4rr+7rH9tCUd3WlQ/67yuti1dA/kaqUaopOk8E2iOvw3lS6U=
X-Received: by 2002:a5b:784:: with SMTP id b4mr6402701ybq.134.1588960593483; Fri, 08 May 2020 10:56:33 -0700 (PDT)
MIME-Version: 1.0
References: <BY5PR11MB4355C26250C9CF46713C9956B5A40@BY5PR11MB4355.namprd11.prod.outlook.com> <D66596CE-7F5C-4562-89A4-48FCE96D0E18@tzi.org> <28486.1588785684@localhost> <CABCOCHRRDYDomEPctAHaHf+MxS2qXab1J4o=_LUEWcJ2=by5Ww@mail.gmail.com> <8F06BFE6-CE7C-4D10-AC61-24AAA2807E45@tzi.org> <CABCOCHRUCK_FpwSCnOOy8fBCX_HeAWQeFvJEyZy2hUL4L2WhrQ@mail.gmail.com> <CABCOCHQOWoPozsYOfVEDy_TYw-YF5H9TZ2eydcOpj-g2d3ysNQ@mail.gmail.com> <000701d62560$d681d790$838586b0$@augustcellars.com>
In-Reply-To: <000701d62560$d681d790$838586b0$@augustcellars.com>
From: Andy Bierman <andy@yumaworks.com>
Date: Fri, 08 May 2020 10:56:22 -0700
Message-ID: <CABCOCHQeFu=gEMCbbRp4H7op_UVi_rgOzzRrAt7QjdS6jB1g2w@mail.gmail.com>
To: Jim Schaad <ietf@augustcellars.com>
Cc: Carsten Bormann <cabo@tzi.org>, Core <core@ietf.org>, NetMod WG <netmod@ietf.org>
Content-Type: multipart/alternative; boundary="000000000000bcb72105a526b733"
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/kFqd0OZyMM828pH6dsS6DaMhi84>
Subject: Re: [netmod] [core] CBOR YANG encoding of union & bits [draft-ietf-core-yang-cbor-12]
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 08 May 2020 17:56:38 -0000

On Fri, May 8, 2020 at 10:48 AM Jim Schaad <ietf@augustcellars.com> wrote:

> Does yang consider that there is a difference between a bit being present
> and zero and a bit being absent?
>
>
>


  leaf bits-leaf {
      type bits {
         bit zero { position 0; }
         bit one { position 1; }
         bit two { position 2; }
         bit 4million { position 4000000; }
     }
  }

I think I see your point.
The value "" is valid for this leaf indicating no bits are set.
In order to send this value:
   { 0, 1, 0x0 }

Any YANG bit that is present is represented by a bit with the value 1 in
the corresponding position and octet.


Andy


*From:* core <core-bounces@ietf.org> *On Behalf Of *Andy Bierman
> *Sent:* Friday, May 8, 2020 8:58 AM
> *To:* Carsten Bormann <cabo@tzi.org>
> *Cc:* core@ietf.org; netmod@ietf.org
> *Subject:* Re: [core] [netmod] CBOR YANG encoding of union & bits
> [draft-ietf-core-yang-cbor-12]
>
>
>
>
>
>
>
> On Fri, May 8, 2020 at 8:51 AM Andy Bierman <andy@yumaworks.com> wrote:
>
>
>
>
>
> On Thu, May 7, 2020 at 11:22 PM Carsten Bormann <cabo@tzi.org> wrote:
>
> On 2020-05-08, at 05:27, Andy Bierman <andy@yumaworks.com> wrote:
> >
> > Why is the bit position allowed to be a uint32 in YANG? Who knows, but
> it has to be supported.
>
> If we think that is the way to go, I like Kio’s proposal over in the CBOR
> list:
> <https://mailarchive.ietf.org/arch/msg/cbor/3sZ4YfWLzmVVnNnQbttkovgjTP8>
>
>
>
>
>
> Yes -- this encoding should work well
>
>
>
> We probably should arm that with some text that says (in nicer words) that
> this is an emergency representation and implementations should not invoke
> it for sane YANG models (with an operable definition of sane).
>
>
>
>
>
> Not sure what this means.
>
> Wouldn't this map approach be used all the time for a bits type?
>
> The "normal" case would be a small number of octets representing all the
> bits present
>
>  (e..g 0x7 for 3 bits : bit 0 to bit 2)
>
> This would simply be 1 map entry with {offset=0,length=1,value=0x7}
>
>
>
> The actual bitmap is conceptually constructed by starting with an array of
> zero bytes.
>
> Overlapping offsets are allowed. Duplicate offsets are allowed.
>
> There is no requirement to list offsets in ascending order.
>
> There is no canonical representation.
>
>
>
> Each map entry is added to the array using a "bit or" operator.
>
> After all map entries are processed the full bits value is known.
>
> This allows an implementation to encode bits serially (often done this way
> with YANG bit names)
>
>
>
> So the same bitset 0x7 could be sent different ways including:
>
>
>
>   { 0, 1, 0x1 }
>
>   { 0, 1, 0x2 }
>
>   { 0, 1, 0x4 }
>
>
>
> If the position is really bit 4 million (bit 1 in byte 500,000)
>
>
>
>   { 0, 500000, 0x1 }
>
>
>
>
>
> oops: correction:  (bit 0 in byte 500000)
>
>
>
>   { 500000, 1, 0x1 }
>
>
>
>
>
> Grüße, Carsten
>
>
>
>
>
> Andy
>
>
>
>