From e5df26295703f2f8f5f9b9ee406407a5684b8122 Mon Sep 17 00:00:00 2001 From: Ashlee Young Date: Fri, 13 Nov 2015 16:06:48 -0800 Subject: ONOS commit id 710293f3afa03540a1fd3be038da0ea6a488765c Change-Id: I66c2370960d7597bdbaf7bf58defca3e864c4215 Signed-off-by: Ashlee Young --- .../net/flow/criteria/ArpHaCriterion.java | 83 ++++++++++++++++++++++ .../onosproject/net/flow/criteria/Criteria.java | 10 +++ .../org/onosproject/net/intent/MplsPathIntent.java | 6 +- .../org/onosproject/net/intent/PathIntent.java | 6 +- .../net/intent/ConnectivityIntentTest.java | 1 + .../org/onosproject/net/intent/MplsIntentTest.java | 1 - .../onosproject/net/intent/MplsPathIntentTest.java | 3 + .../org/onosproject/net/intent/PathIntentTest.java | 2 + .../org/onosproject/ui/topo/PropertyPanelTest.java | 19 ++--- 9 files changed, 118 insertions(+), 13 deletions(-) create mode 100644 framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpHaCriterion.java (limited to 'framework/src/onos/core/api') diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpHaCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpHaCriterion.java new file mode 100644 index 00000000..71269dd1 --- /dev/null +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpHaCriterion.java @@ -0,0 +1,83 @@ +/* + * 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 static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Objects; + +import org.onlab.packet.MacAddress; + +/** + * Implementation of arp_eth_src address or arp_eth_dst address criterion. + */ +public final class ArpHaCriterion implements Criterion { + private final MacAddress mac; + private final Type type; + + /** + * Constructor. + * + * @param mac the MAC Address to match. + * @param type the match type. Should be one of the following: + * Type.ARP_SHA, Type.ARP_THA + */ + ArpHaCriterion(MacAddress mac, Type type) { + checkNotNull(mac, "mac cannot be null"); + checkNotNull(type, "type cannot be null"); + this.mac = mac; + this.type = type; + } + + @Override + public Type type() { + return this.type; + } + + /** + * Gets the MAC Address to match. + * + * @return the MAC Address to match + */ + public MacAddress mac() { + return this.mac; + } + + @Override + public String toString() { + return toStringHelper(type().toString()) + .add("mac", mac).toString(); + } + + @Override + public int hashCode() { + return Objects.hash(type().ordinal(), mac); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof ArpHaCriterion) { + ArpHaCriterion that = (ArpHaCriterion) obj; + return Objects.equals(mac, that.mac) && + 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 778d50a5..bc1a094c 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 @@ -519,6 +519,16 @@ public final class Criteria { return new ArpPaCriterion(ip, Type.ARP_TPA); } + /** + * Creates a match on MAC source field using the specified value. + * + * @param mac MAC source value + * @return match criterion + */ + public static Criterion matchArpTha(MacAddress mac) { + return new ArpHaCriterion(mac, Type.ARP_THA); + } + public static Criterion dummy() { return new DummyCriterion(); } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java index caa5fbb9..4548c44d 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/MplsPathIntent.java @@ -42,6 +42,7 @@ public final class MplsPathIntent extends PathIntent { * ports and using the specified explicit path. * * @param appId application identifier + * @param key intent key * @param selector traffic selector * @param treatment treatment * @param path traversed links @@ -51,11 +52,11 @@ public final class MplsPathIntent extends PathIntent { * @param priority priority to use for flows generated by this intent * @throws NullPointerException {@code path} is null */ - private MplsPathIntent(ApplicationId appId, TrafficSelector selector, + private MplsPathIntent(ApplicationId appId, Key key, TrafficSelector selector, TrafficTreatment treatment, Path path, Optional ingressLabel, Optional egressLabel, List constraints, int priority) { - super(appId, selector, treatment, path, constraints, + super(appId, key, selector, treatment, path, constraints, priority); this.ingressLabel = checkNotNull(ingressLabel); @@ -149,6 +150,7 @@ public final class MplsPathIntent extends PathIntent { return new MplsPathIntent( appId, + key, selector, treatment, path, diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java index 0c831fd5..9bf137a1 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java @@ -42,6 +42,7 @@ public class PathIntent extends ConnectivityIntent { * ports and using the specified explicit path. * * @param appId application identifier + * @param key intent key * @param selector traffic selector * @param treatment treatment * @param path traversed links @@ -50,12 +51,13 @@ public class PathIntent extends ConnectivityIntent { * @throws NullPointerException {@code path} is null */ protected PathIntent(ApplicationId appId, + Key key, TrafficSelector selector, TrafficTreatment treatment, Path path, List constraints, int priority) { - super(appId, null, resources(path.links()), selector, treatment, constraints, + super(appId, key, resources(path.links()), selector, treatment, constraints, priority); PathIntent.validate(path.links()); this.path = path; @@ -138,6 +140,7 @@ public class PathIntent extends ConnectivityIntent { return new PathIntent( appId, + key, selector, treatment, path, @@ -184,6 +187,7 @@ public class PathIntent extends ConnectivityIntent { public String toString() { return MoreObjects.toStringHelper(getClass()) .add("id", id()) + .add("key", key()) .add("appId", appId()) .add("priority", priority()) .add("resources", resources()) diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java index e03ed850..c510b60a 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java @@ -33,6 +33,7 @@ import org.onosproject.net.flow.TrafficTreatment; public abstract class ConnectivityIntentTest extends IntentTest { public static final ApplicationId APPID = new TestApplicationId("foo"); + public static final Key KEY = Key.of(1L, APPID); public static final IntentId IID = new IntentId(123); public static final TrafficSelector MATCH = DefaultTrafficSelector.emptySelector(); diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/MplsIntentTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/MplsIntentTest.java index 196d6ad4..7fbdf232 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/MplsIntentTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/MplsIntentTest.java @@ -112,6 +112,5 @@ public class MplsIntentTest extends AbstractIntentTest { assertThat(intent1.selector(), equalTo(intent2.selector())); assertThat(intent1.treatment(), equalTo(intent2.treatment())); assertThat(intent1.priority(), is(PRIORITY)); - } } diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/MplsPathIntentTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/MplsPathIntentTest.java index 551f19eb..64528cb9 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/MplsPathIntentTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/MplsPathIntentTest.java @@ -47,6 +47,7 @@ public class MplsPathIntentTest extends AbstractIntentTest { Optional label2; TrafficSelector selector; TrafficTreatment treatment; + static final Key KEY1 = Key.of(5L, APP_ID); @Before public void mplsPathIntentTestSetUp() { @@ -58,6 +59,7 @@ public class MplsPathIntentTest extends AbstractIntentTest { label2 = Optional.of(MplsLabel.mplsLabel(2)); intent1 = MplsPathIntent.builder() .appId(APP_ID) + .key(KEY1) .ingressLabel(label1) .egressLabel(label2) .path(defaultPath) @@ -105,6 +107,7 @@ public class MplsPathIntentTest extends AbstractIntentTest { assertThat(intent1.treatment(), equalTo(intent2.treatment())); assertThat(intent1.priority(), is(PRIORITY)); assertThat(intent1.path(), is(defaultPath)); + assertThat(intent1.key(), equalTo(KEY1)); } } diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java index dfbc1846..9e675347 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java @@ -62,12 +62,14 @@ public class PathIntentTest extends ConnectivityIntentTest { assertEquals("incorrect match", MATCH, intent.selector()); assertEquals("incorrect action", NOP, intent.treatment()); assertEquals("incorrect path", PATH1, intent.path()); + assertEquals("incorrect key", KEY, intent.key()); } @Override protected PathIntent createOne() { return PathIntent.builder() .appId(APPID) + .key(KEY) .selector(MATCH) .treatment(NOP) .path(PATH1) diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java index 157cdc74..b6d32bed 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java @@ -63,6 +63,7 @@ public class PropertyPanelTest { private static final String KEY_C = "C"; private static final String SEP = "-"; private static final String KEY_Z = "Z"; + private static final String VALUE_A = "Hay"; private static final String VALUE_B = "Bee"; private static final String VALUE_C = "Sea"; @@ -155,8 +156,8 @@ public class PropertyPanelTest { public void props() { basic(); pp.addProp(KEY_A, VALUE_A) - .addProp(KEY_B, VALUE_B) - .addProp(KEY_C, VALUE_C); + .addProp(KEY_B, VALUE_B) + .addProp(KEY_C, VALUE_C); assertEquals("bad props", 3, pp.properties().size()); validateProps(KEY_A, KEY_B, KEY_C); } @@ -165,7 +166,7 @@ public class PropertyPanelTest { public void separator() { props(); pp.addSeparator() - .addProp(KEY_Z, VALUE_Z); + .addProp(KEY_Z, VALUE_Z); assertEquals("bad props", 5, pp.properties().size()); validateProps(KEY_A, KEY_B, KEY_C, SEP, KEY_Z); @@ -191,8 +192,8 @@ public class PropertyPanelTest { public void intValues() { basic(); pp.addProp(KEY_A, 200) - .addProp(KEY_B, 2000) - .addProp(KEY_C, 1234567); + .addProp(KEY_B, 2000) + .addProp(KEY_C, 1234567); validateProp(KEY_A, "200"); validateProp(KEY_B, "2,000"); @@ -203,9 +204,9 @@ public class PropertyPanelTest { public void longValues() { basic(); pp.addProp(KEY_A, 200L) - .addProp(KEY_B, 2000L) - .addProp(KEY_C, 1234567L) - .addProp(KEY_Z, Long.MAX_VALUE); + .addProp(KEY_B, 2000L) + .addProp(KEY_C, 1234567L) + .addProp(KEY_Z, Long.MAX_VALUE); validateProp(KEY_A, "200"); validateProp(KEY_B, "2,000"); @@ -217,7 +218,7 @@ public class PropertyPanelTest { public void objectValue() { basic(); pp.addProp(KEY_A, new FooClass("a")) - .addProp(KEY_B, new FooClass("bxyyzy"), "[xz]"); + .addProp(KEY_B, new FooClass("bxyyzy"), "[xz]"); validateProp(KEY_A, ">a<"); validateProp(KEY_B, ">byyy<"); -- cgit 1.2.3-korg