Subject: [netmod] review of yang-types

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 21 Jan 2010 18:16:13 +0100

Hi,

I reviewed the document, especially concentrating on the regular
expressions. My comments:

1. In several cases, the expressions use superfluous parentheses which
make the expressions longer and less comprehensible. I think they should
be removed. For example:
OLD
   typedef object-identifier {
     type string {
       pattern '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))'
             + '(\.(0|([1-9]\d*)))*';
     }
NEW
   typedef object-identifier { 
type string {
       pattern '([01]\.[1-3]?[0-9]|2\.(0|[1-9]\d*))(\.(0|[1-9]\d*))*';
     }

2. In the pattern for object-identifier-128, the dot should be escaped:
OLD
   typedef object-identifier-128 {
     type object-identifier {
       pattern '\d*(.\d*){1,127}';
     }
NEW
   typedef object-identifier-128 {
     type object-identifier {
       pattern '\d*(\.\d*){1,127}';
     }

3. Another minor simplification (the sign for timezone):
OLD
   typedef date-and-time {
     type string {
       pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?'
             + '(Z|(\+|-)\d{2}:\d{2})';
     }
ŃEW
   typedef date-and-time { 
type string {
       pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?'
             + '(Z|[\-+]\d{2}:\d{2})';
     }

(This pattern is rather lax, but I guess it is intentional.)

4. phys-address - is it correct that it is allowed to be empty?

5. The pattern for ipv4-address doesn't allow leading zeros in any of
the four octets, for example, this doesn't match: 127.000.000.001.
Moreover, the pattern is unnecessarily complicated. I propose to use the
same pattern as is used later for ipv4-prefix:
OLD
   typedef ipv4-address {
     type string {
       pattern '((0'
             +   '|(1[0-9]{0,2})'
             +   '|(2(([0-4][0-9]?)|(5[0-5]?)|([6-9]?)))'
             +   '|([3-9][0-9]?)'
             +  ')'
             + '\.){3}'
             + '(0'
             +  '|(1[0-9]{0,2})'
             +  '|(2(([0-4][0-9]?)|(5[0-5]?)|([6-9]?)))'
             +  '|([3-9][0-9]?)'
             + ')(%[\p{N}\p{L}]+)?';
     }
NEW
   typedef ipv4-address { 
type string {
       pattern '((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
            + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])'
	    + '(%[\p{N}\p{L}]+)?';
     }

6. An isolated dot "." matches the pattern for domain-name. I understand
it is used e.g. in DNS zone files, but IMO it is the same case as the
zero value for port-number and should be handled via a union where
appropriate.

7. In the descriptions of gauge32 and gauge64:
   s/can not/cannot/

Lada

-- 
Ladislav Lhotka, CESNET
PGP Key ID: E74E8C0C