diff options
author | Ashlee Young <ashlee@wildernessvoice.com> | 2015-12-06 07:15:03 -0800 |
---|---|---|
committer | Ashlee Young <ashlee@wildernessvoice.com> | 2015-12-08 10:55:21 -0800 |
commit | 76dc892491948adae5e5e62cf94448967e8d865b (patch) | |
tree | 7a33ef05cc583946db21edad627060f280a53549 /framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions | |
parent | d333c63fdec8b064184b0a26f8d777f267577fde (diff) |
Fixes bad POM file with ONOS commit 8c68536972f63069c263635c9d9f4f31d7f3e9a2
Change-Id: I7adb5a2d3738d53dbc41db7577768b0e7ced5450
Signed-off-by: Ashlee Young <ashlee@wildernessvoice.com>
Diffstat (limited to 'framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions')
14 files changed, 1106 insertions, 17 deletions
diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/DefaultMoveExtensionTreatment.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/DefaultMoveExtensionTreatment.java new file mode 100644 index 00000000..140a8167 --- /dev/null +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/DefaultMoveExtensionTreatment.java @@ -0,0 +1,146 @@ +/* + * 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.Map; +import java.util.Objects; + +import org.onlab.util.KryoNamespace; +import org.onosproject.net.flow.AbstractExtension; +import org.onosproject.net.flow.instructions.ExtensionTreatmentType; + +import com.google.common.base.MoreObjects; +import com.google.common.collect.Maps; + +/** + * Default implementation of Move treatment. + */ +public class DefaultMoveExtensionTreatment extends AbstractExtension + implements MoveExtensionTreatment { + + private int srcOfs; + private int dstOfs; + private int nBits; + private int src; + private int dst; + private ExtensionTreatmentType type; + + private final KryoNamespace appKryo = new KryoNamespace.Builder() + .register(byte[].class).register(Integer.class).register(Map.class) + .build(); + + /** + * Creates a new move Treatment. + * + * @param srcOfs source offset + * @param dstOfs destination offset + * @param nBits nbits + * @param src source + * @param dst destination + * @param type extension treatment type + */ + public DefaultMoveExtensionTreatment(int srcOfs, int dstOfs, int nBits, + int src, int dst, ExtensionTreatmentType type) { + this.srcOfs = srcOfs; + this.dstOfs = dstOfs; + this.nBits = nBits; + this.src = src; + this.dst = dst; + this.type = type; + } + + @Override + public ExtensionTreatmentType type() { + return type; + } + + @Override + public byte[] serialize() { + Map<String, Integer> values = Maps.newHashMap(); + values.put("srcOfs", srcOfs); + values.put("dstOfs", dstOfs); + values.put("nBits", nBits); + values.put("src", src); + values.put("dst", dst); + values.put("type", ExtensionTreatmentType.ExtensionTreatmentTypes.valueOf(type.toString()).ordinal()); + return appKryo.serialize(values); + } + + @Override + public void deserialize(byte[] data) { + Map<String, Integer> values = appKryo.deserialize(data); + srcOfs = values.get("srcOfs"); + dstOfs = values.get("dstOfs"); + nBits = values.get("nBits"); + src = values.get("src"); + dst = values.get("dst"); + type = new ExtensionTreatmentType(values.get("type").intValue()); + } + + @Override + public int srcOffset() { + return srcOfs; + } + + @Override + public int dstOffset() { + return dstOfs; + } + + @Override + public int src() { + return src; + } + + @Override + public int dst() { + return dst; + } + + @Override + public int nBits() { + return nBits; + } + + @Override + public int hashCode() { + return Objects.hash(srcOfs, dstOfs, src, dst, nBits); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof DefaultMoveExtensionTreatment) { + DefaultMoveExtensionTreatment that = (DefaultMoveExtensionTreatment) obj; + return Objects.equals(srcOfs, that.srcOfs) + && Objects.equals(dstOfs, that.dstOfs) + && Objects.equals(src, that.src) + && Objects.equals(dst, that.dst) + && Objects.equals(nBits, that.nBits); + + } + return false; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()).add("srcOfs", srcOfs) + .add("dstOfs", dstOfs).add("nBits", nBits).add("src", src) + .add("dst", dst).toString(); + } +} diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/MoveExtensionTreatment.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/MoveExtensionTreatment.java new file mode 100644 index 00000000..b67e1bed --- /dev/null +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/MoveExtensionTreatment.java @@ -0,0 +1,59 @@ +/* + * 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 org.onosproject.net.flow.instructions.ExtensionTreatment; + +/** + * The abstraction of Move Treatment. + */ +public interface MoveExtensionTreatment extends ExtensionTreatment { + + /** + * Returns SRC_OFS field of move extension action. + * + * @return SRC_OFS + */ + int srcOffset(); + + /** + * Returns DST_OFS field of move extension action. + * + * @return DST_OFS + */ + int dstOffset(); + + /** + * Returns SRC field of move extension action. + * + * @return SRC + */ + int src(); + + /** + * Returns DST field of move extension action. + * + * @return DST + */ + int dst(); + + /** + * Returns N_BITS field of move extension action. + * + * @return N_BITS + */ + int nBits(); +} diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraExtensionSelectorInterpreter.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraExtensionSelectorInterpreter.java new file mode 100644 index 00000000..9f302991 --- /dev/null +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraExtensionSelectorInterpreter.java @@ -0,0 +1,102 @@ +/* + * 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 org.onosproject.net.behaviour.ExtensionSelectorResolver; +import org.onosproject.net.driver.AbstractHandlerBehaviour; +import org.onosproject.net.flow.criteria.ExtensionSelector; +import org.onosproject.net.flow.criteria.ExtensionSelectorType; +import org.onosproject.openflow.controller.ExtensionSelectorInterpreter; +import org.projectfloodlight.openflow.protocol.OFFactory; +import org.projectfloodlight.openflow.protocol.oxm.OFOxm; + +/** + * Interpreter for Nicira OpenFlow selector extensions. + */ +public class NiciraExtensionSelectorInterpreter + extends AbstractHandlerBehaviour + implements ExtensionSelectorInterpreter, ExtensionSelectorResolver { + + @Override + public boolean supported(ExtensionSelectorType extensionSelectorType) { + if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI.type())) { + return true; + } + if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI.type())) { + return true; + } + if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH1.type())) { + return true; + } + if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH2.type())) { + return true; + } + if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH3.type())) { + return true; + } + if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH4.type())) { + return true; + } + return false; + } + + @Override + public OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector) { + ExtensionSelectorType type = extensionSelector.type(); + if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI.type())) { + // TODO + } + if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI.type())) { + // TODO + } + if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH1.type())) { + // TODO + } + if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH2.type())) { + // TODO + } + if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH3.type())) { + // TODO + } + if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH4.type())) { + // TODO + } + return null; + } + + @Override + public ExtensionSelector mapOxm(OFOxm<?> oxm) { + return null; + } + + @Override + public ExtensionSelector getExtensionSelector(ExtensionSelectorType type) { + if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI.type())) { + return new NiciraMatchNshSpi(); + } + if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI.type())) { + return new NiciraMatchNshSi(); + } + if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH1.type()) + || type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH2.type()) + || type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH3.type()) + || type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH4.type())) { + return new NiciraMatchNshContextHeader(type); + } + return null; + } +} diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraExtensionTreatmentInterpreter.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraExtensionTreatmentInterpreter.java index a7f70f98..5e374d9b 100644 --- a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraExtensionTreatmentInterpreter.java +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraExtensionTreatmentInterpreter.java @@ -31,7 +31,7 @@ import org.projectfloodlight.openflow.protocol.oxm.OFOxmTunnelIpv4Dst; import org.projectfloodlight.openflow.types.IPv4Address; /** - * Interpreter for Nicira OpenFlow extensions. + * Interpreter for Nicira OpenFlow treatment extensions. */ public class NiciraExtensionTreatmentInterpreter extends AbstractHandlerBehaviour implements ExtensionTreatmentInterpreter, ExtensionTreatmentResolver { @@ -46,8 +46,42 @@ public class NiciraExtensionTreatmentInterpreter extends AbstractHandlerBehaviou ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT.type())) { return true; } + if (extensionTreatmentType.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) { + return true; + } + if (extensionTreatmentType.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SI.type())) { + return true; + } + if (extensionTreatmentType.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH1.type())) { + return true; + } + if (extensionTreatmentType.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH2.type())) { + return true; + } + if (extensionTreatmentType.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH3.type())) { + return true; + } + if (extensionTreatmentType.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH4.type())) { + return true; + } if (extensionTreatmentType.equals( - ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) { + ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT_TABLE.type())) { + return true; + } + if (extensionTreatmentType.equals( + ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_ARP_SHA_TO_THA.type())) { + return true; + } + if (extensionTreatmentType.equals( + ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_ARP_SPA_TO_TPA.type())) { + return true; + } + if (extensionTreatmentType.equals( + ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_ETH_SRC_TO_DST.type())) { + return true; + } + if (extensionTreatmentType.equals( + ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_IP_SRC_TO_DST.type())) { return true; } return false; @@ -62,11 +96,35 @@ public class NiciraExtensionTreatmentInterpreter extends AbstractHandlerBehaviou IPv4Address.of(tunnelDst.tunnelDst().toInt()))); } if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT.type())) { - // TODO this will be implemented later + // TODO this will be implemented later } if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) { // TODO this will be implemented later } + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT_TABLE.type())) { + // TODO this will be implemented later + } + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SI.type())) { + // TODO this will be implemented later + } + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH1.type())) { + // TODO this will be implemented later + } + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH2.type())) { + // TODO this will be implemented later + } + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH3.type())) { + // TODO this will be implemented later + } + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH4.type())) { + // TODO this will be implemented later + } + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_ETH_SRC_TO_DST.type()) + || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_ARP_SPA_TO_TPA.type()) + || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_ETH_SRC_TO_DST.type()) + || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_IP_SRC_TO_DST.type())) { + // TODO this will be implemented later + } return null; } @@ -95,9 +153,33 @@ public class NiciraExtensionTreatmentInterpreter extends AbstractHandlerBehaviou if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT.type())) { return new NiciraResubmit(); } + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT_TABLE.type())) { + return new NiciraResubmitTable(); + } if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) { return new NiciraSetNshSpi(); } + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SI.type())) { + return new NiciraSetNshSi(); + } + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH1.type()) + || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH2.type()) + || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH3.type()) + || type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH4.type())) { + return new NiciraSetNshContextHeader(type); + } + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_ARP_SHA_TO_THA.type())) { + return NiciraMoveTreatmentFactory.createNiciraMovArpShaToTha(); + } + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_ARP_SPA_TO_TPA.type())) { + return NiciraMoveTreatmentFactory.createNiciraMovArpSpaToTpa(); + } + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_ETH_SRC_TO_DST.type())) { + return NiciraMoveTreatmentFactory.createNiciraMovEthSrcToDst(); + } + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_MOV_IP_SRC_TO_DST.type())) { + return NiciraMoveTreatmentFactory.createNiciraMovIpSrcToDst(); + } 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/NiciraMatchNshContextHeader.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraMatchNshContextHeader.java new file mode 100644 index 00000000..5f37247f --- /dev/null +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraMatchNshContextHeader.java @@ -0,0 +1,95 @@ +/* + * 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 static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +import org.onlab.util.KryoNamespace; +import org.onosproject.net.NshContextHeader; +import org.onosproject.net.flow.AbstractExtension; +import org.onosproject.net.flow.criteria.ExtensionSelector; +import org.onosproject.net.flow.criteria.ExtensionSelectorType; +/** + * Implementation of Nsh context header criterion. + */ +public final class NiciraMatchNshContextHeader extends AbstractExtension implements ExtensionSelector { + private NshContextHeader nshContextHeader; + private ExtensionSelectorType type; + + private final KryoNamespace appKryo = new KryoNamespace.Builder().build(); + + /** + * Constructor to create Nsh context header. + * + * @param type extension selector type + */ + public NiciraMatchNshContextHeader(ExtensionSelectorType type) { + this.nshContextHeader = null; + this.type = type; + } + + /** + * Gets the nsh context header to match. + * + * @return the nsh context header to match + */ + public NshContextHeader nshContextHeader() { + return nshContextHeader; + } + + @Override + public byte[] serialize() { + return appKryo.serialize(nshContextHeader.nshContextHeader()); + } + + @Override + public void deserialize(byte[] data) { + nshContextHeader = nshContextHeader.of(appKryo.deserialize(data)); + + } + + @Override + public ExtensionSelectorType type() { + return type; + } + + @Override + public String toString() { + return toStringHelper(type().toString()) + .add("nshContextHeader", nshContextHeader.toString()) + .toString(); + } + + @Override + public int hashCode() { + return Objects.hash(type(), nshContextHeader); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof NiciraMatchNshContextHeader) { + NiciraMatchNshContextHeader that = (NiciraMatchNshContextHeader) obj; + return Objects.equals(nshContextHeader, that.nshContextHeader) && + Objects.equals(this.type(), that.type()); + } + return false; + } +} diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraMatchNshSi.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraMatchNshSi.java new file mode 100644 index 00000000..c98a584a --- /dev/null +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraMatchNshSi.java @@ -0,0 +1,91 @@ +/* + * 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 static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +import org.onlab.util.KryoNamespace; +import org.onosproject.net.NshServiceIndex; +import org.onosproject.net.flow.AbstractExtension; +import org.onosproject.net.flow.criteria.ExtensionSelector; +import org.onosproject.net.flow.criteria.ExtensionSelectorType; +/** + * Implementation of NSH Service Index(SI). + */ +public final class NiciraMatchNshSi extends AbstractExtension implements ExtensionSelector { + + private NshServiceIndex nshSi; + + private final KryoNamespace appKryo = new KryoNamespace.Builder().build(); + + /** + * Default constructor. + * + */ + public NiciraMatchNshSi() { + this.nshSi = null; + } + + /** + * Gets the nsh service index to match. + * + * @return the si to match + */ + public NshServiceIndex nshSi() { + return nshSi; + } + + @Override + public byte[] serialize() { + return appKryo.serialize(nshSi.serviceIndex()); + } + + @Override + public void deserialize(byte[] data) { + nshSi = NshServiceIndex.of(appKryo.deserialize(data)); + } + + @Override + public ExtensionSelectorType type() { + return ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI.type(); + } + + @Override + public String toString() { + return toStringHelper(type().toString()) + .add("nshSi", nshSi.toString()) + .toString(); + } + + @Override + public int hashCode() { + return Objects.hash(type(), nshSi); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof NiciraMatchNshSi) { + NiciraMatchNshSi that = (NiciraMatchNshSi) obj; + return Objects.equals(nshSi, that.nshSi); + } + return false; + } +} diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraMatchNshSpi.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraMatchNshSpi.java new file mode 100644 index 00000000..42bb78d4 --- /dev/null +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraMatchNshSpi.java @@ -0,0 +1,91 @@ +/* + * 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 static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +import org.onlab.util.KryoNamespace; +import org.onosproject.net.NshServicePathId; +import org.onosproject.net.flow.AbstractExtension; +import org.onosproject.net.flow.criteria.ExtensionSelector; +import org.onosproject.net.flow.criteria.ExtensionSelectorType; + +/** + * Implementation of NSH Service Path Id selector. + */ +public final class NiciraMatchNshSpi extends AbstractExtension implements ExtensionSelector { + private NshServicePathId nshSpi; + + private final KryoNamespace appKryo = new KryoNamespace.Builder().build(); + + /** + * Default constructor. + */ + public NiciraMatchNshSpi() { + this.nshSpi = null; + } + + /** + * Gets the network service path id to match. + * + * @return the nshSpi to match + */ + public NshServicePathId nshSpi() { + return nshSpi; + } + + @Override + public ExtensionSelectorType type() { + return ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI.type(); + } + + @Override + public byte[] serialize() { + return appKryo.serialize(nshSpi); + } + + @Override + public void deserialize(byte[] data) { + nshSpi = NshServicePathId.of(appKryo.deserialize(data)); + } + + @Override + public String toString() { + return toStringHelper(type().toString()) + .add("nshSpi", nshSpi.toString()) + .toString(); + } + + @Override + public int hashCode() { + return Objects.hash(type(), nshSpi); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof NiciraMatchNshSpi) { + NiciraMatchNshSpi that = (NiciraMatchNshSpi) obj; + return Objects.equals(nshSpi, that.nshSpi) && + Objects.equals(this.type(), that.type()); + } + return false; + } +} diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraMoveTreatmentFactory.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraMoveTreatmentFactory.java new file mode 100644 index 00000000..ac42a3b2 --- /dev/null +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraMoveTreatmentFactory.java @@ -0,0 +1,100 @@ +/* + * 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 org.onosproject.net.flow.instructions.ExtensionTreatment; +import org.onosproject.net.flow.instructions.ExtensionTreatmentType; + +/** + * The factory of move treatment. + */ +public final class NiciraMoveTreatmentFactory { + + /** + * Public constructor is prohibited. + */ + private NiciraMoveTreatmentFactory() { + + } + + /** + * Creates a move treatment that move arp sha to tha. + * + * @return ExtensionTreatment + */ + public static ExtensionTreatment createNiciraMovArpShaToTha() { + int srcOfs = 0; + int dstOfs = 0; + int nBits = 48; + int srcSha = 0x00012206; + int dstTha = 0x00012406; + return new DefaultMoveExtensionTreatment(srcOfs, dstOfs, nBits, srcSha, + dstTha, + ExtensionTreatmentType.ExtensionTreatmentTypes + .NICIRA_MOV_ARP_SHA_TO_THA.type()); + } + + /** + * Creates a move treatment that move arp spa to tpa. + * + * @return ExtensionTreatment + */ + public static ExtensionTreatment createNiciraMovArpSpaToTpa() { + int srcOfs = 0; + int dstOfs = 0; + int nBits = 32; + int srcSpa = 0x00002004; + int dstTpa = 0x00002204; + return new DefaultMoveExtensionTreatment(srcOfs, dstOfs, nBits, srcSpa, + dstTpa, + ExtensionTreatmentType.ExtensionTreatmentTypes + .NICIRA_MOV_ARP_SPA_TO_TPA.type()); + } + + /** + * Creates a move treatment that move eth src to dst. + * + * @return ExtensionTreatment + */ + public static ExtensionTreatment createNiciraMovEthSrcToDst() { + int srcOfs = 0; + int dstOfs = 0; + int nBits = 48; + int srcEth = 0x00000406; + int dstEth = 0x00000206; + return new DefaultMoveExtensionTreatment(srcOfs, dstOfs, nBits, srcEth, + dstEth, + ExtensionTreatmentType.ExtensionTreatmentTypes + .NICIRA_MOV_ETH_SRC_TO_DST.type()); + } + + /** + * Creates a move treatment that move ip src to dst. + * + * @return ExtensionTreatment + */ + public static ExtensionTreatment createNiciraMovIpSrcToDst() { + int srcOfs = 0; + int dstOfs = 0; + int nBits = 32; + int srcIp = 0x00000e04; + int dstIp = 0x00001006; + return new DefaultMoveExtensionTreatment(srcOfs, dstOfs, nBits, srcIp, + dstIp, + ExtensionTreatmentType.ExtensionTreatmentTypes + .NICIRA_MOV_IP_SRC_TO_DST.type()); + } +} 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 index 481b6f9c..b85af4f2 100644 --- 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 @@ -19,7 +19,8 @@ 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.AbstractExtension; +import org.onosproject.net.flow.instructions.ExtensionTreatment; import org.onosproject.net.flow.instructions.ExtensionTreatmentType; import org.onosproject.store.serializers.PortNumberSerializer; @@ -30,7 +31,7 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Nicira resubmit extension instruction. */ -public class NiciraResubmit extends AbstractExtensionTreatment { +public class NiciraResubmit extends AbstractExtension implements ExtensionTreatment { private PortNumber inPort; diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraResubmitTable.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraResubmitTable.java new file mode 100644 index 00000000..4743d217 --- /dev/null +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraResubmitTable.java @@ -0,0 +1,114 @@ +/* + * 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.AbstractExtension; +import org.onosproject.net.flow.instructions.ExtensionTreatment; +import org.onosproject.net.flow.instructions.ExtensionTreatmentType; +import org.onosproject.store.serializers.PortNumberSerializer; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Nicira resubmit-table extension instruction. + */ +public class NiciraResubmitTable extends AbstractExtension implements + ExtensionTreatment { + + //the list of the in port number(PortNumber) and the table(short) + private List<Object> inPortAndTable = new ArrayList<Object>(); + + private final KryoNamespace appKryo = new KryoNamespace.Builder() + .register(ArrayList.class) + .register(new PortNumberSerializer(), PortNumber.class) + .register(short.class) + .register(byte[].class) + .build(); + + /** + * Creates a new resubmit-table instruction. + */ + NiciraResubmitTable() { + inPortAndTable = null; + } + + /** + * Creates a new resubmit-table instruction with a particular inPort and table. + * + * @param inPortAndTable the list of in port number and table + */ + public NiciraResubmitTable(List<Object> inPortAndTable) { + checkNotNull(inPortAndTable); + this.inPortAndTable = inPortAndTable; + } + + /** + * Gets the inPortAndTable. + * + * @return inPortAndTable + */ + public List<Object> inPortAndTable() { + return inPortAndTable; + } + + @Override + public ExtensionTreatmentType type() { + return ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT_TABLE.type(); + } + + @Override + public void deserialize(byte[] data) { + inPortAndTable = appKryo.deserialize(data); + } + + @Override + public byte[] serialize() { + return appKryo.serialize(inPortAndTable); + } + + @Override + public int hashCode() { + return Objects.hash(inPortAndTable); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof NiciraResubmitTable) { + NiciraResubmitTable that = (NiciraResubmitTable) obj; + return Objects.equals(inPortAndTable, that.inPortAndTable); + + } + return false; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("inPortAndTable", inPortAndTable).toString(); + } +} diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraSetNshContextHeader.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraSetNshContextHeader.java new file mode 100644 index 00000000..c8267984 --- /dev/null +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraSetNshContextHeader.java @@ -0,0 +1,108 @@ +/* + * 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.flow.AbstractExtension; +import org.onosproject.net.flow.instructions.ExtensionTreatment; +import org.onosproject.net.flow.instructions.ExtensionTreatmentType; + +import java.util.Objects; + +/** + * Nicira set NSH Context header extension instruction. + */ +public class NiciraSetNshContextHeader extends AbstractExtension implements + ExtensionTreatment { + + private int nshCh; + private ExtensionTreatmentType type; + + private final KryoNamespace appKryo = new KryoNamespace.Builder().build(); + + /** + * Creates a new set nsh context header instruction. + * + * @param type extension treatment type + */ + NiciraSetNshContextHeader(ExtensionTreatmentType type) { + this.nshCh = 0; + this.type = type; + } + + /** + * Creates a new set nsh context header instruction. + * + * @param nshCh nsh context header + * @param type extension treatment type + */ + NiciraSetNshContextHeader(int nshCh, ExtensionTreatmentType type) { + this.nshCh = nshCh; + this.type = type; + } + + /** + * Gets the nsh context header. + * + * @return nsh context header + */ + public int nshCh() { + return nshCh; + } + + @Override + public ExtensionTreatmentType type() { + return type; + } + + @Override + public void deserialize(byte[] data) { + nshCh = appKryo.deserialize(data); + } + + @Override + public byte[] serialize() { + return appKryo.serialize(nshCh); + } + + @Override + public int hashCode() { + return Objects.hash(nshCh, type); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof NiciraSetNshContextHeader) { + NiciraSetNshContextHeader that = (NiciraSetNshContextHeader) obj; + return Objects.equals(nshCh, that.nshCh) && Objects.equals(type, that.type); + + } + return false; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("nshCh", nshCh) + .add("type", type) + .toString(); + } +} diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraSetNshSi.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraSetNshSi.java new file mode 100644 index 00000000..1480508e --- /dev/null +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/extensions/NiciraSetNshSi.java @@ -0,0 +1,101 @@ +/* + * 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.flow.AbstractExtension; +import org.onosproject.net.flow.instructions.ExtensionTreatment; +import org.onosproject.net.flow.instructions.ExtensionTreatmentType; + +import java.util.Objects; + +/** + * Nicira set NSH SI extension instruction. + */ +public class NiciraSetNshSi extends AbstractExtension implements + ExtensionTreatment { + + private byte nshSi; + + private final KryoNamespace appKryo = new KryoNamespace.Builder().build(); + + /** + * Creates a new set nsh si instruction. + */ + NiciraSetNshSi() { + nshSi = 0; + } + + /** + * Creates a new set nsh si instruction with given si. + * + * @param nshSi nsh service index + */ + NiciraSetNshSi(byte nshSi) { + this.nshSi = nshSi; + } + + /** + * Gets the nsh service index. + * + * @return nsh service index + */ + public byte nshSi() { + return nshSi; + } + + @Override + public ExtensionTreatmentType type() { + return ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SI.type(); + } + + @Override + public void deserialize(byte[] data) { + nshSi = appKryo.deserialize(data); + } + + @Override + public byte[] serialize() { + return appKryo.serialize(nshSi); + } + + @Override + public int hashCode() { + return Objects.hash(nshSi); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof NiciraSetNshSi) { + NiciraSetNshSi that = (NiciraSetNshSi) obj; + return Objects.equals(nshSi, that.nshSi); + + } + return false; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("nshSi", nshSi) + .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 index 25358702..1a47173e 100644 --- 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 @@ -16,26 +16,23 @@ package org.onosproject.driver.extensions; -import java.util.Objects; - +import com.google.common.base.MoreObjects; import org.onlab.util.KryoNamespace; -import org.onosproject.net.flow.instructions.AbstractExtensionTreatment; +import org.onosproject.net.flow.AbstractExtension; +import org.onosproject.net.flow.instructions.ExtensionTreatment; import org.onosproject.net.flow.instructions.ExtensionTreatmentType; -import org.onosproject.store.serializers.Ip4AddressSerializer; -import com.google.common.base.MoreObjects; +import java.util.Objects; /** * Nicira set NSH SPI extension instruction. */ -public class NiciraSetNshSpi extends AbstractExtensionTreatment { +public class NiciraSetNshSpi extends AbstractExtension implements + ExtensionTreatment { private int nshSpi; - private final KryoNamespace appKryo = new KryoNamespace.Builder() - .register(new Ip4AddressSerializer(), Integer.class) - .register(byte[].class) - .build(); + private final KryoNamespace appKryo = new KryoNamespace.Builder().build(); /** * Creates a new set nsh spi instruction. 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 ec23a9e0..e28a1e24 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,7 +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.AbstractExtensionTreatment; +import org.onosproject.net.flow.AbstractExtension; +import org.onosproject.net.flow.instructions.ExtensionTreatment; import org.onosproject.net.flow.instructions.ExtensionTreatmentType; import org.onosproject.store.serializers.Ip4AddressSerializer; @@ -30,7 +31,8 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Nicira set tunnel destination extension instruction. */ -public class NiciraSetTunnelDst extends AbstractExtensionTreatment { +public class NiciraSetTunnelDst extends AbstractExtension implements + ExtensionTreatment { private Ip4Address tunnelDst; |