diff options
Diffstat (limited to 'framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc')
13 files changed, 0 insertions, 883 deletions
diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/forwarder/ServiceFunctionForwarderService.java b/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/forwarder/ServiceFunctionForwarderService.java deleted file mode 100644 index 0ed42fcf..00000000 --- a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/forwarder/ServiceFunctionForwarderService.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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.onosproject.sfc.forwarder; - -import org.onosproject.net.flowobjective.Objective; -import org.onosproject.net.NshServicePathId; -import org.onosproject.vtnrsc.PortChain; - -/** - * Abstraction of an entity which provides Service function forwarder. - */ -public interface ServiceFunctionForwarderService { - - /** - * Install Forwarding rule. - * - * @param portChain port-chain - * @param nshSPI nsh spi - */ - void installForwardingRule(PortChain portChain, NshServicePathId nshSPI); - - /** - * Uninstall Forwarding rule. - * - * @param portChain port-chain - * @param nshSPI nsh spi - */ - void unInstallForwardingRule(PortChain portChain, NshServicePathId nshSPI); - - /** - * Prepare forwarding object for Service Function. - * - * @param portChain port-chain - * @param nshSPI nsh spi - * @param type forwarding objective operation type - */ - void prepareServiceFunctionForwarder(PortChain portChain, NshServicePathId nshSPI, Objective.Operation type); -} diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/forwarder/impl/ServiceFunctionForwarderImpl.java b/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/forwarder/impl/ServiceFunctionForwarderImpl.java deleted file mode 100644 index 2846ee01..00000000 --- a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/forwarder/impl/ServiceFunctionForwarderImpl.java +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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.onosproject.sfc.forwarder.impl; - -import static org.slf4j.LoggerFactory.getLogger; -import static org.onosproject.net.flow.criteria.ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; -import java.util.ListIterator; - -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.ReferenceCardinality; -import org.onlab.osgi.DefaultServiceDirectory; -import org.onlab.osgi.ServiceDirectory; -import org.onlab.packet.MacAddress; -import org.onlab.packet.VlanId; -import org.onosproject.core.ApplicationId; -import org.onosproject.net.behaviour.ExtensionSelectorResolver; -import org.onosproject.net.DeviceId; -import org.onosproject.net.NshServicePathId; -import org.onosproject.net.driver.DriverHandler; -import org.onosproject.net.driver.DriverService; -import org.onosproject.net.flow.DefaultTrafficSelector; -import org.onosproject.net.flow.DefaultTrafficTreatment; -import org.onosproject.net.flow.criteria.ExtensionSelector; -import org.onosproject.net.flow.TrafficSelector; -import org.onosproject.net.flow.TrafficTreatment; -import org.onosproject.net.flowobjective.DefaultForwardingObjective; -import org.onosproject.net.flowobjective.FlowObjectiveService; -import org.onosproject.net.flowobjective.ForwardingObjective; -import org.onosproject.net.flowobjective.Objective; -import org.onosproject.net.flowobjective.ForwardingObjective.Flag; -import org.onosproject.vtnrsc.VirtualPortId; -import org.onosproject.vtnrsc.service.VtnRscService; -import org.onosproject.vtnrsc.PortChain; -import org.onosproject.vtnrsc.PortPair; -import org.onosproject.vtnrsc.PortPairGroup; -import org.onosproject.vtnrsc.PortPairGroupId; -import org.onosproject.vtnrsc.PortPairId; -import org.onosproject.vtnrsc.virtualport.VirtualPortService; -import org.onosproject.vtnrsc.portpair.PortPairService; -import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService; -import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService; -import org.onosproject.vtnrsc.portchain.PortChainService; -import org.onosproject.sfc.forwarder.ServiceFunctionForwarderService; - -import org.slf4j.Logger; - -/** - * Provides Service Function Forwarder implementation. - */ -public class ServiceFunctionForwarderImpl implements ServiceFunctionForwarderService { - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected DriverService driverService; - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected VirtualPortService virtualPortService; - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected VtnRscService vtnRscService; - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected PortPairService portPairService; - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected PortPairGroupService portPairGroupService; - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected FlowClassifierService flowClassifierService; - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected PortChainService portChainService; - - private final Logger log = getLogger(getClass()); - protected ApplicationId appId; - protected FlowObjectiveService flowObjectiveService; - - private static final String DRIVER_NAME = "onosfw"; - private static final String PORT_CHAIN_NOT_NULL = "Port-Chain cannot be null"; - private static final String PORT_CHAIN_ID_NOT_NULL = "Port-Chain-Id cannot be null"; - private static final String APP_ID_NOT_NULL = "Application-Id cannot be null"; - private static final int NULL = 0; - - /** - * Default constructor. - */ - public ServiceFunctionForwarderImpl() { - } - - /** - * Explicit constructor. - */ - public ServiceFunctionForwarderImpl(ApplicationId appId) { - this.appId = checkNotNull(appId, APP_ID_NOT_NULL); - ServiceDirectory serviceDirectory = new DefaultServiceDirectory(); - this.flowObjectiveService = serviceDirectory.get(FlowObjectiveService.class); - } - - @Override - public void installForwardingRule(PortChain portChain, NshServicePathId nshSPI) { - checkNotNull(portChain, PORT_CHAIN_NOT_NULL); - prepareServiceFunctionForwarder(portChain, nshSPI, Objective.Operation.ADD); - } - - @Override - public void unInstallForwardingRule(PortChain portChain, NshServicePathId nshSPI) { - checkNotNull(portChain, PORT_CHAIN_NOT_NULL); - prepareServiceFunctionForwarder(portChain, nshSPI, Objective.Operation.REMOVE); - } - - @Override - public void prepareServiceFunctionForwarder(PortChain portChain, NshServicePathId nshSPI, - Objective.Operation type) { - - // Go through the port pair group list - List<PortPairGroupId> portPairGrpList = portChain.portPairGroups(); - ListIterator<PortPairGroupId> listGrpIterator = portPairGrpList.listIterator(); - - // Get source port pair group - if (!listGrpIterator.hasNext()) { - return; - } - PortPairGroupId portPairGrpId = listGrpIterator.next(); - PortPairGroup currentPortPairGroup = portPairGroupService.getPortPairGroup(portPairGrpId); - - // Get destination port pair group - if (!listGrpIterator.hasNext()) { - return; - } - portPairGrpId = listGrpIterator.next(); - PortPairGroup nextPortPairGroup = portPairGroupService.getPortPairGroup(portPairGrpId); - - // push SFF to OVS - pushServiceFunctionForwarder(currentPortPairGroup, nextPortPairGroup, listGrpIterator, nshSPI, type); - } - - /** - * Push service-function-forwarder to OVS. - * - * @param currentPortPairGroup current port-pair-group - * @param nextPortPairGroup next port-pair-group - * @param listGrpIterator pointer to port-pair-group list - */ - public void pushServiceFunctionForwarder(PortPairGroup currentPortPairGroup, PortPairGroup nextPortPairGroup, - ListIterator<PortPairGroupId> listGrpIterator, NshServicePathId nshSPI, Objective.Operation type) { - MacAddress srcMacAddress = null; - MacAddress dstMacAddress = null; - DeviceId deviceId = null; - DeviceId currentDeviceId = null; - DeviceId nextDeviceId = null; - PortPairGroupId portPairGrpId = null; - - // Travel from SF to SF. - do { - // Get the required information on port pairs from source port pair - // group - List<PortPairId> portPairList = currentPortPairGroup.portPairs(); - ListIterator<PortPairId> portPLIterator = portPairList.listIterator(); - if (!portPLIterator.hasNext()) { - break; - } - - PortPairId portPairId = portPLIterator.next(); - PortPair portPair = portPairService.getPortPair(portPairId); - - currentDeviceId = vtnRscService.getSFToSFFMaping(VirtualPortId.portId(portPair.ingress())); - if (deviceId == null) { - deviceId = currentDeviceId; - } - srcMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress())).macAddress(); - dstMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.egress())).macAddress(); - - // pack traffic selector - TrafficSelector.Builder selector = packTrafficSelector(deviceId, srcMacAddress, dstMacAddress, nshSPI); - - // Get the required information on port pairs from destination port - // pair group - portPairList = nextPortPairGroup.portPairs(); - portPLIterator = portPairList.listIterator(); - if (!portPLIterator.hasNext()) { - break; - } - - portPairId = portPLIterator.next(); - portPair = portPairService.getPortPair(portPairId); - - nextDeviceId = vtnRscService.getSFToSFFMaping(VirtualPortId.portId(portPair.ingress())); - - // pack traffic treatment - TrafficTreatment.Builder treatment = packTrafficTreatment(currentDeviceId, nextDeviceId, portPair); - - // Send SFF to OVS - sendServiceFunctionForwarder(selector, treatment, deviceId, type); - - // Replace source port pair group with destination port pair group - // for moving to next SFF processing. - currentPortPairGroup = nextPortPairGroup; - if (!listGrpIterator.hasNext()) { - break; - } - portPairGrpId = listGrpIterator.next(); - nextPortPairGroup = portPairGroupService.getPortPairGroup(portPairGrpId); - } while (true); - } - - /** - * Pack Traffic selector. - * - * @param deviceId device id - * @param srcMacAddress source mac-address - * @param dstMacAddress destination mac-address - * @param nshSPI nsh spi - * @return traffic treatment - */ - public TrafficSelector.Builder packTrafficSelector(DeviceId deviceId, MacAddress srcMacAddress, - MacAddress dstMacAddress, NshServicePathId nshSPI) { - TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); - selector.matchEthSrc(srcMacAddress); - selector.matchEthDst(dstMacAddress); - - DriverHandler handler = driverService.createHandler(deviceId); - ExtensionSelectorResolver resolver = handler.behaviour(ExtensionSelectorResolver.class); - ExtensionSelector nspSpiSelector = resolver.getExtensionSelector(NICIRA_MATCH_NSH_SPI.type()); - - try { - nspSpiSelector.setPropertyValue("nshSpi", nshSPI); - } catch (Exception e) { - log.error("Failed to get extension instruction to set Nsh Spi Id {}", deviceId); - } - - selector.extension(nspSpiSelector, deviceId); - return selector; - } - - /** - * Pack Traffic treatment. - * - * @param currentDeviceId current device id - * @param nextDeviceId next device id - * @param portPair port-pair - * @return traffic treatment - */ - public TrafficTreatment.Builder packTrafficTreatment(DeviceId currentDeviceId, DeviceId nextDeviceId, - PortPair portPair) { - MacAddress srcMacAddress = null; - MacAddress dstMacAddress = null; - - // Check the treatment whether destination SF is on same OVS or in - // different OVS. - TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); - if (currentDeviceId.equals(nextDeviceId)) { - srcMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress())).macAddress(); - dstMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.egress())).macAddress(); - treatment.setEthSrc(srcMacAddress); - treatment.setEthDst(dstMacAddress); - } else { - treatment.setVlanId(VlanId.vlanId(Short.parseShort((vtnRscService.getL3vni(portPair - .tenantId()).toString())))); - } - - return treatment; - } - - /** - * Send service function forwarder to OVS. - * - * @param selector traffic selector - * @param treatment traffic treatment - * @param deviceId device id - * @param type operation type - */ - public void sendServiceFunctionForwarder(TrafficSelector.Builder selector, TrafficTreatment.Builder treatment, - DeviceId deviceId, Objective.Operation type) { - ForwardingObjective.Builder objective = DefaultForwardingObjective.builder().withTreatment(treatment.build()) - .withSelector(selector.build()).fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC); - if (type.equals(Objective.Operation.ADD)) { - log.debug("ADD"); - flowObjectiveService.forward(deviceId, objective.add()); - } else { - log.debug("REMOVE"); - flowObjectiveService.forward(deviceId, objective.remove()); - } - } -} diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/forwarder/impl/package-info.java b/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/forwarder/impl/package-info.java deleted file mode 100644 index 02221196..00000000 --- a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/forwarder/impl/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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. - */ - -/** - * SFC Service manager for interacting with SFC. - */ -package org.onosproject.sfc.forwarder.impl; diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/forwarder/package-info.java b/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/forwarder/package-info.java deleted file mode 100644 index 08021f3c..00000000 --- a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/forwarder/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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. - */ - -/** - * Service function forwarder for SFC. - */ -package org.onosproject.sfc.forwarder; diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/FlowClassifierInstaller.java b/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/FlowClassifierInstaller.java deleted file mode 100644 index f05a21dc..00000000 --- a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/FlowClassifierInstaller.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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.onosproject.sfc.installer; - -import org.onosproject.core.ApplicationId; -import org.onosproject.net.flowobjective.Objective; -import org.onosproject.vtnrsc.FlowClassifier; -import org.onosproject.vtnrsc.PortPair; - -/** - * Abstraction of an entity which installs flow classification rules in ovs. - */ -public interface FlowClassifierInstaller { - - /** - * Install flow classifier rules. - * - * @param flowClassifier Flow Classifier - * @param portPair Port pair - */ - void install(FlowClassifier flowClassifier, PortPair portPair); - - /** - * Programs forwarding object for flow classifier. - * - * @param flowClassifier flow classifier - * @param portPair port pair - * @param appid application id - * @param type forwarding objective operation type - */ - void programFlowClassification(FlowClassifier flowClassifier, PortPair portPair, ApplicationId appid, - Objective.Operation type); -} diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/impl/DefaultFlowClassifierInstaller.java b/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/impl/DefaultFlowClassifierInstaller.java deleted file mode 100644 index e1a80932..00000000 --- a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/impl/DefaultFlowClassifierInstaller.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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.onosproject.sfc.installer.impl; - -import org.onosproject.core.ApplicationId; -import org.onosproject.net.flowobjective.Objective.Operation; -import org.onosproject.sfc.installer.FlowClassifierInstaller; -import org.onosproject.vtnrsc.FlowClassifier; -import org.onosproject.vtnrsc.PortPair; - -/** - * Provides flow classifier installer. - */ -public class DefaultFlowClassifierInstaller implements FlowClassifierInstaller { - - /** - * Default constructor. - */ - public DefaultFlowClassifierInstaller() { - } - - @Override - public void install(FlowClassifier flowClassifier, PortPair portPair) { - // TODO: Process flow-classifier for installation. - } - - @Override - public void programFlowClassification(FlowClassifier flowClassifier, PortPair portPair, ApplicationId appid, - Operation type) { - // TODO: program forwarding objective for flow-classifier installation. - } -} diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/impl/package-info.java b/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/impl/package-info.java deleted file mode 100644 index d9796d80..00000000 --- a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/impl/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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. - */ - -/** - * Implementation of Service for installing flow classifier rules in OVS. - */ -package org.onosproject.sfc.installer.impl; diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/package-info.java b/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/package-info.java deleted file mode 100644 index 77c0ab30..00000000 --- a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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. - */ - -/** - * Service for installing flow classifier rules in OVS. - */ -package org.onosproject.sfc.installer; diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/NshSpiIdGenerators.java b/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/NshSpiIdGenerators.java deleted file mode 100644 index 1dbe8c8f..00000000 --- a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/NshSpiIdGenerators.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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.onosproject.sfc.manager; - -import java.util.concurrent.atomic.AtomicInteger; - -/** - * Unique NSH SPI Id generator for NSH header. - */ -public final class NshSpiIdGenerators { - - private static final AtomicInteger NSH_SPI_ID_GEN = new AtomicInteger(); - private static final int MAX_NSH_SPI_ID = 0x7FFFFFFF; - private static int nshSpiId; - - /** - * Default constructor. - */ - private NshSpiIdGenerators() { - } - - /** - * Get the next NSH SPI id. - * - * @return NSH SPI id - */ - public static int create() { - do { - if (nshSpiId >= MAX_NSH_SPI_ID) { - if (NSH_SPI_ID_GEN.get() >= MAX_NSH_SPI_ID) { - NSH_SPI_ID_GEN.set(0); - } - } - nshSpiId = NSH_SPI_ID_GEN.incrementAndGet(); - } while (nshSpiId > MAX_NSH_SPI_ID); - return nshSpiId; - } -} diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/SfcService.java b/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/SfcService.java deleted file mode 100644 index 4af2d47c..00000000 --- a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/SfcService.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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.onosproject.sfc.manager; - -import org.onosproject.vtnrsc.PortPair; -import org.onosproject.vtnrsc.PortPairGroup; -import org.onosproject.vtnrsc.FlowClassifier; -import org.onosproject.vtnrsc.PortChain; - -/** - * SFC application that applies flows to the device. - */ -public interface SfcService { - - /** - * When port-pair is created, check whether Forwarding Rule needs to be - * updated in OVS. - * - * @param portPair port-pair - */ - void onPortPairCreated(PortPair portPair); - - /** - * When port-pair is deleted, check whether Forwarding Rule needs to be - * updated in OVS. - * - * @param portPair port-pair - */ - void onPortPairDeleted(PortPair portPair); - - /** - * When port-pair-group is created, check whether Forwarding Rule needs to - * be updated in OVS. - * - * @param portPairGroup port-pair-group - */ - void onPortPairGroupCreated(PortPairGroup portPairGroup); - - /** - * When port-pair-group is deleted, check whether Forwarding Rule needs to - * be updated in OVS. - * - * @param portPairGroup port-pair-group - */ - void onPortPairGroupDeleted(PortPairGroup portPairGroup); - - /** - * When flow-classifier is created, check whether Forwarding Rule needs to - * be updated in OVS. - * - * @param flowClassifier flow-classifier - */ - void onFlowClassifierCreated(FlowClassifier flowClassifier); - - /** - * When flow-classifier is deleted, check whether Forwarding Rule needs to - * be updated in OVS. - * - * @param flowClassifier flow-classifier - */ - void onFlowClassifierDeleted(FlowClassifier flowClassifier); - - /** - * When port-chain is created, check whether Forwarding Rule needs to be - * updated in OVS. - * - * @param portChain port-chain - */ - void onPortChainCreated(PortChain portChain); - - /** - * When port-chain is deleted, check whether Forwarding Rule needs to be - * updated in OVS. - * - * @param portChain port-chain - */ - void onPortChainDeleted(PortChain portChain); -} diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/impl/SfcManager.java b/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/impl/SfcManager.java deleted file mode 100644 index 4df07929..00000000 --- a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/impl/SfcManager.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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.onosproject.sfc.manager.impl; - -import static org.slf4j.LoggerFactory.getLogger; - -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.ReferenceCardinality; -import org.apache.felix.scr.annotations.Service; -import org.onlab.util.KryoNamespace; -import org.onosproject.core.ApplicationId; -import org.onosproject.core.CoreService; -import org.onosproject.sfc.manager.SfcService; -import org.onosproject.vtnrsc.PortPair; -import org.onosproject.vtnrsc.PortPairId; -import org.onosproject.vtnrsc.PortPairGroup; -import org.onosproject.vtnrsc.PortPairGroupId; -import org.onosproject.vtnrsc.FlowClassifier; -import org.onosproject.vtnrsc.FlowClassifierId; -import org.onosproject.vtnrsc.PortChain; -import org.onosproject.vtnrsc.PortChainId; -import org.onosproject.vtnrsc.TenantId; -import org.onosproject.vtnrsc.event.VtnRscEvent; -import org.onosproject.vtnrsc.event.VtnRscListener; -import org.onosproject.vtnrsc.service.VtnRscService; - -import org.slf4j.Logger; - -/** - * Provides implementation of SFC Service. - */ -@Component(immediate = true) -@Service -public class SfcManager implements SfcService { - - private final Logger log = getLogger(getClass()); - private static final String APP_ID = "org.onosproject.app.vtn"; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected VtnRscService vtnRscService; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected CoreService coreService; - - protected ApplicationId appId; - - private final VtnRscListener vtnRscListener = new InnerVtnRscListener(); - - @Activate - public void activate() { - appId = coreService.registerApplication(APP_ID); - - vtnRscService.addListener(vtnRscListener); - - KryoNamespace.Builder serializer = KryoNamespace.newBuilder() - .register(TenantId.class) - .register(PortPairId.class) - .register(PortPairGroupId.class) - .register(FlowClassifierId.class) - .register(PortChainId.class); - - log.info("Started"); - } - - @Deactivate - public void deactivate() { - vtnRscService.removeListener(vtnRscListener); - - log.info("Stopped"); - } - - /* - * Handle events. - */ - private class InnerVtnRscListener implements VtnRscListener { - @Override - public void event(VtnRscEvent event) { - - if (VtnRscEvent.Type.PORT_PAIR_PUT == event.type()) { - PortPair portPair = (PortPair) event.subject(); - onPortPairCreated(portPair); - } else if (VtnRscEvent.Type.PORT_PAIR_DELETE == event.type()) { - PortPair portPair = (PortPair) event.subject(); - onPortPairDeleted(portPair); - } else if (VtnRscEvent.Type.PORT_PAIR_UPDATE == event.type()) { - PortPair portPair = (PortPair) event.subject(); - onPortPairDeleted(portPair); - onPortPairCreated(portPair); - } else if (VtnRscEvent.Type.PORT_PAIR_GROUP_PUT == event.type()) { - PortPairGroup portPairGroup = (PortPairGroup) event.subject(); - onPortPairGroupCreated(portPairGroup); - } else if (VtnRscEvent.Type.PORT_PAIR_GROUP_DELETE == event.type()) { - PortPairGroup portPairGroup = (PortPairGroup) event.subject(); - onPortPairGroupDeleted(portPairGroup); - } else if (VtnRscEvent.Type.PORT_PAIR_GROUP_UPDATE == event.type()) { - PortPairGroup portPairGroup = (PortPairGroup) event.subject(); - onPortPairGroupDeleted(portPairGroup); - onPortPairGroupCreated(portPairGroup); - } else if (VtnRscEvent.Type.FLOW_CLASSIFIER_PUT == event.type()) { - FlowClassifier flowClassifier = (FlowClassifier) event.subject(); - onFlowClassifierCreated(flowClassifier); - } else if (VtnRscEvent.Type.FLOW_CLASSIFIER_DELETE == event.type()) { - FlowClassifier flowClassifier = (FlowClassifier) event.subject(); - onFlowClassifierDeleted(flowClassifier); - } else if (VtnRscEvent.Type.FLOW_CLASSIFIER_UPDATE == event.type()) { - FlowClassifier flowClassifier = (FlowClassifier) event.subject(); - onFlowClassifierDeleted(flowClassifier); - onFlowClassifierCreated(flowClassifier); - } else if (VtnRscEvent.Type.PORT_CHAIN_PUT == event.type()) { - PortChain portChain = (PortChain) event.subject(); - onPortChainCreated(portChain); - } else if (VtnRscEvent.Type.PORT_CHAIN_DELETE == event.type()) { - PortChain portChain = (PortChain) event.subject(); - onPortChainDeleted(portChain); - } else if (VtnRscEvent.Type.PORT_CHAIN_UPDATE == event.type()) { - PortChain portChain = (PortChain) event.subject(); - onPortChainDeleted(portChain); - onPortChainCreated(portChain); - } - } - } - - @Override - public void onPortPairCreated(PortPair portPair) { - log.debug("onPortPairCreated"); - // TODO: Modify forwarding rule on port-pair creation. - } - - @Override - public void onPortPairDeleted(PortPair portPair) { - log.debug("onPortPairDeleted"); - // TODO: Modify forwarding rule on port-pair deletion. - } - - @Override - public void onPortPairGroupCreated(PortPairGroup portPairGroup) { - log.debug("onPortPairGroupCreated"); - // TODO: Modify forwarding rule on port-pair-group creation. - } - - @Override - public void onPortPairGroupDeleted(PortPairGroup portPairGroup) { - log.debug("onPortPairGroupDeleted"); - // TODO: Modify forwarding rule on port-pair-group deletion. - } - - @Override - public void onFlowClassifierCreated(FlowClassifier flowClassifier) { - log.debug("onFlowClassifierCreated"); - // TODO: Modify forwarding rule on flow-classifier creation. - } - - @Override - public void onFlowClassifierDeleted(FlowClassifier flowClassifier) { - log.debug("onFlowClassifierDeleted"); - // TODO: Modify forwarding rule on flow-classifier deletion. - } - - @Override - public void onPortChainCreated(PortChain portChain) { - log.debug("onPortChainCreated"); - //TODO: Apply forwarding rule on port-chain creation. - } - - @Override - public void onPortChainDeleted(PortChain portChain) { - log.debug("onPortChainDeleted"); - //TODO: Apply forwarding rule on port-chain deletion. - } -} diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/impl/package-info.java b/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/impl/package-info.java deleted file mode 100644 index 7161380a..00000000 --- a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/impl/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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. - */ - -/** - * SFC Service manager for interacting with SFC. - */ -package org.onosproject.sfc.manager.impl; diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/package-info.java b/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/package-info.java deleted file mode 100644 index 1dd0f5a0..00000000 --- a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * 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. - */ - -/** - * Service for interacting with SFC. - */ -package org.onosproject.sfc.manager; |