2 * Copyright (C) 2015 Intel, 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
9 package org.opendaylight.openflowjava.nx.codec.action;
11 import io.netty.buffer.ByteBuf;
12 import org.opendaylight.openflowjava.nx.api.NiciraActionDeserializerKey;
13 import org.opendaylight.openflowjava.nx.api.NiciraActionSerializerKey;
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.openflowjava.nx.action.rev140421.action.container.action.choice.ActionPushNsh;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionPushNshBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.push.nsh.grouping.NxActionPushNshBuilder;
22 * Codec for the push_nsh
24 public class PushNshCodec extends AbstractActionCodec {
25 public static final int LENGTH = 16;
26 public static final byte NXAST_PUSH_NSH_SUBTYPE = 38;
27 public static final NiciraActionSerializerKey SERIALIZER_KEY =
28 new NiciraActionSerializerKey(EncodeConstants.OF13_VERSION_ID, ActionPushNsh.class);
29 public static final NiciraActionDeserializerKey DESERIALIZER_KEY =
30 new NiciraActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, NXAST_PUSH_NSH_SUBTYPE);
31 private static final int padding = 6;
34 public void serialize(Action input, ByteBuf outBuffer) {
35 ActionPushNsh action = ((ActionPushNsh) input.getActionChoice());
36 serializeHeader(LENGTH, NXAST_PUSH_NSH_SUBTYPE, outBuffer);
37 outBuffer.writeZero(padding);
41 public Action deserialize(ByteBuf message) {
42 ActionBuilder actionBuilder = deserializeHeader(message);
43 ActionPushNshBuilder builder = new ActionPushNshBuilder();
44 NxActionPushNshBuilder nxActionPushNshBuilder = new NxActionPushNshBuilder();
45 message.skipBytes(padding);
46 builder.setNxActionPushNsh(nxActionPushNshBuilder.build());
47 actionBuilder.setActionChoice(builder.build());
48 return actionBuilder.build();