Java tutorial
/* * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.openflowjava.protocol.impl.util; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; import java.util.ArrayList; import java.util.List; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; /** * @author michal.polkorab * */ public class OF13MatchSerializerTest2 { private SerializerRegistry registry; private OFSerializer<Match> matchSerializer; /** * Initializes serializer table and stores correct factory in field */ @Before public void startUp() { registry = new SerializerRegistryImpl(); registry.init(); matchSerializer = registry .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Match.class)); } /** * Testing serialization of match */ @Test public void testEmptyMatch() { MatchBuilder builder = new MatchBuilder(); builder.setType(OxmMatchType.class); Match match = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); matchSerializer.serialize(match, out); Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort()); Assert.assertEquals("Wrong match length", 4, out.readUnsignedShort()); Assert.assertTrue("Wrong padding", out.readableBytes() == 4); } /** * Testing serialization of match */ @Test public void test() { MatchBuilder builder = new MatchBuilder(); builder.setType(OxmMatchType.class); List<MatchEntries> entries = new ArrayList<>(); MatchEntriesBuilder entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(InPort.class); entryBuilder.setHasMask(false); PortNumberMatchEntryBuilder portNumberBuilder = new PortNumberMatchEntryBuilder(); portNumberBuilder.setPortNumber(new PortNumber(42L)); entryBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(InPhyPort.class); entryBuilder.setHasMask(false); portNumberBuilder = new PortNumberMatchEntryBuilder(); portNumberBuilder.setPortNumber(new PortNumber(43L)); entryBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Metadata.class); entryBuilder.setHasMask(true); MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); metadataBuilder.setMetadata(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }); entryBuilder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 0, 0, 2 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(EthDst.class); entryBuilder.setHasMask(true); MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); macBuilder.setMacAddress(new MacAddress("01:00:03:00:00:06")); entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 5 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(EthSrc.class); entryBuilder.setHasMask(true); macBuilder = new MacAddressMatchEntryBuilder(); macBuilder.setMacAddress(new MacAddress("04:00:02:00:00:08")); entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 2 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(EthType.class); entryBuilder.setHasMask(false); EthTypeMatchEntryBuilder ethBuilder = new EthTypeMatchEntryBuilder(); ethBuilder.setEthType(new EtherType(46)); entryBuilder.addAugmentation(EthTypeMatchEntry.class, ethBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(VlanVid.class); entryBuilder.setHasMask(true); VlanVidMatchEntryBuilder vidBuilder = new VlanVidMatchEntryBuilder(); vidBuilder.setCfiBit(true); vidBuilder.setVlanVid(45); entryBuilder.addAugmentation(VlanVidMatchEntry.class, vidBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 9 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(VlanPcp.class); entryBuilder.setHasMask(false); VlanPcpMatchEntryBuilder pcpBuilder = new VlanPcpMatchEntryBuilder(); pcpBuilder.setVlanPcp((short) 14); entryBuilder.addAugmentation(VlanPcpMatchEntry.class, pcpBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(IpDscp.class); entryBuilder.setHasMask(false); DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); dscpBuilder.setDscp(new Dscp((short) 48)); entryBuilder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(IpEcn.class); entryBuilder.setHasMask(false); EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder(); ecnBuilder.setEcn((short) 49); entryBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(IpProto.class); entryBuilder.setHasMask(false); ProtocolNumberMatchEntryBuilder protoBuilder = new ProtocolNumberMatchEntryBuilder(); protoBuilder.setProtocolNumber((short) 50); entryBuilder.addAugmentation(ProtocolNumberMatchEntry.class, protoBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv4Src.class); entryBuilder.setHasMask(true); Ipv4AddressMatchEntryBuilder ipv4Builder = new Ipv4AddressMatchEntryBuilder(); ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.1")); entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 14 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv4Dst.class); entryBuilder.setHasMask(true); ipv4Builder = new Ipv4AddressMatchEntryBuilder(); ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.2")); entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 15 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(TcpSrc.class); entryBuilder.setHasMask(false); PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); portBuilder.setPort( new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber( 6653)); entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(TcpDst.class); entryBuilder.setHasMask(false); portBuilder = new PortMatchEntryBuilder(); portBuilder.setPort( new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber( 6654)); entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(UdpSrc.class); entryBuilder.setHasMask(false); portBuilder = new PortMatchEntryBuilder(); portBuilder.setPort( new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber( 6655)); entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(UdpDst.class); entryBuilder.setHasMask(false); portBuilder = new PortMatchEntryBuilder(); portBuilder.setPort( new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber( 6656)); entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(SctpSrc.class); entryBuilder.setHasMask(false); portBuilder = new PortMatchEntryBuilder(); portBuilder.setPort( new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber( 6657)); entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(SctpDst.class); entryBuilder.setHasMask(false); portBuilder = new PortMatchEntryBuilder(); portBuilder.setPort( new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber( 6658)); entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Icmpv4Type.class); entryBuilder.setHasMask(false); Icmpv4TypeMatchEntryBuilder icmpv4typeBuilder = new Icmpv4TypeMatchEntryBuilder(); icmpv4typeBuilder.setIcmpv4Type((short) 51); entryBuilder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4typeBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Icmpv4Code.class); entryBuilder.setHasMask(false); Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder(); icmpv4CodeBuilder.setIcmpv4Code((short) 52); entryBuilder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(ArpOp.class); entryBuilder.setHasMask(false); OpCodeMatchEntryBuilder opBuilder = new OpCodeMatchEntryBuilder(); opBuilder.setOpCode(53); entryBuilder.addAugmentation(OpCodeMatchEntry.class, opBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(ArpSpa.class); entryBuilder.setHasMask(true); ipv4Builder = new Ipv4AddressMatchEntryBuilder(); ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.4")); entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 16 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(ArpTpa.class); entryBuilder.setHasMask(true); ipv4Builder = new Ipv4AddressMatchEntryBuilder(); ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.5")); entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 17 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(ArpSha.class); entryBuilder.setHasMask(true); macBuilder = new MacAddressMatchEntryBuilder(); macBuilder.setMacAddress(new MacAddress("00:01:02:03:04:05")); entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 4, 0, 0, 6 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(ArpTha.class); entryBuilder.setHasMask(true); macBuilder = new MacAddressMatchEntryBuilder(); macBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03")); entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 6, 0, 0, 4 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6Src.class); entryBuilder.setHasMask(true); Ipv6AddressMatchEntryBuilder ipv6Builder = new Ipv6AddressMatchEntryBuilder(); ipv6Builder.setIpv6Address(new Ipv6Address("0:0:0:0:0:0:0:1")); entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6Dst.class); entryBuilder.setHasMask(true); ipv6Builder = new Ipv6AddressMatchEntryBuilder(); ipv6Builder.setIpv6Address(new Ipv6Address("0:0:1:0:1:0:0:1")); entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6Flabel.class); entryBuilder.setHasMask(true); Ipv6FlabelMatchEntryBuilder flabelBuilder = new Ipv6FlabelMatchEntryBuilder(); flabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(58L)); entryBuilder.addAugmentation(Ipv6FlabelMatchEntry.class, flabelBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 1, 0, 2 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Icmpv6Type.class); entryBuilder.setHasMask(false); Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder(); icmpv6TypeBuilder.setIcmpv6Type((short) 59); entryBuilder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Icmpv6Code.class); entryBuilder.setHasMask(false); Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder(); icmpv6CodeBuilder.setIcmpv6Code((short) 60); entryBuilder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build()); entries.add(entryBuilder.build()); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6NdTarget.class); entryBuilder.setHasMask(false); ipv6Builder = new Ipv6AddressMatchEntryBuilder(); ipv6Builder.setIpv6Address(new Ipv6Address("F:0:0::0:0:0:1")); entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6NdSll.class); entryBuilder.setHasMask(false); macBuilder = new MacAddressMatchEntryBuilder(); macBuilder.setMacAddress(new MacAddress("01:00:03:00:00:06")); entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6NdTll.class); entryBuilder.setHasMask(false); macBuilder = new MacAddressMatchEntryBuilder(); macBuilder.setMacAddress(new MacAddress("04:00:02:00:00:08")); entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(MplsLabel.class); entryBuilder.setHasMask(false); MplsLabelMatchEntryBuilder labelBuilder = new MplsLabelMatchEntryBuilder(); labelBuilder.setMplsLabel(61L); entryBuilder.addAugmentation(MplsLabelMatchEntry.class, labelBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(MplsTc.class); entryBuilder.setHasMask(false); TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); tcBuilder.setTc((short) 62); entryBuilder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(MplsBos.class); entryBuilder.setHasMask(false); BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); bosBuilder.setBos(true); entryBuilder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(PbbIsid.class); entryBuilder.setHasMask(true); IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); isidBuilder.setIsid(64L); entryBuilder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 1, 2 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(TunnelId.class); entryBuilder.setHasMask(true); metadataBuilder = new MetadataMatchEntryBuilder(); metadataBuilder.setMetadata(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }); entryBuilder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 0, 0, 2 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6Exthdr.class); entryBuilder.setHasMask(true); PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true)); entryBuilder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 2 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); builder.setMatchEntries(entries); Match match = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); matchSerializer.serialize(match, out); Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort()); Assert.assertEquals("Wrong match length", 428, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 0, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 42, out.readUnsignedInt()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 43, out.readUnsignedInt()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 5, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 1L, out.readLong()); Assert.assertEquals("Wrong match entry mask", 2L, out.readLong()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 7, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); byte[] array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 1, 0, 3, 0, 0, 6 }, array); array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 0, 0, 5 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 9, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 4, 0, 2, 0, 0, 8 }, array); array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 0, 0, 2 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 10, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 46, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 13, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 4141, out.readUnsignedShort()); array = new byte[2]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 9 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 14, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 14, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 16, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 48, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 18, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 49, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 20, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 50, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 23, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); array = new byte[4]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 10, 0, 0, 1 }, array); array = new byte[4]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 14 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 25, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); array = new byte[4]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 10, 0, 0, 2 }, array); array = new byte[4]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 15 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 26, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 6653, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 28, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 6654, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 30, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 6655, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 32, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 6656, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 34, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 6657, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 36, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 6658, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 38, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 51, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 40, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 52, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 42, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 53, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 45, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); array = new byte[4]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 10, 0, 0, 4 }, array); array = new byte[4]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 16 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 47, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); array = new byte[4]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 10, 0, 0, 5 }, array); array = new byte[4]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 17 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 49, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 0, 1, 2, 3, 4, 5 }, array); array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 4, 0, 0, 6 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 51, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 0, 0, 0, 0, 0, 3 }, array); array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 6, 0, 0, 4 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 53, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 32, out.readUnsignedByte()); array = new byte[16]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, array); array = new byte[16]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 55, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 32, out.readUnsignedByte()); array = new byte[16]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 }, array); array = new byte[16]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 57, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 58, out.readUnsignedInt()); array = new byte[4]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 1, 0, 2 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 58, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 59, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 60, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 60, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 62, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte()); array = new byte[16]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 64, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte()); array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 1, 0, 3, 0, 0, 6 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 66, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte()); array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 4, 0, 2, 0, 0, 8 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 68, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 61, out.readUnsignedInt()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 70, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 62, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 72, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 75, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 64, out.readUnsignedMedium()); array = new byte[3]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 1, 2 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 77, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 1L, out.readLong()); Assert.assertEquals("Wrong match entry mask", 2L, out.readLong()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 79, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 358, out.readUnsignedShort()); array = new byte[2]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 0, 2 }, array); Assert.assertTrue("Wrong padding", out.readableBytes() == 4); } }