Created experimenter subtype for vendor's actions
[openflowjava.git] / openflow-extension-nicira / src / main / java / org / opendaylight / openflowjava / nx / codec / action / RegLoadCodec.java
1 package org.opendaylight.openflowjava.nx.codec.action;
2
3 import io.netty.buffer.ByteBuf;
4
5 import java.math.BigInteger;
6
7 import org.opendaylight.openflowjava.nx.NiciraConstants;
8 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
9 import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey;
10 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.NxmNxRegLoad;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxAction;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.load.grouping.ActionRegLoad;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.load.grouping.ActionRegLoadBuilder;
16
17 public class RegLoadCodec extends AbstractActionSerializer implements OFDeserializer<ActionRegLoad> {
18
19     public static final ExperimenterActionSerializerKey SERIALIZER_KEY = new ExperimenterActionSerializerKey(
20             EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID, NxmNxRegLoad.class);
21     public static final int LENGTH = 24;
22     public static final byte SUBTYPE = 7; // NXAST_REG_LOAD
23
24     @Override
25     public void serialize(Action input, ByteBuf outBuffer) {
26         ActionRegLoad actionRegLoad = input.getAugmentation(OfjAugNxAction.class).getActionRegLoad();
27         serializeHeader(LENGTH, SUBTYPE, outBuffer);
28         outBuffer.writeShort(actionRegLoad.getOfsNbits());
29         outBuffer.writeInt(actionRegLoad.getDst().intValue());
30         outBuffer.writeLong(actionRegLoad.getValue().longValue());
31     }
32
33     @Override
34     public ActionRegLoad deserialize(ByteBuf message) {
35         ActionRegLoadBuilder actionRegLoadBuilder = new ActionRegLoadBuilder();
36         actionRegLoadBuilder.setOfsNbits(message.readUnsignedShort());
37         actionRegLoadBuilder.setDst(message.readUnsignedInt());
38         actionRegLoadBuilder.setValue(BigInteger.valueOf(message.readLong()));
39         return actionRegLoadBuilder.build();
40     }
41
42 }