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.ext.deserialization;
\r
11 import io.netty.buffer.ByteBuf;
\r
13 import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
\r
14 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
\r
15 import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants;
\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;
\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder;
\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;
\r
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
\r
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;
\r
23 * @author michal.polkorab
\r
26 public class OF10VendorActionDeserializer implements OFDeserializer<Action>,
\r
27 HeaderDeserializer<Action> {
\r
30 public Action deserializeHeader(ByteBuf input) {
\r
31 ActionBuilder builder = new ActionBuilder();
\r
32 input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES);
\r
33 builder.setType(Experimenter.class);
\r
34 input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES);
\r
35 ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder();
\r
36 expBuilder.setExperimenter(input.readUnsignedInt());
\r
37 builder.addAugmentation(ExperimenterAction.class, expBuilder.build());
\r
38 return builder.build();
\r
42 public Action deserialize(ByteBuf input) {
\r
43 ActionBuilder builder = new ActionBuilder();
\r
44 input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES);
\r
45 builder.setType(Experimenter.class);
\r
46 int length = input.readUnsignedShort();
\r
47 // subtract experimenter header length
\r
48 length -= ExtConstants.EXPERIMENTER_IDS_LENGTH;
\r
49 ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder();
\r
50 expBuilder.setExperimenter(input.readUnsignedInt());
\r
52 byte[] data = new byte[length];
\r
53 input.readBytes(data);
\r
54 expBuilder.setData(data);
\r
56 builder.addAugmentation(ExperimenterAction.class, expBuilder.build());
\r
57 return builder.build();
\r