Search in sources :

Example 66 with Match

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match in project openflowplugin by opendaylight.

the class Ipv6FlabelEntryDeserializer method deserializeEntry.

@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
    final boolean hasMask = processHeader(message);
    final Ipv6LabelBuilder ipv6labelBuilder = new Ipv6LabelBuilder().setIpv6Flabel(new Ipv6FlowLabel(message.readUnsignedInt()));
    if (hasMask) {
        final byte[] mask = OxmDeserializerHelper.convertMask(message, EncodeConstants.SIZE_OF_INT_IN_BYTES);
        ipv6labelBuilder.setFlabelMask(new Ipv6FlowLabel(ByteUtil.bytesToUnsignedInt(mask)));
    }
    if (Objects.isNull(builder.getLayer3Match())) {
        builder.setLayer3Match(new Ipv6MatchBuilder().setIpv6Label(ipv6labelBuilder.build()).build());
    } else if (Ipv6Match.class.isInstance(builder.getLayer3Match()) && Objects.isNull(Ipv6Match.class.cast(builder.getLayer3Match()).getIpv6Label())) {
        final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
        builder.setLayer3Match(new Ipv6MatchBuilder(match).setIpv6Label(ipv6labelBuilder.build()).build());
    } else {
        throwErrorOnMalformed(builder, "layer3Match", "ipv6Label");
    }
}
Also used : Ipv6Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match) Ipv6LabelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder) Ipv6FlowLabel(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)

Example 67 with Match

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match in project openflowplugin by opendaylight.

the class Ipv6NdTargetEntryDeserializer method deserializeEntry.

@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
    processHeader(message);
    final Ipv6Address address = ByteBufUtils.readIetfIpv6Address(message);
    if (Objects.isNull(builder.getLayer3Match())) {
        builder.setLayer3Match(new Ipv6MatchBuilder().setIpv6NdTarget(address).build());
    } else if (Ipv6Match.class.isInstance(builder.getLayer3Match()) && Objects.isNull(Ipv6Match.class.cast(builder.getLayer3Match()).getIpv6NdTarget())) {
        final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
        builder.setLayer3Match(new Ipv6MatchBuilder(match).setIpv6NdTarget(address).build());
    } else {
        throwErrorOnMalformed(builder, "layer3Match", "ipv6NdTarget");
    }
}
Also used : Ipv6Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)

Example 68 with Match

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match in project openflowplugin by opendaylight.

the class Ipv4SourceEntryDeserializerTest method deserializeEntry.

@Test
public void deserializeEntry() throws Exception {
    final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
    final Ipv4Prefix address = new Ipv4Prefix("192.168.72.0/24");
    final Iterator<String> addressParts = IpConversionUtil.splitToParts(address);
    writeHeader(in, true);
    in.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(new Ipv4Address(addressParts.next())));
    in.writeBytes(MatchConvertorUtil.extractIpv4Mask(addressParts));
    final Ipv4Match match = Ipv4Match.class.cast(deserialize(in).getLayer3Match());
    assertEquals(address.getValue(), match.getIpv4Source().getValue());
    assertEquals(0, in.readableBytes());
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 69 with Match

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match in project openflowplugin by opendaylight.

the class UdpDestinationPortEntrySerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final int tcp = 10;
    final Match sctpMatch = new MatchBuilder().setLayer4Match(new UdpMatchBuilder().setUdpDestinationPort(new PortNumber(tcp)).build()).build();
    assertMatch(sctpMatch, false, (out) -> assertEquals(out.readUnsignedShort(), tcp));
}
Also used : UdpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) UdpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) Test(org.junit.Test)

Example 70 with Match

use of org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match in project openflowplugin by opendaylight.

the class InPortEntrySerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final int port = 42;
    final Match match = new MatchBuilder().setInPort(new NodeConnectorId("openflow:1:" + port)).build();
    assertMatch(match, false, (out) -> assertEquals(out.readUnsignedInt(), port));
}
Also used : NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)182 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)138 ArrayList (java.util.ArrayList)82 BigInteger (java.math.BigInteger)66 EthernetMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)62 Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)61 Ipv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder)60 ByteBuf (io.netty.buffer.ByteBuf)59 IpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder)53 Icmpv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder)49 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)48 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match)45 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)44 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)43 ArpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder)43 TcpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder)42 VlanMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder)41 Icmpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder)40 UdpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder)40 Ipv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match)39