// SPDX-FileCopyrightText: 2021 Open Networking Foundation
//
// SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0

module onf-ip-domain {
  namespace "http://opennetworking.org/aether/ip-domain";
  prefix ipd;

  import ietf-inet-types { prefix inet; }
  import ietf-yang-types{ prefix yg; }
  import onf-aether-types { prefix at; }
  import onf-enterprise{ prefix ent; }

  organization "Open Networking Foundation.";
  contact "Scott Baker";
  description
    "An Aether IP-Domain. This is a list of available subnets
     that may be assigned to UEs, as well as DNS servers and other
     metadata";

  revision "2021-06-02" {
    description "An Aether IP and Domain Specification";
    reference "RFC 6087";
  }

  typedef ip-domain-id {
        type yg:yang-identifier {
            length 1..32;
        }
  }

  container ip-domain {
    description "The top level container";

    list ip-domain {
      key "id";
      description
        "List of ip domains";

      leaf id {
        type ip-domain-id;
        description "ID for this ip domain.";
      }

      leaf display-name {
        type string {
            length 1..80;
        }
        description "display name to use in GUI or CLI";
      }

      leaf dnn {
        type at:dnn;
        description "DNN/APN";
      }      

      leaf dns-primary {
        type inet:ip-address;
        description "primary dns server name";
      }

      leaf dns-secondary {
        type inet:ip-address;
        description "secondary dns server name";
      }

      // Note: Cannot use a subnet as a list key. Dropped support from a
      // list of subnets to a single subnet. Revisit in the future.
      leaf subnet {
        type inet:ipv4-prefix;
        mandatory true;
        description "subnet to allocate ip addresses from";
      }

      leaf admin-status {
        type at:admin-status;
        description "administrative status";
      }

      leaf mtu {
        type at:mtu;
        description "maximum transmission unit";
      }           

      leaf description {
        type at:description;
        description "description of this ip domain";
      }

      // Ip-Domain is always owned by an Enterprise, because it contains
      // IP addresses relative to that Enterprise.
      leaf enterprise {
        type leafref {
          path "/ent:enterprise/ent:enterprise/ent:id";
        }
        mandatory true;
        description
          "Link to enterprise that owns this IP-Domain";
      }         
    }
  } 
}
