module ietf-connectionless-oam {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-connectionless-oam";
  prefix cl-oam;

  import ietf-yang-schema-mount {
    prefix yangmnt;
  }
  import ietf-network {
    prefix nd;
  }
  import ietf-yang-types {
    prefix yang;
  }
  import ietf-interfaces {
    prefix if;
  }
  import ietf-inet-types {
    prefix inet;
  }
  import ietf-network-instance {
    prefix ni;
  }
  import ietf-routing-types {
    prefix rt;
  }
  import ietf-lime-time-types {
    prefix lime;
  }

  organization
    "IETF LIME Working Group";
  contact
    "WG Web:   <https://datatracker.ietf.org/wg/lime>
     WG List:  <mailto:lmap@ietf.org>

     Deepak Kumar <dekumar@cisco.com>
     Qin Wu <bill.wu@huawei.com>
     Srihari Raghavan <srihari@cisco.com>
     Michael Wang <wangzitao@huawei.com>
     Reshad Rahman <rrahman@cisco.com>";
  description
    "This YANG module defines the generic configuration,
     data model, and statistics for OAM protocols using
     connectionless communications, described in a
     protocol independent manner.  It is assumed that each
     protocol maps corresponding abstracts to its native
     format.  Each protocol may extend the YANG data model defined
     here to include protocol specific extensions.

     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 8532; see
     the RFC itself for full legal notices.";

  revision 2019-02-04 2019-03-11 {
    description
      "Base model for Connectionless Operations, Administration,
       and Maintenance (OAM).";
    reference
      "RFC 8532: Generic YANG Data Model for the Management of
       Operations, Administration, and Maintenance (OAM) Protocols
       That Use Connectionless Communications";
  }

  feature connectionless {
    description
      "This feature indicates that the OAM solution is connectionless.";
  }

  feature continuity-check {
    description
      "This feature indicates that the server supports
       executing a Continuity Check OAM command and
       returning a response.  Servers that do not advertise
       this feature will not support executing
       Continuity Check commands or the RPC operation model for
       Continuity Check commands.";
  }

  feature path-discovery {
    description
      "This feature indicates that the server supports
       executing a path discovery OAM command and
       returning a response.  Servers that do not advertise
       this feature will not support executing
       path discovery commands or the RPC operation model for
       path discovery commands.";
  }

  feature ptp-long-format {
    description
      "This feature indicates that the timestamp is PTP long format.";
  }

  feature ntp-short-format {
    description
      "This feature indicates that the timestamp is NTP short format.";
  }

  feature icmp-timestamp {
    description
      "This feature indicates that the timestamp is ICMP timestamp.";
  }

  identity traffic-type {
    description
      "This is the base identity of the traffic type,
       which includes IPv4, IPv6, etc.";
  }

  identity ipv4 {
    base traffic-type;
    description
      "identity for IPv4 traffic type.";
  }

  identity ipv6 {
    base traffic-type;
    description
      "identity for IPv6 traffic type.";
  }

  identity address-attribute-types {
    description
      "This is the base identity of the address attribute types, which
       are Generic IPv4/IPv6 Prefix, BGP Labeled IPv4/IPv6 Prefix,
       Tunnel ID, PW ID, VPLS VE ID, etc. (See RFC 8029 for details.)";
  }

  typedef address-attribute-type {
    type identityref {
      base address-attribute-types;
    }
    description
      "Target address attribute type.";
  }

  typedef percentage {
    type decimal64 {
      fraction-digits 5;
      range "0..100";
    }
    description
      "Percentage.";
  }

  typedef routing-instance-ref {
    type leafref {
      path "/ni:network-instances/ni:network-instance/ni:name";
    }
    description
      "This type is used for leafs that reference a routing instance
       configuration.";
  }

  grouping cc-session-statistics {
    description
      "Grouping for session statistics.";
    container cc-session-statistics {
      description
        "CC session counters.";
      leaf session-count {
        type uint32;
        default "0";
        description
          "Number of Continuity Check sessions.
           A value of zero indicates that no session
           count is sent.";
      }
      leaf session-up-count {
        type uint32;
        default "0";
        description
          "Number of sessions that are up.
           A value of zero indicates that no up
           session count is sent.";
      }
      leaf session-down-count {
        type uint32;
        default "0";
        description
          "Number of sessions that are down.
           A value of zero indicates that no down
           session count is sent.";
      }
      leaf session-admin-down-count {
        type uint32;
        default "0";
        description
          "Number of sessions that are admin-down.
           A value of zero indicates that no admin-
           down session count is sent.";
      }
    }
  }

