0776edd41b27d517a76303a58fc440bea565ee2a
[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.protocol.api.extensibility.OFDeserializer;
8 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
9 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.load.grouping.ActionRegLoad;
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.load.grouping.ActionRegLoadBuilder;
11
12 public class RegLoadCodec implements OFSerializer<ActionRegLoad>, OFDeserializer<ActionRegLoad> {
13
14     public static final int LENGTH = 24;
15     public static final byte SUBTYPE = 7; // NXAST_REG_LOAD
16
17     @Override
18     public void serialize(ActionRegLoad input, ByteBuf outBuffer) {
19         outBuffer.writeShort(input.getOfsNbits());
20         outBuffer.writeInt(input.getDst().intValue());
21         outBuffer.writeLong(input.getValue().longValue());
22     }
23
24     @Override
25     public ActionRegLoad deserialize(ByteBuf message) {
26         ActionRegLoadBuilder actionRegLoadBuilder = new ActionRegLoadBuilder();
27         actionRegLoadBuilder.setOfsNbits(message.readUnsignedShort());
28         actionRegLoadBuilder.setDst(message.readUnsignedInt());
29         actionRegLoadBuilder.setValue(BigInteger.valueOf(message.readLong()));
30         return actionRegLoadBuilder.build();
31     }
32
33 }