use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow in project openflowplugin by opendaylight.
the class FlowCreatorUtil method canModifyFlow.
/**
* Determine whether a flow entry can be modified or not.
*
* @param original An original flow entry.
* @param updated An updated flow entry.
* @param version Protocol version.
* @return {@code true} only if a flow entry can be modified.
*/
public static boolean canModifyFlow(OriginalFlow original, UpdatedFlow updated, Short version) {
// flags, and cookie.
if (!Objects.equals(original.getMatch(), updated.getMatch()) || !equalsWithDefault(original.getPriority(), updated.getPriority(), FlowConvertor.DEFAULT_PRIORITY) || !equalsWithDefault(original.getIdleTimeout(), updated.getIdleTimeout(), FlowConvertor.DEFAULT_IDLE_TIMEOUT) || !equalsWithDefault(original.getHardTimeout(), updated.getHardTimeout(), FlowConvertor.DEFAULT_HARD_TIMEOUT) || !equalsFlowModFlags(original.getFlags(), updated.getFlags())) {
return false;
}
if (!Boolean.TRUE.equals(updated.isStrict()) && version != null && version.shortValue() != OFConstants.OFP_VERSION_1_0) {
FlowCookie cookieMask = updated.getCookieMask();
if (cookieMask != null) {
BigInteger mask = cookieMask.getValue();
if (mask != null && !mask.equals(BigInteger.ZERO)) {
// Allow FLOW_MOD with filtering by cookie.
return true;
}
}
}
FlowCookie oc = original.getCookie();
FlowCookie uc = updated.getCookie();
BigInteger orgCookie;
BigInteger updCookie;
if (oc == null) {
if (uc == null) {
return true;
}
orgCookie = OFConstants.DEFAULT_COOKIE;
updCookie = uc.getValue();
} else {
orgCookie = oc.getValue();
updCookie = (uc == null) ? OFConstants.DEFAULT_COOKIE : uc.getValue();
}
return equalsWithDefault(orgCookie, updCookie, OFConstants.DEFAULT_COOKIE);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow in project openflowplugin by opendaylight.
the class FlowConvertorTest method testOnlyModifyStrictCommand.
/**
* Tests {@link FlowConvertor#convert(Flow, VersionDatapathIdConvertorData)} }.
*/
@Test
public void testOnlyModifyStrictCommand() {
UpdatedFlowBuilder flowBuilder = new UpdatedFlowBuilder();
flowBuilder.setStrict(true);
UpdatedFlow flow = flowBuilder.build();
VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
data.setDatapathId(new BigInteger("42"));
List<FlowModInputBuilder> flowMod = convert(flow, data);
Assert.assertEquals("Wrong version", 1, flowMod.get(0).getVersion().intValue());
Assert.assertEquals("Wrong command", FlowModCommand.OFPFCADD, flowMod.get(0).getCommand());
}
Aggregations