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);
}
Aggregations