List of usage examples for io.netty.buffer ByteBuf readUnsignedByte
public abstract short readUnsignedByte();
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmUdpSrcSerializerTest.java
License:Open Source License
private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); short fieldAndMask = buffer.readUnsignedByte(); assertEquals("Wrong oxm-field", OxmMatchConstants.UDP_SRC, fieldAndMask >>> 1); assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanPcpSerializerTest.java
License:Open Source License
/** * Test correct serialization/*from w ww . j av a2 s . c om*/ */ @Test public void testSerialize() { MatchEntryBuilder builder = prepareVlanPcpMatchEntry((short) 42); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); checkHeader(buffer, false); assertEquals("Wrong value", 42, buffer.readUnsignedByte()); assertTrue("Unexpected data", buffer.readableBytes() == 0); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanPcpSerializerTest.java
License:Open Source License
private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); short fieldAndMask = buffer.readUnsignedByte(); assertEquals("Wrong oxm-field", OxmMatchConstants.VLAN_PCP, fieldAndMask >>> 1); assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanVidSerializerTest.java
License:Open Source License
private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); short fieldAndMask = buffer.readUnsignedByte(); assertEquals("Wrong oxm-field", OxmMatchConstants.VLAN_VID, fieldAndMask >>> 1); assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); if (hasMask) { assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); } else {// ww w . j av a 2 s .com assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); } }
From source file:org.opendaylight.openflowjava.protocol.impl.util.ActionsDeserializer.java
License:Open Source License
private static Action createSetMplsTtlAction(ByteBuf in, ActionBuilder actionBuilder) { actionBuilder.setType(SetMplsTtl.class); MplsTtlActionBuilder mplsTtl = new MplsTtlActionBuilder(); mplsTtl.setMplsTtl(in.readUnsignedByte()); actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtl.build()); in.skipBytes(PADDING_IN_SET_MPLS_TTL_ACTIONS_HEADER); return actionBuilder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.util.ActionsDeserializer.java
License:Open Source License
private static Action createSetNwTtlAction(ByteBuf in, ActionBuilder actionBuilder) { actionBuilder.setType(SetNwTtl.class); NwTtlActionBuilder nwTtl = new NwTtlActionBuilder(); nwTtl.setNwTtl(in.readUnsignedByte()); actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build()); in.skipBytes(PADDING_IN_NW_TTL_ACTIONS_HEADER); return actionBuilder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.util.ActionsSerializerTest.java
License:Open Source License
/** * Testing correct serialization of actions */// www. j a va 2 s .c om @Test public void test() { List<Action> actions = new ArrayList<>(); ActionBuilder actionBuilder = new ActionBuilder(); actionBuilder.setType(Output.class); PortActionBuilder port = new PortActionBuilder(); port.setPort(new PortNumber(42L)); actionBuilder.addAugmentation(PortAction.class, port.build()); MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); maxLen.setMaxLength(52); actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(CopyTtlOut.class); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(CopyTtlIn.class); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(SetMplsTtl.class); MplsTtlActionBuilder mplsTtl = new MplsTtlActionBuilder(); mplsTtl.setMplsTtl((short) 4); actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtl.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(DecMplsTtl.class); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(PushVlan.class); EthertypeActionBuilder etherType = new EthertypeActionBuilder(); etherType.setEthertype(new EtherType(16)); actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(PopVlan.class); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(PushMpls.class); etherType = new EthertypeActionBuilder(); etherType.setEthertype(new EtherType(17)); actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(PopMpls.class); etherType = new EthertypeActionBuilder(); etherType.setEthertype(new EtherType(18)); actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(SetQueue.class); QueueIdActionBuilder queueId = new QueueIdActionBuilder(); queueId.setQueueId(1234L); actionBuilder.addAugmentation(QueueIdAction.class, queueId.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(Group.class); GroupIdActionBuilder group = new GroupIdActionBuilder(); group.setGroupId(555L); actionBuilder.addAugmentation(GroupIdAction.class, group.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(SetNwTtl.class); NwTtlActionBuilder nwTtl = new NwTtlActionBuilder(); nwTtl.setNwTtl((short) 8); actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(DecNwTtl.class); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(SetField.class); OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); List<MatchEntries> entries = new ArrayList<>(); MatchEntriesBuilder matchBuilder = new MatchEntriesBuilder(); matchBuilder.setOxmClass(OpenflowBasicClass.class); matchBuilder.setOxmMatchField(InPort.class); matchBuilder.setHasMask(false); PortNumberMatchEntryBuilder portBuilder = new PortNumberMatchEntryBuilder(); portBuilder.setPortNumber(new PortNumber(1L)); matchBuilder.addAugmentation(PortNumberMatchEntry.class, portBuilder.build()); entries.add(matchBuilder.build()); matchEntries.setMatchEntries(entries); actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(PushPbb.class); etherType = new EthertypeActionBuilder(); etherType.setEthertype(new EtherType(19)); actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(PopPbb.class); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(Experimenter.class); ExperimenterActionBuilder experimenter = new ExperimenterActionBuilder(); experimenter.setExperimenter(4L); experimenter.setData(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 }); actionBuilder.addAugmentation(ExperimenterAction.class, experimenter.build()); actions.add(actionBuilder.build()); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); ActionsSerializer.encodeActions(actions, out); Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); Assert.assertEquals("Wrong action port", 42, out.readUnsignedInt()); Assert.assertEquals("Wrong action max-length", 52, out.readUnsignedShort()); out.skipBytes(6); Assert.assertEquals("Wrong action type", 11, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong action type", 12, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong action type", 15, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action mpls-ttl", 4, out.readUnsignedByte()); out.skipBytes(3); Assert.assertEquals("Wrong action type", 16, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong action type", 17, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action ethertype", 16, out.readUnsignedShort()); out.skipBytes(2); Assert.assertEquals("Wrong action type", 18, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong action type", 19, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action ethertype", 17, out.readUnsignedShort()); out.skipBytes(2); Assert.assertEquals("Wrong action type", 20, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action ethertype", 18, out.readUnsignedShort()); out.skipBytes(2); Assert.assertEquals("Wrong action type", 21, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action queue-id", 1234, out.readUnsignedInt()); Assert.assertEquals("Wrong action type", 22, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action group", 555, out.readUnsignedInt()); Assert.assertEquals("Wrong action type", 23, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action nw-ttl", 8, out.readUnsignedByte()); out.skipBytes(3); Assert.assertEquals("Wrong action type", 24, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong action type", 25, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & mask", 0, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 1, out.readUnsignedInt()); out.skipBytes(4); Assert.assertEquals("Wrong action type", 26, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action ethertype", 19, out.readUnsignedShort()); out.skipBytes(2); Assert.assertEquals("Wrong action type", 27, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong action type", 65535, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); Assert.assertEquals("Wrong experimenter", 4, out.readUnsignedInt()); byte[] data = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; out.readBytes(data); Assert.assertArrayEquals("Wrong data", new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 }, data); Assert.assertTrue("Unread data", out.readableBytes() == 0); }
From source file:org.opendaylight.openflowjava.protocol.impl.util.InstructionsDeserializer.java
License:Open Source License
private static void createGotoTableInstruction(InstructionBuilder builder, ByteBuf input) { builder.setType(GotoTable.class); TableIdInstructionBuilder tableBuilder = new TableIdInstructionBuilder(); tableBuilder.setTableId(input.readUnsignedByte()); builder.addAugmentation(TableIdInstruction.class, tableBuilder.build()); input.skipBytes(GOTO_TABLE_PADDING); }
From source file:org.opendaylight.openflowjava.protocol.impl.util.InstructionsSerializerTest.java
License:Open Source License
/** * Testing instructions translation// w ww.ja v a 2 s.c om */ @Test public void test() { List<Instruction> instructions = new ArrayList<>(); // Goto_table instruction InstructionBuilder builder = new InstructionBuilder(); builder.setType(GotoTable.class); TableIdInstructionBuilder tableIdBuilder = new TableIdInstructionBuilder(); tableIdBuilder.setTableId((short) 5); builder.addAugmentation(TableIdInstruction.class, tableIdBuilder.build()); instructions.add(builder.build()); builder = new InstructionBuilder(); // Write_metadata instruction builder.setType(WriteMetadata.class); MetadataInstructionBuilder metaBuilder = new MetadataInstructionBuilder(); metaBuilder.setMetadata(ByteBufUtils.hexStringToBytes("00 01 02 03 04 05 06 07")); metaBuilder.setMetadataMask(ByteBufUtils.hexStringToBytes("07 06 05 04 03 02 01 00")); builder.addAugmentation(MetadataInstruction.class, metaBuilder.build()); instructions.add(builder.build()); // Clear_actions instruction builder = new InstructionBuilder(); builder.setType(ClearActions.class); instructions.add(builder.build()); // Meter instruction builder = new InstructionBuilder(); builder.setType(Meter.class); MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder(); meterBuilder.setMeterId(42L); builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build()); instructions.add(builder.build()); // Write_actions instruction builder = new InstructionBuilder(); builder.setType(WriteActions.class); ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder(); List<Action> actions = new ArrayList<>(); ActionBuilder actionBuilder = new ActionBuilder(); actionBuilder.setType(Output.class); PortActionBuilder portBuilder = new PortActionBuilder(); portBuilder.setPort(new PortNumber(45L)); actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); MaxLengthActionBuilder maxBuilder = new MaxLengthActionBuilder(); maxBuilder.setMaxLength(55); actionBuilder.addAugmentation(MaxLengthAction.class, maxBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(SetNwTtl.class); NwTtlActionBuilder nwTtl = new NwTtlActionBuilder(); nwTtl.setNwTtl((short) 64); actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build()); actions.add(actionBuilder.build()); actionsBuilder.setAction(actions); builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); instructions.add(builder.build()); // Apply_actions instruction builder = new InstructionBuilder(); builder.setType(ApplyActions.class); actionsBuilder = new ActionsInstructionBuilder(); actions = new ArrayList<>(); actionBuilder = new ActionBuilder(); actionBuilder.setType(PushVlan.class); EthertypeActionBuilder ethertypeBuilder = new EthertypeActionBuilder(); ethertypeBuilder.setEthertype(new EtherType(14)); actionBuilder.addAugmentation(EthertypeAction.class, ethertypeBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(PopPbb.class); actions.add(actionBuilder.build()); actionsBuilder.setAction(actions); builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); instructions.add(builder.build()); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); InstructionsSerializer.encodeInstructions(instructions, out); Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction table-id", 5, out.readUnsignedByte()); out.skipBytes(3); Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction length", 24, out.readUnsignedShort()); out.skipBytes(4); byte[] actual = new byte[8]; out.readBytes(actual); Assert.assertEquals("Wrong instruction metadata", "00 01 02 03 04 05 06 07", ByteBufUtils.bytesToHexString(actual)); actual = new byte[8]; out.readBytes(actual); Assert.assertEquals("Wrong instruction metadata-mask", "07 06 05 04 03 02 01 00", ByteBufUtils.bytesToHexString(actual)); Assert.assertEquals("Wrong instruction type", 5, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong instruction type", 6, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction meter-id", 42, out.readUnsignedInt()); Assert.assertEquals("Wrong instruction type", 3, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction length", 32, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); Assert.assertEquals("Wrong action type", 45, out.readUnsignedInt()); Assert.assertEquals("Wrong action type", 55, out.readUnsignedShort()); out.skipBytes(6); Assert.assertEquals("Wrong action type", 23, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action type", 64, out.readUnsignedByte()); out.skipBytes(3); Assert.assertEquals("Wrong instruction type", 4, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction length", 24, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong action type", 17, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action ethertype", 14, out.readUnsignedShort()); out.skipBytes(2); Assert.assertEquals("Wrong action type", 27, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); out.skipBytes(4); Assert.assertTrue("Not all data were read", out.readableBytes() == 0); }
From source file:org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer.java
License:Open Source License
private static List<MatchEntries> createMatchEntriesInternal(ByteBuf in, int matchLength, boolean oneEntry) { List<MatchEntries> matchEntriesList = new ArrayList<>(); int currLength = 0; while (currLength < matchLength) { MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder(); switch (in.readUnsignedShort()) { case 0x0000: matchEntriesBuilder.setOxmClass(Nxm0Class.class); break; case 0x0001: matchEntriesBuilder.setOxmClass(Nxm1Class.class); break; case 0x8000: matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class); break; case 0xFFFF: matchEntriesBuilder.setOxmClass(ExperimenterClass.class); break; default://from ww w.j a va 2s.co m break; } int fieldAndMask = in.readUnsignedByte(); boolean hasMask = (fieldAndMask & 1) != 0; matchEntriesBuilder.setHasMask(hasMask); int matchField = fieldAndMask >> 1; int matchEntryLength = in.readUnsignedByte(); currLength += EncodeConstants.SIZE_OF_SHORT_IN_BYTES + (2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES) + matchEntryLength; switch (matchField) { case 0: matchEntriesBuilder.setOxmMatchField(InPort.class); PortNumberMatchEntryBuilder port = new PortNumberMatchEntryBuilder(); port.setPortNumber(new PortNumber(in.readUnsignedInt())); matchEntriesBuilder.addAugmentation(PortNumberMatchEntry.class, port.build()); break; case 1: matchEntriesBuilder.setOxmMatchField(InPhyPort.class); PortNumberMatchEntryBuilder phyPort = new PortNumberMatchEntryBuilder(); phyPort.setPortNumber(new PortNumber(in.readUnsignedInt())); matchEntriesBuilder.addAugmentation(PortNumberMatchEntry.class, phyPort.build()); break; case 2: matchEntriesBuilder.setOxmMatchField(Metadata.class); addMetadataAugmentation(matchEntriesBuilder, in); if (hasMask) { addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_LONG_IN_BYTES); } break; case 3: matchEntriesBuilder.setOxmMatchField(EthDst.class); addMacAddressAugmentation(matchEntriesBuilder, in); if (hasMask) { addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.MAC_ADDRESS_LENGTH); } break; case 4: matchEntriesBuilder.setOxmMatchField(EthSrc.class); addMacAddressAugmentation(matchEntriesBuilder, in); if (hasMask) { addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.MAC_ADDRESS_LENGTH); } break; case 5: matchEntriesBuilder.setOxmMatchField(EthType.class); EthTypeMatchEntryBuilder ethertypeBuilder = new EthTypeMatchEntryBuilder(); ethertypeBuilder.setEthType(new EtherType(in.readUnsignedShort())); matchEntriesBuilder.addAugmentation(EthTypeMatchEntry.class, ethertypeBuilder.build()); break; case 6: matchEntriesBuilder.setOxmMatchField(VlanVid.class); VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder(); int vidEntryValue = in.readUnsignedShort(); vlanVidBuilder.setCfiBit((vidEntryValue & (1 << 12)) != 0); // cfi is 13-th bit vlanVidBuilder.setVlanVid(vidEntryValue & ((1 << 12) - 1)); // value without 13-th bit matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build()); if (hasMask) { addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_SHORT_IN_BYTES); } break; case 7: matchEntriesBuilder.setOxmMatchField(VlanPcp.class); VlanPcpMatchEntryBuilder vlanPcpBuilder = new VlanPcpMatchEntryBuilder(); vlanPcpBuilder.setVlanPcp(in.readUnsignedByte()); matchEntriesBuilder.addAugmentation(VlanPcpMatchEntry.class, vlanPcpBuilder.build()); break; case 8: matchEntriesBuilder.setOxmMatchField(IpDscp.class); DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); dscpBuilder.setDscp(new Dscp(in.readUnsignedByte())); matchEntriesBuilder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); break; case 9: matchEntriesBuilder.setOxmMatchField(IpEcn.class); EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder(); ecnBuilder.setEcn(in.readUnsignedByte()); matchEntriesBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build()); break; case 10: matchEntriesBuilder.setOxmMatchField(IpProto.class); ProtocolNumberMatchEntryBuilder protoNumberBuilder = new ProtocolNumberMatchEntryBuilder(); protoNumberBuilder.setProtocolNumber(in.readUnsignedByte()); matchEntriesBuilder.addAugmentation(ProtocolNumberMatchEntry.class, protoNumberBuilder.build()); break; case 11: matchEntriesBuilder.setOxmMatchField(Ipv4Src.class); addIpv4AddressAugmentation(matchEntriesBuilder, in); if (hasMask) { addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES); } break; case 12: matchEntriesBuilder.setOxmMatchField(Ipv4Dst.class); addIpv4AddressAugmentation(matchEntriesBuilder, in); if (hasMask) { addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES); } break; case 13: matchEntriesBuilder.setOxmMatchField(TcpSrc.class); addPortAugmentation(matchEntriesBuilder, in); break; case 14: matchEntriesBuilder.setOxmMatchField(TcpDst.class); addPortAugmentation(matchEntriesBuilder, in); break; case 15: matchEntriesBuilder.setOxmMatchField(UdpSrc.class); addPortAugmentation(matchEntriesBuilder, in); break; case 16: matchEntriesBuilder.setOxmMatchField(UdpDst.class); addPortAugmentation(matchEntriesBuilder, in); break; case 17: matchEntriesBuilder.setOxmMatchField(SctpSrc.class); addPortAugmentation(matchEntriesBuilder, in); break; case 18: matchEntriesBuilder.setOxmMatchField(SctpDst.class); addPortAugmentation(matchEntriesBuilder, in); break; case 19: matchEntriesBuilder.setOxmMatchField(Icmpv4Type.class); Icmpv4TypeMatchEntryBuilder icmpv4TypeBuilder = new Icmpv4TypeMatchEntryBuilder(); icmpv4TypeBuilder.setIcmpv4Type(in.readUnsignedByte()); matchEntriesBuilder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4TypeBuilder.build()); break; case 20: matchEntriesBuilder.setOxmMatchField(Icmpv4Code.class); Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder(); icmpv4CodeBuilder.setIcmpv4Code(in.readUnsignedByte()); matchEntriesBuilder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build()); break; case 21: matchEntriesBuilder.setOxmMatchField(ArpOp.class); OpCodeMatchEntryBuilder opcodeBuilder = new OpCodeMatchEntryBuilder(); opcodeBuilder.setOpCode(in.readUnsignedShort()); matchEntriesBuilder.addAugmentation(OpCodeMatchEntry.class, opcodeBuilder.build()); break; case 22: matchEntriesBuilder.setOxmMatchField(ArpSpa.class); addIpv4AddressAugmentation(matchEntriesBuilder, in); if (hasMask) { addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES); } break; case 23: matchEntriesBuilder.setOxmMatchField(ArpTpa.class); addIpv4AddressAugmentation(matchEntriesBuilder, in); if (hasMask) { addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES); } break; case 24: matchEntriesBuilder.setOxmMatchField(ArpSha.class); addMacAddressAugmentation(matchEntriesBuilder, in); if (hasMask) { addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.MAC_ADDRESS_LENGTH); } break; case 25: matchEntriesBuilder.setOxmMatchField(ArpTha.class); addMacAddressAugmentation(matchEntriesBuilder, in); if (hasMask) { addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.MAC_ADDRESS_LENGTH); } break; case 26: matchEntriesBuilder.setOxmMatchField(Ipv6Src.class); addIpv6AddressAugmentation(matchEntriesBuilder, in); if (hasMask) { addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES); } break; case 27: matchEntriesBuilder.setOxmMatchField(Ipv6Dst.class); addIpv6AddressAugmentation(matchEntriesBuilder, in); if (hasMask) { addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES); } break; case 28: matchEntriesBuilder.setOxmMatchField(Ipv6Flabel.class); Ipv6FlabelMatchEntryBuilder ipv6FlabelBuilder = new Ipv6FlabelMatchEntryBuilder(); ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(in.readUnsignedInt())); matchEntriesBuilder.addAugmentation(Ipv6FlabelMatchEntry.class, ipv6FlabelBuilder.build()); if (hasMask) { addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES); } break; case 29: matchEntriesBuilder.setOxmMatchField(Icmpv6Type.class); Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder(); icmpv6TypeBuilder.setIcmpv6Type(in.readUnsignedByte()); matchEntriesBuilder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build()); break; case 30: matchEntriesBuilder.setOxmMatchField(Icmpv6Code.class); Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder(); icmpv6CodeBuilder.setIcmpv6Code(in.readUnsignedByte()); matchEntriesBuilder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build()); break; case 31: matchEntriesBuilder.setOxmMatchField(Ipv6NdTarget.class); addIpv6AddressAugmentation(matchEntriesBuilder, in); break; case 32: matchEntriesBuilder.setOxmMatchField(Ipv6NdSll.class); addMacAddressAugmentation(matchEntriesBuilder, in); break; case 33: matchEntriesBuilder.setOxmMatchField(Ipv6NdTll.class); addMacAddressAugmentation(matchEntriesBuilder, in); break; case 34: matchEntriesBuilder.setOxmMatchField(MplsLabel.class); MplsLabelMatchEntryBuilder mplsLabelBuilder = new MplsLabelMatchEntryBuilder(); mplsLabelBuilder.setMplsLabel(in.readUnsignedInt()); matchEntriesBuilder.addAugmentation(MplsLabelMatchEntry.class, mplsLabelBuilder.build()); break; case 35: matchEntriesBuilder.setOxmMatchField(MplsTc.class); TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); tcBuilder.setTc(in.readUnsignedByte()); matchEntriesBuilder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); break; case 36: matchEntriesBuilder.setOxmMatchField(MplsBos.class); BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); if (in.readUnsignedByte() != 0) { bosBuilder.setBos(true); } else { bosBuilder.setBos(false); } matchEntriesBuilder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); break; case 37: matchEntriesBuilder.setOxmMatchField(PbbIsid.class); IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); Integer isid = in.readUnsignedMedium(); isidBuilder.setIsid(isid.longValue()); matchEntriesBuilder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); if (hasMask) { addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_3_BYTES); } break; case 38: matchEntriesBuilder.setOxmMatchField(TunnelId.class); addMetadataAugmentation(matchEntriesBuilder, in); if (hasMask) { addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_LONG_IN_BYTES); } break; case 39: matchEntriesBuilder.setOxmMatchField(Ipv6Exthdr.class); PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); int bitmap = in.readUnsignedShort(); final Boolean NONEXT = ((bitmap) & (1 << 0)) != 0; final Boolean ESP = ((bitmap) & (1 << 1)) != 0; final Boolean AUTH = ((bitmap) & (1 << 2)) != 0; final Boolean DEST = ((bitmap) & (1 << 3)) != 0; final Boolean FRAG = ((bitmap) & (1 << 4)) != 0; final Boolean ROUTER = ((bitmap) & (1 << 5)) != 0; final Boolean HOP = ((bitmap) & (1 << 6)) != 0; final Boolean UNREP = ((bitmap) & (1 << 7)) != 0; final Boolean UNSEQ = ((bitmap) & (1 << 8)) != 0; pseudoBuilder.setPseudoField( new Ipv6ExthdrFlags(AUTH, DEST, ESP, FRAG, HOP, NONEXT, ROUTER, UNREP, UNSEQ)); matchEntriesBuilder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); if (hasMask) { addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_SHORT_IN_BYTES); } break; default: break; } matchEntriesList.add(matchEntriesBuilder.build()); if (oneEntry) { break; } } if ((matchLength - currLength) > 0) { in.skipBytes(matchLength - currLength); } return matchEntriesList; }