use of org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey in project openflowplugin by opendaylight.
the class MatchDeserializerTest method testIpv4Address.
/**
* Testing Ipv4 address deserialization.
*/
@Test
public void testIpv4Address() {
ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03");
MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 12);
key.setExperimenterId(null);
OFDeserializer<MatchEntry> entryDeserializer = registry.getDeserializer(key);
MatchEntry entry = entryDeserializer.deserialize(buffer);
Assert.assertEquals("Wrong Ipv4 address format", new Ipv4Address("0.1.2.3"), ((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getIpv4Address());
}
use of org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey in project openflowplugin by opendaylight.
the class MatchDeserializerTest method testHeaders.
/**
* Testing header deserialization.
*/
@Test
public void testHeaders() {
ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03");
MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 12);
key.setExperimenterId(null);
HeaderDeserializer<MatchEntry> entryDeserializer = registry.getDeserializer(key);
MatchEntry entry = entryDeserializer.deserializeHeader(buffer);
Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass());
Assert.assertEquals("Wrong entry field", Ipv4Dst.class, entry.getOxmMatchField());
Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask());
Assert.assertNull("Wrong Ipv4 address", entry.getMatchEntryValue());
}
use of org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey in project openflowplugin by opendaylight.
the class MatchDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf inBuffer, MatchBuilder builder) {
if (inBuffer.readableBytes() <= 0) {
return;
}
int oxmClass = inBuffer.getUnsignedShort(inBuffer.readerIndex());
int oxmField = inBuffer.getUnsignedByte(inBuffer.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1;
final MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, oxmClass, oxmField);
if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) {
long expId = inBuffer.getUnsignedInt(inBuffer.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
key.setExperimenterId(expId);
}
final MatchEntryDeserializer entryDeserializer = entryRegistry.get(key);
if (Objects.nonNull(entryDeserializer)) {
entryDeserializer.deserializeEntry(inBuffer, builder);
} else {
final OFDeserializer<MatchEntry> deserializer = registry.getDeserializer(key);
MatchExtensionHelper.injectExtension(EncodeConstants.OF13_VERSION_ID, deserializer.deserialize(inBuffer), builder, matchPath);
}
}
use of org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey in project openflowplugin by opendaylight.
the class CodeKeyMakerFactoryTest method testMatchEntriesKeyMaker.
/**
* Tests {@link CodeKeyMakerFactory#createMatchEntriesKeyMaker(short)}.
*/
@Test
public void testMatchEntriesKeyMaker() {
CodeKeyMaker keyMaker = CodeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);
Assert.assertNotNull("Null key maker", keyMaker);
ByteBuf buffer = BufferHelper.buildBuffer("80 00 00 04 00 00 00 01");
// skip XID
buffer.skipBytes(4);
MessageCodeKey codeKey = keyMaker.make(buffer);
Assert.assertNotNull("Null key", codeKey);
Assert.assertEquals("Wrong key", new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 32768, 0), codeKey);
Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes());
}
Aggregations