netconfcentral logo

ietf-dhcp@2017-03-02



  module ietf-dhcp {

    yang-version 1;

    namespace
      "urn:ietf:params:xml:ns:yang:ietf-dhcp";

    prefix dhcp;

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

    organization
      "IETF dhc (Dynamic Host Configuration Protocol)
                Working Group";

    contact
      "leo.liubing@huawei.com
                loukunkun@huawei.com
                chin.chen@ericsson.com";

    description
      "The module for implementing DHCP protocol";

    revision "2017-03-02" {
      description "initial draft revision";
      reference
        "rfc2131 rfc6020";

    }


    feature dhcp-server {
      description "Feature DHCP server";
    }

    feature dhcp-client {
      description "Feature DHCP client";
    }

    feature dhcp-relay {
      description "Feature DHCP relay";
    }

    typedef allocate-type {
      type enumeration {
        enum "automatic" {
          value 0;
          description
            "DHCP assigns a permanent IP address to a client";
        }
        enum "dynamic" {
          value 1;
          description
            "DHCP assigns an IP address to a client
         for a limited period of time";
        }
        enum "manual" {
          value 2;
          description
            "a client's IP address is assigned by the
                   network administrator, and DHCP is used
         simply to convey the assigned address to the client";
        }
      }
      description
        "Mechanisms for IP address allocation";
    }

    grouping server-packet {
      description
        "The packets are sent from server ";
      leaf offer-packet {
        type uint32;
        config false;
        description
          "Total number of DHCPOFFER packets";
      }

      leaf ack-packet {
        type uint32;
        config false;
        description
          "Total number of DHCPACK packets";
      }

      leaf nack-packet {
        type uint32;
        config false;
        description
          "Total number of DHCPNAK packets";
      }
    }  // grouping server-packet

    grouping client-packet {
      description
        "The packets are sent from client ";
      leaf decline-packet {
        type uint32;
        config false;
        description
          "Total number of DHCPDECLINE packets";
      }

      leaf discover-packet {
        type uint32;
        config false;
        description
          "Total number of DHCPDISCOVER packets";
      }

      leaf request-packet {
        type uint32;
        config false;
        description
          "Total number of DHCPREQUEST packets";
      }

      leaf release-packet {
        type uint32;
        config false;
        description
          "Total number of DHCPRELEASE packets";
      }

      leaf inform-packet {
        type uint32;
        config false;
        description
          "Total number of DHCPINFORM packets";
      }
    }  // grouping client-packet

    grouping sum-packet {
      description
        "All of commnicated packets between server and client";
      uses server-packet;

      uses client-packet;
    }  // grouping sum-packet

    grouping dhcp-option {
      description "Configuration option";
      leaf dhcp-server-identifier {
        type inet:ip-address;
        description "DHCP server identifier";
      }

      leaf domain-name {
        type string;
        description "Name of the domain";
      }

      leaf domain-name-server {
        type inet:ip-address;
        description
          "IPv4 address of the domain";
      }

      leaf interface-mtu {
        type uint32 {
          range "0..65535";
        }
        description
          "Minimum Transmission Unit (MTU) of the interface";
      }

      leaf netbios-name-server {
        type inet:ip-address;
        description "NETBIOS name server";
      }

      leaf netbios-node-type {
        type uint32 {
          range "0..65535";
        }
        description "NETBIOS node type";
      }

      leaf netbios-scope {
        type string;
        description "NETBIOS scope";
      }
    }  // grouping dhcp-option

    container dhcp {
      description "DHCP configuration";
      container server {
        if-feature dhcp-server;
        description
          "DHCP server configuration";
        leaf lease-time {
          type uint32 {
            range "180..31536000";
          }
          description
            "Default network address lease time assigned to DHCP clients";
        }

        leaf ping-packet-number {
          type uint8 {
            range "0..10";
          }
          default "0";
          description
            "Number of ping packets";
        }

        leaf ping-packet-timeout {
          type uint16 {
            range "0..10000";
          }
          default "500";
          description
            "Timeout of ping packet";
        }

        container option {
          description "Configuration option";
          uses dhcp-option;
        }  // container option

        list dhcp-ip-pool {
          key "ip-pool-name";
          description
            "Global IP pool configuration";
          leaf ip-pool-name {
            type string {
              length "1..64";
            }
            description
              "Name of the IP pool";
          }

          leaf interface {
            type if:interface-ref;
            description
              "Name of the interface";
          }

          leaf gateway-ip {
            type inet:ip-address;
            description
              "IPv4 address of the gateway";
          }

          leaf gateway-mask {
            type inet:ip-prefix;
            description
              "Network submask of the gateway";
          }

          leaf lease-time {
            type uint32 {
              range "180..31536000";
            }
            description
              "Default network address lease time assigned to DHCP clients";
          }

          list manual-allocation {
            key "mac-address ip-address";
            description
              "Mapping from MAC address to IP address";
            leaf mac-address {
              type yang:mac-address;
              description
                "MAC address of the host";
            }

            leaf ip-address {
              type inet:ip-address;
              description
                "IPv4 address of the host";
            }
          }  // list manual-allocation

          list section {
            key "section-index";
            description
              "IPv4 address for the range";
            leaf section-index {
              type uint16 {
                range "0..255";
              }
              description
                "Index of IPv4 address range";
            }

            leaf section-start-ip {
              type inet:ipv4-address;
              mandatory true;
              description
                "Starting IPv4 Address of a section";
            }

            leaf section-end-ip {
              type inet:ipv4-address;
              description
                "Last IPv4 Address of a section";
            }
          }  // list section

          container option {
            description
              "Configuration option";
            uses dhcp-option;
          }  // container option
        }  // list dhcp-ip-pool
      }  // container server

      container relay {
        if-feature dhcp-relay;
        description
          "DHCP relay agent configuration";
        list server-group {
          key "server-group-name";
          description
            "DHCP server group configuration that DHCP relays to";
          leaf server-group-name {
            type string;
            description
              "Name of a DHCP server group";
          }

          leaf interface {
            type if:interface-ref;
            description
              "Name of the interface";
          }

          leaf gateway-address {
            type inet:ipv4-address;
            description
              "IPv4 address of the gateway";
          }

          leaf-list server-address {
            type inet:ipv4-address;
            description
              "IPv4 address of the server";
          }
        }  // list server-group
      }  // container relay

      container client {
        if-feature dhcp-client;
        description
          "DHCP client configuration";
        list interfaces {
          key "interface";
          description
            "Interface configuration";
          leaf interface {
            type if:interface-ref;
            description
              "Name of the interface";
          }

          leaf client-id {
            type string;
            description
              "DHCP client identifier";
          }

          leaf lease {
            type uint32 {
              range "1..4294967295";
            }
            description
              "Default network address lease time assigned to DHCP clients";
          }
        }  // list interfaces
      }  // container client
    }  // container dhcp

    container dhcp-state {
      config false;
      description "DHCP state data";
      container server {
        if-feature dhcp-server;
        description "DHCP server state data";
        container packet-statistics {
          description "Packet statistics";
          leaf interface {
            type if:interface-state-ref;
            description
              "Name of the interface";
          }

          container receive {
            description
              "Number of  received packets";
            uses client-packet;
          }  // container receive

          container send {
            description
              "Number of sent packets";
            uses server-packet;
          }  // container send
        }  // container packet-statistics

        container host {
          description
            "Host status information";
          leaf interface {
            type string;
            config false;
            description
              "Name of the interface";
          }

          leaf host-ip {
            type string;
            config false;
            description
              "IPv4 address of the host";
          }

          leaf host-hardware-address {
            type string;
            config false;
            description
              "MAC address of the host";
          }

          leaf lease {
            type uint32;
            config false;
            description
              "Default network address lease
                      time assigned to DHCP clients";
          }

          leaf type {
            type allocate-type;
            config false;
            description
              "Mechanisms for IP address allocation";
          }
        }  // container host

        list ip-pool {
          key "ip-pool-name";
          description
            "Global IP pool configuration";
          leaf ip-pool-name {
            type string {
              length "1..64";
            }
            description "Name of an IP pool";
          }

          leaf gateway-ip {
            type inet:ip-address;
            description
              "IPv4 address of the gateway";
          }

          leaf gateway-mask {
            type inet:ip-prefix;
            description
              "Network submask of the gateway";
          }

          leaf used-ip-count {
            type uint32;
            config false;
            description
              "Total number of used IPv4 addresses";
          }

          leaf idle-ip-count {
            type uint32;
            config false;
            description
              "Total number of idle IPv4 addresses";
          }

          leaf conflict-ip-count {
            type uint32;
            config false;
            description
              "Total number of conflict IPv4 addresses";
          }

          leaf total-ip-count {
            type uint32;
            config false;
            description
              "Total number of IPv4 addresses";
          }
        }  // list ip-pool
      }  // container server

      container relay {
        if-feature dhcp-relay;
        description
          "DHCP reply agent state data";
        container packet-statistics {
          description "Packet statistics";
          leaf interface {
            type if:interface-state-ref;
            description
              "Name of the interface";
          }

          container receive {
            description
              "Number of  received packets";
            uses sum-packet;
          }  // container receive

          container send {
            description
              "Number of sent packets";
            uses sum-packet;
          }  // container send
        }  // container packet-statistics
      }  // container relay

      container client {
        if-feature dhcp-client;
        description "DHCP client state data";
        container packet-statistics {
          description "Packet statistics";
          leaf interface {
            type if:interface-state-ref;
            description
              "Name of the interface";
          }

          container receive {
            description
              "Number of  received packets";
            uses server-packet;
          }  // container receive

          container send {
            description
              "Number of sent packets";
            uses client-packet;
          }  // container send
        }  // container packet-statistics
      }  // container client
    }  // container dhcp-state

    rpc clean-server-statistics {
      if-feature dhcp-server;
      description
        "Clean server packet statistics";
      input {
        leaf interface {
          type leafref {
            path "/dhcp:dhcp-state/dhcp:server/dhcp:packet-statistics/dhcp:interface";
          }
          description
            "Name of the interface";
        }

        leaf clean-at {
          type yang:date-and-time;
          description
            "The start time to clean packet statistics";
        }
      }

      output {
        leaf clean-finished-at {
          type yang:date-and-time;
          description
            "The finish time to clean packet statistics";
        }
      }
    }  // rpc clean-server-statistics

    rpc clean-relay-statistics {
      if-feature dhcp-relay;
      description
        "Clean relay packet statistics";
      input {
        leaf interface {
          type leafref {
            path "/dhcp:dhcp-state/dhcp:relay/dhcp:packet-statistics/dhcp:interface";
          }
          description
            "Name of the interface";
        }

        leaf clean-at {
          type yang:date-and-time;
          description
            "The start time to clean packet statistics";
        }
      }

      output {
        leaf clean-finished-at {
          type yang:date-and-time;
          description
            "The finish time to clean packet statistics";
        }
      }
    }  // rpc clean-relay-statistics

    rpc clean-client-statistics {
      if-feature dhcp-client;
      description
        "Clean client packet statistics";
      input {
        leaf interface {
          type leafref {
            path "/dhcp:dhcp-state/dhcp:client/dhcp:packet-statistics/dhcp:interface";
          }
          description
            "Name of the interface";
        }

        leaf clean-at {
          type yang:date-and-time;
          description
            "The start time to clean packet statistics";
        }
      }

      output {
        leaf clean-finished-at {
          type yang:date-and-time;
          description
            "The finish time to clean packet statistics";
        }
      }
    }  // rpc clean-client-statistics
  }  // module ietf-dhcp