Committed by
Gerrit Code Review
[ONOS-3284] Add nicira extension of setNshSpi instruction to onos
Change-Id: I341b40e347fad832e0abc24f73099e1935730c6f
Showing
3 changed files
with
116 additions
and
1 deletions
... | @@ -34,7 +34,8 @@ public final class ExtensionTreatmentType { | ... | @@ -34,7 +34,8 @@ public final class ExtensionTreatmentType { |
34 | public enum ExtensionTreatmentTypes { | 34 | public enum ExtensionTreatmentTypes { |
35 | // TODO fix type numbers to include experimenter id | 35 | // TODO fix type numbers to include experimenter id |
36 | NICIRA_SET_TUNNEL_DST(0), | 36 | NICIRA_SET_TUNNEL_DST(0), |
37 | - NICIRA_RESUBMIT(1); | 37 | + NICIRA_RESUBMIT(1), |
38 | + NICIRA_SET_NSH_SPI(32); | ||
38 | 39 | ||
39 | private ExtensionTreatmentType type; | 40 | private ExtensionTreatmentType type; |
40 | 41 | ... | ... |
... | @@ -46,6 +46,10 @@ public class NiciraExtensionTreatmentInterpreter extends AbstractHandlerBehaviou | ... | @@ -46,6 +46,10 @@ public class NiciraExtensionTreatmentInterpreter extends AbstractHandlerBehaviou |
46 | ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT.type())) { | 46 | ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT.type())) { |
47 | return true; | 47 | return true; |
48 | } | 48 | } |
49 | + if (extensionTreatmentType.equals( | ||
50 | + ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) { | ||
51 | + return true; | ||
52 | + } | ||
49 | return false; | 53 | return false; |
50 | } | 54 | } |
51 | 55 | ||
... | @@ -60,6 +64,9 @@ public class NiciraExtensionTreatmentInterpreter extends AbstractHandlerBehaviou | ... | @@ -60,6 +64,9 @@ public class NiciraExtensionTreatmentInterpreter extends AbstractHandlerBehaviou |
60 | if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT.type())) { | 64 | if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT.type())) { |
61 | // TODO this will be implemented later | 65 | // TODO this will be implemented later |
62 | } | 66 | } |
67 | + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) { | ||
68 | + // TODO this will be implemented later | ||
69 | + } | ||
63 | return null; | 70 | return null; |
64 | } | 71 | } |
65 | 72 | ||
... | @@ -88,6 +95,9 @@ public class NiciraExtensionTreatmentInterpreter extends AbstractHandlerBehaviou | ... | @@ -88,6 +95,9 @@ public class NiciraExtensionTreatmentInterpreter extends AbstractHandlerBehaviou |
88 | if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT.type())) { | 95 | if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT.type())) { |
89 | return new NiciraResubmit(); | 96 | return new NiciraResubmit(); |
90 | } | 97 | } |
98 | + if (type.equals(ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type())) { | ||
99 | + return new NiciraSetNshSpi(); | ||
100 | + } | ||
91 | throw new UnsupportedOperationException( | 101 | throw new UnsupportedOperationException( |
92 | "Driver does not support extension type " + type.toString()); | 102 | "Driver does not support extension type " + type.toString()); |
93 | } | 103 | } | ... | ... |
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 java.util.Objects; | ||
20 | + | ||
21 | +import org.onlab.util.KryoNamespace; | ||
22 | +import org.onosproject.net.flow.instructions.AbstractExtensionTreatment; | ||
23 | +import org.onosproject.net.flow.instructions.ExtensionTreatmentType; | ||
24 | +import org.onosproject.store.serializers.Ip4AddressSerializer; | ||
25 | + | ||
26 | +import com.google.common.base.MoreObjects; | ||
27 | + | ||
28 | +/** | ||
29 | + * Nicira set NSH SPI extension instruction. | ||
30 | + */ | ||
31 | +public class NiciraSetNshSpi extends AbstractExtensionTreatment { | ||
32 | + | ||
33 | + private int nshSpi; | ||
34 | + | ||
35 | + private final KryoNamespace appKryo = new KryoNamespace.Builder() | ||
36 | + .register(new Ip4AddressSerializer(), Integer.class) | ||
37 | + .register(byte[].class) | ||
38 | + .build(); | ||
39 | + | ||
40 | + /** | ||
41 | + * Creates a new set nsh spi instruction. | ||
42 | + */ | ||
43 | + NiciraSetNshSpi() { | ||
44 | + nshSpi = 0; | ||
45 | + } | ||
46 | + | ||
47 | + /** | ||
48 | + * Creates a new set nsh spi instruction with given spi. | ||
49 | + * | ||
50 | + * @param nshSpi nsh service path index | ||
51 | + */ | ||
52 | + NiciraSetNshSpi(int nshSpi) { | ||
53 | + this.nshSpi = nshSpi; | ||
54 | + } | ||
55 | + | ||
56 | + /** | ||
57 | + * Gets the nsh service path index. | ||
58 | + * | ||
59 | + * @return nsh service path index | ||
60 | + */ | ||
61 | + public int nshSpi() { | ||
62 | + return nshSpi; | ||
63 | + } | ||
64 | + | ||
65 | + @Override | ||
66 | + public ExtensionTreatmentType type() { | ||
67 | + return ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI.type(); | ||
68 | + } | ||
69 | + | ||
70 | + @Override | ||
71 | + public void deserialize(byte[] data) { | ||
72 | + nshSpi = appKryo.deserialize(data); | ||
73 | + } | ||
74 | + | ||
75 | + @Override | ||
76 | + public byte[] serialize() { | ||
77 | + return appKryo.serialize(nshSpi); | ||
78 | + } | ||
79 | + | ||
80 | + @Override | ||
81 | + public int hashCode() { | ||
82 | + return Objects.hash(nshSpi); | ||
83 | + } | ||
84 | + | ||
85 | + @Override | ||
86 | + public boolean equals(Object obj) { | ||
87 | + if (this == obj) { | ||
88 | + return true; | ||
89 | + } | ||
90 | + if (obj instanceof NiciraSetNshSpi) { | ||
91 | + NiciraSetNshSpi that = (NiciraSetNshSpi) obj; | ||
92 | + return Objects.equals(nshSpi, that.nshSpi); | ||
93 | + | ||
94 | + } | ||
95 | + return false; | ||
96 | + } | ||
97 | + | ||
98 | + @Override | ||
99 | + public String toString() { | ||
100 | + return MoreObjects.toStringHelper(getClass()) | ||
101 | + .add("nshSpi", nshSpi) | ||
102 | + .toString(); | ||
103 | + } | ||
104 | +} |
-
Please register or login to post a comment