module ietf-dhcpv6-types {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-dhcpv6-types";
  prefix "dhcpv6-types";

  import ietf-inet-types {
    prefix inet;
  }
  import ietf-yang-types {
    prefix yang;
  }

  organization "DHC WG";
  contact
   "cuiyong@tsinghua.edu.cn
    lh.sunlinh@gmail.com
    ian.farrer@telekom.de
    sladjana.zechlin@telekom.de
    hezihao9512@gmail.com";

  description "This model defines a YANG data model that can be
    used to define some commonly used DHCPv6 types";

  revision 2018-09-04 {
    description "";
    reference "I-D: draft-ietf-dhc-dhcpv6-yang";
  }

  revision 2018-01-30 {
    description "Initial revision";
    reference "I-D: draft-ietf-dhc-dhcpv6-yang";
  }

  /*
  * Grouping
  */
  grouping vendor-infor {
    description "Vendor information.";
    container vendor-info {
      description "";
      leaf ent-num {
        type uint32;
        mandatory true;
        description "enterprise number";
      }
      leaf-list data {
        type string;
        description "specific vendor info";
      }
    }
  }

  grouping duid {
    description
      "Each server and client has only one DUID (DHCP Unique Identifier).
      The DUID here identifies a unique DHCPv6 server for clients. DUID
      consists of a two-octet type field and an arbitrary length (no more
      than 128 bytes) content field. Currently there are four defined types
      of DUIDs in RFC3315 and RFC6355 - DUID-LLT, DUID-EN, DUID-LL and
      DUID-UUID. DUID-Uknown represents those unconventional DUIDs.";
    reference "RFC3315: Section 9 and RFC6355: Section 4";
    leaf type-code {
      type uint16;
      default 65535;
      description "Type code of this DUID";
    }
    choice duid-type {
    default duid-unknown;
      description "Selects the format for the DUID.";
      case duid-llt {
        description "DUID Based on Link-layer Address Plus Time
          (Type 1 - DUID-LLT)";
        reference "RFC3315 Section 9.2";
        leaf duid-llt-hardware-type {
          type uint16;
          description "Hardware type as assigned by IANA (RFC826).";
        }
        leaf duid-llt-time {
          type yang:timeticks;
          description "The time value is the time that the DUID is
          generated represented in seconds since midnight (UTC),
          January 1, 2000, modulo 2^32.";
        }
        leaf duid-llt-link-layer-addr {
          type yang:mac-address;
          description "Link-layer address as described in RFC2464";
        }
      }
      case duid-en {
        description "DUID Assigned by Vendor Based on Enterprise Number
          (Type 2 - DUID-EN)";
        reference "RFC3315 Section 9.3";
        leaf duid-en-enterprise-number {
          type uint32;
          description "Vendor's registered Private Enterprise Number as
            maintained by IANA";
        }
        leaf duid-en-identifier {
          type string;
          description "Indentifier, unique to the device that is
          using it";
        }
      }
      case duid-ll {
          description "DUID Based on Link-layer Address (Type 3 - DUID-LL)";
          reference "RFC3315 Section 9.4";
          leaf duid-ll-hardware-type {
            type uint16;
            description "Hardware type as assigned by IANA (RFC826).";
          }
          leaf duid-ll-link-layer-addr {
            type yang:mac-address;
            description "Link-layer address as described in RFC2464";
        }
      }
      case duid-uuid {
        description "DUID Based on Universally Unique Identifier
          (Type 4 - DUID-UUID)";
        reference "RFC6335 Defination of the UUID-Based Unique Identifier";
        leaf uuid {
          type yang:uuid;
          description "A Universally Unique IDentifier in the string
            representation defined in RFC 4122. The canonical
            representation uses lowercase characters";
        }
      }
      case duid-unknown {
        description "DUID based on free raw bytes";
        leaf data {
          type binary;
          description "The bits to be used as the identifier";
        }
      }
    }
  }

  grouping portset-para {
    description "portset parameters";
    container port-parameter {
      description "port parameter";
      leaf offset {
        type uint8;
        mandatory true;
        description "offset in a port set";
      }
      leaf psid-len {
        type uint8;
        mandatory true;
        description "length of a psid";
      }
      leaf psid {
        type uint16;
        mandatory true;
        description "psid value";
      }
    }
  }

  grouping iaid {
    description "IA is a construct through which a server and a
        client can identify, group, and manage a set of related IPv6
        addresses. The key of the list is a 4-byte number IAID defined
        in [RFC3315].";
    list identity-association {
      config "false";
      description "IA";
      leaf iaid {
        type uint32;
        mandatory true;
        description "IAID";
      }
      leaf ia-type {
        type string;
        mandatory true;
        description "IA type";
      }
      leaf-list ipv6-addr {
        type inet:ipv6-address;
        description "ipv6 address";
      }
      leaf-list ipv6-prefix {
        type inet:ipv6-prefix;
        description "ipv6 prefix";
      }
      leaf-list prefix-length {
        type uint8;
        description "ipv6 prefix length";
      }
      leaf t1-time {
        type yang:timeticks;
        mandatory true;
        description "t1 time";
      }
      leaf t2-time {
        type yang:timeticks;
        mandatory true;
        description "t2 time";
      }
      leaf preferred-lifetime {
        type yang:timeticks;
        mandatory true;
        description "preferred lifetime";
      }
      leaf valid-lifetime {
        type yang:timeticks;
        mandatory true;
        description "valid lifetime";
      }
    }
  }
}
