List of usage examples for io.netty.buffer ByteBuf readUnsignedByte
public abstract short readUnsignedByte();
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpProtoDeserializer.java
License:Open Source License
private static void addIpProtoValue(ByteBuf input, MatchEntryBuilder builder) { IpProtoCaseBuilder caseBuilder = new IpProtoCaseBuilder(); IpProtoBuilder protoBuilder = new IpProtoBuilder(); protoBuilder.setProtocolNumber(input.readUnsignedByte()); caseBuilder.setIpProto(protoBuilder.build()); builder.setMatchEntryValue(caseBuilder.build()); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsBosDeserializer.java
License:Open Source License
private static void addMplsBosValue(ByteBuf input, MatchEntryBuilder builder) { MplsBosCaseBuilder caseBuilder = new MplsBosCaseBuilder(); MplsBosBuilder bosBuilder = new MplsBosBuilder(); if (input.readUnsignedByte() != 0) { bosBuilder.setBos(true);//from ww w. ja v a2 s . co m } else { bosBuilder.setBos(false); } caseBuilder.setMplsBos(bosBuilder.build()); builder.setMatchEntryValue(caseBuilder.build()); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsTcDeserializer.java
License:Open Source License
private static void addMplsTcValue(ByteBuf input, MatchEntryBuilder builder) { MplsTcCaseBuilder caseBuilder = new MplsTcCaseBuilder(); MplsTcBuilder tcBuilder = new MplsTcBuilder(); tcBuilder.setTc(input.readUnsignedByte()); caseBuilder.setMplsTc(tcBuilder.build()); builder.setMatchEntryValue(caseBuilder.build()); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanPcpDeserializer.java
License:Open Source License
private static void addVlanPcpValue(ByteBuf input, MatchEntryBuilder builder) { VlanPcpCaseBuilder caseBuilder = new VlanPcpCaseBuilder(); VlanPcpBuilder vlanBuilder = new VlanPcpBuilder(); vlanBuilder.setVlanPcp(input.readUnsignedByte()); caseBuilder.setVlanPcp(vlanBuilder.build()); builder.setMatchEntryValue(caseBuilder.build()); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.FlowModInputMessageFactoryTest.java
License:Open Source License
/** * @throws Exception //from w ww . j a va 2s . com * Testing of {@link FlowModInputMessageFactory} for correct translation from POJO */ @Test public void testFlowModInputMessageFactory() throws Exception { FlowModInputBuilder builder = new FlowModInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 }; builder.setCookie(new BigInteger(1, cookie)); byte[] cookieMask = new byte[] { (byte) 0xFF, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30 }; builder.setCookieMask(new BigInteger(1, cookieMask)); builder.setTableId(new TableId(65L)); builder.setCommand(FlowModCommand.forValue(2)); builder.setIdleTimeout(12); builder.setHardTimeout(0); builder.setPriority(126); builder.setBufferId(2L); builder.setOutPort(new PortNumber(4422L)); builder.setOutGroup(98L); builder.setFlags(new FlowModFlags(true, false, true, false, true)); MatchBuilder matchBuilder = new MatchBuilder(); matchBuilder.setType(OxmMatchType.class); List<MatchEntries> entries = new ArrayList<>(); MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(InPhyPort.class); entriesBuilder.setHasMask(false); PortNumberMatchEntryBuilder portNumberBuilder = new PortNumberMatchEntryBuilder(); portNumberBuilder.setPortNumber(new PortNumber(42L)); entriesBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build()); entries.add(entriesBuilder.build()); entriesBuilder.setOxmClass(Nxm0Class.class); entriesBuilder.setOxmMatchField(IpEcn.class); entriesBuilder.setHasMask(false); EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder(); ecnBuilder.setEcn((short) 4); entriesBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build()); entries.add(entriesBuilder.build()); matchBuilder.setMatchEntries(entries); builder.setMatch(matchBuilder.build()); List<Instruction> instructions = new ArrayList<>(); InstructionBuilder insBuilder = new InstructionBuilder(); insBuilder.setType(GotoTable.class); TableIdInstructionBuilder idBuilder = new TableIdInstructionBuilder(); idBuilder.setTableId((short) 43); insBuilder.addAugmentation(TableIdInstruction.class, idBuilder.build()); instructions.add(insBuilder.build()); insBuilder.setType(WriteMetadata.class); MetadataInstructionBuilder metaBuilder = new MetadataInstructionBuilder(); metaBuilder.setMetadata(cookie); metaBuilder.setMetadataMask(cookieMask); insBuilder.addAugmentation(MetadataInstruction.class, metaBuilder.build()); instructions.add(insBuilder.build()); insBuilder = new InstructionBuilder(); insBuilder.setType(ApplyActions.class); insBuilder.addAugmentation(MetadataInstruction.class, metaBuilder.build()); instructions.add(insBuilder.build()); builder.setInstruction(instructions); FlowModInput message = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); FlowModInputMessageFactory factory = FlowModInputMessageFactory.getInstance(); factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message); BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message)); cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; out.readBytes(cookie); Assert.assertEquals("Wrong cookie", message.getCookie(), new BigInteger(1, cookie)); cookieMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; out.readBytes(cookieMask); Assert.assertEquals("Wrong cookieMask", message.getCookieMask(), new BigInteger(1, cookieMask)); Assert.assertEquals("Wrong tableId", message.getTableId().getValue().intValue(), out.readUnsignedByte()); Assert.assertEquals("Wrong command", message.getCommand().getIntValue(), out.readUnsignedByte()); Assert.assertEquals("Wrong idleTimeOut", message.getIdleTimeout().intValue(), out.readShort()); Assert.assertEquals("Wrong hardTimeOut", message.getHardTimeout().intValue(), out.readShort()); Assert.assertEquals("Wrong priority", message.getPriority().intValue(), out.readUnsignedShort()); Assert.assertEquals("Wrong bufferId", message.getBufferId().intValue(), out.readUnsignedInt()); Assert.assertEquals("Wrong outPort", message.getOutPort().getValue().intValue(), out.readUnsignedInt()); Assert.assertEquals("Wrong outGroup", message.getOutGroup().intValue(), out.readUnsignedInt()); Assert.assertEquals("Wrong flags", message.getFlags(), createFlowModFlagsFromBitmap(out.readUnsignedShort())); out.skipBytes(PADDING_IN_FLOW_MOD_MESSAGE); Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort()); out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); Assert.assertEquals("Wrong oxm class", 0x8000, out.readUnsignedShort()); short fieldAndMask = out.readUnsignedByte(); Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1); Assert.assertEquals("Wrong oxm field", 1, fieldAndMask >> 1); out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); Assert.assertEquals("Wrong oxm value", 42, out.readUnsignedInt()); Assert.assertEquals("Wrong oxm class", 0, out.readUnsignedShort()); fieldAndMask = out.readUnsignedByte(); Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1); Assert.assertEquals("Wrong oxm field", 9, fieldAndMask >> 1); out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); Assert.assertEquals("Wrong oxm value", 4, out.readUnsignedByte()); out.skipBytes(7); Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); Assert.assertEquals("Wrong instruction value", 43, out.readUnsignedByte()); out.skipBytes(3); Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort()); out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); out.skipBytes(EncodeConstants.SIZE_OF_INT_IN_BYTES); byte[] cookieRead = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; out.readBytes(cookieRead); byte[] cookieMaskRead = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; out.readBytes(cookieMaskRead); Assert.assertArrayEquals("Wrong metadata", cookie, cookieRead); Assert.assertArrayEquals("Wrong metadata mask", cookieMask, cookieMaskRead); Assert.assertEquals("Wrong instruction type", 4, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort()); out.skipBytes(4); Assert.assertTrue("Unread data", out.readableBytes() == 0); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.FlowRemovedMessageFactoryTest.java
License:Open Source License
@Test public void testSerialize() throws Exception { FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setCookie(BigInteger.valueOf(1234L)); builder.setPriority(1234);/*from w w w . ja va 2 s . c o m*/ builder.setReason(FlowRemovedReason.forValue(2)); builder.setTableId(new TableId(65L)); builder.setDurationSec(1234L); builder.setDurationNsec(1234L); builder.setIdleTimeout(1234); builder.setHardTimeout(1234); builder.setPacketCount(BigInteger.valueOf(1234L)); builder.setByteCount(BigInteger.valueOf(1234L)); MatchBuilder matchBuilder = new MatchBuilder(); matchBuilder.setType(OxmMatchType.class); List<MatchEntry> entries = new ArrayList<>(); MatchEntryBuilder entriesBuilder = new MatchEntryBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(InPhyPort.class); entriesBuilder.setHasMask(false); InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder(); InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder(); inPhyPortBuilder.setPortNumber(new PortNumber(42L)); inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build()); entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build()); entries.add(entriesBuilder.build()); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(IpEcn.class); entriesBuilder.setHasMask(false); IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder(); IpEcnBuilder ipEcnBuilder = new IpEcnBuilder(); ipEcnBuilder.setEcn((short) 4); ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build()); entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build()); entries.add(entriesBuilder.build()); matchBuilder.setMatchEntry(entries); builder.setMatch(matchBuilder.build()); FlowRemovedMessage message = builder.build(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); factory.serialize(message, serializedBuffer); BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 72); Assert.assertEquals("Wrong cookie", message.getCookie().longValue(), serializedBuffer.readLong()); Assert.assertEquals("Wrong priority", message.getPriority().intValue(), serializedBuffer.readShort()); Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readByte()); Assert.assertEquals("Wrong Table ID", message.getTableId().getValue().intValue(), serializedBuffer.readUnsignedByte()); Assert.assertEquals("Wrong duration sec", message.getDurationSec().intValue(), serializedBuffer.readInt()); Assert.assertEquals("Wrong duration nsec", message.getDurationNsec().intValue(), serializedBuffer.readInt()); Assert.assertEquals("Wrong Idle timeout", message.getIdleTimeout().intValue(), serializedBuffer.readShort()); Assert.assertEquals("Wrong Hard timeout", message.getIdleTimeout().intValue(), serializedBuffer.readShort()); Assert.assertEquals("Wrong Packet count", message.getPacketCount().longValue(), serializedBuffer.readLong()); Assert.assertEquals("Wrong Byte count", message.getByteCount().longValue(), serializedBuffer.readLong()); Assert.assertEquals("Wrong match type", 1, serializedBuffer.readUnsignedShort()); serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); Assert.assertEquals("Wrong oxm class", 0x8000, serializedBuffer.readUnsignedShort()); short fieldAndMask = serializedBuffer.readUnsignedByte(); Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1); Assert.assertEquals("Wrong oxm field", 1, fieldAndMask >> 1); serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); Assert.assertEquals("Wrong oxm value", 42, serializedBuffer.readUnsignedInt()); Assert.assertEquals("Wrong oxm class", 0x8000, serializedBuffer.readUnsignedShort()); fieldAndMask = serializedBuffer.readUnsignedByte(); Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1); Assert.assertEquals("Wrong oxm field", 9, fieldAndMask >> 1); serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); Assert.assertEquals("Wrong oxm value", 4, serializedBuffer.readUnsignedByte()); serializedBuffer.skipBytes(7); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetFeaturesOutputFactoryTest.java
License:Open Source License
@Test public void testSerialize() throws Exception { GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setDatapathId(BigInteger.valueOf(1234L)); builder.setBuffers(1234L);//w w w. j a v a 2s. com builder.setTables((short) 12); builder.setAuxiliaryId((short) 12); builder.setCapabilities(new Capabilities(true, false, true, false, true, false, true)); builder.setReserved(1234L); GetFeaturesOutput message = builder.build(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); factory.serialize(message, serializedBuffer); BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 32); Assert.assertEquals("Wrong DatapathId", message.getDatapathId().longValue(), serializedBuffer.readLong()); Assert.assertEquals("Wrong Buffer ID", message.getBuffers().longValue(), serializedBuffer.readInt()); Assert.assertEquals("Wrong tables", message.getTables().shortValue(), serializedBuffer.readUnsignedByte()); Assert.assertEquals("Wrong auxiliary ID", message.getAuxiliaryId().shortValue(), serializedBuffer.readUnsignedByte()); serializedBuffer.skipBytes(PADDING); Assert.assertEquals("Wrong Capabilities", message.getCapabilities(), createCapabilities(serializedBuffer.readInt())); Assert.assertEquals("Wrong reserved", message.getReserved().longValue(), serializedBuffer.readInt()); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.GroupModInputMessageFactoryTest.java
License:Open Source License
/** * @throws Exception/*from w ww.j a va2s. c o m*/ * Testing of {@link GroupModInputMessageFactory} for correct translation from POJO */ @Test public void testGroupModInputMessage() throws Exception { GroupModInputBuilder builder = new GroupModInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setCommand(GroupModCommand.forValue(2)); builder.setType(GroupType.forValue(3)); builder.setGroupId(new GroupId(256L)); List<BucketsList> exp = createBucketsList(); builder.setBucketsList(exp); GroupModInput message = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); GroupModInputMessageFactory factory = GroupModInputMessageFactory.getInstance(); factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message); BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message)); Assert.assertEquals("Wrong command", message.getCommand().getIntValue(), out.readUnsignedShort()); Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedByte()); out.skipBytes(PADDING_IN_GROUP_MOD_MESSAGE); Assert.assertEquals("Wrong groupId", message.getGroupId().getValue().intValue(), out.readUnsignedInt()); List<BucketsList> rec = createBucketsListFromBufer(out); Assert.assertArrayEquals("Wrong bucketList", exp.toArray(), rec.toArray()); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MeterModInputMessageFactoryTest.java
License:Open Source License
private static List<Bands> decodeBandsList(ByteBuf input) { List<Bands> bandsList = new ArrayList<>(); BandsBuilder bandsBuilder = new BandsBuilder(); MeterBandDropCaseBuilder dropCaseBuilder = new MeterBandDropCaseBuilder(); MeterBandDropBuilder dropBand = new MeterBandDropBuilder(); dropBand.setType(MeterBandType.forValue(input.readUnsignedShort())); input.skipBytes(Short.SIZE / Byte.SIZE); dropBand.setRate(input.readUnsignedInt()); dropBand.setBurstSize(input.readUnsignedInt()); input.skipBytes(4);/*from www .java 2s. c o m*/ dropCaseBuilder.setMeterBandDrop(dropBand.build()); bandsList.add(bandsBuilder.setMeterBand(dropCaseBuilder.build()).build()); MeterBandDscpRemarkCaseBuilder dscpCaseBuilder = new MeterBandDscpRemarkCaseBuilder(); MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder(); dscpRemarkBand.setType(MeterBandType.forValue(input.readUnsignedShort())); input.skipBytes(Short.SIZE / Byte.SIZE); dscpRemarkBand.setRate(input.readUnsignedInt()); dscpRemarkBand.setBurstSize(input.readUnsignedInt()); dscpRemarkBand.setPrecLevel(input.readUnsignedByte()); input.skipBytes(3); dscpCaseBuilder.setMeterBandDscpRemark(dscpRemarkBand.build()); bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build()); MeterBandExperimenterCaseBuilder expCaseBuilder = new MeterBandExperimenterCaseBuilder(); MeterBandExperimenterBuilder experimenterBand = new MeterBandExperimenterBuilder(); experimenterBand.setType(MeterBandType.forValue(input.readUnsignedShort())); input.skipBytes(Short.SIZE / Byte.SIZE); experimenterBand.setRate(input.readUnsignedInt()); experimenterBand.setBurstSize(input.readUnsignedInt()); experimenterBand.setExperimenter(input.readUnsignedInt()); expCaseBuilder.setMeterBandExperimenter(experimenterBand.build()); bandsList.add(bandsBuilder.setMeterBand(expCaseBuilder.build()).build()); return bandsList; }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart.MultipartRequestTableFeaturesTest.java
License:Open Source License
/** * @throws Exception/*from w w w . jav a 2 s. c o m*/ * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO */ @Test public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setType(MultipartType.forValue(12)); builder.setFlags(new MultipartRequestFlags(true)); MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder(); MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder(); List<TableFeatures> tableFeaturesList = new ArrayList<>(); TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder(); tableFeaturesBuilder.setTableId((short) 8); tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG"); tableFeaturesBuilder .setMetadataMatch(new BigInteger(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 })); tableFeaturesBuilder .setMetadataWrite(new BigInteger(new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 })); tableFeaturesBuilder.setConfig(new TableConfig(true)); tableFeaturesBuilder.setMaxEntries(65L); List<TableFeatureProperties> properties = new ArrayList<>(); TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLES); NextTableRelatedTableFeaturePropertyBuilder nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder(); List<NextTableIds> nextIds = new ArrayList<>(); nextIds.add(new NextTableIdsBuilder().setTableId((short) 1).build()); nextIds.add(new NextTableIdsBuilder().setTableId((short) 2).build()); nextPropBuilder.setNextTableIds(nextIds); propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build()); properties.add(propBuilder.build()); propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS); nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder(); nextIds = new ArrayList<>(); nextPropBuilder.setNextTableIds(nextIds); propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build()); properties.add(propBuilder.build()); propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONS); InstructionRelatedTableFeaturePropertyBuilder insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder(); List<Instruction> insIds = new ArrayList<>(); InstructionBuilder insBuilder = new InstructionBuilder(); insBuilder.setInstructionChoice(new WriteActionsCaseBuilder().build()); insIds.add(insBuilder.build()); insBuilder = new InstructionBuilder(); insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build()); insIds.add(insBuilder.build()); insPropBuilder.setInstruction(insIds); propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build()); properties.add(propBuilder.build()); propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS); insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder(); insIds = new ArrayList<>(); insBuilder = new InstructionBuilder(); insBuilder.setInstructionChoice(new WriteMetadataCaseBuilder().build()); insIds.add(insBuilder.build()); insBuilder = new InstructionBuilder(); insBuilder.setInstructionChoice(new ApplyActionsCaseBuilder().build()); insIds.add(insBuilder.build()); insBuilder = new InstructionBuilder(); insBuilder.setInstructionChoice(new MeterCaseBuilder().build()); insIds.add(insBuilder.build()); insBuilder = new InstructionBuilder(); insBuilder.setInstructionChoice(new ClearActionsCaseBuilder().build()); insIds.add(insBuilder.build()); insBuilder = new InstructionBuilder(); insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build()); insIds.add(insBuilder.build()); insPropBuilder.setInstruction(insIds); propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build()); properties.add(propBuilder.build()); tableFeaturesBuilder.setTableFeatureProperties(properties); tableFeaturesList.add(tableFeaturesBuilder.build()); tableFeaturesBuilder = new TableFeaturesBuilder(); tableFeaturesBuilder.setTableId((short) 8); tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG"); tableFeaturesBuilder .setMetadataMatch(new BigInteger(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 })); tableFeaturesBuilder .setMetadataWrite(new BigInteger(new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 })); tableFeaturesBuilder.setConfig(new TableConfig(true)); tableFeaturesBuilder.setMaxEntries(67L); properties = new ArrayList<>(); propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONS); ActionRelatedTableFeaturePropertyBuilder actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); List<Action> actions = new ArrayList<>(); ActionBuilder actionBuilder = new ActionBuilder(); actionBuilder.setActionChoice(new OutputActionCaseBuilder().build()); actions.add(actionBuilder.build()); actBuilder.setAction(actions); propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); properties.add(propBuilder.build()); propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS); actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); actions = new ArrayList<>(); actBuilder.setAction(actions); propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); properties.add(propBuilder.build()); propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONS); actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); actions = new ArrayList<>(); actBuilder.setAction(actions); propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); properties.add(propBuilder.build()); propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS); actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); actions = new ArrayList<>(); actBuilder.setAction(actions); propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); properties.add(propBuilder.build()); propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTMATCH); OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); List<MatchEntry> entries = new ArrayList<>(); MatchEntryBuilder entriesBuilder = new MatchEntryBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(InPhyPort.class); entriesBuilder.setHasMask(false); entries.add(entriesBuilder.build()); entriesBuilder = new MatchEntryBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(InPort.class); entriesBuilder.setHasMask(false); entries.add(entriesBuilder.build()); oxmBuilder.setMatchEntry(entries); propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); properties.add(propBuilder.build()); propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTWILDCARDS); oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); entries = new ArrayList<>(); oxmBuilder.setMatchEntry(entries); propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); properties.add(propBuilder.build()); propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELD); oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); entries = new ArrayList<>(); oxmBuilder.setMatchEntry(entries); propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); properties.add(propBuilder.build()); propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS); oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); entries = new ArrayList<>(); oxmBuilder.setMatchEntry(entries); propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); properties.add(propBuilder.build()); propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD); oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); entries = new ArrayList<>(); entriesBuilder = new MatchEntryBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(IpProto.class); entriesBuilder.setHasMask(false); entries.add(entriesBuilder.build()); entriesBuilder = new MatchEntryBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(IpEcn.class); entriesBuilder.setHasMask(false); entries.add(entriesBuilder.build()); oxmBuilder.setMatchEntry(entries); propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); properties.add(propBuilder.build()); propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS); oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); entries = new ArrayList<>(); oxmBuilder.setMatchEntry(entries); propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); properties.add(propBuilder.build()); tableFeaturesBuilder.setTableFeatureProperties(properties); tableFeaturesList.add(tableFeaturesBuilder.build()); featuresBuilder.setTableFeatures(tableFeaturesList); caseBuilder.setMultipartRequestTableFeatures(featuresBuilder.build()); builder.setMultipartRequestBody(caseBuilder.build()); MultipartRequestInput message = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); multipartFactory.serialize(message, out); BufferHelper.checkHeaderV13(out, (byte) 18, 296); Assert.assertEquals("Wrong type", 12, out.readUnsignedShort()); Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort()); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); Assert.assertEquals("Wrong length", 120, out.readUnsignedShort()); Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte()); out.skipBytes(5); Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", ByteBufUtils.decodeNullTerminatedString(out, 32)); byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; out.readBytes(metadataMatch); Assert.assertArrayEquals("Wrong metadata-match", new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }, metadataMatch); byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; out.readBytes(metadataWrite); Assert.assertArrayEquals("Wrong metadata-write", new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }, metadataWrite); Assert.assertEquals("Wrong config", 8, out.readUnsignedInt()); Assert.assertEquals("Wrong max-entries", 65, out.readUnsignedInt()); Assert.assertEquals("Wrong property type", 2, out.readUnsignedShort()); Assert.assertEquals("Wrong property length", 6, out.readUnsignedShort()); Assert.assertEquals("Wrong next-registry-id", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong next-registry-id", 2, out.readUnsignedByte()); out.skipBytes(2); Assert.assertEquals("Wrong property type", 3, out.readUnsignedShort()); Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong property type", 0, out.readUnsignedShort()); Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction type", 3, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong property type", 1, out.readUnsignedShort()); Assert.assertEquals("Wrong property length", 24, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction type", 4, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction type", 6, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction type", 5, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); Assert.assertEquals("Wrong length", 160, out.readUnsignedShort()); Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte()); out.skipBytes(5); Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", ByteBufUtils.decodeNullTerminatedString(out, 32)); metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; out.readBytes(metadataMatch); Assert.assertArrayEquals("Wrong metadata-match", new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }, metadataMatch); metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; out.readBytes(metadataWrite); Assert.assertArrayEquals("Wrong metadata-write", new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }, metadataWrite); Assert.assertEquals("Wrong config", 8, out.readUnsignedInt()); Assert.assertEquals("Wrong max-entries", 67, out.readUnsignedInt()); Assert.assertEquals("Wrong property type", 4, out.readUnsignedShort()); Assert.assertEquals("Wrong property length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort()); Assert.assertEquals("Wrong property type", 5, out.readUnsignedShort()); Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong property type", 6, out.readUnsignedShort()); Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong property type", 7, out.readUnsignedShort()); Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong property type", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort()); Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match field&mask", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match length", 4, out.readUnsignedByte()); Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match field&mask", 0, out.readUnsignedByte()); Assert.assertEquals("Wrong match length", 4, out.readUnsignedByte()); out.skipBytes(4); Assert.assertEquals("Wrong property type", 10, out.readUnsignedShort()); Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong property type", 12, out.readUnsignedShort()); Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong property type", 13, out.readUnsignedShort()); Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong property type", 14, out.readUnsignedShort()); Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort()); Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match field&mask", 20, out.readUnsignedByte()); Assert.assertEquals("Wrong match length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match field&mask", 18, out.readUnsignedByte()); Assert.assertEquals("Wrong match length", 1, out.readUnsignedByte()); out.skipBytes(4); Assert.assertEquals("Wrong property type", 15, out.readUnsignedShort()); Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); out.skipBytes(4); Assert.assertTrue("Unread data", out.readableBytes() == 0); }