Bump upstreams
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / serialization / action / OF10SetNwSrcActionSerializer.java
1 /*
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowjava.protocol.impl.serialization.action;
9
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCase;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
15
16 /**
17  * Serializes OF 1.0 SetNwSrc actions.
18  *
19  * @author michal.polkorab
20  */
21 public class OF10SetNwSrcActionSerializer extends AbstractActionSerializer {
22     public OF10SetNwSrcActionSerializer() {
23         super(ActionConstants.SET_NW_SRC_CODE, ActionConstants.GENERAL_ACTION_LENGTH);
24     }
25
26     @Override
27     protected void serializeBody(final Action action, final ByteBuf outBuffer) {
28         outBuffer.writeBytes(IetfInetUtil.ipv4AddressBytes(
29             ((SetNwSrcCase) action.getActionChoice()).getSetNwSrcAction().getIpAddress()));
30     }
31 }