  grouping session-packet-statistics {
    description
      "Grouping for statistics per session packet.";
    container session-packet-statistics {
      description
        "Statistics per session packet.";
      leaf rx-packet-count {
        type uint32{ uint32 {
          range "0..4294967295";
        }
        default "0";
        description
          "Total count of received OAM packets.
           The value of count will be set to zero (0)
           on creation and will thereafter increase
           monotonically until it reaches a maximum value
           of 2^32-1 (4294967295 decimal), when it wraps
           around and starts increasing again from zero.";
      }
      leaf tx-packet-count {
        type uint32{ uint32 {
          range "0..4294967295";
        }
        default "0";
        description
          "Total count of transmitted OAM packets.
           The value of count will be set to zero (0)
           on creation and will thereafter increase
           monotonically until it reaches a maximum value
           of 2^32-1 (4294967295 decimal), when it wraps
           around and starts increasing again from zero.";
      }
      leaf rx-bad-packet {
        type uint32 {
          range "0..4294967295";
        }
        default "0";
        description
          "Total number of received bad OAM packets.
           The value of count will be set to zero (0)
           on creation and will thereafter increase
           monotonically until it reaches a maximum value
           of 2^32-1 (4294967295 decimal), when it wraps
           around and starts increasing again from zero.";
      }
      leaf tx-packet-failed {
        type uint32 {
          range "0..4294967295";
        }
        default "0";
        description
          "Total number of OAM packets that failed when sent.
           The value of count will be set to zero (0)
           on creation and will thereafter increase
           monotonically until it reaches a maximum value
           of 2^32-1 (4294967295 decimal), when it wraps
           around and starts increasing again from zero.";
      }
    }
  }

  grouping cc-per-session-statistics {
    description
      "Grouping for per-session statistics.";
    container cc-per-session-statistics {
      description
        "Per-session statistics.";
      leaf create-time {
        type yang:date-and-time;
        description
          "Time and date when session is created.";
      }
      leaf last-down-time {
        type yang:date-and-time;
        description
          "Time and date of the last time session was down.";
      }
      leaf last-up-time {
        type yang:date-and-time;
        description
          "Time and date of the last time session was up.";
      }
      leaf down-count {
        type uint32 {
          range "0..4294967295";
        }
        default "0";
        description
          "Total count of Continuity Check sessions down.
           The value of count will be set to zero (0)
           on creation and will thereafter increase
           monotonically until it reaches a maximum value
           of 2^32-1 (4294967295 decimal), when it wraps
           around and starts increasing again from zero.";
      }
      leaf admin-down-count {
        type uint32 {
          range "0..4294967295";
        }
        default "0";
        description
          "Total count of Continuity Check sessions admin down.
           The value of count will be set to zero (0)
           on creation and will thereafter increase
           monotonically until it reaches a maximum value
           of 2^32-1 (4294967295 decimal), when it wraps
           around and starts increasing again from zero.";
      }
      uses session-packet-statistics;
    }
  }

  grouping session-error-statistics {
    description
      "Grouping for per-session error statistics.";
    container session-error-statistics {
      description
        "Per-session error statistics.";
      leaf packet-loss-count {
        type uint32 {
          range "0..4294967295";
        }
        default "0";
        description
          "Total count of received packet drops.
           The value of count will be set to zero (0)
           on creation and will thereafter increase
           monotonically until it reaches a maximum value
           of 2^32-1 (4294967295 decimal), when it wraps
           around and starts increasing again from zero.";
      }
      leaf loss-ratio{ loss-ratio {
        type percentage;
        description
          "Loss ratio of the packets.  Expressed as percentage
           of packets lost with respect to packets sent.";
      }
      leaf packet-reorder-count {
        type uint32 {
          range "0..4294967295";
        }
        default "0";
        description
          "Total count of received packets that were reordered.
           The value of count will be set to zero (0)
           on creation and will thereafter increase
           monotonically until it reaches a maximum value
           of 2^32-1 (4294967295 decimal), when it wraps
           around and starts increasing again from zero.";
      }
      leaf packets-out-of-seq-count {
        type uint32 {
          range "0..4294967295";
        }
        description
          "Total count of packets received out of sequence.
           The value of count will be set to zero (0)
           on creation and will thereafter increase
           monotonically until it reaches a maximum value
           of 2^32-1 (4294967295 decimal), when it wraps
           around and starts increasing again from zero.";
      }
      leaf packets-dup-count {
        type uint32 {
          range "0..4294967295";
        }
        description
          "Total count of received packet duplicates.
           The value of count will be set to zero (0)
           on creation and will thereafter increase
           monotonically until it reaches a maximum value
           of 2^32-1 (4294967295 decimal), when it wraps
           around and starts increasing again from zero.";
      }
    }
  }

  grouping session-delay-statistics {
    description
      "Grouping for delay statistics per session.";
    container session-delay-statistics {
      description
        "Session delay summarized information.  By default, a
         one-way measurement protocol (e.g., OWAMP) is used
         to measure delay.  When a two-way measurement protocol
         (e.g., TWAMP) is used instead, it can be indicated
         using the protocol-id defined in RPC operation of
         retrieval methods for connectionless OAM (RFC 8533),
         i.e., set protocol-id as OWAMP.  Note that only one
         measurement protocol for delay is specified for
         interoperability reasons.";
      leaf time-unit-value {
        type identityref {
          base lime:time-unit-type;
        }
        default lime:milliseconds; "lime:milliseconds";
        description
          "Time units, where the options are s, ms, ns, etc.";
      }
      leaf min-delay-value {
        type uint32;
        description
          "Minimum delay value observed.";
      }
      leaf max-delay-value {
        type uint32;
        description
          "Maximum delay value observed.";
      }
      leaf average-delay-value {
        type uint32;
        description
          "Average delay value observed.";
      }
    }
  }

  grouping session-jitter-statistics {
    description
      "Grouping for per session jitter statistics.";
    container session-jitter-statistics {
      description
        "Summarized information about session jitter.  By default,
         jitter is measured using IP Packet Delay Variation
         (IPDV) as defined in RFC 3393.  When the other measurement
         method is used instead (e.g., Packet Delay Variation used
         in ITU-T Recommendation Y.1540, it can be indicated using
         protocol-id-meta-data defined in RPC operation of
         retrieval methods for connectionless OAM (RFC 8533).
         Note that only one measurement method for jitter is
         specified for interoperability reasons.";
      leaf unit-value {
        type identityref {
          base lime:time-unit-type;
        }
        default lime:milliseconds; "lime:milliseconds";
        description
          "Time units, where the options are s, ms, ns, etc.";
      }
      leaf min-jitter-value {
        type uint32;
        description
          "Minimum jitter value observed.";
      }
      leaf max-jitter-value {
        type uint32;
        description
          "Maximum jitter value observed.";
      }
      leaf average-jitter-value {
        type uint32;
        description
          "Average jitter value observed.";
      }
    }
  }

  grouping session-path-verification-statistics {
    description
      "Grouping for path verification statistics per session.";
    container session-path-verification-statistics {
      description
        "OAM path verification statistics per session.";
      leaf verified-count {
        type uint32 {
          range "0..4294967295";
        }
        description
          "Total number of OAM packets that
           went through a path as intended.
           The value of count will be set to zero (0)
           on creation and will thereafter increase
           monotonically until it reaches a maximum value
           of 2^32-1 (4294967295 decimal), when it wraps
           around and starts increasing again from zero.";
      }
      leaf failed-count {
        type uint32 {
          range "0..4294967295";
        }
        description
          "Total number of OAM packets that
           went through an unintended path.
           The value of count will be set to zero (0)
           on creation and will thereafter increase
           monotonically until it reaches a maximum value
           of 2^32-1 (4294967295 decimal), when it wraps
           around and starts increasing again from zero.";
      }
    }
  }

  grouping session-type {
    description
      "This object indicates which kind of activation will
       be used by the current session.";
    leaf session-type {
      type enumeration {
        enum "proactive" proactive {
          description
            "The current session is a proactive session.";
        }
        enum "on-demand" on-demand {
          description
            "The current session is an on-demand session.";
        }
      }
      default "on-demand";
      description
        "Indicate which kind of activation will be used
         by the current session.";
    }
  }

  identity tp-address-technology-type {
    description
      "Test point address type.";
  }

  identity mac-address-type {
    base tp-address-technology-type;
    description
      "MAC address type.";
  }

  identity ipv4-address-type {
    base tp-address-technology-type;
    description
      "IPv4 address type.";
  }

  identity ipv6-address-type {
    base tp-address-technology-type;
    description
      "IPv6 address type.";
  }
  identity tp-attribute-type {
    base tp-address-technology-type;
    description
      "Test point attribute type.";
  }

  identity router-id-address-type {
    base tp-address-technology-type;
    description
      "System ID address type.";
  }

  identity as-number-address-type {
    base tp-address-technology-type;
    description
      "AS number address type.";
  }

  identity route-distinguisher-address-type {
    base tp-address-technology-type;
    description
      "Route Distinguisher address type.";
  }

  grouping tp-address {
    leaf tp-location-type {
      type identityref {
        base tp-address-technology-type;
      }
      mandatory true;
      description
        "Test point address type.";
    }
    container mac-address {
      when "derived-from-or-self(../tp-location-type,"+ "derived-from-or-self(../tp-location-type,"
         + "'cl-oam:mac-address-type')" {
        description
          "MAC address type.";
      }
      leaf mac-address {
        type yang:mac-address;
        mandatory true;
        description
          "MAC address.";
      }
      description
        "MAC address based TP addressing.";
    }
    container ipv4-address {
      when "derived-from-or-self(../tp-location-type,"+ "derived-from-or-self(../tp-location-type,"
         + "'cl-oam:ipv4-address-type')" {
        description
          "IPv4 address type.";
      }
      leaf ipv4-address {
        type inet:ipv4-address;
        mandatory true;
        description
          "IPv4 address.";
      }
      description
        "IP address based TP addressing.";
    }
    container ipv6-address {
      when "derived-from-or-self(../tp-location-type,"+ "derived-from-or-self(../tp-location-type,"
         + "'cl-oam:ipv6-address-type')" {
        description
          "IPv6 address type.";
      }
      leaf ipv6-address {
        type inet:ipv6-address;
        mandatory true;
        description
          "IPv6 address.";
      }
      description
        "IPv6 address based TP addressing.";
    }
    container tp-attribute {
      when "derived-from-or-self(../tp-location-type,"+ "derived-from-or-self(../tp-location-type,"
         + "'cl-oam:tp-attribute-type')" {
        description
          "Test point attribute type.";
      }
      leaf tp-attribute-type {
        type address-attribute-type;
        description
          "Test point type.";
      }
      choice tp-attribute-value {
        description
          "Test point value.";
        case ip-prefix {
          leaf ip-prefix {
            type inet:ip-prefix;
            description
              "Generic IPv4/IPv6 prefix.  See Sections 3.2.13 and
               3.2.14 of RFC 8029.";
            reference
              "RFC 8029: Detecting Multiprotocol Label
               Switched (MPLS) Data-Plane Failures";
          }
        }
        case bgp {
          leaf bgp {
            type inet:ip-prefix;
            description
              "BGP Labeled IPv4/IPv6 Prefix.  See Sections
               3.2.11 and 3.2.12 of RFC 8029 for details.";
            reference
              "RFC 8029: Detecting Multiprotocol Label
               Switched (MPLS) Data-Plane Failures";
          }
        }
        case tunnel {
          leaf tunnel-interface {
            type uint32;
            description
              "Basic IPv4/IPv6 Tunnel ID.  See Sections 3.2.3
               and 3.2.4 of RFC 8029 for details.";
            reference
              "RFC 8029: Detecting Multiprotocol Label
               Switched (MPLS) Data-Plane Failures.";
          }
        }
        case pw {
          leaf remote-pe-address {
            type inet:ip-address;
            description
              "Remote PE address.  See Section 3.2.8
               of RFC 8029 for details.";
            reference
              "RFC 8029: Detecting Multiprotocol Label
               Switched (MPLS) Data-Plane Failures";
          }
          leaf pw-id {
            type uint32;
            description
              "Pseudowire ID is a non-zero 32-bit ID.  See Sections
               3.2.8 and 3.2.9 of RFC 8029 for details.";
            reference
              "RFC 8029: Detecting Multiprotocol Label
               Switched (MPLS) Data-Plane Failures";
          }
        }
        case vpls {
          leaf route-distinguisher {
            type rt:route-distinguisher;
            description
              "Route Distinguisher is an 8-octet identifier
               used to distinguish information about various
               L2VPNs advertised by a node.";
            reference
              "RFC 8029: Detecting Multiprotocol Label
               Switched (MPLS) Data-Plane Failures";
          }
          leaf sender-ve-id {
            type uint16;
            description
              "Sender's VE ID.  The VE ID (VPLS Edge Identifier)
               is a 2-octet identifier.";
            reference
              "RFC 8029: Detecting Multiprotocol Label
               Switched (MPLS) Data-Plane Failures";
          }
          leaf receiver-ve-id {
            type uint16;
            description
              "Receiver's VE ID.  The VE ID (VPLS Edge Identifier)
               is a 2-octet identifier.";
            reference
              "RFC 8029: Detecting Multiprotocol Label
               Switched (MPLS) Data-Plane Failures";
          }
        }
        case mpls-mldp {
          choice root-address {
            description
              "Root address choice.";
            case ip-address {
              leaf source-address {
                type inet:ip-address;
                description
                  "IP address.";
              }
              leaf group-ip-address {
                type inet:ip-address;
                description
                  "Group IP address.";
              }
            }
            case vpn {
              leaf as-number {
                type inet:as-number;
                description
                  "The AS number that identifies an Autonomous
                   System.";
              }
            }
            case global-id {
              leaf lsp-id {
                type string;
                description
                  "LSP ID is an identifier of a LSP
                   within a MPLS network.";
                reference
                  "RFC 8029: Detecting Multiprotocol Label
                   Switched (MPLS) Data-Plane Failures";
              }
            }
          }
        }
      }
      description
        "Test Point Attribute Container.";
    }
    container system-info {
      when "derived-from-or-self(../tp-location-type,"+ "derived-from-or-self(../tp-location-type,"
         + "'cl-oam:router-id-address-type')" {
        description
          "System ID address type.";
      }
      leaf router-id {
        type rt:router-id;
        description
          "Router ID assigned to this node.";
      }
      description
        "Router ID container.";
    }
    description
      "TP Address.";
  }

  grouping tp-address-ni {
    description
      "Test point address with VRF.";
    leaf ni {
      type routing-instance-ref;
      description
        "The ni is used to describe virtual resource partitioning
         that may be present on a network device.  An example of a
         common industry term for virtual resource partitioning is
         'VRF instance'.";
    }
    uses tp-address;
  }

  grouping connectionless-oam-tps {
    list oam-neighboring-tps {
      key "index";
      leaf index {
        type uint16{ uint16 {
          range "0..65535";
        }
        description
          "Index of a list of neighboring test points
           in layers up and down the stack for
           the same interface that are related to the
           current test point.";
      }
      leaf position {
        type int8 {
          range "-1..1";
        }
        default "0";
        description
          "The position of the neighboring test point relative to
           the current test point.  Level 0 indicates a test point
           corresponding to a specific index in the same layer as
           the current test point.  -1 means there is a test point
           corresponding to a specific index in the test point down
           the stack, and +1 means there is a test point corresponding
           to a specific index in the test point up the stack.";
      }
      choice tp-location {
        case mac-address {
          leaf mac-address-location {
            type yang:mac-address;
            description
              "MAC address.";
          }
          description
            "MAC address based TP addressing.";
        }
        case ipv4-address {
          leaf ipv4-address-location {
            type inet:ipv4-address;
            description
              "IPv4 address.";
          }
          description
            "IP address based TP addressing.";
        }
        case ipv6-address {
          leaf ipv6-address-location {
            type inet:ipv6-address;
            description
              "IPv6 address.";
          }
          description
            "IPv6 address based TP addressing.";
        }
        case as-number {
          leaf as-number-location {
            type inet:as-number;
            description
              "AS number location.";
          }
          description
            "AS number for point-to-multipoint OAM.";
        }
        case router-id {
          leaf router-id-location {
            type rt:router-id;
            description
              "System ID location.";
          }
          description
            "System ID.";
        }
        description
          "TP location.";
      }
      description
        "List of neighboring test points in the same layer that are
         related to current test point.  If the neighboring test point
         is placed after the current test point, the position is
         specified as +1.  If the neighboring test point is placed
         before the current test point, the position is specified
         as -1; if no neighboring test points are placed before or
         after the current test point in the same layer, the
         position is specified as 0.";
    }
    description
      "List of neighboring test points related to connectionless OAM.";
  }

  grouping tp-technology {
    choice technology {
      default "technology-null";
      case technology-null {
        description
          "This is a placeholder when no technology is needed.";
        leaf tech-null {
          type empty;
          description
            "There is no technology to be defined.";
        }
      }
      description
        "Technology choice.";
    }
    description
      "OAM technology.";
  }

  grouping tp-tools {
    description
      "Test point OAM toolset.";
    container tp-tools {
      leaf continuity-check {
        type boolean;
        mandatory true;
        description
          "A flag indicating whether or not the
           Continuity Check function is supported.";
        reference
          "RFC 792: INTERNET CONTROL MESSAGE PROTOCOL
           RFC 4443: Internet Control Message Protocol (ICMPv6)
               for the Internet Protocol Version 6 (IPv6) Specification
           RFC 5880: Bidirectional Forwarding Detection
           RFC 5881: BFD for IPv4 and IPv6
           RFC 5883: BFD for Multihop Paths
           RFC 5884: BFD for MPLS Label Switched Paths
           RFC 5885: BFD for PW VCCV
           RFC 6450: Multicast Ping Protocol
           RFC 8029: Detecting Multiprotocol Label Switched (MPLS)
               Data-Plane Failures";
      }
      leaf path-discovery {
        type boolean;
        mandatory true;
        description
          "A flag indicating whether or not the
           path discovery function is supported.";
        reference
          "RFC 792: INTERNET CONTROL MESSAGE PROTOCOL
           RFC 4443: Internet Control Message Protocol (ICMPv6)
               for the Internet Protocol Version 6 (IPv6) Specification
           RFC 4884: Extended ICMP to Support Multi-Part Messages
           RFC 5837: Extending ICMP for Interface and Next-Hop
               Identification
           RFC 8029: Detecting Multiprotocol Label Switched (MPLS)
               Data-Plane Failures";
      }
      description
        "Container for test point OAM toolset.";
    }
  }

  grouping test-point-location-info {
    uses tp-technology;
    uses tp-tools;
    anydata root {
      yangmnt:mount-point "root";
      description
        "Root for models supported per test point.";
    }
    uses connectionless-oam-tps;
    description
      "Test point location.";
  }

  grouping test-point-locations {
    description
      "Group of test point locations.";
    leaf tp-location-type {
      type identityref {
        base tp-address-technology-type;
      }
      description
        "Test point location type.";
    }
    container ipv4-location-type {
      when "derived-from-or-self(../tp-location-type,"+ "derived-from-or-self(../tp-location-type,"
         + "'cl-oam:ipv4-address-type')" {
        description
          "When test point location type is equal to IPv4 address.";
      }
      container test-point-ipv4-location-list {
        list test-point-locations {
          key "ipv4-location ni";
          leaf ipv4-location {
            type inet:ipv4-address;
            description
              "IPv4 address.";
          }
          leaf ni {
            type routing-instance-ref;
            description
              "The ni is used to describe the
               corresponding network instance";
          }
          uses test-point-location-info;
          description
            "List of test point locations.";
        }
        description
          "Serves as top-level container
           for test point location list.";
      }
      description
        "Container for IPv4 location types.";
    }
    container ipv6-location-type {
      when "derived-from-or-self(../tp-location-type,"+ "derived-from-or-self(../tp-location-type,"
         + "'cl-oam:ipv6-address-type')" {
        description
          "When test point location is equal to IPv6 address.";
      }
      container test-point-ipv6-location-list {
        list test-point-locations {
          key "ipv6-location ni";
          leaf ipv6-location {
            type inet:ipv6-address;
            description
              "IPv6 address.";
          }
          leaf ni {
            type routing-instance-ref;
            description
              "The ni is used to describe the
               corresponding network instance.";
          }
          uses test-point-location-info;
          description
            "List of test point locations.";
        }
        description
          "Serves as top-level container
           for test point location list.";
      }
      description
        "ipv6 location type container.";
    }
    container mac-location-type {
      when "derived-from-or-self(../tp-location-type,"+ "derived-from-or-self(../tp-location-type,"
         + "'cl-oam:mac-address-type')" {
        description
          "When test point location type is equal to MAC address.";
      }
      container test-point-mac-address-location-list {
        list test-point-locations {
          key "mac-address-location";
          leaf mac-address-location {
            type yang:mac-address;
            description
              "MAC address.";
          }
          uses test-point-location-info;
          description
            "List of test point locations.";
        }
        description
          "Serves as top-level container
           for test point location list.";
      }
      description
        "Container for MAC address location types.";
    }
    container group-as-number-location-type {
      when "derived-from-or-self(../tp-location-type,"+ "derived-from-or-self(../tp-location-type,"
         + "'cl-oam:as-number-address-type')" {
        description
          "When test point location type is equal to AS number.";
      }
      container test-point-as-number-location-list {
        list test-point-locations {
          key "as-number-location";
          leaf as-number-location {
            type inet:as-number;
            description
              "AS number for point-to-multipoint OAM.";
          }
          leaf ni {
            type routing-instance-ref;
            description
              "The ni is used to describe the
               corresponding network instance.";
          }
          uses test-point-location-info;
          description
            "List of test point locations.";
        }
        description
          "Serves as top-level container
           for test point location list.";
      }
      description
        "Container for AS number location types.";
    }
    container group-router-id-location-type {
      when "derived-from-or-self(../tp-location-type,"+ "derived-from-or-self(../tp-location-type,"
         + "'cl-oam:router-id-address-type')" {
        description
          "When test point location type is equal to system-info.";
      }
      container test-point-system-info-location-list {
        list test-point-locations {
          key "router-id-location";
          leaf router-id-location {
            type rt:router-id;
            description
              "System ID.";
          }
          leaf ni {
            type routing-instance-ref;
            description
              "The ni is used to describe the
               corresponding network instance.";
          }
          uses test-point-location-info;
          description
            "List of test point locations.";
        }
        description
          "Serves as top-level container for
           test point location list.";
      }
      description
        "Container for system ID location types.";
    }
  }

  augment "/nd:networks/nd:network/nd:node" {
    description
      "Augments the /networks/network/node path defined in the
       ietf-network module (RFC 8345) with test-point-locations
       grouping.";
    uses test-point-locations;
  }

  grouping timestamp {
    description
      "Grouping for timestamp.";
    leaf timestamp-type {
      type identityref {
        base lime:timestamp-type;
      }
      description
        "Type of timestamp, such as Truncated PTP or NTP.";
    }
    container timestamp-64bit {
      when
   "derived-from-or-self(../timestamp-type, 'lime:truncated-ptp')" "derived-from-or-self(../timestamp-type,"
         + "'lime:truncated-ptp')"
         + "or derived-from-or-self(../timestamp-type, 'lime:ntp64')" derived-from-or-self(../timestamp-type,"
         + "'lime:ntp64')" {
        description
          "Only applies when PTP truncated or 64-bit NTP timestamp.";
      }
      leaf timestamp-sec {
        type uint32;
        description
          "Absolute timestamp in seconds as per IEEE 1588v2
           or seconds part in 64-bit NTP timestamp.";
      }
      leaf timestamp-nanosec {
        type uint32;
        description
          "Fractional part in nanoseconds as per IEEE 1588v2
           or fractional part in 64-bit NTP timestamp.";
      }
      description
        "Container for 64-bit timestamp.  The Network Time Protocol
         (NTP) 64-bit timestamp format is defined in RFC 5905.  The
         PTP truncated timestamp format is defined in IEEE 1588v1.";
      reference
        "RFC 5905: Network Time Protocol Version 4: Protocol and
             Algorithms Specification
         IEEE 1588v1: IEEE Standard for a Precision Clock
             Synchronization Protocol for Networked Measurement and
             Control Systems Version 1";
    }
    container timestamp-80bit {
      when "derived-from-or-self(../timestamp-type, 'lime:ptp80')"{ 'lime:ptp80')" {
        description
          "Only applies when 80-bit PTP timestamp.";
      }
      if-feature ptp-long-format; "ptp-long-format";
      leaf timestamp-sec {
        type uint64 {
          range "0..281474976710655";
        }
        description
          "48-bit timestamp in seconds as per IEEE 1588v2.";
      }
      leaf timestamp-nanosec {
        type uint32;
        description
          "Fractional part in nanoseconds as per IEEE 1588v2.";
      }
      description
        "Container for 80-bit timestamp.";
    }
    container ntp-timestamp-32bit {
      when "derived-from-or-self(../timestamp-type, 'lime:truncated-ntp')"{ "derived-from-or-self(../timestamp-type,"
         + "'lime:truncated-ntp')" {
        description
          "Only applies when 32-bit NTP short-format timestamp.";
      }
      if-feature ntp-short-format; "ntp-short-format";
      leaf timestamp-sec {
        type uint16;
        description
          "Timestamp in seconds as per short-format NTP.";
      }
      leaf timestamp-nanosec {
        type uint16;
        description
          "Truncated fractional part in 16-bit NTP timestamp.";
      }
      description
        "Container for 32-bit timestamp RFC5905.";
      reference
        "RFC 5905: Network Time Protocol Version 4: Protocol and
         Algorithms Specification.";
    }
    container icmp-timestamp-32bit {
      when "derived-from-or-self(../timestamp-type, 'lime:icmp')"{ 'lime:icmp')" {
        description
          "Only applies when ICMP timestamp.";
      }
      if-feature icmp-timestamp; "icmp-timestamp";
      leaf timestamp-millisec {
        type uint32;
        description
          "Timestamp in milliseconds for ICMP timestamp.";
      }
      description
        "Container for 32-bit timestamp.  See RFC 792 for ICMP
         timestamp format.";
    }
  }

  grouping path-discovery-data {
    description
      "Data output from nodes related to path discovery.";
    container src-test-point {
      description
        "Source test point.";
      uses tp-address-ni;
    }
    container dest-test-point {
      description
        "Destination test point.";
      uses tp-address-ni;
    }
    leaf sequence-number {
      type uint64;
      default "0";
      description
        "Sequence number in data packets.  A value of
         zero indicates that no sequence number is sent.";
    }
    leaf hop-cnt {
      type uint8;
      default "0";
      description
        "Hop count.  A value of zero indicates
         that no hop count is sent.";
    }
    uses session-packet-statistics;
    uses session-error-statistics;
    uses session-delay-statistics;
    uses session-jitter-statistics;
    container path-verification {
      description
        "Optional information related to path verification.";
      leaf flow-info {
        type string;
        description
          "Information that refers to the flow.";
      }
      uses session-path-verification-statistics;
    }
    container path-trace-info {
      description
        "Optional per-hop path trace information about test points.
         The path trace information list typically has a single
         element for per-hop cases such as path-discovery RPC operation
         but allows a list of hop-related information for other types of
         data retrieval methods.";
      list path-trace-info-list {
        key "index";
        description
          "Path trace information list.";
        leaf index {
          type uint32;
          description
            "Trace information index.";
        }
        uses tp-address-ni;
        uses timestamp;
        leaf ingress-intf-name {
          type if:interface-ref;
          description
            "Ingress interface name.";
        }
        leaf egress-intf-name {
          type if:interface-ref;
          description
            "Egress interface name.";
        }
        leaf queue-depth {
          type uint32;
          description
            "Length of the queue of the interface from where
             the packet is forwarded out.  The queue depth could
             be the current number of memory buffers used by the
             queue, and a packet can consume one or more memory buffers,
             thus constituting device-level information.";
        }
        leaf transit-delay {
          type uint32;
          description
            "Time in nanoseconds that the packet spent transiting a
             node.";
        }
        leaf app-meta-data {
          type uint64;
          description
            "Application-specific data added by node.";
        }
      }
    }
  }

  grouping continuity-check-data {
    description
      "Continuity Check data output from nodes.";
    container src-test-point {
      description
        "Source test point.";
      uses tp-address-ni;
      leaf egress-intf-name {
        type if:interface-ref;
        description
          "Egress interface name.";
      }
    }
    container dest-test-point {
      description
        "Destination test point.";
      uses tp-address-ni;
      leaf ingress-intf-name {
        type if:interface-ref;
        description
          "Ingress interface name.";
      }
    }
    leaf sequence-number {
      type uint64;
      default "0";
      description
        "Sequence number in data packets.  A value of
         zero indicates that no sequence number is sent.";
    }
    leaf hop-cnt {
      type uint8;
      default "0";
      description
        "Hop count.  A value of zero indicates
         that no hop count is sent.";
    }
    uses session-packet-statistics;
    uses session-error-statistics;
    uses session-delay-statistics;
    uses session-jitter-statistics;
  }

  container cc-session-statistics-data {
    if-feature "continuity-check";
    config false;
    list cc-session-statistics {
      key type; "type";
      leaf type {
        type identityref {
          base traffic-type;
        }
        description
          "Type of traffic.";
      }
      container cc-ipv4-sessions-statistics {
        when "../type = 'ipv4'" {
          description
            "Only applies when traffic type is IPv4.";
        }
        description
          "CC ipv4 sessions.";
        uses cc-session-statistics;
      }
      container cc-ipv6-sessions-statistics {
        when "../type = 'ipv6'" {
          description
            "Only applies when traffic type is IPv6.";
        }
        description
          "CC IPv6 sessions.";
        uses cc-session-statistics;
      }
      description
        "List of CC session statistics data.";
    }
    description
      "CC operational information.";
  }
}