Committed by
Gerrit Code Review
Pull out inner-classes from Criteria to be independent classes
Make constructors of sub-types of Criterion package private for limiting instantiation only from static factory methods in Criteria Change-Id: I1fb1e9d003288a778a49e758549a92b66bf3cfdf
Showing
34 changed files
with
1948 additions
and
70 deletions
... | @@ -31,7 +31,7 @@ import org.onosproject.net.Host; | ... | @@ -31,7 +31,7 @@ import org.onosproject.net.Host; |
31 | import org.onosproject.net.device.DeviceService; | 31 | import org.onosproject.net.device.DeviceService; |
32 | import org.onosproject.net.flow.FlowRule; | 32 | import org.onosproject.net.flow.FlowRule; |
33 | import org.onosproject.net.flow.FlowRuleService; | 33 | import org.onosproject.net.flow.FlowRuleService; |
34 | -import org.onosproject.net.flow.criteria.Criteria.EthCriterion; | 34 | +import org.onosproject.net.flow.criteria.EthCriterion; |
35 | import org.onosproject.net.flow.criteria.Criterion; | 35 | import org.onosproject.net.flow.criteria.Criterion; |
36 | import org.onosproject.net.flow.criteria.Criterion.Type; | 36 | import org.onosproject.net.flow.criteria.Criterion.Type; |
37 | import org.onosproject.net.host.HostEvent; | 37 | import org.onosproject.net.host.HostEvent; | ... | ... |
... | @@ -40,7 +40,7 @@ import org.onosproject.net.flow.DefaultTrafficSelector; | ... | @@ -40,7 +40,7 @@ import org.onosproject.net.flow.DefaultTrafficSelector; |
40 | import org.onosproject.net.flow.DefaultTrafficTreatment; | 40 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
41 | import org.onosproject.net.flow.TrafficSelector; | 41 | import org.onosproject.net.flow.TrafficSelector; |
42 | import org.onosproject.net.flow.TrafficTreatment; | 42 | import org.onosproject.net.flow.TrafficTreatment; |
43 | -import org.onosproject.net.flow.criteria.Criteria.IPCriterion; | 43 | +import org.onosproject.net.flow.criteria.IPCriterion; |
44 | import org.onosproject.net.flow.criteria.Criterion; | 44 | import org.onosproject.net.flow.criteria.Criterion; |
45 | import org.onosproject.net.host.HostService; | 45 | import org.onosproject.net.host.HostService; |
46 | import org.onosproject.net.intent.Intent; | 46 | import org.onosproject.net.intent.Intent; | ... | ... |
This diff is collapsed. Click to expand it.
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import org.onlab.packet.MacAddress; | ||
19 | + | ||
20 | +import java.util.Objects; | ||
21 | + | ||
22 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
23 | + | ||
24 | +/** | ||
25 | + * Implementation of MAC address criterion. | ||
26 | + */ | ||
27 | +public final class EthCriterion implements Criterion { | ||
28 | + private final MacAddress mac; | ||
29 | + private final Type type; | ||
30 | + | ||
31 | + /** | ||
32 | + * Constructor. | ||
33 | + * | ||
34 | + * @param mac the source or destination MAC address to match | ||
35 | + * @param type the match type. Should be either Type.ETH_DST or | ||
36 | + * Type.ETH_SRC | ||
37 | + */ | ||
38 | + EthCriterion(MacAddress mac, Type type) { | ||
39 | + this.mac = mac; | ||
40 | + this.type = type; | ||
41 | + } | ||
42 | + | ||
43 | + @Override | ||
44 | + public Type type() { | ||
45 | + return this.type; | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * Gets the MAC address to match. | ||
50 | + * | ||
51 | + * @return the MAC address to match | ||
52 | + */ | ||
53 | + public MacAddress mac() { | ||
54 | + return this.mac; | ||
55 | + } | ||
56 | + | ||
57 | + @Override | ||
58 | + public String toString() { | ||
59 | + return toStringHelper(type().toString()) | ||
60 | + .add("mac", mac).toString(); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public int hashCode() { | ||
65 | + return Objects.hash(type, mac); | ||
66 | + } | ||
67 | + | ||
68 | + @Override | ||
69 | + public boolean equals(Object obj) { | ||
70 | + if (this == obj) { | ||
71 | + return true; | ||
72 | + } | ||
73 | + if (obj instanceof EthCriterion) { | ||
74 | + EthCriterion that = (EthCriterion) obj; | ||
75 | + return Objects.equals(mac, that.mac) && | ||
76 | + Objects.equals(type, that.type); | ||
77 | + } | ||
78 | + return false; | ||
79 | + } | ||
80 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
21 | + | ||
22 | +/** | ||
23 | + * Implementation of Ethernet type criterion (16 bits unsigned integer). | ||
24 | + */ | ||
25 | +public final class EthTypeCriterion implements Criterion { | ||
26 | + private static final int MASK = 0xffff; | ||
27 | + private final int ethType; // Ethernet type value: 16 bits | ||
28 | + | ||
29 | + /** | ||
30 | + * Constructor. | ||
31 | + * | ||
32 | + * @param ethType the Ethernet frame type to match (16 bits unsigned | ||
33 | + * integer) | ||
34 | + */ | ||
35 | + EthTypeCriterion(int ethType) { | ||
36 | + this.ethType = ethType & MASK; | ||
37 | + } | ||
38 | + | ||
39 | + @Override | ||
40 | + public Type type() { | ||
41 | + return Type.ETH_TYPE; | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * Gets the Ethernet frame type to match. | ||
46 | + * | ||
47 | + * @return the Ethernet frame type to match (16 bits unsigned integer) | ||
48 | + */ | ||
49 | + public int ethType() { | ||
50 | + return ethType; | ||
51 | + } | ||
52 | + | ||
53 | + @Override | ||
54 | + public String toString() { | ||
55 | + return toStringHelper(type().toString()) | ||
56 | + .add("ethType", Long.toHexString(ethType)) | ||
57 | + .toString(); | ||
58 | + } | ||
59 | + | ||
60 | + @Override | ||
61 | + public int hashCode() { | ||
62 | + return Objects.hash(type(), ethType); | ||
63 | + } | ||
64 | + | ||
65 | + @Override | ||
66 | + public boolean equals(Object obj) { | ||
67 | + if (this == obj) { | ||
68 | + return true; | ||
69 | + } | ||
70 | + if (obj instanceof EthTypeCriterion) { | ||
71 | + EthTypeCriterion that = (EthTypeCriterion) obj; | ||
72 | + return Objects.equals(ethType, that.ethType) && | ||
73 | + Objects.equals(this.type(), that.type()); | ||
74 | + } | ||
75 | + return false; | ||
76 | + } | ||
77 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import org.onlab.packet.IpPrefix; | ||
19 | + | ||
20 | +import java.util.Objects; | ||
21 | + | ||
22 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
23 | + | ||
24 | +/** | ||
25 | + * Implementation of IP address criterion. | ||
26 | + */ | ||
27 | +public final class IPCriterion implements Criterion { | ||
28 | + private final IpPrefix ip; | ||
29 | + private final Type type; | ||
30 | + | ||
31 | + /** | ||
32 | + * Constructor. | ||
33 | + * | ||
34 | + * @param ip the IP prefix to match. Could be either IPv4 or IPv6 | ||
35 | + * @param type the match type. Should be one of the following: | ||
36 | + * Type.IPV4_SRC, Type.IPV4_DST, Type.IPV6_SRC, Type.IPV6_DST | ||
37 | + */ | ||
38 | + IPCriterion(IpPrefix ip, Type type) { | ||
39 | + this.ip = ip; | ||
40 | + this.type = type; | ||
41 | + } | ||
42 | + | ||
43 | + @Override | ||
44 | + public Type type() { | ||
45 | + return this.type; | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * Gets the IP prefix to match. | ||
50 | + * | ||
51 | + * @return the IP prefix to match | ||
52 | + */ | ||
53 | + public IpPrefix ip() { | ||
54 | + return this.ip; | ||
55 | + } | ||
56 | + | ||
57 | + @Override | ||
58 | + public String toString() { | ||
59 | + return toStringHelper(type().toString()) | ||
60 | + .add("ip", ip).toString(); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public int hashCode() { | ||
65 | + return Objects.hash(type, ip); | ||
66 | + } | ||
67 | + | ||
68 | + @Override | ||
69 | + public boolean equals(Object obj) { | ||
70 | + if (this == obj) { | ||
71 | + return true; | ||
72 | + } | ||
73 | + if (obj instanceof IPCriterion) { | ||
74 | + IPCriterion that = (IPCriterion) obj; | ||
75 | + return Objects.equals(ip, that.ip) && | ||
76 | + Objects.equals(type, that.type); | ||
77 | + } | ||
78 | + return false; | ||
79 | + } | ||
80 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
21 | + | ||
22 | +/** | ||
23 | + * Implementation of IP DSCP (Differentiated Services Code Point) | ||
24 | + * criterion (6 bits). | ||
25 | + */ | ||
26 | +public final class IPDscpCriterion implements Criterion { | ||
27 | + private static final byte MASK = 0x3f; | ||
28 | + private final byte ipDscp; // IP DSCP value: 6 bits | ||
29 | + | ||
30 | + /** | ||
31 | + * Constructor. | ||
32 | + * | ||
33 | + * @param ipDscp the IP DSCP value to match | ||
34 | + */ | ||
35 | + IPDscpCriterion(byte ipDscp) { | ||
36 | + this.ipDscp = (byte) (ipDscp & MASK); | ||
37 | + } | ||
38 | + | ||
39 | + @Override | ||
40 | + public Type type() { | ||
41 | + return Type.IP_DSCP; | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * Gets the IP DSCP value to match. | ||
46 | + * | ||
47 | + * @return the IP DSCP value to match | ||
48 | + */ | ||
49 | + public byte ipDscp() { | ||
50 | + return ipDscp; | ||
51 | + } | ||
52 | + | ||
53 | + @Override | ||
54 | + public String toString() { | ||
55 | + return toStringHelper(type().toString()) | ||
56 | + .add("ipDscp", Long.toHexString(ipDscp)).toString(); | ||
57 | + } | ||
58 | + | ||
59 | + @Override | ||
60 | + public int hashCode() { | ||
61 | + return Objects.hash(type(), ipDscp); | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public boolean equals(Object obj) { | ||
66 | + if (this == obj) { | ||
67 | + return true; | ||
68 | + } | ||
69 | + if (obj instanceof IPDscpCriterion) { | ||
70 | + IPDscpCriterion that = (IPDscpCriterion) obj; | ||
71 | + return Objects.equals(ipDscp, that.ipDscp) && | ||
72 | + Objects.equals(this.type(), that.type()); | ||
73 | + } | ||
74 | + return false; | ||
75 | + } | ||
76 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
21 | + | ||
22 | +/** | ||
23 | + * Implementation of IP ECN (Explicit Congestion Notification) criterion | ||
24 | + * (2 bits). | ||
25 | + */ | ||
26 | +public final class IPEcnCriterion implements Criterion { | ||
27 | + private static final byte MASK = 0x3; | ||
28 | + private final byte ipEcn; // IP ECN value: 2 bits | ||
29 | + | ||
30 | + /** | ||
31 | + * Constructor. | ||
32 | + * | ||
33 | + * @param ipEcn the IP ECN value to match (2 bits) | ||
34 | + */ | ||
35 | + IPEcnCriterion(byte ipEcn) { | ||
36 | + this.ipEcn = (byte) (ipEcn & MASK); | ||
37 | + } | ||
38 | + | ||
39 | + @Override | ||
40 | + public Type type() { | ||
41 | + return Type.IP_ECN; | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * Gets the IP ECN value to match. | ||
46 | + * | ||
47 | + * @return the IP ECN value to match (2 bits) | ||
48 | + */ | ||
49 | + public byte ipEcn() { | ||
50 | + return ipEcn; | ||
51 | + } | ||
52 | + | ||
53 | + @Override | ||
54 | + public String toString() { | ||
55 | + return toStringHelper(type().toString()) | ||
56 | + .add("ipEcn", Long.toHexString(ipEcn)).toString(); | ||
57 | + } | ||
58 | + | ||
59 | + @Override | ||
60 | + public int hashCode() { | ||
61 | + return Objects.hash(type(), ipEcn); | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public boolean equals(Object obj) { | ||
66 | + if (this == obj) { | ||
67 | + return true; | ||
68 | + } | ||
69 | + if (obj instanceof IPEcnCriterion) { | ||
70 | + IPEcnCriterion that = (IPEcnCriterion) obj; | ||
71 | + return Objects.equals(ipEcn, that.ipEcn) && | ||
72 | + Objects.equals(this.type(), that.type()); | ||
73 | + } | ||
74 | + return false; | ||
75 | + } | ||
76 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
21 | + | ||
22 | +/** | ||
23 | + * Implementation of Internet Protocol Number criterion (8 bits unsigned) | ||
24 | + * integer. | ||
25 | + */ | ||
26 | +public final class IPProtocolCriterion implements Criterion { | ||
27 | + private static final short MASK = 0xff; | ||
28 | + private final short proto; // IP protocol number: 8 bits | ||
29 | + | ||
30 | + /** | ||
31 | + * Constructor. | ||
32 | + * | ||
33 | + * @param protocol the IP protocol (e.g., TCP=6, UDP=17) to match | ||
34 | + * (8 bits unsigned integer) | ||
35 | + */ | ||
36 | + IPProtocolCriterion(short protocol) { | ||
37 | + this.proto = (short) (protocol & MASK); | ||
38 | + } | ||
39 | + | ||
40 | + @Override | ||
41 | + public Type type() { | ||
42 | + return Type.IP_PROTO; | ||
43 | + } | ||
44 | + | ||
45 | + /** | ||
46 | + * Gets the IP protocol to match. | ||
47 | + * | ||
48 | + * @return the IP protocol to match (8 bits unsigned integer) | ||
49 | + */ | ||
50 | + public short protocol() { | ||
51 | + return proto; | ||
52 | + } | ||
53 | + | ||
54 | + @Override | ||
55 | + public String toString() { | ||
56 | + return toStringHelper(type().toString()) | ||
57 | + .add("protocol", proto).toString(); | ||
58 | + } | ||
59 | + | ||
60 | + @Override | ||
61 | + public int hashCode() { | ||
62 | + return Objects.hash(type(), proto); | ||
63 | + } | ||
64 | + | ||
65 | + @Override | ||
66 | + public boolean equals(Object obj) { | ||
67 | + if (this == obj) { | ||
68 | + return true; | ||
69 | + } | ||
70 | + if (obj instanceof IPProtocolCriterion) { | ||
71 | + IPProtocolCriterion that = (IPProtocolCriterion) obj; | ||
72 | + return Objects.equals(proto, that.proto); | ||
73 | + } | ||
74 | + return false; | ||
75 | + } | ||
76 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
21 | + | ||
22 | +/** | ||
23 | + * Implementation of IPv6 Extension Header pseudo-field criterion | ||
24 | + * (16 bits). Those are defined in Criterion.IPv6ExthdrFlags. | ||
25 | + */ | ||
26 | +public final class IPv6ExthdrFlagsCriterion implements Criterion { | ||
27 | + private static final int MASK = 0xffff; | ||
28 | + private final int exthdrFlags; // IPv6 Exthdr flags: 16 bits | ||
29 | + | ||
30 | + /** | ||
31 | + * Constructor. | ||
32 | + * | ||
33 | + * @param exthdrFlags the IPv6 Extension Header pseudo-field flags | ||
34 | + * to match (16 bits). Those are defined in Criterion.IPv6ExthdrFlags | ||
35 | + */ | ||
36 | + IPv6ExthdrFlagsCriterion(int exthdrFlags) { | ||
37 | + this.exthdrFlags = exthdrFlags & MASK; | ||
38 | + } | ||
39 | + | ||
40 | + @Override | ||
41 | + public Type type() { | ||
42 | + return Type.IPV6_EXTHDR; | ||
43 | + } | ||
44 | + | ||
45 | + /** | ||
46 | + * Gets the IPv6 Extension Header pseudo-field flags to match. | ||
47 | + * | ||
48 | + * @return the IPv6 Extension Header pseudo-field flags to match | ||
49 | + * (16 bits). Those are defined in Criterion.IPv6ExthdrFlags | ||
50 | + */ | ||
51 | + public int exthdrFlags() { | ||
52 | + return exthdrFlags; | ||
53 | + } | ||
54 | + | ||
55 | + @Override | ||
56 | + public String toString() { | ||
57 | + return toStringHelper(type().toString()) | ||
58 | + .add("exthdrFlags", Long.toHexString(exthdrFlags)).toString(); | ||
59 | + } | ||
60 | + | ||
61 | + @Override | ||
62 | + public int hashCode() { | ||
63 | + return Objects.hash(type(), exthdrFlags); | ||
64 | + } | ||
65 | + | ||
66 | + @Override | ||
67 | + public boolean equals(Object obj) { | ||
68 | + if (this == obj) { | ||
69 | + return true; | ||
70 | + } | ||
71 | + if (obj instanceof IPv6ExthdrFlagsCriterion) { | ||
72 | + IPv6ExthdrFlagsCriterion that = (IPv6ExthdrFlagsCriterion) obj; | ||
73 | + return Objects.equals(exthdrFlags, that.exthdrFlags) && | ||
74 | + Objects.equals(this.type(), that.type()); | ||
75 | + } | ||
76 | + return false; | ||
77 | + } | ||
78 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
21 | + | ||
22 | +/** | ||
23 | + * Implementation of IPv6 Flow Label (RFC 6437) criterion (20 bits unsigned | ||
24 | + * integer). | ||
25 | + */ | ||
26 | +public final class IPv6FlowLabelCriterion implements Criterion { | ||
27 | + private static final int MASK = 0xfffff; | ||
28 | + private final int flowLabel; // IPv6 flow label: 20 bits | ||
29 | + | ||
30 | + /** | ||
31 | + * Constructor. | ||
32 | + * | ||
33 | + * @param flowLabel the IPv6 flow label to match (20 bits) | ||
34 | + */ | ||
35 | + IPv6FlowLabelCriterion(int flowLabel) { | ||
36 | + this.flowLabel = flowLabel & MASK; | ||
37 | + } | ||
38 | + | ||
39 | + @Override | ||
40 | + public Type type() { | ||
41 | + return Type.IPV6_FLABEL; | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * Gets the IPv6 flow label to match. | ||
46 | + * | ||
47 | + * @return the IPv6 flow label to match (20 bits) | ||
48 | + */ | ||
49 | + public int flowLabel() { | ||
50 | + return flowLabel; | ||
51 | + } | ||
52 | + | ||
53 | + @Override | ||
54 | + public String toString() { | ||
55 | + return toStringHelper(type().toString()) | ||
56 | + .add("flowLabel", Long.toHexString(flowLabel)).toString(); | ||
57 | + } | ||
58 | + | ||
59 | + @Override | ||
60 | + public int hashCode() { | ||
61 | + return Objects.hash(type(), flowLabel); | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public boolean equals(Object obj) { | ||
66 | + if (this == obj) { | ||
67 | + return true; | ||
68 | + } | ||
69 | + if (obj instanceof IPv6FlowLabelCriterion) { | ||
70 | + IPv6FlowLabelCriterion that = (IPv6FlowLabelCriterion) obj; | ||
71 | + return Objects.equals(flowLabel, that.flowLabel) && | ||
72 | + Objects.equals(this.type(), that.type()); | ||
73 | + } | ||
74 | + return false; | ||
75 | + } | ||
76 | +} |
core/api/src/main/java/org/onosproject/net/flow/criteria/IPv6NDLinkLayerAddressCriterion.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import org.onlab.packet.MacAddress; | ||
19 | + | ||
20 | +import java.util.Objects; | ||
21 | + | ||
22 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
23 | + | ||
24 | +/** | ||
25 | + * Implementation of IPv6 Neighbor Discovery link-layer address criterion. | ||
26 | + */ | ||
27 | +public final class IPv6NDLinkLayerAddressCriterion implements Criterion { | ||
28 | + private final MacAddress mac; | ||
29 | + private final Type type; | ||
30 | + | ||
31 | + /** | ||
32 | + * Constructor. | ||
33 | + * | ||
34 | + * @param mac the source or destination link-layer address to match | ||
35 | + * @param type the match type. Should be either Type.IPV6_ND_SLL or | ||
36 | + * Type.IPV6_ND_TLL | ||
37 | + */ | ||
38 | + IPv6NDLinkLayerAddressCriterion(MacAddress mac, Type type) { | ||
39 | + this.mac = mac; | ||
40 | + this.type = type; | ||
41 | + } | ||
42 | + | ||
43 | + @Override | ||
44 | + public Type type() { | ||
45 | + return this.type; | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * Gets the MAC link-layer address to match. | ||
50 | + * | ||
51 | + * @return the MAC link-layer address to match | ||
52 | + */ | ||
53 | + public MacAddress mac() { | ||
54 | + return this.mac; | ||
55 | + } | ||
56 | + | ||
57 | + @Override | ||
58 | + public String toString() { | ||
59 | + return toStringHelper(type().toString()) | ||
60 | + .add("mac", mac).toString(); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public int hashCode() { | ||
65 | + return Objects.hash(type, mac); | ||
66 | + } | ||
67 | + | ||
68 | + @Override | ||
69 | + public boolean equals(Object obj) { | ||
70 | + if (this == obj) { | ||
71 | + return true; | ||
72 | + } | ||
73 | + if (obj instanceof IPv6NDLinkLayerAddressCriterion) { | ||
74 | + IPv6NDLinkLayerAddressCriterion that = | ||
75 | + (IPv6NDLinkLayerAddressCriterion) obj; | ||
76 | + return Objects.equals(mac, that.mac) && | ||
77 | + Objects.equals(type, that.type); | ||
78 | + } | ||
79 | + return false; | ||
80 | + } | ||
81 | +} |
core/api/src/main/java/org/onosproject/net/flow/criteria/IPv6NDTargetAddressCriterion.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import org.onlab.packet.Ip6Address; | ||
19 | + | ||
20 | +import java.util.Objects; | ||
21 | + | ||
22 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
23 | + | ||
24 | +/** | ||
25 | + * Implementation of IPv6 Neighbor Discovery target address criterion. | ||
26 | + */ | ||
27 | +public final class IPv6NDTargetAddressCriterion implements Criterion { | ||
28 | + private final Ip6Address targetAddress; | ||
29 | + | ||
30 | + /** | ||
31 | + * Constructor. | ||
32 | + * | ||
33 | + * @param targetAddress the IPv6 target address to match | ||
34 | + */ | ||
35 | + IPv6NDTargetAddressCriterion(Ip6Address targetAddress) { | ||
36 | + this.targetAddress = targetAddress; | ||
37 | + } | ||
38 | + | ||
39 | + @Override | ||
40 | + public Type type() { | ||
41 | + return Type.IPV6_ND_TARGET; | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * Gets the IPv6 target address to match. | ||
46 | + * | ||
47 | + * @return the IPv6 target address to match | ||
48 | + */ | ||
49 | + public Ip6Address targetAddress() { | ||
50 | + return this.targetAddress; | ||
51 | + } | ||
52 | + | ||
53 | + @Override | ||
54 | + public String toString() { | ||
55 | + return toStringHelper(type().toString()) | ||
56 | + .add("targetAddress", targetAddress).toString(); | ||
57 | + } | ||
58 | + | ||
59 | + @Override | ||
60 | + public int hashCode() { | ||
61 | + return Objects.hash(type(), targetAddress); | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public boolean equals(Object obj) { | ||
66 | + if (this == obj) { | ||
67 | + return true; | ||
68 | + } | ||
69 | + if (obj instanceof IPv6NDTargetAddressCriterion) { | ||
70 | + IPv6NDTargetAddressCriterion that = | ||
71 | + (IPv6NDTargetAddressCriterion) obj; | ||
72 | + return Objects.equals(targetAddress, that.targetAddress) && | ||
73 | + Objects.equals(type(), that.type()); | ||
74 | + } | ||
75 | + return false; | ||
76 | + } | ||
77 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
21 | + | ||
22 | +/** | ||
23 | + * Implementation of ICMP code criterion (8 bits unsigned integer). | ||
24 | + */ | ||
25 | +public final class IcmpCodeCriterion implements Criterion { | ||
26 | + private static final short MASK = 0xff; | ||
27 | + private final short icmpCode; // The ICMP code: 8 bits | ||
28 | + | ||
29 | + /** | ||
30 | + * Constructor. | ||
31 | + * | ||
32 | + * @param icmpCode the ICMP code to match (8 bits unsigned integer) | ||
33 | + */ | ||
34 | + IcmpCodeCriterion(short icmpCode) { | ||
35 | + this.icmpCode = (short) (icmpCode & MASK); | ||
36 | + } | ||
37 | + | ||
38 | + @Override | ||
39 | + public Type type() { | ||
40 | + return Type.ICMPV4_CODE; | ||
41 | + } | ||
42 | + | ||
43 | + /** | ||
44 | + * Gets the ICMP code to match. | ||
45 | + * | ||
46 | + * @return the ICMP code to match (8 bits unsigned integer) | ||
47 | + */ | ||
48 | + public short icmpCode() { | ||
49 | + return icmpCode; | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public String toString() { | ||
54 | + return toStringHelper(type().toString()) | ||
55 | + .add("icmpCode", icmpCode).toString(); | ||
56 | + } | ||
57 | + | ||
58 | + @Override | ||
59 | + public int hashCode() { | ||
60 | + return Objects.hash(type(), icmpCode); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public boolean equals(Object obj) { | ||
65 | + if (this == obj) { | ||
66 | + return true; | ||
67 | + } | ||
68 | + if (obj instanceof IcmpCodeCriterion) { | ||
69 | + IcmpCodeCriterion that = (IcmpCodeCriterion) obj; | ||
70 | + return Objects.equals(icmpCode, that.icmpCode) && | ||
71 | + Objects.equals(this.type(), that.type()); | ||
72 | + } | ||
73 | + return false; | ||
74 | + } | ||
75 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
21 | + | ||
22 | +/** | ||
23 | + * Implementation of ICMP type criterion (8 bits unsigned integer). | ||
24 | + */ | ||
25 | +public final class IcmpTypeCriterion implements Criterion { | ||
26 | + private static final short MASK = 0xff; | ||
27 | + private final short icmpType; // The ICMP type: 8 bits | ||
28 | + | ||
29 | + /** | ||
30 | + * Constructor. | ||
31 | + * | ||
32 | + * @param icmpType the ICMP type to match (8 bits unsigned integer) | ||
33 | + */ | ||
34 | + IcmpTypeCriterion(short icmpType) { | ||
35 | + this.icmpType = (short) (icmpType & MASK); | ||
36 | + } | ||
37 | + | ||
38 | + @Override | ||
39 | + public Type type() { | ||
40 | + return Type.ICMPV4_TYPE; | ||
41 | + } | ||
42 | + | ||
43 | + /** | ||
44 | + * Gets the ICMP type to match. | ||
45 | + * | ||
46 | + * @return the ICMP type to match (8 bits unsigned integer) | ||
47 | + */ | ||
48 | + public short icmpType() { | ||
49 | + return icmpType; | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public String toString() { | ||
54 | + return toStringHelper(type().toString()) | ||
55 | + .add("icmpType", icmpType).toString(); | ||
56 | + } | ||
57 | + | ||
58 | + @Override | ||
59 | + public int hashCode() { | ||
60 | + return Objects.hash(type(), icmpType); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public boolean equals(Object obj) { | ||
65 | + if (this == obj) { | ||
66 | + return true; | ||
67 | + } | ||
68 | + if (obj instanceof IcmpTypeCriterion) { | ||
69 | + IcmpTypeCriterion that = (IcmpTypeCriterion) obj; | ||
70 | + return Objects.equals(icmpType, that.icmpType) && | ||
71 | + Objects.equals(this.type(), that.type()); | ||
72 | + } | ||
73 | + return false; | ||
74 | + } | ||
75 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
21 | + | ||
22 | +/** | ||
23 | + * Implementation of ICMPv6 code criterion (8 bits unsigned integer). | ||
24 | + */ | ||
25 | +public final class Icmpv6CodeCriterion implements Criterion { | ||
26 | + private static final short MASK = 0xff; | ||
27 | + private final short icmpv6Code; // ICMPv6 code: 8 bits | ||
28 | + | ||
29 | + /** | ||
30 | + * Constructor. | ||
31 | + * | ||
32 | + * @param icmpv6Code the ICMPv6 code to match (8 bits unsigned integer) | ||
33 | + */ | ||
34 | + Icmpv6CodeCriterion(short icmpv6Code) { | ||
35 | + this.icmpv6Code = (short) (icmpv6Code & MASK); | ||
36 | + } | ||
37 | + | ||
38 | + @Override | ||
39 | + public Type type() { | ||
40 | + return Type.ICMPV6_CODE; | ||
41 | + } | ||
42 | + | ||
43 | + /** | ||
44 | + * Gets the ICMPv6 code to match. | ||
45 | + * | ||
46 | + * @return the ICMPv6 code to match (8 bits unsigned integer) | ||
47 | + */ | ||
48 | + public short icmpv6Code() { | ||
49 | + return icmpv6Code; | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public String toString() { | ||
54 | + return toStringHelper(type().toString()) | ||
55 | + .add("icmpv6Code", icmpv6Code).toString(); | ||
56 | + } | ||
57 | + | ||
58 | + @Override | ||
59 | + public int hashCode() { | ||
60 | + return Objects.hash(type(), icmpv6Code); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public boolean equals(Object obj) { | ||
65 | + if (this == obj) { | ||
66 | + return true; | ||
67 | + } | ||
68 | + if (obj instanceof Icmpv6CodeCriterion) { | ||
69 | + Icmpv6CodeCriterion that = (Icmpv6CodeCriterion) obj; | ||
70 | + return Objects.equals(icmpv6Code, that.icmpv6Code) && | ||
71 | + Objects.equals(this.type(), that.type()); | ||
72 | + } | ||
73 | + return false; | ||
74 | + } | ||
75 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
21 | + | ||
22 | +/** | ||
23 | + * Implementation of ICMPv6 type criterion (8 bits unsigned integer). | ||
24 | + */ | ||
25 | +public final class Icmpv6TypeCriterion implements Criterion { | ||
26 | + private static final short MASK = 0xff; | ||
27 | + private final short icmpv6Type; // ICMPv6 type: 8 bits | ||
28 | + | ||
29 | + /** | ||
30 | + * Constructor. | ||
31 | + * | ||
32 | + * @param icmpv6Type the ICMPv6 type to match (8 bits unsigned integer) | ||
33 | + */ | ||
34 | + Icmpv6TypeCriterion(short icmpv6Type) { | ||
35 | + this.icmpv6Type = (short) (icmpv6Type & MASK); | ||
36 | + } | ||
37 | + | ||
38 | + @Override | ||
39 | + public Type type() { | ||
40 | + return Type.ICMPV6_TYPE; | ||
41 | + } | ||
42 | + | ||
43 | + /** | ||
44 | + * Gets the ICMPv6 type to match. | ||
45 | + * | ||
46 | + * @return the ICMPv6 type to match (8 bits unsigned integer) | ||
47 | + */ | ||
48 | + public short icmpv6Type() { | ||
49 | + return icmpv6Type; | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public String toString() { | ||
54 | + return toStringHelper(type().toString()) | ||
55 | + .add("icmpv6Type", icmpv6Type).toString(); | ||
56 | + } | ||
57 | + | ||
58 | + @Override | ||
59 | + public int hashCode() { | ||
60 | + return Objects.hash(type(), icmpv6Type); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public boolean equals(Object obj) { | ||
65 | + if (this == obj) { | ||
66 | + return true; | ||
67 | + } | ||
68 | + if (obj instanceof Icmpv6TypeCriterion) { | ||
69 | + Icmpv6TypeCriterion that = (Icmpv6TypeCriterion) obj; | ||
70 | + return Objects.equals(icmpv6Type, that.icmpv6Type) && | ||
71 | + Objects.equals(this.type(), that.type()); | ||
72 | + } | ||
73 | + return false; | ||
74 | + } | ||
75 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
21 | + | ||
22 | +/** | ||
23 | + * Implementation of lambda (wavelength) criterion (16 bits unsigned | ||
24 | + * integer). | ||
25 | + */ | ||
26 | +public final class LambdaCriterion implements Criterion { | ||
27 | + private static final int MASK = 0xffff; | ||
28 | + private final int lambda; // Lambda value: 16 bits | ||
29 | + private final Type type; | ||
30 | + | ||
31 | + /** | ||
32 | + * Constructor. | ||
33 | + * | ||
34 | + * @param lambda the lambda (wavelength) to match (16 bits unsigned | ||
35 | + * integer) | ||
36 | + * @param type the match type. Should be Type.OCH_SIGID | ||
37 | + */ | ||
38 | + LambdaCriterion(int lambda, Type type) { | ||
39 | + this.lambda = lambda & MASK; | ||
40 | + this.type = type; | ||
41 | + } | ||
42 | + | ||
43 | + @Override | ||
44 | + public Type type() { | ||
45 | + return this.type; | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * Gets the lambda (wavelength) to match. | ||
50 | + * | ||
51 | + * @return the lambda (wavelength) to match (16 bits unsigned integer) | ||
52 | + */ | ||
53 | + public int lambda() { | ||
54 | + return lambda; | ||
55 | + } | ||
56 | + | ||
57 | + @Override | ||
58 | + public String toString() { | ||
59 | + return toStringHelper(type().toString()) | ||
60 | + .add("lambda", lambda).toString(); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public int hashCode() { | ||
65 | + return Objects.hash(type, lambda); | ||
66 | + } | ||
67 | + | ||
68 | + @Override | ||
69 | + public boolean equals(Object obj) { | ||
70 | + if (this == obj) { | ||
71 | + return true; | ||
72 | + } | ||
73 | + if (obj instanceof LambdaCriterion) { | ||
74 | + LambdaCriterion that = (LambdaCriterion) obj; | ||
75 | + return Objects.equals(lambda, that.lambda) && | ||
76 | + Objects.equals(type, that.type); | ||
77 | + } | ||
78 | + return false; | ||
79 | + } | ||
80 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
21 | + | ||
22 | +/** | ||
23 | + * Implementation of Metadata criterion. | ||
24 | + */ | ||
25 | +public final class MetadataCriterion implements Criterion { | ||
26 | + private final long metadata; | ||
27 | + | ||
28 | + /** | ||
29 | + * Constructor. | ||
30 | + * | ||
31 | + * @param metadata the metadata to match (64 bits data) | ||
32 | + */ | ||
33 | + MetadataCriterion(long metadata) { | ||
34 | + this.metadata = metadata; | ||
35 | + } | ||
36 | + | ||
37 | + @Override | ||
38 | + public Type type() { | ||
39 | + return Type.METADATA; | ||
40 | + } | ||
41 | + | ||
42 | + /** | ||
43 | + * Gets the metadata to match. | ||
44 | + * | ||
45 | + * @return the metadata to match (64 bits data) | ||
46 | + */ | ||
47 | + public long metadata() { | ||
48 | + return metadata; | ||
49 | + } | ||
50 | + | ||
51 | + @Override | ||
52 | + public String toString() { | ||
53 | + return toStringHelper(type().toString()) | ||
54 | + .add("metadata", Long.toHexString(metadata)) | ||
55 | + .toString(); | ||
56 | + } | ||
57 | + | ||
58 | + @Override | ||
59 | + public int hashCode() { | ||
60 | + return Objects.hash(type(), metadata); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public boolean equals(Object obj) { | ||
65 | + if (this == obj) { | ||
66 | + return true; | ||
67 | + } | ||
68 | + if (obj instanceof MetadataCriterion) { | ||
69 | + MetadataCriterion that = (MetadataCriterion) obj; | ||
70 | + return Objects.equals(metadata, that.metadata) && | ||
71 | + Objects.equals(this.type(), that.type()); | ||
72 | + } | ||
73 | + return false; | ||
74 | + } | ||
75 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import org.onlab.packet.MplsLabel; | ||
19 | + | ||
20 | +import java.util.Objects; | ||
21 | + | ||
22 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
23 | + | ||
24 | +/** | ||
25 | + * Implementation of MPLS tag criterion (20 bits). | ||
26 | + */ | ||
27 | +public final class MplsCriterion implements Criterion { | ||
28 | + private static final int MASK = 0xfffff; | ||
29 | + private final MplsLabel mplsLabel; | ||
30 | + | ||
31 | + MplsCriterion(MplsLabel mplsLabel) { | ||
32 | + this.mplsLabel = mplsLabel; | ||
33 | + } | ||
34 | + | ||
35 | + @Override | ||
36 | + public Type type() { | ||
37 | + return Type.MPLS_LABEL; | ||
38 | + } | ||
39 | + | ||
40 | + public MplsLabel label() { | ||
41 | + return mplsLabel; | ||
42 | + } | ||
43 | + | ||
44 | + @Override | ||
45 | + public String toString() { | ||
46 | + return toStringHelper(type().toString()) | ||
47 | + .add("mpls", mplsLabel).toString(); | ||
48 | + } | ||
49 | + | ||
50 | + @Override | ||
51 | + public int hashCode() { | ||
52 | + return Objects.hash(type(), mplsLabel); | ||
53 | + } | ||
54 | + | ||
55 | + @Override | ||
56 | + public boolean equals(Object obj) { | ||
57 | + if (this == obj) { | ||
58 | + return true; | ||
59 | + } | ||
60 | + if (obj instanceof MplsCriterion) { | ||
61 | + MplsCriterion that = (MplsCriterion) obj; | ||
62 | + return Objects.equals(mplsLabel, that.mplsLabel) && | ||
63 | + Objects.equals(this.type(), that.type()); | ||
64 | + } | ||
65 | + return false; | ||
66 | + } | ||
67 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
21 | + | ||
22 | +/** | ||
23 | + * Implementation of optical signal type criterion (8 bits unsigned | ||
24 | + * integer). | ||
25 | + */ | ||
26 | +public final class OpticalSignalTypeCriterion implements Criterion { | ||
27 | + private static final short MASK = 0xff; | ||
28 | + private final short signalType; // Signal type value: 8 bits | ||
29 | + private final Type type; | ||
30 | + | ||
31 | + /** | ||
32 | + * Constructor. | ||
33 | + * | ||
34 | + * @param signalType the optical signal type to match (8 bits unsigned | ||
35 | + * integer) | ||
36 | + * @param type the match type. Should be Type.OCH_SIGTYPE | ||
37 | + */ | ||
38 | + OpticalSignalTypeCriterion(short signalType, Type type) { | ||
39 | + this.signalType = (short) (signalType & MASK); | ||
40 | + this.type = type; | ||
41 | + } | ||
42 | + | ||
43 | + @Override | ||
44 | + public Type type() { | ||
45 | + return this.type; | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * Gets the optical signal type to match. | ||
50 | + * | ||
51 | + * @return the optical signal type to match (8 bits unsigned integer) | ||
52 | + */ | ||
53 | + public short signalType() { | ||
54 | + return signalType; | ||
55 | + } | ||
56 | + | ||
57 | + @Override | ||
58 | + public String toString() { | ||
59 | + return toStringHelper(type().toString()) | ||
60 | + .add("signalType", signalType).toString(); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public int hashCode() { | ||
65 | + return Objects.hash(type, signalType); | ||
66 | + } | ||
67 | + | ||
68 | + @Override | ||
69 | + public boolean equals(Object obj) { | ||
70 | + if (this == obj) { | ||
71 | + return true; | ||
72 | + } | ||
73 | + if (obj instanceof OpticalSignalTypeCriterion) { | ||
74 | + OpticalSignalTypeCriterion that = (OpticalSignalTypeCriterion) obj; | ||
75 | + return Objects.equals(signalType, that.signalType) && | ||
76 | + Objects.equals(type, that.type); | ||
77 | + } | ||
78 | + return false; | ||
79 | + } | ||
80 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import org.onosproject.net.PortNumber; | ||
19 | + | ||
20 | +import java.util.Objects; | ||
21 | + | ||
22 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
23 | + | ||
24 | +/** | ||
25 | + * Implementation of input port criterion. | ||
26 | + */ | ||
27 | +public final class PortCriterion implements Criterion { | ||
28 | + private final PortNumber port; | ||
29 | + private final Type type; | ||
30 | + | ||
31 | + /** | ||
32 | + * Constructor. | ||
33 | + * | ||
34 | + * @param port the input port number to match | ||
35 | + * @param type the match type. Should be either Type.IN_PORT or | ||
36 | + * Type.IN_PHY_PORT | ||
37 | + */ | ||
38 | + PortCriterion(PortNumber port, Type type) { | ||
39 | + this.port = port; | ||
40 | + this.type = type; | ||
41 | + } | ||
42 | + | ||
43 | + @Override | ||
44 | + public Type type() { | ||
45 | + return this.type; | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * Gets the input port number to match. | ||
50 | + * | ||
51 | + * @return the input port number to match | ||
52 | + */ | ||
53 | + public PortNumber port() { | ||
54 | + return this.port; | ||
55 | + } | ||
56 | + | ||
57 | + @Override | ||
58 | + public String toString() { | ||
59 | + return toStringHelper(type().toString()) | ||
60 | + .add("port", port).toString(); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public int hashCode() { | ||
65 | + return Objects.hash(type(), port); | ||
66 | + } | ||
67 | + | ||
68 | + @Override | ||
69 | + public boolean equals(Object obj) { | ||
70 | + if (this == obj) { | ||
71 | + return true; | ||
72 | + } | ||
73 | + if (obj instanceof PortCriterion) { | ||
74 | + PortCriterion that = (PortCriterion) obj; | ||
75 | + return Objects.equals(port, that.port) && | ||
76 | + Objects.equals(this.type(), that.type()); | ||
77 | + } | ||
78 | + return false; | ||
79 | + } | ||
80 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
21 | + | ||
22 | +/** | ||
23 | + * Implementation of SCTP port criterion (16 bits unsigned integer). | ||
24 | + */ | ||
25 | +public final class SctpPortCriterion implements Criterion { | ||
26 | + private static final int MASK = 0xffff; | ||
27 | + private final int sctpPort; // Port value: 16 bits | ||
28 | + private final Type type; | ||
29 | + | ||
30 | + /** | ||
31 | + * Constructor. | ||
32 | + * | ||
33 | + * @param sctpPort the SCTP port to match (16 bits unsigned integer) | ||
34 | + * @param type the match type. Should be either Type.SCTP_SRC or | ||
35 | + * Type.SCTP_DST | ||
36 | + */ | ||
37 | + SctpPortCriterion(int sctpPort, Type type) { | ||
38 | + this.sctpPort = sctpPort & MASK; | ||
39 | + this.type = type; | ||
40 | + } | ||
41 | + | ||
42 | + @Override | ||
43 | + public Type type() { | ||
44 | + return this.type; | ||
45 | + } | ||
46 | + | ||
47 | + /** | ||
48 | + * Gets the SCTP port to match. | ||
49 | + * | ||
50 | + * @return the SCTP port to match (16 bits unsigned integer) | ||
51 | + */ | ||
52 | + public int sctpPort() { | ||
53 | + return this.sctpPort; | ||
54 | + } | ||
55 | + | ||
56 | + @Override | ||
57 | + public String toString() { | ||
58 | + return toStringHelper(type().toString()) | ||
59 | + .add("sctpPort", sctpPort).toString(); | ||
60 | + } | ||
61 | + | ||
62 | + @Override | ||
63 | + public int hashCode() { | ||
64 | + return Objects.hash(type, sctpPort); | ||
65 | + } | ||
66 | + | ||
67 | + @Override | ||
68 | + public boolean equals(Object obj) { | ||
69 | + if (this == obj) { | ||
70 | + return true; | ||
71 | + } | ||
72 | + if (obj instanceof SctpPortCriterion) { | ||
73 | + SctpPortCriterion that = (SctpPortCriterion) obj; | ||
74 | + return Objects.equals(sctpPort, that.sctpPort) && | ||
75 | + Objects.equals(type, that.type); | ||
76 | + } | ||
77 | + return false; | ||
78 | + } | ||
79 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
21 | + | ||
22 | +/** | ||
23 | + * Implementation of TCP port criterion (16 bits unsigned integer). | ||
24 | + */ | ||
25 | +public final class TcpPortCriterion implements Criterion { | ||
26 | + private static final int MASK = 0xffff; | ||
27 | + private final int tcpPort; // Port value: 16 bits | ||
28 | + private final Type type; | ||
29 | + | ||
30 | + /** | ||
31 | + * Constructor. | ||
32 | + * | ||
33 | + * @param tcpPort the TCP port to match (16 bits unsigned integer) | ||
34 | + * @param type the match type. Should be either Type.TCP_SRC or | ||
35 | + * Type.TCP_DST | ||
36 | + */ | ||
37 | + TcpPortCriterion(int tcpPort, Type type) { | ||
38 | + this.tcpPort = tcpPort & MASK; | ||
39 | + this.type = type; | ||
40 | + } | ||
41 | + | ||
42 | + @Override | ||
43 | + public Type type() { | ||
44 | + return this.type; | ||
45 | + } | ||
46 | + | ||
47 | + /** | ||
48 | + * Gets the TCP port to match. | ||
49 | + * | ||
50 | + * @return the TCP port to match (16 bits unsigned integer) | ||
51 | + */ | ||
52 | + public int tcpPort() { | ||
53 | + return this.tcpPort; | ||
54 | + } | ||
55 | + | ||
56 | + @Override | ||
57 | + public String toString() { | ||
58 | + return toStringHelper(type().toString()) | ||
59 | + .add("tcpPort", tcpPort).toString(); | ||
60 | + } | ||
61 | + | ||
62 | + @Override | ||
63 | + public int hashCode() { | ||
64 | + return Objects.hash(type, tcpPort); | ||
65 | + } | ||
66 | + | ||
67 | + @Override | ||
68 | + public boolean equals(Object obj) { | ||
69 | + if (this == obj) { | ||
70 | + return true; | ||
71 | + } | ||
72 | + if (obj instanceof TcpPortCriterion) { | ||
73 | + TcpPortCriterion that = (TcpPortCriterion) obj; | ||
74 | + return Objects.equals(tcpPort, that.tcpPort) && | ||
75 | + Objects.equals(type, that.type); | ||
76 | + } | ||
77 | + return false; | ||
78 | + } | ||
79 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
21 | + | ||
22 | +/** | ||
23 | + * Implementation of UDP port criterion (16 bits unsigned integer). | ||
24 | + */ | ||
25 | +public final class UdpPortCriterion implements Criterion { | ||
26 | + private static final int MASK = 0xffff; | ||
27 | + private final int udpPort; // Port value: 16 bits | ||
28 | + private final Type type; | ||
29 | + | ||
30 | + /** | ||
31 | + * Constructor. | ||
32 | + * | ||
33 | + * @param udpPort the UDP port to match (16 bits unsigned integer) | ||
34 | + * @param type the match type. Should be either Type.UDP_SRC or | ||
35 | + * Type.UDP_DST | ||
36 | + */ | ||
37 | + UdpPortCriterion(int udpPort, Type type) { | ||
38 | + this.udpPort = udpPort & MASK; | ||
39 | + this.type = type; | ||
40 | + } | ||
41 | + | ||
42 | + @Override | ||
43 | + public Type type() { | ||
44 | + return this.type; | ||
45 | + } | ||
46 | + | ||
47 | + /** | ||
48 | + * Gets the UDP port to match. | ||
49 | + * | ||
50 | + * @return the UDP port to match (16 bits unsigned integer) | ||
51 | + */ | ||
52 | + public int udpPort() { | ||
53 | + return this.udpPort; | ||
54 | + } | ||
55 | + | ||
56 | + @Override | ||
57 | + public String toString() { | ||
58 | + return toStringHelper(type().toString()) | ||
59 | + .add("udpPort", udpPort).toString(); | ||
60 | + } | ||
61 | + | ||
62 | + @Override | ||
63 | + public int hashCode() { | ||
64 | + return Objects.hash(type, udpPort); | ||
65 | + } | ||
66 | + | ||
67 | + @Override | ||
68 | + public boolean equals(Object obj) { | ||
69 | + if (this == obj) { | ||
70 | + return true; | ||
71 | + } | ||
72 | + if (obj instanceof UdpPortCriterion) { | ||
73 | + UdpPortCriterion that = (UdpPortCriterion) obj; | ||
74 | + return Objects.equals(udpPort, that.udpPort) && | ||
75 | + Objects.equals(type, that.type); | ||
76 | + } | ||
77 | + return false; | ||
78 | + } | ||
79 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import org.onlab.packet.VlanId; | ||
19 | + | ||
20 | +import java.util.Objects; | ||
21 | + | ||
22 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
23 | + | ||
24 | +/** | ||
25 | + * Implementation of VLAN ID criterion. | ||
26 | + */ | ||
27 | +public final class VlanIdCriterion implements Criterion { | ||
28 | + private final VlanId vlanId; | ||
29 | + | ||
30 | + /** | ||
31 | + * Constructor. | ||
32 | + * | ||
33 | + * @param vlanId the VLAN ID to match | ||
34 | + */ | ||
35 | + VlanIdCriterion(VlanId vlanId) { | ||
36 | + this.vlanId = vlanId; | ||
37 | + } | ||
38 | + | ||
39 | + @Override | ||
40 | + public Type type() { | ||
41 | + return Type.VLAN_VID; | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * Gets the VLAN ID to match. | ||
46 | + * | ||
47 | + * @return the VLAN ID to match | ||
48 | + */ | ||
49 | + public VlanId vlanId() { | ||
50 | + return vlanId; | ||
51 | + } | ||
52 | + | ||
53 | + @Override | ||
54 | + public String toString() { | ||
55 | + return toStringHelper(type().toString()) | ||
56 | + .add("vlanId", vlanId).toString(); | ||
57 | + } | ||
58 | + | ||
59 | + @Override | ||
60 | + public int hashCode() { | ||
61 | + return Objects.hash(type(), vlanId); | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public boolean equals(Object obj) { | ||
66 | + if (this == obj) { | ||
67 | + return true; | ||
68 | + } | ||
69 | + if (obj instanceof VlanIdCriterion) { | ||
70 | + VlanIdCriterion that = (VlanIdCriterion) obj; | ||
71 | + return Objects.equals(vlanId, that.vlanId) && | ||
72 | + Objects.equals(this.type(), that.type()); | ||
73 | + } | ||
74 | + return false; | ||
75 | + } | ||
76 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.flow.criteria; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
21 | + | ||
22 | +/** | ||
23 | + * Implementation of VLAN priority criterion (3 bits). | ||
24 | + */ | ||
25 | +public final class VlanPcpCriterion implements Criterion { | ||
26 | + private static final byte MASK = 0x7; | ||
27 | + private final byte vlanPcp; // VLAN pcp value: 3 bits | ||
28 | + | ||
29 | + /** | ||
30 | + * Constructor. | ||
31 | + * | ||
32 | + * @param vlanPcp the VLAN priority to match (3 bits) | ||
33 | + */ | ||
34 | + VlanPcpCriterion(byte vlanPcp) { | ||
35 | + this.vlanPcp = (byte) (vlanPcp & MASK); | ||
36 | + } | ||
37 | + | ||
38 | + @Override | ||
39 | + public Type type() { | ||
40 | + return Type.VLAN_PCP; | ||
41 | + } | ||
42 | + | ||
43 | + /** | ||
44 | + * Gets the VLAN priority to match. | ||
45 | + * | ||
46 | + * @return the VLAN priority to match (3 bits) | ||
47 | + */ | ||
48 | + public byte priority() { | ||
49 | + return vlanPcp; | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public String toString() { | ||
54 | + return toStringHelper(type().toString()) | ||
55 | + .add("priority", Long.toHexString(vlanPcp)).toString(); | ||
56 | + } | ||
57 | + | ||
58 | + @Override | ||
59 | + public int hashCode() { | ||
60 | + return Objects.hash(type(), vlanPcp); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public boolean equals(Object obj) { | ||
65 | + if (this == obj) { | ||
66 | + return true; | ||
67 | + } | ||
68 | + if (obj instanceof VlanPcpCriterion) { | ||
69 | + VlanPcpCriterion that = (VlanPcpCriterion) obj; | ||
70 | + return Objects.equals(vlanPcp, that.vlanPcp) && | ||
71 | + Objects.equals(this.type(), that.type()); | ||
72 | + } | ||
73 | + return false; | ||
74 | + } | ||
75 | +} |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
... | @@ -34,8 +34,8 @@ import org.onosproject.net.flow.DefaultTrafficTreatment; | ... | @@ -34,8 +34,8 @@ import org.onosproject.net.flow.DefaultTrafficTreatment; |
34 | import org.onosproject.net.flow.FlowRule; | 34 | import org.onosproject.net.flow.FlowRule; |
35 | import org.onosproject.net.flow.TrafficSelector; | 35 | import org.onosproject.net.flow.TrafficSelector; |
36 | import org.onosproject.net.flow.TrafficTreatment; | 36 | import org.onosproject.net.flow.TrafficTreatment; |
37 | -import org.onosproject.net.flow.criteria.Criteria; | ||
38 | import org.onosproject.net.flow.criteria.Criterion; | 37 | import org.onosproject.net.flow.criteria.Criterion; |
38 | +import org.onosproject.net.flow.criteria.EthTypeCriterion; | ||
39 | import org.onosproject.net.intent.FlowRuleIntent; | 39 | import org.onosproject.net.intent.FlowRuleIntent; |
40 | import org.onosproject.net.intent.Intent; | 40 | import org.onosproject.net.intent.Intent; |
41 | import org.onosproject.net.intent.IntentCompiler; | 41 | import org.onosproject.net.intent.IntentCompiler; |
... | @@ -241,8 +241,8 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { | ... | @@ -241,8 +241,8 @@ public class MplsPathIntentCompiler implements IntentCompiler<MplsPathIntent> { |
241 | // if the ingress ethertype is defined, the egress traffic | 241 | // if the ingress ethertype is defined, the egress traffic |
242 | // will be use that value, otherwise the IPv4 ethertype is used. | 242 | // will be use that value, otherwise the IPv4 ethertype is used. |
243 | Criterion c = intent.selector().getCriterion(Criterion.Type.ETH_TYPE); | 243 | Criterion c = intent.selector().getCriterion(Criterion.Type.ETH_TYPE); |
244 | - if (c != null && c instanceof Criteria.EthTypeCriterion) { | 244 | + if (c != null && c instanceof EthTypeCriterion) { |
245 | - Criteria.EthTypeCriterion ethertype = (Criteria.EthTypeCriterion) c; | 245 | + EthTypeCriterion ethertype = (EthTypeCriterion) c; |
246 | treat.popMpls((short) ethertype.ethType()); | 246 | treat.popMpls((short) ethertype.ethType()); |
247 | } else { | 247 | } else { |
248 | treat.popMpls(Ethernet.TYPE_IPV4); | 248 | treat.popMpls(Ethernet.TYPE_IPV4); | ... | ... |
... | @@ -73,8 +73,31 @@ import org.onosproject.net.flow.FlowRuleBatchOperation; | ... | @@ -73,8 +73,31 @@ import org.onosproject.net.flow.FlowRuleBatchOperation; |
73 | import org.onosproject.net.flow.FlowRuleBatchRequest; | 73 | import org.onosproject.net.flow.FlowRuleBatchRequest; |
74 | import org.onosproject.net.flow.FlowRuleExtPayLoad; | 74 | import org.onosproject.net.flow.FlowRuleExtPayLoad; |
75 | import org.onosproject.net.flow.StoredFlowEntry; | 75 | import org.onosproject.net.flow.StoredFlowEntry; |
76 | -import org.onosproject.net.flow.criteria.Criteria; | ||
77 | import org.onosproject.net.flow.criteria.Criterion; | 76 | import org.onosproject.net.flow.criteria.Criterion; |
77 | +import org.onosproject.net.flow.criteria.EthCriterion; | ||
78 | +import org.onosproject.net.flow.criteria.EthTypeCriterion; | ||
79 | +import org.onosproject.net.flow.criteria.IPCriterion; | ||
80 | +import org.onosproject.net.flow.criteria.IPDscpCriterion; | ||
81 | +import org.onosproject.net.flow.criteria.IPEcnCriterion; | ||
82 | +import org.onosproject.net.flow.criteria.IPProtocolCriterion; | ||
83 | +import org.onosproject.net.flow.criteria.IPv6ExthdrFlagsCriterion; | ||
84 | +import org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion; | ||
85 | +import org.onosproject.net.flow.criteria.IPv6NDLinkLayerAddressCriterion; | ||
86 | +import org.onosproject.net.flow.criteria.IPv6NDTargetAddressCriterion; | ||
87 | +import org.onosproject.net.flow.criteria.IcmpCodeCriterion; | ||
88 | +import org.onosproject.net.flow.criteria.IcmpTypeCriterion; | ||
89 | +import org.onosproject.net.flow.criteria.Icmpv6CodeCriterion; | ||
90 | +import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion; | ||
91 | +import org.onosproject.net.flow.criteria.LambdaCriterion; | ||
92 | +import org.onosproject.net.flow.criteria.MetadataCriterion; | ||
93 | +import org.onosproject.net.flow.criteria.MplsCriterion; | ||
94 | +import org.onosproject.net.flow.criteria.OpticalSignalTypeCriterion; | ||
95 | +import org.onosproject.net.flow.criteria.PortCriterion; | ||
96 | +import org.onosproject.net.flow.criteria.SctpPortCriterion; | ||
97 | +import org.onosproject.net.flow.criteria.TcpPortCriterion; | ||
98 | +import org.onosproject.net.flow.criteria.UdpPortCriterion; | ||
99 | +import org.onosproject.net.flow.criteria.VlanIdCriterion; | ||
100 | +import org.onosproject.net.flow.criteria.VlanPcpCriterion; | ||
78 | import org.onosproject.net.flow.instructions.Instructions; | 101 | import org.onosproject.net.flow.instructions.Instructions; |
79 | import org.onosproject.net.flow.instructions.L0ModificationInstruction; | 102 | import org.onosproject.net.flow.instructions.L0ModificationInstruction; |
80 | import org.onosproject.net.flow.instructions.L2ModificationInstruction; | 103 | import org.onosproject.net.flow.instructions.L2ModificationInstruction; |
... | @@ -234,30 +257,30 @@ public final class KryoNamespaces { | ... | @@ -234,30 +257,30 @@ public final class KryoNamespaces { |
234 | FlowEntry.FlowEntryState.class, | 257 | FlowEntry.FlowEntryState.class, |
235 | FlowId.class, | 258 | FlowId.class, |
236 | DefaultTrafficSelector.class, | 259 | DefaultTrafficSelector.class, |
237 | - Criteria.PortCriterion.class, | 260 | + PortCriterion.class, |
238 | - Criteria.MetadataCriterion.class, | 261 | + MetadataCriterion.class, |
239 | - Criteria.EthCriterion.class, | 262 | + EthCriterion.class, |
240 | - Criteria.EthTypeCriterion.class, | 263 | + EthTypeCriterion.class, |
241 | - Criteria.VlanIdCriterion.class, | 264 | + VlanIdCriterion.class, |
242 | - Criteria.VlanPcpCriterion.class, | 265 | + VlanPcpCriterion.class, |
243 | - Criteria.IPDscpCriterion.class, | 266 | + IPDscpCriterion.class, |
244 | - Criteria.IPEcnCriterion.class, | 267 | + IPEcnCriterion.class, |
245 | - Criteria.IPProtocolCriterion.class, | 268 | + IPProtocolCriterion.class, |
246 | - Criteria.IPCriterion.class, | 269 | + IPCriterion.class, |
247 | - Criteria.TcpPortCriterion.class, | 270 | + TcpPortCriterion.class, |
248 | - Criteria.UdpPortCriterion.class, | 271 | + UdpPortCriterion.class, |
249 | - Criteria.SctpPortCriterion.class, | 272 | + SctpPortCriterion.class, |
250 | - Criteria.IcmpTypeCriterion.class, | 273 | + IcmpTypeCriterion.class, |
251 | - Criteria.IcmpCodeCriterion.class, | 274 | + IcmpCodeCriterion.class, |
252 | - Criteria.IPv6FlowLabelCriterion.class, | 275 | + IPv6FlowLabelCriterion.class, |
253 | - Criteria.Icmpv6TypeCriterion.class, | 276 | + Icmpv6TypeCriterion.class, |
254 | - Criteria.Icmpv6CodeCriterion.class, | 277 | + Icmpv6CodeCriterion.class, |
255 | - Criteria.IPv6NDTargetAddressCriterion.class, | 278 | + IPv6NDTargetAddressCriterion.class, |
256 | - Criteria.IPv6NDLinkLayerAddressCriterion.class, | 279 | + IPv6NDLinkLayerAddressCriterion.class, |
257 | - Criteria.MplsCriterion.class, | 280 | + MplsCriterion.class, |
258 | - Criteria.IPv6ExthdrFlagsCriterion.class, | 281 | + IPv6ExthdrFlagsCriterion.class, |
259 | - Criteria.LambdaCriterion.class, | 282 | + LambdaCriterion.class, |
260 | - Criteria.OpticalSignalTypeCriterion.class, | 283 | + OpticalSignalTypeCriterion.class, |
261 | Criterion.class, | 284 | Criterion.class, |
262 | Criterion.Type.class, | 285 | Criterion.Type.class, |
263 | DefaultTrafficTreatment.class, | 286 | DefaultTrafficTreatment.class, | ... | ... |
... | @@ -44,6 +44,12 @@ import org.onosproject.net.flow.TrafficSelector; | ... | @@ -44,6 +44,12 @@ import org.onosproject.net.flow.TrafficSelector; |
44 | import org.onosproject.net.flow.TrafficTreatment; | 44 | import org.onosproject.net.flow.TrafficTreatment; |
45 | import org.onosproject.net.flow.criteria.Criteria; | 45 | import org.onosproject.net.flow.criteria.Criteria; |
46 | import org.onosproject.net.flow.criteria.Criterion; | 46 | import org.onosproject.net.flow.criteria.Criterion; |
47 | +import org.onosproject.net.flow.criteria.EthCriterion; | ||
48 | +import org.onosproject.net.flow.criteria.EthTypeCriterion; | ||
49 | +import org.onosproject.net.flow.criteria.IPCriterion; | ||
50 | +import org.onosproject.net.flow.criteria.IPProtocolCriterion; | ||
51 | +import org.onosproject.net.flow.criteria.PortCriterion; | ||
52 | +import org.onosproject.net.flow.criteria.VlanIdCriterion; | ||
47 | import org.onosproject.net.flowobjective.FilteringObjective; | 53 | import org.onosproject.net.flowobjective.FilteringObjective; |
48 | import org.onosproject.net.flowobjective.FlowObjectiveStore; | 54 | import org.onosproject.net.flowobjective.FlowObjectiveStore; |
49 | import org.onosproject.net.flowobjective.ForwardingObjective; | 55 | import org.onosproject.net.flowobjective.ForwardingObjective; |
... | @@ -245,8 +251,8 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli | ... | @@ -245,8 +251,8 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli |
245 | log.debug("Processing versatile forwarding objective"); | 251 | log.debug("Processing versatile forwarding objective"); |
246 | TrafficSelector selector = fwd.selector(); | 252 | TrafficSelector selector = fwd.selector(); |
247 | 253 | ||
248 | - Criteria.EthTypeCriterion ethType = | 254 | + EthTypeCriterion ethType = |
249 | - (Criteria.EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE); | 255 | + (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE); |
250 | if (ethType == null) { | 256 | if (ethType == null) { |
251 | log.error("Versatile forwarding objective must include ethType"); | 257 | log.error("Versatile forwarding objective must include ethType"); |
252 | fail(fwd, ObjectiveError.UNKNOWN); | 258 | fail(fwd, ObjectiveError.UNKNOWN); |
... | @@ -263,11 +269,11 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli | ... | @@ -263,11 +269,11 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli |
263 | fail(fwd, ObjectiveError.UNSUPPORTED); | 269 | fail(fwd, ObjectiveError.UNSUPPORTED); |
264 | return Collections.emptySet(); | 270 | return Collections.emptySet(); |
265 | } else if (ethType.ethType() == Ethernet.TYPE_IPV4) { | 271 | } else if (ethType.ethType() == Ethernet.TYPE_IPV4) { |
266 | - Criteria.IPCriterion ipSrc = (Criteria.IPCriterion) selector | 272 | + IPCriterion ipSrc = (IPCriterion) selector |
267 | .getCriterion(Criterion.Type.IPV4_SRC); | 273 | .getCriterion(Criterion.Type.IPV4_SRC); |
268 | - Criteria.IPCriterion ipDst = (Criteria.IPCriterion) selector | 274 | + IPCriterion ipDst = (IPCriterion) selector |
269 | .getCriterion(Criterion.Type.IPV4_DST); | 275 | .getCriterion(Criterion.Type.IPV4_DST); |
270 | - Criteria.IPProtocolCriterion ipProto = (Criteria.IPProtocolCriterion) selector | 276 | + IPProtocolCriterion ipProto = (IPProtocolCriterion) selector |
271 | .getCriterion(Criterion.Type.IP_PROTO); | 277 | .getCriterion(Criterion.Type.IP_PROTO); |
272 | if (ipSrc != null) { | 278 | if (ipSrc != null) { |
273 | log.warn("Driver does not currently handle matching Src IP"); | 279 | log.warn("Driver does not currently handle matching Src IP"); |
... | @@ -296,8 +302,8 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli | ... | @@ -296,8 +302,8 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli |
296 | private Collection<FlowRule> processSpecific(ForwardingObjective fwd) { | 302 | private Collection<FlowRule> processSpecific(ForwardingObjective fwd) { |
297 | log.debug("Processing specific forwarding objective"); | 303 | log.debug("Processing specific forwarding objective"); |
298 | TrafficSelector selector = fwd.selector(); | 304 | TrafficSelector selector = fwd.selector(); |
299 | - Criteria.EthTypeCriterion ethType = | 305 | + EthTypeCriterion ethType = |
300 | - (Criteria.EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE); | 306 | + (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE); |
301 | if (ethType == null || ethType.ethType() != Ethernet.TYPE_IPV4) { | 307 | if (ethType == null || ethType.ethType() != Ethernet.TYPE_IPV4) { |
302 | fail(fwd, ObjectiveError.UNSUPPORTED); | 308 | fail(fwd, ObjectiveError.UNSUPPORTED); |
303 | return Collections.emptySet(); | 309 | return Collections.emptySet(); |
... | @@ -307,7 +313,7 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli | ... | @@ -307,7 +313,7 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli |
307 | DefaultTrafficSelector.builder() | 313 | DefaultTrafficSelector.builder() |
308 | .matchEthType(Ethernet.TYPE_IPV4) | 314 | .matchEthType(Ethernet.TYPE_IPV4) |
309 | .matchIPDst( | 315 | .matchIPDst( |
310 | - ((Criteria.IPCriterion) | 316 | + ((IPCriterion) |
311 | selector.getCriterion(Criterion.Type.IPV4_DST)).ip()) | 317 | selector.getCriterion(Criterion.Type.IPV4_DST)).ip()) |
312 | .build(); | 318 | .build(); |
313 | 319 | ||
... | @@ -351,10 +357,10 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli | ... | @@ -351,10 +357,10 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli |
351 | ApplicationId applicationId) { | 357 | ApplicationId applicationId) { |
352 | // This driver only processes filtering criteria defined with switch | 358 | // This driver only processes filtering criteria defined with switch |
353 | // ports as the key | 359 | // ports as the key |
354 | - Criteria.PortCriterion p; | 360 | + PortCriterion p; |
355 | if (!filt.key().equals(Criteria.dummy()) && | 361 | if (!filt.key().equals(Criteria.dummy()) && |
356 | filt.key().type() == Criterion.Type.IN_PORT) { | 362 | filt.key().type() == Criterion.Type.IN_PORT) { |
357 | - p = (Criteria.PortCriterion) filt.key(); | 363 | + p = (PortCriterion) filt.key(); |
358 | } else { | 364 | } else { |
359 | log.warn("No key defined in filtering objective from app: {}. Not" | 365 | log.warn("No key defined in filtering objective from app: {}. Not" |
360 | + "processing filtering objective", applicationId); | 366 | + "processing filtering objective", applicationId); |
... | @@ -365,7 +371,7 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli | ... | @@ -365,7 +371,7 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli |
365 | FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); | 371 | FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); |
366 | for (Criterion c : filt.conditions()) { | 372 | for (Criterion c : filt.conditions()) { |
367 | if (c.type() == Criterion.Type.ETH_DST) { | 373 | if (c.type() == Criterion.Type.ETH_DST) { |
368 | - Criteria.EthCriterion e = (Criteria.EthCriterion) c; | 374 | + EthCriterion e = (EthCriterion) c; |
369 | log.debug("adding rule for MAC: {}", e.mac()); | 375 | log.debug("adding rule for MAC: {}", e.mac()); |
370 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | 376 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); |
371 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); | 377 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); |
... | @@ -381,7 +387,7 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli | ... | @@ -381,7 +387,7 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli |
381 | .forTable(MAC_TABLE).build(); | 387 | .forTable(MAC_TABLE).build(); |
382 | ops = install ? ops.add(rule) : ops.remove(rule); | 388 | ops = install ? ops.add(rule) : ops.remove(rule); |
383 | } else if (c.type() == Criterion.Type.VLAN_VID) { | 389 | } else if (c.type() == Criterion.Type.VLAN_VID) { |
384 | - Criteria.VlanIdCriterion v = (Criteria.VlanIdCriterion) c; | 390 | + VlanIdCriterion v = (VlanIdCriterion) c; |
385 | log.debug("adding rule for VLAN: {}", v.vlanId()); | 391 | log.debug("adding rule for VLAN: {}", v.vlanId()); |
386 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | 392 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); |
387 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); | 393 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); |
... | @@ -399,7 +405,7 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli | ... | @@ -399,7 +405,7 @@ public class OVSCorsaPipeline extends AbstractHandlerBehaviour implements Pipeli |
399 | .forTable(VLAN_TABLE).build(); | 405 | .forTable(VLAN_TABLE).build(); |
400 | ops = install ? ops.add(rule) : ops.remove(rule); | 406 | ops = install ? ops.add(rule) : ops.remove(rule); |
401 | } else if (c.type() == Criterion.Type.IPV4_DST) { | 407 | } else if (c.type() == Criterion.Type.IPV4_DST) { |
402 | - Criteria.IPCriterion ip = (Criteria.IPCriterion) c; | 408 | + IPCriterion ip = (IPCriterion) c; |
403 | log.debug("adding rule for IP: {}", ip.ip()); | 409 | log.debug("adding rule for IP: {}", ip.ip()); |
404 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | 410 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); |
405 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); | 411 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); | ... | ... |
... | @@ -22,28 +22,30 @@ import org.onlab.packet.Ip6Prefix; | ... | @@ -22,28 +22,30 @@ import org.onlab.packet.Ip6Prefix; |
22 | import org.onlab.packet.VlanId; | 22 | import org.onlab.packet.VlanId; |
23 | import org.onosproject.net.flow.FlowRule; | 23 | import org.onosproject.net.flow.FlowRule; |
24 | import org.onosproject.net.flow.TrafficSelector; | 24 | import org.onosproject.net.flow.TrafficSelector; |
25 | -import org.onosproject.net.flow.criteria.Criteria; | 25 | +import org.onosproject.net.flow.criteria.EthCriterion; |
26 | -import org.onosproject.net.flow.criteria.Criteria.EthCriterion; | 26 | +import org.onosproject.net.flow.criteria.EthTypeCriterion; |
27 | -import org.onosproject.net.flow.criteria.Criteria.EthTypeCriterion; | 27 | +import org.onosproject.net.flow.criteria.IPCriterion; |
28 | -import org.onosproject.net.flow.criteria.Criteria.IPCriterion; | 28 | +import org.onosproject.net.flow.criteria.IPDscpCriterion; |
29 | -import org.onosproject.net.flow.criteria.Criteria.IPDscpCriterion; | 29 | +import org.onosproject.net.flow.criteria.IPEcnCriterion; |
30 | -import org.onosproject.net.flow.criteria.Criteria.IPEcnCriterion; | 30 | +import org.onosproject.net.flow.criteria.IPProtocolCriterion; |
31 | -import org.onosproject.net.flow.criteria.Criteria.IPProtocolCriterion; | 31 | +import org.onosproject.net.flow.criteria.IPv6ExthdrFlagsCriterion; |
32 | -import org.onosproject.net.flow.criteria.Criteria.IPv6FlowLabelCriterion; | 32 | +import org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion; |
33 | -import org.onosproject.net.flow.criteria.Criteria.IPv6NDLinkLayerAddressCriterion; | 33 | +import org.onosproject.net.flow.criteria.IPv6NDLinkLayerAddressCriterion; |
34 | -import org.onosproject.net.flow.criteria.Criteria.IPv6NDTargetAddressCriterion; | 34 | +import org.onosproject.net.flow.criteria.IPv6NDTargetAddressCriterion; |
35 | -import org.onosproject.net.flow.criteria.Criteria.IcmpCodeCriterion; | 35 | +import org.onosproject.net.flow.criteria.IcmpCodeCriterion; |
36 | -import org.onosproject.net.flow.criteria.Criteria.IcmpTypeCriterion; | 36 | +import org.onosproject.net.flow.criteria.IcmpTypeCriterion; |
37 | -import org.onosproject.net.flow.criteria.Criteria.Icmpv6CodeCriterion; | 37 | +import org.onosproject.net.flow.criteria.Icmpv6CodeCriterion; |
38 | -import org.onosproject.net.flow.criteria.Criteria.Icmpv6TypeCriterion; | 38 | +import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion; |
39 | -import org.onosproject.net.flow.criteria.Criteria.LambdaCriterion; | 39 | +import org.onosproject.net.flow.criteria.LambdaCriterion; |
40 | -import org.onosproject.net.flow.criteria.Criteria.MetadataCriterion; | 40 | +import org.onosproject.net.flow.criteria.MetadataCriterion; |
41 | -import org.onosproject.net.flow.criteria.Criteria.PortCriterion; | 41 | +import org.onosproject.net.flow.criteria.MplsCriterion; |
42 | -import org.onosproject.net.flow.criteria.Criteria.SctpPortCriterion; | 42 | +import org.onosproject.net.flow.criteria.OpticalSignalTypeCriterion; |
43 | -import org.onosproject.net.flow.criteria.Criteria.TcpPortCriterion; | 43 | +import org.onosproject.net.flow.criteria.PortCriterion; |
44 | -import org.onosproject.net.flow.criteria.Criteria.UdpPortCriterion; | 44 | +import org.onosproject.net.flow.criteria.SctpPortCriterion; |
45 | -import org.onosproject.net.flow.criteria.Criteria.VlanIdCriterion; | 45 | +import org.onosproject.net.flow.criteria.TcpPortCriterion; |
46 | -import org.onosproject.net.flow.criteria.Criteria.VlanPcpCriterion; | 46 | +import org.onosproject.net.flow.criteria.UdpPortCriterion; |
47 | +import org.onosproject.net.flow.criteria.VlanIdCriterion; | ||
48 | +import org.onosproject.net.flow.criteria.VlanPcpCriterion; | ||
47 | import org.onosproject.net.flow.criteria.Criterion; | 49 | import org.onosproject.net.flow.criteria.Criterion; |
48 | import org.projectfloodlight.openflow.protocol.OFFactory; | 50 | import org.projectfloodlight.openflow.protocol.OFFactory; |
49 | import org.projectfloodlight.openflow.protocol.OFFlowAdd; | 51 | import org.projectfloodlight.openflow.protocol.OFFlowAdd; |
... | @@ -362,12 +364,12 @@ public abstract class FlowModBuilder { | ... | @@ -362,12 +364,12 @@ public abstract class FlowModBuilder { |
362 | MacAddress.of(llAddressCriterion.mac().toLong())); | 364 | MacAddress.of(llAddressCriterion.mac().toLong())); |
363 | break; | 365 | break; |
364 | case MPLS_LABEL: | 366 | case MPLS_LABEL: |
365 | - Criteria.MplsCriterion mp = (Criteria.MplsCriterion) c; | 367 | + MplsCriterion mp = (MplsCriterion) c; |
366 | mBuilder.setExact(MatchField.MPLS_LABEL, U32.of(mp.label().toInt())); | 368 | mBuilder.setExact(MatchField.MPLS_LABEL, U32.of(mp.label().toInt())); |
367 | break; | 369 | break; |
368 | case IPV6_EXTHDR: | 370 | case IPV6_EXTHDR: |
369 | - Criteria.IPv6ExthdrFlagsCriterion exthdrFlagsCriterion = | 371 | + IPv6ExthdrFlagsCriterion exthdrFlagsCriterion = |
370 | - (Criteria.IPv6ExthdrFlagsCriterion) c; | 372 | + (IPv6ExthdrFlagsCriterion) c; |
371 | mBuilder.setExact(MatchField.IPV6_EXTHDR, | 373 | mBuilder.setExact(MatchField.IPV6_EXTHDR, |
372 | U16.of(exthdrFlagsCriterion.exthdrFlags())); | 374 | U16.of(exthdrFlagsCriterion.exthdrFlags())); |
373 | break; | 375 | break; |
... | @@ -378,8 +380,8 @@ public abstract class FlowModBuilder { | ... | @@ -378,8 +380,8 @@ public abstract class FlowModBuilder { |
378 | (short) lc.lambda(), (short) 1)); | 380 | (short) lc.lambda(), (short) 1)); |
379 | break; | 381 | break; |
380 | case OCH_SIGTYPE: | 382 | case OCH_SIGTYPE: |
381 | - Criteria.OpticalSignalTypeCriterion sc = | 383 | + OpticalSignalTypeCriterion sc = |
382 | - (Criteria.OpticalSignalTypeCriterion) c; | 384 | + (OpticalSignalTypeCriterion) c; |
383 | mBuilder.setExact(MatchField.OCH_SIGTYPE, | 385 | mBuilder.setExact(MatchField.OCH_SIGTYPE, |
384 | U8.of(sc.signalType())); | 386 | U8.of(sc.signalType())); |
385 | break; | 387 | break; | ... | ... |
-
Please register or login to post a comment