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

  import ietf-dhcpv6-options {
    prefix dhcpv6-options;
  }
  import ietf-dhcpv6-types {
    prefix dhcpv6-types;
  }
  import ietf-interfaces {
    prefix if;
  }

  organization "DHC WG";
  contact
   "cuiyong@tsinghua.edu.cn
    wangh13@mails.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 configure and manage a DHCPv6 client.";

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

  revision 2018-03-04 {
    description "Resolved most issues on the DHC official
    github";
    reference "I-D: draft-ietf-dhc-dhcpv6-yang";
  }

  revision 2017-12-22 {
    description "Resolve most issues on Ian's github.";
    reference "I-D: draft-ietf-dhc-dhcpv6-yang";
  }

  revision 2017-11-24 {
      description "First version of the separated client specific
        YANG model.";
      reference "I-D: draft-ietf-dhc-dhcpv6-yang";
  }
  /*
   * Data Nodes
   */

  container client {
    presence "Enables the client";
    description "dhcpv6 client portion";

    container client-config {
      description "configuration tree of client";
      container duid {
        description "Sets the DUID";
        uses dhcpv6-types:duid;
      }
      list client-if {
        key if-name;
        description "A client may have several interfaces, it is more reasonable to
          configure and manage parameters on the interface-level. The list defines
          specific client interfaces and their data. Different interfaces are
          distinguished by the key which is a configurable string value.";
        leaf if-name {
          type if:interface-ref;
          mandatory true;
          description "interface name";
        }

        leaf cli-id {
          type uint32;
          mandatory true;
          description "client id";
        }

        /*
        leaf description {
          type string;
          description "description of the client interface";
        }
        */

        leaf pd-function {
          type boolean;
          mandatory true;
          description "Whether the client can act as a requesting router
            to request prefixes using prefix delegation ([RFC3633]).";
        }
        leaf rapid-commit {
          type boolean;
          mandatory true;
          description "'1' indicates a client can initiate a Solicit-Reply message
            exchange by adding a Rapid Commit option in Solicit message. '0' means
            the client is not allowed to add a Rapid Commit option to request
            addresses in a two-message exchange pattern.";
        }

        /*
        container mo-tab {
          description "The management tab label indicates the operation mode of the
            DHCPv6 client.
            'm'=1 and 'o'=1 indicate the client will use DHCPv6 to  obtain all the configuration
            data.
            'm'=1 and 'o'=0 are a meaningless combination.
            'm'=0 and 'o'=1 indicate the client will use stateless DHCPv6 to obtain configuration
            data apart from addresses/prefixes data.
            'm'=0 and 'o'=0 represent the client will not use DHCPv6 but use SLAAC to
            achieve configuration.";

            // if - not sure about the intended use here as it seems
            // to be redfining what will be received in the PIO. Is
            // the intention to be whether they PIO options will be
            // obeyed as received or overridden?
          leaf m-tab {
            type boolean;
            mandatory true;
            description "m tab";
          }
          leaf o-tab {
            type boolean;
            mandatory true;
            description "o tab";
          }
        }
        */

        container client-configured-options {
          description "client configured options";
          uses dhcpv6-options:client-option-definitions;
        }
      }
    }

    container client-state {
      config "false";
      description "state tree of client";
      container if-other-paras {
        description "A client can obtain extra configuration
          data other than address and prefix information through
          DHCPv6. This container describes such data the client
          was configured. The potential configuration data may
          include DNS server addresses, SIP server domain names, etc.";
        uses dhcpv6-options:server-option-definitions;
      }
     container packet-stats {
        config "false";
        description "A container records
          all the packet status information
          of a specific interface.";
        leaf solicit-count {
          type uint32;
          mandatory true;
          description "solicit counter";
        }
        leaf request-count {
          type uint32;
          mandatory true;
          description "request counter";
        }
        leaf renew-count {
          type uint32;
          mandatory true;
          description "renew counter";
        }
        leaf rebind-count {
          type uint32;
          mandatory true;
          description "rebind counter";
        }
        leaf decline-count {
          type uint32;
          mandatory true;
          description "decline counter";
        }
        leaf release-count {
          type uint32;
          mandatory true;
          description "release counter";
        }
        leaf info-req-count {
          type uint32;
          mandatory true;
          description "information request counter";
        }
        leaf advertise-count {
          type uint32;
          mandatory true;
          description "advertise counter";
        }
        leaf confirm-count {
          type uint32;
          mandatory true;
          description "confirm counter";
        }
        leaf reply-count {
          type uint32;
          mandatory true;
          description "reply counter";
        }
        leaf reconfigure-count {
          type uint32;
          mandatory true;
          description "recofigure counter";
        }
      }
    }

  }

  /*
   * Notifications
   */

  notification notifications {
    description "dhcpv6 client notification module";
    container dhcpv6-client-event {
      description "dhcpv6 client event";

      container ia-lease-event {
        description "raised when the client was allocated
          a new IA from the server or it renew/rebind/release
          its current IA";
        leaf event-type {
          type enumeration {
            enum "allocation" {
              description "allocate";
            }
            enum "rebind" {
              description "rebind";
            }
            enum "renew" {
              description "renew";
            }
            enum "release" {
              description "release";
            }
          }
          mandatory true;
          description "event type";
        }
        container duid {
          description "Sets the DUID";
          uses dhcpv6-types:duid;
        }
        leaf iaid {
          type uint32;
          mandatory true;
          description "IAID";
        }
        leaf serv-name {
          type string;
          description "server name";
        }
        leaf description {
          type string;
          description "description of event";
        }
      }

      container invalid-ia-detected {
        description "raised when the identity association of the
          client can be proved to be invalid.  Possible condition
          includes duplicated address, illegal address, etc.";
        container duid {
          description "Sets the DUID";
          uses dhcpv6-types:duid;
        }
        leaf cli-duid {
          type uint32;
          mandatory true;
          description "duid of client";
        }
        leaf iaid {
          type uint32;
          mandatory true;
          description "IAID";
        }
        leaf serv-name {
          type string;
          description "server name";
        }
        leaf description {
          type string;
          description "description of the event";
        }
      }

      container retransmission-failed {
        description "raised when the retransmission mechanism defined
          in [RFC3315] is failed.";
        container duid {
          description "Sets the DUID";
          uses dhcpv6-types:duid;
        }
        leaf description {
          type enumeration {
            enum "MRC failed" {
              description "MRC failed";
            }
            enum "MRD failed" {
              description "MRD failed";
            }
          }
          mandatory true;
          description "description of failure";
        }
      }

      container failed-status-turn-up {
        description "raised when the client receives a message includes
          an unsuccessful Status Code option.";
        container duid {
          description "Sets the DUID";
          uses dhcpv6-types:duid;
        }
        leaf status-code {
          type enumeration {
            enum "1" {
              description "UnspecFail";
            }
            enum "2" {
              description "NoAddrAvail";
            }
            enum "3" {
              description "NoBinding";
            }
            enum "4" {
              description "NotOnLink";
            }
            enum "5" {
              description "UseMulticast";
            }
          }
          mandatory true;
          description "employed status code";
        }
      }

    }
  }
}
