aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/core/api/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/core/api/src/main/java')
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/EncapsulationType.java30
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/TributarySlot.java73
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ExtensionTreatmentResolver.java (renamed from framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ExtensionResolver.java)8
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/TunnelConfig.java1
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/config/Config.java20
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/BasicFeatureConfig.java54
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java7
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java4
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java8
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java4
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpOpCriterion.java78
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java32
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java90
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsTcCriterion.java75
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/TcpFlagsCriterion.java75
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionTreatment.java (renamed from framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionInstruction.java)2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatment.java (renamed from framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionInstruction.java)4
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java (renamed from framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionType.java)26
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java18
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java48
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java65
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java55
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java25
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroupKey.java17
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java2
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java12
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/EncapsulationConstraint.java83
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java8
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java38
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java19
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceRequest.java2
31 files changed, 906 insertions, 77 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/EncapsulationType.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/EncapsulationType.java
new file mode 100644
index 00000000..63ff46d3
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/EncapsulationType.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2014-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;
+
+public enum EncapsulationType {
+ /**
+ * Indicates an MPLS encapsulation.
+ */
+ MPLS,
+ /**
+ * Indicates a VLAN encapsulation.
+ */
+ VLAN,
+};
+
+
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/TributarySlot.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/TributarySlot.java
new file mode 100644
index 00000000..d8a10c81
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/TributarySlot.java
@@ -0,0 +1,73 @@
+/*
+ * 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;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implementation of ODU Tributary Slot simply designated by an index number of slot.
+ */
+public class TributarySlot {
+
+ private final long index;
+
+ /**
+ * Creates an instance representing the TributarySlot specified by the given index number.
+ *
+ * @param index index number of wavelength
+ */
+ public TributarySlot(long index) {
+ this.index = index;
+ }
+
+ public static TributarySlot of(long index) {
+ return new TributarySlot(index);
+ }
+
+ /**
+ * Returns the index number of TributarySlot.
+ *
+ * @return the index number of TributarySlot
+ */
+ public long index() {
+ return index;
+ }
+
+ @Override
+ public int hashCode() {
+ return Long.hashCode(index);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof TributarySlot)) {
+ return false;
+ }
+
+ final TributarySlot that = (TributarySlot) obj;
+ return this.index == that.index;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("index", index)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ExtensionResolver.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ExtensionTreatmentResolver.java
index 54cbc7ac..85f0216d 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ExtensionResolver.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/ExtensionTreatmentResolver.java
@@ -18,14 +18,14 @@ package org.onosproject.net.behaviour;
import com.google.common.annotations.Beta;
import org.onosproject.net.driver.HandlerBehaviour;
-import org.onosproject.net.flow.instructions.ExtensionInstruction;
-import org.onosproject.net.flow.instructions.ExtensionType;
+import org.onosproject.net.flow.instructions.ExtensionTreatment;
+import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
/**
* Provides access to the extension implemented by this driver.
*/
@Beta
-public interface ExtensionResolver extends HandlerBehaviour {
+public interface ExtensionTreatmentResolver extends HandlerBehaviour {
/**
* Gets an extension instruction instance of the specified type, if supported
@@ -36,5 +36,5 @@ public interface ExtensionResolver extends HandlerBehaviour {
* @throws UnsupportedOperationException if the extension type is not
* supported by this driver
*/
- ExtensionInstruction getExtensionInstruction(ExtensionType type);
+ ExtensionTreatment getExtensionInstruction(ExtensionTreatmentType type);
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/TunnelConfig.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/TunnelConfig.java
index e3b4c198..a1b97ffd 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/TunnelConfig.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/TunnelConfig.java
@@ -29,6 +29,7 @@ public interface TunnelConfig extends HandlerBehaviour {
*
* @param tunnel tunnel descriptor
*/
+ @Deprecated
void createTunnel(TunnelDescription tunnel);
/**
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/Config.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/Config.java
index 3757d327..5f2c9f3a 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/Config.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/Config.java
@@ -333,6 +333,26 @@ public abstract class Config<S> {
}
/**
+ * Gets the specified array property as a list of items.
+ *
+ * @param name property name
+ * @param function mapper from string to item
+ * @param defaultValue default value if property not set
+ * @param <T> type of item
+ * @return list of items
+ */
+ protected <T> List<T> getList(String name, Function<String, T> function, List<T> defaultValue) {
+ List<T> list = Lists.newArrayList();
+ JsonNode jsonNode = object.path(name);
+ if (jsonNode.isMissingNode()) {
+ return defaultValue;
+ }
+ ArrayNode arrayNode = (ArrayNode) jsonNode;
+ arrayNode.forEach(i -> list.add(function.apply(i.asText())));
+ return list;
+ }
+
+ /**
* Sets the specified property as an array of items in a given collection or
* clears it if null is given.
*
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/BasicFeatureConfig.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/BasicFeatureConfig.java
new file mode 100644
index 00000000..fcf24bc6
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/config/basics/BasicFeatureConfig.java
@@ -0,0 +1,54 @@
+/*
+ * 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.config.basics;
+
+import org.onosproject.net.config.Config;
+
+/**
+ * Base abstraction for configuring feature on subject.
+ *
+ * @param <S> Subject type
+ */
+public abstract class BasicFeatureConfig<S> extends Config<S> {
+
+ private static final String ENABLED = "enabled";
+
+ private final boolean defaultValue;
+
+ protected BasicFeatureConfig(boolean defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ /**
+ * Indicates whether the feature for the subject is enabled.
+ *
+ * @return true if feature is enabled
+ */
+ public boolean enabled() {
+ return get(ENABLED, defaultValue);
+ }
+
+ /**
+ * Specifies whether the feature for the subject is to be enabled.
+ *
+ * @param enabled true to enable; false to disable; null to clear
+ * @return self
+ */
+ public BasicFeatureConfig<S> enabled(Boolean enabled) {
+ return (BasicFeatureConfig<S>) setOrClear(ENABLED, enabled);
+ }
+
+}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java
index a842d600..d3c2449c 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java
@@ -340,7 +340,7 @@ public final class DefaultTrafficSelector implements TrafficSelector {
@Override
public Builder matchMplsBos(boolean mplsBos) {
- return add(Criteria.matchMplsLabel(mplsBos));
+ return add(Criteria.matchMplsBos(mplsBos));
}
@Override
@@ -374,6 +374,11 @@ public final class DefaultTrafficSelector implements TrafficSelector {
}
@Override
+ public Builder matchArpOp(int arpOp) {
+ return add(Criteria.matchArpOp(arpOp));
+ }
+
+ @Override
public TrafficSelector build() {
return new DefaultTrafficSelector(ImmutableSet.copyOf(selector.values()));
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
index 4615a82b..22bff7dd 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
@@ -30,7 +30,7 @@ import org.onosproject.core.GroupId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.IndexedLambda;
import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.instructions.ExtensionInstruction;
+import org.onosproject.net.flow.instructions.ExtensionTreatment;
import org.onosproject.net.flow.instructions.Instruction;
import org.onosproject.net.flow.instructions.Instructions;
import org.onosproject.net.meter.MeterId;
@@ -489,7 +489,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
}
@Override
- public TrafficTreatment.Builder extension(ExtensionInstruction extension,
+ public TrafficTreatment.Builder extension(ExtensionTreatment extension,
DeviceId deviceId) {
return add(Instructions.extension(extension, deviceId));
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java
index 9fe88d5a..b92281f5 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java
@@ -419,6 +419,14 @@ public interface TrafficSelector {
Builder matchArpSha(MacAddress addr);
/**
+ * Matches a arp operation type.
+ *
+ * @param arpOp a arp operation type
+ * @return a selection builder
+ */
+ Builder matchArpOp(int arpOp);
+
+ /**
* Builds an immutable traffic selector.
*
* @return traffic selector
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
index f1a676ab..06b6ffa0 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
@@ -26,7 +26,7 @@ import org.onlab.packet.VlanId;
import org.onosproject.core.GroupId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.instructions.ExtensionInstruction;
+import org.onosproject.net.flow.instructions.ExtensionTreatment;
import org.onosproject.net.flow.instructions.Instruction;
import org.onosproject.net.flow.instructions.Instructions;
import org.onosproject.net.meter.MeterId;
@@ -430,7 +430,7 @@ public interface TrafficTreatment {
* @param deviceId device ID
* @return a treatment builder
*/
- Builder extension(ExtensionInstruction extension, DeviceId deviceId);
+ Builder extension(ExtensionTreatment extension, DeviceId deviceId);
/**
* Builds an immutable traffic treatment descriptor.
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpOpCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpOpCriterion.java
new file mode 100644
index 00000000..8c5398c6
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpOpCriterion.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.flow.criteria;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+
+/**
+ * Implementation of arp operation type criterion.
+ */
+public final class ArpOpCriterion implements Criterion {
+ private final int arpOp;
+ private final Type type;
+
+ /**
+ * Constructor.
+ *
+ * @param arpOp the arp operation type to match.
+ * @param type the match type. Should be the following:
+ * Type.ARP_OP
+ */
+ ArpOpCriterion(int arpOp, Type type) {
+ this.arpOp = arpOp;
+ this.type = type;
+ }
+
+ @Override
+ public Type type() {
+ return this.type;
+ }
+
+ /**
+ * Gets the arp operation type to match.
+ *
+ * @return the arp operation type to match
+ */
+ public int arpOp() {
+ return this.arpOp;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(type().toString())
+ .add("arpOp", arpOp).toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(type().ordinal(), arpOp);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof ArpOpCriterion) {
+ ArpOpCriterion that = (ArpOpCriterion) obj;
+ return Objects.equals(arpOp, that.arpOp) &&
+ Objects.equals(type, that.type);
+ }
+ return false;
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java
index 554b8e74..a28a4ab9 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java
@@ -230,6 +230,16 @@ public final class Criteria {
}
/**
+ * Creates a match on TCP flags using the specified value.
+ *
+ * @param flags TCP flags
+ * @return match criterion
+ */
+ public static Criterion matchTcpFlags(int flags) {
+ return new TcpFlagsCriterion(flags);
+ }
+
+ /**
* Creates a match on UDP source port field using the specified value.
*
* @param udpPort UDP source port
@@ -438,11 +448,21 @@ public final class Criteria {
* @param mplsBos boolean value indicating true (BOS=1) or false (BOS=0)
* @return match criterion
*/
- public static Criterion matchMplsLabel(boolean mplsBos) {
+ public static Criterion matchMplsBos(boolean mplsBos) {
return new MplsBosCriterion(mplsBos);
}
/**
+ * Creates a match on MPLS TC.
+ *
+ * @param mplsTc MPLS TC (3 bits)
+ * @return match criterion
+ */
+ public static Criterion matchMplsTc(byte mplsTc) {
+ return new MplsTcCriterion(mplsTc);
+ }
+
+ /**
* Creates a match on Tunnel ID.
*
* @param tunnelId Tunnel ID (64 bits)
@@ -549,6 +569,16 @@ public final class Criteria {
return new ArpHaCriterion(mac, Type.ARP_SHA);
}
+ /**
+ * Creates a match on arp operation type field using the specified value.
+ *
+ * @param arpOp arp operation type value
+ * @return match criterion
+ */
+ public static Criterion matchArpOp(int arpOp) {
+ return new ArpOpCriterion(arpOp, Type.ARP_OP);
+ }
+
public static Criterion dummy() {
return new DummyCriterion();
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java
index 10cb629f..26665246 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java
@@ -28,92 +28,136 @@ public interface Criterion {
enum Type {
/** Switch input port. */
IN_PORT,
+
/** Switch physical input port. */
IN_PHY_PORT,
+
/** Metadata passed between tables. */
METADATA,
+
/** Ethernet destination address. */
ETH_DST,
+
/** Ethernet source address. */
ETH_SRC,
+
/** Ethernet frame type. */
ETH_TYPE,
+
/** VLAN id. */
VLAN_VID,
+
/** VLAN priority. */
VLAN_PCP,
+
/** IP DSCP (6 bits in ToS field). */
IP_DSCP,
+
/** IP ECN (2 bits in ToS field). */
IP_ECN,
+
/** IP protocol. */
IP_PROTO,
+
/** IPv4 source address. */
IPV4_SRC,
+
/** IPv4 destination address. */
IPV4_DST,
+
/** TCP source port. */
TCP_SRC,
+
/** TCP destination port. */
TCP_DST,
+
/** UDP source port. */
UDP_SRC,
+
/** UDP destination port. */
UDP_DST,
+
/** SCTP source port. */
SCTP_SRC,
+
/** SCTP destination port. */
SCTP_DST,
+
/** ICMP type. */
ICMPV4_TYPE,
+
/** ICMP code. */
ICMPV4_CODE,
+
/** ARP opcode. */
ARP_OP,
+
/** ARP source IPv4 address. */
ARP_SPA,
+
/** ARP target IPv4 address. */
ARP_TPA,
+
/** ARP source hardware address. */
ARP_SHA,
+
/** ARP target hardware address. */
ARP_THA,
+
/** IPv6 source address. */
IPV6_SRC,
+
/** IPv6 destination address. */
IPV6_DST,
+
/** IPv6 Flow Label. */
IPV6_FLABEL,
+
/** ICMPv6 type. */
ICMPV6_TYPE,
+
/** ICMPv6 code. */
ICMPV6_CODE,
+
/** Target address for ND. */
IPV6_ND_TARGET,
+
/** Source link-layer for ND. */
IPV6_ND_SLL,
+
/** Target link-layer for ND. */
IPV6_ND_TLL,
+
/** MPLS label. */
MPLS_LABEL,
+
/** MPLS TC. */
MPLS_TC,
- /** MPLS BoS bit. */
+
+ /** MPLS BoS bit. */
MPLS_BOS,
+
/** PBB I-SID. */
PBB_ISID,
+
/** Logical Port Metadata. */
TUNNEL_ID,
+
/** IPv6 Extension Header pseudo-field. */
IPV6_EXTHDR,
+
/** Unassigned value: 40. */
UNASSIGNED_40,
+
/** PBB UCA header field. */
PBB_UCA,
+
/** TCP flags. */
TCP_FLAGS,
+
/** Output port from action set metadata. */
ACTSET_OUTPUT,
+
/** Packet type value. */
PACKET_TYPE,
@@ -123,16 +167,17 @@ public interface Criterion {
//
/** Optical channel signal ID (lambda). */
OCH_SIGID,
+
/** Optical channel signal type (fixed or flexible). */
OCH_SIGTYPE,
+
/** ODU (Optical channel Data Unit) signal ID. */
ODU_SIGID,
+
/** ODU (Optical channel Data Unit) signal type. */
ODU_SIGTYPE,
- /**
- * An empty criterion.
- */
+ /** An empty criterion. */
DUMMY
}
@@ -182,4 +227,41 @@ public interface Criterion {
return this.value;
}
}
+
+ enum TCPFlags {
+
+ /** ECN-nonce concealment protection. */
+ NS((short) (1 << 0)),
+ /** Congestion Window Reduced. */
+ CWR((short) (1 << 1)),
+ /** ECN-Echo. **/
+ ECE((short) (1 << 2)),
+ /** Urgent pointer field is significant. */
+ URG((short) (1 << 3)),
+ /** Acknowledgment field is significant. */
+ ACK((short) (1 << 4)),
+ /** Push the buffered data to the receiving application. */
+ PSH((short) (1 << 5)),
+ /** Reset the connection. */
+ RST((short) (1 << 6)),
+ /** Synchronize sequence numbers. */
+ SYN((short) (1 << 7)),
+ /** No more data from sender. */
+ FIN((short) (1 << 8));
+
+ private short value;
+
+ TCPFlags(short value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value as an integer.
+ *
+ * @return the value as an integer
+ */
+ public short getValue() {
+ return this.value;
+ }
+ }
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsTcCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsTcCriterion.java
new file mode 100644
index 00000000..8ad62358
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsTcCriterion.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.flow.criteria;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Implementation of MPLS TC criterion (3 bits).
+ */
+public final class MplsTcCriterion implements Criterion {
+ private static final byte MASK = 0x7;
+ private final byte mplsTc;
+
+ /**
+ * Constructor.
+ *
+ * @param mplsTc the MPLS TC to match (3 bits)
+ */
+ MplsTcCriterion(byte mplsTc) {
+ this.mplsTc = (byte) (mplsTc & MASK);
+ }
+
+ @Override
+ public Type type() {
+ return Type.MPLS_TC;
+ }
+
+ /**
+ * Gets the MPLS TC to match.
+ *
+ * @return the MPLS TC to match (3 bits)
+ */
+ public byte tc() {
+ return mplsTc;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(type().toString())
+ .add("tc", Long.toHexString(mplsTc)).toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(type().ordinal(), mplsTc);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof MplsTcCriterion) {
+ MplsTcCriterion that = (MplsTcCriterion) obj;
+ return Objects.equals(mplsTc, that.mplsTc) &&
+ Objects.equals(this.type(), that.type());
+ }
+ return false;
+ }
+}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/TcpFlagsCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/TcpFlagsCriterion.java
new file mode 100644
index 00000000..e0b53958
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/TcpFlagsCriterion.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.flow.criteria;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Implementation of TCP flags criterion (12 bits unsigned integer).
+ */
+public final class TcpFlagsCriterion implements Criterion {
+ private static final int MASK = 0xfffff;
+ private final int flags; // TCP flags: 12 bits
+
+ /**
+ * Constructor.
+ *
+ * @param flags the TCP flags to match (12 bits)
+ */
+ TcpFlagsCriterion(int flags) {
+ this.flags = flags & MASK;
+ }
+
+ @Override
+ public Type type() {
+ return Type.TCP_FLAGS;
+ }
+
+ /**
+ * Gets the TCP flags to match.
+ *
+ * @return the TCP flags to match (12 bits)
+ */
+ public int flags() {
+ return flags;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(type().toString())
+ .add("flags", Long.toHexString(flags)).toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(type().ordinal(), flags);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof TcpFlagsCriterion) {
+ TcpFlagsCriterion that = (TcpFlagsCriterion) obj;
+ return Objects.equals(flags, that.flags) &&
+ Objects.equals(this.type(), that.type());
+ }
+ return false;
+ }
+}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionTreatment.java
index 9f22f888..ac7c771f 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionInstruction.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/AbstractExtensionTreatment.java
@@ -23,7 +23,7 @@ import java.util.List;
/**
* Abstract implementation of the set/get property methods of ExtensionInstruction.
*/
-public abstract class AbstractExtensionInstruction implements ExtensionInstruction {
+public abstract class AbstractExtensionTreatment implements ExtensionTreatment {
private static final String INVALID_KEY = "Invalid property key: ";
private static final String INVALID_TYPE = "Given type does not match field type: ";
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatment.java
index 89e0cc5e..0e8885ed 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionInstruction.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatment.java
@@ -21,14 +21,14 @@ import java.util.List;
/**
* An extensible instruction type.
*/
-public interface ExtensionInstruction {
+public interface ExtensionTreatment {
/**
* Gets the type of the extension instruction.
*
* @return type
*/
- ExtensionType type();
+ ExtensionTreatmentType type();
/**
* Sets a property on the extension instruction.
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionType.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java
index 3e1cb75c..38fbc279 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionType.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java
@@ -25,25 +25,27 @@ import java.util.Objects;
* Type of extension instructions.
*/
@Beta
-public final class ExtensionType {
+public final class ExtensionTreatmentType {
/**
* A list of well-known named extension instruction type codes.
+ * These numbers have no impact on the actual OF type id.
*/
- public enum ExtensionTypes {
+ public enum ExtensionTreatmentTypes {
// TODO fix type numbers to include experimenter id
- NICIRA_SET_TUNNEL_DST(31),
- NICIRA_RESUBMIT(32);
+ NICIRA_SET_TUNNEL_DST(0),
+ NICIRA_RESUBMIT(1),
+ NICIRA_SET_NSH_SPI(32);
- private ExtensionType type;
+ private ExtensionTreatmentType type;
/**
* Creates a new named extension instruction type.
*
* @param type type code
*/
- ExtensionTypes(int type) {
- this.type = new ExtensionType(type);
+ ExtensionTreatmentTypes(int type) {
+ this.type = new ExtensionTreatmentType(type);
}
/**
@@ -51,7 +53,7 @@ public final class ExtensionType {
*
* @return extension type object
*/
- public ExtensionType type() {
+ public ExtensionTreatmentType type() {
return type;
}
}
@@ -63,7 +65,7 @@ public final class ExtensionType {
*
* @param type type code
*/
- public ExtensionType(int type) {
+ public ExtensionTreatmentType(int type) {
this.type = type;
}
@@ -77,8 +79,8 @@ public final class ExtensionType {
if (this == obj) {
return true;
}
- if (obj instanceof ExtensionType) {
- final ExtensionType that = (ExtensionType) obj;
+ if (obj instanceof ExtensionTreatmentType) {
+ final ExtensionTreatmentType that = (ExtensionTreatmentType) obj;
return this.type == that.type;
}
return false;
@@ -86,7 +88,7 @@ public final class ExtensionType {
@Override
public String toString() {
- return MoreObjects.toStringHelper(ExtensionType.class)
+ return MoreObjects.toStringHelper(ExtensionTreatmentType.class)
.add("type", type)
.toString();
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
index 126e722e..4643b315 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
@@ -489,7 +489,7 @@ public final class Instructions {
* @param deviceId device ID
* @return extension instruction
*/
- public static ExtensionInstructionWrapper extension(ExtensionInstruction extension,
+ public static ExtensionInstructionWrapper extension(ExtensionTreatment extension,
DeviceId deviceId) {
checkNotNull(extension, "Extension instruction cannot be null");
checkNotNull(deviceId, "Device ID cannot be null");
@@ -858,16 +858,16 @@ public final class Instructions {
* Extension instruction.
*/
public static class ExtensionInstructionWrapper implements Instruction {
- private final ExtensionInstruction extensionInstruction;
+ private final ExtensionTreatment extensionTreatment;
private final DeviceId deviceId;
- ExtensionInstructionWrapper(ExtensionInstruction extension, DeviceId deviceId) {
- extensionInstruction = extension;
+ ExtensionInstructionWrapper(ExtensionTreatment extension, DeviceId deviceId) {
+ extensionTreatment = extension;
this.deviceId = deviceId;
}
- public ExtensionInstruction extensionInstruction() {
- return extensionInstruction;
+ public ExtensionTreatment extensionInstruction() {
+ return extensionTreatment;
}
public DeviceId deviceId() {
@@ -882,14 +882,14 @@ public final class Instructions {
@Override
public String toString() {
return toStringHelper(type().toString())
- .add("extension", extensionInstruction)
+ .add("extension", extensionTreatment)
.add("deviceId", deviceId)
.toString();
}
@Override
public int hashCode() {
- return Objects.hash(type().ordinal(), extensionInstruction, deviceId);
+ return Objects.hash(type().ordinal(), extensionTreatment, deviceId);
}
@Override
@@ -899,7 +899,7 @@ public final class Instructions {
}
if (obj instanceof ExtensionInstructionWrapper) {
ExtensionInstructionWrapper that = (ExtensionInstructionWrapper) obj;
- return Objects.equals(extensionInstruction, that.extensionInstruction)
+ return Objects.equals(extensionTreatment, that.extensionTreatment)
&& Objects.equals(deviceId, that.deviceId);
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java
index 0abf5abe..af481805 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java
@@ -16,6 +16,7 @@
package org.onosproject.net.flowobjective;
import com.google.common.annotations.Beta;
+
import org.onosproject.core.ApplicationId;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
@@ -119,6 +120,53 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
return context;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hash(selector, flag, permanent,
+ timeout, appId, priority, nextId,
+ treatment, op);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof DefaultForwardingObjective)) {
+ return false;
+ }
+ final DefaultForwardingObjective other = (DefaultForwardingObjective) obj;
+ boolean nextEq = false, treatmentEq = false;
+ if (this.selector.equals(other.selector) &&
+ this.flag == other.flag &&
+ this.permanent == other.permanent &&
+ this.timeout == other.timeout &&
+ this.appId.equals(other.appId) &&
+ this.priority == other.priority &&
+ this.op == other.op) {
+ if (this.nextId != null && other.nextId != null) {
+ nextEq = this.nextId == other.nextId;
+ }
+ if (this.treatment != null && other.treatment != null) {
+ treatmentEq = this.treatment.equals(other.treatment);
+ }
+ if (nextEq && treatmentEq) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Returns a new builder.
*
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java
index 20e89295..4701589f 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultNextObjective.java
@@ -18,6 +18,7 @@ package org.onosproject.net.flowobjective;
import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableList;
import org.onosproject.core.ApplicationId;
+import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import java.util.Collection;
@@ -39,6 +40,7 @@ public final class DefaultNextObjective implements NextObjective {
private final Integer id;
private final Operation op;
private final Optional<ObjectiveContext> context;
+ private final TrafficSelector meta;
private DefaultNextObjective(Builder builder) {
this.treatments = builder.treatments;
@@ -47,6 +49,7 @@ public final class DefaultNextObjective implements NextObjective {
this.id = builder.id;
this.op = builder.op;
this.context = Optional.ofNullable(builder.context);
+ this.meta = builder.meta;
}
@Override
@@ -94,6 +97,11 @@ public final class DefaultNextObjective implements NextObjective {
return context;
}
+ @Override
+ public TrafficSelector meta() {
+ return meta;
+ }
+
/**
* Returns a new builder.
*
@@ -111,6 +119,7 @@ public final class DefaultNextObjective implements NextObjective {
private List<TrafficTreatment> treatments;
private Operation op;
private ObjectiveContext context;
+ private TrafficSelector meta;
private final ImmutableList.Builder<TrafficTreatment> listBuilder
= ImmutableList.builder();
@@ -172,6 +181,12 @@ public final class DefaultNextObjective implements NextObjective {
}
@Override
+ public Builder setMeta(TrafficSelector meta) {
+ this.meta = meta;
+ return this;
+ }
+
+ @Override
public NextObjective add() {
treatments = listBuilder.build();
op = Operation.ADD;
@@ -218,5 +233,55 @@ public final class DefaultNextObjective implements NextObjective {
return new DefaultNextObjective(this);
}
+
+ @Override
+ public NextObjective addToExisting() {
+ treatments = listBuilder.build();
+ op = Operation.ADD_TO_EXISTING;
+ checkNotNull(appId, "Must supply an application id");
+ checkNotNull(id, "id cannot be null");
+ checkNotNull(type, "The type cannot be null");
+ checkArgument(!treatments.isEmpty(), "Must have at least one treatment");
+
+ return new DefaultNextObjective(this);
+ }
+
+ @Override
+ public NextObjective removeFromExisting() {
+ treatments = listBuilder.build();
+ op = Operation.REMOVE_FROM_EXISTING;
+ checkNotNull(appId, "Must supply an application id");
+ checkNotNull(id, "id cannot be null");
+ checkNotNull(type, "The type cannot be null");
+
+ return new DefaultNextObjective(this);
+ }
+
+ @Override
+ public NextObjective addToExisting(ObjectiveContext context) {
+ treatments = listBuilder.build();
+ op = Operation.ADD_TO_EXISTING;
+ this.context = context;
+ checkNotNull(appId, "Must supply an application id");
+ checkNotNull(id, "id cannot be null");
+ checkNotNull(type, "The type cannot be null");
+ checkArgument(!treatments.isEmpty(), "Must have at least one treatment");
+
+ return new DefaultNextObjective(this);
+ }
+
+ @Override
+ public NextObjective removeFromExisting(ObjectiveContext context) {
+ treatments = listBuilder.build();
+ op = Operation.REMOVE_FROM_EXISTING;
+ this.context = context;
+ checkNotNull(appId, "Must supply an application id");
+ checkNotNull(id, "id cannot be null");
+ checkNotNull(type, "The type cannot be null");
+
+ return new DefaultNextObjective(this);
+ }
+
}
+
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java
index 1350d7a1..08916eb2 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/NextObjective.java
@@ -17,6 +17,7 @@ package org.onosproject.net.flowobjective;
import com.google.common.annotations.Beta;
import org.onosproject.core.ApplicationId;
+import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import java.util.Collection;
@@ -34,7 +35,7 @@ import java.util.Collection;
* - Failover
* - Simple
*
- * These types will indicate to the driver what the intended behaviour is.
+ * These types will indicate to the driver what the intended behavior is.
* For example, a broadcast next objective with a collection of output
* treatments will indicate to a driver that all output actions are expected
* to be executed simultaneously. The driver is then free to implement this
@@ -84,6 +85,16 @@ public interface NextObjective extends Objective {
Type type();
/**
+ * Auxiliary optional information provided to the device-driver.Typically
+ * conveys information about selectors (matches) that are intended to
+ * use this Next Objective.
+ *
+ * @return a selector intended to pass meta information to the device driver.
+ * Value may be null if no meta information is provided.
+ */
+ TrafficSelector meta();
+
+ /**
* A next step builder.
*/
interface Builder extends Objective.Builder {
@@ -131,6 +142,14 @@ public interface NextObjective extends Objective {
Builder withPriority(int priority);
/**
+ * Set meta information related to this next objective.
+ *
+ * @param selector match conditions
+ * @return an objective builder
+ */
+ Builder setMeta(TrafficSelector selector);
+
+ /**
* Builds the next objective that will be added.
*
* @return a next objective
@@ -162,6 +181,40 @@ public interface NextObjective extends Objective {
*/
NextObjective remove(ObjectiveContext context);
+ /**
+ * Build the next objective that will be added, with {@link Operation}
+ * ADD_TO_EXISTING.
+ *
+ * @return a next objective
+ */
+ NextObjective addToExisting();
+
+ /**
+ * Build the next objective that will be removed, with {@link Operation}
+ * REMOVE_FROM_EXISTING.
+ *
+ * @return a next objective
+ */
+ NextObjective removeFromExisting();
+
+ /**
+ * Builds the next objective that will be added, with {@link Operation}
+ * ADD_TO_EXISTING. The context will be used to notify the calling application.
+ *
+ * @param context an objective context
+ * @return a next objective
+ */
+ NextObjective addToExisting(ObjectiveContext context);
+
+ /**
+ * Builds the next objective that will be removed, with {@link Operation}
+ * REMOVE_FROM_EXISTING. The context will be used to notify the calling application.
+ *
+ * @param context an objective context
+ * @return a next objective
+ */
+ NextObjective removeFromExisting(ObjectiveContext context);
+
}
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java
index 6ac7a7a2..b1d73a7c 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java
@@ -21,7 +21,7 @@ import org.onosproject.core.ApplicationId;
import java.util.Optional;
/**
- * Base representation of an flow description.
+ * Base representation of a flow-objective description.
*/
@Beta
public interface Objective {
@@ -35,14 +35,30 @@ public interface Objective {
*/
enum Operation {
/**
- * Adds the objective.
+ * Adds the objective. Can be used for any flow objective. For forwarding
+ * and filtering objectives, existing objectives with identical selector
+ * and priority fields (but different treatments or next) will be replaced.
+ * For next objectives, if modification is desired, ADD will not
+ * do anything - use ADD_TO_EXISTING.
*/
ADD,
/**
- * Removes the objective.
+ * Removes the objective. Can be used for any flow objective.
*/
- REMOVE
+ REMOVE,
+
+ /**
+ * Add to an existing Next Objective. Should not be used for any other
+ * objective.
+ */
+ ADD_TO_EXISTING,
+
+ /**
+ * Remove from an existing Next Objective. Should not be used for any
+ * other objective.
+ */
+ REMOVE_FROM_EXISTING
}
/**
@@ -129,6 +145,7 @@ public interface Objective {
* @return an objective builder
*/
Builder withPriority(int priority);
+
}
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroupKey.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroupKey.java
index 7f00ae70..e1eacd1e 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroupKey.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroupKey.java
@@ -25,6 +25,7 @@ import java.util.Arrays;
public class DefaultGroupKey implements GroupKey {
private final byte[] key;
+ protected static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
public DefaultGroupKey(byte[] key) {
this.key = checkNotNull(key);
@@ -52,4 +53,20 @@ public class DefaultGroupKey implements GroupKey {
return Arrays.hashCode(this.key);
}
+ /**
+ * Returns a hex string representation of the byte array that is used
+ * as a group key. This solution was adapted from
+ * http://stackoverflow.com/questions/9655181/
+ */
+ @Override
+ public String toString() {
+ char[] hexChars = new char[key.length * 2];
+ for (int j = 0; j < key.length; j++) {
+ int v = key[j] & 0xFF;
+ hexChars[j * 2] = HEX_ARRAY[v >>> 4];
+ hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
+ }
+ return "GroupKey:0x" + new String(hexChars);
+ }
+
} \ No newline at end of file
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java
index c1467241..306597b3 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/HostToHostIntent.java
@@ -114,6 +114,8 @@ public final class HostToHostIntent extends ConnectivityIntent {
return this;
}
+
+
/**
* Builds a host to host intent from the accumulated parameters.
*
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java
index 444feee4..1b4a2600 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java
@@ -17,9 +17,9 @@ package org.onosproject.net.intent.constraint;
import com.google.common.annotations.Beta;
+import org.onlab.util.Bandwidth;
import org.onlab.util.DataRateUnit;
import org.onosproject.net.Link;
-import org.onosproject.net.resource.link.BandwidthResource;
import org.onosproject.net.resource.link.BandwidthResourceRequest;
import org.onosproject.net.resource.link.LinkResourceService;
import org.onosproject.net.resource.ResourceRequest;
@@ -36,14 +36,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
@Beta
public final class BandwidthConstraint extends BooleanConstraint {
- private final BandwidthResource bandwidth;
+ private final Bandwidth bandwidth;
/**
* Creates a new bandwidth constraint.
*
* @param bandwidth required bandwidth
*/
- public BandwidthConstraint(BandwidthResource bandwidth) {
+ public BandwidthConstraint(Bandwidth bandwidth) {
this.bandwidth = checkNotNull(bandwidth, "Bandwidth cannot be null");
}
@@ -55,7 +55,7 @@ public final class BandwidthConstraint extends BooleanConstraint {
* @return {@link BandwidthConstraint} instance with given bandwidth requirement
*/
public static BandwidthConstraint of(double v, DataRateUnit unit) {
- return new BandwidthConstraint(BandwidthResource.of(v, unit));
+ return new BandwidthConstraint(Bandwidth.of(v, unit));
}
// Constructor for serialization
@@ -68,7 +68,7 @@ public final class BandwidthConstraint extends BooleanConstraint {
for (ResourceRequest request : resourceService.getAvailableResources(link)) {
if (request.type() == ResourceType.BANDWIDTH) {
BandwidthResourceRequest brr = (BandwidthResourceRequest) request;
- if (brr.bandwidth().toDouble() >= bandwidth.toDouble()) {
+ if (brr.bandwidth().toDouble() >= bandwidth.bps()) {
return true;
}
}
@@ -81,7 +81,7 @@ public final class BandwidthConstraint extends BooleanConstraint {
*
* @return required bandwidth
*/
- public BandwidthResource bandwidth() {
+ public Bandwidth bandwidth() {
return bandwidth;
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/EncapsulationConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/EncapsulationConstraint.java
new file mode 100644
index 00000000..e8539398
--- /dev/null
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/EncapsulationConstraint.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2014-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.intent.constraint;
+
+
+import org.onosproject.net.EncapsulationType;
+import org.onosproject.net.Link;
+import org.onosproject.net.resource.link.LinkResourceService;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Encapsulation to manage core transportation.
+ */
+public class EncapsulationConstraint extends BooleanConstraint {
+
+ private EncapsulationType encapType;
+
+ /**
+ * Creates a new encapsulation constraint.
+ *
+ * @param encapType the encapsulation type {@link EncapsulationType}
+ */
+ public EncapsulationConstraint(EncapsulationType encapType) {
+ checkNotNull(encapType, "EncapsulationType cannot be null");
+ this.encapType = encapType;
+ }
+
+
+ @Override
+ public boolean isValid(Link link, LinkResourceService resourceService) {
+ //TODO: validate the availability of the resources for each link in the path.
+ //e.g., availability of MPLSlabels, VLANID
+
+ return true;
+ }
+
+ /**
+ * Returns the encapsulation type required by this constraint.
+ *
+ * @return encapType
+ */
+ public EncapsulationType encapType() {
+ return encapType;
+ }
+
+ @Override
+ public int hashCode() {
+ return encapType.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null || getClass() != obj.getClass()) {
+ return false;
+ }
+ final EncapsulationConstraint other = (EncapsulationConstraint) obj;
+ return this.encapType() == other.encapType();
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("encapType", encapType).toString();
+ }
+}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java
index 7811a004..eba28984 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java
@@ -16,8 +16,8 @@
package org.onosproject.net.intent.constraint;
import com.google.common.annotations.Beta;
+import org.onosproject.net.IndexedLambda;
import org.onosproject.net.Link;
-import org.onosproject.net.resource.link.LambdaResource;
import org.onosproject.net.resource.link.LinkResourceService;
import org.onosproject.net.resource.ResourceRequest;
import org.onosproject.net.resource.ResourceType;
@@ -32,14 +32,14 @@ import static com.google.common.base.MoreObjects.toStringHelper;
@Beta
public class LambdaConstraint extends BooleanConstraint {
- private final LambdaResource lambda;
+ private final IndexedLambda lambda;
/**
* Creates a new optical lambda constraint.
*
* @param lambda optional lambda to indicate a specific lambda
*/
- public LambdaConstraint(LambdaResource lambda) {
+ public LambdaConstraint(IndexedLambda lambda) {
this.lambda = lambda;
}
@@ -63,7 +63,7 @@ public class LambdaConstraint extends BooleanConstraint {
*
* @return required lambda
*/
- public LambdaResource lambda() {
+ public IndexedLambda lambda() {
return lambda;
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java
index cdcd4072..28c429bd 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java
@@ -16,8 +16,8 @@
package org.onosproject.net.newresource;
import com.google.common.annotations.Beta;
+import com.google.common.collect.ImmutableList;
-import java.util.Arrays;
import java.util.List;
/**
@@ -26,50 +26,42 @@ import java.util.List;
@Beta
public interface ResourceAdminService {
/**
- * Registers resources as the children of the parent resource path.
+ * Registers the specified resources.
*
- * @param parent parent resource path under which the resource are registered
- * @param children resources to be registered as the children of the parent
- * @param <T> type of resources
+ * @param resources resources to be registered
* @return true if registration is successfully done, false otherwise. Registration
* succeeds when each resource is not registered or unallocated.
*/
- default <T> boolean registerResources(ResourcePath parent, T... children) {
- return registerResources(parent, Arrays.asList(children));
+ default boolean registerResources(ResourcePath... resources) {
+ return registerResources(ImmutableList.copyOf(resources));
}
/**
- * Registers resources as the children of the parent resource path.
+ * Registers the specified resources.
*
- * @param parent parent resource path under which the resource are registered
- * @param children resources to be registered as the children of the parent
- * @param <T> type of resources
+ * @param resources resources to be registered
* @return true if registration is successfully done, false otherwise. Registration
* succeeds when each resource is not registered or unallocated.
*/
- <T> boolean registerResources(ResourcePath parent, List<T> children);
+ boolean registerResources(List<ResourcePath> resources);
/**
- * Unregisters resources as the children of the parent resource path.
+ * Unregisters the specified resources.
*
- * @param parent parent resource path under which the resource are unregistered
- * @param children resources to be unregistered as the children of the parent
- * @param <T> type of resources
+ * @param resources resources to be unregistered
* @return true if unregistration is successfully done, false otherwise. Unregistration
* succeeds when each resource is not registered or unallocated.
*/
- default <T> boolean unregisterResources(ResourcePath parent, T... children) {
- return unregisterResources(parent, Arrays.asList(children));
+ default boolean unregisterResources(ResourcePath... resources) {
+ return unregisterResources(ImmutableList.copyOf(resources));
}
/**
- * Unregisters resources as the children of the parent resource path.
+ * Unregisters the specified resources.
*
- * @param parent parent resource path under which the resource are unregistered
- * @param children resources to be unregistered as the children of the parent
- * @param <T> type of resources
+ * @param resources resources to be unregistered
* @return true if unregistration is successfully done, false otherwise. Unregistration
* succeeds when each resource is not registered or unallocated.
*/
- <T> boolean unregisterResources(ResourcePath parent, List<T> children);
+ boolean unregisterResources(List<ResourcePath> resources);
}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java
index d87682a9..c0c4e34f 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java
@@ -56,6 +56,7 @@ public abstract class ResourcePath {
* Creates an resource path which represents a discrete-type resource from the specified components.
*
* @param components components of the path. The order represents hierarchical structure of the resource.
+ * @return resource path instance
*/
public static ResourcePath discrete(Object... components) {
if (components.length == 0) {
@@ -70,6 +71,7 @@ public abstract class ResourcePath {
*
* @param value amount of the resource
* @param components components of the path. The order represents hierarchical structure of the resource.
+ * @return resource path instance
*/
public static ResourcePath continuous(double value, Object... components) {
return new Continuous(ImmutableList.copyOf(components), value);
@@ -141,12 +143,27 @@ public abstract class ResourcePath {
return Optional.ofNullable(parent);
}
+ /**
+ * Returns a child resource path of this instance with specifying the child object.
+ * The child resource path is discrete-type.
+ *
+ * @param child child object
+ * @return a child resource path
+ */
public ResourcePath child(Object child) {
checkState(this instanceof Discrete);
return new Discrete((Discrete) this, child);
}
+ /**
+ * Returns a child resource path of this instance with specifying a child object and
+ * value. The child resource path is continuous-type.
+ *
+ * @param child child object
+ * @param value value
+ * @return a child resource path
+ */
public ResourcePath child(Object child, double value) {
checkState(this instanceof Discrete);
@@ -197,6 +214,7 @@ public abstract class ResourcePath {
* implementation only. It is not for resource API user.
* </p>
*/
+ @Beta
public static final class Discrete extends ResourcePath {
private Discrete() {
super();
@@ -218,6 +236,7 @@ public abstract class ResourcePath {
* Note: This class is exposed to the public, but intended to be used in the resource API
* implementation only. It is not for resource API user.
*/
+ @Beta
public static final class Continuous extends ResourcePath {
// Note: value is not taken into account for equality
private final double value;
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceRequest.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceRequest.java
index b57465f2..583570f5 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceRequest.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/DefaultLinkResourceRequest.java
@@ -201,7 +201,7 @@ public final class DefaultLinkResourceRequest implements LinkResourceRequest {
return addLambdaRequest();
} else if (constraint instanceof BandwidthConstraint) {
BandwidthConstraint bw = (BandwidthConstraint) constraint;
- return addBandwidthRequest(bw.bandwidth().toDouble());
+ return addBandwidthRequest(bw.bandwidth().bps());
}
return this;
}