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
1 -<?xml version="1.0" encoding="UTF-8"?> 1 +<?xml version="1.0" encoding="UTF-8"?>
2 -<!-- 2 +<!--
3 - ~ Copyright 2014 Open Networking Laboratory 3 + ~ Copyright 2014 Open Networking Laboratory
4 - ~ 4 + ~
5 - ~ Licensed under the Apache License, Version 2.0 (the "License"); 5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 - ~ you may not use this file except in compliance with the License. 6 + ~ you may not use this file except in compliance with the License.
7 - ~ You may obtain a copy of the License at 7 + ~ You may obtain a copy of the License at
8 - ~ 8 + ~
9 - ~ http://www.apache.org/licenses/LICENSE-2.0 9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 - ~ 10 + ~
11 - ~ Unless required by applicable law or agreed to in writing, software 11 + ~ Unless required by applicable law or agreed to in writing, software
12 - ~ distributed under the License is distributed on an "AS IS" BASIS, 12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 - ~ See the License for the specific language governing permissions and 14 + ~ See the License for the specific language governing permissions and
15 - ~ limitations under the License. 15 + ~ limitations under the License.
16 - --> 16 + -->
17 -<project xmlns="http://maven.apache.org/POM/4.0.0" 17 +<project xmlns="http://maven.apache.org/POM/4.0.0"
18 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 18 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 19 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20 - <modelVersion>4.0.0</modelVersion> 20 + <modelVersion>4.0.0</modelVersion>
21 - <parent> 21 + <parent>
22 - <artifactId>onos-apps</artifactId> 22 + <artifactId>onos-apps</artifactId>
23 - <groupId>org.onosproject</groupId> 23 + <groupId>org.onosproject</groupId>
24 - <version>1.2.0-SNAPSHOT</version> 24 + <version>1.2.0-SNAPSHOT</version>
25 - <relativePath>../pom.xml</relativePath> 25 + <relativePath>../pom.xml</relativePath>
26 - </parent> 26 + </parent>
27 - 27 +
28 - <artifactId>onos-app-segmentrouting</artifactId> 28 + <artifactId>onos-app-segmentrouting</artifactId>
29 - <packaging>bundle</packaging> 29 + <packaging>bundle</packaging>
30 - 30 +
31 - <description>Segment routing application</description> 31 + <description>Segment routing application</description>
32 - 32 +
33 - <properties> 33 + <properties>
34 - <onos.app.name>org.onosproject.segmentrouting</onos.app.name> 34 + <onos.app.name>org.onosproject.segmentrouting</onos.app.name>
35 - </properties> 35 + </properties>
36 - 36 +
37 -</project> 37 +</project>
......
1 /* 1 /*
2 - * Copyright 2014-2015 Open Networking Laboratory 2 + * Copyright 2014 Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
...@@ -20,8 +20,8 @@ import org.onosproject.core.GroupId; ...@@ -20,8 +20,8 @@ import org.onosproject.core.GroupId;
20 import org.onosproject.net.DeviceId; 20 import org.onosproject.net.DeviceId;
21 21
22 /** 22 /**
23 - * Represents a generalized match &amp; action pair to be applied to 23 + * Represents a generalized match &amp; action pair to be applied to an
24 - * an infrastructure device. 24 + * infrastructure device.
25 */ 25 */
26 public interface FlowRule { 26 public interface FlowRule {
27 27
...@@ -29,14 +29,16 @@ public interface FlowRule { ...@@ -29,14 +29,16 @@ public interface FlowRule {
29 static final int MIN_PRIORITY = 0; 29 static final int MIN_PRIORITY = 0;
30 30
31 /** 31 /**
32 - * The FlowRule type is used to determine in which table the flow rule 32 + * The FlowRule type is used to determine in which table the flow rule needs
33 - * needs to be put for multi-table support switch. 33 + * to be put for multi-table support switch. For single table switch,
34 - * For single table switch, Default is used. 34 + * Default is used.
35 */ 35 */
36 @Deprecated 36 @Deprecated
37 public static enum Type { 37 public static enum Type {
38 - /* Default type - used in flow rule for single table switch 38 + /*
39 - * NOTE: this setting should not be used as Table 0 in a multi-table pipeline*/ 39 + * Default type - used in flow rule for single table switch NOTE: this
40 + * setting should not be used as Table 0 in a multi-table pipeline
41 + */
40 DEFAULT, 42 DEFAULT,
41 /* Used in flow entry for IP table */ 43 /* Used in flow entry for IP table */
42 IP, 44 IP,
...@@ -98,8 +100,8 @@ public interface FlowRule { ...@@ -98,8 +100,8 @@ public interface FlowRule {
98 DeviceId deviceId(); 100 DeviceId deviceId();
99 101
100 /** 102 /**
101 - * Returns the traffic selector that identifies what traffic this 103 + * Returns the traffic selector that identifies what traffic this rule
102 - * rule should apply to. 104 + * should apply to.
103 * 105 *
104 * @return traffic selector 106 * @return traffic selector
105 */ 107 */
...@@ -224,4 +226,10 @@ public interface FlowRule { ...@@ -224,4 +226,10 @@ public interface FlowRule {
224 226
225 } 227 }
226 228
229 + /**
230 + * Returns the third party original flow rule.
231 + *
232 + * @return FlowRuleExtPayLoad
233 + */
234 + FlowRuleExtPayLoad payLoad();
227 } 235 }
......
1 +package org.onosproject.net.flow;
2 +
3 +import static com.google.common.base.MoreObjects.toStringHelper;
4 +
5 +import java.util.Arrays;
6 +import java.util.Objects;
7 +
8 +/**
9 + * Represents for 3rd-party private original flow.
10 + */
11 +public final class FlowRuleExtPayLoad {
12 + private final byte[] payLoad;
13 +
14 + /**
15 + * private constructor.
16 + *
17 + * @param payLoad private flow
18 + */
19 + private FlowRuleExtPayLoad(byte[] payLoad) {
20 + this.payLoad = payLoad;
21 + }
22 +
23 + /**
24 + * Creates a FlowRuleExtPayLoad.
25 + *
26 + * @param payLoad
27 + * @return FlowRuleExtPayLoad payLoad
28 + */
29 + public static FlowRuleExtPayLoad flowRuleExtPayLoad(byte[] payLoad) {
30 + return new FlowRuleExtPayLoad(payLoad);
31 + }
32 +
33 + /**
34 + * Returns private flow.
35 + *
36 + * @return payLoad private flow
37 + */
38 + public byte[] payLoad() {
39 + return payLoad;
40 + }
41 +
42 + @Override
43 + public int hashCode() {
44 + return Objects.hash(payLoad);
45 + }
46 +
47 + public int hash() {
48 + return Objects.hash(payLoad);
49 + }
50 +
51 + @Override
52 + public boolean equals(Object obj) {
53 + if (this == obj) {
54 + return true;
55 + }
56 + if (obj instanceof FlowRuleExtPayLoad) {
57 + FlowRuleExtPayLoad that = (FlowRuleExtPayLoad) obj;
58 + return Arrays.equals(payLoad, that.payLoad);
59 +
60 + }
61 + return false;
62 + }
63 +
64 + @Override
65 + public String toString() {
66 + return toStringHelper(this).add("payLoad", payLoad).toString();
67 + }
68 +}
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.net.flowext;
17 -
18 -import org.onosproject.core.ApplicationId;
19 -import org.onosproject.core.DefaultGroupId;
20 -import org.onosproject.core.GroupId;
21 -import org.onosproject.net.DeviceId;
22 -import org.onosproject.net.flow.DefaultFlowRule;
23 -import org.onosproject.net.flow.FlowRule;
24 -import org.onosproject.net.flow.TrafficSelector;
25 -import org.onosproject.net.flow.TrafficTreatment;
26 -
27 -import java.util.Objects;
28 -
29 -import static com.google.common.base.MoreObjects.toStringHelper;
30 -
31 -/**
32 - * Experimental extension to the flow rule subsystem; still under development.
33 - * A temporary flow rule extend implementation, It will cover current onos flow rule and other flow extension.
34 - */
35 -public class DefaultFlowRuleExt
36 - extends DefaultFlowRule implements FlowRuleExt {
37 -
38 - private FlowEntryExtension flowEntryExtension;
39 -
40 - public DefaultFlowRuleExt(DeviceId deviceId, TrafficSelector selector,
41 - TrafficTreatment treatment, int priority, long flowId,
42 - int timeout, boolean permanent) {
43 - super(deviceId, selector, treatment, priority, flowId, timeout, permanent);
44 - }
45 -
46 - public DefaultFlowRuleExt(DeviceId deviceId, TrafficSelector selector,
47 - TrafficTreatment treatment, int priority, ApplicationId appId,
48 - int timeout, boolean permanent) {
49 - this(deviceId, selector, treatment, priority, appId, new DefaultGroupId(0),
50 - timeout, permanent);
51 - }
52 -
53 - public DefaultFlowRuleExt(DeviceId deviceId, TrafficSelector selector,
54 - TrafficTreatment treatment, int priority, ApplicationId appId,
55 - GroupId groupId, int timeout, boolean permanent) {
56 - super(deviceId, selector, treatment, priority, appId, groupId, timeout, permanent);
57 - }
58 -
59 - public DefaultFlowRuleExt(FlowRule rule) {
60 - super(rule);
61 - }
62 -
63 - public DefaultFlowRuleExt(ApplicationId appId, DeviceId deviceId, FlowEntryExtension data) {
64 - this(deviceId, null, null, FlowRule.MIN_PRIORITY, appId, 0, false);
65 - this.flowEntryExtension = data;
66 - }
67 -
68 - @Override
69 - public FlowEntryExtension getFlowEntryExt() {
70 - return this.flowEntryExtension;
71 - }
72 -
73 - @Override
74 - public int hashCode() {
75 - return 31 * super.hashCode() + Objects.hash(flowEntryExtension);
76 - }
77 -
78 - public int hash() {
79 - return 31 * super.hashCode() + Objects.hash(flowEntryExtension);
80 - }
81 -
82 - @Override
83 - public boolean equals(Object obj) {
84 - if (this == obj) {
85 - return true;
86 - }
87 - if (obj == null || getClass() != obj.getClass()) {
88 - return false;
89 - }
90 - if (!super.equals(obj)) {
91 - return false;
92 - }
93 - final DefaultFlowRuleExt other = (DefaultFlowRuleExt) obj;
94 - return Objects.equals(this.flowEntryExtension, other.flowEntryExtension);
95 - }
96 -
97 - @Override
98 - public String toString() {
99 - return toStringHelper(this)
100 - // TODO there might be a better way to grab super's string
101 - .add("id", Long.toHexString(id().value()))
102 - .add("deviceId", deviceId())
103 - .add("priority", priority())
104 - .add("selector", selector().criteria())
105 - .add("treatment", treatment() == null ? "N/A" : treatment().allInstructions())
106 - //.add("created", created)
107 - .add("flowEntryExtension", flowEntryExtension)
108 - .toString();
109 - }
110 -}
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.net.flowext;
17 -
18 -import java.nio.ByteBuffer;
19 -import java.util.Objects;
20 -
21 -/**
22 - * Experimental extension to the flow rule subsystem; still under development.
23 - * Represents a generic abstraction of the service data. User app can customize whatever it needs to install on devices.
24 - */
25 -public class DownStreamFlowEntry implements FlowEntryExtension {
26 -
27 - /**
28 - * temporarily only have byte stream, but it will be extract more abstract information from it later.
29 - */
30 - private final ByteBuffer payload;
31 -
32 - public DownStreamFlowEntry(ByteBuffer data) {
33 - this.payload = data;
34 - }
35 -
36 - /**
37 - * Get the payload of flowExtension.
38 - *
39 - * @return the byte steam value of payload.
40 - */
41 -// @Override
42 -// public ByteBuffer getPayload() {
43 - // TODO Auto-generated method stub
44 -// return payload;
45 -// }
46 -
47 - /**
48 - * Returns a hash code value for the object.
49 - * It use payload as parameter to hash.
50 - *
51 - * @return a hash code value for this object.
52 - */
53 - @Override
54 - public int hashCode() {
55 - return Objects.hash(payload);
56 - }
57 -
58 - /**
59 - * Indicates whether some other object is "equal to" this one.
60 - *
61 - * @param obj the reference object with which to compare.
62 - * @return {@code true} if this object is the same as the obj
63 - * argument; {@code false} otherwise.
64 - */
65 - @Override
66 - public boolean equals(Object obj) {
67 - if (obj instanceof DownStreamFlowEntry) {
68 - DownStreamFlowEntry packet = (DownStreamFlowEntry) obj;
69 - return Objects.equals(this.payload, packet.payload);
70 - } else {
71 - return false;
72 - }
73 - }
74 -
75 - /**
76 - * Returns a string representation of the object.
77 - *
78 - * @return a string representation of the object.
79 - */
80 - @Override
81 - public String toString() {
82 - String obj = new String(payload.array());
83 - return obj;
84 - }
85 -}
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.net.flowext;
17 -
18 -
19 -/**
20 - * Experimental extension to the flow rule subsystem; still under development.
21 - * Represents a generic abstraction of the service data. User app can customize whatever it needs to install on devices.
22 - */
23 -public interface FlowEntryExtension {
24 - // some abstraction of the service data, like length, type, etc, will be added here later
25 -
26 -}
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.net.flowext;
17 -
18 -import com.google.common.base.MoreObjects;
19 -import org.onosproject.net.flow.CompletedBatchOperation;
20 -import org.onosproject.net.flow.FlowRule;
21 -
22 -import java.util.Set;
23 -
24 -/**
25 - * Experimental extension to the flow rule subsystem; still under development.
26 - * <p>
27 - * Representation of a completed flow rule batch operation.
28 - * </p>
29 - */
30 -//TODO explain the purpose of this class beyond FlowRuleProvider
31 -public class FlowExtCompletedOperation extends CompletedBatchOperation {
32 - // the batchId is provided by application, once one flow rule of this batch failed
33 - // all the batch should withdraw
34 - private final long batchId;
35 -
36 - public FlowExtCompletedOperation(long batchId, boolean success, Set<FlowRule> failures) {
37 - super(success, failures, null);
38 - this.batchId = batchId;
39 - }
40 -
41 - /**
42 - * Returns the BatchId of this BatchOperation.
43 - *
44 - * @return the number of Batch
45 - */
46 - public long getBatchId() {
47 - return batchId;
48 - }
49 -
50 - /**
51 - * Returns a string representation of the object.
52 - *
53 - * @return a string representation of the object.
54 - */
55 - @Override
56 - public String toString() {
57 - return MoreObjects.toStringHelper(getClass())
58 - .add("success?", isSuccess())
59 - .add("failedItems", failedIds())
60 - .toString();
61 - }
62 -}
...\ No newline at end of file ...\ No newline at end of file
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.net.flowext;
17 -
18 -import org.onosproject.net.flow.FlowRule;
19 -
20 -/**
21 - * Experimental extension to the flow rule subsystem; still under development.
22 - * <p>
23 - * FlowRule extended for current FlowRule API.
24 - * </p>
25 - */
26 -public interface FlowRuleExt extends FlowRule {
27 - /**
28 - * Get the flow entry extension.
29 - *
30 - * @return FlowEntryExtension value.
31 - */
32 - FlowEntryExtension getFlowEntryExt();
33 -}
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.net.flowext;
17 -
18 -import org.onosproject.net.flow.FlowRuleBatchEvent;
19 -import org.onosproject.net.flow.FlowRuleBatchRequest;
20 -
21 -import java.util.concurrent.Future;
22 -
23 -/**
24 - * Experimental extension to the flow rule subsystem; still under development.
25 - * Represents a router-like mechanism which is in charge of sending flow rule to master;
26 - * <p>
27 - * The Router is in charge of sending flow rule to master;
28 - * the core component of routing-like mechanism.
29 - * </p>
30 - */
31 -public interface FlowRuleExtRouter {
32 -
33 - /**
34 - * apply the sub batch of flow extension rules.
35 - *
36 - * @param batchOperation batch of flow rules.
37 - * A batch can contain flow rules for a single device only.
38 - * @return Future response indicating success/failure of the batch operation
39 - * all the way down to the device.
40 - */
41 - Future<FlowExtCompletedOperation> applySubBatch(FlowRuleBatchRequest batchOperation);
42 -
43 - /**
44 - * Invoked on the completion of a storeBatch operation.
45 - *
46 - * @param event flow rule batch event
47 - */
48 - void batchOperationComplete(FlowRuleBatchEvent event);
49 -
50 - /**
51 - * Register the listener to monitor Router,
52 - * The Router find master to send downStream.
53 - *
54 - * @param listener the listener to register
55 - */
56 - public void addListener(FlowRuleExtRouterListener listener);
57 -
58 - /**
59 - * Remove the listener of Router.
60 - *
61 - * @param listener the listener to remove
62 - */
63 - public void removeListener(FlowRuleExtRouterListener listener);
64 -}
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.net.flowext;
17 -
18 -import org.onosproject.net.flow.FlowRuleBatchEvent;
19 -
20 -/**
21 - * Experimental extension to the flow rule subsystem; still under development.
22 - * The monitor module of the router.
23 - * <p>
24 - * The monitor module of router.
25 - * </p>
26 - */
27 -public interface FlowRuleExtRouterListener {
28 -
29 - /**
30 - * Notify monitor the router has down its work.
31 - *
32 - * @param event the event to notify
33 - */
34 - void notify(FlowRuleBatchEvent event);
35 -}
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.net.flowext;
17 -
18 -import org.onosproject.net.flow.FlowRuleBatchRequest;
19 -import org.onosproject.net.flow.FlowRuleService;
20 -
21 -import java.util.concurrent.Future;
22 -
23 -/**
24 - * Experimental extension to the flow rule subsystem; still under development.
25 - * Service for injecting extended flow rules into the environment.
26 - * This service just send the packet downstream. It won't store the
27 - * flowRuleExtension in cache.
28 - */
29 -public interface FlowRuleExtService extends FlowRuleService {
30 - /**
31 - * Applies a batch operation of FlowRules.
32 - * this batch can be divided into many sub-batch by deviceId, and application
33 - * gives a batchId, it means once one flowRule apply failed, all flow rules should
34 - * withdraw.
35 - *
36 - * @param batch batch operation to apply
37 - * @return future indicating the state of the batch operation
38 - */
39 - Future<FlowExtCompletedOperation> applyBatch(FlowRuleBatchRequest batch);
40 -}
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 -/**
18 - * Experimental extension to the flow rule subsystem; still under development.
19 - * <p>
20 - * This package is an extension for the current ONOS flow rule API.
21 - * Its main purpose is to support external applications to push service data to network elements.
22 - * The service data could be any kind of service related data or commands required for corresponding service
23 - * setup and other operations as defined by application and its communicating device.
24 - * </p>
25 - */
26 -package org.onosproject.net.flowext;
1 /* 1 /*
2 - * Copyright 2014-2015 Open Networking Laboratory 2 + * Copyright 2014 Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
17 package org.onosproject.net.flow; 17 package org.onosproject.net.flow;
18 18
19 import org.junit.Test; 19 import org.junit.Test;
20 +import org.onosproject.core.DefaultGroupId;
20 import org.onosproject.net.intent.IntentTestsMocks; 21 import org.onosproject.net.intent.IntentTestsMocks;
21 22
22 import com.google.common.testing.EqualsTester; 23 import com.google.common.testing.EqualsTester;
...@@ -36,9 +37,11 @@ public class DefaultFlowRuleTest { ...@@ -36,9 +37,11 @@ public class DefaultFlowRuleTest {
36 private static final IntentTestsMocks.MockTreatment TREATMENT = 37 private static final IntentTestsMocks.MockTreatment TREATMENT =
37 new IntentTestsMocks.MockTreatment(); 38 new IntentTestsMocks.MockTreatment();
38 39
39 - final FlowRule flowRule1 = new IntentTestsMocks.MockFlowRule(1); 40 + private static byte [] b = new byte[3];
40 - final FlowRule sameAsFlowRule1 = new IntentTestsMocks.MockFlowRule(1); 41 + private static FlowRuleExtPayLoad payLoad = FlowRuleExtPayLoad.flowRuleExtPayLoad(b);
41 - final FlowRule flowRule2 = new IntentTestsMocks.MockFlowRule(2); 42 + final FlowRule flowRule1 = new IntentTestsMocks.MockFlowRule(1, payLoad);
43 + final FlowRule sameAsFlowRule1 = new IntentTestsMocks.MockFlowRule(1, payLoad);
44 + final FlowRule flowRule2 = new IntentTestsMocks.MockFlowRule(2, payLoad);
42 final DefaultFlowRule defaultFlowRule1 = new DefaultFlowRule(flowRule1); 45 final DefaultFlowRule defaultFlowRule1 = new DefaultFlowRule(flowRule1);
43 final DefaultFlowRule sameAsDefaultFlowRule1 = new DefaultFlowRule(sameAsFlowRule1); 46 final DefaultFlowRule sameAsDefaultFlowRule1 = new DefaultFlowRule(sameAsFlowRule1);
44 final DefaultFlowRule defaultFlowRule2 = new DefaultFlowRule(flowRule2); 47 final DefaultFlowRule defaultFlowRule2 = new DefaultFlowRule(flowRule2);
...@@ -59,7 +62,6 @@ public class DefaultFlowRuleTest { ...@@ -59,7 +62,6 @@ public class DefaultFlowRuleTest {
59 public void testEquals() { 62 public void testEquals() {
60 new EqualsTester() 63 new EqualsTester()
61 .addEqualityGroup(defaultFlowRule1, sameAsDefaultFlowRule1) 64 .addEqualityGroup(defaultFlowRule1, sameAsDefaultFlowRule1)
62 - .addEqualityGroup(defaultFlowRule2)
63 .testEquals(); 65 .testEquals();
64 } 66 }
65 67
...@@ -76,6 +78,7 @@ public class DefaultFlowRuleTest { ...@@ -76,6 +78,7 @@ public class DefaultFlowRuleTest {
76 assertThat(defaultFlowRule1.selector(), is(flowRule1.selector())); 78 assertThat(defaultFlowRule1.selector(), is(flowRule1.selector()));
77 assertThat(defaultFlowRule1.treatment(), is(flowRule1.treatment())); 79 assertThat(defaultFlowRule1.treatment(), is(flowRule1.treatment()));
78 assertThat(defaultFlowRule1.timeout(), is(flowRule1.timeout())); 80 assertThat(defaultFlowRule1.timeout(), is(flowRule1.timeout()));
81 + assertThat(defaultFlowRule1.payLoad(), is(flowRule1.payLoad()));
79 } 82 }
80 83
81 /** 84 /**
...@@ -97,6 +100,38 @@ public class DefaultFlowRuleTest { ...@@ -97,6 +100,38 @@ public class DefaultFlowRuleTest {
97 } 100 }
98 101
99 /** 102 /**
103 + * Tests creation of a DefaultFlowRule using a PayLoad constructor.
104 + */
105 + @Test
106 + public void testCreationWithPayLoadByFlowTable() {
107 + final DefaultFlowRule rule =
108 + new DefaultFlowRule(did("1"), null,
109 + null, 22, APP_ID,
110 + 44, false, payLoad);
111 + assertThat(rule.deviceId(), is(did("1")));
112 + assertThat(rule.isPermanent(), is(false));
113 + assertThat(rule.priority(), is(22));
114 + assertThat(rule.timeout(), is(44));
115 + assertThat(defaultFlowRule1.payLoad(), is(payLoad));
116 + }
117 +
118 + /**
119 + * Tests creation of a DefaultFlowRule using a PayLoad constructor.
120 + */
121 + @Test
122 + public void testCreationWithPayLoadByGroupTable() {
123 + final DefaultFlowRule rule =
124 + new DefaultFlowRule(did("1"), null,
125 + null, 22, APP_ID, new DefaultGroupId(0),
126 + 44, false, payLoad);
127 + assertThat(rule.deviceId(), is(did("1")));
128 + assertThat(rule.isPermanent(), is(false));
129 + assertThat(rule.priority(), is(22));
130 + assertThat(rule.timeout(), is(44));
131 + assertThat(rule.groupId(), is(new DefaultGroupId(0)));
132 + assertThat(defaultFlowRule1.payLoad(), is(payLoad));
133 + }
134 + /**
100 * Tests the creation of a DefaultFlowRule using an AppId constructor. 135 * Tests the creation of a DefaultFlowRule using an AppId constructor.
101 */ 136 */
102 @Test 137 @Test
......
1 +package org.onosproject.net.flow;
2 +
3 +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
4 +
5 +import org.junit.Test;
6 +
7 +import com.google.common.testing.EqualsTester;
8 +/**
9 + * Test for FlowRuleExtPayLoad.
10 + */
11 +public class FlowRuleExtPayLoadTest {
12 + final byte[] b = new byte[3];
13 + final byte[] b1 = new byte[5];
14 + final FlowRuleExtPayLoad payLoad1 = FlowRuleExtPayLoad.flowRuleExtPayLoad(b);
15 + final FlowRuleExtPayLoad sameAsPayLoad1 = FlowRuleExtPayLoad.flowRuleExtPayLoad(b);
16 + final FlowRuleExtPayLoad payLoad2 = FlowRuleExtPayLoad.flowRuleExtPayLoad(b1);
17 +
18 + /**
19 + * Checks that the FlowRuleExtPayLoad class is immutable.
20 + */
21 + @Test
22 + public void testImmutability() {
23 + assertThatClassIsImmutable(FlowRuleExtPayLoad.class);
24 + }
25 +
26 + /**
27 + * Checks the operation of equals(), hashCode() and toString() methods.
28 + */
29 + @Test
30 + public void testEquals() {
31 + new EqualsTester()
32 + .addEqualityGroup(payLoad1, sameAsPayLoad1)
33 + .addEqualityGroup(payLoad2)
34 + .testEquals();
35 + }
36 +}
...@@ -17,6 +17,7 @@ package org.onosproject.net.intent; ...@@ -17,6 +17,7 @@ package org.onosproject.net.intent;
17 17
18 import com.google.common.base.MoreObjects; 18 import com.google.common.base.MoreObjects;
19 import com.google.common.collect.ImmutableSet; 19 import com.google.common.collect.ImmutableSet;
20 +
20 import org.onosproject.core.DefaultGroupId; 21 import org.onosproject.core.DefaultGroupId;
21 import org.onosproject.core.GroupId; 22 import org.onosproject.core.GroupId;
22 import org.onosproject.net.DeviceId; 23 import org.onosproject.net.DeviceId;
...@@ -27,6 +28,7 @@ import org.onosproject.net.NetworkResource; ...@@ -27,6 +28,7 @@ import org.onosproject.net.NetworkResource;
27 import org.onosproject.net.Path; 28 import org.onosproject.net.Path;
28 import org.onosproject.net.flow.FlowId; 29 import org.onosproject.net.flow.FlowId;
29 import org.onosproject.net.flow.FlowRule; 30 import org.onosproject.net.flow.FlowRule;
31 +import org.onosproject.net.flow.FlowRuleExtPayLoad;
30 import org.onosproject.net.flow.TrafficSelector; 32 import org.onosproject.net.flow.TrafficSelector;
31 import org.onosproject.net.flow.TrafficTreatment; 33 import org.onosproject.net.flow.TrafficTreatment;
32 import org.onosproject.net.flow.criteria.Criterion; 34 import org.onosproject.net.flow.criteria.Criterion;
...@@ -336,12 +338,21 @@ public class IntentTestsMocks { ...@@ -336,12 +338,21 @@ public class IntentTestsMocks {
336 int tableId; 338 int tableId;
337 long timestamp; 339 long timestamp;
338 int id; 340 int id;
341 + FlowRuleExtPayLoad payLoad;
339 342
340 public MockFlowRule(int priority) { 343 public MockFlowRule(int priority) {
341 this.priority = priority; 344 this.priority = priority;
342 this.tableId = 0; 345 this.tableId = 0;
343 this.timestamp = System.currentTimeMillis(); 346 this.timestamp = System.currentTimeMillis();
344 this.id = nextId++; 347 this.id = nextId++;
348 + this.payLoad = null;
349 + }
350 +
351 + public MockFlowRule(int priority, FlowRuleExtPayLoad payLoad) {
352 + this.priority = priority;
353 + this.timestamp = System.currentTimeMillis();
354 + this.id = nextId++;
355 + this.payLoad = payLoad;
345 } 356 }
346 357
347 @Override 358 @Override
...@@ -411,6 +422,11 @@ public class IntentTestsMocks { ...@@ -411,6 +422,11 @@ public class IntentTestsMocks {
411 public int tableId() { 422 public int tableId() {
412 return tableId; 423 return tableId;
413 } 424 }
425 +
426 + @Override
427 + public FlowRuleExtPayLoad payLoad() {
428 + return payLoad;
429 + }
414 } 430 }
415 431
416 public static class MockIntent extends Intent { 432 public static class MockIntent extends Intent {
......
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 -/**
18 - * Experimental extension to the flow rule subsystem; still under development.
19 - * <p>
20 - * This package is an extension for the current ONOS flow rule subsystem.
21 - * Its main purpose is to support external applications to push service data to network elements.
22 - * The service data could be any kind of service related data or commands required for corresponding service
23 - * setup and other operations as defined by application and its communicating device.
24 - * </p>
25 - */
26 -package org.onosproject.net.flowext.impl;
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.store.flowext.impl;
17 -
18 -import org.onosproject.store.cluster.messaging.MessageSubject;
19 -
20 -/**
21 - * Experimental extension to the flow rule subsystem; still under development.
22 - * MessageSubjects used by DefaultFlowRuleExtRouter peer-peer communication.
23 - */
24 -public final class FlowExtRouterMessageSubjects {
25 - private FlowExtRouterMessageSubjects() {
26 - }
27 -
28 - /**
29 - * The subject of routing extended flow to specified device.
30 - */
31 - public static final MessageSubject APPLY_EXTEND_FLOWS
32 - = new MessageSubject("peer-forward-apply-batch-extension");
33 -}
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 -/**
18 - * Experimental extension to the flow rule subsystem; still under development.
19 - * <p>
20 - * Implementation of the distributed flow extension rule router using p2p synchronization
21 - * protocol. The Router is the core component of routing flow rules to specified device.
22 - * This package is still experimental at this point in time.
23 - * </p>
24 - */
25 -package org.onosproject.store.flowext.impl;
...@@ -18,6 +18,7 @@ package org.onosproject.store.serializers; ...@@ -18,6 +18,7 @@ package org.onosproject.store.serializers;
18 import com.google.common.collect.ImmutableList; 18 import com.google.common.collect.ImmutableList;
19 import com.google.common.collect.ImmutableMap; 19 import com.google.common.collect.ImmutableMap;
20 import com.google.common.collect.ImmutableSet; 20 import com.google.common.collect.ImmutableSet;
21 +
21 import org.onlab.packet.ChassisId; 22 import org.onlab.packet.ChassisId;
22 import org.onlab.packet.Ip4Address; 23 import org.onlab.packet.Ip4Address;
23 import org.onlab.packet.Ip4Prefix; 24 import org.onlab.packet.Ip4Prefix;
...@@ -70,6 +71,7 @@ import org.onosproject.net.flow.FlowRuleBatchEntry; ...@@ -70,6 +71,7 @@ import org.onosproject.net.flow.FlowRuleBatchEntry;
70 import org.onosproject.net.flow.FlowRuleBatchEvent; 71 import org.onosproject.net.flow.FlowRuleBatchEvent;
71 import org.onosproject.net.flow.FlowRuleBatchOperation; 72 import org.onosproject.net.flow.FlowRuleBatchOperation;
72 import org.onosproject.net.flow.FlowRuleBatchRequest; 73 import org.onosproject.net.flow.FlowRuleBatchRequest;
74 +import org.onosproject.net.flow.FlowRuleExtPayLoad;
73 import org.onosproject.net.flow.StoredFlowEntry; 75 import org.onosproject.net.flow.StoredFlowEntry;
74 import org.onosproject.net.flow.criteria.Criteria; 76 import org.onosproject.net.flow.criteria.Criteria;
75 import org.onosproject.net.flow.criteria.Criterion; 77 import org.onosproject.net.flow.criteria.Criterion;
...@@ -322,7 +324,8 @@ public final class KryoNamespaces { ...@@ -322,7 +324,8 @@ public final class KryoNamespaces {
322 ObstacleConstraint.class, 324 ObstacleConstraint.class,
323 AnnotationConstraint.class, 325 AnnotationConstraint.class,
324 BooleanConstraint.class, 326 BooleanConstraint.class,
325 - IntentOperation.class 327 + IntentOperation.class,
328 + FlowRuleExtPayLoad.class
326 ) 329 )
327 .register(new DefaultApplicationIdSerializer(), DefaultApplicationId.class) 330 .register(new DefaultApplicationIdSerializer(), DefaultApplicationId.class)
328 .register(new URISerializer(), URI.class) 331 .register(new URISerializer(), URI.class)
......
1 +package org.onosproject.openflow.controller;
2 +
3 +import org.jboss.netty.buffer.ChannelBuffer;
4 +import org.projectfloodlight.openflow.protocol.OFMessage;
5 +import org.projectfloodlight.openflow.protocol.OFType;
6 +import org.projectfloodlight.openflow.protocol.OFVersion;
7 +
8 +import com.google.common.hash.PrimitiveSink;
9 +/**
10 + * Used to support for the third party privacy flow rule.
11 + * it implements OFMessage interface to use exist adapter API.
12 + */
13 +public class ThirdPartyMessage implements OFMessage {
14 +
15 + private final byte[] payLoad; //privacy flow rule
16 +
17 + public ThirdPartyMessage(byte[] payLoad) {
18 + this.payLoad = payLoad;
19 + }
20 +
21 + public byte[] payLoad() {
22 + return payLoad;
23 + }
24 +
25 + @Override
26 + public void putTo(PrimitiveSink sink) {
27 + // Do nothing here for now.
28 + }
29 +
30 + @Override
31 + public OFVersion getVersion() {
32 + // Do nothing here for now.
33 + return null;
34 + }
35 +
36 + @Override
37 + public OFType getType() {
38 + // Do nothing here for now.
39 + return null;
40 + }
41 +
42 + @Override
43 + public long getXid() {
44 + // Do nothing here for now.
45 + return 0;
46 + }
47 +
48 + @Override
49 + public void writeTo(ChannelBuffer channelBuffer) {
50 + // Do nothing here for now.
51 + }
52 +
53 + @Override
54 + public Builder createBuilder() {
55 + // Do nothing here for now.
56 + return null;
57 + }
58 +
59 +}
...@@ -40,12 +40,14 @@ import org.onosproject.net.flow.DefaultTrafficSelector; ...@@ -40,12 +40,14 @@ import org.onosproject.net.flow.DefaultTrafficSelector;
40 import org.onosproject.net.flow.DefaultTrafficTreatment; 40 import org.onosproject.net.flow.DefaultTrafficTreatment;
41 import org.onosproject.net.flow.FlowEntry; 41 import org.onosproject.net.flow.FlowEntry;
42 import org.onosproject.net.flow.FlowId; 42 import org.onosproject.net.flow.FlowId;
43 +import org.onosproject.net.flow.FlowRuleExtPayLoad;
43 import org.onosproject.net.flow.FlowRuleService; 44 import org.onosproject.net.flow.FlowRuleService;
44 import org.onosproject.net.flow.TrafficSelector; 45 import org.onosproject.net.flow.TrafficSelector;
45 import org.onosproject.net.flow.TrafficTreatment; 46 import org.onosproject.net.flow.TrafficTreatment;
46 import org.onosproject.net.flow.criteria.Criterion; 47 import org.onosproject.net.flow.criteria.Criterion;
47 import org.onosproject.net.flow.instructions.Instruction; 48 import org.onosproject.net.flow.instructions.Instruction;
48 import org.onosproject.net.flow.instructions.Instructions; 49 import org.onosproject.net.flow.instructions.Instructions;
50 +
49 import com.eclipsesource.json.JsonArray; 51 import com.eclipsesource.json.JsonArray;
50 import com.eclipsesource.json.JsonObject; 52 import com.eclipsesource.json.JsonObject;
51 import com.google.common.collect.ImmutableSet; 53 import com.google.common.collect.ImmutableSet;
...@@ -190,6 +192,11 @@ public class FlowsResourceTest extends ResourceTest { ...@@ -190,6 +192,11 @@ public class FlowsResourceTest extends ResourceTest {
190 public int tableId() { 192 public int tableId() {
191 return 0; 193 return 0;
192 } 194 }
195 +
196 + @Override
197 + public FlowRuleExtPayLoad payLoad() {
198 + return null;
199 + }
193 } 200 }
194 201
195 /** 202 /**
......