X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflow-protocol-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Futil%2FCodeKeyMakerFactory.java;h=7713e355e4d30a5ca6b0d297c51dbb400f0d583b;hb=519a86d1ddcfb8f0fe264174e62e5424e1efba1f;hp=d2eabddde753ec4052e7ad328853c338fe9c275c;hpb=60ad94454217d7d1f6f9e65f39f72ae111ecc845;p=openflowjava.git diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java index d2eabddd..7713e355 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java @@ -1,88 +1,90 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.ActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.InstructionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public abstract class CodeKeyMakerFactory { - - /** - * @param version - * @return - */ - 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; - } - }; - } - - /** - * @param version - * @return - */ - public static CodeKeyMaker createActionsKeyMaker(short version) { - return new AbstractCodeKeyMaker(version) { - @Override - public MessageCodeKey make(ByteBuf input) { - int type = input.getUnsignedShort(input.readerIndex()); - if (type == EncodeConstants.EXPERIMENTER_VALUE) { - Long expId = input.getUnsignedInt(input.readerIndex() - + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - return new ActionDeserializerKey(getVersion(), type, expId); - } - ActionDeserializerKey actionDeserializerKey = new ActionDeserializerKey(getVersion(), type, null); - return actionDeserializerKey; - } - }; - } - - /** - * @param version - * @return - */ - public static CodeKeyMaker createInstructionsKeyMaker(short version) { - return new AbstractCodeKeyMaker(version) { - @Override - public MessageCodeKey make(ByteBuf input) { - int type = input.getUnsignedShort(input.readerIndex()); - if (type == EncodeConstants.EXPERIMENTER_VALUE) { - Long expId = input.getUnsignedInt(input.readerIndex() - + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - return new InstructionDeserializerKey(getVersion(), type, expId); - } - return new InstructionDeserializerKey(getVersion(), type, null); - } - }; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public abstract class CodeKeyMakerFactory { + + /** + * @param version + * @return + */ + 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; + } + }; + } + + /** + * @param version + * @return + */ + public static CodeKeyMaker createActionsKeyMaker(short version) { + return new AbstractCodeKeyMaker(version) { + @Override + public MessageCodeKey make(ByteBuf input) { + int type = input.getUnsignedShort(input.readerIndex()); + if (type == EncodeConstants.EXPERIMENTER_VALUE) { + Long expId = input.getUnsignedInt(input.readerIndex() + + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + return new ExperimenterActionDeserializerKey(getVersion(), expId); + } + ActionDeserializerKey actionDeserializerKey = new ActionDeserializerKey(getVersion(), type, null); + return actionDeserializerKey; + } + }; + } + + /** + * @param version + * @return + */ + public static CodeKeyMaker createInstructionsKeyMaker(short version) { + return new AbstractCodeKeyMaker(version) { + @Override + public MessageCodeKey make(ByteBuf input) { + int type = input.getUnsignedShort(input.readerIndex()); + if (type == EncodeConstants.EXPERIMENTER_VALUE) { + Long expId = input.getUnsignedInt(input.readerIndex() + + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + return new ExperimenterInstructionDeserializerKey(getVersion(), expId); + } + return new InstructionDeserializerKey(getVersion(), type, null); + } + }; + } +}