use of org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey in project openflowplugin by opendaylight.
the class TypeKeyMakerFactoryTest method testExperimenterMatchEntriesKeyMaker.
/**
* Tests {@link TypeKeyMakerFactory#createMatchEntriesKeyMaker(short)}.
*/
@Test
public void testExperimenterMatchEntriesKeyMaker() {
TypeKeyMaker<MatchEntry> keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);
Assert.assertNotNull("Null keyMaker", keyMaker);
MatchEntryBuilder builder = new MatchEntryBuilder();
builder.setOxmClass(ExperimenterClass.class);
builder.setOxmMatchField(OxmMatchFieldClass.class);
builder.setHasMask(true);
ExperimenterIdCaseBuilder caseBuilder = new ExperimenterIdCaseBuilder();
ExperimenterBuilder expBuilder = new ExperimenterBuilder();
expBuilder.setExperimenter(new ExperimenterId(42L));
caseBuilder.setExperimenter(expBuilder.build());
builder.setMatchEntryValue(caseBuilder.build());
MatchEntry entry = builder.build();
MessageTypeKey<?> key = keyMaker.make(entry);
Assert.assertNotNull("Null key", key);
MatchEntrySerializerKey<?, ?> comparationKey = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, ExperimenterClass.class, OxmMatchFieldClass.class);
comparationKey.setExperimenterId(42L);
Assert.assertEquals("Wrong key", comparationKey, key);
}
use of org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey in project openflowplugin by opendaylight.
the class OF13SetFieldActionSerializer method serialize.
@Override
// FB doesn't recognize Objects.requireNonNull
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public void serialize(Action action, ByteBuf outBuffer) {
Objects.requireNonNull(registry);
final int startIndex = outBuffer.writerIndex();
outBuffer.writeShort(ActionConstants.SET_FIELD_CODE);
final int lengthIndex = outBuffer.writerIndex();
outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH);
MatchEntry entry = ((SetFieldCase) action.getActionChoice()).getSetFieldAction().getMatchEntry().get(0);
MatchEntrySerializerKey<?, ?> key = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), entry.getOxmMatchField());
if (entry.getOxmClass().equals(ExperimenterClass.class)) {
ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) entry.getMatchEntryValue();
key.setExperimenterId(experimenterIdCase.getExperimenter().getExperimenter().getValue());
} else {
key.setExperimenterId(null);
}
OFSerializer<MatchEntry> serializer = registry.getSerializer(key);
serializer.serialize(entry, outBuffer);
int paddingRemainder = (outBuffer.writerIndex() - startIndex) % EncodeConstants.PADDING;
if (paddingRemainder != 0) {
outBuffer.writeZero(EncodeConstants.PADDING - paddingRemainder);
}
outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex);
}
use of org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey in project openflowplugin by opendaylight.
the class MatchExtensionHelper method processExtension.
/**
* Processes an extension.
*
* @param ofVersion openflow version
* @param matchPath match path
* @param matchEntry match entry
* @return an ExtensionListBuilder
*/
private static ExtensionListBuilder processExtension(MatchEntry matchEntry, short ofVersion, MatchPath matchPath) {
ExtensionListBuilder extListBld = null;
// TODO: EXTENSION PROPOSAL (match, OFJava to MD-SAL)
MatchEntrySerializerKey<? extends OxmClassBase, ? extends MatchField> key = new MatchEntrySerializerKey<>(ofVersion, matchEntry.getOxmClass(), matchEntry.getOxmMatchField());
if (null != OFSessionUtil.getExtensionConvertorProvider()) {
ConvertorFromOFJava<MatchEntry, MatchPath> convertor = OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
if (convertor != null) {
ExtensionAugment<? extends Augmentation<Extension>> extensionMatch = convertor.convert(matchEntry, matchPath);
ExtensionBuilder extBld = new ExtensionBuilder();
extBld.addAugmentation(extensionMatch.getAugmentationClass(), extensionMatch.getAugmentationObject());
extListBld = new ExtensionListBuilder();
extListBld.setExtension(extBld.build());
extListBld.setExtensionKey(extensionMatch.getKey());
}
}
return extListBld;
}
Aggregations