2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
9 package org.opendaylight.openflowjava.protocol.impl.util;
\r
11 import io.netty.buffer.ByteBuf;
\r
13 import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey;
\r
14 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;
\r
15 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
\r
21 * @author michal.polkorab
\r
24 public abstract class CodeKeyMakerFactory {
\r
30 public static CodeKeyMaker createMatchEntriesKeyMaker(short version) {
\r
31 return new AbstractCodeKeyMaker(version) {
\r
33 public MessageCodeKey make(ByteBuf input) {
\r
34 int oxmClass = input.getUnsignedShort(input.readerIndex());
\r
35 int oxmField = input.getUnsignedByte(input.readerIndex()
\r
36 + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1;
\r
37 return new EnhancedMessageCodeKey(getVersion(), oxmClass,
\r
38 oxmField, MatchEntries.class);
\r
47 public static CodeKeyMaker createActionsKeyMaker(short version) {
\r
48 return new AbstractCodeKeyMaker(version) {
\r
50 public MessageCodeKey make(ByteBuf input) {
\r
51 int type = input.getUnsignedShort(input.readerIndex());
\r
52 return new MessageCodeKey(getVersion(), type, Action.class);
\r
61 public static CodeKeyMaker createInstructionsKeyMaker(short version) {
\r
62 return new AbstractCodeKeyMaker(version) {
\r
64 public MessageCodeKey make(ByteBuf input) {
\r
65 int type = input.getUnsignedShort(input.readerIndex());
\r
66 return new MessageCodeKey(getVersion(), type, Instruction.class);
\r