\r
import org.opendaylight.openflowjava.protocol.impl.serialization.OFSerializer;\r
import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
+import org.opendaylight.openflowjava.protocol.impl.util.InstructionsSerializer;\r
+import org.opendaylight.openflowjava.protocol.impl.util.MatchSerializer;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;\r
\r
/**\r
+ * Translates FlowMod messages\r
* @author timotej.kubas\r
* @author michal.polkorab\r
*/\r
public class FlowModInputMessageFactory implements OFSerializer<FlowModInput> {\r
private static final byte MESSAGE_TYPE = 14;\r
private static final byte PADDING_IN_FLOW_MOD_MESSAGE = 2;\r
- private static final int MESSAGE_LENGTH = 48; //flags\r
+ private static final int MESSAGE_LENGTH = 48;\r
private static FlowModInputMessageFactory instance;\r
\r
private FlowModInputMessageFactory() {\r
out.writeShort(message.getIdleTimeout().intValue());\r
out.writeShort(message.getHardTimeout().intValue());\r
out.writeShort(message.getPriority());\r
+ out.writeInt(message.getBufferId().intValue());\r
out.writeInt(message.getOutPort().getValue().intValue());\r
out.writeInt(message.getOutGroup().intValue());\r
out.writeShort(createFlowModFlagsBitmask(message.getFlags()));\r
ByteBufUtils.padBuffer(PADDING_IN_FLOW_MOD_MESSAGE, out);\r
- // TODO implementation of match structure\r
- // TODO implementation of instructions\r
+ MatchSerializer.encodeMatch(message.getMatch(), out);\r
+ InstructionsSerializer.encodeInstructions(message.getInstructions(), out);\r
+ \r
}\r
\r
@Override\r
public int computeLength(FlowModInput message) {\r
- return MESSAGE_LENGTH;\r
+ return MESSAGE_LENGTH + MatchSerializer.computeMatchLength(message.getMatch())\r
+ + InstructionsSerializer.computeInstructionsLength(message.getInstructions());\r
}\r
\r
@Override\r
public byte getMessageType() {\r
return MESSAGE_TYPE;\r
}\r
- \r
+\r
private static int createFlowModFlagsBitmask(FlowModFlags flags) {\r
int flowModFlagBitmask = 0;\r
Map<Integer, Boolean> flowModFlagsMap = new HashMap<>();\r
flowModFlagBitmask = ByteBufUtils.fillBitMaskFromMap(flowModFlagsMap);\r
return flowModFlagBitmask;\r
}\r
+ \r
+ \r
}\r