module ietf-interfaces {

  namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces";
  prefix "if";

  import iana-if-type {
    prefix ift;
  }

  organization
    "IETF NETMOD (NETCONF Data Modeling Language) Working Group";

  contact
    "WG Web:   <http://tools.ietf.org/wg/netmod/>
     WG List:  <mailto:netmod@ietf.org>

     WG Chair: David Kessens
               <mailto:david.kessens@nsn.com>

     WG Chair: Juergen Schoenwaelder
               <mailto:j.schoenwaelder@jacobs-university.de>

     Editor:   Martin Bjorklund
               <mailto:mbj@tail-f.com>";

  description
    "This module contains a collection of YANG definitions for
     configuring network interfaces.

     Copyright (c) 2011 IETF Trust and the persons identified as
     authors of the code.  All rights reserved.

     Redistribution and use in source and binary forms, with or
     without modification, is permitted pursuant to, and subject
     to the license terms contained in, the Simplified BSD License
     set forth in Section 4.c of the IETF Trust's Legal Provisions
     Relating to IETF Documents
     (http://trustee.ietf.org/license-info).

     This version of this YANG module is part of RFC XXXX; see
     the RFC itself for full legal notices.";

  // RFC Ed.: replace XXXX with actual RFC number and remove this
  // note.

  // RFC Ed.: update the date below with the date of RFC publication
  // and remove this note.
  revision 2011-03-29 {
    description
      "Initial revision.";
    reference
      "RFC XXXX: A YANG Data Model for Interface Configuration";
  }

  /* Typedefs */

  typedef interface-ref {
    type leafref {
      path "/if:interfaces/if:interface/if:name";
    }
    description
      "This type is used by data models that need to reference
       interfaces.";
  }

  /* Features */

  feature snmp-if-mib {
    description
      "This feature indicates that the server implements IF-MIB,
       accessible over SNMP.";
    reference
      "RFC 2863: The Interfaces Group MIB";
  }

  /* Data nodes */

  container interfaces {
    description
      "Interface parameters.";

    list interface {
      key "name";
      unique "type location";

      description
        "The list of configured interfaces on the device.";
      leaf name {
        type string {
          length "1..255";
        }
        description
          "An arbitrary name for the interface.

           A device MAY restrict the allowed values for this leaf,
           possibly depending on the type and location.

           For example, if a device has a single array of 8 ethernet
           ports, the name might be restricted to be on the form
          'ethN', where N is an integer between '1' and '8'.";
      }

      leaf description {
        type string;
        description
          "A textual description of the interface.

           This leaf MAY be mapped to ifAlias by an implementation.
           Such an implementation MAY restrict the length of the
           value of this leaf so that it matches the restrictions
           of ifAlias.";
        reference
          "RFC 2863: The Interfaces Group MIB - ifAlias";
      }

      leaf type {
        type ift:iana-if-type;
        mandatory true;
        description
          "The type of the interface.

           When an interface entry is created, a server MAY
           initialize the type leaf with a valid value, e.g., if it
           is possible to derive the type from the name of the
           interface.";
      }

      leaf location {
        type string;
        description
          "The device-specific location of the interface of a
           particular type.  The format of the location string
           depends on the interface type and the device.

           Media-specific modules must specify if the location
           is needed for the given type.

           For example, if a device has a single array of 8 ethernet
           ports, the location can be one of '1' to '8'.  As another
           example, if a device has N cards of M ports, the location
           can be on the form 'n/m'.

           When an interface entry is created, a server MAY
           initialize the location leaf with a valid value, e.g., if
           it is possible to derive the location from the name of
           the interface.";
      }

      leaf admin-status {
        type enumeration {
          enum "up" {
            value 1;
          }
          enum "down" {
            value 2;
          }
        }
        default "up";
        description
          "The desired state of the interface.

           This leaf contains the configured, desired state of the
           interface.  Systems that implement the IF-MIB use the
           value of this leaf to set IF-MIB.ifAdminStatus after an
           ifEntry has been initialized, as described in RFC 2863.";
        // FIXME: Can we say that changing ifAdminStatus does NOT
        //        change this object?  If not, is the opposite
        //        always true, i.e. that changing ifAdminStatus
        //        results in a change of this object (in running)?
        //        Or should we be silent?
        reference
          "RFC 2863: The Interfaces Group MIB - ifAdminStatus";
      }

      leaf-list if-index {
        if-feature snmp-if-mib;
        type int32 {
          range "1..2147483647";
        }
        config false;
        description
          "The list of ifIndex values for all ifEntries that are
           represented by this interface.  If there is a one-to-one
           mapping between the interface and entries in the ifTable,
           this leaf-list will have a single value.

           Media-specific modules must specify how the type is
           mapped to entries in the ifTable.";
        reference
          "RFC 2863: The Interfaces Group MIB - ifIndex";
      }

      leaf mtu {
        type uint32;
        description
          "The size, in octets, of the largest packet that the
           interface can send and receive.  This node might not be
           valid for all interface types.

           Media-specific modules must specify any restrictions on
           the mtu for their interface type.";
      }

      leaf link-up-down-trap-enable {
        if-feature snmp-if-mib;
        type enumeration {
          enum enabled {
            value 1;
          }
          enum disabled {
            value 2;
          }
        }
        description
          "Indicates whether linkUp/linkDown SNMP traps should be
           generated for this interface.

           If this node is not configured, the value 'enabled' is
           operationally used by the server for interfaces which do
           not operate on top of any other intertface (as defined in
           the ifStackTable), and 'disabled' otherwise.";
        reference
          "RFC 2863: The Interfaces Group MIB -
                     ifLinkUpDownTrapEnable";
      }
    }
  }
}
