diff options
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria')
5 files changed, 345 insertions, 5 deletions
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; + } +} |