module ietf-interface-protection {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-interface-protection";
  prefix ifprot;

  import ietf-interfaces {
    prefix if;
    reference
      "RFC 8343";
  }

  organization
    "Internet Engineering Task Force (IETF) CCAMP WG";
  contact
    "WG List: <mailto:ccamp@ietf.org>

     Editors:
      Jonas Ahlberg (jonas.ahlberg@ericsson.com)
      Min Ye (amy.yemin@huawei.com)
      Xi Li (Xi.Li@neclab.eu)
      Daniela Spreafico (daniela.spreafico@nokia.com)
      Marko Vaupotic (Marko.Vaupotic@aviatnet.com)";
  description
    "This is a module for the entities in
     a generic interface protection mechanism.

     Copyright (c) 2019 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 8561; see
     the RFC itself for full legal notices.";

  revision 2019-06-19 {
    description
      "Initial revision.";
    reference
      "RFC 8561: A YANG Data Model for Microwave Radio Link";
  }

  /*
   * Protection architecture type identities
   */

  identity protection-architecture-type {
    description
      "protection architecture type";
    reference
      "ITU-T G.808.1";
  }

  identity one-plus-one-type {
    base protection-architecture-type;
    description
      "1+1; one interface protects
       another one interface.";
    reference
      "ITU-T G.808.1";
  }

  identity one-to-n-type {
    base protection-architecture-type;
    description
      "1:N; one interface protects
       n other interfaces.";
    reference
      "ITU-T G.808.1";
  }

  /*
   * Protection states identities
   */

  identity protection-states {
    description
      "Identities describing the status of the protection
       in a group of interfaces configured in
       a protection mode.";
  }

  identity unprotected {
    base protection-states;
    description
      "Not protected.";
  }

  identity protected {
    base protection-states;
    description
      "Protected.";
  }

  identity unable-to-protect {
    base protection-states;
    description
      "Unable to protect.";
  }

  /*
   * Protection Groups
   */

  grouping protection-groups {
    description
      "Configuration of protected groups of interfaces
       providing protection for each other.  More than one
       protected group per higher-layer interface is allowed.";
    list protection-group {
      key "name";
      description
        "List of protected groups of interfaces
         in a higher-layer interface.";
      leaf name {
        type string;
        description
          "Name used for identification of the protection group.";
      }
      leaf protection-architecture-type {
        type identityref {
          base protection-architecture-type;
        }
        default "ifprot:one-plus-one-type";
        description
          "The type of protection architecture used, e.g., one
           interface protecting one or several other interfaces.";

        reference
          "ITU-T G.808.1";
      }
      leaf-list members {
        type if:interface-ref;
        min-elements 2;
        description
          "Association to a group of interfaces configured for
           protection and used by a higher-layer interface.";
      }
      leaf operation-type {
        type enumeration {
          enum non-revertive {
            description
              "In non-revertive operation, the traffic does not
               return to the working interface if the switch requests
               are terminated.";
            reference
              "ITU-T G.808.1";
          }
          enum revertive {
            description
              "In revertive operation, the traffic always
               returns to (or remains on) the working interface
               if the switch requests are terminated.";
            reference
              "ITU-T G.808.1";
          }
        }
        default "non-revertive";
        description
          "The type of protection operation, i.e., revertive
           or non-revertive operation.";
      }
      leaf-list working-entity {
        when "../operation-type = 'revertive'";
        type if:interface-ref;
        min-elements 1;
        description
          "The interfaces that the traffic normally should
           be transported over when there is no need to use the
           protecting interface.";
      }
      leaf revertive-wait-to-restore {
        when "../operation-type = 'revertive'";
        type uint16;
        units "seconds";
        default "0";
        description
          "The time to wait before switching back to the working
           interface if operation-type is revertive.";
        reference
          "ITU-T G.808.1";
      }
      leaf hold-off-timer {
        type uint16;
        units "milliseconds";
        default "0";
        description
          "Time interval after the detection of a fault and its
           confirmation as a condition requiring the protection-
           switching procedure.";
        reference
          "ITU-T G.808.1";
      }
      leaf status {
        type identityref {
          base protection-states;
        }
        config false;
        description
          "Status of the protection in a group of interfaces
           configured in a protection mode.";
        reference
          "ITU-T G.808.1";
      }
      action manual-switch-working {
        description
          "A switch action initiated by an operator command.
           It switches a normal traffic signal to the working
           transport entity.";
        reference
          "ITU-T G.808.1";
      }
      action manual-switch-protection {
        description
          "A switch action initiated by an operator command.
           It switches a normal traffic signal to the protection
           transport entity.";
        reference
          "ITU-T G.808.1";
      }
      action forced-switch {
        description
          "A switch action initiated by an operator command.
           It switches a normal traffic signal to the protection
           transport entity and forces it to remain on that
           entity even when criteria for switching back to
           the original entity are fulfilled.";
        reference
          "ITU-T G.808.1";
      }
      action lockout-of-protection {
        description
          "A switch action temporarily disables access to the
           protection transport entity for all signals.";
        reference
          "ITU-T G.808.1";
      }
      action freeze {
        description
          "A switch action temporarily prevents any switch action
           to be taken and, as such, freezes the current state.
           Until the freeze is cleared, additional near-end external
           commands are rejected, and fault condition changes and
           received Automatic Protection-Switching (APS) messages
           are ignored.";
        reference
          "ITU-T G.808.1";
      }
      action exercise {
        description
          "A switch action to test if the APS communication is
           operating correctly.  It is lower priority than any 'real'
           switch request.";
        reference
          "ITU-T G.808.1";
      }
      action clear {
        description
          "An action clears all switch commands.";
        reference
          "ITU-T G.808.1";
      }
    }
  }
}
