submodule ietf-snmp-target {

  belongs-to ietf-snmp {
    prefix snmp;
  }

  import ietf-inet-types {
    prefix inet;
  }

  include ietf-snmp-common;

  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: Thomas Nadeau
               <mailto:tnadeau@lucidvision.com>

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

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

     Editor:   Juergen Schoenwaelder
               <mailto:j.schoenwaelder@jacobs-university.de>";

  description
    "This submodule contains a collection of YANG definitions
     for configuring SNMP targets.

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

  reference
    "RFC 3413: Simple Network Management Protocol (SNMP)
       Applications";

  revision 2014-12-10 {
    description
      "Initial revision.";
    reference
      "RFC 7407: A YANG Data Model for SNMP Configuration";
  }

  augment /snmp:snmp {

    list target {
      key name;
      description
        "List of targets.";
      reference
        "RFC 3413: Simple Network Management Protocol (SNMP)
           Applications.
           SNMP-TARGET-MIB.snmpTargetAddrTable";

      leaf name {
        type snmp:identifier;
        description
          "Identifies the target.";
        reference
          "RFC 3413: Simple Network Management Protocol (SNMP)
             Applications.
             SNMP-TARGET-MIB.snmpTargetAddrName";
      }
      choice transport {
        mandatory true;
        description
          "Transport address of the target.

           The snmpTargetAddrTDomain and snmpTargetAddrTAddress
           objects are mapped to transport-specific YANG nodes.  Each
           transport is configured as a separate case in this
           choice.  Submodules providing configuration for additional
           transports are expected to augment this choice.";

        reference
          "RFC 3413: Simple Network Management Protocol (SNMP)
             Applications.
             SNMP-TARGET-MIB.snmpTargetAddrTDomain
             SNMP-TARGET-MIB.snmpTargetAddrTAddress";
        case udp {
          reference
           "RFC 3417: Transport Mappings for the Simple Network
              Management Protocol (SNMP).
              SNMPv2-TM.snmpUDPDomain
            RFC 3419: Textual Conventions for Transport Addresses.
              TRANSPORT-ADDRESS-MIB.transportDomainUdpIpv4
              TRANSPORT-ADDRESS-MIB.transportDomainUdpIpv4z
              TRANSPORT-ADDRESS-MIB.transportDomainUdpIpv6
              TRANSPORT-ADDRESS-MIB.transportDomainUdpIpv6z";
          container udp {
            leaf ip {
              type inet:ip-address;
              mandatory true;
              reference
                "RFC 3413: Simple Network Management Protocol (SNMP).
                   SNMP-TARGET-MIB.snmpTargetAddrTAddress";
            }
            leaf port {
              type inet:port-number;
              default 162;
              description
                "UDP port number.";
              reference
                "RFC 3413: Simple Network Management Protocol (SNMP).
                   SNMP-TARGET-MIB.snmpTargetAddrTAddress";
            }
            leaf prefix-length {
              type uint8;
              description
                "The value of this leaf must match the value of
                 ../snmp:ip.  If ../snmp:ip contains an IPv4 address,
                 this leaf must be less than or equal to 32.  If it
                 contains an IPv6 address, it must be less than or
                 equal to 128.

                 Note that the prefix-length is currently only used
                 by the Community-based Security Model to filter
                 incoming messages.  Furthermore, the prefix-length
                 filtering does not cover all possible filters
                 supported by the corresponding MIB object.";

              reference
                "RFC 3584: Coexistence between Version 1, Version 2,
                   and Version 3 of the Internet-standard
                   Network Management Framework.
                   SNMP-COMMUNITY-MIB.snmpTargetAddrTMask";
            }
          }
        }
      }
      leaf-list tag {
        type snmp:tag-value;
        description
          "List of tag values used to select target addresses.";
        reference
          "RFC 3413: Simple Network Management Protocol (SNMP).
             Applications.
             SNMP-TARGET-MIB.snmpTargetAddrTagList";
      }
      leaf timeout {
        type uint32;
        units "0.01 seconds";
        default 1500;
        description
          "Needed only if this target can receive
           InformRequest-PDUs.";
        reference
          "RFC 3413: Simple Network Management Protocol (SNMP).
             Applications.
             SNMP-TARGET-MIB.snmpTargetAddrTimeout";
      }
      leaf retries {
        type uint8;
        default 3;
        description
          "Needed only if this target can receive
           InformRequest-PDUs.";
        reference
          "RFC 3413: Simple Network Management Protocol (SNMP).
             Applications.
             SNMP-TARGET-MIB.snmpTargetAddrRetryCount";
      }
      leaf target-params {
        type snmp:identifier;
        mandatory true;
        reference
          "RFC 3413: Simple Network Management Protocol (SNMP).
             Applications.
             SNMP-TARGET-MIB.snmpTargetAddrParams";
      }
    }

    list target-params {
      key name;
      description
        "List of target parameters.";
      reference
        "RFC 3413: Simple Network Management Protocol (SNMP).
           Applications.
           SNMP-TARGET-MIB.snmpTargetParamsTable";

      leaf name {
        type snmp:identifier;
      }
      choice params {
        description
          "This choice is augmented with case nodes containing
           configuration parameters specific to the security model.";
      }
    }
  }
}
