Search in sources :

Example 1 with TcpFlagsMatch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatch in project openflowplugin by opendaylight.

the class TcpFlagsEntryDeserializer method deserializeEntry.

@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
    final boolean hasMask = processHeader(message);
    // Just skip experimenter ID for now, not used
    message.readUnsignedInt();
    final TcpFlagsMatchBuilder tcpFlagsBuilder = new TcpFlagsMatchBuilder().setTcpFlags(message.readUnsignedShort());
    if (hasMask) {
        tcpFlagsBuilder.setTcpFlagsMask(message.readUnsignedShort());
    }
    if (Objects.isNull(builder.getTcpFlagsMatch())) {
        builder.setTcpFlagsMatch(tcpFlagsBuilder.build());
    } else {
        throwErrorOnMalformed(builder, "tcpFlagsMatch");
    }
}
Also used : TcpFlagsMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatchBuilder)

Example 2 with TcpFlagsMatch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatch in project openflowplugin by opendaylight.

the class TcpFlagsEntryDeserializerTest method deserializeEntry.

@Test
public void deserializeEntry() throws Exception {
    final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
    final int tcpFlags = 6;
    final int tcpFlagsMask = 5;
    writeHeader(in, false);
    in.writeInt((int) EncodeConstants.ONF_EXPERIMENTER_ID);
    in.writeShort(tcpFlags);
    TcpFlagsMatch match = deserialize(in).getTcpFlagsMatch();
    assertEquals(tcpFlags, match.getTcpFlags().intValue());
    assertEquals(0, in.readableBytes());
    writeHeader(in, true);
    in.writeInt((int) EncodeConstants.ONF_EXPERIMENTER_ID);
    in.writeShort(tcpFlags);
    in.writeShort(tcpFlagsMask);
    match = deserialize(in).getTcpFlagsMatch();
    assertEquals(tcpFlags, match.getTcpFlags().intValue());
    assertEquals(tcpFlagsMask, match.getTcpFlagsMask().intValue());
    assertEquals(0, in.readableBytes());
}
Also used : TcpFlagsMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatch) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 3 with TcpFlagsMatch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatch in project openflowplugin by opendaylight.

the class MatchConvertor method convert.

@Override
public List<MatchEntry> convert(final Match source, final VersionConvertorData data) {
    List<MatchEntry> result = new ArrayList<>();
    if (source == null) {
        return result;
    }
    final ExtensionConverterProvider extensionConvertorProvider = OFSessionUtil.getExtensionConvertorProvider();
    inPortMatch(result, source.getInPort());
    inPhyPortMatch(result, source.getInPhyPort());
    metadataMatch(result, source.getMetadata());
    ethernetMatch(result, source.getEthernetMatch());
    vlanMatch(result, source.getVlanMatch());
    ipMatch(result, source.getIpMatch());
    layer4Match(result, source.getLayer4Match(), getConvertorExecutor(), extensionConvertorProvider);
    icmpv4Match(result, source.getIcmpv4Match());
    icmpv6Match(result, source.getIcmpv6Match());
    layer3Match(result, source.getLayer3Match(), getConvertorExecutor(), extensionConvertorProvider);
    protocolMatchFields(result, source.getProtocolMatchFields());
    tunnelMatch(result, source.getTunnel());
    tcpFlagsMatch(result, source.getTcpFlagsMatch());
    /*
         * TODO: EXTENSION PROPOSAL (source, MD-SAL to OFJava)
         * - we might need version for conversion and for key
         */
    Optional<GeneralExtensionListGrouping> extensionListOpt = ExtensionResolvers.getMatchExtensionResolver().getExtension(source);
    if (extensionListOpt.isPresent()) {
        List<ExtensionList> extensionListList = extensionListOpt.get().getExtensionList();
        for (ExtensionList extensionItem : extensionListList) {
            // TODO: get real version
            ConverterExtensionKey<? extends ExtensionKey> key = new ConverterExtensionKey<>(extensionItem.getExtensionKey(), OFConstants.OFP_VERSION_1_3);
            ConvertorToOFJava<MatchEntry> convertor = extensionConvertorProvider.getConverter(key);
            if (convertor == null) {
                throw new IllegalStateException("No converter found for key: " + key.toString());
            }
            MatchEntry ofMatch = convertor.convert(extensionItem.getExtension());
            result.add(ofMatch);
        }
    }
    return result;
}
Also used : MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) ExtensionConverterProvider(org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider) ExtensionList(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionList) ArrayList(java.util.ArrayList) GeneralExtensionListGrouping(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionListGrouping) ConverterExtensionKey(org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey)

Example 4 with TcpFlagsMatch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatch in project openflowplugin by opendaylight.

the class TcpFlagsEntrySerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final int tcp = 8;
    final byte[] tcpMask = new byte[] { 30, 30 };
    final Match tcpFlagsMatch = new MatchBuilder().setTcpFlagsMatch(new TcpFlagsMatchBuilder().setTcpFlags(tcp).setTcpFlagsMask(ByteUtil.bytesToUnsignedShort(tcpMask)).build()).build();
    assertMatch(tcpFlagsMatch, true, (out) -> {
        assertEquals(out.readUnsignedShort(), tcp);
        byte[] mask = new byte[2];
        out.readBytes(mask);
        assertArrayEquals(mask, tcpMask);
    });
    final Match tcpFlagsMatchNoMask = new MatchBuilder().setTcpFlagsMatch(new TcpFlagsMatchBuilder().setTcpFlags(tcp).build()).build();
    assertMatch(tcpFlagsMatchNoMask, false, (out) -> assertEquals(out.readUnsignedShort(), tcp));
}
Also used : TcpFlagsMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatchBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) TcpFlagsMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatchBuilder) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) Test(org.junit.Test)

Example 5 with TcpFlagsMatch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatch in project openflowplugin by opendaylight.

the class TunnelIdEntrySerializerTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    final long tunnelId = 8;
    final byte[] tcpMask = new byte[] { 30, 30, 30, 30, 0, 0, 0, 0 };
    final ByteBuffer maskBuff = ByteBuffer.allocate(Long.BYTES);
    maskBuff.put(tcpMask, 0, tcpMask.length);
    maskBuff.flip();
    final Match tcpFlagsMatch = new MatchBuilder().setTunnel(new TunnelBuilder().setTunnelId(BigInteger.valueOf(tunnelId)).setTunnelMask(BigInteger.valueOf(maskBuff.getLong())).build()).build();
    assertMatch(tcpFlagsMatch, true, (out) -> {
        assertEquals(out.readLong(), tunnelId);
        byte[] mask = new byte[8];
        out.readBytes(mask);
        assertArrayEquals(mask, tcpMask);
    });
    final Match tcpFlagsMatchNoMask = new MatchBuilder().setTunnel(new TunnelBuilder().setTunnelId(BigInteger.valueOf(tunnelId)).build()).build();
    assertMatch(tcpFlagsMatchNoMask, false, (out) -> assertEquals(out.readLong(), tunnelId));
}
Also used : ByteBuffer(java.nio.ByteBuffer) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) TunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)3 TcpFlagsMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatchBuilder)3 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)2 ByteBuf (io.netty.buffer.ByteBuf)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 ConverterExtensionKey (org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey)1 ExtensionConverterProvider (org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider)1 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)1 EtherType (org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType)1 EthernetTypeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder)1 EthernetMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)1 Icmpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder)1 Icmpv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder)1 IpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder)1 TcpFlagsMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatch)1 TunnelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder)1 VlanMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder)1 ArpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder)1