- private static final int MESSAGE_LENGTH = 48;
- private static FlowModInputMessageFactory instance;
-
- private FlowModInputMessageFactory() {
- // singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized FlowModInputMessageFactory getInstance() {
- if(instance == null) {
- instance = new FlowModInputMessageFactory();
- }
- return instance;
- }
-
- @Override
- public void messageToBuffer(short version, ByteBuf out, FlowModInput message) {
- ByteBufUtils.writeOFHeader(instance, message, out);
- out.writeLong(message.getCookie().longValue());
- out.writeLong(message.getCookieMask().longValue());
- out.writeByte(message.getTableId().getValue().byteValue());
- out.writeByte(message.getCommand().getIntValue());
- out.writeShort(message.getIdleTimeout().intValue());
- out.writeShort(message.getHardTimeout().intValue());
- out.writeShort(message.getPriority());
- out.writeInt(message.getBufferId().intValue());
- out.writeInt(message.getOutPort().getValue().intValue());
- out.writeInt(message.getOutGroup().intValue());
- out.writeShort(createFlowModFlagsBitmask(message.getFlags()));
- ByteBufUtils.padBuffer(PADDING_IN_FLOW_MOD_MESSAGE, out);
- MatchSerializer.encodeMatch(message.getMatch(), out);
- InstructionsSerializer.encodeInstructions(message.getInstruction(), out);
- }