diff options
Diffstat (limited to 'framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions')
-rw-r--r-- | framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraExtensionTreatmentInterpreter.java (renamed from framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraExtensionInterpreter.java) | 48 | ||||
-rw-r--r-- | framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraResubmit.java | 107 | ||||
-rw-r--r-- | framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraSetNshSpi.java | 104 | ||||
-rw-r--r-- | framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraSetTunnelDst.java | 10 |
4 files changed, 246 insertions, 23 deletions
diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraExtensionInterpreter.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraExtensionTreatmentInterpreter.java index b8f1fd91..a7f70f98 100644 --- a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraExtensionInterpreter.java +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraExtensionTreatmentInterpreter.java @@ -17,11 +17,11 @@ package org.onosproject.driver.extensions; import org.onlab.packet.Ip4Address; -import org.onosproject.net.behaviour.ExtensionResolver; +import org.onosproject.net.behaviour.ExtensionTreatmentResolver; import org.onosproject.net.driver.AbstractHandlerBehaviour; -import org.onosproject.net.flow.instructions.ExtensionInstruction; -import org.onosproject.net.flow.instructions.ExtensionType; -import org.onosproject.openflow.controller.ExtensionInterpreter; +import org.onosproject.net.flow.instructions.ExtensionTreatment; +import org.onosproject.net.flow.instructions.ExtensionTreatmentType; +import org.onosproject.openflow.controller.ExtensionTreatmentInterpreter; import org.projectfloodlight.openflow.protocol.OFActionType; import org.projectfloodlight.openflow.protocol.OFFactory; import org.projectfloodlight.openflow.protocol.action.OFAction; @@ -33,36 +33,45 @@ import org.projectfloodlight.openflow.types.IPv4Address; /** * Interpreter for Nicira OpenFlow extensions. */ -public class NiciraExtensionInterpreter extends AbstractHandlerBehaviour - implements ExtensionInterpreter, ExtensionResolver { +public class NiciraExtensionTreatmentInterpreter extends AbstractHandlerBehaviour + implements ExtensionTreatmentInterpreter, ExtensionTreatmentResolver { @Override - public boolean supported(ExtensionType extensionType) { - if (extensionType.equals(ExtensionType.ExtensionTypes.NICIRA_SET_TUNNEL_DST.type())) { + public boolean supported(ExtensionTreatmentType extensionTreatmentType) { + if (extensionTreatmentType.equals( + ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST.type())) { return true; } - if (extensionType.equals(ExtensionType.ExtensionTypes.NICIRA_RESUBMIT.type())) { + if (extensionTreatmentType.equals( + ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT.type())) { + return true; + } + if (extensionTreatmentType.equals( + ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) { return true; } return false; } @Override - public OFAction mapInstruction(OFFactory factory, ExtensionInstruction extensionInstruction) { - ExtensionType type = extensionInstruction.type(); - if (type.equals(ExtensionType.ExtensionTypes.NICIRA_SET_TUNNEL_DST.type())) { - NiciraSetTunnelDst tunnelDst = (NiciraSetTunnelDst) extensionInstruction; + public OFAction mapInstruction(OFFactory factory, ExtensionTreatment extensionTreatment) { + ExtensionTreatmentType type = extensionTreatment.type(); + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST.type())) { + NiciraSetTunnelDst tunnelDst = (NiciraSetTunnelDst) extensionTreatment; return factory.actions().setField(factory.oxms().tunnelIpv4Dst( IPv4Address.of(tunnelDst.tunnelDst().toInt()))); } - if (type.equals(ExtensionType.ExtensionTypes.NICIRA_RESUBMIT.type())) { + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT.type())) { // TODO this will be implemented later } + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) { + // TODO this will be implemented later + } return null; } @Override - public ExtensionInstruction mapAction(OFAction action) { + public ExtensionTreatment mapAction(OFAction action) { if (action.getType().equals(OFActionType.SET_FIELD)) { OFActionSetField setFieldAction = (OFActionSetField) action; OFOxm<?> oxm = setFieldAction.getField(); @@ -79,13 +88,16 @@ public class NiciraExtensionInterpreter extends AbstractHandlerBehaviour } @Override - public ExtensionInstruction getExtensionInstruction(ExtensionType type) { - if (type.equals(ExtensionType.ExtensionTypes.NICIRA_SET_TUNNEL_DST.type())) { + public ExtensionTreatment getExtensionInstruction(ExtensionTreatmentType type) { + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST.type())) { return new NiciraSetTunnelDst(); } - if (type.equals(ExtensionType.ExtensionTypes.NICIRA_RESUBMIT.type())) { + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT.type())) { return new NiciraResubmit(); } + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) { + return new NiciraSetNshSpi(); + } throw new UnsupportedOperationException( "Driver does not support extension type " + type.toString()); } diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraResubmit.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraResubmit.java new file mode 100644 index 00000000..481b6f9c --- /dev/null +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraResubmit.java @@ -0,0 +1,107 @@ +/* + * 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.driver.extensions; + +import com.google.common.base.MoreObjects; +import org.onlab.util.KryoNamespace; +import org.onosproject.net.PortNumber; +import org.onosproject.net.flow.instructions.AbstractExtensionTreatment; +import org.onosproject.net.flow.instructions.ExtensionTreatmentType; +import org.onosproject.store.serializers.PortNumberSerializer; + +import java.util.Objects; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Nicira resubmit extension instruction. + */ +public class NiciraResubmit extends AbstractExtensionTreatment { + + private PortNumber inPort; + + private final KryoNamespace appKryo = new KryoNamespace.Builder() + .register(new PortNumberSerializer(), PortNumber.class) + .register(byte[].class) + .build(); + + /** + * Creates a new resubmit instruction. + */ + NiciraResubmit() { + inPort = null; + } + + /** + * Creates a new resubmit instruction with a particular inPort. + * + * @param inPort in port number + */ + public NiciraResubmit(PortNumber inPort) { + checkNotNull(inPort); + this.inPort = inPort; + } + + /** + * Gets the inPort. + * + * @return inPort + */ + public PortNumber inPort() { + return inPort; + } + + @Override + public ExtensionTreatmentType type() { + return ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT.type(); + } + + @Override + public void deserialize(byte[] data) { + inPort = appKryo.deserialize(data); + } + + @Override + public byte[] serialize() { + return appKryo.serialize(inPort); + } + + @Override + public int hashCode() { + return Objects.hash(inPort); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof NiciraResubmit) { + NiciraResubmit that = (NiciraResubmit) obj; + return Objects.equals(inPort, that.inPort); + + } + return false; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("inPort", inPort) + .toString(); + } +} diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraSetNshSpi.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraSetNshSpi.java new file mode 100644 index 00000000..25358702 --- /dev/null +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraSetNshSpi.java @@ -0,0 +1,104 @@ +/* + * 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.driver.extensions; + +import java.util.Objects; + +import org.onlab.util.KryoNamespace; +import org.onosproject.net.flow.instructions.AbstractExtensionTreatment; +import org.onosproject.net.flow.instructions.ExtensionTreatmentType; +import org.onosproject.store.serializers.Ip4AddressSerializer; + +import com.google.common.base.MoreObjects; + +/** + * Nicira set NSH SPI extension instruction. + */ +public class NiciraSetNshSpi extends AbstractExtensionTreatment { + + private int nshSpi; + + private final KryoNamespace appKryo = new KryoNamespace.Builder() + .register(new Ip4AddressSerializer(), Integer.class) + .register(byte[].class) + .build(); + + /** + * Creates a new set nsh spi instruction. + */ + NiciraSetNshSpi() { + nshSpi = 0; + } + + /** + * Creates a new set nsh spi instruction with given spi. + * + * @param nshSpi nsh service path index + */ + NiciraSetNshSpi(int nshSpi) { + this.nshSpi = nshSpi; + } + + /** + * Gets the nsh service path index. + * + * @return nsh service path index + */ + public int nshSpi() { + return nshSpi; + } + + @Override + public ExtensionTreatmentType type() { + return ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type(); + } + + @Override + public void deserialize(byte[] data) { + nshSpi = appKryo.deserialize(data); + } + + @Override + public byte[] serialize() { + return appKryo.serialize(nshSpi); + } + + @Override + public int hashCode() { + return Objects.hash(nshSpi); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof NiciraSetNshSpi) { + NiciraSetNshSpi that = (NiciraSetNshSpi) obj; + return Objects.equals(nshSpi, that.nshSpi); + + } + return false; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("nshSpi", nshSpi) + .toString(); + } +} diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraSetTunnelDst.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraSetTunnelDst.java index a20b2479..ec23a9e0 100644 --- a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraSetTunnelDst.java +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraSetTunnelDst.java @@ -19,8 +19,8 @@ package org.onosproject.driver.extensions; import com.google.common.base.MoreObjects; import org.onlab.packet.Ip4Address; import org.onlab.util.KryoNamespace; -import org.onosproject.net.flow.instructions.AbstractExtensionInstruction; -import org.onosproject.net.flow.instructions.ExtensionType; +import org.onosproject.net.flow.instructions.AbstractExtensionTreatment; +import org.onosproject.net.flow.instructions.ExtensionTreatmentType; import org.onosproject.store.serializers.Ip4AddressSerializer; import java.util.Objects; @@ -30,7 +30,7 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Nicira set tunnel destination extension instruction. */ -public class NiciraSetTunnelDst extends AbstractExtensionInstruction { +public class NiciraSetTunnelDst extends AbstractExtensionTreatment { private Ip4Address tunnelDst; @@ -67,8 +67,8 @@ public class NiciraSetTunnelDst extends AbstractExtensionInstruction { } @Override - public ExtensionType type() { - return ExtensionType.ExtensionTypes.NICIRA_SET_TUNNEL_DST.type(); + public ExtensionTreatmentType type() { + return ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST.type(); } @Override |