package org.opendaylight.openflowjava.protocol.impl.serialization.factories;
import io.netty.buffer.ByteBuf;
-
import java.util.HashMap;
import java.util.Map;
-
import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
-import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortMod;
/**
- * Translates PortMod messages
+ * Translates PortMod messages.
+ * OF protocol versions: 1.3.
* @author timotej.kubas
* @author michal.polkorab
*/
-public class PortModInputMessageFactory implements OFSerializer<PortModInput> {
+public class PortModInputMessageFactory implements OFSerializer<PortMod> {
private static final byte MESSAGE_TYPE = 16;
private static final byte PADDING_IN_PORT_MOD_MESSAGE_01 = 4;
private static final byte PADDING_IN_PORT_MOD_MESSAGE_02 = 2;
private static final byte PADDING_IN_PORT_MOD_MESSAGE_03 = 4;
@Override
- public void serialize(final PortModInput message, final ByteBuf outBuffer) {
+ public void serialize(final PortMod message, final ByteBuf outBuffer) {
+ int index = outBuffer.writerIndex();
ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
outBuffer.writeInt(message.getPortNo().getValue().intValue());
- ByteBufUtils.padBuffer(PADDING_IN_PORT_MOD_MESSAGE_01, outBuffer);
- outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(message.getHwAddress().getValue()));
- ByteBufUtils.padBuffer(PADDING_IN_PORT_MOD_MESSAGE_02, outBuffer);
+ outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_01);
+ outBuffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(message.getHwAddress()));
+ outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_02);
outBuffer.writeInt(createPortConfigBitmask(message.getConfig()));
outBuffer.writeInt(createPortConfigBitmask(message.getMask()));
outBuffer.writeInt(createPortFeaturesBitmask(message.getAdvertise()));
- ByteBufUtils.padBuffer(PADDING_IN_PORT_MOD_MESSAGE_03, outBuffer);
- ByteBufUtils.updateOFHeaderLength(outBuffer);
+ outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_03);
+ ByteBufUtils.updateOFHeaderLength(outBuffer, index);
}
/**