module openconfig-rib-bgp-types {
  yang-version 1;
  namespace "http://openconfig.net/yang/rib/bgp-types";
  prefix oc-bgprib-types;

  import openconfig-extensions {
    prefix oc-ext;
  }

  organization
    "OpenConfig working group";
  contact
    "OpenConfig working group
     www.openconfig.net";
  description
    "Defines identity and type defintions associated with
     the OpenConfig BGP RIB modules";

  revision 2019-03-14 {
    description
      "Update last-modified timestamp to be expressed as nanoseconds
       since the Unix epoch.";
    reference
      "0.5.0";
  }
  revision 2019-02-27 {
    description
      "Remove top-level BGP RIB container, and update list
       names to be compatible with path compression.";
    reference
      "0.4.0";
  }
  revision 2018-11-21 {
    description
      "Add OpenConfig module metadata extensions.";
    reference
      "0.3.1";
  }
  revision 2016-10-17 {
    description
      "OpenConfig BGP RIB refactor";
    reference
      "0.3.0";
  }
  revision 2016-04-11 {
    description
      "OpenConfig public release";
    reference
      "0.2.0";
  }

  oc-ext:openconfig-version "0.5.0";
  oc-ext:regexp-posix;
  oc-ext:catalog-organization "openconfig";
  oc-ext:origin "openconfig";

  identity INVALID_ROUTE_REASON {
    description
      "Base identity for reason code for routes that are rejected as
       invalid.  Some derived entities are based on BMP v3";
    reference
      "BGP Monitoring Protocol (draft-ietf-grow-bmp-07)";
  }

  identity INVALID_CLUSTER_LOOP {
    base INVALID_ROUTE_REASON;
    description
      "Route was invalid due to CLUSTER_LIST loop";
  }

  identity INVALID_AS_LOOP {
    base INVALID_ROUTE_REASON;
    description
      "Route was invalid due to AS_PATH loop";
  }

  identity INVALID_ORIGINATOR {
    base INVALID_ROUTE_REASON;
    description
      "Route was invalid due to ORIGINATOR_ID, e.g., update has
       local router as originator";
  }

  identity INVALID_CONFED {
    base INVALID_ROUTE_REASON;
    description
      "Route was invalid due to a loop in the AS_CONFED_SEQUENCE or
       AS_CONFED_SET attributes";
  }

  identity BGP_NOT_SELECTED_BESTPATH {
    description
      "Base identity for indicating reason a route was was not
       selected by BGP route selection algorithm";
    reference
      "RFC 4271 - Section 9.1";
  }

  identity LOCAL_PREF_LOWER {
    base BGP_NOT_SELECTED_BESTPATH;
    description
      "Route has a lower localpref attribute than current best path";
    reference
      "RFC 4271 - Section 9.1.2";
  }

  identity AS_PATH_LONGER {
    base BGP_NOT_SELECTED_BESTPATH;
    description
      "Route has a longer AS path attribute than current best path";
    reference
      "RFC 4271 - Section 9.1.2.2 (a)";
  }

  identity ORIGIN_TYPE_HIGHER {
    base BGP_NOT_SELECTED_BESTPATH;
    description
      "Route has a higher origin type, i.e., IGP origin is preferred
       over EGP or incomplete";
    reference
      "RFC 4271 - Section 9.1.2.2 (b)";
  }

  identity MED_HIGHER {
    base BGP_NOT_SELECTED_BESTPATH;
    description
      "Route has a higher MED, or metric, attribute than the current
       best path";
    reference
      "RFC 4271 - Section 9.1.2.2 (c)";
  }

  identity PREFER_EXTERNAL {
    base BGP_NOT_SELECTED_BESTPATH;
    description
      "Route source is via IGP, rather than EGP.";
    reference
      "RFC 4271 - Section 9.1.2.2 (d)";
  }

  identity NEXTHOP_COST_HIGHER {
    base BGP_NOT_SELECTED_BESTPATH;
    description
      "Route has a higher interior cost to the next hop.";
    reference
      "RFC 4271 - Section 9.1.2.2 (e)";
  }

  identity HIGHER_ROUTER_ID {
    base BGP_NOT_SELECTED_BESTPATH;
    description
      "Route was sent by a peer with a higher BGP Identifier value,
       or router id";
    reference
      "RFC 4271 - Section 9.1.2.2 (f)";
  }

  identity HIGHER_PEER_ADDRESS {
    base BGP_NOT_SELECTED_BESTPATH;
    description
      "Route was sent by a peer with a higher IP address";
    reference
      "RFC 4271 - Section 9.1.2.2 (g)";
  }

  identity BGP_NOT_SELECTED_POLICY {
    description
      "Base identity for reason code for routes that are rejected
       due to policy";
  }

  identity REJECTED_IMPORT_POLICY {
    base BGP_NOT_SELECTED_POLICY;
    description
      "Route was rejected after apply import policies";
  }

  identity TUNNEL_ENCAPSULATION_TYPE {
    description
      "Types of tunnel encapsulation, as described by the Tunnel
       Encapsulation attribute";
    reference
      "RFC5512";
  }

  identity SRTE_POLICY_TUNNEL {
    base TUNNEL_ENCAPSULATION_TYPE;
    description
      "Segment Routing Traffic Engineering Policy tunnel.";
    reference
      "draft-previdi-idr-segment-routing-te-policy";
  }

  identity TUNNEL_ENCAPSULATION_SUBTLV_TYPE {
    description
      "SubTLVs of the Tunnel Encapsulation attribute";
    reference
      "RFC5512";
  }

  identity TUNNEL_REMOTE_ENDPOINT {
    base TUNNEL_ENCAPSULATION_SUBTLV_TYPE;
    description
      "Remote endpoint of the tunnel.";
    reference
      "RFC5512";
  }

  identity TUNNEL_COLOR {
    base TUNNEL_ENCAPSULATION_SUBTLV_TYPE;
    description
      "Colour of the tunnel";
    reference
      "RFC5512";
  }

  identity SRTE_PREFERENCE {
    base TUNNEL_ENCAPSULATION_SUBTLV_TYPE;
    description
      "Preference of the SR-TE policy entry described by
       the tunnel encapsulation attribute.";
    reference
      "draft-previdi-idr-segment-routing-te-policy";
  }

  identity SRTE_BINDING_SID {
    base TUNNEL_ENCAPSULATION_SUBTLV_TYPE;
    description
      "Binding SID to be used by the SR-TE policy described
       by the tunnel encapsulation attribute.";
    reference
      "draft-previdi-idr-segment-routing-te-policy";
  }

  identity SRTE_SEGMENT_LIST {
    base TUNNEL_ENCAPSULATION_SUBTLV_TYPE;
    description
      "Segment lists to be used by the SR-TE policy described
       by the tunnel encapsulation attribute.";
    reference
      "draft-previdi-idr-segment-routing-te-policy";
  }

  identity SRTE_SEGMENT_LIST_SUBTLV {
    description
      "SubTLVs of the SR-TE Policy Segment List sub-TLV of the
       Tunnel Encapsulation attribute.";
    reference
      "draft-previdi-idr-segment-routing-te-policy";
  }

  identity SRTE_SEGMENT_LIST_WEIGHT {
    base SRTE_SEGMENT_LIST_SUBTLV;
    description
      "Weight of the segment list within the SR-TE policy";
    reference
      "draft-previdi-idr-segment-routing-te-policy";
  }

  identity SRTE_SEGMENT_LIST_SEGMENT {
    base SRTE_SEGMENT_LIST_SUBTLV;
    description
      "An individual element within the SR-TE Policy Segment
       List.";
  }
}