Search in sources :

Example 1 with MatchEntryDeserializerKey

use of org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey in project openflowplugin by opendaylight.

the class MatchEntryDeserializerRegistryHelper method registerExperimenter.

public void registerExperimenter(int oxmField, long expId, OFGeneralDeserializer deserializer) {
    MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(version, OxmMatchConstants.EXPERIMENTER_CLASS, oxmField);
    key.setExperimenterId(expId);
    registry.registerDeserializer(key, deserializer);
}
Also used : MatchEntryDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey)

Example 2 with MatchEntryDeserializerKey

use of org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey in project openflowplugin by opendaylight.

the class MatchEntryDeserializerRegistryHelper method register.

/**
 * Registers match entry deserializer under provided oxmfield.
 *
 * @param oxmField oxm_field value/code
 * @param deserializer deserializer instance
 */
public void register(int oxmField, OFGeneralDeserializer deserializer) {
    MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(version, oxmClass, oxmField);
    key.setExperimenterId(null);
    registry.registerDeserializer(key, deserializer);
}
Also used : MatchEntryDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey)

Example 3 with MatchEntryDeserializerKey

use of org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey in project openflowplugin by opendaylight.

the class CodeKeyMakerFactory method createMatchEntriesKeyMaker.

public static CodeKeyMaker createMatchEntriesKeyMaker(short version) {
    return new AbstractCodeKeyMaker(version) {

        @Override
        public MessageCodeKey make(ByteBuf input) {
            int oxmClass = input.getUnsignedShort(input.readerIndex());
            int oxmField = input.getUnsignedByte(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1;
            MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(getVersion(), oxmClass, oxmField);
            if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) {
                long expId = input.getUnsignedInt(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
                key.setExperimenterId(expId);
                return key;
            }
            key.setExperimenterId(null);
            return key;
        }
    };
}
Also used : MatchEntryDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey) ByteBuf(io.netty.buffer.ByteBuf)

Example 4 with MatchEntryDeserializerKey

use of org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey in project openflowplugin by opendaylight.

the class MatchDeserializerTest method testIpv6Address.

/**
 * Testing Ipv6 address deserialization.
 */
@Test
public void testIpv6Address() {
    ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 34 10 00 00 00 01 00 02 00 03 00 04 00 05 00 06 0F 07");
    MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 26);
    key.setExperimenterId(null);
    OFDeserializer<MatchEntry> entryDeserializer = registry.getDeserializer(key);
    MatchEntry entry = entryDeserializer.deserialize(buffer);
    Assert.assertEquals("Wrong Ipv6 address format", new Ipv6Address("0:1:2:3:4:5:6:f07"), ((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getIpv6Address());
}
Also used : MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) MatchEntryDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey) ByteBuf(io.netty.buffer.ByteBuf) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Ipv6SrcCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCase) Test(org.junit.Test)

Example 5 with MatchEntryDeserializerKey

use of org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey 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());
}
Also used : MatchEntryDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey) SetFieldMatchKey(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchKey)

Aggregations

MatchEntryDeserializerKey (org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey)14 Test (org.junit.Test)7 ByteBuf (io.netty.buffer.ByteBuf)6 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)5 MessageCodeKey (org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey)3 NiciraActionDeserializerKey (org.opendaylight.openflowjava.nx.api.NiciraActionDeserializerKey)2 NiciraActionSerializerKey (org.opendaylight.openflowjava.nx.api.NiciraActionSerializerKey)2 MatchEntrySerializerKey (org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey)2 Nxm0Class (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 ExperimenterActionDeserializerKey (org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionDeserializerKey)1 ExperimenterActionSerializerKey (org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey)1 ExperimenterIdDeserializerKey (org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey)1 ExperimenterIdMeterSubTypeSerializerKey (org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdMeterSubTypeSerializerKey)1 ExperimenterIdSerializerKey (org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey)1 ExperimenterInstructionDeserializerKey (org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionDeserializerKey)1 ExperimenterInstructionSerializerKey (org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey)1 MessageTypeKey (org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey)1