use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch in project openflowplugin by opendaylight.
the class TableFeaturesMatchFieldDeserializer method deserialize.
/**
* Deserialize match field if deserializer supports it, otherwise returns empty optional.
*
* @param message input buffer
* @return set field match
*/
public Optional<SetFieldMatch> deserialize(ByteBuf message) {
int oxmClass = message.getUnsignedShort(message.readerIndex());
int oxmField = message.getUnsignedByte(message.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1;
Long expId = null;
if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) {
expId = message.getUnsignedInt(message.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
}
final MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, oxmClass, oxmField);
key.setExperimenterId(expId);
return Optional.ofNullable(codeToFieldMap.get(key)).map(clazz -> processHeader(message).setKey(new SetFieldMatchKey(clazz)).setMatchType(clazz).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch in project openflowplugin by opendaylight.
the class ApplySetfieldTablePropertySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final ApplySetfield property = new ApplySetfieldBuilder().setApplySetfield(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.ApplySetfieldBuilder().setSetFieldMatch(ImmutableList.<SetFieldMatch>builder().add(new SetFieldMatchBuilder().setMatchType(ArpOp.class).setHasMask(false).build()).build()).build()).build();
assertProperty(property, out -> {
assertEquals(out.readUnsignedShort(), OxmMatchConstants.OPENFLOW_BASIC_CLASS);
assertEquals(out.readUnsignedByte(), OxmMatchConstants.ARP_OP << 1);
// Skip match entry length
out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch in project openflowplugin by opendaylight.
the class WriteSetfieldTablePropertySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final WriteSetfield property = new WriteSetfieldBuilder().setWriteSetfield(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.WriteSetfieldBuilder().setSetFieldMatch(ImmutableList.<SetFieldMatch>builder().add(new SetFieldMatchBuilder().setMatchType(ArpOp.class).setHasMask(false).build()).build()).build()).build();
assertProperty(property, out -> {
assertEquals(out.readUnsignedShort(), OxmMatchConstants.OPENFLOW_BASIC_CLASS);
assertEquals(out.readUnsignedByte(), OxmMatchConstants.ARP_OP << 1);
// Skip match entry length
out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch in project openflowplugin by opendaylight.
the class TableFeaturesResponseConvertor method setSetFieldTableFeatureProperty.
private static List<SetFieldMatch> setSetFieldTableFeatureProperty(final TableFeatureProperties properties, final boolean setHasMask) {
List<SetFieldMatch> setFieldMatchList = new ArrayList<>();
SetFieldMatchBuilder setFieldMatchBuilder = new SetFieldMatchBuilder();
// This handles only OpenflowBasicClass oxm class.
for (MatchEntry currMatch : properties.getAugmentation(OxmRelatedTableFeatureProperty.class).getMatchEntry()) {
Class<? extends MatchField> ofMatchField = currMatch.getOxmMatchField();
if (setHasMask) {
setFieldMatchBuilder.setHasMask(currMatch.isHasMask());
}
setFieldMatchBuilder.setMatchType(OF_TO_SAL_TABLE_FEATURE_PROPERTIES.get(ofMatchField));
setFieldMatchList.add(setFieldMatchBuilder.build());
}
return setFieldMatchList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch in project openflowplugin by opendaylight.
the class WildcardsTablePropertySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Wildcards property = new WildcardsBuilder().setWildcardSetfield(new WildcardSetfieldBuilder().setSetFieldMatch(ImmutableList.<SetFieldMatch>builder().add(new SetFieldMatchBuilder().setMatchType(ArpOp.class).setHasMask(false).build()).build()).build()).build();
assertProperty(property, out -> {
assertEquals(out.readUnsignedShort(), OxmMatchConstants.OPENFLOW_BASIC_CLASS);
assertEquals(out.readUnsignedByte(), OxmMatchConstants.ARP_OP << 1);
// Skip match entry length
out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
});
}
Aggregations