Adding OpenConfig YANG models.

Change-Id: I0a2fdd5826e80933cf4b9ae939ff3051acec02aa
diff --git a/models/openconfig/src/main/yang/policy-forwarding/openconfig-pf-forwarding-policies.yang b/models/openconfig/src/main/yang/policy-forwarding/openconfig-pf-forwarding-policies.yang
new file mode 100644
index 0000000..48e9b19
--- /dev/null
+++ b/models/openconfig/src/main/yang/policy-forwarding/openconfig-pf-forwarding-policies.yang
@@ -0,0 +1,264 @@
+submodule openconfig-pf-forwarding-policies {
+  belongs-to openconfig-policy-forwarding {
+    prefix "oc-pf";
+  }
+
+  import openconfig-extensions { prefix "oc-ext"; }
+  import openconfig-packet-match { prefix "oc-pmatch"; }
+  import ietf-yang-types { prefix "yang"; }
+  import ietf-inet-types { prefix "inet"; }
+
+  include openconfig-pf-path-groups;
+
+  organization
+    "OpenConfig working group";
+
+  contact
+    "OpenConfig working group
+    www.openconfig.net";
+
+  description
+    "This submodule contains configuration and operational state
+    relating to the definition of policy-forwarding policies.";
+
+  oc-ext:openconfig-version "0.2.0";
+
+  revision "2017-06-21" {
+    description
+      "Amend policy forwarding model based on ACL changes.";
+    reference "0.2.0";
+  }
+
+  revision "2017-02-28" {
+    description
+      "Initial public release of policy forwarding.";
+    reference "0.1.0";
+  }
+
+  revision "2016-11-08" {
+    description
+      "Initial revision";
+    reference "0.0.1";
+  }
+
+  grouping pf-forwarding-policy-structural {
+    description
+      "Structural grouping defining forwarding policies under the
+      policy- forwarding module.";
+
+    container policies {
+      description
+        "Forwarding policies defined to enact policy-based forwarding
+        on the local system.";
+
+      list policy {
+        key "policy-id";
+
+        description
+          "A forwarding policy is defined to have a set of match
+          criteria, allowing particular fields of a packet's header to
+          be matched, and a set of forwarding actions which determines
+          how the local system should forward the packet.";
+
+        leaf policy-id {
+          type leafref {
+            path "../config/policy-id";
+          }
+          description
+            "Reference to the identifier for the forwarding-policy.";
+        }
+
+        container config {
+          description
+            "Configuration options relating to the forwarding
+            policy.";
+          uses pf-forwarding-policy-config;
+        }
+
+        container state {
+          config false;
+          description
+            "Operational state parameters relating to the forwarding
+            policy.";
+          uses pf-forwarding-policy-config;
+        }
+
+        container rules {
+          description
+            "The criteria that should be matched for a packet to be
+            forwarded according to the policy action.";
+
+          list rule {
+            key "sequence-id";
+
+            description
+              "A match rule for the policy. In the case that multiple
+              criteria are specified within a single ";
+
+            leaf sequence-id {
+              type leafref {
+                path "../config/sequence-id";
+              }
+              description
+                "A unique sequence identifier for the match rule.";
+            }
+
+            container config {
+              description
+                "Configuration parameters relating to the match
+                rule.";
+              uses pf-forwarding-policy-rule-config;
+            }
+
+            container state {
+              config false;
+              description
+                "Operational state parameters relating to the match
+                rule.";
+              uses pf-forwarding-policy-rule-config;
+              uses pf-forwarding-policy-rule-state;
+            }
+
+            uses oc-pmatch:ethernet-header-top;
+            uses oc-pmatch:ipv4-protocol-fields-top;
+            uses oc-pmatch:ipv6-protocol-fields-top;
+            uses oc-pmatch:transport-fields-top;
+
+            container action {
+              description
+                "The forwarding policy action to be applied for
+                packets matching the rule.";
+
+              container config {
+                description
+                  "Configuration parameters relating to the forwarding
+                  rule's action.";
+                uses pf-forwarding-policy-action-config;
+              }
+
+              container state {
+                config false;
+                description
+                  "Operational state parameters relating to the
+                  forwarding rule's action.";
+                uses pf-forwarding-policy-action-config;
+              }
+
+            }
+          }
+        }
+      }
+    }
+  }
+
+  grouping pf-forwarding-policy-config {
+    description
+      "Configuration parameters relating to the forwarding policy.";
+
+    leaf policy-id {
+      type string;
+      description
+        "A unique name identifying the forwarding policy. This name is
+        used when applying the policy to a particular interface.";
+    }
+  }
+
+  grouping pf-forwarding-policy-rule-config {
+    description
+      "Configuration parameters relating to a policy rule.";
+
+    leaf sequence-id {
+      type uint32;
+      description
+        "Unique sequence number for the policy rule.";
+    }
+  }
+
+  grouping pf-forwarding-policy-rule-state {
+    description
+      "Operational state parameters relating to a policy rule.";
+
+    leaf matched-pkts {
+      type yang:counter64;
+      description
+        "Number of packets matched by the rule.";
+    }
+
+    leaf matched-octets {
+      type yang:counter64;
+      description
+        "Bytes matched by the rule.";
+    }
+  }
+
+  grouping pf-forwarding-policy-action-config {
+    description
+      "Forwarding policy action configuration parameters.";
+
+    leaf discard {
+      type boolean;
+      default false;
+      description
+        "When this leaf is set to true, the local system should drop
+        packets that match the rule.";
+    }
+
+    leaf decapsulate-gre {
+      type boolean;
+      default false;
+      description
+        "When this leaf is set to true, the local system should remove
+        the GRE header from the packet matching the rule. Following
+        the decapsulation it should subsequently forward the
+        encapsulated packet according to the relevant lookup (e.g., if
+        the encapsulated packet is IP, the packet should be routed
+        according to the IP destination).";
+    }
+
+    leaf network-instance {
+      type leafref {
+
+        // We are at:
+        // $NIROOT/policy-forwarding/policies/
+        // policy/rules/rule/action/config/
+        // network-instance
+        path "../../../../../../../../config/name";
+      }
+      description
+        "When this leaf is set, packets matching the match criteria
+        for the forwarding rule should be looked up in the
+        network-instance that is referenced rather than the
+        network-instance with which the interface is associated.
+        Such configuration allows policy-routing into multiple
+        sub-topologies from a single ingress access interface, or
+        different send and receive contexts for a particular
+        interface (sometimes referred to as half-duplex VRF).";
+    }
+
+    leaf path-selection-group {
+      type leafref {
+        // We are at:
+        // $NIROOT/policy-forwarding/policies/
+        // policy/rules/rule/action/config/to-path-group
+        path "../../../../../../../path-selection-groups/" +
+             "path-selection-group/config/group-id";
+      }
+      description
+        "When path-selection-group is set, packets matching the
+        match criteria for the forwarding rule should be forwarded
+        only via one of the paths that is specified within the
+        referenced path-selection-group. The next-hop of the packet
+        within the routing context should be used to determine between
+        multiple paths that are specified within the group.";
+    }
+
+    leaf next-hop {
+      type inet:ip-address-no-zone;
+      description
+        "When an IP next-hop is specified in the next-hop field,
+        packets matching the match criteria for the forwarding rule
+        should be forwarded to the next-hop IP address, bypassing any
+        lookup on the local system.";
+    }
+  }
+}
diff --git a/models/openconfig/src/main/yang/policy-forwarding/openconfig-pf-interfaces.yang b/models/openconfig/src/main/yang/policy-forwarding/openconfig-pf-interfaces.yang
new file mode 100644
index 0000000..41ba545
--- /dev/null
+++ b/models/openconfig/src/main/yang/policy-forwarding/openconfig-pf-interfaces.yang
@@ -0,0 +1,121 @@
+submodule openconfig-pf-interfaces {
+  belongs-to openconfig-policy-forwarding {
+    prefix "oc-pf";
+  }
+
+  import openconfig-extensions { prefix "oc-ext"; }
+  import openconfig-interfaces { prefix "oc-if"; }
+
+  include openconfig-pf-forwarding-policies;
+
+  organization
+    "OpenConfig working group";
+
+  contact
+    "OpenConfig working group
+    www.openconfig.net";
+
+  description
+    "This submodule contains groupings related to the association
+    between interfaces and policy forwarding rules.";
+
+  oc-ext:openconfig-version "0.2.0";
+
+  revision "2017-06-21" {
+    description
+      "Amend policy forwarding model based on ACL changes.";
+    reference "0.2.0";
+  }
+
+  revision "2017-02-28" {
+    description
+      "Initial public release of policy forwarding.";
+    reference "0.1.0";
+  }
+
+  revision "2016-11-08" {
+    description
+      "Initial revision";
+    reference "0.0.1";
+  }
+
+
+  grouping pf-interfaces-structural {
+    description
+      "Structural grouping for interface to forwarding policy bindings
+      within the policy-forwarding model.";
+
+    container interfaces {
+      description
+        "Configuration and operational state relating policy
+        forwarding on interfaces.";
+
+      list interface {
+        key "interface-id";
+
+        description
+          "Configuration and operationals state relating to the
+          relationship between interfaces and policy-based forwarding
+          rules.";
+
+        leaf interface-id {
+          type leafref {
+            path "../config/interface-id";
+          }
+          description
+            "A reference to the unique identifier for the interface
+            being referenced by the policy.";
+        }
+
+        container config {
+          description
+            "Configuration parameters relating to an interface to
+            policy forwarding rule binding.";
+
+          uses pf-interface-config;
+        }
+
+        container state {
+          config false;
+          description
+            "Operational state parameters relating to an interface to
+            policy forwarding rule binding.";
+
+          uses pf-interface-config;
+        }
+
+        uses oc-if:interface-ref;
+      }
+    }
+  }
+
+  grouping pf-interface-config {
+    description
+      "Configuration parameters relating to an interface to policy
+      forwarding rule binding.";
+
+    leaf interface-id {
+      type oc-if:interface-id;
+      description
+        "A unique identifier for the interface.";
+    }
+
+    leaf apply-forwarding-policy {
+      type leafref {
+        // We are at /network-instances/network-instance/
+        // policy-forwarding/interfaces/interface/config/
+        // apply-forwarding-policy
+        path "../../../../policies/policy/" +
+             "config/policy-id";
+      }
+      description
+        "The policy to be applied on the interface. Packets ingress on
+        the referenced interface should be compared to the match
+        criteria within the specified policy, and in the case that
+        these criteria are met, the forwarding actions specified
+        applied. These policies should be applied following quality of
+        service classification, and ACL actions if such entities are
+        referenced by the corresponding interface.";
+    }
+  }
+}
diff --git a/models/openconfig/src/main/yang/policy-forwarding/openconfig-pf-path-groups.yang b/models/openconfig/src/main/yang/policy-forwarding/openconfig-pf-path-groups.yang
new file mode 100644
index 0000000..d97e8df
--- /dev/null
+++ b/models/openconfig/src/main/yang/policy-forwarding/openconfig-pf-path-groups.yang
@@ -0,0 +1,122 @@
+submodule openconfig-pf-path-groups {
+  belongs-to openconfig-policy-forwarding {
+    prefix "oc-pf";
+  }
+
+  import openconfig-extensions { prefix "oc-ext"; }
+
+  organization
+    "OpenConfig working group";
+
+  contact
+    "OpenConfig working group
+    www.openconfig.net";
+
+  description
+    "This submodule contains configuration and operational state
+    relating to path-selection-groups which are used to group
+    forwarding entities together to be used as policy forwarding
+    targets.";
+
+  oc-ext:openconfig-version "0.2.0";
+
+  revision "2017-06-21" {
+    description
+      "Amend policy forwarding model based on ACL changes.";
+    reference "0.2.0";
+  }
+
+  revision "2017-02-28" {
+    description
+      "Initial public release of policy forwarding.";
+    reference "0.1.0";
+  }
+
+  revision "2016-11-08" {
+    description
+      "Initial revision";
+    reference "0.0.1";
+  }
+
+  grouping pf-path-groups-structural {
+    description
+      "Structural grouping containing the definition of path groups
+      within the context of policy-based forwarding.";
+
+    container path-selection-groups {
+      description
+        "Surrounding container for the path selection groups defined
+        within the policy forwarding model.";
+
+      list path-selection-group {
+        key "group-id";
+
+        leaf group-id {
+          type leafref {
+            path "../config/group-id";
+          }
+          description
+            "Reference to a unique identifier for the path selection
+            group";
+
+        }
+
+        description
+          "A path selection group is a set of forwarding resources,
+          which are grouped as eligible paths for a particular
+          policy-based forwarding rule. A policy rule may select a
+          path-selection-group as the egress for a particular type of
+          traffic (e.g., DSCP value). The system then utilises its
+          standard forwarding lookup mechanism to select from the
+          paths that are specified within the group - for IP packets,
+          the destination IP address is used such that the packet is
+          routed to the entity within the path-selection-group that
+          corresponds to the next-hop for the destination IP address
+          of the packet; for L2 packets, the selection is based on the
+          destination MAC address.";
+
+        container config {
+          description
+            "Configuration parameters relating to the path selection
+            group.";
+          uses pf-path-selection-group-config;
+        }
+
+        container state {
+          config false;
+          description
+            "Operational state parameters relating to the path
+            selection group.";
+          uses pf-path-selection-group-config;
+        }
+      }
+    }
+  }
+
+  grouping pf-path-selection-group-config {
+    description
+      "Configuration parameters relating to a path selection group.";
+
+    leaf group-id {
+      type string;
+      description
+        "A unique name for the path-selection-group";
+    }
+
+    leaf-list mpls-lsp {
+      type leafref {
+        // We are at /network-instances/network-instance/
+        // policy-forwarding/path-selection-groups/
+        // path-selection-group/config/mpls-lsp
+        path "../../../../../mpls/lsps/constrained-path/tunnels/" +
+             "tunnel/config/name";
+      }
+      description
+        "A set of MPLS constrained-path LSPs which should be
+        considered for the policy forwarding next-hop. In order to
+        select between the LSPs within the path-selection-group, the
+        system should determine which LSP provides the best path to
+        the next-hop for the routed packet.";
+    }
+  }
+}
diff --git a/models/openconfig/src/main/yang/policy-forwarding/openconfig-policy-forwarding.yang b/models/openconfig/src/main/yang/policy-forwarding/openconfig-policy-forwarding.yang
new file mode 100644
index 0000000..63dbf78
--- /dev/null
+++ b/models/openconfig/src/main/yang/policy-forwarding/openconfig-policy-forwarding.yang
@@ -0,0 +1,119 @@
+module openconfig-policy-forwarding {
+  yang-version "1";
+
+  namespace "http://openconfig.net/yang/policy-forwarding";
+
+  prefix "oc-pf";
+
+  import openconfig-extensions { prefix "oc-ext"; }
+
+  // Include submodules.
+  include openconfig-pf-forwarding-policies;
+  include openconfig-pf-path-groups;
+  include openconfig-pf-interfaces;
+
+  organization
+    "OpenConfig working group";
+
+  contact
+    "OpenConfig working group
+    www.openconfig.net";
+
+  description
+    "This module defines configuration and operational state data
+    relating to policy-based forwarding. Policy-based forwarding is
+    utilised when a system chooses how to forward packets (including
+    applying data-plane operations such as encapsulation or
+    decapsulation) based on policies other than destination L2 or L3
+    header. Typically, systems may implement:
+
+     - IP policy-based routing, where routing may be done based on the
+       source plus destination of an IP packet; information within the
+       L4 header; or some combination of both.
+     - Encapsulation or decapsulation based on certain policy
+       information - for example, matching particular IP destinations
+       and decapsulating GRE headers.
+     - Class-based selection of egress routes - such as class-based
+       selection of an egress MPLS path.
+
+    The policies that are defined in this model are applied to a
+    particular ingress context of a network element (e.g., interface)
+    and are defined to apply following other interface policy such as
+    QoS classification and access control lists.
+
+    This module defines:
+
+     - policy-forwarding
+    |
+    |--- policies
+    |    |-- policy
+    |        |-- [match criteria]    How packets are defined to
+    |        |                       match policy.
+    |        |-- [forwarding-action] How packets matching should
+    |                                 be forwarded.
+    |--- interfaces
+    |    |-- interfaces
+    |        | -- apply-forwarding-policy  Forwarding policy to
+    |                                      used on the interface.
+    |--- path-selection-groups
+         |-- path-selection-group     A group of forwarding resources
+                                      that are grouped for purposes
+                                      of next-hop selection.
+
+    A forwarding-policy specifies the match criteria that it intends
+    to use to determine the packets that it reroutes - this may
+    consist of a number of criteria, such as DSCP. The action of the
+    policy results in a forwarding action being applied to matching
+    packets. For example, decapsulating the packet from a GRE header.
+    In order to enact the policy based on particular interfaces - the
+    forwarding-policy is applied to an interface via referencing it
+    within an 'apply-forwarding-policy' statement associated with an
+    interface.
+
+    In some cases (e.g., Class-Based Tunnel Selection) the forwarding
+    action does not resolve to a single egress action, and rather
+    normal forwarding rules are to be applied but considering a subset
+    of forwarding resources. In these cases, a path-selection-group
+    can be created, referencing the subset of forwarding paths that
+    should be used for the egress selection. In the case that a subset
+    of MPLS LSPs are eligible for, say, DSCP 46 marked packets, a
+    path-selection-group is created, referencing the subset of LSPs.
+    The forwarding action of the corresponding policy is set to
+    PATH_GROUP and references the configured group of LSPs.";
+
+  oc-ext:openconfig-version "0.2.0";
+
+  revision "2017-06-21" {
+    description
+      "Amend policy forwarding model based on ACL changes.";
+    reference "0.2.0";
+  }
+
+  revision "2017-02-28" {
+    description
+      "Initial public release of policy forwarding.";
+    reference "0.1.0";
+  }
+
+  revision "2016-11-08" {
+    description
+      "Initial revision.";
+    reference "0.0.1";
+  }
+
+
+  grouping policy-forwarding-top {
+    description
+      "Top-level grouping for Policy Forwarding";
+
+    container policy-forwarding {
+      description
+        "Configuration and operational state relating to policy-forwarding within
+        a network instance.";
+
+      uses pf-forwarding-policy-structural;
+      uses pf-interfaces-structural;
+      uses pf-path-groups-structural;
+    }
+  }
+}