SEBA-815 Multi Tcont support by OLT app.
Change-Id: I024ef2fcb3d3e59cc86bd2088726ae513fcff796
diff --git a/app/src/main/java/org/opencord/olt/internalapi/AccessDeviceFlowService.java b/app/src/main/java/org/opencord/olt/internalapi/AccessDeviceFlowService.java
new file mode 100644
index 0000000..362b154
--- /dev/null
+++ b/app/src/main/java/org/opencord/olt/internalapi/AccessDeviceFlowService.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.opencord.olt.internalapi;
+
+import org.onlab.packet.VlanId;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.flowobjective.ForwardingObjective;
+import org.onosproject.net.flowobjective.ObjectiveError;
+import org.onosproject.net.meter.MeterId;
+import org.opencord.sadis.UniTagInformation;
+
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Olt service for flow operations.
+ */
+public interface AccessDeviceFlowService {
+
+ /**
+ * Provisions or removes trap-to-controller DHCP packets.
+ *
+ * @param devId the target device identifier
+ * @param port the uni port for which this trap flow is designated
+ * @param upstreamMeterId the upstream meter id that includes the upstream
+ * bandwidth profile values such as PIR,CIR. If no meter id needs to be referenced,
+ * null can be sent
+ * @param tagInformation the uni tag (ctag, stag) information
+ * @param install true to install the flow, false to remove the flow
+ * @param upstream true if trapped packets are flowing upstream towards
+ * server, false if packets are flowing downstream towards client
+ */
+ void processDhcpFilteringObjectives(DeviceId devId, PortNumber port,
+ MeterId upstreamMeterId,
+ UniTagInformation tagInformation,
+ boolean install,
+ boolean upstream);
+
+ /**
+ * Trap igmp packets to the controller.
+ *
+ * @param devId Device identifier to send the flow
+ * @param port Uni Port number
+ * @param upstreamMeterId upstream meter id that represents the upstream bandwidth profile
+ * @param tagInformation the uni tag information of the subscriber
+ * @param install the indicator to install or to remove the flow
+ * @param upstream determines the direction of the flow
+ */
+ void processIgmpFilteringObjectives(DeviceId devId, PortNumber port,
+ MeterId upstreamMeterId,
+ UniTagInformation tagInformation,
+ boolean install,
+ boolean upstream);
+
+ /**
+ * Trap eapol authentication packets to the controller.
+ *
+ * @param devId the device identifier
+ * @param portNumber the port for which this trap flow is designated
+ * @param bpId bandwidth profile id to add the related meter to the flow
+ * @param filterFuture completable future for this filtering objective operation
+ * @param vlanId the default or customer tag for a subscriber
+ * @param install true to install the flow, false to remove the flow
+ */
+ void processEapolFilteringObjectives(DeviceId devId, PortNumber portNumber, String bpId,
+ CompletableFuture<ObjectiveError> filterFuture,
+ VlanId vlanId, boolean install);
+
+ /**
+ * Trap lldp packets to the controller.
+ *
+ * @param devId the device identifier
+ * @param port the port for which this trap flow is designated
+ * @param install true to install the flow, false to remove the flow
+ */
+ void processLldpFilteringObjective(DeviceId devId, PortNumber port, boolean install);
+
+ /**
+ * Installs trap filtering objectives for particular traffic types (LLDP, IGMP and DHCP) on an
+ * NNI port.
+ *
+ * @param devId device ID
+ * @param port port number
+ * @param install true to install, false to remove
+ */
+ void processNniFilteringObjectives(DeviceId devId, PortNumber port, boolean install);
+
+ /**
+ * Creates a ForwardingObjective builder with double-tag match criteria and output
+ * action. The treatment will not contain pop or push actions.
+ * If the last parameter is true, use the upstream meter id and vice versa.
+ *
+ * @param uplinkPort the nni port
+ * @param subscriberPort the uni port
+ * @param meterId the meter id that is assigned to upstream or downstream flows
+ * @param tagInfo the uni tag information
+ * @param upstream true to create upstream, false to create downstream builder
+ * @return ForwardingObjective.Builder
+ */
+ ForwardingObjective.Builder createTransparentBuilder(PortNumber uplinkPort,
+ PortNumber subscriberPort,
+ MeterId meterId,
+ UniTagInformation tagInfo,
+ boolean upstream);
+
+ /**
+ * Creates a ForwardingObjective builder for the upstream flows.
+ * The treatment will contain push action
+ *
+ * @param uplinkPort the nni port
+ * @param subscriberPort the uni port
+ * @param upstreamMeterId the meter id that is assigned to upstream flows
+ * @param uniTagInformation the uni tag information
+ * @return ForwardingObjective.Builder
+ */
+ ForwardingObjective.Builder createUpBuilder(PortNumber uplinkPort,
+ PortNumber subscriberPort,
+ MeterId upstreamMeterId,
+ UniTagInformation uniTagInformation);
+
+ /**
+ * Creates a ForwardingObjective builder for the downstream flows.
+ * The treatment will contain pop action
+ *
+ * @param uplinkPort the nni port
+ * @param subscriberPort the uni port
+ * @param downstreamMeterId the meter id that is assigned to downstream flows
+ * @param tagInformation the uni tag information
+ * @return ForwardingObjective.Builder
+ */
+ ForwardingObjective.Builder createDownBuilder(PortNumber uplinkPort,
+ PortNumber subscriberPort,
+ MeterId downstreamMeterId,
+ UniTagInformation tagInformation);
+}
diff --git a/app/src/main/java/org/opencord/olt/internalapi/AccessDeviceMeterService.java b/app/src/main/java/org/opencord/olt/internalapi/AccessDeviceMeterService.java
new file mode 100644
index 0000000..d2d51b2
--- /dev/null
+++ b/app/src/main/java/org/opencord/olt/internalapi/AccessDeviceMeterService.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.opencord.olt.internalapi;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.meter.MeterId;
+import org.onosproject.net.meter.MeterKey;
+import org.opencord.sadis.BandwidthProfileInformation;
+
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Olt service for meter operations.
+ */
+public interface AccessDeviceMeterService {
+
+ /**
+ * Returns information about bandwidthProfile-meterKey (device / meter) mappings
+ * that have been programmed in the data-plane.
+ *
+ * @return an immutable map of bandwidthProfile-meterKey (device / meter) mappings
+ */
+ ImmutableMap<String, Set<MeterKey>> getBpMeterMappings();
+
+ /**
+ * Adds a bandwidthProfile-meterKey (device / meter) mapping that have been programmed
+ * in the data plane.
+ *
+ * @param deviceId the access device id
+ * @param meterId the meter id that is mapped to the bandwidth profile
+ * @param bandwidthProfile the bandwidth profile id
+ */
+ void addMeterIdToBpMapping(DeviceId deviceId, MeterId meterId, String bandwidthProfile);
+
+ /**
+ * Returns the meter id for a given bandwidth profile.
+ *
+ * @param deviceId the access device id
+ * @param bandwidthProfile the bandwidth profile id
+ * @return the meter id
+ */
+ MeterId getMeterIdFromBpMapping(DeviceId deviceId, String bandwidthProfile);
+
+ /**
+ * Returns information about device-meter relations that have been programmed in the
+ * data-plane.
+ *
+ * @return an immutable set of device-meter mappings
+ */
+ ImmutableSet<MeterKey> getProgMeters();
+
+ /**
+ * Creates a meter and sends it to the device.
+ *
+ * @param deviceId the access device id
+ * @param bpInfo the bandwidth profile information
+ * @param meterFuture the meter future to indicate whether the meter creation is
+ * successful or not.
+ * @return meter id that is generated for the given parameters
+ */
+ MeterId createMeter(DeviceId deviceId, BandwidthProfileInformation bpInfo,
+ CompletableFuture<Object> meterFuture);
+
+
+}
diff --git a/app/src/main/java/org/opencord/olt/internalapi/package-info.java b/app/src/main/java/org/opencord/olt/internalapi/package-info.java
new file mode 100644
index 0000000..2b5d98d
--- /dev/null
+++ b/app/src/main/java/org/opencord/olt/internalapi/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Internal APIs for the OLT application.
+ */
+package org.opencord.olt.internalapi;