Search in sources :

Example 1 with TunnelIpv4Match

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

the class SalToOfTunnelIpv4MatchCase method process.

@Override
public Optional<List<MatchEntry>> process(@Nonnull TunnelIpv4Match source, VersionConvertorData data, ConvertorExecutor convertorExecutor) {
    List<MatchEntry> result = new ArrayList<>();
    if (source.getTunnelIpv4Source() != null) {
        Ipv4Prefix ipv4Prefix = source.getTunnelIpv4Source();
        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
        matchEntryBuilder.setOxmMatchField(Ipv4Src.class);
        Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
        Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
        Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
        ipv4SrcBuilder.setIpv4Address(ipv4Address);
        boolean hasMask = false;
        byte[] mask = MatchConvertorUtil.extractIpv4Mask(addressParts);
        if (null != mask) {
            ipv4SrcBuilder.setMask(mask);
            hasMask = true;
        }
        matchEntryBuilder.setHasMask(hasMask);
        Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
        ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
        matchEntryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
        result.add(matchEntryBuilder.build());
    }
    if (source.getTunnelIpv4Destination() != null) {
        Ipv4Prefix ipv4Prefix = source.getTunnelIpv4Destination();
        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
        matchEntryBuilder.setOxmMatchField(Ipv4Dst.class);
        Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
        Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
        Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
        ipv4DstBuilder.setIpv4Address(ipv4Address);
        boolean hasMask = false;
        byte[] mask = MatchConvertorUtil.extractIpv4Mask(addressParts);
        if (null != mask) {
            ipv4DstBuilder.setMask(mask);
            hasMask = true;
        }
        matchEntryBuilder.setHasMask(hasMask);
        Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
        ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
        matchEntryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
        result.add(matchEntryBuilder.build());
    }
    return Optional.of(result);
}
Also used : Ipv4SrcCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder) MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) ArrayList(java.util.ArrayList) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) Ipv4DstBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4DstBuilder) Ipv4DstCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCaseBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Ipv4SrcBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Aggregations

ArrayList (java.util.ArrayList)1 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)1 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)1 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)1 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)1 Ipv4DstCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCaseBuilder)1 Ipv4SrcCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder)1 Ipv4DstBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4DstBuilder)1 Ipv4SrcBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder)1