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/core/api/src/main/java/org/onosproject/net/flow | |
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/core/api/src/main/java/org/onosproject/net/flow')
18 files changed, 691 insertions, 72 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionTreatment.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/AbstractExtension.java index ac7c771f..b48d69ce 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionTreatment.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/AbstractExtension.java @@ -14,22 +14,25 @@ * limitations under the License. */ -package org.onosproject.net.flow.instructions; +package org.onosproject.net.flow; + +import org.onosproject.net.flow.instructions.ExtensionPropertyException; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; /** - * Abstract implementation of the set/get property methods of ExtensionInstruction. + * Abstract implementation of the set/get property methods of Extension. */ -public abstract class AbstractExtensionTreatment implements ExtensionTreatment { +public abstract class AbstractExtension implements Extension { private static final String INVALID_KEY = "Invalid property key: "; private static final String INVALID_TYPE = "Given type does not match field type: "; @Override - public <T> void setPropertyValue(String key, T value) throws ExtensionPropertyException { + public <T> void setPropertyValue(String key, T value) throws + ExtensionPropertyException { Class<?> clazz = this.getClass(); try { Field field = clazz.getDeclaredField(key); diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java index d3c2449c..0525d8fa 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java @@ -15,14 +15,8 @@ */ package org.onosproject.net.flow; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.TreeSet; - +import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableSet; import org.onlab.packet.Ip4Address; import org.onlab.packet.Ip6Address; import org.onlab.packet.IpPrefix; @@ -30,12 +24,19 @@ import org.onlab.packet.MacAddress; import org.onlab.packet.MplsLabel; import org.onlab.packet.TpPort; import org.onlab.packet.VlanId; +import org.onosproject.net.DeviceId; import org.onosproject.net.PortNumber; import org.onosproject.net.flow.criteria.Criteria; import org.onosproject.net.flow.criteria.Criterion; +import org.onosproject.net.flow.criteria.ExtensionSelector; -import com.google.common.base.MoreObjects; -import com.google.common.collect.ImmutableSet; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.TreeSet; /** * Default traffic selector implementation. @@ -379,6 +380,12 @@ public final class DefaultTrafficSelector implements TrafficSelector { } @Override + public TrafficSelector.Builder extension(ExtensionSelector extensionSelector, + DeviceId deviceId) { + return add(Criteria.extension(extensionSelector, deviceId)); + } + + @Override public TrafficSelector build() { return new DefaultTrafficSelector(ImmutableSet.copyOf(selector.values())); } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java index 22bff7dd..40291f57 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java @@ -489,6 +489,21 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { } @Override + public Builder setArpSpa(IpAddress addr) { + return add(Instructions.modArpSpa(addr)); + } + + @Override + public Builder setArpSha(MacAddress addr) { + return add(Instructions.modArpSha(addr)); + } + + @Override + public Builder setArpOp(short op) { + return add(Instructions.modL3ArpOp(op)); + } + + @Override public TrafficTreatment.Builder extension(ExtensionTreatment extension, DeviceId deviceId) { return add(Instructions.extension(extension, deviceId)); diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/Extension.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/Extension.java new file mode 100644 index 00000000..1d61542e --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/Extension.java @@ -0,0 +1,71 @@ +/* + * 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.net.flow; + +import org.onosproject.net.flow.instructions.ExtensionPropertyException; + +import java.util.List; + +/** + * An extension to the northbound APIs. + */ +public interface Extension { + + /** + * Sets a property on the extension. + * + * @param key property key + * @param value value to set for the given key + * @param <T> class of the value + * @throws ExtensionPropertyException if the given key is not a valid + * property on this extension + */ + <T> void setPropertyValue(String key, T value) throws ExtensionPropertyException; + + /** + * Gets a property value of an extension. + * + * @param key property key + * @param <T> class of the value + * @return value of the property + * @throws ExtensionPropertyException if the given key is not a valid + * property on this extension + */ + <T> T getPropertyValue(String key) throws ExtensionPropertyException; + + /** + * Gets a list of all properties on the extension. + * + * @return list of properties + */ + List<String> getProperties(); + + /** + * Serialize the extension to a byte array. + * + * @return byte array + */ + byte[] serialize(); + + /** + * Deserialize the extension from a byte array. The properties + * of this object will be overwritten with the data in the byte array. + * + * @param data input byte array + */ + void deserialize(byte[] data); +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java index b92281f5..0d055add 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java @@ -15,8 +15,6 @@ */ package org.onosproject.net.flow; -import java.util.Set; - import org.onlab.packet.Ip4Address; import org.onlab.packet.Ip6Address; import org.onlab.packet.IpPrefix; @@ -24,8 +22,12 @@ import org.onlab.packet.MacAddress; import org.onlab.packet.MplsLabel; import org.onlab.packet.TpPort; import org.onlab.packet.VlanId; +import org.onosproject.net.DeviceId; import org.onosproject.net.PortNumber; import org.onosproject.net.flow.criteria.Criterion; +import org.onosproject.net.flow.criteria.ExtensionSelector; + +import java.util.Set; /** * Abstraction of a slice of network traffic. @@ -427,6 +429,15 @@ public interface TrafficSelector { Builder matchArpOp(int arpOp); /** + * Uses an extension selector. + * + * @param extensionSelector extension selector + * @param deviceId device ID + * @return a selection builder + */ + Builder extension(ExtensionSelector extensionSelector, DeviceId deviceId); + + /** * Builds an immutable traffic selector. * * @return traffic selector diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java index 06b6ffa0..3e57925d 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java @@ -424,6 +424,30 @@ public interface TrafficTreatment { Builder setUdpDst(TpPort port); /** + * Sets the arp src ip address. + * + * @param addr an ip + * @return a treatment builder + */ + Builder setArpSpa(IpAddress addr); + + /** + * Sets the arp src mac address. + * + * @param addr a macaddress + * @return a treatment builder + */ + Builder setArpSha(MacAddress addr); + + /** + * Sets the arp operation. + * + * @param op the value of arp operation. + * @return a treatment builder. + */ + Builder setArpOp(short op); + + /** * Uses an extension treatment. * * @param extension extension treatment diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java index a28a4ab9..c94b1e02 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java @@ -23,6 +23,7 @@ import org.onlab.packet.MacAddress; import org.onlab.packet.MplsLabel; import org.onlab.packet.TpPort; import org.onlab.packet.VlanId; +import org.onosproject.net.DeviceId; import org.onosproject.net.IndexedLambda; import org.onosproject.net.Lambda; import org.onosproject.net.OchSignal; @@ -579,6 +580,33 @@ public final class Criteria { return new ArpOpCriterion(arpOp, Type.ARP_OP); } + /** + * Creates a match on PBB I-SID field using the specific value. + * + * @param pbbIsid PBB I-SID + * @return match criterion + */ + public static Criterion matchPbbIsid(int pbbIsid) { + return new PbbIsidCriterion(pbbIsid); + } + + /** + * Creates an extension criterion for the specified extension selector. + * + * @param extensionSelector extension selector + * @param deviceId device ID + * @return match criterion + */ + public static Criterion extension(ExtensionSelector extensionSelector, + DeviceId deviceId) { + return new ExtensionCriterion(extensionSelector, deviceId); + } + + /** + * Creates a dummy criterion. + * + * @return match criterion + */ public static Criterion dummy() { return new DummyCriterion(); } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java index 26665246..17557b9d 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java @@ -177,6 +177,9 @@ public interface Criterion { /** ODU (Optical channel Data Unit) signal type. */ ODU_SIGTYPE, + /** Extension criterion. */ + EXTENSION, + /** An empty criterion. */ DUMMY } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionCriterion.java new file mode 100644 index 00000000..646b4184 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionCriterion.java @@ -0,0 +1,92 @@ +/* + * 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.net.flow.criteria; + +import org.onosproject.net.DeviceId; + +import java.util.Objects; + +import static com.google.common.base.MoreObjects.toStringHelper; + +/** + * Criterion for implementing selector extensions. + */ +public class ExtensionCriterion implements Criterion { + + private final ExtensionSelector extensionSelector; + private final DeviceId deviceId; + + /** + * Constructor. + * + * @param extensionSelector extension selector + */ + public ExtensionCriterion(ExtensionSelector extensionSelector, DeviceId deviceId) { + this.extensionSelector = extensionSelector; + this.deviceId = deviceId; + } + + /** + * Returns the extension selector. + * + * @return extension selector + */ + public ExtensionSelector extensionSelector() { + return extensionSelector; + } + + /** + * Returns the device ID. + * + * @return device ID + */ + public DeviceId deviceId() { + return deviceId; + } + + @Override + public Type type() { + return Type.EXTENSION; + } + + @Override + public String toString() { + return toStringHelper(type().toString()) + .add("extensionSelector", extensionSelector.toString()) + .add("deviceId", deviceId) + .toString(); + } + + @Override + public int hashCode() { + return Objects.hash(type().ordinal(), extensionSelector, deviceId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof ExtensionCriterion) { + ExtensionCriterion that = (ExtensionCriterion) obj; + return Objects.equals(extensionSelector, that.extensionSelector) && + Objects.equals(deviceId, that.deviceId) && + Objects.equals(this.type(), that.type()); + } + return false; + } +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionSelector.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionSelector.java new file mode 100644 index 00000000..d3cebb37 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionSelector.java @@ -0,0 +1,32 @@ +/* + * 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.net.flow.criteria; + +import org.onosproject.net.flow.Extension; + +/** + * An extension for the selector API. + */ +public interface ExtensionSelector extends Extension { + + /** + * Gets the type of the extension selector. + * + * @return type + */ + ExtensionSelectorType type(); +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionSelectorType.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionSelectorType.java new file mode 100644 index 00000000..fa8f0923 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionSelectorType.java @@ -0,0 +1,98 @@ +/* + * 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.net.flow.criteria; + +import com.google.common.annotations.Beta; +import com.google.common.base.MoreObjects; + +import java.util.Objects; + +/** + * Type of selector extensions. + */ +@Beta +public class ExtensionSelectorType { + + /** + * A list of well-known named extension selector type codes. + * These numbers have no impact on the actual OF type id. + */ + public enum ExtensionSelectorTypes { + NICIRA_MATCH_NSH_SPI(0), + NICIRA_MATCH_NSH_SI(1), + NICIRA_MATCH_NSH_CH1(2), + NICIRA_MATCH_NSH_CH2(3), + NICIRA_MATCH_NSH_CH3(4), + NICIRA_MATCH_NSH_CH4(5); + + + private ExtensionSelectorType type; + + /** + * Creates a new named extension selector type. + * + * @param type type code + */ + ExtensionSelectorTypes(int type) { + this.type = new ExtensionSelectorType(type); + } + + /** + * Gets the extension type object for this named type code. + * + * @return extension type object + */ + public ExtensionSelectorType type() { + return type; + } + } + + private final int type; + + /** + * Creates an extension type with the given int type code. + * + * @param type type code + */ + public ExtensionSelectorType(int type) { + this.type = type; + } + + @Override + public int hashCode() { + return Objects.hash(type); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof ExtensionSelectorType) { + final ExtensionSelectorType that = (ExtensionSelectorType) obj; + return this.type == that.type; + } + return false; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(ExtensionSelectorType.class) + .add("type", type) + .toString(); + } +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalIdCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalIdCriterion.java index cb513397..21018544 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalIdCriterion.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalIdCriterion.java @@ -74,7 +74,7 @@ public final class OduSignalIdCriterion implements Criterion { @Override public String toString() { - return toStringHelper(type().toString()) + return toStringHelper(this) .add("oduSignalId", oduSignalId) .toString(); } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalTypeCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalTypeCriterion.java index d92880db..f4854339 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalTypeCriterion.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalTypeCriterion.java @@ -74,7 +74,7 @@ public final class OduSignalTypeCriterion implements Criterion { @Override public String toString() { - return toStringHelper(type().toString()) + return toStringHelper(this) .add("signalType", signalType) .toString(); } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/PbbIsidCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/PbbIsidCriterion.java new file mode 100644 index 00000000..979aa6bd --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/PbbIsidCriterion.java @@ -0,0 +1,75 @@ +/* + * 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.net.flow.criteria; + +import java.util.Objects; + +import static com.google.common.base.MoreObjects.toStringHelper; + +/** + * Implementation of PBB I-SID criterion (24 bits unsigned integer). + */ +public final class PbbIsidCriterion implements Criterion { + private static final int MASK = 0xfffff; + private final int pbbIsid; // PBB I-SID: 24 bits + + /** + * Constructor. + * + * @param pbbIsid the PBB I-SID to match (24 bits) + */ + PbbIsidCriterion(int pbbIsid) { + this.pbbIsid = pbbIsid & MASK; + } + + @Override + public Criterion.Type type() { + return Criterion.Type.PBB_ISID; + } + + /** + * Gets the PBB I-SID to match. + * + * @return the PBB I-SID to match (24 bits) + */ + public int pbbIsid() { + return this.pbbIsid; + } + + @Override + public String toString() { + return toStringHelper(type().toString()) + .add("pbbIsid", Long.toHexString(pbbIsid)).toString(); + } + + @Override + public int hashCode() { + return Objects.hash(type().ordinal(), pbbIsid); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof PbbIsidCriterion) { + PbbIsidCriterion that = (PbbIsidCriterion) obj; + return Objects.equals(pbbIsid, that.pbbIsid) && + Objects.equals(this.type(), that.type()); + } + return false; + } +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatment.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatment.java index 0e8885ed..3df152e9 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatment.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatment.java @@ -16,63 +16,18 @@ package org.onosproject.net.flow.instructions; -import java.util.List; +import org.onosproject.net.flow.Extension; /** - * An extensible instruction type. + * An extension for the treatment API. */ -public interface ExtensionTreatment { +public interface ExtensionTreatment extends Extension { /** - * Gets the type of the extension instruction. + * Gets the type of the treatment extension. * * @return type */ ExtensionTreatmentType type(); - /** - * Sets a property on the extension instruction. - * - * @param key property key - * @param value value to set for the given key - * @param <T> class of the value - * @throws ExtensionPropertyException if the given key is not a valid - * property on this extension instruction - */ - <T> void setPropertyValue(String key, T value) throws ExtensionPropertyException; - - /** - * Gets a property value of an extension instruction. - * - * @param key property key - * @param <T> class of the value - * @return value of the property - * @throws ExtensionPropertyException if the given key is not a valid - * property on this extension instruction - */ - <T> T getPropertyValue(String key) throws ExtensionPropertyException; - - /** - * Gets a list of all properties on the extension instruction. - * - * @return list of properties - */ - List<String> getProperties(); - - /** - * Serialize the extension instruction to a byte array. - * - * @return byte array - */ - byte[] serialize(); - - /** - * Deserialize the extension instruction from a byte array. The properties - * of this object will be overwritten with the data in the byte array. - * - * @param data input byte array - */ - void deserialize(byte[] data); - - } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java index 38fbc279..f597a46c 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java @@ -22,7 +22,7 @@ import com.google.common.base.MoreObjects; import java.util.Objects; /** - * Type of extension instructions. + * Type of treatment extensions. */ @Beta public final class ExtensionTreatmentType { @@ -32,15 +32,24 @@ public final class ExtensionTreatmentType { * These numbers have no impact on the actual OF type id. */ public enum ExtensionTreatmentTypes { - // TODO fix type numbers to include experimenter id NICIRA_SET_TUNNEL_DST(0), NICIRA_RESUBMIT(1), - NICIRA_SET_NSH_SPI(32); + NICIRA_RESUBMIT_TABLE(14), + NICIRA_SET_NSH_SPI(32), + NICIRA_SET_NSH_SI(33), + NICIRA_SET_NSH_CH1(34), + NICIRA_SET_NSH_CH2(35), + NICIRA_SET_NSH_CH3(36), + NICIRA_SET_NSH_CH4(37), + NICIRA_MOV_ARP_SHA_TO_THA(2), + NICIRA_MOV_ARP_SPA_TO_TPA(3), + NICIRA_MOV_ETH_SRC_TO_DST(4), + NICIRA_MOV_IP_SRC_TO_DST(5); private ExtensionTreatmentType type; /** - * Creates a new named extension instruction type. + * Creates a new named extension treatment type. * * @param type type code */ diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java index 4643b315..8ed882c8 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java @@ -35,6 +35,9 @@ import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSig import org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSignalIdInstruction; import org.onosproject.net.flow.instructions.L3ModificationInstruction.L3SubType; import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction; +import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpIPInstruction; +import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpEthInstruction; +import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpOpInstruction; import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction; import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModTtlInstruction; import org.onosproject.net.flow.instructions.L4ModificationInstruction.L4SubType; @@ -299,6 +302,39 @@ public final class Instructions { } /** + * Creates a L3 ARP IP src modification. + * + * @param addr the ip address to modify to + * @return a L3 modification + */ + public static L3ModificationInstruction modArpSpa(IpAddress addr) { + checkNotNull(addr, "Src l3 ARP IP address cannot be null"); + return new ModArpIPInstruction(L3SubType.ARP_SPA, addr); + } + + /** + * Creates a l3 ARP Ether src modification. + * + * @param addr the mac address to modify to + * @return a l3 modification + */ + public static L3ModificationInstruction modArpSha(MacAddress addr) { + checkNotNull(addr, "Src l3 ARP address cannot be null"); + return new ModArpEthInstruction(L3SubType.ARP_SHA, addr); + } + + /** + * Creates a l3 ARP operation modification. + * + * @param op the ARP operation to modify to + * @return a l3 modification + */ + public static L3ModificationInstruction modL3ArpOp(short op) { + checkNotNull(op, "Arp operation cannot be null"); + return new ModArpOpInstruction(L3SubType.ARP_OP, op); + } + + /** * Creates a push MPLS header instruction. * * @return a L2 modification. diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L3ModificationInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L3ModificationInstruction.java index 41819504..0efe9a77 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L3ModificationInstruction.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L3ModificationInstruction.java @@ -20,6 +20,7 @@ import static com.google.common.base.MoreObjects.toStringHelper; import java.util.Objects; import org.onlab.packet.IpAddress; +import org.onlab.packet.MacAddress; /** * Abstraction of a single traffic treatment step. @@ -68,7 +69,22 @@ public abstract class L3ModificationInstruction implements Instruction { /** * Copy TTL in. */ - TTL_IN + TTL_IN, + + /** + * ARP IP src modification. + */ + ARP_SPA, + + /** + * ARP Ether src modification. + */ + ARP_SHA, + + /** + * Arp operation modification. + */ + ARP_OP //TODO: remaining types } @@ -133,6 +149,150 @@ public abstract class L3ModificationInstruction implements Instruction { } /** + * Represents a L3 ARP IP src/dst modification instruction. + */ + public static final class ModArpIPInstruction extends L3ModificationInstruction { + + private final L3SubType subtype; + private final IpAddress ip; + + ModArpIPInstruction(L3SubType subType, IpAddress addr) { + + this.subtype = subType; + this.ip = addr; + } + + @Override + public L3SubType subtype() { + return this.subtype; + } + + public IpAddress ip() { + return this.ip; + } + + @Override + public String toString() { + return toStringHelper(subtype().toString()) + .add("ip", ip).toString(); + } + + @Override + public int hashCode() { + return Objects.hash(type(), subtype(), ip); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof ModArpIPInstruction) { + ModArpIPInstruction that = (ModArpIPInstruction) obj; + return Objects.equals(ip, that.ip) && + Objects.equals(this.subtype(), that.subtype()); + } + return false; + } + } + + /** + * Represents a L3 ARP Ether src/dst modification instruction. + */ + public static final class ModArpEthInstruction extends L3ModificationInstruction { + + private final L3SubType subtype; + private final MacAddress mac; + + ModArpEthInstruction(L3SubType subType, MacAddress addr) { + + this.subtype = subType; + this.mac = addr; + } + + @Override + public L3SubType subtype() { + return this.subtype; + } + + public MacAddress mac() { + return this.mac; + } + + @Override + public String toString() { + return toStringHelper(subtype().toString()) + .add("mac", mac).toString(); + } + + @Override + public int hashCode() { + return Objects.hash(type(), subtype(), mac); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof ModArpEthInstruction) { + ModArpEthInstruction that = (ModArpEthInstruction) obj; + return Objects.equals(mac, that.mac) && + Objects.equals(this.subtype(), that.subtype()); + } + return false; + } + } + + /** + * Represents a L3 ARP operation modification instruction. + */ + public static final class ModArpOpInstruction extends L3ModificationInstruction { + + private final L3SubType subtype; + private final short op; + + ModArpOpInstruction(L3SubType subType, short op) { + + this.subtype = subType; + this.op = op; + } + + @Override + public L3SubType subtype() { + return this.subtype; + } + + public long op() { + return this.op; + } + + @Override + public String toString() { + return toStringHelper(subtype().toString()) + .add("op", op).toString(); + } + + @Override + public int hashCode() { + return Objects.hash(type(), subtype(), op); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof ModArpOpInstruction) { + ModArpOpInstruction that = (ModArpOpInstruction) obj; + return Objects.equals(op, that.op) && + Objects.equals(this.subtype(), that.subtype()); + } + return false; + } + } + + /** * Represents a L3 IPv6 Flow Label (RFC 6437) modification instruction * (20 bits unsigned integer). */ |