Subject: [netmod] enumerate / bits restrictions

From: Juergen Schoenwaelder <[email-masked]>
Date: Wed, 18 Feb 2009 14:58:46 +0100

The YANG language does not support the restricting of enumeration and
bits types. The following example is therefore not legal YANG:

  typedef color {
      type enumeration {
          enum black { value 0x000000; }
          enum red   { value 0xff0000; }
          enum green { value 0x00ff00; }
          enum blue  { value 0x0000ff; }
          enum white { value 0xffffff; }
      }
  }

  typedef monochrome {
      type color { enum white; enum black; }
  }

  leaf status {
      type color {
          enum red; enum green;
      }
  }

Note that the SMIv2 does allow the restriction of named numbers when
you write object definitions or in conformance statements and this is
being used in MIB modules.

The proposal is to support this kind of subtying in YANG. This
requires to replace the text in section 9.6.4 with something like
this:

  An enumeration type can be restricted to a subset of the enumerated
  values by using the "enum" statement (Section XYZ). Note that
  restrictions can not add new enums to a type nor can they change the
  value associated with an enum.

And similarly for the section 9.7.4, add the following:

  The named bits can be restricted using the "bit" statement (Section
  XYZ). Note that restrictions can not add new bits to a type nor can
  they change the position associated with an enum.

/js

-- 
Juergen Schoenwaelder           Jacobs University Bremen gGmbH
Phone: +49 421 200 3587         Campus Ring 1, 28759 Bremen, Germany
Fax:   +49 421 200 3103         <http://www.jacobs-university.de/>