2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowjava.nx.codec.action;
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.openflowjava.nx.api.NiciraConstants;
12 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
13 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
14 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
22 public abstract class AbstractActionCodec implements OFSerializer<Action>, OFDeserializer<Action> {
24 protected final static void serializeHeader(final int msgLength, final int subtype, final ByteBuf outBuffer) {
25 outBuffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE);
26 writeMsgLengthVendorIdSubtypeToBuffer(msgLength, subtype, outBuffer);
29 private final static void writeMsgLengthVendorIdSubtypeToBuffer(final int msgLength, final int subtype, final ByteBuf outBuffer) {
30 outBuffer.writeShort(msgLength);
31 outBuffer.writeInt(NiciraConstants.NX_VENDOR_ID.intValue());
32 outBuffer.writeShort(subtype);
35 protected final static ActionBuilder deserializeHeader(final ByteBuf message) {
36 // size of experimenter type
37 message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
39 message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
41 message.skipBytes(EncodeConstants.SIZE_OF_INT_IN_BYTES);
43 message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
44 ActionBuilder actionBuilder = new ActionBuilder();
45 actionBuilder.setExperimenterId(getExperimenterId());
49 protected final static ExperimenterId getExperimenterId(){
50 return new ExperimenterId(NiciraConstants.NX_VENDOR_ID);