Committed by
Gerrit Code Review
[ONOS-3284]Traffic selector updated for NSH ext match
Change-Id: Ic6f993df9a6bc735dc1ee9fca39ef05568f5ee5e
Showing
9 changed files
with
583 additions
and
1 deletions
| 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; | ||
| 17 | + | ||
| 18 | +import java.util.Objects; | ||
| 19 | + | ||
| 20 | +import com.google.common.base.MoreObjects; | ||
| 21 | + | ||
| 22 | +/* | ||
| 23 | + * Representation of NSH context header value | ||
| 24 | + */ | ||
| 25 | +public final class NshContextHeader { | ||
| 26 | + | ||
| 27 | + private final int nshContextHeader; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * Default constructor. | ||
| 31 | + * | ||
| 32 | + * @param nshContextHeader nsh context header value. | ||
| 33 | + */ | ||
| 34 | + private NshContextHeader(int nshContextHeader) { | ||
| 35 | + this.nshContextHeader = nshContextHeader; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * Returns the NshContextHeader by setting its value. | ||
| 40 | + * | ||
| 41 | + * @param nshContextHeader nsh context header value. | ||
| 42 | + * @return NshContextHeader | ||
| 43 | + */ | ||
| 44 | + public static NshContextHeader of(int nshContextHeader) { | ||
| 45 | + return new NshContextHeader(nshContextHeader); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * Returns nsh context header value. | ||
| 51 | + * | ||
| 52 | + * @return the nsh context header | ||
| 53 | + */ | ||
| 54 | + public int nshContextHeader() { | ||
| 55 | + return nshContextHeader; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + | ||
| 59 | + @Override | ||
| 60 | + public int hashCode() { | ||
| 61 | + return Objects.hash(nshContextHeader); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @Override | ||
| 65 | + public boolean equals(Object obj) { | ||
| 66 | + if (this == obj) { | ||
| 67 | + return true; | ||
| 68 | + } | ||
| 69 | + if (!(obj instanceof NshContextHeader)) { | ||
| 70 | + return false; | ||
| 71 | + } | ||
| 72 | + final NshContextHeader other = (NshContextHeader) obj; | ||
| 73 | + return Objects.equals(this.nshContextHeader, other.nshContextHeader); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + @Override | ||
| 77 | + public String toString() { | ||
| 78 | + return MoreObjects.toStringHelper(this) | ||
| 79 | + .add("nshContextHeader", nshContextHeader) | ||
| 80 | + .toString(); | ||
| 81 | + } | ||
| 82 | +} | ||
| 83 | + |
| 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; | ||
| 17 | + | ||
| 18 | +import java.util.Objects; | ||
| 19 | + | ||
| 20 | +import com.google.common.base.MoreObjects; | ||
| 21 | + | ||
| 22 | +/* | ||
| 23 | + * Representation of NSH Service index | ||
| 24 | + */ | ||
| 25 | +public final class NshServiceIndex { | ||
| 26 | + private static final short MASK = 0xFF; | ||
| 27 | + private final short serviceIndex; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * Default constructor. | ||
| 31 | + * | ||
| 32 | + * @param serviceIndex nsh service index | ||
| 33 | + */ | ||
| 34 | + private NshServiceIndex(short serviceIndex) { | ||
| 35 | + this.serviceIndex = (short) (serviceIndex & MASK); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * Returns the NshServiceIndex by setting its value. | ||
| 40 | + * | ||
| 41 | + * @param serviceIndex nsh service index | ||
| 42 | + * @return NshServiceIndex | ||
| 43 | + */ | ||
| 44 | + public static NshServiceIndex of(short serviceIndex) { | ||
| 45 | + return new NshServiceIndex(serviceIndex); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * Returns nsh service index value. | ||
| 51 | + * | ||
| 52 | + * @return the nsh service index | ||
| 53 | + */ | ||
| 54 | + public short serviceIndex() { | ||
| 55 | + return serviceIndex; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + | ||
| 59 | + @Override | ||
| 60 | + public int hashCode() { | ||
| 61 | + return Objects.hash(serviceIndex); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @Override | ||
| 65 | + public boolean equals(Object obj) { | ||
| 66 | + if (this == obj) { | ||
| 67 | + return true; | ||
| 68 | + } | ||
| 69 | + if (!(obj instanceof NshServiceIndex)) { | ||
| 70 | + return false; | ||
| 71 | + } | ||
| 72 | + final NshServiceIndex other = (NshServiceIndex) obj; | ||
| 73 | + return Objects.equals(this.serviceIndex, other.serviceIndex); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + @Override | ||
| 77 | + public String toString() { | ||
| 78 | + return MoreObjects.toStringHelper(this) | ||
| 79 | + .add("serviceIndex", serviceIndex) | ||
| 80 | + .toString(); | ||
| 81 | + } | ||
| 82 | +} | ||
| 83 | + |
| 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; | ||
| 17 | + | ||
| 18 | +import java.util.Objects; | ||
| 19 | + | ||
| 20 | +import com.google.common.base.MoreObjects; | ||
| 21 | + | ||
| 22 | +/* | ||
| 23 | + * Representation of NSH Service path Identifier | ||
| 24 | + */ | ||
| 25 | +public final class NshServicePathId { | ||
| 26 | + | ||
| 27 | + private final int servicePathId; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * Default constructor. | ||
| 31 | + * | ||
| 32 | + * @param servicePathId nsh service path identifier | ||
| 33 | + */ | ||
| 34 | + private NshServicePathId(int servicePathId) { | ||
| 35 | + this.servicePathId = servicePathId; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * Returns the NshServicePathId by setting its value. | ||
| 40 | + * | ||
| 41 | + * @param servicePathId nsh service path identifier | ||
| 42 | + * @return NshServicePathId | ||
| 43 | + */ | ||
| 44 | + public static NshServicePathId of(int servicePathId) { | ||
| 45 | + return new NshServicePathId(servicePathId); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * Returns nsh context service path identifier. | ||
| 51 | + * | ||
| 52 | + * @return the nsh context service path id | ||
| 53 | + */ | ||
| 54 | + public int servicePathId() { | ||
| 55 | + return servicePathId; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + | ||
| 59 | + @Override | ||
| 60 | + public int hashCode() { | ||
| 61 | + return Objects.hash(servicePathId); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @Override | ||
| 65 | + public boolean equals(Object obj) { | ||
| 66 | + if (this == obj) { | ||
| 67 | + return true; | ||
| 68 | + } | ||
| 69 | + if (!(obj instanceof NshServicePathId)) { | ||
| 70 | + return false; | ||
| 71 | + } | ||
| 72 | + final NshServicePathId other = (NshServicePathId) obj; | ||
| 73 | + return Objects.equals(this.servicePathId, other.servicePathId); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + @Override | ||
| 77 | + public String toString() { | ||
| 78 | + return MoreObjects.toStringHelper(this) | ||
| 79 | + .add("servicePathId", servicePathId) | ||
| 80 | + .toString(); | ||
| 81 | + } | ||
| 82 | +} | ||
| 83 | + |
| ... | @@ -32,7 +32,13 @@ public class ExtensionSelectorType { | ... | @@ -32,7 +32,13 @@ public class ExtensionSelectorType { |
| 32 | * These numbers have no impact on the actual OF type id. | 32 | * These numbers have no impact on the actual OF type id. |
| 33 | */ | 33 | */ |
| 34 | public enum ExtensionSelectorTypes { | 34 | public enum ExtensionSelectorTypes { |
| 35 | - PLACEHOLDER(0); // TODO remove when actual extensions are added | 35 | + NICIRA_MATCH_NSH_SPI(0), |
| 36 | + NICIRA_MATCH_NSH_SI(1), | ||
| 37 | + NICIRA_MATCH_NSH_CH1(2), | ||
| 38 | + NICIRA_MATCH_NSH_CH2(3), | ||
| 39 | + NICIRA_MATCH_NSH_CH3(4), | ||
| 40 | + NICIRA_MATCH_NSH_CH4(5); | ||
| 41 | + | ||
| 36 | 42 | ||
| 37 | private ExtensionSelectorType type; | 43 | private ExtensionSelectorType type; |
| 38 | 44 | ... | ... |
| ... | @@ -50,6 +50,7 @@ public class DefaultMoveExtensionTreatment extends AbstractExtension | ... | @@ -50,6 +50,7 @@ public class DefaultMoveExtensionTreatment extends AbstractExtension |
| 50 | * @param nBits nbits | 50 | * @param nBits nbits |
| 51 | * @param src source | 51 | * @param src source |
| 52 | * @param dst destination | 52 | * @param dst destination |
| 53 | + * @param type extension treatment type | ||
| 53 | */ | 54 | */ |
| 54 | public DefaultMoveExtensionTreatment(int srcOfs, int dstOfs, int nBits, | 55 | public DefaultMoveExtensionTreatment(int srcOfs, int dstOfs, int nBits, |
| 55 | int src, int dst, ExtensionTreatmentType type) { | 56 | int src, int dst, ExtensionTreatmentType type) { | ... | ... |
| ... | @@ -33,11 +33,48 @@ public class NiciraExtensionSelectorInterpreter | ... | @@ -33,11 +33,48 @@ public class NiciraExtensionSelectorInterpreter |
| 33 | 33 | ||
| 34 | @Override | 34 | @Override |
| 35 | public boolean supported(ExtensionSelectorType extensionSelectorType) { | 35 | public boolean supported(ExtensionSelectorType extensionSelectorType) { |
| 36 | + if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI.type())) { | ||
| 37 | + return true; | ||
| 38 | + } | ||
| 39 | + if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI.type())) { | ||
| 40 | + return true; | ||
| 41 | + } | ||
| 42 | + if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH1.type())) { | ||
| 43 | + return true; | ||
| 44 | + } | ||
| 45 | + if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH2.type())) { | ||
| 46 | + return true; | ||
| 47 | + } | ||
| 48 | + if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH3.type())) { | ||
| 49 | + return true; | ||
| 50 | + } | ||
| 51 | + if (extensionSelectorType.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH4.type())) { | ||
| 52 | + return true; | ||
| 53 | + } | ||
| 36 | return false; | 54 | return false; |
| 37 | } | 55 | } |
| 38 | 56 | ||
| 39 | @Override | 57 | @Override |
| 40 | public OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector) { | 58 | public OFOxm<?> mapSelector(OFFactory factory, ExtensionSelector extensionSelector) { |
| 59 | + ExtensionSelectorType type = extensionSelector.type(); | ||
| 60 | + if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI.type())) { | ||
| 61 | + // TODO | ||
| 62 | + } | ||
| 63 | + if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI.type())) { | ||
| 64 | + // TODO | ||
| 65 | + } | ||
| 66 | + if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH1.type())) { | ||
| 67 | + // TODO | ||
| 68 | + } | ||
| 69 | + if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH2.type())) { | ||
| 70 | + // TODO | ||
| 71 | + } | ||
| 72 | + if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH3.type())) { | ||
| 73 | + // TODO | ||
| 74 | + } | ||
| 75 | + if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH4.type())) { | ||
| 76 | + // TODO | ||
| 77 | + } | ||
| 41 | return null; | 78 | return null; |
| 42 | } | 79 | } |
| 43 | 80 | ||
| ... | @@ -48,6 +85,18 @@ public class NiciraExtensionSelectorInterpreter | ... | @@ -48,6 +85,18 @@ public class NiciraExtensionSelectorInterpreter |
| 48 | 85 | ||
| 49 | @Override | 86 | @Override |
| 50 | public ExtensionSelector getExtensionSelector(ExtensionSelectorType type) { | 87 | public ExtensionSelector getExtensionSelector(ExtensionSelectorType type) { |
| 88 | + if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI.type())) { | ||
| 89 | + return new NiciraMatchNshSpi(); | ||
| 90 | + } | ||
| 91 | + if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI.type())) { | ||
| 92 | + return new NiciraMatchNshSi(); | ||
| 93 | + } | ||
| 94 | + if (type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH1.type()) | ||
| 95 | + || type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH2.type()) | ||
| 96 | + || type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH3.type()) | ||
| 97 | + || type.equals(ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_CH4.type())) { | ||
| 98 | + return new NiciraMatchNshContextHeader(type); | ||
| 99 | + } | ||
| 51 | return null; | 100 | return null; |
| 52 | } | 101 | } |
| 53 | } | 102 | } | ... | ... |
| 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.driver.extensions; | ||
| 17 | + | ||
| 18 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
| 19 | + | ||
| 20 | +import java.util.Objects; | ||
| 21 | + | ||
| 22 | +import org.onlab.util.KryoNamespace; | ||
| 23 | +import org.onosproject.net.NshContextHeader; | ||
| 24 | +import org.onosproject.net.flow.AbstractExtension; | ||
| 25 | +import org.onosproject.net.flow.criteria.ExtensionSelector; | ||
| 26 | +import org.onosproject.net.flow.criteria.ExtensionSelectorType; | ||
| 27 | +/** | ||
| 28 | + * Implementation of Nsh context header criterion. | ||
| 29 | + */ | ||
| 30 | +public final class NiciraMatchNshContextHeader extends AbstractExtension implements ExtensionSelector { | ||
| 31 | + private NshContextHeader nshContextHeader; | ||
| 32 | + private ExtensionSelectorType type; | ||
| 33 | + | ||
| 34 | + private final KryoNamespace appKryo = new KryoNamespace.Builder().build(); | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * Constructor to create Nsh context header. | ||
| 38 | + * | ||
| 39 | + * @param type extension selector type | ||
| 40 | + */ | ||
| 41 | + public NiciraMatchNshContextHeader(ExtensionSelectorType type) { | ||
| 42 | + this.nshContextHeader = null; | ||
| 43 | + this.type = type; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * Gets the nsh context header to match. | ||
| 48 | + * | ||
| 49 | + * @return the nsh context header to match | ||
| 50 | + */ | ||
| 51 | + public NshContextHeader nshContextHeader() { | ||
| 52 | + return nshContextHeader; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + @Override | ||
| 56 | + public byte[] serialize() { | ||
| 57 | + return appKryo.serialize(nshContextHeader.nshContextHeader()); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + @Override | ||
| 61 | + public void deserialize(byte[] data) { | ||
| 62 | + nshContextHeader = nshContextHeader.of(appKryo.deserialize(data)); | ||
| 63 | + | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @Override | ||
| 67 | + public ExtensionSelectorType type() { | ||
| 68 | + return type; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + @Override | ||
| 72 | + public String toString() { | ||
| 73 | + return toStringHelper(type().toString()) | ||
| 74 | + .add("nshContextHeader", nshContextHeader.toString()) | ||
| 75 | + .toString(); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + @Override | ||
| 79 | + public int hashCode() { | ||
| 80 | + return Objects.hash(type(), nshContextHeader); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + @Override | ||
| 84 | + public boolean equals(Object obj) { | ||
| 85 | + if (this == obj) { | ||
| 86 | + return true; | ||
| 87 | + } | ||
| 88 | + if (obj instanceof NiciraMatchNshContextHeader) { | ||
| 89 | + NiciraMatchNshContextHeader that = (NiciraMatchNshContextHeader) obj; | ||
| 90 | + return Objects.equals(nshContextHeader, that.nshContextHeader) && | ||
| 91 | + Objects.equals(this.type(), that.type()); | ||
| 92 | + } | ||
| 93 | + return false; | ||
| 94 | + } | ||
| 95 | +} |
| 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.driver.extensions; | ||
| 17 | + | ||
| 18 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
| 19 | + | ||
| 20 | +import java.util.Objects; | ||
| 21 | + | ||
| 22 | +import org.onlab.util.KryoNamespace; | ||
| 23 | +import org.onosproject.net.NshServiceIndex; | ||
| 24 | +import org.onosproject.net.flow.AbstractExtension; | ||
| 25 | +import org.onosproject.net.flow.criteria.ExtensionSelector; | ||
| 26 | +import org.onosproject.net.flow.criteria.ExtensionSelectorType; | ||
| 27 | +/** | ||
| 28 | + * Implementation of NSH Service Index(SI). | ||
| 29 | + */ | ||
| 30 | +public final class NiciraMatchNshSi extends AbstractExtension implements ExtensionSelector { | ||
| 31 | + | ||
| 32 | + private NshServiceIndex nshSi; | ||
| 33 | + | ||
| 34 | + private final KryoNamespace appKryo = new KryoNamespace.Builder().build(); | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * Default constructor. | ||
| 38 | + * | ||
| 39 | + */ | ||
| 40 | + public NiciraMatchNshSi() { | ||
| 41 | + this.nshSi = null; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * Gets the nsh service index to match. | ||
| 46 | + * | ||
| 47 | + * @return the si to match | ||
| 48 | + */ | ||
| 49 | + public NshServiceIndex nshSi() { | ||
| 50 | + return nshSi; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + @Override | ||
| 54 | + public byte[] serialize() { | ||
| 55 | + return appKryo.serialize(nshSi.serviceIndex()); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + @Override | ||
| 59 | + public void deserialize(byte[] data) { | ||
| 60 | + nshSi = NshServiceIndex.of(appKryo.deserialize(data)); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + @Override | ||
| 64 | + public ExtensionSelectorType type() { | ||
| 65 | + return ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI.type(); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + @Override | ||
| 69 | + public String toString() { | ||
| 70 | + return toStringHelper(type().toString()) | ||
| 71 | + .add("nshSi", nshSi.toString()) | ||
| 72 | + .toString(); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + @Override | ||
| 76 | + public int hashCode() { | ||
| 77 | + return Objects.hash(type(), nshSi); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @Override | ||
| 81 | + public boolean equals(Object obj) { | ||
| 82 | + if (this == obj) { | ||
| 83 | + return true; | ||
| 84 | + } | ||
| 85 | + if (obj instanceof NiciraMatchNshSi) { | ||
| 86 | + NiciraMatchNshSi that = (NiciraMatchNshSi) obj; | ||
| 87 | + return Objects.equals(nshSi, that.nshSi); | ||
| 88 | + } | ||
| 89 | + return false; | ||
| 90 | + } | ||
| 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 | +package org.onosproject.driver.extensions; | ||
| 17 | + | ||
| 18 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
| 19 | + | ||
| 20 | +import java.util.Objects; | ||
| 21 | + | ||
| 22 | +import org.onlab.util.KryoNamespace; | ||
| 23 | +import org.onosproject.net.NshServicePathId; | ||
| 24 | +import org.onosproject.net.flow.AbstractExtension; | ||
| 25 | +import org.onosproject.net.flow.criteria.ExtensionSelector; | ||
| 26 | +import org.onosproject.net.flow.criteria.ExtensionSelectorType; | ||
| 27 | + | ||
| 28 | +/** | ||
| 29 | + * Implementation of NSH Service Path Id selector. | ||
| 30 | + */ | ||
| 31 | +public final class NiciraMatchNshSpi extends AbstractExtension implements ExtensionSelector { | ||
| 32 | + private NshServicePathId nshSpi; | ||
| 33 | + | ||
| 34 | + private final KryoNamespace appKryo = new KryoNamespace.Builder().build(); | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * Default constructor. | ||
| 38 | + */ | ||
| 39 | + public NiciraMatchNshSpi() { | ||
| 40 | + this.nshSpi = null; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * Gets the network service path id to match. | ||
| 45 | + * | ||
| 46 | + * @return the nshSpi to match | ||
| 47 | + */ | ||
| 48 | + public NshServicePathId nshSpi() { | ||
| 49 | + return nshSpi; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + @Override | ||
| 53 | + public ExtensionSelectorType type() { | ||
| 54 | + return ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI.type(); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + @Override | ||
| 58 | + public byte[] serialize() { | ||
| 59 | + return appKryo.serialize(nshSpi); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @Override | ||
| 63 | + public void deserialize(byte[] data) { | ||
| 64 | + nshSpi = NshServicePathId.of(appKryo.deserialize(data)); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + @Override | ||
| 68 | + public String toString() { | ||
| 69 | + return toStringHelper(type().toString()) | ||
| 70 | + .add("nshSpi", nshSpi.toString()) | ||
| 71 | + .toString(); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @Override | ||
| 75 | + public int hashCode() { | ||
| 76 | + return Objects.hash(type(), nshSpi); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + @Override | ||
| 80 | + public boolean equals(Object obj) { | ||
| 81 | + if (this == obj) { | ||
| 82 | + return true; | ||
| 83 | + } | ||
| 84 | + if (obj instanceof NiciraMatchNshSpi) { | ||
| 85 | + NiciraMatchNshSpi that = (NiciraMatchNshSpi) obj; | ||
| 86 | + return Objects.equals(nshSpi, that.nshSpi) && | ||
| 87 | + Objects.equals(this.type(), that.type()); | ||
| 88 | + } | ||
| 89 | + return false; | ||
| 90 | + } | ||
| 91 | +} |
-
Please register or login to post a comment