@Override public FlowModInput deserialize(ByteBuf rawMessage) { FlowModInputBuilder builder = new FlowModInputBuilder(); builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); builder.setXid(rawMessage.readUnsignedInt()); byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; rawMessage.readBytes(cookie); builder.setCookie(new BigInteger(1, cookie)); byte[] cookie_mask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; rawMessage.readBytes(cookie_mask); builder.setCookieMask(new BigInteger(1, cookie_mask)); builder.setTableId(new TableId((long) rawMessage.readUnsignedByte())); builder.setCommand(FlowModCommand.forValue(rawMessage.readUnsignedByte())); builder.setIdleTimeout(rawMessage.readUnsignedShort()); builder.setHardTimeout(rawMessage.readUnsignedShort()); builder.setPriority(rawMessage.readUnsignedShort()); builder.setBufferId(rawMessage.readUnsignedInt()); builder.setOutPort(new PortNumber(rawMessage.readUnsignedInt())); builder.setOutGroup(rawMessage.readUnsignedInt()); builder.setFlags(createFlowModFlagsFromBitmap(rawMessage.readUnsignedShort())); rawMessage.skipBytes(PADDING); OFDeserializer<Match> matchDeserializer = registry.getDeserializer( new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class)); builder.setMatch(matchDeserializer.deserialize(rawMessage)); CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); List<Instruction> instructions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, rawMessage.readableBytes(), rawMessage, keyMaker, registry); builder.setInstruction(instructions); return builder.build(); }
private FlowModInputBuilder toFlowModInput(Flow flow, short version, BigInteger datapathid) { FlowModInputBuilder flowMod = new FlowModInputBuilder(); salToOFFlowCookie(flow, flowMod); salToOFFlowCookieMask(flow, flowMod); salToOFFlowTableId(flow, flowMod); salToOFFlowCommand(flow, flowMod); salToOFFlowIdleTimeout(flow, flowMod); salToOFFlowHardTimeout(flow, flowMod); salToOFFlowPriority(flow, flowMod); salToOFFlowBufferId(flow, flowMod); salToOFFlowOutPort(flow, flowMod); salToOFFlowOutGroup(flow, flowMod); // convert and inject flowFlags FlowFlagReactor.getInstance().convert(flow.getFlags(), version, flowMod, getConvertorExecutor()); // convert and inject match MatchReactor.getInstance().convert(flow.getMatch(), version, flowMod, getConvertorExecutor()); if (flow.getInstructions() != null) { flowMod.setInstruction(toInstructions(flow, version, datapathid)); flowMod.setAction(getActions(version, datapathid, flow)); } flowMod.setVersion(version); return flowMod; }