Frank Wang
Committed by Gerrit Code Review

[ONOS-5097]adding group table entry failed

Change-Id: I17fc9f156e1f10800caba2cbc180dac45e97a675
......@@ -40,7 +40,9 @@ public class ExtensionSelectorType {
NICIRA_MATCH_NSH_CH4(5),
NICIRA_MATCH_ENCAP_ETH_TYPE(6),
OFDPA_MATCH_VLAN_VID(16),
BMV2_MATCH_PARAMS(128);
BMV2_MATCH_PARAMS(128),
UNRESOLVED_TYPE(200);
private ExtensionSelectorType type;
......
/*
* Copyright 2016-present 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.flow.criteria;
import org.onosproject.net.flow.AbstractExtension;
import java.util.Arrays;
import java.util.Objects;
import static com.google.common.base.MoreObjects.toStringHelper;
/**
* Unresolved extension selector.
*/
public class UnresolvedExtensionSelector extends AbstractExtension implements ExtensionSelector {
private byte[] bytes;
private ExtensionSelectorType unresolvedSelectorType;
/**
* Creates a new unresolved extension selector with given data in byte form.
*
* @param type unresolved extension data type
*/
public UnresolvedExtensionSelector(byte[] arraybyte, ExtensionSelectorType type) {
this.bytes = arraybyte;
this.unresolvedSelectorType = type;
}
@Override
public byte[] serialize() {
return bytes;
}
@Override
public void deserialize(byte[] data) {
bytes = data;
}
@Override
public ExtensionSelectorType type() {
return ExtensionSelectorType.ExtensionSelectorTypes.UNRESOLVED_TYPE.type();
}
@Override
public int hashCode() {
return Objects.hash(bytes);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof UnresolvedExtensionSelector) {
UnresolvedExtensionSelector that = (UnresolvedExtensionSelector) obj;
return Arrays.equals(bytes, that.bytes);
}
return false;
}
@Override
public String toString() {
return toStringHelper(type().toString())
.add("bytes", bytes)
.add("unresolvedSelectorType", unresolvedSelectorType)
.toString();
}
}
......@@ -62,7 +62,9 @@ public final class ExtensionTreatmentType {
NICIRA_ENCAP_ETH_DST(122),
NICIRA_ENCAP_ETH_TYPE(123),
BMV2_ACTION(128),
OPLINK_ATTENUATION(130);
OPLINK_ATTENUATION(130),
UNRESOLVED_TYPE(200);
private ExtensionTreatmentType type;
......
/*
* Copyright 2015-present 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.flow.instructions;
import com.google.common.base.MoreObjects;
import org.onosproject.net.flow.AbstractExtension;
import java.util.Arrays;
import java.util.Objects;
/**
* Unresolved extension treatment.
*/
public class UnresolvedExtensionTreatment extends AbstractExtension implements ExtensionTreatment {
private byte[] bytes;
private ExtensionTreatmentType unresolvedTreatmentType;
/**
* Creates a new unresolved extension treatment with given data in byte form.
*
* @param type unresolved extension data type
*/
public UnresolvedExtensionTreatment(byte[] arraybyte, ExtensionTreatmentType type) {
this.bytes = arraybyte;
this.unresolvedTreatmentType = type;
}
@Override
public ExtensionTreatmentType type() {
return ExtensionTreatmentType.ExtensionTreatmentTypes.UNRESOLVED_TYPE.type();
}
@Override
public void deserialize(byte[] data) {
bytes = data;
}
@Override
public byte[] serialize() {
return bytes;
}
@Override
public int hashCode() {
return Objects.hash(bytes);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof UnresolvedExtensionTreatment) {
UnresolvedExtensionTreatment that = (UnresolvedExtensionTreatment) obj;
return Arrays.equals(bytes, that.bytes);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("bytes", bytes)
.add("unresolvedTreatmentType", unresolvedTreatmentType)
.toString();
}
}
......@@ -21,6 +21,7 @@ import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import org.onlab.osgi.DefaultServiceDirectory;
import org.onlab.util.ItemNotFoundException;
import org.onosproject.net.DeviceId;
import org.onosproject.net.behaviour.ExtensionSelectorResolver;
import org.onosproject.net.driver.DefaultDriverData;
......@@ -31,6 +32,7 @@ import org.onosproject.net.flow.criteria.Criteria;
import org.onosproject.net.flow.criteria.ExtensionCriterion;
import org.onosproject.net.flow.criteria.ExtensionSelector;
import org.onosproject.net.flow.criteria.ExtensionSelectorType;
import org.onosproject.net.flow.criteria.UnresolvedExtensionSelector;
/**
* Serializer for extension criteria.
......@@ -56,16 +58,20 @@ public class ExtensionCriterionSerializer extends Serializer<ExtensionCriterion>
Class<ExtensionCriterion> type) {
ExtensionSelectorType exType = (ExtensionSelectorType) kryo.readClassAndObject(input);
DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input);
DriverService driverService = DefaultServiceDirectory.getService(DriverService.class);
byte[] bytes = (byte[]) kryo.readClassAndObject(input);
ExtensionSelector selector;
try {
DriverHandler handler = new DefaultDriverHandler(
new DefaultDriverData(driverService.getDriver(deviceId), deviceId));
ExtensionSelectorResolver resolver = handler.behaviour(ExtensionSelectorResolver.class);
ExtensionSelector selector = resolver.getExtensionSelector(exType);
byte[] bytes = (byte[]) kryo.readClassAndObject(input);
selector = resolver.getExtensionSelector(exType);
selector.deserialize(bytes);
} catch (ItemNotFoundException | IllegalArgumentException e) {
selector = new UnresolvedExtensionSelector(bytes, exType);
}
return Criteria.extension(selector, deviceId);
}
}
......
......@@ -21,6 +21,7 @@ import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import org.onlab.osgi.DefaultServiceDirectory;
import org.onlab.util.ItemNotFoundException;
import org.onosproject.net.DeviceId;
import org.onosproject.net.behaviour.ExtensionTreatmentResolver;
import org.onosproject.net.driver.DefaultDriverData;
......@@ -30,6 +31,7 @@ import org.onosproject.net.driver.DriverService;
import org.onosproject.net.flow.instructions.ExtensionTreatment;
import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
import org.onosproject.net.flow.instructions.Instructions;
import org.onosproject.net.flow.instructions.UnresolvedExtensionTreatment;
/**
* Serializer for extension instructions.
......@@ -56,17 +58,19 @@ public class ExtensionInstructionSerializer extends
Class<Instructions.ExtensionInstructionWrapper> type) {
ExtensionTreatmentType exType = (ExtensionTreatmentType) kryo.readClassAndObject(input);
DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input);
DriverService driverService = DefaultServiceDirectory.getService(DriverService.class);
byte[] bytes = (byte[]) kryo.readClassAndObject(input);
ExtensionTreatment instruction;
try {
DriverHandler handler = new DefaultDriverHandler(
new DefaultDriverData(driverService.getDriver(deviceId), deviceId));
ExtensionTreatmentResolver resolver = handler.behaviour(ExtensionTreatmentResolver.class);
ExtensionTreatment instruction = resolver.getExtensionInstruction(exType);
byte[] bytes = (byte[]) kryo.readClassAndObject(input);
instruction = resolver.getExtensionInstruction(exType);
instruction.deserialize(bytes);
} catch (ItemNotFoundException | IllegalArgumentException e) {
instruction = new UnresolvedExtensionTreatment(bytes, exType);
}
return Instructions.extension(instruction, deviceId);
}
......