jcc
Committed by Thomas Vachuska

FlowRule private extension refactor.

1.merge private flow into regular flowrule subsystem.no mirror code any
more.no change flowrule api.
2.define a rich-data-type to carry private flow.
3.modify OpenFlowRuleProvider.class to support for 3rd party private
flow.i don't know whether is suitable.because this class name is
relative with open flow protocal.
4.fix some junit test bug caused by modification of FlowRule interface.

Change-Id: I6c54d1e97f231a75bd1b416f0893e0379613d7ce
Showing 25 changed files with 285 additions and 618 deletions
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>onos-apps</artifactId>
<groupId>org.onosproject</groupId>
<version>1.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-app-segmentrouting</artifactId>
<packaging>bundle</packaging>
<description>Segment routing application</description>
<properties>
<onos.app.name>org.onosproject.segmentrouting</onos.app.name>
</properties>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>onos-apps</artifactId>
<groupId>org.onosproject</groupId>
<version>1.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-app-segmentrouting</artifactId>
<packaging>bundle</packaging>
<description>Segment routing application</description>
<properties>
<onos.app.name>org.onosproject.segmentrouting</onos.app.name>
</properties>
</project>
......
/*
* Copyright 2014-2015 Open Networking Laboratory
* 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.
......@@ -20,8 +20,8 @@ import org.onosproject.core.GroupId;
import org.onosproject.net.DeviceId;
/**
* Represents a generalized match &amp; action pair to be applied to
* an infrastructure device.
* Represents a generalized match &amp; action pair to be applied to an
* infrastructure device.
*/
public interface FlowRule {
......@@ -29,14 +29,16 @@ public interface FlowRule {
static final int MIN_PRIORITY = 0;
/**
* The FlowRule type is used to determine in which table the flow rule
* needs to be put for multi-table support switch.
* For single table switch, Default is used.
* The FlowRule type is used to determine in which table the flow rule needs
* to be put for multi-table support switch. For single table switch,
* Default is used.
*/
@Deprecated
public static enum Type {
/* Default type - used in flow rule for single table switch
* NOTE: this setting should not be used as Table 0 in a multi-table pipeline*/
/*
* Default type - used in flow rule for single table switch NOTE: this
* setting should not be used as Table 0 in a multi-table pipeline
*/
DEFAULT,
/* Used in flow entry for IP table */
IP,
......@@ -98,8 +100,8 @@ public interface FlowRule {
DeviceId deviceId();
/**
* Returns the traffic selector that identifies what traffic this
* rule should apply to.
* Returns the traffic selector that identifies what traffic this rule
* should apply to.
*
* @return traffic selector
*/
......@@ -224,4 +226,10 @@ public interface FlowRule {
}
/**
* Returns the third party original flow rule.
*
* @return FlowRuleExtPayLoad
*/
FlowRuleExtPayLoad payLoad();
}
......
package org.onosproject.net.flow;
import static com.google.common.base.MoreObjects.toStringHelper;
import java.util.Arrays;
import java.util.Objects;
/**
* 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
* @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 Objects.hash(payLoad);
}
public int hash() {
return Objects.hash(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();
}
}
/*
* 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.flowext;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.DefaultGroupId;
import org.onosproject.core.GroupId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.flow.DefaultFlowRule;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import java.util.Objects;
import static com.google.common.base.MoreObjects.toStringHelper;
/**
* Experimental extension to the flow rule subsystem; still under development.
* A temporary flow rule extend implementation, It will cover current onos flow rule and other flow extension.
*/
public class DefaultFlowRuleExt
extends DefaultFlowRule implements FlowRuleExt {
private FlowEntryExtension flowEntryExtension;
public DefaultFlowRuleExt(DeviceId deviceId, TrafficSelector selector,
TrafficTreatment treatment, int priority, long flowId,
int timeout, boolean permanent) {
super(deviceId, selector, treatment, priority, flowId, timeout, permanent);
}
public DefaultFlowRuleExt(DeviceId deviceId, TrafficSelector selector,
TrafficTreatment treatment, int priority, ApplicationId appId,
int timeout, boolean permanent) {
this(deviceId, selector, treatment, priority, appId, new DefaultGroupId(0),
timeout, permanent);
}
public DefaultFlowRuleExt(DeviceId deviceId, TrafficSelector selector,
TrafficTreatment treatment, int priority, ApplicationId appId,
GroupId groupId, int timeout, boolean permanent) {
super(deviceId, selector, treatment, priority, appId, groupId, timeout, permanent);
}
public DefaultFlowRuleExt(FlowRule rule) {
super(rule);
}
public DefaultFlowRuleExt(ApplicationId appId, DeviceId deviceId, FlowEntryExtension data) {
this(deviceId, null, null, FlowRule.MIN_PRIORITY, appId, 0, false);
this.flowEntryExtension = data;
}
@Override
public FlowEntryExtension getFlowEntryExt() {
return this.flowEntryExtension;
}
@Override
public int hashCode() {
return 31 * super.hashCode() + Objects.hash(flowEntryExtension);
}
public int hash() {
return 31 * super.hashCode() + Objects.hash(flowEntryExtension);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
if (!super.equals(obj)) {
return false;
}
final DefaultFlowRuleExt other = (DefaultFlowRuleExt) obj;
return Objects.equals(this.flowEntryExtension, other.flowEntryExtension);
}
@Override
public String toString() {
return toStringHelper(this)
// TODO there might be a better way to grab super's string
.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("created", created)
.add("flowEntryExtension", flowEntryExtension)
.toString();
}
}
/*
* 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.flowext;
import java.nio.ByteBuffer;
import java.util.Objects;
/**
* Experimental extension to the flow rule subsystem; still under development.
* Represents a generic abstraction of the service data. User app can customize whatever it needs to install on devices.
*/
public class DownStreamFlowEntry implements FlowEntryExtension {
/**
* temporarily only have byte stream, but it will be extract more abstract information from it later.
*/
private final ByteBuffer payload;
public DownStreamFlowEntry(ByteBuffer data) {
this.payload = data;
}
/**
* Get the payload of flowExtension.
*
* @return the byte steam value of payload.
*/
// @Override
// public ByteBuffer getPayload() {
// TODO Auto-generated method stub
// return payload;
// }
/**
* Returns a hash code value for the object.
* It use payload as parameter to hash.
*
* @return a hash code value for this object.
*/
@Override
public int hashCode() {
return Objects.hash(payload);
}
/**
* Indicates whether some other object is "equal to" this one.
*
* @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.
*/
@Override
public boolean equals(Object obj) {
if (obj instanceof DownStreamFlowEntry) {
DownStreamFlowEntry packet = (DownStreamFlowEntry) obj;
return Objects.equals(this.payload, packet.payload);
} else {
return false;
}
}
/**
* Returns a string representation of the object.
*
* @return a string representation of the object.
*/
@Override
public String toString() {
String obj = new String(payload.array());
return obj;
}
}
/*
* 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.flowext;
/**
* Experimental extension to the flow rule subsystem; still under development.
* Represents a generic abstraction of the service data. User app can customize whatever it needs to install on devices.
*/
public interface FlowEntryExtension {
// some abstraction of the service data, like length, type, etc, will be added here later
}
/*
* 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.flowext;
import com.google.common.base.MoreObjects;
import org.onosproject.net.flow.CompletedBatchOperation;
import org.onosproject.net.flow.FlowRule;
import java.util.Set;
/**
* Experimental extension to the flow rule subsystem; still under development.
* <p>
* Representation of a completed flow rule batch operation.
* </p>
*/
//TODO explain the purpose of this class beyond FlowRuleProvider
public class FlowExtCompletedOperation extends CompletedBatchOperation {
// the batchId is provided by application, once one flow rule of this batch failed
// all the batch should withdraw
private final long batchId;
public FlowExtCompletedOperation(long batchId, boolean success, Set<FlowRule> failures) {
super(success, failures, null);
this.batchId = batchId;
}
/**
* Returns the BatchId of this BatchOperation.
*
* @return the number of Batch
*/
public long getBatchId() {
return batchId;
}
/**
* Returns a string representation of the object.
*
* @return a string representation of the object.
*/
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("success?", isSuccess())
.add("failedItems", failedIds())
.toString();
}
}
\ No newline at end of file
/*
* 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.flowext;
import org.onosproject.net.flow.FlowRule;
/**
* Experimental extension to the flow rule subsystem; still under development.
* <p>
* FlowRule extended for current FlowRule API.
* </p>
*/
public interface FlowRuleExt extends FlowRule {
/**
* Get the flow entry extension.
*
* @return FlowEntryExtension value.
*/
FlowEntryExtension getFlowEntryExt();
}
/*
* 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.flowext;
import org.onosproject.net.flow.FlowRuleBatchEvent;
import org.onosproject.net.flow.FlowRuleBatchRequest;
import java.util.concurrent.Future;
/**
* Experimental extension to the flow rule subsystem; still under development.
* Represents a router-like mechanism which is in charge of sending flow rule to master;
* <p>
* The Router is in charge of sending flow rule to master;
* the core component of routing-like mechanism.
* </p>
*/
public interface FlowRuleExtRouter {
/**
* apply the sub batch of flow extension rules.
*
* @param batchOperation batch of flow rules.
* A batch can contain flow rules for a single device only.
* @return Future response indicating success/failure of the batch operation
* all the way down to the device.
*/
Future<FlowExtCompletedOperation> applySubBatch(FlowRuleBatchRequest batchOperation);
/**
* Invoked on the completion of a storeBatch operation.
*
* @param event flow rule batch event
*/
void batchOperationComplete(FlowRuleBatchEvent event);
/**
* Register the listener to monitor Router,
* The Router find master to send downStream.
*
* @param listener the listener to register
*/
public void addListener(FlowRuleExtRouterListener listener);
/**
* Remove the listener of Router.
*
* @param listener the listener to remove
*/
public void removeListener(FlowRuleExtRouterListener listener);
}
/*
* 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.flowext;
import org.onosproject.net.flow.FlowRuleBatchEvent;
/**
* Experimental extension to the flow rule subsystem; still under development.
* The monitor module of the router.
* <p>
* The monitor module of router.
* </p>
*/
public interface FlowRuleExtRouterListener {
/**
* Notify monitor the router has down its work.
*
* @param event the event to notify
*/
void notify(FlowRuleBatchEvent event);
}
/*
* 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.flowext;
import org.onosproject.net.flow.FlowRuleBatchRequest;
import org.onosproject.net.flow.FlowRuleService;
import java.util.concurrent.Future;
/**
* Experimental extension to the flow rule subsystem; still under development.
* Service for injecting extended flow rules into the environment.
* This service just send the packet downstream. It won't store the
* flowRuleExtension in cache.
*/
public interface FlowRuleExtService extends FlowRuleService {
/**
* Applies a batch operation of FlowRules.
* this batch can be divided into many sub-batch by deviceId, and application
* gives a batchId, it means once one flowRule apply failed, all flow rules should
* withdraw.
*
* @param batch batch operation to apply
* @return future indicating the state of the batch operation
*/
Future<FlowExtCompletedOperation> applyBatch(FlowRuleBatchRequest batch);
}
/*
* 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.
*/
/**
* Experimental extension to the flow rule subsystem; still under development.
* <p>
* This package is an extension for the current ONOS flow rule API.
* Its main purpose is to support external applications to push service data to network elements.
* The service data could be any kind of service related data or commands required for corresponding service
* setup and other operations as defined by application and its communicating device.
* </p>
*/
package org.onosproject.net.flowext;
/*
* Copyright 2014-2015 Open Networking Laboratory
* 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.
......@@ -17,6 +17,7 @@
package org.onosproject.net.flow;
import org.junit.Test;
import org.onosproject.core.DefaultGroupId;
import org.onosproject.net.intent.IntentTestsMocks;
import com.google.common.testing.EqualsTester;
......@@ -36,9 +37,11 @@ public class DefaultFlowRuleTest {
private static final IntentTestsMocks.MockTreatment TREATMENT =
new IntentTestsMocks.MockTreatment();
final FlowRule flowRule1 = new IntentTestsMocks.MockFlowRule(1);
final FlowRule sameAsFlowRule1 = new IntentTestsMocks.MockFlowRule(1);
final FlowRule flowRule2 = new IntentTestsMocks.MockFlowRule(2);
private static byte [] b = new byte[3];
private static FlowRuleExtPayLoad payLoad = FlowRuleExtPayLoad.flowRuleExtPayLoad(b);
final FlowRule flowRule1 = new IntentTestsMocks.MockFlowRule(1, payLoad);
final FlowRule sameAsFlowRule1 = new IntentTestsMocks.MockFlowRule(1, payLoad);
final FlowRule flowRule2 = new IntentTestsMocks.MockFlowRule(2, payLoad);
final DefaultFlowRule defaultFlowRule1 = new DefaultFlowRule(flowRule1);
final DefaultFlowRule sameAsDefaultFlowRule1 = new DefaultFlowRule(sameAsFlowRule1);
final DefaultFlowRule defaultFlowRule2 = new DefaultFlowRule(flowRule2);
......@@ -59,7 +62,6 @@ public class DefaultFlowRuleTest {
public void testEquals() {
new EqualsTester()
.addEqualityGroup(defaultFlowRule1, sameAsDefaultFlowRule1)
.addEqualityGroup(defaultFlowRule2)
.testEquals();
}
......@@ -76,6 +78,7 @@ public class DefaultFlowRuleTest {
assertThat(defaultFlowRule1.selector(), is(flowRule1.selector()));
assertThat(defaultFlowRule1.treatment(), is(flowRule1.treatment()));
assertThat(defaultFlowRule1.timeout(), is(flowRule1.timeout()));
assertThat(defaultFlowRule1.payLoad(), is(flowRule1.payLoad()));
}
/**
......@@ -97,6 +100,38 @@ public class DefaultFlowRuleTest {
}
/**
* Tests creation of a DefaultFlowRule using a PayLoad constructor.
*/
@Test
public void testCreationWithPayLoadByFlowTable() {
final DefaultFlowRule rule =
new DefaultFlowRule(did("1"), null,
null, 22, APP_ID,
44, false, payLoad);
assertThat(rule.deviceId(), is(did("1")));
assertThat(rule.isPermanent(), is(false));
assertThat(rule.priority(), is(22));
assertThat(rule.timeout(), is(44));
assertThat(defaultFlowRule1.payLoad(), is(payLoad));
}
/**
* Tests creation of a DefaultFlowRule using a PayLoad constructor.
*/
@Test
public void testCreationWithPayLoadByGroupTable() {
final DefaultFlowRule rule =
new DefaultFlowRule(did("1"), null,
null, 22, APP_ID, new DefaultGroupId(0),
44, false, payLoad);
assertThat(rule.deviceId(), is(did("1")));
assertThat(rule.isPermanent(), is(false));
assertThat(rule.priority(), is(22));
assertThat(rule.timeout(), is(44));
assertThat(rule.groupId(), is(new DefaultGroupId(0)));
assertThat(defaultFlowRule1.payLoad(), is(payLoad));
}
/**
* Tests the creation of a DefaultFlowRule using an AppId constructor.
*/
@Test
......
package org.onosproject.net.flow;
import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
import org.junit.Test;
import com.google.common.testing.EqualsTester;
/**
* Test for FlowRuleExtPayLoad.
*/
public class FlowRuleExtPayLoadTest {
final byte[] b = new byte[3];
final byte[] b1 = new byte[5];
final FlowRuleExtPayLoad payLoad1 = FlowRuleExtPayLoad.flowRuleExtPayLoad(b);
final FlowRuleExtPayLoad sameAsPayLoad1 = FlowRuleExtPayLoad.flowRuleExtPayLoad(b);
final FlowRuleExtPayLoad payLoad2 = FlowRuleExtPayLoad.flowRuleExtPayLoad(b1);
/**
* Checks that the FlowRuleExtPayLoad class is immutable.
*/
@Test
public void testImmutability() {
assertThatClassIsImmutable(FlowRuleExtPayLoad.class);
}
/**
* Checks the operation of equals(), hashCode() and toString() methods.
*/
@Test
public void testEquals() {
new EqualsTester()
.addEqualityGroup(payLoad1, sameAsPayLoad1)
.addEqualityGroup(payLoad2)
.testEquals();
}
}
......@@ -17,6 +17,7 @@ package org.onosproject.net.intent;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableSet;
import org.onosproject.core.DefaultGroupId;
import org.onosproject.core.GroupId;
import org.onosproject.net.DeviceId;
......@@ -27,6 +28,7 @@ import org.onosproject.net.NetworkResource;
import org.onosproject.net.Path;
import org.onosproject.net.flow.FlowId;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.FlowRuleExtPayLoad;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.criteria.Criterion;
......@@ -336,12 +338,21 @@ public class IntentTestsMocks {
int tableId;
long timestamp;
int id;
FlowRuleExtPayLoad payLoad;
public MockFlowRule(int priority) {
this.priority = priority;
this.tableId = 0;
this.timestamp = System.currentTimeMillis();
this.id = nextId++;
this.payLoad = null;
}
public MockFlowRule(int priority, FlowRuleExtPayLoad payLoad) {
this.priority = priority;
this.timestamp = System.currentTimeMillis();
this.id = nextId++;
this.payLoad = payLoad;
}
@Override
......@@ -411,6 +422,11 @@ public class IntentTestsMocks {
public int tableId() {
return tableId;
}
@Override
public FlowRuleExtPayLoad payLoad() {
return payLoad;
}
}
public static class MockIntent extends Intent {
......
/*
* 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.
*/
/**
* Experimental extension to the flow rule subsystem; still under development.
* <p>
* This package is an extension for the current ONOS flow rule subsystem.
* Its main purpose is to support external applications to push service data to network elements.
* The service data could be any kind of service related data or commands required for corresponding service
* setup and other operations as defined by application and its communicating device.
* </p>
*/
package org.onosproject.net.flowext.impl;
/*
* 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.store.flowext.impl;
import org.onosproject.store.cluster.messaging.MessageSubject;
/**
* Experimental extension to the flow rule subsystem; still under development.
* MessageSubjects used by DefaultFlowRuleExtRouter peer-peer communication.
*/
public final class FlowExtRouterMessageSubjects {
private FlowExtRouterMessageSubjects() {
}
/**
* The subject of routing extended flow to specified device.
*/
public static final MessageSubject APPLY_EXTEND_FLOWS
= new MessageSubject("peer-forward-apply-batch-extension");
}
/*
* 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.
*/
/**
* Experimental extension to the flow rule subsystem; still under development.
* <p>
* Implementation of the distributed flow extension rule router using p2p synchronization
* protocol. The Router is the core component of routing flow rules to specified device.
* This package is still experimental at this point in time.
* </p>
*/
package org.onosproject.store.flowext.impl;
......@@ -18,6 +18,7 @@ package org.onosproject.store.serializers;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import org.onlab.packet.ChassisId;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip4Prefix;
......@@ -70,6 +71,7 @@ import org.onosproject.net.flow.FlowRuleBatchEntry;
import org.onosproject.net.flow.FlowRuleBatchEvent;
import org.onosproject.net.flow.FlowRuleBatchOperation;
import org.onosproject.net.flow.FlowRuleBatchRequest;
import org.onosproject.net.flow.FlowRuleExtPayLoad;
import org.onosproject.net.flow.StoredFlowEntry;
import org.onosproject.net.flow.criteria.Criteria;
import org.onosproject.net.flow.criteria.Criterion;
......@@ -322,7 +324,8 @@ public final class KryoNamespaces {
ObstacleConstraint.class,
AnnotationConstraint.class,
BooleanConstraint.class,
IntentOperation.class
IntentOperation.class,
FlowRuleExtPayLoad.class
)
.register(new DefaultApplicationIdSerializer(), DefaultApplicationId.class)
.register(new URISerializer(), URI.class)
......
package org.onosproject.openflow.controller;
import org.jboss.netty.buffer.ChannelBuffer;
import org.projectfloodlight.openflow.protocol.OFMessage;
import org.projectfloodlight.openflow.protocol.OFType;
import org.projectfloodlight.openflow.protocol.OFVersion;
import com.google.common.hash.PrimitiveSink;
/**
* Used to support for the third party privacy flow rule.
* it implements OFMessage interface to use exist adapter API.
*/
public class ThirdPartyMessage implements OFMessage {
private final byte[] payLoad; //privacy flow rule
public ThirdPartyMessage(byte[] payLoad) {
this.payLoad = payLoad;
}
public byte[] payLoad() {
return payLoad;
}
@Override
public void putTo(PrimitiveSink sink) {
// Do nothing here for now.
}
@Override
public OFVersion getVersion() {
// Do nothing here for now.
return null;
}
@Override
public OFType getType() {
// Do nothing here for now.
return null;
}
@Override
public long getXid() {
// Do nothing here for now.
return 0;
}
@Override
public void writeTo(ChannelBuffer channelBuffer) {
// Do nothing here for now.
}
@Override
public Builder createBuilder() {
// Do nothing here for now.
return null;
}
}
......@@ -40,12 +40,14 @@ import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.FlowEntry;
import org.onosproject.net.flow.FlowId;
import org.onosproject.net.flow.FlowRuleExtPayLoad;
import org.onosproject.net.flow.FlowRuleService;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flow.criteria.Criterion;
import org.onosproject.net.flow.instructions.Instruction;
import org.onosproject.net.flow.instructions.Instructions;
import com.eclipsesource.json.JsonArray;
import com.eclipsesource.json.JsonObject;
import com.google.common.collect.ImmutableSet;
......@@ -190,6 +192,11 @@ public class FlowsResourceTest extends ResourceTest {
public int tableId() {
return 0;
}
@Override
public FlowRuleExtPayLoad payLoad() {
return null;
}
}
/**
......