diff options
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/net/flow')
90 files changed, 0 insertions, 11235 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/AbstractExtension.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/AbstractExtension.java deleted file mode 100644 index b48d69ce..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/AbstractExtension.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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; - -import org.onosproject.net.flow.instructions.ExtensionPropertyException; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; - -/** - * Abstract implementation of the set/get property methods of Extension. - */ -public abstract class AbstractExtension implements Extension { - - private static final String INVALID_KEY = "Invalid property key: "; - private static final String INVALID_TYPE = "Given type does not match field type: "; - - @Override - public <T> void setPropertyValue(String key, T value) throws - ExtensionPropertyException { - Class<?> clazz = this.getClass(); - try { - Field field = clazz.getDeclaredField(key); - field.setAccessible(true); - field.set(this, value); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new ExtensionPropertyException(INVALID_KEY + key); - } - } - - @Override - public <T> T getPropertyValue(String key) throws ExtensionPropertyException { - Class<?> clazz = this.getClass(); - try { - Field field = clazz.getDeclaredField(key); - field.setAccessible(true); - @SuppressWarnings("unchecked") - T result = (T) field.get(this); - return result; - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new ExtensionPropertyException(INVALID_KEY + key); - } catch (ClassCastException e) { - throw new ExtensionPropertyException(INVALID_TYPE + key); - } - } - - @Override - public List<String> getProperties() { - Class<?> clazz = this.getClass(); - - List<String> fields = new ArrayList<>(); - - for (Field field : clazz.getDeclaredFields()) { - fields.add(field.getName()); - } - - return fields; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/BatchOperation.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/BatchOperation.java deleted file mode 100644 index 09e34d88..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/BatchOperation.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2014 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; - -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * A list of BatchOperationEntry. - * - * @param <T> the enum of operators <br> - * This enum must be defined in each sub-classes. - */ -public abstract class BatchOperation<T extends BatchOperationEntry<?, ?>> { - - private final List<T> ops; - - /** - * Creates new {@link BatchOperation} object. - */ - public BatchOperation() { - ops = new LinkedList<>(); - } - - /** - * Creates {@link BatchOperation} object from a list of batch operation - * entries. - * - * @param batchOperations the list of batch operation entries. - */ - public BatchOperation(Collection<T> batchOperations) { - ops = new LinkedList<>(checkNotNull(batchOperations)); - } - - /** - * Removes all operations maintained in this object. - */ - public void clear() { - ops.clear(); - } - - /** - * Returns the number of operations in this object. - * - * @return the number of operations in this object - */ - public int size() { - return ops.size(); - } - - /** - * Returns the operations in this object. - * - * @return the operations in this object - */ - public List<T> getOperations() { - return Collections.unmodifiableList(ops); - } - - /** - * Adds an operation. - * FIXME: Brian promises that the Intent Framework - * will not modify the batch operation after it has submitted it. - * Ali would prefer immutablity, but trusts brian for better or - * for worse. - * - * @param entry the operation to be added - * @return this object if succeeded, null otherwise - */ - public BatchOperation<T> addOperation(T entry) { - return ops.add(entry) ? this : null; - } - - /** - * Add all operations from another batch to this batch. - * - * @param another another batch - * @return true if success - */ - public boolean addAll(BatchOperation<T> another) { - return ops.addAll(another.getOperations()); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (o == null) { - return false; - } - - if (getClass() != o.getClass()) { - return false; - } - BatchOperation<?> other = (BatchOperation<?>) o; - - return this.ops.equals(other.ops); - } - - @Override - public int hashCode() { - return ops.hashCode(); - } - - @Override - public String toString() { - return ops.toString(); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/BatchOperationEntry.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/BatchOperationEntry.java deleted file mode 100644 index cc054286..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/BatchOperationEntry.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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.flow; - -import java.util.Objects; - -import com.google.common.base.MoreObjects; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * A super class for batch operation entry classes. - * <p> - * This is the interface to classes which are maintained by BatchOperation as - * its entries. - */ -public class BatchOperationEntry<T extends Enum<?>, U> { - - private final T operator; - private final U target; - - /** - * Constructs new instance for the entry of the BatchOperation. - * - * @param operator the operator of this operation - * @param target the target object of this operation - */ - public BatchOperationEntry(T operator, U target) { - this.operator = checkNotNull(operator); - this.target = checkNotNull(target); - } - - /** - * Gets the target object of this operation. - * - * @return the target object of this operation - */ - public U target() { - return target; - } - - /** - * Gets the operator of this operation. - * - * @return the operator of this operation - */ - public T operator() { - return operator; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - BatchOperationEntry<?, ?> other = (BatchOperationEntry<?, ?>) o; - return (this.operator == other.operator) && - Objects.equals(this.target, other.target); - } - - @Override - public int hashCode() { - return Objects.hash(operator, target); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("operator", operator) - .add("target", target) - .toString(); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/BatchOperationResult.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/BatchOperationResult.java deleted file mode 100644 index 684a8698..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/BatchOperationResult.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2014 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; - -import java.util.Set; - -/** - * Interface capturing the result of a batch operation. - * - */ -public interface BatchOperationResult<T> { - - /** - * Returns whether the operation was successful. - * @return true if successful, false otherwise - */ - boolean isSuccess(); - - /** - * Obtains a set of items which failed. - * @return a set of failures - */ - Set<T> failedItems(); - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/CompletedBatchOperation.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/CompletedBatchOperation.java deleted file mode 100644 index 3afae5ef..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/CompletedBatchOperation.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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.flow; - - -import com.google.common.base.MoreObjects; -import com.google.common.collect.ImmutableSet; -import org.onosproject.net.DeviceId; - -import java.util.Collections; -import java.util.Set; - -/** - * Representation of a completed flow rule batch operation. - */ -public class CompletedBatchOperation implements BatchOperationResult<FlowRule> { - - private final boolean success; - private final Set<FlowRule> failures; - private final Set<Long> failedIds; - private final DeviceId deviceId; - - /** - * Creates a new batch completion result. - * - * @param success indicates whether the completion is successful - * @param failures set of any failures encountered - * @param failedIds (optional) set of failed operation ids - * @param deviceId the device this operation completed for - */ - public CompletedBatchOperation(boolean success, Set<? extends FlowRule> failures, - Set<Long> failedIds, DeviceId deviceId) { - this.success = success; - this.failures = ImmutableSet.copyOf(failures); - this.failedIds = ImmutableSet.copyOf(failedIds); - this.deviceId = deviceId; - } - - /** - * Creates a new batch completion result. - * - * @param success indicates whether the completion is successful. - * @param failures set of any failures encountered - * @param deviceId the device this operation completed for - */ - public CompletedBatchOperation(boolean success, Set<? extends FlowRule> failures, - DeviceId deviceId) { - this.success = success; - this.failures = ImmutableSet.copyOf(failures); - this.failedIds = Collections.emptySet(); - this.deviceId = deviceId; - } - - - - @Override - public boolean isSuccess() { - return success; - } - - @Override - public Set<FlowRule> failedItems() { - return failures; - } - - public Set<Long> failedIds() { - return failedIds; - } - - public DeviceId deviceId() { - return this.deviceId; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()) - .add("success?", success) - .add("failedItems", failures) - .add("failedIds", failedIds) - .add("deviceId", deviceId) - .toString(); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowEntry.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowEntry.java deleted file mode 100644 index f7e7708e..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowEntry.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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.flow; - -import static com.google.common.base.MoreObjects.toStringHelper; -import static org.slf4j.LoggerFactory.getLogger; - -import org.slf4j.Logger; - -public class DefaultFlowEntry extends DefaultFlowRule - implements StoredFlowEntry { - - private static final Logger log = getLogger(DefaultFlowEntry.class); - - private long life; - private long packets; - private long bytes; - private FlowEntryState state; - - private long lastSeen = -1; - - private final int errType; - - private final int errCode; - - public DefaultFlowEntry(FlowRule rule, FlowEntryState state, - long life, long packets, long bytes) { - super(rule); - this.state = state; - this.life = life; - this.packets = packets; - this.bytes = bytes; - this.errCode = -1; - this.errType = -1; - this.lastSeen = System.currentTimeMillis(); - } - - public DefaultFlowEntry(FlowRule rule) { - super(rule); - this.state = FlowEntryState.PENDING_ADD; - this.life = 0; - this.packets = 0; - this.bytes = 0; - this.errCode = -1; - this.errType = -1; - this.lastSeen = System.currentTimeMillis(); - } - - public DefaultFlowEntry(FlowRule rule, int errType, int errCode) { - super(rule); - this.state = FlowEntryState.FAILED; - this.errType = errType; - this.errCode = errCode; - this.lastSeen = System.currentTimeMillis(); - } - - @Override - public long life() { - return life; - } - - @Override - public long packets() { - return packets; - } - - @Override - public long bytes() { - return bytes; - } - - @Override - public FlowEntryState state() { - return this.state; - } - - @Override - public long lastSeen() { - return lastSeen; - } - - @Override - public void setLastSeen() { - this.lastSeen = System.currentTimeMillis(); - } - - @Override - public void setState(FlowEntryState newState) { - this.state = newState; - } - - @Override - public void setLife(long life) { - this.life = life; - } - - @Override - public void setPackets(long packets) { - this.packets = packets; - } - - @Override - public void setBytes(long bytes) { - this.bytes = bytes; - } - - @Override - public int errType() { - return this.errType; - } - - @Override - public int errCode() { - return this.errCode; - } - - @Override - public String toString() { - return toStringHelper(this) - .add("rule", super.toString()) - .add("state", state) - .toString(); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java deleted file mode 100644 index 5492fa98..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Copyright 2014 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; - -import org.onosproject.core.ApplicationId; -import org.onosproject.core.DefaultGroupId; -import org.onosproject.core.GroupId; -import org.onosproject.net.DeviceId; - -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -public class DefaultFlowRule implements FlowRule { - - private final DeviceId deviceId; - private final int priority; - private final TrafficSelector selector; - private final TrafficTreatment treatment; - private final long created; - - private final FlowId id; - - private final Short appId; - - private final int timeout; - private final boolean permanent; - private final GroupId groupId; - - private final Integer tableId; - private final FlowRuleExtPayLoad payLoad; - - public DefaultFlowRule(FlowRule rule) { - this.deviceId = rule.deviceId(); - this.priority = rule.priority(); - this.selector = rule.selector(); - this.treatment = rule.treatment(); - this.appId = rule.appId(); - this.groupId = rule.groupId(); - this.id = rule.id(); - this.timeout = rule.timeout(); - this.permanent = rule.isPermanent(); - this.created = System.currentTimeMillis(); - this.tableId = rule.tableId(); - this.payLoad = rule.payLoad(); - } - - private DefaultFlowRule(DeviceId deviceId, TrafficSelector selector, - TrafficTreatment treatment, Integer priority, - FlowId flowId, Boolean permanent, Integer timeout, - Integer tableId) { - - this.deviceId = deviceId; - this.selector = selector; - this.treatment = treatment; - this.priority = priority; - this.appId = (short) (flowId.value() >>> 48); - this.id = flowId; - this.permanent = permanent; - this.timeout = timeout; - this.tableId = tableId; - this.created = System.currentTimeMillis(); - - - //FIXME: fields below will be removed. - this.groupId = new DefaultGroupId(0); - this.payLoad = null; - } - - /** - * Support for the third party flow rule. Creates a flow rule of flow table. - * - * @param deviceId the identity of the device where this rule applies - * @param selector the traffic selector that identifies what traffic this - * rule - * @param treatment the traffic treatment that applies to selected traffic - * @param priority the flow rule priority given in natural order - * @param appId the application id of this flow - * @param timeout the timeout for this flow requested by an application - * @param permanent whether the flow is permanent i.e. does not time out - * @param payLoad 3rd-party origin private flow - */ - public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector, - TrafficTreatment treatment, int priority, - ApplicationId appId, int timeout, boolean permanent, - FlowRuleExtPayLoad payLoad) { - - if (priority < FlowRule.MIN_PRIORITY) { - throw new IllegalArgumentException("Priority cannot be less than " - + MIN_PRIORITY); - } - - this.deviceId = deviceId; - this.priority = priority; - this.selector = selector; - this.treatment = treatment; - this.appId = appId.id(); - this.groupId = new DefaultGroupId(0); - this.timeout = timeout; - this.permanent = permanent; - this.tableId = 0; - this.created = System.currentTimeMillis(); - this.payLoad = payLoad; - - /* - * id consists of the following. | appId (16 bits) | groupId (16 bits) | - * flowId (32 bits) | - */ - this.id = FlowId.valueOf((((long) this.appId) << 48) - | (((long) this.groupId.id()) << 32) - | (this.hash() & 0xffffffffL)); - } - - /** - * Support for the third party flow rule. Creates a flow rule of group - * table. - * - * @param deviceId the identity of the device where this rule applies - * @param selector the traffic selector that identifies what traffic this - * rule - * @param treatment the traffic treatment that applies to selected traffic - * @param priority the flow rule priority given in natural order - * @param appId the application id of this flow - * @param groupId the group id of this flow - * @param timeout the timeout for this flow requested by an application - * @param permanent whether the flow is permanent i.e. does not time out - * @param payLoad 3rd-party origin private flow - * - */ - public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector, - TrafficTreatment treatment, int priority, - ApplicationId appId, GroupId groupId, int timeout, - boolean permanent, FlowRuleExtPayLoad payLoad) { - - if (priority < FlowRule.MIN_PRIORITY) { - throw new IllegalArgumentException("Priority cannot be less than " - + MIN_PRIORITY); - } - - this.deviceId = deviceId; - this.priority = priority; - this.selector = selector; - this.treatment = treatment; - this.appId = appId.id(); - this.groupId = groupId; - this.timeout = timeout; - this.permanent = permanent; - this.created = System.currentTimeMillis(); - this.tableId = 0; - this.payLoad = payLoad; - - /* - * id consists of the following. | appId (16 bits) | groupId (16 bits) | - * flowId (32 bits) | - */ - this.id = FlowId.valueOf((((long) this.appId) << 48) - | (((long) this.groupId.id()) << 32) - | (this.hash() & 0xffffffffL)); - } - - @Override - public FlowId id() { - return id; - } - - @Override - public short appId() { - return appId; - } - - @Override - public GroupId groupId() { - return groupId; - } - - @Override - public int priority() { - return priority; - } - - @Override - public DeviceId deviceId() { - return deviceId; - } - - @Override - public TrafficSelector selector() { - return selector; - } - - @Override - public TrafficTreatment treatment() { - return treatment; - } - - @Override - /* - * The priority and statistics can change on a given treatment and selector - * - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public int hashCode() { - return Objects.hash(deviceId, selector, tableId, payLoad); - } - - //FIXME do we need this method in addition to hashCode()? - private int hash() { - return Objects.hash(deviceId, selector, tableId, payLoad); - } - - @Override - /* - * The priority and statistics can change on a given treatment and selector - * - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof DefaultFlowRule) { - DefaultFlowRule that = (DefaultFlowRule) obj; - return Objects.equals(deviceId, that.deviceId) && - Objects.equals(priority, that.priority) && - Objects.equals(selector, that.selector) && - Objects.equals(tableId, that.tableId) - && Objects.equals(payLoad, that.payLoad); - } - return false; - } - - @Override - public boolean exactMatch(FlowRule rule) { - return this.equals(rule) && - Objects.equals(this.id, rule.id()) && - Objects.equals(this.treatment, rule.treatment()); - } - - @Override - public String toString() { - return toStringHelper(this) - .add("id", Long.toHexString(id.value())) - .add("deviceId", deviceId) - .add("priority", priority) - .add("selector", selector.criteria()) - .add("treatment", treatment == null ? "N/A" : treatment.allInstructions()) - .add("tableId", tableId) - .add("created", created) - .add("payLoad", payLoad) - .toString(); - } - - @Override - public int timeout() { - return timeout; - } - - @Override - public boolean isPermanent() { - return permanent; - } - - @Override - public int tableId() { - return tableId; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder implements FlowRule.Builder { - - private FlowId flowId; - private ApplicationId appId; - private Integer priority; - private DeviceId deviceId; - private Integer tableId = 0; - private TrafficSelector selector; - private TrafficTreatment treatment; - private Integer timeout; - private Boolean permanent; - - @Override - public FlowRule.Builder withCookie(long cookie) { - this.flowId = FlowId.valueOf(cookie); - return this; - } - - @Override - public FlowRule.Builder fromApp(ApplicationId appId) { - this.appId = appId; - return this; - } - - @Override - public FlowRule.Builder withPriority(int priority) { - this.priority = priority; - return this; - } - - @Override - public FlowRule.Builder forDevice(DeviceId deviceId) { - this.deviceId = deviceId; - return this; - } - - @Override - public FlowRule.Builder forTable(int tableId) { - this.tableId = tableId; - return this; - } - - @Override - public FlowRule.Builder withSelector(TrafficSelector selector) { - this.selector = selector; - return this; - } - - @Override - public FlowRule.Builder withTreatment(TrafficTreatment treatment) { - this.treatment = treatment; - return this; - } - - @Override - public FlowRule.Builder makePermanent() { - this.timeout = 0; - this.permanent = true; - return this; - } - - @Override - public FlowRule.Builder makeTemporary(int timeout) { - this.permanent = false; - this.timeout = timeout; - return this; - } - - @Override - public FlowRule build() { - checkArgument(flowId != null || appId != null, "Either an application" + - " id or a cookie must be supplied"); - checkNotNull(selector, "Traffic selector cannot be null"); - checkArgument(timeout != null || permanent != null, "Must either have " + - "a timeout or be permanent"); - checkNotNull(deviceId, "Must refer to a device"); - checkNotNull(priority, "Priority cannot be null"); - checkArgument(priority >= MIN_PRIORITY, "Priority cannot be less than " + - MIN_PRIORITY); - - // Computing a flow ID based on appId takes precedence over setting - // the flow ID directly - if (appId != null) { - flowId = computeFlowId(appId); - } - - return new DefaultFlowRule(deviceId, selector, treatment, priority, - flowId, permanent, timeout, tableId); - } - - private FlowId computeFlowId(ApplicationId appId) { - return FlowId.valueOf((((long) appId.id()) << 48) - | (hash() & 0xffffffffL)); - } - - private int hash() { - return Objects.hash(deviceId, priority, selector, tableId); - } - - } - - @Override - public FlowRuleExtPayLoad payLoad() { - return payLoad; - } - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTableStatisticsEntry.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTableStatisticsEntry.java deleted file mode 100644 index 929b285d..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTableStatisticsEntry.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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; - -import org.onosproject.net.DeviceId; -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Default implementation of table statistics entry interface. - */ -public final class DefaultTableStatisticsEntry implements TableStatisticsEntry { - - private final DeviceId deviceId; - private final int tableId; - private final long activeFlowEntries; - private final long packetsLookedupCount; - private final long packetsMatchedCount; - - /** - * Default table statistics constructor. - * - * @param deviceId device identifier - * @param tableId table identifier - * @param activeFlowEntries number of active flow entries in the table - * @param packetsLookedupCount number of packets looked up in table - * @param packetsMatchedCount number of packets that hit table - */ - public DefaultTableStatisticsEntry(DeviceId deviceId, - int tableId, - long activeFlowEntries, - long packetsLookedupCount, - long packetsMatchedCount) { - this.deviceId = checkNotNull(deviceId); - this.tableId = tableId; - this.activeFlowEntries = activeFlowEntries; - this.packetsLookedupCount = packetsLookedupCount; - this.packetsMatchedCount = packetsMatchedCount; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("device: " + deviceId + ", "); - - sb.append("tableId: " + this.tableId + ", "); - sb.append("activeEntries: " + this.activeFlowEntries + ", "); - sb.append("packetsLookedUp: " + this.packetsLookedupCount + ", "); - sb.append("packetsMatched: " + this.packetsMatchedCount); - - return sb.toString(); - } - - @Override - public int tableId() { - return tableId; - } - - @Override - public long activeFlowEntries() { - return activeFlowEntries; - } - - @Override - public long packetsLookedup() { - return packetsLookedupCount; - } - - @Override - public long packetsMatched() { - return packetsMatchedCount; - } - - @Override - public DeviceId deviceId() { - return deviceId; - } -} 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 deleted file mode 100644 index 0525d8fa..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java +++ /dev/null @@ -1,393 +0,0 @@ -/* - * 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.flow; - -import com.google.common.base.MoreObjects; -import com.google.common.collect.ImmutableSet; -import org.onlab.packet.Ip4Address; -import org.onlab.packet.Ip6Address; -import org.onlab.packet.IpPrefix; -import org.onlab.packet.MacAddress; -import org.onlab.packet.MplsLabel; -import org.onlab.packet.TpPort; -import org.onlab.packet.VlanId; -import org.onosproject.net.DeviceId; -import org.onosproject.net.PortNumber; -import org.onosproject.net.flow.criteria.Criteria; -import org.onosproject.net.flow.criteria.Criterion; -import org.onosproject.net.flow.criteria.ExtensionSelector; - -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.TreeSet; - -/** - * Default traffic selector implementation. - */ -public final class DefaultTrafficSelector implements TrafficSelector { - - private static final Comparator<? super Criterion> TYPE_COMPARATOR = - (c1, c2) -> c1.type().compareTo(c2.type()); - - private final Set<Criterion> criteria; - - private static final TrafficSelector EMPTY - = new DefaultTrafficSelector(Collections.emptySet()); - - /** - * Creates a new traffic selector with the specified criteria. - * - * @param criteria criteria - */ - private DefaultTrafficSelector(Set<Criterion> criteria) { - TreeSet<Criterion> elements = new TreeSet<>(TYPE_COMPARATOR); - elements.addAll(criteria); - this.criteria = ImmutableSet.copyOf(elements); - } - - @Override - public Set<Criterion> criteria() { - return criteria; - } - - @Override - public Criterion getCriterion(Criterion.Type type) { - for (Criterion c : criteria) { - if (c.type() == type) { - return c; - } - } - return null; - } - - @Override - public int hashCode() { - return criteria.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof DefaultTrafficSelector) { - DefaultTrafficSelector that = (DefaultTrafficSelector) obj; - return Objects.equals(criteria, that.criteria); - - } - return false; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()) - .add("criteria", criteria) - .toString(); - } - - /** - * Returns a new traffic selector builder. - * - * @return traffic selector builder - */ - public static TrafficSelector.Builder builder() { - return new Builder(); - } - - /** - * Returns an empty traffic selector. - * - * @return empty traffic selector - */ - public static TrafficSelector emptySelector() { - return EMPTY; - } - - /** - * Returns a new traffic selector builder primed to produce entities - * patterned after the supplied selector. - * - * @param selector base selector - * @return traffic selector builder - */ - public static TrafficSelector.Builder builder(TrafficSelector selector) { - return new Builder(selector); - } - - /** - * Builder of traffic selector entities. - */ - public static final class Builder implements TrafficSelector.Builder { - - private final Map<Criterion.Type, Criterion> selector = new HashMap<>(); - - private Builder() { - } - - private Builder(TrafficSelector selector) { - for (Criterion c : selector.criteria()) { - add(c); - } - } - - @Override - public Builder add(Criterion criterion) { - selector.put(criterion.type(), criterion); - return this; - } - - @Override - public Builder matchInPort(PortNumber port) { - return add(Criteria.matchInPort(port)); - } - - @Override - public Builder matchInPhyPort(PortNumber port) { - return add(Criteria.matchInPhyPort(port)); - } - - @Override - public Builder matchMetadata(long metadata) { - return add(Criteria.matchMetadata(metadata)); - } - - @Override - public Builder matchEthDst(MacAddress addr) { - return add(Criteria.matchEthDst(addr)); - } - - @Override - public Builder matchEthSrc(MacAddress addr) { - return add(Criteria.matchEthSrc(addr)); - } - - @Override - public Builder matchEthType(short ethType) { - return add(Criteria.matchEthType(ethType)); - } - - @Override - public Builder matchVlanId(VlanId vlanId) { - return add(Criteria.matchVlanId(vlanId)); - } - - @Override - public Builder matchVlanPcp(byte vlanPcp) { - return add(Criteria.matchVlanPcp(vlanPcp)); - } - - @Override - public Builder matchIPDscp(byte ipDscp) { - return add(Criteria.matchIPDscp(ipDscp)); - } - - @Override - public Builder matchIPEcn(byte ipEcn) { - return add(Criteria.matchIPEcn(ipEcn)); - } - - @Override - public Builder matchIPProtocol(byte proto) { - return add(Criteria.matchIPProtocol(proto)); - } - - @Override - public Builder matchIPSrc(IpPrefix ip) { - return add(Criteria.matchIPSrc(ip)); - } - - @Override - public Builder matchIPDst(IpPrefix ip) { - return add(Criteria.matchIPDst(ip)); - } - - @Deprecated - @Override - public Builder matchTcpSrc(short tcpPort) { - return matchTcpSrc(TpPort.tpPort(tcpPort)); - } - - @Override - public Builder matchTcpSrc(TpPort tcpPort) { - return add(Criteria.matchTcpSrc(tcpPort)); - } - - @Deprecated - @Override - public Builder matchTcpDst(short tcpPort) { - return matchTcpDst(TpPort.tpPort(tcpPort)); - } - - @Override - public Builder matchTcpDst(TpPort tcpPort) { - return add(Criteria.matchTcpDst(tcpPort)); - } - - @Deprecated - @Override - public Builder matchUdpSrc(short udpPort) { - return matchUdpSrc(TpPort.tpPort(udpPort)); - } - - @Override - public Builder matchUdpSrc(TpPort udpPort) { - return add(Criteria.matchUdpSrc(udpPort)); - } - - @Deprecated - @Override - public Builder matchUdpDst(short udpPort) { - return matchUdpDst(TpPort.tpPort(udpPort)); - } - - @Override - public Builder matchUdpDst(TpPort udpPort) { - return add(Criteria.matchUdpDst(udpPort)); - } - - @Deprecated - @Override - public Builder matchSctpSrc(short sctpPort) { - return matchSctpSrc(TpPort.tpPort(sctpPort)); - } - - @Override - public Builder matchSctpSrc(TpPort sctpPort) { - return add(Criteria.matchSctpSrc(sctpPort)); - } - - @Deprecated - @Override - public Builder matchSctpDst(short sctpPort) { - return matchSctpDst(TpPort.tpPort(sctpPort)); - } - - @Override - public Builder matchSctpDst(TpPort sctpPort) { - return add(Criteria.matchSctpDst(sctpPort)); - } - - @Override - public Builder matchIcmpType(byte icmpType) { - return add(Criteria.matchIcmpType(icmpType)); - } - - @Override - public Builder matchIcmpCode(byte icmpCode) { - return add(Criteria.matchIcmpCode(icmpCode)); - } - - @Override - public Builder matchIPv6Src(IpPrefix ip) { - return add(Criteria.matchIPv6Src(ip)); - } - - @Override - public Builder matchIPv6Dst(IpPrefix ip) { - return add(Criteria.matchIPv6Dst(ip)); - } - - @Override - public Builder matchIPv6FlowLabel(int flowLabel) { - return add(Criteria.matchIPv6FlowLabel(flowLabel)); - } - - @Override - public Builder matchIcmpv6Type(byte icmpv6Type) { - return add(Criteria.matchIcmpv6Type(icmpv6Type)); - } - - @Override - public Builder matchIcmpv6Code(byte icmpv6Code) { - return add(Criteria.matchIcmpv6Code(icmpv6Code)); - } - - @Override - public Builder matchIPv6NDTargetAddress(Ip6Address targetAddress) { - return add(Criteria.matchIPv6NDTargetAddress(targetAddress)); - } - - @Override - public Builder matchIPv6NDSourceLinkLayerAddress(MacAddress mac) { - return add(Criteria.matchIPv6NDSourceLinkLayerAddress(mac)); - } - - @Override - public Builder matchIPv6NDTargetLinkLayerAddress(MacAddress mac) { - return add(Criteria.matchIPv6NDTargetLinkLayerAddress(mac)); - } - - @Override - public Builder matchMplsLabel(MplsLabel mplsLabel) { - return add(Criteria.matchMplsLabel(mplsLabel)); - } - - @Override - public Builder matchMplsBos(boolean mplsBos) { - return add(Criteria.matchMplsBos(mplsBos)); - } - - @Override - public TrafficSelector.Builder matchTunnelId(long tunnelId) { - return add(Criteria.matchTunnelId(tunnelId)); - } - - @Override - public Builder matchIPv6ExthdrFlags(short exthdrFlags) { - return add(Criteria.matchIPv6ExthdrFlags(exthdrFlags)); - } - - @Override - public Builder matchArpTpa(Ip4Address addr) { - return add(Criteria.matchArpTpa(addr)); - } - - @Override - public Builder matchArpSpa(Ip4Address addr) { - return add(Criteria.matchArpSpa(addr)); - } - - @Override - public Builder matchArpTha(MacAddress addr) { - return add(Criteria.matchArpTha(addr)); - } - - @Override - public Builder matchArpSha(MacAddress addr) { - return add(Criteria.matchArpSha(addr)); - } - - @Override - public Builder matchArpOp(int arpOp) { - return add(Criteria.matchArpOp(arpOp)); - } - - @Override - public TrafficSelector.Builder extension(ExtensionSelector extensionSelector, - DeviceId deviceId) { - return add(Criteria.extension(extensionSelector, deviceId)); - } - - @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 deleted file mode 100644 index 40291f57..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java +++ /dev/null @@ -1,524 +0,0 @@ -/* - * 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.flow; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; -import java.util.Objects; - -import org.onlab.packet.EthType; -import org.onlab.packet.IpAddress; -import org.onlab.packet.MacAddress; -import org.onlab.packet.MplsLabel; -import org.onlab.packet.TpPort; -import org.onlab.packet.VlanId; -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.ExtensionTreatment; -import org.onosproject.net.flow.instructions.Instruction; -import org.onosproject.net.flow.instructions.Instructions; -import org.onosproject.net.meter.MeterId; - -import com.google.common.base.MoreObjects; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; - -/** - * Default traffic treatment implementation. - */ -public final class DefaultTrafficTreatment implements TrafficTreatment { - - private final List<Instruction> immediate; - private final List<Instruction> deferred; - private final List<Instruction> all; - private final Instructions.TableTypeTransition table; - private final Instructions.MetadataInstruction meta; - - private final boolean hasClear; - - private static final DefaultTrafficTreatment EMPTY - = new DefaultTrafficTreatment(ImmutableList.of(Instructions.createNoAction())); - private final Instructions.MeterInstruction meter; - - /** - * Creates a new traffic treatment from the specified list of instructions. - * - * @param immediate immediate instructions - */ - private DefaultTrafficTreatment(List<Instruction> immediate) { - this.immediate = ImmutableList.copyOf(checkNotNull(immediate)); - this.deferred = ImmutableList.of(); - this.all = this.immediate; - this.hasClear = false; - this.table = null; - this.meta = null; - this.meter = null; - } - - /** - * Creates a new traffic treatment from the specified list of instructions. - * - * @param deferred deferred instructions - * @param immediate immediate instructions - * @param table table transition instruction - * @param clear instruction to clear the deferred actions list - */ - private DefaultTrafficTreatment(List<Instruction> deferred, - List<Instruction> immediate, - Instructions.TableTypeTransition table, - boolean clear, - Instructions.MetadataInstruction meta, - Instructions.MeterInstruction meter) { - this.immediate = ImmutableList.copyOf(checkNotNull(immediate)); - this.deferred = ImmutableList.copyOf(checkNotNull(deferred)); - this.all = new ImmutableList.Builder<Instruction>() - .addAll(immediate) - .addAll(deferred) - .build(); - this.table = table; - this.meta = meta; - this.hasClear = clear; - this.meter = meter; - } - - @Override - public List<Instruction> deferred() { - return deferred; - } - - @Override - public List<Instruction> immediate() { - return immediate; - } - - @Override - public List<Instruction> allInstructions() { - return all; - } - - @Override - public Instructions.TableTypeTransition tableTransition() { - return table; - } - - @Override - public boolean clearedDeferred() { - return hasClear; - } - - @Override - public Instructions.MetadataInstruction writeMetadata() { - return meta; - } - - @Override - public Instructions.MeterInstruction metered() { - return meter; - } - - /** - * Returns a new traffic treatment builder. - * - * @return traffic treatment builder - */ - public static TrafficTreatment.Builder builder() { - return new Builder(); - } - - /** - * Returns an empty traffic treatment. - * - * @return empty traffic treatment - */ - public static TrafficTreatment emptyTreatment() { - return EMPTY; - } - - /** - * Returns a new traffic treatment builder primed to produce entities - * patterned after the supplied treatment. - * - * @param treatment base treatment - * @return traffic treatment builder - */ - public static TrafficTreatment.Builder builder(TrafficTreatment treatment) { - return new Builder(treatment); - } - - //FIXME: Order of instructions may affect hashcode - @Override - public int hashCode() { - return Objects.hash(immediate, deferred, table, meta); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof DefaultTrafficTreatment) { - DefaultTrafficTreatment that = (DefaultTrafficTreatment) obj; - return Objects.equals(immediate, that.immediate) && - Objects.equals(deferred, that.deferred) && - Objects.equals(table, that.table) && - Objects.equals(meta, that.meta); - - } - return false; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()) - .add("immediate", immediate) - .add("deferred", deferred) - .add("transition", table == null ? "None" : table.toString()) - .add("cleared", hasClear) - .add("metadata", meta) - .toString(); - } - - /** - * Builds a list of treatments following the following order. - * Modifications -> Group -> Output (including drop) - */ - public static final class Builder implements TrafficTreatment.Builder { - - boolean clear = false; - - Instructions.TableTypeTransition table; - - Instructions.MetadataInstruction meta; - - Instructions.MeterInstruction meter; - - List<Instruction> deferred = Lists.newLinkedList(); - - List<Instruction> immediate = Lists.newLinkedList(); - - List<Instruction> current = immediate; - - // Creates a new builder - private Builder() { - } - - // Creates a new builder based off an existing treatment - private Builder(TrafficTreatment treatment) { - deferred(); - treatment.deferred().forEach(i -> add(i)); - - immediate(); - treatment.immediate().stream() - // NOACTION will get re-added if there are no other actions - .filter(i -> i.type() != Instruction.Type.NOACTION) - .forEach(i -> add(i)); - - clear = treatment.clearedDeferred(); - } - - @Override - public Builder add(Instruction instruction) { - - switch (instruction.type()) { - case DROP: - case NOACTION: - case OUTPUT: - case GROUP: - case QUEUE: - case L0MODIFICATION: - case L1MODIFICATION: - case L2MODIFICATION: - case L3MODIFICATION: - case L4MODIFICATION: - case EXTENSION: - current.add(instruction); - break; - case TABLE: - table = (Instructions.TableTypeTransition) instruction; - break; - case METADATA: - meta = (Instructions.MetadataInstruction) instruction; - break; - case METER: - meter = (Instructions.MeterInstruction) instruction; - break; - default: - throw new IllegalArgumentException("Unknown instruction type: " + - instruction.type()); - } - - return this; - } - - /** - * Add a NOACTION when DROP instruction is explicitly specified. - * - * @return the traffic treatment builder - */ - @Override - public Builder drop() { - return add(Instructions.createNoAction()); - } - - /** - * Add a NOACTION when no instruction is specified. - * - * @return the traffic treatment builder - */ - private Builder noAction() { - return add(Instructions.createNoAction()); - } - - @Override - public Builder punt() { - return add(Instructions.createOutput(PortNumber.CONTROLLER)); - } - - @Override - public Builder setOutput(PortNumber number) { - return add(Instructions.createOutput(number)); - } - - @Override - public Builder setEthSrc(MacAddress addr) { - return add(Instructions.modL2Src(addr)); - } - - @Override - public Builder setEthDst(MacAddress addr) { - return add(Instructions.modL2Dst(addr)); - } - - @Override - public Builder setVlanId(VlanId id) { - return add(Instructions.modVlanId(id)); - } - - @Override - public Builder setVlanPcp(Byte pcp) { - return add(Instructions.modVlanPcp(pcp)); - } - - @Override - public Builder setIpSrc(IpAddress addr) { - return add(Instructions.modL3Src(addr)); - } - - @Override - public Builder setIpDst(IpAddress addr) { - return add(Instructions.modL3Dst(addr)); - } - - @Override - public Builder decNwTtl() { - return add(Instructions.decNwTtl()); - } - - @Override - public Builder copyTtlIn() { - return add(Instructions.copyTtlIn()); - } - - @Override - public Builder copyTtlOut() { - return add(Instructions.copyTtlOut()); - } - - @Override - public Builder pushMpls() { - return add(Instructions.pushMpls()); - } - - @Override - public Builder popMpls() { - return add(Instructions.popMpls()); - } - - @Override - public Builder popMpls(int etherType) { - return add(Instructions.popMpls(new EthType(etherType))); - } - - @Override - public Builder popMpls(EthType etherType) { - return add(Instructions.popMpls(etherType)); - } - - @Override - public Builder setMpls(MplsLabel mplsLabel) { - return add(Instructions.modMplsLabel(mplsLabel)); - } - - @Override - public Builder setMplsBos(boolean mplsBos) { - return add(Instructions.modMplsBos(mplsBos)); - } - - @Override - public Builder decMplsTtl() { - return add(Instructions.decMplsTtl()); - } - - @Deprecated - @Override - public Builder setLambda(short lambda) { - return add(Instructions.modL0Lambda(new IndexedLambda(lambda))); - } - - @Override - public Builder group(GroupId groupId) { - return add(Instructions.createGroup(groupId)); - } - - @Override - public Builder setQueue(long queueId) { - return add(Instructions.setQueue(queueId, null)); - } - - @Override - public Builder setQueue(long queueId, PortNumber port) { - return add(Instructions.setQueue(queueId, port)); - } - - @Override - public TrafficTreatment.Builder meter(MeterId meterId) { - return add(Instructions.meterTraffic(meterId)); - } - - @Override - public Builder popVlan() { - return add(Instructions.popVlan()); - } - - @Override - public Builder pushVlan() { - return add(Instructions.pushVlan()); - } - - @Override - public Builder transition(Integer tableId) { - return add(Instructions.transition(tableId)); - } - - @Override - public Builder immediate() { - current = immediate; - return this; - } - - @Override - public Builder deferred() { - current = deferred; - return this; - } - - @Override - public Builder wipeDeferred() { - clear = true; - return this; - } - - @Override - public Builder writeMetadata(long metadata, long metadataMask) { - return add(Instructions.writeMetadata(metadata, metadataMask)); - } - - @Override - public Builder setTunnelId(long tunnelId) { - return add(Instructions.modTunnelId(tunnelId)); - } - - @Deprecated - @Override - public TrafficTreatment.Builder setTcpSrc(short port) { - return setTcpSrc(TpPort.tpPort(port)); - } - - @Override - public TrafficTreatment.Builder setTcpSrc(TpPort port) { - return add(Instructions.modTcpSrc(port)); - } - - @Deprecated - @Override - public TrafficTreatment.Builder setTcpDst(short port) { - return setTcpDst(TpPort.tpPort(port)); - } - - @Override - public TrafficTreatment.Builder setTcpDst(TpPort port) { - return add(Instructions.modTcpDst(port)); - } - - @Deprecated - @Override - public TrafficTreatment.Builder setUdpSrc(short port) { - return setUdpSrc(TpPort.tpPort(port)); - } - - @Override - public TrafficTreatment.Builder setUdpSrc(TpPort port) { - return add(Instructions.modUdpSrc(port)); - } - - @Deprecated - @Override - public TrafficTreatment.Builder setUdpDst(short port) { - return setUdpDst(TpPort.tpPort(port)); - } - - @Override - public TrafficTreatment.Builder setUdpDst(TpPort port) { - return add(Instructions.modUdpDst(port)); - } - - @Override - public Builder setArpSpa(IpAddress addr) { - return add(Instructions.modArpSpa(addr)); - } - - @Override - public Builder setArpSha(MacAddress addr) { - return add(Instructions.modArpSha(addr)); - } - - @Override - public Builder setArpOp(short op) { - return add(Instructions.modL3ArpOp(op)); - } - - @Override - public TrafficTreatment.Builder extension(ExtensionTreatment extension, - DeviceId deviceId) { - return add(Instructions.extension(extension, deviceId)); - } - - @Override - public TrafficTreatment build() { - if (deferred.size() == 0 && immediate.size() == 0 - && table == null && !clear) { - immediate(); - noAction(); - } - return new DefaultTrafficTreatment(deferred, immediate, table, clear, meta, meter); - } - - } - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTypedFlowEntry.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTypedFlowEntry.java deleted file mode 100644 index afceb14e..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTypedFlowEntry.java +++ /dev/null @@ -1,122 +0,0 @@ -/*
- * 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;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Default flow entry class with FlowLiveType value, IMMEDIATE_FLOW, SHORT_FLOW, MID_FLOW, LONG_FLOW.
- */
-public class DefaultTypedFlowEntry extends DefaultFlowEntry
- implements TypedStoredFlowEntry {
- private FlowLiveType liveType;
-
- /**
- * Creates a typed flow entry from flow rule and its statistics, with default flow live type(IMMEDIATE_FLOW).
- *
- * @param rule the flow rule
- * @param state the flow state
- * @param life the flow duration since creation
- * @param packets the flow packets count
- * @param bytes the flow bytes count
- *
- */
- public DefaultTypedFlowEntry(FlowRule rule, FlowEntryState state,
- long life, long packets, long bytes) {
- super(rule, state, life, packets, bytes);
- this.liveType = FlowLiveType.IMMEDIATE_FLOW;
- }
-
- /**
- * Creates a typed flow entry from flow rule, with default flow live type(IMMEDIATE_FLOW).
- *
- * @param rule the flow rule
- *
- */
- public DefaultTypedFlowEntry(FlowRule rule) {
- super(rule);
- this.liveType = FlowLiveType.IMMEDIATE_FLOW;
- }
-
- /**
- * Creates a typed flow entry from flow entry, with default flow live type(IMMEDIATE_FLOW).
- *
- * @param fe the flow entry
- *
- */
- public DefaultTypedFlowEntry(FlowEntry fe) {
- super(fe, fe.state(), fe.life(), fe.packets(), fe.bytes());
- this.liveType = FlowLiveType.IMMEDIATE_FLOW;
- }
-
- /**
- * Creates a typed flow entry from flow rule and flow live type.
- *
- * @param rule the flow rule
- * @param liveType the flow live type
- *
- */
- public DefaultTypedFlowEntry(FlowRule rule, FlowLiveType liveType) {
- super(rule);
- this.liveType = liveType;
- }
-
- /**
- * Creates a typed flow entry from flow entry and flow live type.
- *
- * @param fe the flow rule
- * @param liveType the flow live type
- *
- */
- public DefaultTypedFlowEntry(FlowEntry fe, FlowLiveType liveType) {
- super(fe, fe.state(), fe.life(), fe.packets(), fe.bytes());
- this.liveType = liveType;
- }
-
- /**
- * Creates a typed flow entry from flow rule, error code and flow live type.
- *
- * @param rule the flow rule
- * @param errType the flow error type
- * @param errCode the flow error code
- * @param liveType the flow live type
- *
- */
- public DefaultTypedFlowEntry(FlowRule rule, int errType, int errCode, FlowLiveType liveType) {
- super(rule, errType, errCode);
- this.liveType = liveType;
- }
-
- @Override
- public FlowLiveType flowLiveType() {
- return this.liveType;
- }
-
- @Override
- public void setFlowLiveType(FlowLiveType liveType) {
- this.liveType = liveType;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("entry", super.toString())
- .add("type", liveType)
- .toString();
- }
-}
-
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/Extension.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/Extension.java deleted file mode 100644 index 1d61542e..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/Extension.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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; - -import org.onosproject.net.flow.instructions.ExtensionPropertyException; - -import java.util.List; - -/** - * An extension to the northbound APIs. - */ -public interface Extension { - - /** - * Sets a property on the extension. - * - * @param key property key - * @param value value to set for the given key - * @param <T> class of the value - * @throws ExtensionPropertyException if the given key is not a valid - * property on this extension - */ - <T> void setPropertyValue(String key, T value) throws ExtensionPropertyException; - - /** - * Gets a property value of an extension. - * - * @param key property key - * @param <T> class of the value - * @return value of the property - * @throws ExtensionPropertyException if the given key is not a valid - * property on this extension - */ - <T> T getPropertyValue(String key) throws ExtensionPropertyException; - - /** - * Gets a list of all properties on the extension. - * - * @return list of properties - */ - List<String> getProperties(); - - /** - * Serialize the extension to a byte array. - * - * @return byte array - */ - byte[] serialize(); - - /** - * Deserialize the extension from a byte array. The properties - * of this object will be overwritten with the data in the byte array. - * - * @param data input byte array - */ - void deserialize(byte[] data); -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowEntry.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowEntry.java deleted file mode 100644 index 389b2142..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowEntry.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2014 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; - - -/** - * Represents a generalized match & action pair to be applied to - * an infrastucture device. - */ -public interface FlowEntry extends FlowRule { - - - enum FlowEntryState { - - /** - * Indicates that this rule has been submitted for addition. - * Not necessarily in the flow table. - */ - PENDING_ADD, - - /** - * Rule has been added which means it is in the flow table. - */ - ADDED, - - /** - * Flow has been marked for removal, might still be in flow table. - */ - PENDING_REMOVE, - - /** - * Flow has been removed from flow table and can be purged. - */ - REMOVED, - - /** - * Indicates that the installation of this flow has failed. - */ - FAILED - } - - /** - * Returns the flow entry state. - * - * @return flow entry state - */ - FlowEntryState state(); - - /** - * Returns the number of milliseconds this flow rule has been applied. - * - * @return number of millis - */ - long life(); - - /** - * Returns the number of packets this flow rule has matched. - * - * @return number of packets - */ - long packets(); - - /** - * Returns the number of bytes this flow rule has matched. - * - * @return number of bytes - */ - long bytes(); - - // TODO: consider removing this attribute - /** - * When this flow entry was last deemed active. - * @return epoch time of last activity - */ - long lastSeen(); - - /** - * Indicates the error type. - * @return an integer value of the error - */ - int errType(); - - /** - * Indicates the error code. - * @return an integer value of the error - */ - int errCode(); - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowId.java deleted file mode 100644 index 52500f59..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowId.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2014 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; - -import com.google.common.base.Objects; - -/** - * Representation of a Flow ID. - */ -public final class FlowId { - - private final long flowid; - - private FlowId(long id) { - this.flowid = id; - } - - public static FlowId valueOf(long id) { - return new FlowId(id); - } - - public long value() { - return flowid; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (obj.getClass() == this.getClass()) { - FlowId that = (FlowId) obj; - return Objects.equal(this.flowid, that.flowid); - } - return false; - } - - @Override - public int hashCode() { - return Objects.hashCode(this.flowid); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java deleted file mode 100644 index 35d45fbd..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright 2014 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; - -import org.onosproject.core.ApplicationId; -import org.onosproject.core.GroupId; -import org.onosproject.net.DeviceId; - -/** - * Represents a generalized match & action pair to be applied to an - * infrastructure device. - */ -public interface FlowRule { - - int MAX_TIMEOUT = 60; - int MIN_PRIORITY = 0; - - /** - * Returns the ID of this flow. - * - * @return the flow ID - */ - FlowId id(); - - /** - * Returns the application id of this flow. - * - * @return an applicationId - */ - short appId(); - - /** - * Returns the group id of this flow. - * - * @return an groupId - */ - GroupId groupId(); - - /** - * Returns the flow rule priority given in natural order; higher numbers - * mean higher priorities. - * - * @return flow rule priority - */ - int priority(); - - /** - * Returns the identity of the device where this rule applies. - * - * @return device identifier - */ - DeviceId deviceId(); - - /** - * Returns the traffic selector that identifies what traffic this rule - * should apply to. - * - * @return traffic selector - */ - TrafficSelector selector(); - - /** - * Returns the traffic treatment that applies to selected traffic. - * - * @return traffic treatment - */ - TrafficTreatment treatment(); - - /** - * Returns the timeout for this flow requested by an application. - * - * @return integer value of the timeout - */ - int timeout(); - - /** - * Returns whether the flow is permanent i.e. does not time out. - * - * @return true if the flow is permanent, otherwise false - */ - boolean isPermanent(); - - /** - * Returns the table id for this rule. - * - * @return an integer. - */ - int tableId(); - - /** - * {@inheritDoc} - * - * Equality for flow rules only considers 'match equality'. This means that - * two flow rules with the same match conditions will be equal, regardless - * of the treatment or other characteristics of the flow. - * - * @param obj the reference object with which to compare. - * @return {@code true} if this object is the same as the obj - * argument; {@code false} otherwise. - */ - boolean equals(Object obj); - - /** - * Returns whether this flow rule is an exact match to the flow rule given - * in the argument. - * <p> - * Exact match means that deviceId, priority, selector, - * tableId, flowId and treatment are equal. Note that this differs from - * the notion of object equality for flow rules, which does not consider the - * flowId or treatment when testing equality. - * </p> - * - * @param rule other rule to match against - * @return true if the rules are an exact match, otherwise false - */ - boolean exactMatch(FlowRule rule); - - /** - * A flowrule builder. - */ - interface Builder { - - /** - * Assigns a cookie value to this flowrule. Mutually exclusive with the - * fromApp method. This method is intended to take a cookie value from - * the dataplane and not from the application. - * - * @param cookie a long value - * @return this - */ - Builder withCookie(long cookie); - - /** - * Assigns the application that built this flow rule to this object. - * The short value of the appId will be used as a basis for the - * cookie value computation. It is expected that application use this - * call to set their application id. - * - * @param appId an application id - * @return this - */ - Builder fromApp(ApplicationId appId); - - /** - * Sets the priority for this flow rule. - * - * @param priority an integer - * @return this - */ - Builder withPriority(int priority); - - /** - * Sets the deviceId for this flow rule. - * - * @param deviceId a device id - * @return this - */ - Builder forDevice(DeviceId deviceId); - - /** - * Sets the table id for this flow rule. Default value is 0. - * - * @param tableId an integer - * @return this - */ - Builder forTable(int tableId); - - /** - * Sets the selector (or match field) for this flow rule. - * - * @param selector a traffic selector - * @return this - */ - Builder withSelector(TrafficSelector selector); - - /** - * Sets the traffic treatment for this flow rule. - * - * @param treatment a traffic treatment - * @return this - */ - Builder withTreatment(TrafficTreatment treatment); - - /** - * Makes this rule permanent on the dataplane. - * - * @return this - */ - Builder makePermanent(); - - /** - * Makes this rule temporary and timeout after the specified amount - * of time. - * - * @param timeout an integer - * @return this - */ - Builder makeTemporary(int timeout); - - /** - * Builds a flow rule object. - * - * @return a flow rule. - */ - FlowRule build(); - - } - - /** - * Returns the third party original flow rule. - * - * @return FlowRuleExtPayLoad - */ - FlowRuleExtPayLoad payLoad(); -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleBatchEntry.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleBatchEntry.java deleted file mode 100644 index 455c6bd8..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleBatchEntry.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.flow; - -import org.onosproject.net.flow.FlowRuleBatchEntry.FlowRuleOperation; - -@Deprecated -/** - * @deprecated in Drake release - no longer a public API - */ -public class FlowRuleBatchEntry - extends BatchOperationEntry<FlowRuleOperation, FlowRule> { - - private final Long id; // FIXME: consider using Optional<Long> - - public FlowRuleBatchEntry(FlowRuleOperation operator, FlowRule target) { - super(operator, target); - this.id = null; - } - - public FlowRuleBatchEntry(FlowRuleOperation operator, FlowRule target, Long id) { - super(operator, target); - this.id = id; - } - - public Long id() { - return id; - } - - public enum FlowRuleOperation { - ADD, - REMOVE, - MODIFY - } - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleBatchEvent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleBatchEvent.java deleted file mode 100644 index 2e823c23..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleBatchEvent.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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.flow; - -import org.onosproject.event.AbstractEvent; -import org.onosproject.net.DeviceId; - -@Deprecated -/** - * Describes flow rule batch event. - * - * @deprecated in Drake release - no longer a public API - */ -public final class FlowRuleBatchEvent extends AbstractEvent<FlowRuleBatchEvent.Type, FlowRuleBatchRequest> { - - - /** - * Type of flow rule events. - */ - public enum Type { - - // Request has been forwarded to MASTER Node - /** - * Signifies that a batch operation has been initiated. - */ - BATCH_OPERATION_REQUESTED, - - // MASTER Node has pushed the batch down to the Device - // (e.g., Received barrier reply) - /** - * Signifies that a batch operation has completed. - */ - BATCH_OPERATION_COMPLETED, - } - - private final CompletedBatchOperation result; - private final DeviceId deviceId; - - /** - * Constructs a new FlowRuleBatchEvent. - * - * @param request batch operation request - * @param deviceId the device this batch will be processed on - * @return event. - */ - public static FlowRuleBatchEvent requested(FlowRuleBatchRequest request, DeviceId deviceId) { - FlowRuleBatchEvent event = new FlowRuleBatchEvent(Type.BATCH_OPERATION_REQUESTED, request, deviceId); - return event; - } - - /** - * Constructs a new FlowRuleBatchEvent. - * @param request batch operation request. - * @param result completed batch operation result. - * @return event. - */ - public static FlowRuleBatchEvent completed(FlowRuleBatchRequest request, CompletedBatchOperation result) { - FlowRuleBatchEvent event = new FlowRuleBatchEvent(Type.BATCH_OPERATION_COMPLETED, request, result); - return event; - } - - /** - * Returns the result of this batch operation. - * @return batch operation result. - */ - public CompletedBatchOperation result() { - return result; - } - - /** - * Returns the deviceId for this batch. - * @return device id - */ - public DeviceId deviceId() { - return deviceId; - } - - /** - * Creates an event of a given type and for the specified flow rule batch. - * - * @param type flow rule batch event type - * @param request event flow rule batch subject - * @param result the result of the batch operation - */ - private FlowRuleBatchEvent(Type type, FlowRuleBatchRequest request, CompletedBatchOperation result) { - super(type, request); - this.result = result; - this.deviceId = result.deviceId(); - } - - /** - * Creates an event of a given type and for the specified flow rule batch. - * - * @param type flow rule batch event type - * @param request event flow rule batch subject - * @param deviceId the device id for this batch - */ - private FlowRuleBatchEvent(Type type, FlowRuleBatchRequest request, DeviceId deviceId) { - super(type, request); - this.result = null; - this.deviceId = deviceId; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleBatchOperation.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleBatchOperation.java deleted file mode 100644 index 35428f46..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleBatchOperation.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.flow; - -import org.onosproject.net.DeviceId; - -import java.util.Collection; - -@Deprecated -/** - * Class used with the flow subsystem to process per device - * batches. - * - * @deprecated in Drake release - no longer a public API - */ -public class FlowRuleBatchOperation - extends BatchOperation<FlowRuleBatchEntry> { - - /** - * This id is used to cary to id of the original - * FlowOperations and track where this batch operation - * came from. The id is unique cluster wide. - */ - private final long id; - private final DeviceId deviceId; - - public FlowRuleBatchOperation(Collection<FlowRuleBatchEntry> operations, - DeviceId deviceId, long flowOperationId) { - super(operations); - this.id = flowOperationId; - this.deviceId = deviceId; - } - - public DeviceId deviceId() { - return this.deviceId; - } - - public long id() { - return id; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleBatchRequest.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleBatchRequest.java deleted file mode 100644 index 0b0585b9..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleBatchRequest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.flow; - -import com.google.common.collect.Lists; -import org.onosproject.net.DeviceId; - -import java.util.Collections; -import java.util.List; -import java.util.Set; - -@Deprecated -/** - * @deprecated in Drake release - no longer a public API - */ -public class FlowRuleBatchRequest { - - /** - * This id is used to carry to id of the original - * FlowOperations and track where this batch operation - * came from. The id is unique cluster wide. - */ - private final long batchId; - - private final Set<FlowRuleBatchEntry> ops; - - - public FlowRuleBatchRequest(long batchId, Set<FlowRuleBatchEntry> ops) { - this.batchId = batchId; - this.ops = Collections.unmodifiableSet(ops); - } - - public Set<FlowRuleBatchEntry> ops() { - return ops; - } - - public FlowRuleBatchOperation asBatchOperation(DeviceId deviceId) { - List<FlowRuleBatchEntry> entries = Lists.newArrayList(); - entries.addAll(ops); - return new FlowRuleBatchOperation(entries, deviceId, batchId); - } - - public long batchId() { - return batchId; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleEvent.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleEvent.java deleted file mode 100644 index 41ef1c8a..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleEvent.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2014 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; - -import org.onosproject.event.AbstractEvent; - -/** - * Describes flow rule event. - */ -public class FlowRuleEvent extends AbstractEvent<FlowRuleEvent.Type, FlowRule> { - - /** - * Type of flow rule events. - */ - public enum Type { - /** - * Signifies that a new flow rule has been detected. - */ - RULE_ADDED, - - /** - * Signifies that a flow rule has been removed. - */ - RULE_REMOVED, - - /** - * Signifies that a rule has been updated. - */ - RULE_UPDATED, - - // internal event between Manager <-> Store - - /* - * Signifies that a request to add flow rule has been added to the store. - */ - RULE_ADD_REQUESTED, - /* - * Signifies that a request to remove flow rule has been added to the store. - */ - RULE_REMOVE_REQUESTED, - } - - /** - * Creates an event of a given type and for the specified flow rule and the - * current time. - * - * @param type flow rule event type - * @param flowRule event flow rule subject - */ - public FlowRuleEvent(Type type, FlowRule flowRule) { - super(type, flowRule); - } - - /** - * Creates an event of a given type and for the specified flow rule and time. - * - * @param type flow rule event type - * @param flowRule event flow rule subject - * @param time occurrence time - */ - public FlowRuleEvent(Type type, FlowRule flowRule, long time) { - super(type, flowRule, time); - } - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleExtPayLoad.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleExtPayLoad.java deleted file mode 100644 index d4d2d9ec..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleExtPayLoad.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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; - -import static com.google.common.base.MoreObjects.toStringHelper; - -import java.util.Arrays; - -/** - * Represents for 3rd-party private original flow. - */ -public final class FlowRuleExtPayLoad { - private final byte[] payLoad; - - /** - * private constructor. - * - * @param payLoad private flow - */ - private FlowRuleExtPayLoad(byte[] payLoad) { - this.payLoad = payLoad; - } - - /** - * Creates a FlowRuleExtPayLoad. - * - * @param payLoad payload byte data - * @return FlowRuleExtPayLoad payLoad - */ - public static FlowRuleExtPayLoad flowRuleExtPayLoad(byte[] payLoad) { - return new FlowRuleExtPayLoad(payLoad); - } - - /** - * Returns private flow. - * - * @return payLoad private flow - */ - public byte[] payLoad() { - return payLoad; - } - - @Override - public int hashCode() { - return Arrays.hashCode(payLoad); - } - - public int hash() { - return Arrays.hashCode(payLoad); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof FlowRuleExtPayLoad) { - FlowRuleExtPayLoad that = (FlowRuleExtPayLoad) obj; - return Arrays.equals(payLoad, that.payLoad); - - } - return false; - } - - @Override - public String toString() { - return toStringHelper(this).add("payLoad", payLoad).toString(); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleListener.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleListener.java deleted file mode 100644 index 1a6ef7d9..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleListener.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2014 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; - -import org.onosproject.event.EventListener; - -/** - * Entity capable of receiving flow rule related events. - */ -public interface FlowRuleListener extends EventListener<FlowRuleEvent> { -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleOperation.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleOperation.java deleted file mode 100644 index 82d43be8..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleOperation.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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; - -import com.google.common.base.MoreObjects; - -/** - * Representation of an operation on a flow rule table. - */ -public class FlowRuleOperation { - - /** - * Type of flow table operations. - */ - public enum Type { - ADD, - MODIFY, - REMOVE - } - - private final FlowRule rule; - private final Type type; - - public FlowRuleOperation(FlowRule rule, Type type) { - this.rule = rule; - this.type = type; - } - - /** - * Returns the type of operation. - * - * @return type - */ - public Type type() { - return type; - } - - /** - * Returns the flow rule. - * - * @return flow rule - */ - public FlowRule rule() { - return rule; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("rule", rule) - .add("type", type) - .toString(); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleOperations.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleOperations.java deleted file mode 100644 index 84e0b8be..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleOperations.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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; - -import com.google.common.base.MoreObjects; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; - -import java.util.List; -import java.util.Set; - -import static org.onosproject.net.flow.FlowRuleOperation.Type.*; - -/** - * A batch of flow rule operations that are broken into stages. - * TODO move this up to parent's package - */ -public class FlowRuleOperations { - - private final List<Set<FlowRuleOperation>> stages; - private final FlowRuleOperationsContext callback; // TODO consider Optional - - private FlowRuleOperations(List<Set<FlowRuleOperation>> stages, - FlowRuleOperationsContext cb) { - this.stages = stages; - this.callback = cb; - } - - // kryo-constructor - protected FlowRuleOperations() { - this.stages = Lists.newArrayList(); - this.callback = null; - } - - /** - * Returns the flow rule operations as sets of stages that should be - * executed sequentially. - * - * @return flow rule stages - */ - public List<Set<FlowRuleOperation>> stages() { - return stages; - } - - /** - * Returns the callback for this batch of operations. - * - * @return callback - */ - public FlowRuleOperationsContext callback() { - return callback; - } - - /** - * Returns a new builder. - * - * @return new builder - */ - public static Builder builder() { - return new Builder(); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("stages", stages) - .toString(); - } - - /** - * A builder for constructing flow rule operations. - */ - public static final class Builder { - - private final ImmutableList.Builder<Set<FlowRuleOperation>> listBuilder = ImmutableList.builder(); - private ImmutableSet.Builder<FlowRuleOperation> currentStage = ImmutableSet.builder(); - - // prevent use of the default constructor outside of this file; use the above method - private Builder() {} - - /** - * Appends a flow rule add to the current stage. - * - * @param flowRule flow rule - * @return this - */ - public Builder add(FlowRule flowRule) { - currentStage.add(new FlowRuleOperation(flowRule, ADD)); - return this; - } - - /** - * Appends an existing flow rule to the current stage. - * - * @param flowRuleOperation flow rule operation - * @return this - */ - public Builder operation(FlowRuleOperation flowRuleOperation) { - currentStage.add(flowRuleOperation); - return this; - } - - /** - * Appends a flow rule modify to the current stage. - * - * @param flowRule flow rule - * @return this - */ - public Builder modify(FlowRule flowRule) { - currentStage.add(new FlowRuleOperation(flowRule, MODIFY)); - return this; - } - - /** - * Appends a flow rule remove to the current stage. - * - * @param flowRule flow rule - * @return this - */ - // FIXME this is confusing, consider renaming - public Builder remove(FlowRule flowRule) { - currentStage.add(new FlowRuleOperation(flowRule, REMOVE)); - return this; - } - - /** - * Closes the current stage. - */ - private void closeStage() { - ImmutableSet<FlowRuleOperation> stage = currentStage.build(); - if (!stage.isEmpty()) { - listBuilder.add(stage); - } - } - - /** - * Closes the current stage and starts a new one. - * - * @return this - */ - public Builder newStage() { - closeStage(); - currentStage = ImmutableSet.builder(); - return this; - } - - /** - * Builds the immutable flow rule operations. - * - * @return flow rule operations - */ - public FlowRuleOperations build() { - return build(null); - } - - /** - * Builds the immutable flow rule operations. - * - * @param cb the callback to call when this operation completes - * @return flow rule operations - */ - public FlowRuleOperations build(FlowRuleOperationsContext cb) { - closeStage(); - return new FlowRuleOperations(listBuilder.build(), cb); - } - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleOperationsContext.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleOperationsContext.java deleted file mode 100644 index c405b129..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleOperationsContext.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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; - -/** - * The context of a flow rule operations that will become the subject of - * the notification. - * - * Implementations of this class must be serializable. - */ -public interface FlowRuleOperationsContext { - // TODO we might also want to execute a method on behalf of the app - default void onSuccess(FlowRuleOperations ops){} - default void onError(FlowRuleOperations ops){} -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleProvider.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleProvider.java deleted file mode 100644 index ac2895eb..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleProvider.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.flow; - -import org.onosproject.core.ApplicationId; -import org.onosproject.net.provider.Provider; - -/** - * Abstraction of a flow rule provider. - */ -public interface FlowRuleProvider extends Provider { - - /** - * Instructs the provider to apply the specified flow rules to their - * respective devices. - * @param flowRules one or more flow rules - * throws SomeKindOfException that indicates which ones were applied and - * which ones failed - */ - void applyFlowRule(FlowRule... flowRules); - - /** - * Instructs the provider to remove the specified flow rules to their - * respective devices. - * @param flowRules one or more flow rules - * throws SomeKindOfException that indicates which ones were applied and - * which ones failed - */ - void removeFlowRule(FlowRule... flowRules); - - /** - * Removes rules by their id. - * @param id the id to remove - * @param flowRules one or more flow rules - */ - void removeRulesById(ApplicationId id, FlowRule... flowRules); - - /** - * Installs a batch of flow rules. Each flowrule is associated to an - * operation which results in either addition, removal or modification. - * @param batch a batch of flow rules - */ - void executeBatch(FlowRuleBatchOperation batch); - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleProviderRegistry.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleProviderRegistry.java deleted file mode 100644 index 7e317c01..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleProviderRegistry.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2014 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; - -import org.onosproject.net.provider.ProviderRegistry; - -/** - * Abstraction for a flow rule provider registry. - */ -public interface FlowRuleProviderRegistry - extends ProviderRegistry<FlowRuleProvider, FlowRuleProviderService> { -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleProviderService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleProviderService.java deleted file mode 100644 index aefa96b4..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleProviderService.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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.flow; - -import java.util.List; - -import org.onosproject.net.DeviceId; -import org.onosproject.net.provider.ProviderService; - -/** - * Service through which flow rule providers can inject information into - * the core. - */ -public interface FlowRuleProviderService extends ProviderService<FlowRuleProvider> { - - /** - * Signals that a flow rule that was previously installed has been removed. - * - * @param flowEntry removed flow entry - */ - void flowRemoved(FlowEntry flowEntry); - - /** - * Pushes the collection of flow entries currently applied on the given - * device. - * - * @param deviceId device identifier - * @param flowEntries collection of flow rules - */ - void pushFlowMetrics(DeviceId deviceId, Iterable<FlowEntry> flowEntries); - - /** - * Pushes the collection of flow entries currently applied on the given - * device without flowMissing process. - * - * @param deviceId device identifier - * @param flowEntries collection of flow rules - */ - void pushFlowMetricsWithoutFlowMissing(DeviceId deviceId, Iterable<FlowEntry> flowEntries); - - /** - * Pushes the collection of table statistics entries currently extracted - * from the given device. - * - * @param deviceId device identifier - * @param tableStatsEntries collection of flow table statistics entries - */ - void pushTableStatistics(DeviceId deviceId, List<TableStatisticsEntry> tableStatsEntries); - - /** - * Indicates to the core that the requested batch operation has - * been completed. - * - * @param batchId the batch which was processed - * @param operation the resulting outcome of the operation - */ - void batchOperationCompleted(long batchId, CompletedBatchOperation operation); -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java deleted file mode 100644 index ee8d5a98..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleService.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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.flow; - -import org.onosproject.core.ApplicationId; -import org.onosproject.event.ListenerService; -import org.onosproject.net.DeviceId; - -/** - * Service for injecting flow rules into the environment and for obtaining - * information about flow rules already in the environment. This implements - * semantics of a distributed authoritative flow table where the master copy - * of the flow rules lies with the controller and the devices hold only the - * 'cached' copy. - */ -public interface FlowRuleService - extends ListenerService<FlowRuleEvent, FlowRuleListener> { - - /** - * The topic used for obtaining globally unique ids. - */ - String FLOW_OP_TOPIC = "flow-ops-ids"; - - /** - * Returns the number of flow rules in the system. - * - * @return flow rule count - */ - int getFlowRuleCount(); - - /** - * Returns the collection of flow entries applied on the specified device. - * This will include flow rules which may not yet have been applied to - * the device. - * - * @param deviceId device identifier - * @return collection of flow rules - */ - Iterable<FlowEntry> getFlowEntries(DeviceId deviceId); - - // TODO: add createFlowRule factory method and execute operations method - - /** - * Applies the specified flow rules onto their respective devices. These - * flow rules will be retained by the system and re-applied anytime the - * device reconnects to the controller. - * - * @param flowRules one or more flow rules - */ - void applyFlowRules(FlowRule... flowRules); - - /** - * Removes the specified flow rules from their respective devices. If the - * device is not presently connected to the controller, these flow will - * be removed once the device reconnects. - * - * @param flowRules one or more flow rules - * throws SomeKindOfException that indicates which ones were removed and - * which ones failed - */ - void removeFlowRules(FlowRule... flowRules); - - /** - * Removes all rules by id. - * - * @param appId id to remove - */ - void removeFlowRulesById(ApplicationId appId); - - /** - * Returns a list of rules with this application id. - * - * @param id the id to look up - * @return collection of flow rules - */ - Iterable<FlowRule> getFlowRulesById(ApplicationId id); - - /** - * Returns a list of rules filterd by application and group id. - * - * @param appId the application id to lookup - * @param groupId the groupid to lookup - * @return collection of flow rules - */ - Iterable<FlowRule> getFlowRulesByGroupId(ApplicationId appId, short groupId); - - /** - * Applies a batch operation of FlowRules. - * - * @param ops batch operation to apply - */ - void apply(FlowRuleOperations ops); - - /** - * Returns the collection of flow table statistics of the specified device. - * - * @param deviceId device identifier - * @return collection of flow table statistics - */ - Iterable<TableStatisticsEntry> getFlowTableStatistics(DeviceId deviceId); -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleStore.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleStore.java deleted file mode 100644 index d81c73c9..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleStore.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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.flow; - -import java.util.List; - -import org.onosproject.net.DeviceId; -import org.onosproject.store.Store; - -/** - * Manages inventory of flow rules; not intended for direct use. - */ -public interface FlowRuleStore extends Store<FlowRuleBatchEvent, FlowRuleStoreDelegate> { - - /** - * Returns the number of flow rule in the store. - * - * @return number of flow rules - */ - int getFlowRuleCount(); - - /** - * Returns the stored flow. - * - * @param rule the rule to look for - * @return a flow rule - */ - FlowEntry getFlowEntry(FlowRule rule); - - /** - * Returns the flow entries associated with a device. - * - * @param deviceId the device ID - * @return the flow entries - */ - Iterable<FlowEntry> getFlowEntries(DeviceId deviceId); - - /** - * // TODO: Better description of method behavior. - * Stores a new flow rule without generating events. - * - * @param rule the flow rule to add - * @deprecated in Cardinal Release - */ - @Deprecated - void storeFlowRule(FlowRule rule); - - /** - * Stores a batch of flow rules. - * - * @param batchOperation batch of flow rules. - * A batch can contain flow rules for a single device only. - * - */ - void storeBatch(FlowRuleBatchOperation batchOperation); - - /** - * Invoked on the completion of a storeBatch operation. - * - * @param event flow rule batch event - */ - void batchOperationComplete(FlowRuleBatchEvent event); - - /** - * Marks a flow rule for deletion. Actual deletion will occur - * when the provider indicates that the flow has been removed. - * - * @param rule the flow rule to delete - */ - void deleteFlowRule(FlowRule rule); - - /** - * Stores a new flow rule, or updates an existing entry. - * - * @param rule the flow rule to add or update - * @return flow_added event, or null if just an update - */ - FlowRuleEvent addOrUpdateFlowRule(FlowEntry rule); - - /** - * @param rule the flow entry to remove - * @return flow_removed event, or null if nothing removed - */ - FlowRuleEvent removeFlowRule(FlowEntry rule); - - /** - * Updates the flow table statistics of the specified device using - * the given statistics. - * - * @param deviceId device identifier - * @param tableStats list of table statistics - * @return ready to send event describing what occurred; - */ - FlowRuleEvent updateTableStatistics(DeviceId deviceId, - List<TableStatisticsEntry> tableStats); - - /** - * Returns the flow table statistics associated with a device. - * - * @param deviceId the device ID - * @return the flow table statistics - */ - Iterable<TableStatisticsEntry> getTableStatistics(DeviceId deviceId); -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleStoreDelegate.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleStoreDelegate.java deleted file mode 100644 index c4ddb129..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/FlowRuleStoreDelegate.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2014 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; - -import org.onosproject.store.StoreDelegate; - -/** - * Flow rule store delegate abstraction. - */ -public interface FlowRuleStoreDelegate extends StoreDelegate<FlowRuleBatchEvent> { -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/StoredFlowEntry.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/StoredFlowEntry.java deleted file mode 100644 index dc0c3395..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/StoredFlowEntry.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2014 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; - - -public interface StoredFlowEntry extends FlowEntry { - - /** - * Sets the last active epoch time. - */ - void setLastSeen(); - - /** - * Sets the new state for this entry. - * @param newState new flow entry state. - */ - void setState(FlowEntryState newState); - - /** - * Sets how long this entry has been entered in the system. - * @param life epoch time - */ - void setLife(long life); - - /** - * Number of packets seen by this entry. - * @param packets a long value - */ - void setPackets(long packets); - - /** - * Number of bytes seen by this rule. - * @param bytes a long value - */ - void setBytes(long bytes); - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TableStatisticsEntry.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TableStatisticsEntry.java deleted file mode 100644 index 563f31ce..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TableStatisticsEntry.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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; - -import org.onosproject.net.DeviceId; - -/** - * Interface for flow table statistics of a device. - */ -public interface TableStatisticsEntry { - - /** - * Returns the device Id. - * - * @return device id - */ - DeviceId deviceId(); - - /** - * Returns the table number. - * - * @return table number - */ - int tableId(); - - /** - * Returns the number of active flow entries in this table. - * - * @return the number of active flow entries - */ - long activeFlowEntries(); - - /** - * Returns the number of packets looked up in the table. - * - * @return the number of packets looked up in the table - */ - long packetsLookedup(); - - /** - * Returns the number of packets that successfully matched in the table. - * - * @return the number of packets that successfully matched in the table - */ - long packetsMatched(); -} 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 deleted file mode 100644 index 0d055add..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java +++ /dev/null @@ -1,447 +0,0 @@ -/* - * 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.flow; - -import org.onlab.packet.Ip4Address; -import org.onlab.packet.Ip6Address; -import org.onlab.packet.IpPrefix; -import org.onlab.packet.MacAddress; -import org.onlab.packet.MplsLabel; -import org.onlab.packet.TpPort; -import org.onlab.packet.VlanId; -import org.onosproject.net.DeviceId; -import org.onosproject.net.PortNumber; -import org.onosproject.net.flow.criteria.Criterion; -import org.onosproject.net.flow.criteria.ExtensionSelector; - -import java.util.Set; - -/** - * Abstraction of a slice of network traffic. - */ -public interface TrafficSelector { - - /** - * Returns selection criteria as an ordered list. - * - * @return list of criteria - */ - Set<Criterion> criteria(); - - /** - * Returns the selection criterion for a particular type, if it exists in - * this traffic selector. - * - * @param type criterion type to look up - * @return the criterion of the specified type if one exists, otherwise null - */ - Criterion getCriterion(Criterion.Type type); - - /** - * Builder of traffic selector entities. - */ - interface Builder { - - /** - * Adds a traffic selection criterion. If a same type criterion has - * already been added, it will be replaced by this one. - * - * @param criterion new criterion - * @return self - */ - Builder add(Criterion criterion); - - /** - * Matches an inport. - * - * @param port the inport - * @return a selection builder - */ - Builder matchInPort(PortNumber port); - - /** - * Matches a physical inport. - * - * @param port the physical inport - * @return a selection builder - */ - Builder matchInPhyPort(PortNumber port); - - /** - * Matches a metadata. - * - * @param metadata the metadata - * @return a selection builder - */ - Builder matchMetadata(long metadata); - - /** - * Matches a l2 dst address. - * - * @param addr a l2 address - * @return a selection builder - */ - Builder matchEthDst(MacAddress addr); - - /** - * Matches a l2 src address. - * - * @param addr a l2 address - * @return a selection builder - */ - Builder matchEthSrc(MacAddress addr); - - /** - * Matches the ethernet type. - * - * @param ethType an ethernet type - * @return a selection builder - */ - Builder matchEthType(short ethType); - - /** - * Matches the vlan id. - * - * @param vlanId a vlan id - * @return a selection builder - */ - Builder matchVlanId(VlanId vlanId); - - /** - * Matches a vlan priority. - * - * @param vlanPcp a vlan priority - * @return a selection builder - */ - Builder matchVlanPcp(byte vlanPcp); - - /** - * Matches an IP DSCP (6 bits in ToS field). - * - * @param ipDscp an IP DSCP value - * @return a selection builder - */ - Builder matchIPDscp(byte ipDscp); - - /** - * Matches an IP ECN (2 bits in ToS field). - * - * @param ipEcn an IP ECN value - * @return a selection builder - */ - Builder matchIPEcn(byte ipEcn); - - /** - * Matches the l3 protocol. - * - * @param proto a l3 protocol - * @return a selection builder - */ - Builder matchIPProtocol(byte proto); - - /** - * Matches a l3 IPv4 address. - * - * @param ip a l3 address - * @return a selection builder - */ - Builder matchIPSrc(IpPrefix ip); - - /** - * Matches a l3 IPv4 address. - * - * @param ip a l3 address - * @return a selection builder - */ - Builder matchIPDst(IpPrefix ip); - - /** - * Matches a TCP source port number. - * - * @param tcpPort a TCP source port number - * @return a selection builder - * @deprecated in Drake release - */ - @Deprecated - Builder matchTcpSrc(short tcpPort); - - /** - * Matches a TCP source port number. - * - * @param tcpPort a TCP source port number - * @return a selection builder - */ - Builder matchTcpSrc(TpPort tcpPort); - - /** - * Matches a TCP destination port number. - * - * @param tcpPort a TCP destination port number - * @return a selection builder - * @deprecated in Drake release - */ - @Deprecated - Builder matchTcpDst(short tcpPort); - - /** - * Matches a TCP destination port number. - * - * @param tcpPort a TCP destination port number - * @return a selection builder - */ - Builder matchTcpDst(TpPort tcpPort); - - /** - * Matches an UDP source port number. - * - * @param udpPort an UDP source port number - * @return a selection builder - * @deprecated in Drake release - */ - @Deprecated - Builder matchUdpSrc(short udpPort); - - /** - * Matches an UDP source port number. - * - * @param udpPort an UDP source port number - * @return a selection builder - */ - Builder matchUdpSrc(TpPort udpPort); - - /** - * Matches an UDP destination port number. - * - * @param udpPort an UDP destination port number - * @return a selection builder - * @deprecated in Drake release - */ - @Deprecated - Builder matchUdpDst(short udpPort); - - /** - * Matches an UDP destination port number. - * - * @param udpPort an UDP destination port number - * @return a selection builder - */ - Builder matchUdpDst(TpPort udpPort); - - /** - * Matches a SCTP source port number. - * - * @param sctpPort a SCTP source port number - * @return a selection builder - * @deprecated in Drake release - */ - @Deprecated - Builder matchSctpSrc(short sctpPort); - - /** - * Matches a SCTP source port number. - * - * @param sctpPort a SCTP source port number - * @return a selection builder - */ - Builder matchSctpSrc(TpPort sctpPort); - - /** - * Matches a SCTP destination port number. - * - * @param sctpPort a SCTP destination port number - * @return a selection builder - * @deprecated in Drake release - */ - @Deprecated - Builder matchSctpDst(short sctpPort); - - /** - * Matches a SCTP destination port number. - * - * @param sctpPort a SCTP destination port number - * @return a selection builder - */ - Builder matchSctpDst(TpPort sctpPort); - - /** - * Matches an ICMP type. - * - * @param icmpType an ICMP type - * @return a selection builder - */ - Builder matchIcmpType(byte icmpType); - - /** - * Matches an ICMP code. - * - * @param icmpCode an ICMP code - * @return a selection builder - */ - Builder matchIcmpCode(byte icmpCode); - - /** - * Matches a l3 IPv6 address. - * - * @param ip a l3 IPv6 address - * @return a selection builder - */ - Builder matchIPv6Src(IpPrefix ip); - - /** - * Matches a l3 IPv6 address. - * - * @param ip a l3 IPv6 address - * @return a selection builder - */ - Builder matchIPv6Dst(IpPrefix ip); - - /** - * Matches an IPv6 flow label. - * - * @param flowLabel an IPv6 flow label - * @return a selection builder - */ - Builder matchIPv6FlowLabel(int flowLabel); - - /** - * Matches an ICMPv6 type. - * - * @param icmpv6Type an ICMPv6 type - * @return a selection builder - */ - Builder matchIcmpv6Type(byte icmpv6Type); - - /** - * Matches an ICMPv6 code. - * - * @param icmpv6Code an ICMPv6 code - * @return a selection builder - */ - Builder matchIcmpv6Code(byte icmpv6Code); - - /** - * Matches an IPv6 Neighbor Discovery target address. - * - * @param targetAddress an IPv6 Neighbor Discovery target address - * @return a selection builder - */ - Builder matchIPv6NDTargetAddress(Ip6Address targetAddress); - - /** - * Matches an IPv6 Neighbor Discovery source link-layer address. - * - * @param mac an IPv6 Neighbor Discovery source link-layer address - * @return a selection builder - */ - Builder matchIPv6NDSourceLinkLayerAddress(MacAddress mac); - - /** - * Matches an IPv6 Neighbor Discovery target link-layer address. - * - * @param mac an IPv6 Neighbor Discovery target link-layer address - * @return a selection builder - */ - Builder matchIPv6NDTargetLinkLayerAddress(MacAddress mac); - - /** - * Matches on a MPLS label. - * - * @param mplsLabel a MPLS label. - * @return a selection builder - */ - Builder matchMplsLabel(MplsLabel mplsLabel); - - /** - * Matches on a MPLS Bottom-of-Stack indicator bit. - * - * @param mplsBos boolean value indicating BOS=1 (true) or BOS=0 (false). - * @return a selection builder - */ - Builder matchMplsBos(boolean mplsBos); - - /** - * Matches a tunnel id. - * - * @param tunnelId a tunnel id - * @return a selection builder - */ - Builder matchTunnelId(long tunnelId); - - /** - * Matches on IPv6 Extension Header pseudo-field flags. - * - * @param exthdrFlags the IPv6 Extension Header pseudo-field flags - * @return a selection builder - */ - Builder matchIPv6ExthdrFlags(short exthdrFlags); - - /** - * Matches a arp IPv4 destination address. - * - * @param addr a arp IPv4 destination address - * @return a selection builder - */ - Builder matchArpTpa(Ip4Address addr); - - /** - * Matches a arp IPv4 source address. - * - * @param addr a arp IPv4 source address - * @return a selection builder - */ - Builder matchArpSpa(Ip4Address addr); - - /** - * Matches a arp_eth_dst address. - * - * @param addr a arp_eth_dst address - * @return a selection builder - */ - Builder matchArpTha(MacAddress addr); - - /** - * Matches a arp_eth_src address. - * - * @param addr a arp_eth_src address - * @return a selection builder - */ - Builder matchArpSha(MacAddress addr); - - /** - * Matches a arp operation type. - * - * @param arpOp a arp operation type - * @return a selection builder - */ - Builder matchArpOp(int arpOp); - - /** - * Uses an extension selector. - * - * @param extensionSelector extension selector - * @param deviceId device ID - * @return a selection builder - */ - Builder extension(ExtensionSelector extensionSelector, DeviceId deviceId); - - /** - * Builds an immutable traffic selector. - * - * @return traffic selector - */ - TrafficSelector build(); - } -} 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 deleted file mode 100644 index 3e57925d..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java +++ /dev/null @@ -1,473 +0,0 @@ -/* - * 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.flow; - -import java.util.List; - -import org.onlab.packet.EthType; -import org.onlab.packet.IpAddress; -import org.onlab.packet.MacAddress; -import org.onlab.packet.MplsLabel; -import org.onlab.packet.TpPort; -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.ExtensionTreatment; -import org.onosproject.net.flow.instructions.Instruction; -import org.onosproject.net.flow.instructions.Instructions; -import org.onosproject.net.meter.MeterId; - -/** - * Abstraction of network traffic treatment. - */ -public interface TrafficTreatment { - - /** - * Returns the list of treatment instructions that will be applied - * further down the pipeline. - * @return list of treatment instructions - */ - List<Instruction> deferred(); - - /** - * Returns the list of treatment instructions that will be applied - * immediately. - * @return list of treatment instructions - */ - List<Instruction> immediate(); - - /** - * Returns the list of all instructions in the treatment, both immediate and - * deferred. - * - * @return list of treatment instructions - */ - List<Instruction> allInstructions(); - - /** - * Returns the next table in the pipeline. - * @return a table transition; may be null. - */ - Instructions.TableTypeTransition tableTransition(); - - /** - * Whether the deferred treatment instructions will be cleared - * by the device. - * @return a boolean - */ - boolean clearedDeferred(); - - /** - * Returns the metadata instruction if there is one. - * - * @return a metadata instruction that may be null - */ - Instructions.MetadataInstruction writeMetadata(); - - /** - * Returns the meter instruction if there is one. - * - * @return a meter instruction that may be null - */ - Instructions.MeterInstruction metered(); - - /** - * Builder of traffic treatment entities. - */ - interface Builder { - - /** - * Adds an instruction to the builder. - * - * @param instruction an instruction - * @return a treatment builder - */ - Builder add(Instruction instruction); - - /** - * Adds a drop instruction. - * - * @return a treatment builder - */ - Builder drop(); - - /** - * Adds a punt-to-controller instruction. - * - * @return a treatment builder - */ - Builder punt(); - - /** - * Set the output port. - * - * @param number the out port - * @return a treatment builder - */ - Builder setOutput(PortNumber number); - - /** - * Sets the src l2 address. - * - * @param addr a macaddress - * @return a treatment builder - */ - Builder setEthSrc(MacAddress addr); - - /** - * Sets the dst l2 address. - * - * @param addr a macaddress - * @return a treatment builder - */ - Builder setEthDst(MacAddress addr); - - /** - * Sets the vlan id. - * - * @param id a vlanid - * @return a treatment builder - */ - Builder setVlanId(VlanId id); - - /** - * Sets the vlan priority. - * - * @param pcp a vlan priority - * @return a treatment builder - */ - Builder setVlanPcp(Byte pcp); - - /** - * Sets the src l3 address. - * - * @param addr an ip - * @return a treatment builder - */ - Builder setIpSrc(IpAddress addr); - - /** - * Sets the dst l3 address. - * - * @param addr an ip - * @return a treatment builder - */ - Builder setIpDst(IpAddress addr); - - /** - * Decrement the TTL in IP header by one. - * - * @return a treatment builder - */ - Builder decNwTtl(); - - /** - * Copy the TTL to outer protocol layer. - * - * @return a treatment builder - */ - Builder copyTtlOut(); - - /** - * Copy the TTL to inner protocol layer. - * - * @return a treatment builder - */ - Builder copyTtlIn(); - - /** - * Push MPLS ether type. - * - * @return a treatment builder - */ - Builder pushMpls(); - - /** - * Pops MPLS ether type. - * - * @return a treatment builder - */ - Builder popMpls(); - - /** - * Pops MPLS ether type and set the new ethertype. - * - * @param etherType an ether type - * @return a treatment builder - * @deprecated in Drake Release - */ - @Deprecated - Builder popMpls(int etherType); - - /** - * Pops MPLS ether type and set the new ethertype. - * - * @param etherType an ether type - * @return a treatment builder - */ - Builder popMpls(EthType etherType); - - /** - * Sets the mpls label. - * - * @param mplsLabel MPLS label - * @return a treatment builder - */ - Builder setMpls(MplsLabel mplsLabel); - - /** - * Sets the mpls bottom-of-stack indicator bit. - * - * @param mplsBos boolean to set BOS=1 (true) or BOS=0 (false) - * @return a treatment builder. - */ - Builder setMplsBos(boolean mplsBos); - - /** - * Decrement MPLS TTL. - * - * @return a treatment builder - */ - Builder decMplsTtl(); - - /** - * Sets the optical channel ID or lambda. - * - * @param lambda optical channel ID - * @return a treatment builder - * @deprecated in Drake Release - */ - @Deprecated - Builder setLambda(short lambda); - - /** - * Sets the group ID. - * - * @param groupId group ID - * @return a treatment builder - */ - Builder group(GroupId groupId); - - /** - * Sets the Queue ID. - * - * @param queueId a queue ID - * @return a treatment builder - */ - Builder setQueue(long queueId); - - /** - * Sets the Queue ID for a specific port. - * - * @param queueId a queue ID - * @param port a port number - * @return a treatment builder - */ - Builder setQueue(long queueId, PortNumber port); - - /** - * Sets a meter to be used by this flow. - * - * @param meterId a meter id - * @return a treatment builder - */ - Builder meter(MeterId meterId); - - /** - * Sets the next table id to transition to. - * - * @param tableId the table table - * @return a treatement builder - */ - Builder transition(Integer tableId); - - - /** - * Pops outermost VLAN tag. - * - * @return a treatment builder - */ - Builder popVlan(); - - /** - * Pushes a new VLAN tag. - * - * @return a treatment builder - */ - Builder pushVlan(); - - /** - * Any instructions preceded by this method call will be deferred. - * @return a treatment builder - */ - Builder deferred(); - - /** - * Any instructions preceded by this method call will be immediate. - * @return a treatment builder - */ - Builder immediate(); - - - /** - * Instructs the device to clear the deferred instructions set. - * @return a treatment builder - */ - Builder wipeDeferred(); - - /** - * Writes metadata to associate with a packet. - * <pre> - * {@code - * new_metadata = (old_metadata & ̃mask) | (value & mask) - * } - * </pre> - * - * @param value the metadata to write - * @param mask the masked bits for the value - * @return a treatment builder - */ - Builder writeMetadata(long value, long mask); - - /** - * Sets the tunnel id. - * - * @param tunnelId a tunnel id - * @return a treatment builder - */ - Builder setTunnelId(long tunnelId); - - /** - * Sets the src TCP port. - * - * @param port a port number - * @return a treatment builder - * @deprecated in Drake release - */ - @Deprecated - Builder setTcpSrc(short port); - - /** - * Sets the src TCP port. - * - * @param port a port number - * @return a treatment builder - */ - Builder setTcpSrc(TpPort port); - - /** - * Sets the dst TCP port. - * - * @param port a port number - * @return a treatment builder - * @deprecated in Drake release - */ - @Deprecated - Builder setTcpDst(short port); - - /** - * Sets the dst TCP port. - * - * @param port a port number - * @return a treatment builder - */ - Builder setTcpDst(TpPort port); - - /** - * Sets the src UDP port. - * - * @param port a port number - * @return a treatment builder - * @deprecated in Drake release - */ - @Deprecated - Builder setUdpSrc(short port); - - /** - * Sets the src UDP port. - * - * @param port a port number - * @return a treatment builder - */ - Builder setUdpSrc(TpPort port); - - /** - * Sets the dst UDP port. - * - * @param port a port number - * @return a treatment builder - * @deprecated in Drake release - */ - @Deprecated - Builder setUdpDst(short port); - - /** - * Sets the dst UDP port. - * - * @param port a port number - * @return a treatment builder - */ - Builder setUdpDst(TpPort port); - - /** - * Sets the arp src ip address. - * - * @param addr an ip - * @return a treatment builder - */ - Builder setArpSpa(IpAddress addr); - - /** - * Sets the arp src mac address. - * - * @param addr a macaddress - * @return a treatment builder - */ - Builder setArpSha(MacAddress addr); - - /** - * Sets the arp operation. - * - * @param op the value of arp operation. - * @return a treatment builder. - */ - Builder setArpOp(short op); - - /** - * Uses an extension treatment. - * - * @param extension extension treatment - * @param deviceId device ID - * @return a treatment builder - */ - Builder extension(ExtensionTreatment extension, DeviceId deviceId); - - /** - * Builds an immutable traffic treatment descriptor. - * <p> - * If the treatment is empty when build() is called, it will add a default - * drop rule automatically. For a treatment that is actually empty, use - * {@link org.onosproject.net.flow.DefaultTrafficTreatment#emptyTreatment}. - * </p> - * - * @return traffic treatment - */ - TrafficTreatment build(); - - } - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TypedStoredFlowEntry.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TypedStoredFlowEntry.java deleted file mode 100644 index 965fd1f8..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TypedStoredFlowEntry.java +++ /dev/null @@ -1,67 +0,0 @@ -/*
- * 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;
-
-/**
- * Represents a flow live type for a given flow entry.
- */
-public interface TypedStoredFlowEntry extends StoredFlowEntry {
- enum FlowLiveType {
- /**
- * Indicates that this rule has been submitted for addition immediately.
- * Not necessarily collecting flow stats.
- */
- IMMEDIATE_FLOW,
-
- /**
- * Indicates that this rule has been submitted for a short time.
- * Necessarily collecting flow stats every calAndPollInterval.
- */
- SHORT_FLOW,
-
- /**
- * Indicates that this rule has been submitted for a mid time.
- * Necessarily collecting flow stats every midPollInterval.
- */
- MID_FLOW,
-
- /**
- * Indicates that this rule has been submitted for a long time.
- * Necessarily collecting flow stats every longPollInterval.
- */
- LONG_FLOW,
-
- /**
- * Indicates that this rule has been submitted for UNKNOWN or ERROR.
- * Not necessarily collecting flow stats.
- */
- UNKNOWN_FLOW
- }
-
- /**
- * Gets the flow live type for this entry.
- *
- * @return flow live type
- */
- FlowLiveType flowLiveType();
-
- /**
- * Sets the new flow live type for this entry.
- * @param liveType new flow live type.
- */
- void setFlowLiveType(FlowLiveType liveType);
-}
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 deleted file mode 100644 index 71269dd1..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpHaCriterion.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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/ArpOpCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpOpCriterion.java deleted file mode 100644 index 8c5398c6..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpOpCriterion.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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/ArpPaCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpPaCriterion.java deleted file mode 100644 index ba5a03d8..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ArpPaCriterion.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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; - -import org.onlab.packet.Ip4Address; - -/** - * Implementation of arp spa or tpa address criterion. - */ -public final class ArpPaCriterion implements Criterion { - private final Ip4Address ip; - private final Type type; - - /** - * Constructor. - * - * @param ip the Ip4 Address to match. - * @param type the match type. Should be one of the following: - * Type.ARP_SPA, Type.ARP_TPA - */ - ArpPaCriterion(Ip4Address ip, Type type) { - this.ip = ip; - this.type = type; - } - - @Override - public Type type() { - return this.type; - } - - /** - * Gets the Ip4 Address to match. - * - * @return the Ip4 Address to match - */ - public Ip4Address ip() { - return this.ip; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("ip", ip).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), ip); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ArpPaCriterion) { - ArpPaCriterion that = (ArpPaCriterion) obj; - return Objects.equals(ip, that.ip) && - 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 deleted file mode 100644 index c94b1e02..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java +++ /dev/null @@ -1,624 +0,0 @@ -/* - * 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.flow.criteria; - -import org.onlab.packet.EthType; -import org.onlab.packet.Ip4Address; -import org.onlab.packet.Ip6Address; -import org.onlab.packet.IpPrefix; -import org.onlab.packet.MacAddress; -import org.onlab.packet.MplsLabel; -import org.onlab.packet.TpPort; -import org.onlab.packet.VlanId; -import org.onosproject.net.DeviceId; -import org.onosproject.net.IndexedLambda; -import org.onosproject.net.Lambda; -import org.onosproject.net.OchSignal; -import org.onosproject.net.OchSignalType; -import org.onosproject.net.OduSignalId; -import org.onosproject.net.OduSignalType; -import org.onosproject.net.PortNumber; -import org.onosproject.net.flow.criteria.Criterion.Type; - -/** - * Factory class to create various traffic selection criteria. - */ -public final class Criteria { - - //TODO: incomplete type implementation. Need to implement complete list from Criterion - - // Ban construction - private Criteria() { - } - - /** - * Creates a match on IN_PORT field using the specified value. - * - * @param port inport value - * @return match criterion - */ - public static Criterion matchInPort(PortNumber port) { - return new PortCriterion(port, Type.IN_PORT); - } - - /** - * Creates a match on IN_PHY_PORT field using the specified value. - * - * @param port inport value - * @return match criterion - */ - public static Criterion matchInPhyPort(PortNumber port) { - return new PortCriterion(port, Type.IN_PHY_PORT); - } - - /** - * Creates a match on METADATA field using the specified value. - * - * @param metadata metadata value (64 bits data) - * @return match criterion - */ - public static Criterion matchMetadata(long metadata) { - return new MetadataCriterion(metadata); - } - - /** - * Creates a match on ETH_DST field using the specified value. This value - * may be a wildcard mask. - * - * @param mac MAC address value or wildcard mask - * @return match criterion - */ - public static Criterion matchEthDst(MacAddress mac) { - return new EthCriterion(mac, Type.ETH_DST); - } - - /** - * Creates a match on ETH_SRC field using the specified value. This value - * may be a wildcard mask. - * - * @param mac MAC address value or wildcard mask - * @return match criterion - */ - public static Criterion matchEthSrc(MacAddress mac) { - return new EthCriterion(mac, Type.ETH_SRC); - } - - /** - * Creates a match on ETH_TYPE field using the specified value. - * - * @param ethType eth type value (16 bits unsigned integer) - * @return match criterion - */ - public static Criterion matchEthType(int ethType) { - return new EthTypeCriterion(ethType); - } - - /** - * Creates a match on ETH_TYPE field using the specified value. - * - * @param ethType eth type value - * @return match criterion - */ - public static Criterion matchEthType(EthType ethType) { - return new EthTypeCriterion(ethType); - } - - /** - * Creates a match on VLAN ID field using the specified value. - * - * @param vlanId vlan id value - * @return match criterion - */ - public static Criterion matchVlanId(VlanId vlanId) { - return new VlanIdCriterion(vlanId); - } - - /** - * Creates a match on VLAN PCP field using the specified value. - * - * @param vlanPcp vlan pcp value (3 bits) - * @return match criterion - */ - public static Criterion matchVlanPcp(byte vlanPcp) { - return new VlanPcpCriterion(vlanPcp); - } - - /** - * Creates a match on IP DSCP field using the specified value. - * - * @param ipDscp ip dscp value (6 bits) - * @return match criterion - */ - public static Criterion matchIPDscp(byte ipDscp) { - return new IPDscpCriterion(ipDscp); - } - - /** - * Creates a match on IP ECN field using the specified value. - * - * @param ipEcn ip ecn value (2 bits) - * @return match criterion - */ - public static Criterion matchIPEcn(byte ipEcn) { - return new IPEcnCriterion(ipEcn); - } - - /** - * Creates a match on IP proto field using the specified value. - * - * @param proto ip protocol value (8 bits unsigned integer) - * @return match criterion - */ - public static Criterion matchIPProtocol(short proto) { - return new IPProtocolCriterion(proto); - } - - /** - * Creates a match on IPv4 source field using the specified value. - * - * @param ip ipv4 source value - * @return match criterion - */ - public static Criterion matchIPSrc(IpPrefix ip) { - return new IPCriterion(ip, Type.IPV4_SRC); - } - - /** - * Creates a match on IPv4 destination field using the specified value. - * - * @param ip ipv4 source value - * @return match criterion - */ - public static Criterion matchIPDst(IpPrefix ip) { - return new IPCriterion(ip, Type.IPV4_DST); - } - - /** - * Creates a match on TCP source port field using the specified value. - * - * @param tcpPort TCP source port - * @return match criterion - * @deprecated in Drake release - */ - @Deprecated - public static Criterion matchTcpSrc(short tcpPort) { - return new TcpPortCriterion(TpPort.tpPort(tcpPort), Type.TCP_SRC); - } - - /** - * Creates a match on TCP source port field using the specified value. - * - * @param tcpPort TCP source port - * @return match criterion - */ - public static Criterion matchTcpSrc(TpPort tcpPort) { - return new TcpPortCriterion(tcpPort, Type.TCP_SRC); - } - - /** - * Creates a match on TCP destination port field using the specified value. - * - * @param tcpPort TCP destination port - * @return match criterion - * @deprecated in Drake release - */ - @Deprecated - public static Criterion matchTcpDst(short tcpPort) { - return new TcpPortCriterion(TpPort.tpPort(tcpPort), Type.TCP_DST); - } - - /** - * Creates a match on TCP destination port field using the specified value. - * - * @param tcpPort TCP destination port - * @return match criterion - */ - public static Criterion matchTcpDst(TpPort tcpPort) { - return new TcpPortCriterion(tcpPort, Type.TCP_DST); - } - - /** - * 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 - * @return match criterion - * @deprecated in Drake release - */ - @Deprecated - public static Criterion matchUdpSrc(short udpPort) { - return new UdpPortCriterion(TpPort.tpPort(udpPort), Type.UDP_SRC); - } - - /** - * Creates a match on UDP source port field using the specified value. - * - * @param udpPort UDP source port - * @return match criterion - */ - public static Criterion matchUdpSrc(TpPort udpPort) { - return new UdpPortCriterion(udpPort, Type.UDP_SRC); - } - - /** - * Creates a match on UDP destination port field using the specified value. - * - * @param udpPort UDP destination port - * @return match criterion - * @deprecated in Drake release - */ - @Deprecated - public static Criterion matchUdpDst(short udpPort) { - return new UdpPortCriterion(TpPort.tpPort(udpPort), Type.UDP_DST); - } - - /** - * Creates a match on UDP destination port field using the specified value. - * - * @param udpPort UDP destination port - * @return match criterion - */ - public static Criterion matchUdpDst(TpPort udpPort) { - return new UdpPortCriterion(udpPort, Type.UDP_DST); - } - - /** - * Creates a match on SCTP source port field using the specified value. - * - * @param sctpPort SCTP source port - * @return match criterion - * @deprecated in Drake release - */ - @Deprecated - public static Criterion matchSctpSrc(short sctpPort) { - return new SctpPortCriterion(TpPort.tpPort(sctpPort), Type.SCTP_SRC); - } - - /** - * Creates a match on SCTP source port field using the specified value. - * - * @param sctpPort SCTP source port - * @return match criterion - */ - public static Criterion matchSctpSrc(TpPort sctpPort) { - return new SctpPortCriterion(sctpPort, Type.SCTP_SRC); - } - - /** - * Creates a match on SCTP destination port field using the specified - * value. - * - * @param sctpPort SCTP destination port - * @return match criterion - * @deprecated in Drake release - */ - @Deprecated - public static Criterion matchSctpDst(short sctpPort) { - return new SctpPortCriterion(TpPort.tpPort(sctpPort), Type.SCTP_DST); - } - - /** - * Creates a match on SCTP destination port field using the specified - * value. - * - * @param sctpPort SCTP destination port - * @return match criterion - */ - public static Criterion matchSctpDst(TpPort sctpPort) { - return new SctpPortCriterion(sctpPort, Type.SCTP_DST); - } - - /** - * Creates a match on ICMP type field using the specified value. - * - * @param icmpType ICMP type (8 bits unsigned integer) - * @return match criterion - */ - public static Criterion matchIcmpType(short icmpType) { - return new IcmpTypeCriterion(icmpType); - } - - /** - * Creates a match on ICMP code field using the specified value. - * - * @param icmpCode ICMP code (8 bits unsigned integer) - * @return match criterion - */ - public static Criterion matchIcmpCode(short icmpCode) { - return new IcmpCodeCriterion(icmpCode); - } - - /** - * Creates a match on IPv6 source field using the specified value. - * - * @param ip ipv6 source value - * @return match criterion - */ - public static Criterion matchIPv6Src(IpPrefix ip) { - return new IPCriterion(ip, Type.IPV6_SRC); - } - - /** - * Creates a match on IPv6 destination field using the specified value. - * - * @param ip ipv6 destination value - * @return match criterion - */ - public static Criterion matchIPv6Dst(IpPrefix ip) { - return new IPCriterion(ip, Type.IPV6_DST); - } - - /** - * Creates a match on IPv6 flow label field using the specified value. - * - * @param flowLabel IPv6 flow label (20 bits) - * @return match criterion - */ - public static Criterion matchIPv6FlowLabel(int flowLabel) { - return new IPv6FlowLabelCriterion(flowLabel); - } - - /** - * Creates a match on ICMPv6 type field using the specified value. - * - * @param icmpv6Type ICMPv6 type (8 bits unsigned integer) - * @return match criterion - */ - public static Criterion matchIcmpv6Type(short icmpv6Type) { - return new Icmpv6TypeCriterion(icmpv6Type); - } - - /** - * Creates a match on ICMPv6 code field using the specified value. - * - * @param icmpv6Code ICMPv6 code (8 bits unsigned integer) - * @return match criterion - */ - public static Criterion matchIcmpv6Code(short icmpv6Code) { - return new Icmpv6CodeCriterion(icmpv6Code); - } - - /** - * Creates a match on IPv6 Neighbor Discovery target address using the - * specified value. - * - * @param targetAddress IPv6 Neighbor Discovery target address - * @return match criterion - */ - public static Criterion matchIPv6NDTargetAddress(Ip6Address targetAddress) { - return new IPv6NDTargetAddressCriterion(targetAddress); - } - - /** - * Creates a match on IPv6 Neighbor Discovery source link-layer address - * using the specified value. - * - * @param mac IPv6 Neighbor Discovery source link-layer address - * @return match criterion - */ - public static Criterion matchIPv6NDSourceLinkLayerAddress(MacAddress mac) { - return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_SLL); - } - - /** - * Creates a match on IPv6 Neighbor Discovery target link-layer address - * using the specified value. - * - * @param mac IPv6 Neighbor Discovery target link-layer address - * @return match criterion - */ - public static Criterion matchIPv6NDTargetLinkLayerAddress(MacAddress mac) { - return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_TLL); - } - - /** - * Creates a match on MPLS label. - * - * @param mplsLabel MPLS label (20 bits) - * @return match criterion - */ - public static Criterion matchMplsLabel(MplsLabel mplsLabel) { - return new MplsCriterion(mplsLabel); - } - - /** - * Creates a match on MPLS Bottom-of-Stack indicator bit. - * - * @param mplsBos boolean value indicating true (BOS=1) or false (BOS=0) - * @return match criterion - */ - 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) - * @return match criterion - */ - public static Criterion matchTunnelId(long tunnelId) { - return new TunnelIdCriterion(tunnelId); - } - - /** - * Creates a match on IPv6 Extension Header pseudo-field fiags. - * Those are defined in Criterion.IPv6ExthdrFlags. - * - * @param exthdrFlags IPv6 Extension Header pseudo-field flags (16 bits) - * @return match criterion - */ - public static Criterion matchIPv6ExthdrFlags(int exthdrFlags) { - return new IPv6ExthdrFlagsCriterion(exthdrFlags); - } - - /** - * Creates a match on lambda using the specified value. - * - * @param lambda lambda - * @return match criterion - */ - public static Criterion matchLambda(Lambda lambda) { - if (lambda instanceof IndexedLambda) { - return new IndexedLambdaCriterion((IndexedLambda) lambda); - } else if (lambda instanceof OchSignal) { - return new OchSignalCriterion((OchSignal) lambda); - } else { - throw new UnsupportedOperationException(String.format("Unsupported type of Lambda: %s", lambda)); - } - } - - /** - * Create a match on OCh (Optical Channel) signal type. - * - * @param signalType OCh signal type - * @return match criterion - */ - public static Criterion matchOchSignalType(OchSignalType signalType) { - return new OchSignalTypeCriterion(signalType); - } - - /** - * Creates a match on ODU (Optical channel Data Unit) signal ID using the specified value. - * - * @param oduSignalId ODU Signal Id - * @return match criterion - */ - public static Criterion matchOduSignalId(OduSignalId oduSignalId) { - return new OduSignalIdCriterion(oduSignalId); - } - - /** - * Creates a match on ODU (Optical channel Data Unit) signal Type using the specified value. - * - * @param signalType ODU Signal Type - * @return match criterion - */ - public static Criterion matchOduSignalType(OduSignalType signalType) { - return new OduSignalTypeCriterion(signalType); - } - - /** - * Creates a match on IPv4 destination field using the specified value. - * - * @param ip ipv4 destination value - * @return match criterion - */ - public static Criterion matchArpTpa(Ip4Address ip) { - return new ArpPaCriterion(ip, Type.ARP_TPA); - } - - /** - * Creates a match on IPv4 source field using the specified value. - * - * @param ip ipv4 source value - * @return match criterion - */ - public static Criterion matchArpSpa(Ip4Address ip) { - return new ArpPaCriterion(ip, Type.ARP_SPA); - } - - /** - * Creates a match on MAC destination field using the specified value. - * - * @param mac MAC destination value - * @return match criterion - */ - public static Criterion matchArpTha(MacAddress mac) { - return new ArpHaCriterion(mac, Type.ARP_THA); - } - - /** - * Creates a match on MAC source field using the specified value. - * - * @param mac MAC source value - * @return match criterion - */ - public static Criterion matchArpSha(MacAddress mac) { - 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); - } - - /** - * Creates a match on PBB I-SID field using the specific value. - * - * @param pbbIsid PBB I-SID - * @return match criterion - */ - public static Criterion matchPbbIsid(int pbbIsid) { - return new PbbIsidCriterion(pbbIsid); - } - - /** - * Creates an extension criterion for the specified extension selector. - * - * @param extensionSelector extension selector - * @param deviceId device ID - * @return match criterion - */ - public static Criterion extension(ExtensionSelector extensionSelector, - DeviceId deviceId) { - return new ExtensionCriterion(extensionSelector, deviceId); - } - - /** - * Creates a dummy criterion. - * - * @return match criterion - */ - public static Criterion dummy() { - return new DummyCriterion(); - } - - /** - * Dummy Criterion used with @see{FilteringObjective}. - */ - private static class DummyCriterion implements Criterion { - - @Override - public Type type() { - return Type.DUMMY; - } - } -} 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 deleted file mode 100644 index 17557b9d..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Criterion.java +++ /dev/null @@ -1,270 +0,0 @@ -/* - * 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.flow.criteria; - - -/** - * Representation of a single header field selection. - */ -public interface Criterion { - - /** - * Types of fields to which the selection criterion may apply. - */ - // From page 75 of OpenFlow 1.5.0 spec - 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, - - /** 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, - - // - // NOTE: Everything below is defined elsewhere: ONOS-specific, - // extensions, etc. - // - /** 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, - - /** Extension criterion. */ - EXTENSION, - - /** An empty criterion. */ - DUMMY - } - - /** - * Returns the type of criterion. - * - * @return type of criterion - */ - Type type(); - - /** - * Bit definitions for IPv6 Extension Header pseudo-field. - * From page 79 of OpenFlow 1.5.0 spec. - */ - enum IPv6ExthdrFlags { - /** "No next header" encountered. */ - NONEXT((short) (1 << 0)), - /** Encrypted Sec Payload header present. */ - ESP((short) (1 << 1)), - /** Authentication header present. */ - AUTH((short) (1 << 2)), - /** 1 or 2 dest headers present. */ - DEST((short) (1 << 3)), - /** Fragment header present. */ - FRAG((short) (1 << 4)), - /** Router header present. */ - ROUTER((short) (1 << 5)), - /** Hop-by-hop header present. */ - HOP((short) (1 << 6)), - /** Unexpected repeats encountered. */ - UNREP((short) (1 << 7)), - /** Unexpected sequencing encountered. */ - UNSEQ((short) (1 << 8)); - - private short value; - - IPv6ExthdrFlags(short value) { - this.value = value; - } - - /** - * Gets the value as an integer. - * - * @return the value as an integer - */ - public short getValue() { - 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/EthCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/EthCriterion.java deleted file mode 100644 index 6020974d..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/EthCriterion.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 org.onlab.packet.MacAddress; - -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; - -/** - * Implementation of MAC address criterion. - */ -public final class EthCriterion implements Criterion { - private final MacAddress mac; - private final Type type; - - /** - * Constructor. - * - * @param mac the source or destination MAC address to match - * @param type the match type. Should be either Type.ETH_DST or - * Type.ETH_SRC - */ - EthCriterion(MacAddress mac, Type type) { - 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 EthCriterion) { - EthCriterion that = (EthCriterion) obj; - return Objects.equals(mac, that.mac) && - Objects.equals(type, that.type); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/EthTypeCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/EthTypeCriterion.java deleted file mode 100644 index b2666d4d..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/EthTypeCriterion.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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 org.onlab.packet.EthType; - -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; - -/** - * Implementation of Ethernet type criterion (16 bits unsigned integer). - */ -public final class EthTypeCriterion implements Criterion { - - - private final EthType ethType; - - /** - * Constructor. - * - * @param ethType the Ethernet frame type to match (16 bits unsigned - * integer) - */ - EthTypeCriterion(int ethType) { - this.ethType = new EthType(ethType); - } - - /** - * Constructor. - * - * @param ethType the Ethernet frame type to match - */ - EthTypeCriterion(EthType ethType) { - this.ethType = ethType; - } - - @Override - public Type type() { - return Type.ETH_TYPE; - } - - /** - * Gets the Ethernet frame type to match. - * - * @return the Ethernet frame type to match (16 bits unsigned integer) - */ - public EthType ethType() { - return ethType; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("ethType", ethType.toString()) - .toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), ethType); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof EthTypeCriterion) { - EthTypeCriterion that = (EthTypeCriterion) obj; - return Objects.equals(ethType, that.ethType) && - Objects.equals(this.type(), that.type()); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionCriterion.java deleted file mode 100644 index 646b4184..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionCriterion.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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 org.onosproject.net.DeviceId; - -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; - -/** - * Criterion for implementing selector extensions. - */ -public class ExtensionCriterion implements Criterion { - - private final ExtensionSelector extensionSelector; - private final DeviceId deviceId; - - /** - * Constructor. - * - * @param extensionSelector extension selector - */ - public ExtensionCriterion(ExtensionSelector extensionSelector, DeviceId deviceId) { - this.extensionSelector = extensionSelector; - this.deviceId = deviceId; - } - - /** - * Returns the extension selector. - * - * @return extension selector - */ - public ExtensionSelector extensionSelector() { - return extensionSelector; - } - - /** - * Returns the device ID. - * - * @return device ID - */ - public DeviceId deviceId() { - return deviceId; - } - - @Override - public Type type() { - return Type.EXTENSION; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("extensionSelector", extensionSelector.toString()) - .add("deviceId", deviceId) - .toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), extensionSelector, deviceId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ExtensionCriterion) { - ExtensionCriterion that = (ExtensionCriterion) obj; - return Objects.equals(extensionSelector, that.extensionSelector) && - Objects.equals(deviceId, that.deviceId) && - Objects.equals(this.type(), that.type()); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionSelector.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionSelector.java deleted file mode 100644 index d3cebb37..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionSelector.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 org.onosproject.net.flow.Extension; - -/** - * An extension for the selector API. - */ -public interface ExtensionSelector extends Extension { - - /** - * Gets the type of the extension selector. - * - * @return type - */ - ExtensionSelectorType type(); -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionSelectorType.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionSelectorType.java deleted file mode 100644 index fa8f0923..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/ExtensionSelectorType.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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 com.google.common.annotations.Beta; -import com.google.common.base.MoreObjects; - -import java.util.Objects; - -/** - * Type of selector extensions. - */ -@Beta -public class ExtensionSelectorType { - - /** - * A list of well-known named extension selector type codes. - * These numbers have no impact on the actual OF type id. - */ - public enum ExtensionSelectorTypes { - NICIRA_MATCH_NSH_SPI(0), - NICIRA_MATCH_NSH_SI(1), - NICIRA_MATCH_NSH_CH1(2), - NICIRA_MATCH_NSH_CH2(3), - NICIRA_MATCH_NSH_CH3(4), - NICIRA_MATCH_NSH_CH4(5); - - - private ExtensionSelectorType type; - - /** - * Creates a new named extension selector type. - * - * @param type type code - */ - ExtensionSelectorTypes(int type) { - this.type = new ExtensionSelectorType(type); - } - - /** - * Gets the extension type object for this named type code. - * - * @return extension type object - */ - public ExtensionSelectorType type() { - return type; - } - } - - private final int type; - - /** - * Creates an extension type with the given int type code. - * - * @param type type code - */ - public ExtensionSelectorType(int type) { - this.type = type; - } - - @Override - public int hashCode() { - return Objects.hash(type); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ExtensionSelectorType) { - final ExtensionSelectorType that = (ExtensionSelectorType) obj; - return this.type == that.type; - } - return false; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(ExtensionSelectorType.class) - .add("type", type) - .toString(); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPCriterion.java deleted file mode 100644 index 018afe80..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPCriterion.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 org.onlab.packet.IpPrefix; - -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; - -/** - * Implementation of IP address criterion. - */ -public final class IPCriterion implements Criterion { - private final IpPrefix ip; - private final Type type; - - /** - * Constructor. - * - * @param ip the IP prefix to match. Could be either IPv4 or IPv6 - * @param type the match type. Should be one of the following: - * Type.IPV4_SRC, Type.IPV4_DST, Type.IPV6_SRC, Type.IPV6_DST - */ - IPCriterion(IpPrefix ip, Type type) { - this.ip = ip; - this.type = type; - } - - @Override - public Type type() { - return this.type; - } - - /** - * Gets the IP prefix to match. - * - * @return the IP prefix to match - */ - public IpPrefix ip() { - return this.ip; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("ip", ip).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), ip); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof IPCriterion) { - IPCriterion that = (IPCriterion) obj; - return Objects.equals(ip, that.ip) && - Objects.equals(type, that.type); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPDscpCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPDscpCriterion.java deleted file mode 100644 index 8634aa66..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPDscpCriterion.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 IP DSCP (Differentiated Services Code Point) - * criterion (6 bits). - */ -public final class IPDscpCriterion implements Criterion { - private static final byte MASK = 0x3f; - private final byte ipDscp; // IP DSCP value: 6 bits - - /** - * Constructor. - * - * @param ipDscp the IP DSCP value to match - */ - IPDscpCriterion(byte ipDscp) { - this.ipDscp = (byte) (ipDscp & MASK); - } - - @Override - public Type type() { - return Type.IP_DSCP; - } - - /** - * Gets the IP DSCP value to match. - * - * @return the IP DSCP value to match - */ - public byte ipDscp() { - return ipDscp; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("ipDscp", Long.toHexString(ipDscp)).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), ipDscp); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof IPDscpCriterion) { - IPDscpCriterion that = (IPDscpCriterion) obj; - return Objects.equals(ipDscp, that.ipDscp) && - Objects.equals(this.type(), that.type()); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPEcnCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPEcnCriterion.java deleted file mode 100644 index 48b3fbf6..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPEcnCriterion.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 IP ECN (Explicit Congestion Notification) criterion - * (2 bits). - */ -public final class IPEcnCriterion implements Criterion { - private static final byte MASK = 0x3; - private final byte ipEcn; // IP ECN value: 2 bits - - /** - * Constructor. - * - * @param ipEcn the IP ECN value to match (2 bits) - */ - IPEcnCriterion(byte ipEcn) { - this.ipEcn = (byte) (ipEcn & MASK); - } - - @Override - public Type type() { - return Type.IP_ECN; - } - - /** - * Gets the IP ECN value to match. - * - * @return the IP ECN value to match (2 bits) - */ - public byte ipEcn() { - return ipEcn; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("ipEcn", Long.toHexString(ipEcn)).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), ipEcn); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof IPEcnCriterion) { - IPEcnCriterion that = (IPEcnCriterion) obj; - return Objects.equals(ipEcn, that.ipEcn) && - Objects.equals(this.type(), that.type()); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPProtocolCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPProtocolCriterion.java deleted file mode 100644 index 6879f802..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPProtocolCriterion.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 Internet Protocol Number criterion (8 bits unsigned) - * integer. - */ -public final class IPProtocolCriterion implements Criterion { - private static final short MASK = 0xff; - private final short proto; // IP protocol number: 8 bits - - /** - * Constructor. - * - * @param protocol the IP protocol (e.g., TCP=6, UDP=17) to match - * (8 bits unsigned integer) - */ - IPProtocolCriterion(short protocol) { - this.proto = (short) (protocol & MASK); - } - - @Override - public Type type() { - return Type.IP_PROTO; - } - - /** - * Gets the IP protocol to match. - * - * @return the IP protocol to match (8 bits unsigned integer) - */ - public short protocol() { - return proto; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("protocol", proto).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), proto); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof IPProtocolCriterion) { - IPProtocolCriterion that = (IPProtocolCriterion) obj; - return Objects.equals(proto, that.proto); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPv6ExthdrFlagsCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPv6ExthdrFlagsCriterion.java deleted file mode 100644 index 2463bf64..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPv6ExthdrFlagsCriterion.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 IPv6 Extension Header pseudo-field criterion - * (16 bits). Those are defined in Criterion.IPv6ExthdrFlags. - */ -public final class IPv6ExthdrFlagsCriterion implements Criterion { - private static final int MASK = 0xffff; - private final int exthdrFlags; // IPv6 Exthdr flags: 16 bits - - /** - * Constructor. - * - * @param exthdrFlags the IPv6 Extension Header pseudo-field flags - * to match (16 bits). Those are defined in Criterion.IPv6ExthdrFlags - */ - IPv6ExthdrFlagsCriterion(int exthdrFlags) { - this.exthdrFlags = exthdrFlags & MASK; - } - - @Override - public Type type() { - return Type.IPV6_EXTHDR; - } - - /** - * Gets the IPv6 Extension Header pseudo-field flags to match. - * - * @return the IPv6 Extension Header pseudo-field flags to match - * (16 bits). Those are defined in Criterion.IPv6ExthdrFlags - */ - public int exthdrFlags() { - return exthdrFlags; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("exthdrFlags", Long.toHexString(exthdrFlags)).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), exthdrFlags); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof IPv6ExthdrFlagsCriterion) { - IPv6ExthdrFlagsCriterion that = (IPv6ExthdrFlagsCriterion) obj; - return Objects.equals(exthdrFlags, that.exthdrFlags) && - Objects.equals(this.type(), that.type()); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPv6FlowLabelCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPv6FlowLabelCriterion.java deleted file mode 100644 index 6e1021d9..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPv6FlowLabelCriterion.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 IPv6 Flow Label (RFC 6437) criterion (20 bits unsigned - * integer). - */ -public final class IPv6FlowLabelCriterion implements Criterion { - private static final int MASK = 0xfffff; - private final int flowLabel; // IPv6 flow label: 20 bits - - /** - * Constructor. - * - * @param flowLabel the IPv6 flow label to match (20 bits) - */ - IPv6FlowLabelCriterion(int flowLabel) { - this.flowLabel = flowLabel & MASK; - } - - @Override - public Type type() { - return Type.IPV6_FLABEL; - } - - /** - * Gets the IPv6 flow label to match. - * - * @return the IPv6 flow label to match (20 bits) - */ - public int flowLabel() { - return flowLabel; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("flowLabel", Long.toHexString(flowLabel)).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), flowLabel); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof IPv6FlowLabelCriterion) { - IPv6FlowLabelCriterion that = (IPv6FlowLabelCriterion) obj; - return Objects.equals(flowLabel, that.flowLabel) && - Objects.equals(this.type(), that.type()); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPv6NDLinkLayerAddressCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPv6NDLinkLayerAddressCriterion.java deleted file mode 100644 index 9f310d4a..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPv6NDLinkLayerAddressCriterion.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 org.onlab.packet.MacAddress; - -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; - -/** - * Implementation of IPv6 Neighbor Discovery link-layer address criterion. - */ -public final class IPv6NDLinkLayerAddressCriterion implements Criterion { - private final MacAddress mac; - private final Type type; - - /** - * Constructor. - * - * @param mac the source or destination link-layer address to match - * @param type the match type. Should be either Type.IPV6_ND_SLL or - * Type.IPV6_ND_TLL - */ - IPv6NDLinkLayerAddressCriterion(MacAddress mac, Type type) { - this.mac = mac; - this.type = type; - } - - @Override - public Type type() { - return this.type; - } - - /** - * Gets the MAC link-layer address to match. - * - * @return the MAC link-layer 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 IPv6NDLinkLayerAddressCriterion) { - IPv6NDLinkLayerAddressCriterion that = - (IPv6NDLinkLayerAddressCriterion) obj; - return Objects.equals(mac, that.mac) && - Objects.equals(type, that.type); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPv6NDTargetAddressCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPv6NDTargetAddressCriterion.java deleted file mode 100644 index ffef044a..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IPv6NDTargetAddressCriterion.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 org.onlab.packet.Ip6Address; - -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; - -/** - * Implementation of IPv6 Neighbor Discovery target address criterion. - */ -public final class IPv6NDTargetAddressCriterion implements Criterion { - private final Ip6Address targetAddress; - - /** - * Constructor. - * - * @param targetAddress the IPv6 target address to match - */ - IPv6NDTargetAddressCriterion(Ip6Address targetAddress) { - this.targetAddress = targetAddress; - } - - @Override - public Type type() { - return Type.IPV6_ND_TARGET; - } - - /** - * Gets the IPv6 target address to match. - * - * @return the IPv6 target address to match - */ - public Ip6Address targetAddress() { - return this.targetAddress; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("targetAddress", targetAddress).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), targetAddress); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof IPv6NDTargetAddressCriterion) { - IPv6NDTargetAddressCriterion that = - (IPv6NDTargetAddressCriterion) obj; - return Objects.equals(targetAddress, that.targetAddress) && - Objects.equals(type(), that.type()); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IcmpCodeCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IcmpCodeCriterion.java deleted file mode 100644 index 516f61b3..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IcmpCodeCriterion.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 ICMP code criterion (8 bits unsigned integer). - */ -public final class IcmpCodeCriterion implements Criterion { - private static final short MASK = 0xff; - private final short icmpCode; // The ICMP code: 8 bits - - /** - * Constructor. - * - * @param icmpCode the ICMP code to match (8 bits unsigned integer) - */ - IcmpCodeCriterion(short icmpCode) { - this.icmpCode = (short) (icmpCode & MASK); - } - - @Override - public Type type() { - return Type.ICMPV4_CODE; - } - - /** - * Gets the ICMP code to match. - * - * @return the ICMP code to match (8 bits unsigned integer) - */ - public short icmpCode() { - return icmpCode; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("icmpCode", icmpCode).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), icmpCode); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof IcmpCodeCriterion) { - IcmpCodeCriterion that = (IcmpCodeCriterion) obj; - return Objects.equals(icmpCode, that.icmpCode) && - Objects.equals(this.type(), that.type()); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IcmpTypeCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IcmpTypeCriterion.java deleted file mode 100644 index 63251425..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IcmpTypeCriterion.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 ICMP type criterion (8 bits unsigned integer). - */ -public final class IcmpTypeCriterion implements Criterion { - private static final short MASK = 0xff; - private final short icmpType; // The ICMP type: 8 bits - - /** - * Constructor. - * - * @param icmpType the ICMP type to match (8 bits unsigned integer) - */ - IcmpTypeCriterion(short icmpType) { - this.icmpType = (short) (icmpType & MASK); - } - - @Override - public Type type() { - return Type.ICMPV4_TYPE; - } - - /** - * Gets the ICMP type to match. - * - * @return the ICMP type to match (8 bits unsigned integer) - */ - public short icmpType() { - return icmpType; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("icmpType", icmpType).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), icmpType); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof IcmpTypeCriterion) { - IcmpTypeCriterion that = (IcmpTypeCriterion) obj; - return Objects.equals(icmpType, that.icmpType) && - Objects.equals(this.type(), that.type()); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Icmpv6CodeCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Icmpv6CodeCriterion.java deleted file mode 100644 index a41b6fef..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Icmpv6CodeCriterion.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 ICMPv6 code criterion (8 bits unsigned integer). - */ -public final class Icmpv6CodeCriterion implements Criterion { - private static final short MASK = 0xff; - private final short icmpv6Code; // ICMPv6 code: 8 bits - - /** - * Constructor. - * - * @param icmpv6Code the ICMPv6 code to match (8 bits unsigned integer) - */ - Icmpv6CodeCriterion(short icmpv6Code) { - this.icmpv6Code = (short) (icmpv6Code & MASK); - } - - @Override - public Type type() { - return Type.ICMPV6_CODE; - } - - /** - * Gets the ICMPv6 code to match. - * - * @return the ICMPv6 code to match (8 bits unsigned integer) - */ - public short icmpv6Code() { - return icmpv6Code; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("icmpv6Code", icmpv6Code).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), icmpv6Code); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof Icmpv6CodeCriterion) { - Icmpv6CodeCriterion that = (Icmpv6CodeCriterion) obj; - return Objects.equals(icmpv6Code, that.icmpv6Code) && - Objects.equals(this.type(), that.type()); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Icmpv6TypeCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Icmpv6TypeCriterion.java deleted file mode 100644 index 7410ba17..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/Icmpv6TypeCriterion.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 ICMPv6 type criterion (8 bits unsigned integer). - */ -public final class Icmpv6TypeCriterion implements Criterion { - private static final short MASK = 0xff; - private final short icmpv6Type; // ICMPv6 type: 8 bits - - /** - * Constructor. - * - * @param icmpv6Type the ICMPv6 type to match (8 bits unsigned integer) - */ - Icmpv6TypeCriterion(short icmpv6Type) { - this.icmpv6Type = (short) (icmpv6Type & MASK); - } - - @Override - public Type type() { - return Type.ICMPV6_TYPE; - } - - /** - * Gets the ICMPv6 type to match. - * - * @return the ICMPv6 type to match (8 bits unsigned integer) - */ - public short icmpv6Type() { - return icmpv6Type; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("icmpv6Type", icmpv6Type).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), icmpv6Type); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof Icmpv6TypeCriterion) { - Icmpv6TypeCriterion that = (Icmpv6TypeCriterion) obj; - return Objects.equals(icmpv6Type, that.icmpv6Type) && - Objects.equals(this.type(), that.type()); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IndexedLambdaCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IndexedLambdaCriterion.java deleted file mode 100644 index 88a6fe10..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/IndexedLambdaCriterion.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 com.google.common.base.MoreObjects; -import org.onosproject.net.IndexedLambda; - -import java.util.Objects; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Implementation of indexed lambda criterion. - */ -public class IndexedLambdaCriterion implements Criterion { - - private final IndexedLambda lambda; - - /** - * Creates a criterion with the specified value. - * - * @param lambda lambda index number - */ - IndexedLambdaCriterion(IndexedLambda lambda) { - this.lambda = checkNotNull(lambda); - } - - @Override - public Type type() { - // TODO: consider defining a new specific type - // Now OCH_SIGID is used due to compatibility concerns - return Type.OCH_SIGID; - } - - /** - * Returns the indexed lambda to match. - * - * @return the indexed lambda to match - */ - public IndexedLambda lambda() { - return lambda; - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), lambda); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof IndexedLambdaCriterion)) { - return false; - } - final IndexedLambdaCriterion that = (IndexedLambdaCriterion) obj; - return Objects.equals(this.lambda, that.lambda); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("lambda", lambda) - .toString(); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/LambdaCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/LambdaCriterion.java deleted file mode 100644 index 656800b1..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/LambdaCriterion.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 lambda (wavelength) criterion (16 bits unsigned - * integer). - */ -public final class LambdaCriterion implements Criterion { - private static final int MASK = 0xffff; - private final int lambda; // Lambda value: 16 bits - private final Type type; - - /** - * Constructor. - * - * @param lambda the lambda (wavelength) to match (16 bits unsigned - * integer) - * @param type the match type. Should be Type.OCH_SIGID - */ - LambdaCriterion(int lambda, Type type) { - this.lambda = lambda & MASK; - this.type = type; - } - - @Override - public Type type() { - return this.type; - } - - /** - * Gets the lambda (wavelength) to match. - * - * @return the lambda (wavelength) to match (16 bits unsigned integer) - */ - public int lambda() { - return lambda; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("lambda", lambda).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), lambda); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof LambdaCriterion) { - LambdaCriterion that = (LambdaCriterion) obj; - return Objects.equals(lambda, that.lambda) && - Objects.equals(type, that.type); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MetadataCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MetadataCriterion.java deleted file mode 100644 index 8177b483..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MetadataCriterion.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 Metadata criterion. - */ -public final class MetadataCriterion implements Criterion { - private final long metadata; - - /** - * Constructor. - * - * @param metadata the metadata to match (64 bits data) - */ - MetadataCriterion(long metadata) { - this.metadata = metadata; - } - - @Override - public Type type() { - return Type.METADATA; - } - - /** - * Gets the metadata to match. - * - * @return the metadata to match (64 bits data) - */ - public long metadata() { - return metadata; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("metadata", Long.toHexString(metadata)) - .toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), metadata); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof MetadataCriterion) { - MetadataCriterion that = (MetadataCriterion) obj; - return Objects.equals(metadata, that.metadata) && - Objects.equals(this.type(), that.type()); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsBosCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsBosCriterion.java deleted file mode 100644 index c8b6690d..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsBosCriterion.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 MPLS BOS criterion (1 bit). - */ -public class MplsBosCriterion implements Criterion { - private boolean mplsBos; - - MplsBosCriterion(boolean mplsBos) { - this.mplsBos = mplsBos; - } - - @Override - public Type type() { - return Type.MPLS_BOS; - } - - public boolean mplsBos() { - return mplsBos; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("bos", mplsBos).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), mplsBos); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof MplsBosCriterion) { - MplsBosCriterion that = (MplsBosCriterion) obj; - return Objects.equals(mplsBos, that.mplsBos()) && - Objects.equals(this.type(), that.type()); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsCriterion.java deleted file mode 100644 index 34d384f1..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsCriterion.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 org.onlab.packet.MplsLabel; - -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; - -/** - * Implementation of MPLS tag criterion (20 bits). - */ -public final class MplsCriterion implements Criterion { - private static final int MASK = 0xfffff; - private final MplsLabel mplsLabel; - - MplsCriterion(MplsLabel mplsLabel) { - this.mplsLabel = mplsLabel; - } - - @Override - public Type type() { - return Type.MPLS_LABEL; - } - - public MplsLabel label() { - return mplsLabel; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("mpls", mplsLabel).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), mplsLabel); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof MplsCriterion) { - MplsCriterion that = (MplsCriterion) obj; - return Objects.equals(mplsLabel, that.mplsLabel) && - Objects.equals(this.type(), that.type()); - } - return false; - } -} 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 deleted file mode 100644 index 8ad62358..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/MplsTcCriterion.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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/OchSignalCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OchSignalCriterion.java deleted file mode 100644 index 3a51a6bd..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OchSignalCriterion.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 com.google.common.base.MoreObjects; -import org.onosproject.net.OchSignal; - -import java.util.Objects; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Implementation of OCh (Optical Channel) signal criterion. - * This criterion is based on the specification of "OFPXMT_EXP_OCH_SIGID" in - * Open Networking Foundation "Optical Transport Protocol Extension Version 1.0", but - * defined in protocol agnostic way. - */ -public final class OchSignalCriterion implements Criterion { - - private final OchSignal lambda; - - /** - * Create an instance with the specified OCh signal. - * - * @param lambda OCh signal - */ - OchSignalCriterion(OchSignal lambda) { - this.lambda = checkNotNull(lambda); - } - - @Override - public Type type() { - return Type.OCH_SIGID; - } - - /** - * Returns the OCh signal to match. - * - * @return the OCh signal to match - */ - public OchSignal lambda() { - return lambda; - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), lambda); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof OchSignalCriterion)) { - return false; - } - final OchSignalCriterion that = (OchSignalCriterion) obj; - return Objects.equals(this.lambda, that.lambda); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("lambda", lambda) - .toString(); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OchSignalTypeCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OchSignalTypeCriterion.java deleted file mode 100644 index cf838bf3..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OchSignalTypeCriterion.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 com.google.common.base.MoreObjects; -import org.onosproject.net.OchSignalType; - -import java.util.Objects; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Implementation of OCh (Optical Channel) signal type criterion. - */ -public class OchSignalTypeCriterion implements Criterion { - - private final OchSignalType signalType; - - /** - * Creates a criterion with the specified value. - * - * @param signalType OCh signal type - */ - OchSignalTypeCriterion(OchSignalType signalType) { - this.signalType = checkNotNull(signalType); - } - - @Override - public Type type() { - return Type.OCH_SIGTYPE; - } - - /** - * Returns the OCh signal type to match. - * - * @return the OCh signal type to match - */ - public OchSignalType signalType() { - return signalType; - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), signalType); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof OchSignalTypeCriterion)) { - return false; - } - final OchSignalTypeCriterion that = (OchSignalTypeCriterion) obj; - return Objects.equals(this.signalType, that.signalType); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("signalType", signalType) - .toString(); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalIdCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalIdCriterion.java deleted file mode 100644 index 21018544..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalIdCriterion.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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.onosproject.net.OduSignalId; - -/** - * Implementation of ODU (Optical channel Data Unit) signal ID signal criterion. - * This criterion is based on the specification of "OFPXMT_EXP_ODU_SIGID" in - * Open Networking Foundation "Optical Transport Protocol Extension Version 1.0", but - * defined in protocol agnostic way. - */ -public final class OduSignalIdCriterion implements Criterion { - - private final OduSignalId oduSignalId; - - /** - * Create an instance with the specified ODU signal ID. - * - * @param oduSignalId - ODU signal ID - */ - OduSignalIdCriterion(OduSignalId oduSignalId) { - this.oduSignalId = checkNotNull(oduSignalId); - } - - @Override - public Type type() { - return Type.ODU_SIGID; - } - - /** - * Returns the ODU Signal to match. - * - * @return the ODU signal to match - */ - public OduSignalId oduSignalId() { - return oduSignalId; - } - - @Override - public int hashCode() { - return Objects.hash(type(), oduSignalId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof OduSignalIdCriterion)) { - return false; - } - final OduSignalIdCriterion that = (OduSignalIdCriterion) obj; - return Objects.equals(this.oduSignalId, that.oduSignalId); - } - - @Override - public String toString() { - return toStringHelper(this) - .add("oduSignalId", oduSignalId) - .toString(); - } - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalTypeCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalTypeCriterion.java deleted file mode 100644 index f4854339..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/OduSignalTypeCriterion.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.onosproject.net.OduSignalType; - -/** - * Implementation of ODU (Optical channel Data Unit) signal Type criterion. - * This criterion is based on the specification of "OFPXMT_EXP_ODU_SIGTYPE" in - * Open Networking Foundation "Optical Transport Protocol Extension Version 1.0", but - * defined in protocol agnostic way. - */ -public final class OduSignalTypeCriterion implements Criterion { - - private final OduSignalType signalType; - - /** - * Create an instance with the specified ODU signal Type. - * - * @param signalType - ODU signal Type - */ - OduSignalTypeCriterion(OduSignalType signalType) { - this.signalType = checkNotNull(signalType); - } - - @Override - public Type type() { - return Type.ODU_SIGTYPE; - } - - /** - * Returns the ODU Signal Type to match. - * - * @return the ODU signal Type to match - */ - public OduSignalType signalType() { - return signalType; - } - - @Override - public int hashCode() { - return Objects.hash(type(), signalType); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof OduSignalTypeCriterion)) { - return false; - } - final OduSignalTypeCriterion that = (OduSignalTypeCriterion) obj; - return Objects.equals(this.signalType, that.signalType); - } - - @Override - public String toString() { - return toStringHelper(this) - .add("signalType", signalType) - .toString(); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/PbbIsidCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/PbbIsidCriterion.java deleted file mode 100644 index 979aa6bd..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/PbbIsidCriterion.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 PBB I-SID criterion (24 bits unsigned integer). - */ -public final class PbbIsidCriterion implements Criterion { - private static final int MASK = 0xfffff; - private final int pbbIsid; // PBB I-SID: 24 bits - - /** - * Constructor. - * - * @param pbbIsid the PBB I-SID to match (24 bits) - */ - PbbIsidCriterion(int pbbIsid) { - this.pbbIsid = pbbIsid & MASK; - } - - @Override - public Criterion.Type type() { - return Criterion.Type.PBB_ISID; - } - - /** - * Gets the PBB I-SID to match. - * - * @return the PBB I-SID to match (24 bits) - */ - public int pbbIsid() { - return this.pbbIsid; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("pbbIsid", Long.toHexString(pbbIsid)).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), pbbIsid); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof PbbIsidCriterion) { - PbbIsidCriterion that = (PbbIsidCriterion) obj; - return Objects.equals(pbbIsid, that.pbbIsid) && - Objects.equals(this.type(), that.type()); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/PortCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/PortCriterion.java deleted file mode 100644 index f07cd500..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/PortCriterion.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 org.onosproject.net.PortNumber; - -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; - -/** - * Implementation of input port criterion. - */ -public final class PortCriterion implements Criterion { - private final PortNumber port; - private final Type type; - - /** - * Constructor. - * - * @param port the input port number to match - * @param type the match type. Should be either Type.IN_PORT or - * Type.IN_PHY_PORT - */ - PortCriterion(PortNumber port, Type type) { - this.port = port; - this.type = type; - } - - @Override - public Type type() { - return this.type; - } - - /** - * Gets the input port number to match. - * - * @return the input port number to match - */ - public PortNumber port() { - return this.port; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("port", port).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), port); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof PortCriterion) { - PortCriterion that = (PortCriterion) obj; - return Objects.equals(port, that.port) && - Objects.equals(this.type(), that.type()); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/SctpPortCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/SctpPortCriterion.java deleted file mode 100644 index 2d4cf15a..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/SctpPortCriterion.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 org.onlab.packet.TpPort; - -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; - -/** - * Implementation of SCTP port criterion (16 bits unsigned integer). - */ -public final class SctpPortCriterion implements Criterion { - private final TpPort sctpPort; - private final Type type; - - /** - * Constructor. - * - * @param sctpPort the SCTP port to match - * @param type the match type. Should be either Type.SCTP_SRC or - * Type.SCTP_DST - */ - SctpPortCriterion(TpPort sctpPort, Type type) { - this.sctpPort = sctpPort; - this.type = type; - } - - @Override - public Type type() { - return this.type; - } - - /** - * Gets the SCTP port to match. - * - * @return the SCTP port to match - */ - public TpPort sctpPort() { - return this.sctpPort; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("sctpPort", sctpPort).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), sctpPort); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof SctpPortCriterion) { - SctpPortCriterion that = (SctpPortCriterion) obj; - return Objects.equals(sctpPort, that.sctpPort) && - Objects.equals(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 deleted file mode 100644 index e0b53958..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/TcpFlagsCriterion.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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/criteria/TcpPortCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/TcpPortCriterion.java deleted file mode 100644 index e682b238..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/TcpPortCriterion.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 org.onlab.packet.TpPort; - -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; - -/** - * Implementation of TCP port criterion (16 bits unsigned integer). - */ -public final class TcpPortCriterion implements Criterion { - private final TpPort tcpPort; - private final Type type; - - /** - * Constructor. - * - * @param tcpPort the TCP port to match - * @param type the match type. Should be either Type.TCP_SRC or - * Type.TCP_DST - */ - TcpPortCriterion(TpPort tcpPort, Type type) { - this.tcpPort = tcpPort; - this.type = type; - } - - @Override - public Type type() { - return this.type; - } - - /** - * Gets the TCP port to match. - * - * @return the TCP port to match - */ - public TpPort tcpPort() { - return this.tcpPort; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("tcpPort", tcpPort).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), tcpPort); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof TcpPortCriterion) { - TcpPortCriterion that = (TcpPortCriterion) obj; - return Objects.equals(tcpPort, that.tcpPort) && - Objects.equals(type, that.type); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/TunnelIdCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/TunnelIdCriterion.java deleted file mode 100644 index 3362c73f..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/TunnelIdCriterion.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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 Tunnel ID criterion. - */ -public class TunnelIdCriterion implements Criterion { - private final long tunnelId; - - /** - * Constructor. - * - * @param tunnelId a Tunnel ID to match(64 bits) - */ - TunnelIdCriterion(long tunnelId) { - this.tunnelId = tunnelId; - } - - @Override - public Type type() { - return Type.TUNNEL_ID; - } - - /** - * Gets the Tunnel ID to match. - * - * @return the Tunnel ID to match (64 bits) - */ - public long tunnelId() { - return tunnelId; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("tunnelId", Long.toHexString(tunnelId)) - .toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), tunnelId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof TunnelIdCriterion) { - TunnelIdCriterion that = (TunnelIdCriterion) obj; - return Objects.equals(tunnelId, that.tunnelId) && - Objects.equals(this.type(), that.type()); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/UdpPortCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/UdpPortCriterion.java deleted file mode 100644 index 8a29f471..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/UdpPortCriterion.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 org.onlab.packet.TpPort; - -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; - -/** - * Implementation of UDP port criterion (16 bits unsigned integer). - */ -public final class UdpPortCriterion implements Criterion { - private final TpPort udpPort; - private final Type type; - - /** - * Constructor. - * - * @param udpPort the UDP port to match - * @param type the match type. Should be either Type.UDP_SRC or - * Type.UDP_DST - */ - UdpPortCriterion(TpPort udpPort, Type type) { - this.udpPort = udpPort; - this.type = type; - } - - @Override - public Type type() { - return this.type; - } - - /** - * Gets the UDP port to match. - * - * @return the UDP port to match - */ - public TpPort udpPort() { - return this.udpPort; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("udpPort", udpPort).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), udpPort); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof UdpPortCriterion) { - UdpPortCriterion that = (UdpPortCriterion) obj; - return Objects.equals(udpPort, that.udpPort) && - Objects.equals(type, that.type); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/VlanIdCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/VlanIdCriterion.java deleted file mode 100644 index c73edb12..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/VlanIdCriterion.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 org.onlab.packet.VlanId; - -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; - -/** - * Implementation of VLAN ID criterion. - */ -public final class VlanIdCriterion implements Criterion { - private final VlanId vlanId; - - /** - * Constructor. - * - * @param vlanId the VLAN ID to match - */ - VlanIdCriterion(VlanId vlanId) { - this.vlanId = vlanId; - } - - @Override - public Type type() { - return Type.VLAN_VID; - } - - /** - * Gets the VLAN ID to match. - * - * @return the VLAN ID to match - */ - public VlanId vlanId() { - return vlanId; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("vlanId", vlanId).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), vlanId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof VlanIdCriterion) { - VlanIdCriterion that = (VlanIdCriterion) obj; - return Objects.equals(vlanId, that.vlanId) && - Objects.equals(this.type(), that.type()); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/VlanPcpCriterion.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/VlanPcpCriterion.java deleted file mode 100644 index 0c83e141..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/VlanPcpCriterion.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 VLAN priority criterion (3 bits). - */ -public final class VlanPcpCriterion implements Criterion { - private static final byte MASK = 0x7; - private final byte vlanPcp; // VLAN pcp value: 3 bits - - /** - * Constructor. - * - * @param vlanPcp the VLAN priority to match (3 bits) - */ - VlanPcpCriterion(byte vlanPcp) { - this.vlanPcp = (byte) (vlanPcp & MASK); - } - - @Override - public Type type() { - return Type.VLAN_PCP; - } - - /** - * Gets the VLAN priority to match. - * - * @return the VLAN priority to match (3 bits) - */ - public byte priority() { - return vlanPcp; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("priority", Long.toHexString(vlanPcp)).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), vlanPcp); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof VlanPcpCriterion) { - VlanPcpCriterion that = (VlanPcpCriterion) obj; - return Objects.equals(vlanPcp, that.vlanPcp) && - Objects.equals(this.type(), that.type()); - } - return false; - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/package-info.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/package-info.java deleted file mode 100644 index 1f091928..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/criteria/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2014 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. - */ - -/** - * Traffic selection criteria model. - */ -package org.onosproject.net.flow.criteria; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionPropertyException.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionPropertyException.java deleted file mode 100644 index 5750d09e..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionPropertyException.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.instructions; - -/** - * Exception indicating there was an error while setting/getting an extension - * instruction property. - */ -public class ExtensionPropertyException extends Exception { - - public ExtensionPropertyException(String message) { - super(message); - } - - public ExtensionPropertyException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatment.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatment.java deleted file mode 100644 index 3df152e9..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatment.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.instructions; - -import org.onosproject.net.flow.Extension; - -/** - * An extension for the treatment API. - */ -public interface ExtensionTreatment extends Extension { - - /** - * Gets the type of the treatment extension. - * - * @return type - */ - ExtensionTreatmentType type(); - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java deleted file mode 100644 index f597a46c..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionTreatmentType.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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.instructions; - -import com.google.common.annotations.Beta; -import com.google.common.base.MoreObjects; - -import java.util.Objects; - -/** - * Type of treatment extensions. - */ -@Beta -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 ExtensionTreatmentTypes { - NICIRA_SET_TUNNEL_DST(0), - NICIRA_RESUBMIT(1), - NICIRA_RESUBMIT_TABLE(14), - NICIRA_SET_NSH_SPI(32), - NICIRA_SET_NSH_SI(33), - NICIRA_SET_NSH_CH1(34), - NICIRA_SET_NSH_CH2(35), - NICIRA_SET_NSH_CH3(36), - NICIRA_SET_NSH_CH4(37), - NICIRA_MOV_ARP_SHA_TO_THA(2), - NICIRA_MOV_ARP_SPA_TO_TPA(3), - NICIRA_MOV_ETH_SRC_TO_DST(4), - NICIRA_MOV_IP_SRC_TO_DST(5); - - private ExtensionTreatmentType type; - - /** - * Creates a new named extension treatment type. - * - * @param type type code - */ - ExtensionTreatmentTypes(int type) { - this.type = new ExtensionTreatmentType(type); - } - - /** - * Gets the extension type object for this named type code. - * - * @return extension type object - */ - public ExtensionTreatmentType type() { - return type; - } - } - - private final int type; - - /** - * Creates an extension type with the given int type code. - * - * @param type type code - */ - public ExtensionTreatmentType(int type) { - this.type = type; - } - - @Override - public int hashCode() { - return Objects.hash(type); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ExtensionTreatmentType) { - final ExtensionTreatmentType that = (ExtensionTreatmentType) obj; - return this.type == that.type; - } - return false; - } - - @Override - public String toString() { - 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/Instruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java deleted file mode 100644 index 31ad80c5..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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.flow.instructions; - -/** - * Abstraction of a single traffic treatment step. - */ -public interface Instruction { - - /** - * Represents the type of traffic treatment. - */ - enum Type { - /** - * Signifies that the traffic should be dropped. - */ - @Deprecated - DROP, - - /** - * Signifies that the traffic requires no action. - * - * In OF10, the behavior of NOACTION is DROP. - * In OF13, the behavior depends on current Action Set. - */ - NOACTION, - - /** - * Signifies that the traffic should be output to a port. - */ - OUTPUT, - - /** - * Signifies that traffic should be sent out of a group. - */ - GROUP, - - /** - * Signifies that the traffic should be enqueued to an already-configured - queue on a port. - */ - QUEUE, - - /** - * Signifies that traffic should be metered according to a meter. - */ - METER, - - /** - * Signifies that the traffic should be modified in L0 way. - */ - L0MODIFICATION, - - /** - * Signifies that the traffic should be modified in L1 way. - */ - L1MODIFICATION, - - /** - * Signifies that the traffic should be modified in L2 way. - */ - L2MODIFICATION, - - /** - * Signifies that the traffic should be passed to another table. - */ - TABLE, - - /** - * Signifies that the traffic should be modified in L3 way. - */ - L3MODIFICATION, - - /** - * Signifies that metadata be attached to traffic. - */ - METADATA, - - /** - * Signifies that the traffic should be modified in L4 way. - */ - L4MODIFICATION, - - /** - * Signifies that an extension instruction will be used. - */ - EXTENSION - } - - /** - * Returns the type of instruction. - * - * @return type of instruction - */ - Type type(); - -} 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 deleted file mode 100644 index 8ed882c8..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java +++ /dev/null @@ -1,948 +0,0 @@ -/* - * 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.flow.instructions; - -import com.google.common.base.MoreObjects; -import org.onlab.packet.EthType; -import org.onlab.packet.IpAddress; -import org.onlab.packet.MacAddress; -import org.onlab.packet.MplsLabel; -import org.onlab.packet.TpPort; -import org.onlab.packet.VlanId; -import org.onosproject.core.GroupId; -import org.onosproject.net.DeviceId; -import org.onosproject.net.IndexedLambda; -import org.onosproject.net.Lambda; -import org.onosproject.net.OchSignal; -import org.onosproject.net.OduSignalId; -import org.onosproject.net.PortNumber; -import org.onosproject.net.flow.instructions.L0ModificationInstruction.L0SubType; -import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction; -import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction; -import org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSignalIdInstruction; -import org.onosproject.net.flow.instructions.L3ModificationInstruction.L3SubType; -import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction; -import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpIPInstruction; -import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpEthInstruction; -import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpOpInstruction; -import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction; -import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModTtlInstruction; -import org.onosproject.net.flow.instructions.L4ModificationInstruction.L4SubType; -import org.onosproject.net.flow.instructions.L4ModificationInstruction.ModTransportPortInstruction; -import org.onosproject.net.meter.MeterId; - -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Factory class for creating various traffic treatment instructions. - */ -public final class Instructions { - - // Ban construction - private Instructions() {} - - /** - * Creates an output instruction using the specified port number. This can - * include logical ports such as CONTROLLER, FLOOD, etc. - * - * @param number port number - * @return output instruction - */ - public static OutputInstruction createOutput(final PortNumber number) { - checkNotNull(number, "PortNumber cannot be null"); - return new OutputInstruction(number); - } - - /** - * Creates a drop instruction. - * - * @return drop instruction - */ - @Deprecated - public static DropInstruction createDrop() { - return new DropInstruction(); - } - - /** - * Creates a no action instruction. - * - * @return no action instruction - */ - public static NoActionInstruction createNoAction() { - return new NoActionInstruction(); - } - - /** - * Creates a group instruction. - * - * @param groupId Group Id - * @return group instruction - */ - public static GroupInstruction createGroup(final GroupId groupId) { - checkNotNull(groupId, "GroupId cannot be null"); - return new GroupInstruction(groupId); - } - - /** - * Creates a set-queue instruction. - * - * @param queueId Queue Id - * @param port Port number - * @return set-queue instruction - */ - public static SetQueueInstruction setQueue(final long queueId, final PortNumber port) { - checkNotNull(queueId, "queue ID cannot be null"); - return new SetQueueInstruction(queueId, port); - } - - public static MeterInstruction meterTraffic(final MeterId meterId) { - checkNotNull(meterId, "meter id cannot be null"); - return new MeterInstruction(meterId); - } - - /** - * Creates an L0 modification with the specified OCh signal. - * - * @param lambda OCh signal - * @return an L0 modification - */ - public static L0ModificationInstruction modL0Lambda(Lambda lambda) { - checkNotNull(lambda, "L0 OCh signal cannot be null"); - - if (lambda instanceof IndexedLambda) { - return new ModLambdaInstruction(L0SubType.LAMBDA, (short) ((IndexedLambda) lambda).index()); - } else if (lambda instanceof OchSignal) { - return new ModOchSignalInstruction((OchSignal) lambda); - } else { - throw new UnsupportedOperationException(String.format("Unsupported type: %s", lambda)); - } - } - - /** - * Creates an L1 modification with the specified ODU signal Id. - * - * @param oduSignalId ODU Signal Id - * @return a L1 modification - */ - public static L1ModificationInstruction modL1OduSignalId(OduSignalId oduSignalId) { - checkNotNull(oduSignalId, "L1 ODU signal ID cannot be null"); - return new ModOduSignalIdInstruction(oduSignalId); - } - /** - * Creates a l2 src modification. - * - * @param addr the mac address to modify to - * @return a l2 modification - */ - public static L2ModificationInstruction modL2Src(MacAddress addr) { - checkNotNull(addr, "Src l2 address cannot be null"); - return new L2ModificationInstruction.ModEtherInstruction( - L2ModificationInstruction.L2SubType.ETH_SRC, addr); - } - - /** - * Creates a L2 dst modification. - * - * @param addr the mac address to modify to - * @return a L2 modification - */ - public static L2ModificationInstruction modL2Dst(MacAddress addr) { - checkNotNull(addr, "Dst l2 address cannot be null"); - return new L2ModificationInstruction.ModEtherInstruction( - L2ModificationInstruction.L2SubType.ETH_DST, addr); - } - - /** - * Creates a VLAN ID modification. - * - * @param vlanId the VLAN ID to modify to - * @return a L2 modification - */ - public static L2ModificationInstruction modVlanId(VlanId vlanId) { - checkNotNull(vlanId, "VLAN id cannot be null"); - return new L2ModificationInstruction.ModVlanIdInstruction(vlanId); - } - - /** - * Creates a VLAN PCP modification. - * - * @param vlanPcp the PCP to modify to - * @return a L2 modification - */ - public static L2ModificationInstruction modVlanPcp(Byte vlanPcp) { - checkNotNull(vlanPcp, "VLAN Pcp cannot be null"); - return new L2ModificationInstruction.ModVlanPcpInstruction(vlanPcp); - } - - /** - * Creates a MPLS label modification. - * - * @param mplsLabel MPLS label to set - * @return a L2 Modification - */ - public static L2ModificationInstruction modMplsLabel(MplsLabel mplsLabel) { - checkNotNull(mplsLabel, "MPLS label cannot be null"); - return new L2ModificationInstruction.ModMplsLabelInstruction(mplsLabel); - } - - /** - * Creates a MPLS BOS bit modification. - * - * @param mplsBos MPLS BOS bit to set (true) or unset (false) - * @return a L2 Modification - */ - public static L2ModificationInstruction modMplsBos(boolean mplsBos) { - return new L2ModificationInstruction.ModMplsBosInstruction(mplsBos); - } - - /** - * Creates a MPLS decrement TTL modification. - * - * @return a L2 Modification - */ - public static L2ModificationInstruction decMplsTtl() { - return new L2ModificationInstruction.ModMplsTtlInstruction(); - } - - /** - * Creates a L3 IPv4 src modification. - * - * @param addr the IPv4 address to modify to - * @return a L3 modification - */ - public static L3ModificationInstruction modL3Src(IpAddress addr) { - checkNotNull(addr, "Src l3 IPv4 address cannot be null"); - return new ModIPInstruction(L3SubType.IPV4_SRC, addr); - } - - /** - * Creates a L3 IPv4 dst modification. - * - * @param addr the IPv4 address to modify to - * @return a L3 modification - */ - public static L3ModificationInstruction modL3Dst(IpAddress addr) { - checkNotNull(addr, "Dst l3 IPv4 address cannot be null"); - return new ModIPInstruction(L3SubType.IPV4_DST, addr); - } - - /** - * Creates a L3 IPv6 src modification. - * - * @param addr the IPv6 address to modify to - * @return a L3 modification - */ - public static L3ModificationInstruction modL3IPv6Src(IpAddress addr) { - checkNotNull(addr, "Src l3 IPv6 address cannot be null"); - return new ModIPInstruction(L3SubType.IPV6_SRC, addr); - } - - /** - * Creates a L3 IPv6 dst modification. - * - * @param addr the IPv6 address to modify to - * @return a L3 modification - */ - public static L3ModificationInstruction modL3IPv6Dst(IpAddress addr) { - checkNotNull(addr, "Dst l3 IPv6 address cannot be null"); - return new ModIPInstruction(L3SubType.IPV6_DST, addr); - } - - /** - * Creates a L3 IPv6 Flow Label modification. - * - * @param flowLabel the IPv6 flow label to modify to (20 bits) - * @return a L3 modification - */ - public static L3ModificationInstruction modL3IPv6FlowLabel(int flowLabel) { - return new ModIPv6FlowLabelInstruction(flowLabel); - } - - /** - * Creates a L3 decrement TTL modification. - * - * @return a L3 modification - */ - public static L3ModificationInstruction decNwTtl() { - return new ModTtlInstruction(L3SubType.DEC_TTL); - } - - /** - * Creates a L3 copy TTL to outer header modification. - * - * @return a L3 modification - */ - public static L3ModificationInstruction copyTtlOut() { - return new ModTtlInstruction(L3SubType.TTL_OUT); - } - - /** - * Creates a L3 copy TTL to inner header modification. - * - * @return a L3 modification - */ - public static L3ModificationInstruction copyTtlIn() { - return new ModTtlInstruction(L3SubType.TTL_IN); - } - - /** - * Creates a L3 ARP IP src modification. - * - * @param addr the ip address to modify to - * @return a L3 modification - */ - public static L3ModificationInstruction modArpSpa(IpAddress addr) { - checkNotNull(addr, "Src l3 ARP IP address cannot be null"); - return new ModArpIPInstruction(L3SubType.ARP_SPA, addr); - } - - /** - * Creates a l3 ARP Ether src modification. - * - * @param addr the mac address to modify to - * @return a l3 modification - */ - public static L3ModificationInstruction modArpSha(MacAddress addr) { - checkNotNull(addr, "Src l3 ARP address cannot be null"); - return new ModArpEthInstruction(L3SubType.ARP_SHA, addr); - } - - /** - * Creates a l3 ARP operation modification. - * - * @param op the ARP operation to modify to - * @return a l3 modification - */ - public static L3ModificationInstruction modL3ArpOp(short op) { - checkNotNull(op, "Arp operation cannot be null"); - return new ModArpOpInstruction(L3SubType.ARP_OP, op); - } - - /** - * Creates a push MPLS header instruction. - * - * @return a L2 modification. - */ - public static Instruction pushMpls() { - return new L2ModificationInstruction.PushHeaderInstructions( - L2ModificationInstruction.L2SubType.MPLS_PUSH, - EthType.EtherType.MPLS_UNICAST.ethType()); - } - - /** - * Creates a pop MPLS header instruction. - * - * @return a L2 modification. - */ - public static Instruction popMpls() { - return new L2ModificationInstruction.PushHeaderInstructions( - L2ModificationInstruction.L2SubType.MPLS_POP, - EthType.EtherType.MPLS_UNICAST.ethType()); - } - - /** - * Creates a pop MPLS header instruction with a particular ethertype. - * - * @param etherType Ethernet type to set - * @return a L2 modification. - */ - public static Instruction popMpls(EthType etherType) { - checkNotNull(etherType, "Ethernet type cannot be null"); - return new L2ModificationInstruction.PushHeaderInstructions( - L2ModificationInstruction.L2SubType.MPLS_POP, etherType); - } - - /** - * Creates a pop VLAN header instruction. - * - * @return a L2 modification - */ - public static Instruction popVlan() { - return new L2ModificationInstruction.PopVlanInstruction( - L2ModificationInstruction.L2SubType.VLAN_POP); - } - - /** - * Creates a push VLAN header instruction. - * - * @return a L2 modification - */ - public static Instruction pushVlan() { - return new L2ModificationInstruction.PushHeaderInstructions( - L2ModificationInstruction.L2SubType.VLAN_PUSH, - EthType.EtherType.VLAN.ethType()); - } - - /** - * Sends the packet to the table id. - * - * @param tableId flow rule table id - * @return table type transition instruction - */ - public static Instruction transition(Integer tableId) { - checkNotNull(tableId, "Table id cannot be null"); - return new TableTypeTransition(tableId); - } - - /** - * Writes metadata to associate with a packet. - * - * @param metadata the metadata value to write - * @param metadataMask the bits to mask for the metadata value - * @return metadata instruction - */ - public static Instruction writeMetadata(long metadata, long metadataMask) { - return new MetadataInstruction(metadata, metadataMask); - } - - /** - * Creates a Tunnel ID modification. - * - * @param tunnelId the Tunnel ID to modify to - * @return a L2 modification - */ - public static L2ModificationInstruction modTunnelId(long tunnelId) { - checkNotNull(tunnelId, "Tunnel id cannot be null"); - return new L2ModificationInstruction.ModTunnelIdInstruction(tunnelId); - } - - /** - * Creates a TCP src modification. - * - * @param port the TCP port number to modify to - * @return a L4 modification - * @deprecated in Drake release - */ - @Deprecated - public static L4ModificationInstruction modTcpSrc(short port) { - checkNotNull(port, "Src TCP port cannot be null"); - return new ModTransportPortInstruction(L4SubType.TCP_SRC, TpPort.tpPort(port)); - } - - /** - * Creates a TCP src modification. - * - * @param port the TCP port number to modify to - * @return a L4 modification - */ - public static L4ModificationInstruction modTcpSrc(TpPort port) { - checkNotNull(port, "Src TCP port cannot be null"); - return new ModTransportPortInstruction(L4SubType.TCP_SRC, port); - } - - /** - * Creates a TCP dst modification. - * - * @param port the TCP port number to modify to - * @return a L4 modification - * @deprecated in Drake release - */ - @Deprecated - public static L4ModificationInstruction modTcpDst(short port) { - checkNotNull(port, "Dst TCP port cannot be null"); - return new ModTransportPortInstruction(L4SubType.TCP_DST, TpPort.tpPort(port)); - } - - /** - * Creates a TCP dst modification. - * - * @param port the TCP port number to modify to - * @return a L4 modification - */ - public static L4ModificationInstruction modTcpDst(TpPort port) { - checkNotNull(port, "Dst TCP port cannot be null"); - return new ModTransportPortInstruction(L4SubType.TCP_DST, port); - } - - /** - * Creates a UDP src modification. - * - * @param port the UDP port number to modify to - * @return a L4 modification - * @deprecated in Drake release - */ - @Deprecated - public static L4ModificationInstruction modUdpSrc(short port) { - checkNotNull(port, "Src UDP port cannot be null"); - return new ModTransportPortInstruction(L4SubType.UDP_SRC, TpPort.tpPort(port)); - } - - /** - * Creates a UDP src modification. - * - * @param port the UDP port number to modify to - * @return a L4 modification - */ - public static L4ModificationInstruction modUdpSrc(TpPort port) { - checkNotNull(port, "Src UDP port cannot be null"); - return new ModTransportPortInstruction(L4SubType.UDP_SRC, port); - } - - /** - * Creates a UDP dst modification. - * - * @param port the UDP port number to modify to - * @return a L4 modification - * @deprecated in Drake release - */ - @Deprecated - public static L4ModificationInstruction modUdpDst(short port) { - checkNotNull(port, "Dst UDP port cannot be null"); - return new ModTransportPortInstruction(L4SubType.UDP_DST, TpPort.tpPort(port)); - } - - /** - * Creates a UDP dst modification. - * - * @param port the UDP port number to modify to - * @return a L4 modification - */ - public static L4ModificationInstruction modUdpDst(TpPort port) { - checkNotNull(port, "Dst UDP port cannot be null"); - return new ModTransportPortInstruction(L4SubType.UDP_DST, port); - } - - /** - * Creates an extension instruction. - * - * @param extension extension instruction - * @param deviceId device ID - * @return extension instruction - */ - public static ExtensionInstructionWrapper extension(ExtensionTreatment extension, - DeviceId deviceId) { - checkNotNull(extension, "Extension instruction cannot be null"); - checkNotNull(deviceId, "Device ID cannot be null"); - return new ExtensionInstructionWrapper(extension, deviceId); - } - - /** - * Drop instruction. - */ - @Deprecated - public static final class DropInstruction implements Instruction { - - private DropInstruction() {} - - @Override - public Type type() { - return Type.DROP; - } - - @Override - public String toString() { - return toStringHelper(type().toString()).toString(); - } - - @Override - public int hashCode() { - return type().ordinal(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof DropInstruction) { - return true; - } - return false; - } - } - - /** - * No Action instruction. - */ - public static final class NoActionInstruction implements Instruction { - - private NoActionInstruction() {} - - @Override - public Type type() { - return Type.NOACTION; - } - - @Override - public String toString() { - return toStringHelper(type().toString()).toString(); - } - - @Override - public int hashCode() { - return type().ordinal(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof NoActionInstruction) { - return true; - } - return false; - } - } - - /** - * Output Instruction. - */ - public static final class OutputInstruction implements Instruction { - private final PortNumber port; - - private OutputInstruction(PortNumber port) { - this.port = port; - } - - public PortNumber port() { - return port; - } - - @Override - public Type type() { - return Type.OUTPUT; - } - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("port", port).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), port); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof OutputInstruction) { - OutputInstruction that = (OutputInstruction) obj; - return Objects.equals(port, that.port); - - } - return false; - } - } - - /** - * Group Instruction. - */ - public static final class GroupInstruction implements Instruction { - private final GroupId groupId; - - private GroupInstruction(GroupId groupId) { - this.groupId = groupId; - } - - public GroupId groupId() { - return groupId; - } - - @Override - public Type type() { - return Type.GROUP; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .addValue("group ID=0x" + Integer.toHexString(groupId.id())) - .toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), groupId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof GroupInstruction) { - GroupInstruction that = (GroupInstruction) obj; - return Objects.equals(groupId, that.groupId); - - } - return false; - } - } - - /** - * Set-Queue Instruction. - */ - public static final class SetQueueInstruction implements Instruction { - private final long queueId; - private final PortNumber port; - - private SetQueueInstruction(long queueId) { - this.queueId = queueId; - this.port = null; - } - - private SetQueueInstruction(long queueId, PortNumber port) { - this.queueId = queueId; - this.port = port; - } - - public long queueId() { - return queueId; - } - - public PortNumber port() { - return port; - } - - @Override - public Type type() { - return Type.QUEUE; - } - - @Override - public String toString() { - MoreObjects.ToStringHelper toStringHelper = toStringHelper(type().toString()); - toStringHelper.add("queueId", queueId); - - if (port() != null) { - toStringHelper.add("port", port); - } - return toStringHelper.toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), queueId, port); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof SetQueueInstruction) { - SetQueueInstruction that = (SetQueueInstruction) obj; - return Objects.equals(queueId, that.queueId) && Objects.equals(port, that.port); - - } - return false; - } - } - - /** - * A meter instruction. - */ - public static final class MeterInstruction implements Instruction { - private final MeterId meterId; - - private MeterInstruction(MeterId meterId) { - this.meterId = meterId; - } - - public MeterId meterId() { - return meterId; - } - - @Override - public Type type() { - return Type.METER; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("meter ID", meterId.id()).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), meterId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof MeterInstruction) { - MeterInstruction that = (MeterInstruction) obj; - return Objects.equals(meterId, that.meterId); - - } - return false; - } - } - - /** - * Transition instruction. - */ - public static class TableTypeTransition implements Instruction { - private final Integer tableId; - - TableTypeTransition(Integer tableId) { - this.tableId = tableId; - } - - @Override - public Type type() { - return Type.TABLE; - } - - public Integer tableId() { - return this.tableId; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("tableId", this.tableId).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), tableId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof TableTypeTransition) { - TableTypeTransition that = (TableTypeTransition) obj; - return Objects.equals(tableId, that.tableId); - - } - return false; - } - } - - /** - * Metadata instruction. - */ - public static class MetadataInstruction implements Instruction { - private final long metadata; - private final long metadataMask; - - MetadataInstruction(long metadata, long metadataMask) { - this.metadata = metadata; - this.metadataMask = metadataMask; - } - - @Override - public Type type() { - return Type.METADATA; - } - - public long metadata() { - return this.metadata; - } - - public long metadataMask() { - return this.metadataMask; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("metadata", Long.toHexString(this.metadata)) - .add("metadata mask", Long.toHexString(this.metadataMask)) - .toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), metadata, metadataMask); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof MetadataInstruction) { - MetadataInstruction that = (MetadataInstruction) obj; - return Objects.equals(metadata, that.metadata) && - Objects.equals(metadataMask, that.metadataMask); - - } - return false; - } - } - - /** - * Extension instruction. - */ - public static class ExtensionInstructionWrapper implements Instruction { - private final ExtensionTreatment extensionTreatment; - private final DeviceId deviceId; - - ExtensionInstructionWrapper(ExtensionTreatment extension, DeviceId deviceId) { - extensionTreatment = extension; - this.deviceId = deviceId; - } - - public ExtensionTreatment extensionInstruction() { - return extensionTreatment; - } - - public DeviceId deviceId() { - return deviceId; - } - - @Override - public Type type() { - return Type.EXTENSION; - } - - @Override - public String toString() { - return toStringHelper(type().toString()) - .add("extension", extensionTreatment) - .add("deviceId", deviceId) - .toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type().ordinal(), extensionTreatment, deviceId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ExtensionInstructionWrapper) { - ExtensionInstructionWrapper that = (ExtensionInstructionWrapper) obj; - return Objects.equals(extensionTreatment, that.extensionTreatment) - && Objects.equals(deviceId, that.deviceId); - - } - return false; - } - } - -} - - diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java deleted file mode 100644 index 4af3d168..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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.flow.instructions; - -import com.google.common.base.MoreObjects; -import org.onosproject.net.OchSignal; - -import static com.google.common.base.MoreObjects.toStringHelper; - -import java.util.Objects; - -public abstract class L0ModificationInstruction implements Instruction { - - /** - * Represents the type of traffic treatment. - */ - public enum L0SubType { - /** - * Lambda modification. - */ - LAMBDA, - /** - * OCh (Optical Channel) modification. - */ - OCH, - } - - public abstract L0SubType subtype(); - - @Override - public final Type type() { - return Type.L0MODIFICATION; - } - - /** - * Represents a L0 lambda modification instruction. - */ - public static final class ModLambdaInstruction extends L0ModificationInstruction { - - private final L0SubType subtype; - private final short lambda; - - ModLambdaInstruction(L0SubType subType, short lambda) { - this.subtype = subType; - this.lambda = lambda; - } - - @Override - public L0SubType subtype() { - return this.subtype; - } - - public short lambda() { - return this.lambda; - } - - @Override - public String toString() { - return toStringHelper(subtype().toString()) - .add("lambda", lambda).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type(), subtype, lambda); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ModLambdaInstruction) { - ModLambdaInstruction that = (ModLambdaInstruction) obj; - return Objects.equals(lambda, that.lambda) && - Objects.equals(subtype, that.subtype); - } - return false; - } - } - - /** - * Represents an L0 OCh (Optical Channel) modification instruction. - */ - public static final class ModOchSignalInstruction extends L0ModificationInstruction { - - private final OchSignal lambda; - - ModOchSignalInstruction(OchSignal lambda) { - this.lambda = lambda; - } - - @Override - public L0SubType subtype() { - return L0SubType.OCH; - } - - public OchSignal lambda() { - return lambda; - } - - @Override - public int hashCode() { - return lambda.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof ModOchSignalInstruction)) { - return false; - } - final ModOchSignalInstruction that = (ModOchSignalInstruction) obj; - return Objects.equals(this.lambda, that.lambda); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("lambda", lambda) - .toString(); - } - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java deleted file mode 100644 index b72dd7bc..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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.flow.instructions; - -import org.onosproject.net.OduSignalId; - -import static com.google.common.base.MoreObjects.toStringHelper; - -import java.util.Objects; - -public abstract class L1ModificationInstruction implements Instruction { - - /** - * Represents the type of traffic treatment. - */ - public enum L1SubType { - /** - * ODU (Optical channel Data Unit) Signal Id modification. - */ - ODU_SIGID - } - - public abstract L1SubType subtype(); - - @Override - public final Type type() { - return Type.L1MODIFICATION; - } - - /** - * Represents an L1 ODU (Optical channel Data Unit) Signal Id modification instruction. - */ - public static final class ModOduSignalIdInstruction extends L1ModificationInstruction { - - private final OduSignalId oduSignalId; - - ModOduSignalIdInstruction(OduSignalId oduSignalId) { - this.oduSignalId = oduSignalId; - } - - @Override - public L1SubType subtype() { - return L1SubType.ODU_SIGID; - } - - public OduSignalId oduSignalId() { - return oduSignalId; - } - - @Override - public int hashCode() { - return oduSignalId.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof ModOduSignalIdInstruction)) { - return false; - } - final ModOduSignalIdInstruction that = (ModOduSignalIdInstruction) obj; - return Objects.equals(this.oduSignalId, that.oduSignalId); - } - - @Override - public String toString() { - return toStringHelper(this) - .add("oduSignalId", oduSignalId) - .toString(); - } - } - -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L2ModificationInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L2ModificationInstruction.java deleted file mode 100644 index 0dbbb451..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L2ModificationInstruction.java +++ /dev/null @@ -1,517 +0,0 @@ -/* - * 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.flow.instructions; - -import org.onlab.packet.EthType; -import org.onlab.packet.MacAddress; -import org.onlab.packet.MplsLabel; -import org.onlab.packet.VlanId; - -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; - -/** - * Abstraction of a single traffic treatment step. - */ -public abstract class L2ModificationInstruction implements Instruction { - - /** - * Represents the type of traffic treatment. - */ - public enum L2SubType { - /** - * Ether src modification. - */ - ETH_SRC, - - /** - * Ether dst modification. - */ - ETH_DST, - - /** - * VLAN id modification. - */ - VLAN_ID, - - /** - * VLAN priority modification. - */ - VLAN_PCP, - - /** - * MPLS Label modification. - */ - MPLS_LABEL, - - /** - * MPLS Push modification. - */ - MPLS_PUSH, - - /** - * MPLS Pop modification. - */ - MPLS_POP, - - /** - * MPLS TTL modification. - */ - DEC_MPLS_TTL, - - /** - * VLAN Pop modification. - */ - VLAN_POP, - - /** - * VLAN Push modification. - */ - VLAN_PUSH, - - /** - * Tunnel id modification. - */ - TUNNEL_ID, - - /** - * MPLS BOS instruction. - */ - MPLS_BOS - } - - // TODO: Create factory class 'Instructions' that will have various factory - // to create specific instructions. - - public abstract L2SubType subtype(); - - @Override - public final Type type() { - return Type.L2MODIFICATION; - } - - /** - * Represents a L2 src/dst modification instruction. - */ - public static final class ModEtherInstruction extends L2ModificationInstruction { - - private final L2SubType subtype; - private final MacAddress mac; - - ModEtherInstruction(L2SubType subType, MacAddress addr) { - - this.subtype = subType; - this.mac = addr; - } - - @Override - public L2SubType subtype() { - return this.subtype; - } - - public MacAddress mac() { - return this.mac; - } - - @Override - public String toString() { - return toStringHelper(subtype().toString()) - .add("mac", mac).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type(), subtype, mac); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ModEtherInstruction) { - ModEtherInstruction that = (ModEtherInstruction) obj; - return Objects.equals(mac, that.mac) && - Objects.equals(subtype, that.subtype); - } - return false; - } - } - - // TODO This instruction is reused for Pop-Mpls. Consider renaming. - public static final class PushHeaderInstructions extends - L2ModificationInstruction { - - - private final L2SubType subtype; - private final EthType ethernetType; // Ethernet type value: 16 bits - - PushHeaderInstructions(L2SubType subType, EthType ethernetType) { - this.subtype = subType; - this.ethernetType = ethernetType; - } - - public EthType ethernetType() { - return ethernetType; - } - - @Override - public L2SubType subtype() { - return this.subtype; - } - - @Override - public String toString() { - return toStringHelper(subtype().toString()) - .add("ethernetType", ethernetType()) - .toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type(), subtype, ethernetType); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof PushHeaderInstructions) { - PushHeaderInstructions that = (PushHeaderInstructions) obj; - return Objects.equals(subtype, that.subtype) && - Objects.equals(this.ethernetType, that.ethernetType); - } - return false; - } - } - - - - /** - * Represents a VLAN id modification instruction. - */ - public static final class ModVlanIdInstruction extends L2ModificationInstruction { - - private final VlanId vlanId; - - ModVlanIdInstruction(VlanId vlanId) { - this.vlanId = vlanId; - } - - @Override - public L2SubType subtype() { - return L2SubType.VLAN_ID; - } - - public VlanId vlanId() { - return this.vlanId; - } - - @Override - public String toString() { - return toStringHelper(subtype().toString()) - .add("id", vlanId).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type(), subtype(), vlanId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ModVlanIdInstruction) { - ModVlanIdInstruction that = (ModVlanIdInstruction) obj; - return Objects.equals(vlanId, that.vlanId); - } - return false; - } - } - - /** - * Represents a VLAN PCP modification instruction. - */ - public static final class ModVlanPcpInstruction extends L2ModificationInstruction { - - private static final byte MASK = 0x7; - private final byte vlanPcp; - - ModVlanPcpInstruction(byte vlanPcp) { - this.vlanPcp = (byte) (vlanPcp & MASK); - } - - @Override - public L2SubType subtype() { - return L2SubType.VLAN_PCP; - } - - public byte vlanPcp() { - return this.vlanPcp; - } - - @Override - public String toString() { - return toStringHelper(subtype().toString()) - .add("pcp", Long.toHexString(vlanPcp)).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type(), subtype(), vlanPcp); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ModVlanPcpInstruction) { - ModVlanPcpInstruction that = (ModVlanPcpInstruction) obj; - return Objects.equals(vlanPcp, that.vlanPcp); - } - return false; - } - } - - /** - * Represents a VLAN POP modification instruction. - */ - public static final class PopVlanInstruction extends L2ModificationInstruction { - private final L2SubType subtype; - - PopVlanInstruction(L2SubType subType) { - this.subtype = subType; - } - - @Override - public L2SubType subtype() { - return subtype; - } - - @Override - public String toString() { - return toStringHelper(subtype().toString()) - .toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type(), subtype); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof PopVlanInstruction) { - PopVlanInstruction that = (PopVlanInstruction) obj; - return Objects.equals(subtype, that.subtype); - } - return false; - } - } - - /** - * Represents a MPLS label modification. - */ - public static final class ModMplsLabelInstruction - extends L2ModificationInstruction { - - private final MplsLabel mplsLabel; - - ModMplsLabelInstruction(MplsLabel mplsLabel) { - this.mplsLabel = mplsLabel; - } - - /** - * @deprecated in Drake Release. - * @return integer value of label - */ - // Consider changing return value to MplsLabel - // after deprecation process so that it'll be symmetric to - // MplsCriterion#label() - @Deprecated - public Integer label() { - return mplsLabel.toInt(); - } - - public MplsLabel mplsLabel() { - return mplsLabel; - } - - @Override - public L2SubType subtype() { - return L2SubType.MPLS_LABEL; - } - - @Override - public String toString() { - return toStringHelper(subtype().toString()) - .add("mpls", mplsLabel).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type(), subtype(), mplsLabel); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ModMplsLabelInstruction) { - ModMplsLabelInstruction that = (ModMplsLabelInstruction) obj; - return Objects.equals(mplsLabel, that.mplsLabel); - } - return false; - } - } - - /** - * Represents a MPLS BOS modification. - */ - public static final class ModMplsBosInstruction - extends L2ModificationInstruction { - - private final boolean mplsBos; - - ModMplsBosInstruction(boolean mplsBos) { - this.mplsBos = mplsBos; - } - - public boolean mplsBos() { - return mplsBos; - } - - @Override - public L2SubType subtype() { - return L2SubType.MPLS_BOS; - } - - @Override - public String toString() { - return toStringHelper(subtype().toString()).add("bos", mplsBos) - .toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type(), subtype(), mplsBos); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ModMplsBosInstruction) { - ModMplsBosInstruction that = (ModMplsBosInstruction) obj; - return Objects.equals(mplsBos, that.mplsBos()); - } - return false; - } - } - - /** - * Represents a MPLS TTL modification. - */ - public static final class ModMplsTtlInstruction - extends L2ModificationInstruction { - - ModMplsTtlInstruction() { - } - - @Override - public L2SubType subtype() { - return L2SubType.DEC_MPLS_TTL; - } - - @Override - public String toString() { - return toStringHelper(subtype().toString()) - .toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type(), subtype()); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ModMplsTtlInstruction) { - return true; - } - return false; - } - } - - /** - * Represents a Tunnel id modification. - */ - public static final class ModTunnelIdInstruction - extends L2ModificationInstruction { - - private final long tunnelId; - - ModTunnelIdInstruction(long tunnelId) { - this.tunnelId = tunnelId; - } - - public long tunnelId() { - return this.tunnelId; - } - - @Override - public L2SubType subtype() { - return L2SubType.TUNNEL_ID; - } - - @Override - public String toString() { - return toStringHelper(subtype().toString()) - .add("id", Long.toHexString(tunnelId)) - .toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type(), subtype(), tunnelId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ModTunnelIdInstruction) { - ModTunnelIdInstruction that = (ModTunnelIdInstruction) obj; - return Objects.equals(tunnelId, that.tunnelId); - } - return false; - } - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L3ModificationInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L3ModificationInstruction.java deleted file mode 100644 index 0efe9a77..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L3ModificationInstruction.java +++ /dev/null @@ -1,391 +0,0 @@ -/* - * 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.flow.instructions; - -import static com.google.common.base.MoreObjects.toStringHelper; - -import java.util.Objects; - -import org.onlab.packet.IpAddress; -import org.onlab.packet.MacAddress; - -/** - * Abstraction of a single traffic treatment step. - */ -public abstract class L3ModificationInstruction implements Instruction { - - /** - * Represents the type of traffic treatment. - */ - public enum L3SubType { - /** - * IPv4 src modification. - */ - IPV4_SRC, - - /** - * IPv4 dst modification. - */ - IPV4_DST, - - /** - * IPv6 src modification. - */ - IPV6_SRC, - - /** - * IPv6 dst modification. - */ - IPV6_DST, - - /** - * IPv6 flow label modification. - */ - IPV6_FLABEL, - - /** - * Decrement TTL. - */ - DEC_TTL, - - /** - * Copy TTL out. - */ - TTL_OUT, - - /** - * Copy TTL in. - */ - TTL_IN, - - /** - * ARP IP src modification. - */ - ARP_SPA, - - /** - * ARP Ether src modification. - */ - ARP_SHA, - - /** - * Arp operation modification. - */ - ARP_OP - - //TODO: remaining types - } - - /** - * Returns the subtype of the modification instruction. - * @return type of instruction - */ - public abstract L3SubType subtype(); - - @Override - public final Type type() { - return Type.L3MODIFICATION; - } - - /** - * Represents a L3 src/dst modification instruction. - */ - public static final class ModIPInstruction extends L3ModificationInstruction { - - private final L3SubType subtype; - private final IpAddress ip; - - ModIPInstruction(L3SubType subType, IpAddress addr) { - - this.subtype = subType; - this.ip = addr; - } - - @Override - public L3SubType subtype() { - return this.subtype; - } - - public IpAddress ip() { - return this.ip; - } - - @Override - public String toString() { - return toStringHelper(subtype().toString()) - .add("ip", ip).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type(), subtype(), ip); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ModIPInstruction) { - ModIPInstruction that = (ModIPInstruction) obj; - return Objects.equals(ip, that.ip) && - Objects.equals(this.subtype(), that.subtype()); - } - return false; - } - } - - /** - * Represents a L3 ARP IP src/dst modification instruction. - */ - public static final class ModArpIPInstruction extends L3ModificationInstruction { - - private final L3SubType subtype; - private final IpAddress ip; - - ModArpIPInstruction(L3SubType subType, IpAddress addr) { - - this.subtype = subType; - this.ip = addr; - } - - @Override - public L3SubType subtype() { - return this.subtype; - } - - public IpAddress ip() { - return this.ip; - } - - @Override - public String toString() { - return toStringHelper(subtype().toString()) - .add("ip", ip).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type(), subtype(), ip); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ModArpIPInstruction) { - ModArpIPInstruction that = (ModArpIPInstruction) obj; - return Objects.equals(ip, that.ip) && - Objects.equals(this.subtype(), that.subtype()); - } - return false; - } - } - - /** - * Represents a L3 ARP Ether src/dst modification instruction. - */ - public static final class ModArpEthInstruction extends L3ModificationInstruction { - - private final L3SubType subtype; - private final MacAddress mac; - - ModArpEthInstruction(L3SubType subType, MacAddress addr) { - - this.subtype = subType; - this.mac = addr; - } - - @Override - public L3SubType subtype() { - return this.subtype; - } - - public MacAddress mac() { - return this.mac; - } - - @Override - public String toString() { - return toStringHelper(subtype().toString()) - .add("mac", mac).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type(), subtype(), mac); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ModArpEthInstruction) { - ModArpEthInstruction that = (ModArpEthInstruction) obj; - return Objects.equals(mac, that.mac) && - Objects.equals(this.subtype(), that.subtype()); - } - return false; - } - } - - /** - * Represents a L3 ARP operation modification instruction. - */ - public static final class ModArpOpInstruction extends L3ModificationInstruction { - - private final L3SubType subtype; - private final short op; - - ModArpOpInstruction(L3SubType subType, short op) { - - this.subtype = subType; - this.op = op; - } - - @Override - public L3SubType subtype() { - return this.subtype; - } - - public long op() { - return this.op; - } - - @Override - public String toString() { - return toStringHelper(subtype().toString()) - .add("op", op).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type(), subtype(), op); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ModArpOpInstruction) { - ModArpOpInstruction that = (ModArpOpInstruction) obj; - return Objects.equals(op, that.op) && - Objects.equals(this.subtype(), that.subtype()); - } - return false; - } - } - - /** - * Represents a L3 IPv6 Flow Label (RFC 6437) modification instruction - * (20 bits unsigned integer). - */ - public static final class ModIPv6FlowLabelInstruction - extends L3ModificationInstruction { - private static final int MASK = 0xfffff; - private final int flowLabel; // IPv6 flow label: 20 bits - - /** - * Creates a new flow mod instruction. - * - * @param flowLabel the IPv6 flow label to set in the treatment (20 bits) - */ - ModIPv6FlowLabelInstruction(int flowLabel) { - this.flowLabel = flowLabel & MASK; - } - - @Override - public L3SubType subtype() { - return L3SubType.IPV6_FLABEL; - } - - /** - * Gets the IPv6 flow label to set in the treatment. - * - * @return the IPv6 flow label to set in the treatment (20 bits) - */ - public int flowLabel() { - return this.flowLabel; - } - - @Override - public String toString() { - return toStringHelper(subtype().toString()) - .add("flowLabel", Long.toHexString(flowLabel)).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type(), subtype(), flowLabel); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ModIPv6FlowLabelInstruction) { - ModIPv6FlowLabelInstruction that = - (ModIPv6FlowLabelInstruction) obj; - return Objects.equals(flowLabel, that.flowLabel); - } - return false; - } - } - - /** - * Represents a L3 TTL modification instruction. - */ - public static final class ModTtlInstruction extends L3ModificationInstruction { - - private final L3SubType subtype; - - ModTtlInstruction(L3SubType subtype) { - this.subtype = subtype; - } - - @Override - public L3SubType subtype() { - return this.subtype; - } - - @Override - public String toString() { - return toStringHelper(subtype().toString()) - .toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type(), subtype()); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ModTtlInstruction) { - ModTtlInstruction that = (ModTtlInstruction) obj; - return Objects.equals(this.subtype(), that.subtype()); - } - return false; - } - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L4ModificationInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L4ModificationInstruction.java deleted file mode 100644 index 441a2c5f..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L4ModificationInstruction.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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.flow.instructions; - -import org.onlab.packet.TpPort; - -import java.util.Objects; - -import static com.google.common.base.MoreObjects.toStringHelper; - -/** - * Abstraction of a single traffic treatment step. - */ -public abstract class L4ModificationInstruction implements Instruction { - - /** - * Represents the type of traffic treatment. - */ - public enum L4SubType { - /** - * TCP src modification. - */ - TCP_SRC, - - /** - * TCP dst modification. - */ - TCP_DST, - - /** - * UDP src modification. - */ - UDP_SRC, - - /** - * UDP dst modification. - */ - UDP_DST - - //TODO: remaining types - } - - /** - * Returns the subtype of the modification instruction. - * - * @return type of instruction - */ - public abstract L4SubType subtype(); - - @Override - public Type type() { - return Type.L4MODIFICATION; - } - - /** - * Represents a L4 src/dst modification instruction. - */ - public static final class ModTransportPortInstruction extends L4ModificationInstruction { - - private final L4SubType subtype; - private final TpPort port; - - public ModTransportPortInstruction(L4SubType subtype, TpPort port) { - this.subtype = subtype; - this.port = port; - } - - @Override - public L4SubType subtype() { - return this.subtype; - } - - public TpPort port() { - return this.port; - } - - @Override - public String toString() { - return toStringHelper(subtype().toString()) - .add("port", port).toString(); - } - - @Override - public int hashCode() { - return Objects.hash(type(), subtype(), port); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ModTransportPortInstruction) { - ModTransportPortInstruction that = (ModTransportPortInstruction) obj; - return Objects.equals(port, that.port) && - Objects.equals(this.subtype(), that.subtype()); - } - return false; - } - } -} diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/package-info.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/package-info.java deleted file mode 100644 index 65f58a40..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2014 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. - */ - -/** - * Traffic treatment model. - */ -package org.onosproject.net.flow.instructions; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/package-info.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/package-info.java deleted file mode 100644 index 6068b6f2..00000000 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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. - */ - -/** - * Flow rule model & related services API definitions. - * - * <p> - * The figure below depicts the general interactions between different - * components of the intent subsystem.<br> - * <img src="doc-files/flow-design.png" alt="ONOS flow rule subsystem design"> - * </p> - */ -package org.onosproject.net.flow; |