diff options
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/net/flow')
13 files changed, 389 insertions, 34 deletions
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 a842d600..d3c2449c 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 @@ -340,7 +340,7 @@ public final class DefaultTrafficSelector implements TrafficSelector { @Override public Builder matchMplsBos(boolean mplsBos) { - return add(Criteria.matchMplsLabel(mplsBos)); + return add(Criteria.matchMplsBos(mplsBos)); } @Override @@ -374,6 +374,11 @@ public final class DefaultTrafficSelector implements TrafficSelector { } @Override + public Builder matchArpOp(int arpOp) { + return add(Criteria.matchArpOp(arpOp)); + } + + @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 4615a82b..22bff7dd 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 @@ -30,7 +30,7 @@ import org.onosproject.core.GroupId; import org.onosproject.net.DeviceId; import org.onosproject.net.IndexedLambda; import org.onosproject.net.PortNumber; -import org.onosproject.net.flow.instructions.ExtensionInstruction; +import org.onosproject.net.flow.instructions.ExtensionTreatment; import org.onosproject.net.flow.instructions.Instruction; import org.onosproject.net.flow.instructions.Instructions; import org.onosproject.net.meter.MeterId; @@ -489,7 +489,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { } @Override - public TrafficTreatment.Builder extension(ExtensionInstruction extension, + 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/TrafficSelector.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java index 9fe88d5a..b92281f5 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 @@ -419,6 +419,14 @@ public interface TrafficSelector { Builder matchArpSha(MacAddress addr); /** + * Matches a arp operation type. + * + * @param arpOp a arp operation type + * @return a selection builder + */ + Builder matchArpOp(int arpOp); + + /** * 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 f1a676ab..06b6ffa0 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 @@ -26,7 +26,7 @@ import org.onlab.packet.VlanId; import org.onosproject.core.GroupId; import org.onosproject.net.DeviceId; import org.onosproject.net.PortNumber; -import org.onosproject.net.flow.instructions.ExtensionInstruction; +import org.onosproject.net.flow.instructions.ExtensionTreatment; import org.onosproject.net.flow.instructions.Instruction; import org.onosproject.net.flow.instructions.Instructions; import org.onosproject.net.meter.MeterId; @@ -430,7 +430,7 @@ public interface TrafficTreatment { * @param deviceId device ID * @return a treatment builder */ - Builder extension(ExtensionInstruction extension, DeviceId deviceId); + Builder extension(ExtensionTreatment extension, DeviceId deviceId); /** * Builds an immutable traffic treatment descriptor. diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpOpCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpOpCriterion.java new file mode 100644 index 00000000..8c5398c6 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpOpCriterion.java @@ -0,0 +1,78 @@ +/* + * 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 static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +/** + * Implementation of arp operation type criterion. + */ +public final class ArpOpCriterion implements Criterion { + private final int arpOp; + private final Type type; + + /** + * Constructor. + * + * @param arpOp the arp operation type to match. + * @param type the match type. Should be the following: + * Type.ARP_OP + */ + ArpOpCriterion(int arpOp, Type type) { + this.arpOp = arpOp; + this.type = type; + } + + @Override + public Type type() { + return this.type; + } + + /** + * Gets the arp operation type to match. + * + * @return the arp operation type to match + */ + public int arpOp() { + return this.arpOp; + } + + @Override + public String toString() { + return toStringHelper(type().toString()) + .add("arpOp", arpOp).toString(); + } + + @Override + public int hashCode() { + return Objects.hash(type().ordinal(), arpOp); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof ArpOpCriterion) { + ArpOpCriterion that = (ArpOpCriterion) obj; + return Objects.equals(arpOp, that.arpOp) && + Objects.equals(type, that.type); + } + return false; + } +}
\ No newline at end of file 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 554b8e74..a28a4ab9 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 @@ -230,6 +230,16 @@ public final class Criteria { } /** + * Creates a match on TCP flags using the specified value. + * + * @param flags TCP flags + * @return match criterion + */ + public static Criterion matchTcpFlags(int flags) { + return new TcpFlagsCriterion(flags); + } + + /** * Creates a match on UDP source port field using the specified value. * * @param udpPort UDP source port @@ -438,11 +448,21 @@ public final class Criteria { * @param mplsBos boolean value indicating true (BOS=1) or false (BOS=0) * @return match criterion */ - public static Criterion matchMplsLabel(boolean mplsBos) { + public static Criterion matchMplsBos(boolean mplsBos) { return new MplsBosCriterion(mplsBos); } /** + * Creates a match on MPLS TC. + * + * @param mplsTc MPLS TC (3 bits) + * @return match criterion + */ + public static Criterion matchMplsTc(byte mplsTc) { + return new MplsTcCriterion(mplsTc); + } + + /** * Creates a match on Tunnel ID. * * @param tunnelId Tunnel ID (64 bits) @@ -549,6 +569,16 @@ public final class Criteria { return new ArpHaCriterion(mac, Type.ARP_SHA); } + /** + * Creates a match on arp operation type field using the specified value. + * + * @param arpOp arp operation type value + * @return match criterion + */ + public static Criterion matchArpOp(int arpOp) { + return new ArpOpCriterion(arpOp, Type.ARP_OP); + } + 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 10cb629f..26665246 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 @@ -28,92 +28,136 @@ public interface Criterion { enum Type { /** Switch input port. */ IN_PORT, + /** Switch physical input port. */ IN_PHY_PORT, + /** Metadata passed between tables. */ METADATA, + /** Ethernet destination address. */ ETH_DST, + /** Ethernet source address. */ ETH_SRC, + /** Ethernet frame type. */ ETH_TYPE, + /** VLAN id. */ VLAN_VID, + /** VLAN priority. */ VLAN_PCP, + /** IP DSCP (6 bits in ToS field). */ IP_DSCP, + /** IP ECN (2 bits in ToS field). */ IP_ECN, + /** IP protocol. */ IP_PROTO, + /** IPv4 source address. */ IPV4_SRC, + /** IPv4 destination address. */ IPV4_DST, + /** TCP source port. */ TCP_SRC, + /** TCP destination port. */ TCP_DST, + /** UDP source port. */ UDP_SRC, + /** UDP destination port. */ UDP_DST, + /** SCTP source port. */ SCTP_SRC, + /** SCTP destination port. */ SCTP_DST, + /** ICMP type. */ ICMPV4_TYPE, + /** ICMP code. */ ICMPV4_CODE, + /** ARP opcode. */ ARP_OP, + /** ARP source IPv4 address. */ ARP_SPA, + /** ARP target IPv4 address. */ ARP_TPA, + /** ARP source hardware address. */ ARP_SHA, + /** ARP target hardware address. */ ARP_THA, + /** IPv6 source address. */ IPV6_SRC, + /** IPv6 destination address. */ IPV6_DST, + /** IPv6 Flow Label. */ IPV6_FLABEL, + /** ICMPv6 type. */ ICMPV6_TYPE, + /** ICMPv6 code. */ ICMPV6_CODE, + /** Target address for ND. */ IPV6_ND_TARGET, + /** Source link-layer for ND. */ IPV6_ND_SLL, + /** Target link-layer for ND. */ IPV6_ND_TLL, + /** MPLS label. */ MPLS_LABEL, + /** MPLS TC. */ MPLS_TC, - /** MPLS BoS bit. */ + + /** MPLS BoS bit. */ MPLS_BOS, + /** PBB I-SID. */ PBB_ISID, + /** Logical Port Metadata. */ TUNNEL_ID, + /** IPv6 Extension Header pseudo-field. */ IPV6_EXTHDR, + /** Unassigned value: 40. */ UNASSIGNED_40, + /** PBB UCA header field. */ PBB_UCA, + /** TCP flags. */ TCP_FLAGS, + /** Output port from action set metadata. */ ACTSET_OUTPUT, + /** Packet type value. */ PACKET_TYPE, @@ -123,16 +167,17 @@ public interface Criterion { // /** Optical channel signal ID (lambda). */ OCH_SIGID, + /** Optical channel signal type (fixed or flexible). */ OCH_SIGTYPE, + /** ODU (Optical channel Data Unit) signal ID. */ ODU_SIGID, + /** ODU (Optical channel Data Unit) signal type. */ ODU_SIGTYPE, - /** - * An empty criterion. - */ + /** An empty criterion. */ DUMMY } @@ -182,4 +227,41 @@ public interface Criterion { return this.value; } } + + enum TCPFlags { + + /** ECN-nonce concealment protection. */ + NS((short) (1 << 0)), + /** Congestion Window Reduced. */ + CWR((short) (1 << 1)), + /** ECN-Echo. **/ + ECE((short) (1 << 2)), + /** Urgent pointer field is significant. */ + URG((short) (1 << 3)), + /** Acknowledgment field is significant. */ + ACK((short) (1 << 4)), + /** Push the buffered data to the receiving application. */ + PSH((short) (1 << 5)), + /** Reset the connection. */ + RST((short) (1 << 6)), + /** Synchronize sequence numbers. */ + SYN((short) (1 << 7)), + /** No more data from sender. */ + FIN((short) (1 << 8)); + + private short value; + + TCPFlags(short value) { + this.value = value; + } + + /** + * Gets the value as an integer. + * + * @return the value as an integer + */ + public short getValue() { + return this.value; + } + } } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsTcCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsTcCriterion.java new file mode 100644 index 00000000..8ad62358 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsTcCriterion.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 MPLS TC criterion (3 bits). + */ +public final class MplsTcCriterion implements Criterion { + private static final byte MASK = 0x7; + private final byte mplsTc; + + /** + * Constructor. + * + * @param mplsTc the MPLS TC to match (3 bits) + */ + MplsTcCriterion(byte mplsTc) { + this.mplsTc = (byte) (mplsTc & MASK); + } + + @Override + public Type type() { + return Type.MPLS_TC; + } + + /** + * Gets the MPLS TC to match. + * + * @return the MPLS TC to match (3 bits) + */ + public byte tc() { + return mplsTc; + } + + @Override + public String toString() { + return toStringHelper(type().toString()) + .add("tc", Long.toHexString(mplsTc)).toString(); + } + + @Override + public int hashCode() { + return Objects.hash(type().ordinal(), mplsTc); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof MplsTcCriterion) { + MplsTcCriterion that = (MplsTcCriterion) obj; + return Objects.equals(mplsTc, that.mplsTc) && + Objects.equals(this.type(), that.type()); + } + return false; + } +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/TcpFlagsCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/TcpFlagsCriterion.java new file mode 100644 index 00000000..e0b53958 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/TcpFlagsCriterion.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 TCP flags criterion (12 bits unsigned integer). + */ +public final class TcpFlagsCriterion implements Criterion { + private static final int MASK = 0xfffff; + private final int flags; // TCP flags: 12 bits + + /** + * Constructor. + * + * @param flags the TCP flags to match (12 bits) + */ + TcpFlagsCriterion(int flags) { + this.flags = flags & MASK; + } + + @Override + public Type type() { + return Type.TCP_FLAGS; + } + + /** + * Gets the TCP flags to match. + * + * @return the TCP flags to match (12 bits) + */ + public int flags() { + return flags; + } + + @Override + public String toString() { + return toStringHelper(type().toString()) + .add("flags", Long.toHexString(flags)).toString(); + } + + @Override + public int hashCode() { + return Objects.hash(type().ordinal(), flags); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof TcpFlagsCriterion) { + TcpFlagsCriterion that = (TcpFlagsCriterion) obj; + return Objects.equals(flags, that.flags) && + Objects.equals(this.type(), that.type()); + } + return false; + } +} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionTreatment.java index 9f22f888..ac7c771f 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionInstruction.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionTreatment.java @@ -23,7 +23,7 @@ import java.util.List; /** * Abstract implementation of the set/get property methods of ExtensionInstruction. */ -public abstract class AbstractExtensionInstruction implements ExtensionInstruction { +public abstract class AbstractExtensionTreatment implements ExtensionTreatment { private static final String INVALID_KEY = "Invalid property key: "; private static final String INVALID_TYPE = "Given type does not match field type: "; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatment.java index 89e0cc5e..0e8885ed 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionInstruction.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatment.java @@ -21,14 +21,14 @@ import java.util.List; /** * An extensible instruction type. */ -public interface ExtensionInstruction { +public interface ExtensionTreatment { /** * Gets the type of the extension instruction. * * @return type */ - ExtensionType type(); + ExtensionTreatmentType type(); /** * Sets a property on the extension instruction. diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionType.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java index 3e1cb75c..38fbc279 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionType.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java @@ -25,25 +25,27 @@ import java.util.Objects; * Type of extension instructions. */ @Beta -public final class ExtensionType { +public final class ExtensionTreatmentType { /** * A list of well-known named extension instruction type codes. + * These numbers have no impact on the actual OF type id. */ - public enum ExtensionTypes { + public enum ExtensionTreatmentTypes { // TODO fix type numbers to include experimenter id - NICIRA_SET_TUNNEL_DST(31), - NICIRA_RESUBMIT(32); + NICIRA_SET_TUNNEL_DST(0), + NICIRA_RESUBMIT(1), + NICIRA_SET_NSH_SPI(32); - private ExtensionType type; + private ExtensionTreatmentType type; /** * Creates a new named extension instruction type. * * @param type type code */ - ExtensionTypes(int type) { - this.type = new ExtensionType(type); + ExtensionTreatmentTypes(int type) { + this.type = new ExtensionTreatmentType(type); } /** @@ -51,7 +53,7 @@ public final class ExtensionType { * * @return extension type object */ - public ExtensionType type() { + public ExtensionTreatmentType type() { return type; } } @@ -63,7 +65,7 @@ public final class ExtensionType { * * @param type type code */ - public ExtensionType(int type) { + public ExtensionTreatmentType(int type) { this.type = type; } @@ -77,8 +79,8 @@ public final class ExtensionType { if (this == obj) { return true; } - if (obj instanceof ExtensionType) { - final ExtensionType that = (ExtensionType) obj; + if (obj instanceof ExtensionTreatmentType) { + final ExtensionTreatmentType that = (ExtensionTreatmentType) obj; return this.type == that.type; } return false; @@ -86,7 +88,7 @@ public final class ExtensionType { @Override public String toString() { - return MoreObjects.toStringHelper(ExtensionType.class) + return MoreObjects.toStringHelper(ExtensionTreatmentType.class) .add("type", type) .toString(); } 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 126e722e..4643b315 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 @@ -489,7 +489,7 @@ public final class Instructions { * @param deviceId device ID * @return extension instruction */ - public static ExtensionInstructionWrapper extension(ExtensionInstruction extension, + public static ExtensionInstructionWrapper extension(ExtensionTreatment extension, DeviceId deviceId) { checkNotNull(extension, "Extension instruction cannot be null"); checkNotNull(deviceId, "Device ID cannot be null"); @@ -858,16 +858,16 @@ public final class Instructions { * Extension instruction. */ public static class ExtensionInstructionWrapper implements Instruction { - private final ExtensionInstruction extensionInstruction; + private final ExtensionTreatment extensionTreatment; private final DeviceId deviceId; - ExtensionInstructionWrapper(ExtensionInstruction extension, DeviceId deviceId) { - extensionInstruction = extension; + ExtensionInstructionWrapper(ExtensionTreatment extension, DeviceId deviceId) { + extensionTreatment = extension; this.deviceId = deviceId; } - public ExtensionInstruction extensionInstruction() { - return extensionInstruction; + public ExtensionTreatment extensionInstruction() { + return extensionTreatment; } public DeviceId deviceId() { @@ -882,14 +882,14 @@ public final class Instructions { @Override public String toString() { return toStringHelper(type().toString()) - .add("extension", extensionInstruction) + .add("extension", extensionTreatment) .add("deviceId", deviceId) .toString(); } @Override public int hashCode() { - return Objects.hash(type().ordinal(), extensionInstruction, deviceId); + return Objects.hash(type().ordinal(), extensionTreatment, deviceId); } @Override @@ -899,7 +899,7 @@ public final class Instructions { } if (obj instanceof ExtensionInstructionWrapper) { ExtensionInstructionWrapper that = (ExtensionInstructionWrapper) obj; - return Objects.equals(extensionInstruction, that.extensionInstruction) + return Objects.equals(extensionTreatment, that.extensionTreatment) && Objects.equals(deviceId, that.deviceId); } |