2 * Copyright (c) 2016 Pantheon Technologies s.r.o. 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.openflowplugin.impl.protocol.serialization.actions;
11 import com.google.common.base.MoreObjects;
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
14 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
15 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction;
19 public class OutputActionSerializer extends AbstractActionSerializer<OutputActionCase> {
22 public void serialize(OutputActionCase action, ByteBuf outBuffer) {
23 super.serialize(action, outBuffer);
24 final OutputAction outputAction = action.getOutputAction();
25 Long value = InventoryDataServiceUtil.portNumberfromNodeConnectorId(
27 outputAction.getOutputNodeConnector().getValue());
29 throw new IllegalArgumentException("Not a valid port number: "
30 + outputAction.getOutputNodeConnector().getValue());
32 outBuffer.writeInt(value.intValue());
33 outBuffer.writeShort(MoreObjects.firstNonNull(outputAction.getMaxLength(), 0));
34 outBuffer.writeZero(ActionConstants.OUTPUT_PADDING);
38 protected int getLength() {
39 return ActionConstants.LARGER_ACTION_LENGTH;
43 protected int getType() {
44 return ActionConstants.OUTPUT_CODE;