Search in sources :

Example 1 with HeaderDeserializer

use of org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer in project openflowplugin by opendaylight.

the class ActionUtil method readActionHeader.

/**
 * Deserialize OpenFlow action header, using extension converter if available.
 * TODO: Remove also extension converters
 *
 * @param version  OpenFlow version
 * @param message  OpenFlow buffered message
 * @param registry deserializer registry
 * @param path     Action path
 */
public static Action readActionHeader(short version, ByteBuf message, DeserializerRegistry registry, ActionPath path) {
    int type = message.getUnsignedShort(message.readerIndex());
    Long expId = null;
    if (type == EncodeConstants.EXPERIMENTER_VALUE) {
        expId = message.getUnsignedInt(message.readerIndex() + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    }
    try {
        final MessageCodeExperimenterKey key = new MessageCodeExperimenterKey(version, type, Action.class, expId);
        final HeaderDeserializer<Action> deserializer = registry.getDeserializer(key);
        return deserializer.deserializeHeader(message);
    } catch (ClassCastException | IllegalStateException e) {
        final MessageCodeKey key = Objects.nonNull(expId) ? new ExperimenterActionDeserializerKey(version, expId) : new ActionDeserializerKey(version, type, expId);
        final HeaderDeserializer<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> deserializer = registry.getDeserializer(key);
        return ActionExtensionHelper.processAlienAction(deserializer.deserializeHeader(message), OpenflowVersion.get(version), path);
    }
}
Also used : ExperimenterActionDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionDeserializerKey) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action) HeaderDeserializer(org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer) MessageCodeExperimenterKey(org.opendaylight.openflowplugin.api.openflow.protocol.deserialization.MessageCodeExperimenterKey) MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey) ExperimenterActionDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionDeserializerKey) ActionDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey)

Aggregations

HeaderDeserializer (org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer)1 ActionDeserializerKey (org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey)1 ExperimenterActionDeserializerKey (org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionDeserializerKey)1 MessageCodeKey (org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey)1 MessageCodeExperimenterKey (org.opendaylight.openflowplugin.api.openflow.protocol.deserialization.MessageCodeExperimenterKey)1 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action)1