BitOhenry
Committed by Gerrit Code Review

[ONOS-3361] Add nicira extension of resubmit instruction to onos

	modified:   core/api/src/main/java/org/onosproject/net/flow/instructions/ExtensionType.java
	modified:   drivers/src/main/java/org/onosproject/driver/extensions/NiciraExtensionInterpreter.java
	new file:   drivers/src/main/java/org/onosproject/driver/extensions/NiciraResubmit.java

Change-Id: Ib0a4a7b6360dd1629d0d2f74ef0d56f2c2a91a20
...@@ -32,7 +32,8 @@ public final class ExtensionType { ...@@ -32,7 +32,8 @@ public final class ExtensionType {
32 */ 32 */
33 public enum ExtensionTypes { 33 public enum ExtensionTypes {
34 // TODO fix type numbers to include experimenter id 34 // TODO fix type numbers to include experimenter id
35 - NICIRA_SET_TUNNEL_DST(31); 35 + NICIRA_SET_TUNNEL_DST(31),
36 + NICIRA_RESUBMIT(32);
36 37
37 private ExtensionType type; 38 private ExtensionType type;
38 39
......
...@@ -41,7 +41,9 @@ public class NiciraExtensionInterpreter extends AbstractHandlerBehaviour ...@@ -41,7 +41,9 @@ public class NiciraExtensionInterpreter extends AbstractHandlerBehaviour
41 if (extensionType.equals(ExtensionType.ExtensionTypes.NICIRA_SET_TUNNEL_DST)) { 41 if (extensionType.equals(ExtensionType.ExtensionTypes.NICIRA_SET_TUNNEL_DST)) {
42 return true; 42 return true;
43 } 43 }
44 - 44 + if (extensionType.equals(ExtensionType.ExtensionTypes.NICIRA_RESUBMIT)) {
45 + return true;
46 + }
45 return false; 47 return false;
46 } 48 }
47 49
...@@ -53,6 +55,9 @@ public class NiciraExtensionInterpreter extends AbstractHandlerBehaviour ...@@ -53,6 +55,9 @@ public class NiciraExtensionInterpreter extends AbstractHandlerBehaviour
53 return factory.actions().setField(factory.oxms().tunnelIpv4Dst( 55 return factory.actions().setField(factory.oxms().tunnelIpv4Dst(
54 IPv4Address.of(tunnelDst.tunnelDst().toInt()))); 56 IPv4Address.of(tunnelDst.tunnelDst().toInt())));
55 } 57 }
58 + if (type.equals(ExtensionType.ExtensionTypes.NICIRA_RESUBMIT.type())) {
59 + // TODO this will be implemented later
60 + }
56 return null; 61 return null;
57 } 62 }
58 63
...@@ -78,6 +83,9 @@ public class NiciraExtensionInterpreter extends AbstractHandlerBehaviour ...@@ -78,6 +83,9 @@ public class NiciraExtensionInterpreter extends AbstractHandlerBehaviour
78 if (type.equals(ExtensionType.ExtensionTypes.NICIRA_SET_TUNNEL_DST.type())) { 83 if (type.equals(ExtensionType.ExtensionTypes.NICIRA_SET_TUNNEL_DST.type())) {
79 return new NiciraSetTunnelDst(); 84 return new NiciraSetTunnelDst();
80 } 85 }
86 + if (type.equals(ExtensionType.ExtensionTypes.NICIRA_RESUBMIT.type())) {
87 + return new NiciraResubmit();
88 + }
81 throw new UnsupportedOperationException( 89 throw new UnsupportedOperationException(
82 "Driver does not support extension type " + type.toString()); 90 "Driver does not support extension type " + type.toString());
83 } 91 }
......
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 +package org.onosproject.driver.extensions;
18 +
19 +import com.google.common.base.MoreObjects;
20 +import org.onlab.util.KryoNamespace;
21 +import org.onosproject.net.PortNumber;
22 +import org.onosproject.net.flow.instructions.AbstractExtensionInstruction;
23 +import org.onosproject.net.flow.instructions.ExtensionType;
24 +import org.onosproject.store.serializers.PortNumberSerializer;
25 +
26 +import java.util.Objects;
27 +
28 +import static com.google.common.base.Preconditions.checkNotNull;
29 +
30 +/**
31 + * Nicira resubmit extension instruction.
32 + */
33 +public class NiciraResubmit extends AbstractExtensionInstruction {
34 +
35 + private PortNumber inPort;
36 +
37 + private final KryoNamespace appKryo = new KryoNamespace.Builder()
38 + .register(new PortNumberSerializer(), PortNumber.class)
39 + .register(byte[].class)
40 + .build();
41 +
42 + /**
43 + * Creates a new resubmit instruction.
44 + */
45 + NiciraResubmit() {
46 + inPort = null;
47 + }
48 +
49 + /**
50 + * Creates a new resubmit instruction with a particular inPort.
51 + *
52 + * @param inPort in port number
53 + */
54 + public NiciraResubmit(PortNumber inPort) {
55 + checkNotNull(inPort);
56 + this.inPort = inPort;
57 + }
58 +
59 + /**
60 + * Gets the inPort.
61 + *
62 + * @return inPort
63 + */
64 + public PortNumber inPort() {
65 + return inPort;
66 + }
67 +
68 + @Override
69 + public ExtensionType type() {
70 + return ExtensionType.ExtensionTypes.NICIRA_RESUBMIT.type();
71 + }
72 +
73 + @Override
74 + public void deserialize(byte[] data) {
75 + inPort = appKryo.deserialize(data);
76 + }
77 +
78 + @Override
79 + public byte[] serialize() {
80 + return appKryo.serialize(inPort);
81 + }
82 +
83 + @Override
84 + public int hashCode() {
85 + return Objects.hash(inPort);
86 + }
87 +
88 + @Override
89 + public boolean equals(Object obj) {
90 + if (this == obj) {
91 + return true;
92 + }
93 + if (obj instanceof NiciraResubmit) {
94 + NiciraResubmit that = (NiciraResubmit) obj;
95 + return Objects.equals(inPort, that.inPort);
96 +
97 + }
98 + return false;
99 + }
100 +
101 + @Override
102 + public String toString() {
103 + return MoreObjects.toStringHelper(getClass())
104 + .add("inPort", inPort)
105 + .toString();
106 + }
107 +}