use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst in project openflowplugin by opendaylight.
the class OfToSalIpv4SrcCase method process.
@Override
public Optional<MatchBuilder> process(@Nonnull Ipv4SrcCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
final MatchBuilder matchBuilder = data.getMatchBuilder();
final Ipv4MatchBuilder ipv4MatchBuilder = data.getIpv4MatchBuilder();
final Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder = data.getIpv4MatchArbitraryBitMaskBuilder();
Ipv4Src ipv4Address = source.getIpv4Src();
if (ipv4Address != null) {
byte[] mask = ipv4Address.getMask();
if (mask != null && IpConversionUtil.isArbitraryBitMask(mask)) {
// Needs to convert ipv4dst to ipv4MatchArbitrary.
if (ipv4MatchBuilder.getIpv4Destination() != null) {
Ipv4Prefix ipv4PrefixDestinationAddress = ipv4MatchBuilder.getIpv4Destination();
Ipv4Address ipv4DstAddress = IpConversionUtil.extractIpv4Address(ipv4PrefixDestinationAddress);
DottedQuad dstDottedQuadMask = IpConversionUtil.extractIpv4AddressMask(ipv4PrefixDestinationAddress);
setDstIpv4MatchArbitraryBitMaskBuilderFields(ipv4MatchArbitraryBitMaskBuilder, dstDottedQuadMask, ipv4DstAddress.getValue());
}
DottedQuad srcDottedQuadMask = IpConversionUtil.createArbitraryBitMask(mask);
String stringIpv4SrcAddress = ipv4Address.getIpv4Address().getValue();
setSrcIpv4MatchArbitraryBitMaskBuilderFields(ipv4MatchArbitraryBitMaskBuilder, srcDottedQuadMask, stringIpv4SrcAddress);
matchBuilder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());
} else if (ipv4MatchArbitraryBitMaskBuilder.getIpv4DestinationAddressNoMask() != null) {
/*
Case where destination is of type ipv4MatchArbitraryBitMask already exists in Layer3Match,
source which of type ipv4Match needs to be converted to ipv4MatchArbitraryBitMask.
We convert 36.36.36.0/24 to 36.36.0/255.255.255.0
expected output example:-
<ipv4-destination>36.36.36.0/24</ipv4-destination>
<ipv4-source-address-no-mask>36.36.36.0</ipv4-source-address-no-mask>
<ipv4-source-arbitrary-bitmask>255.0.255.0</ipv4-source-arbitrary-bitmask>
after conversion output example:-
<ipv4-destination-address-no-mask>36.36.36.0</ipv4-destination-address-no-mask>
<ipv4-destination-arbitrary-bitmask>255.255.255.0</ipv4-destination-arbitrary-bitmask>
<ipv4-source-address-no-mask>36.36.36.0</ipv4-source-address-no-mask>
<ipv4-source-arbitrary-bitmask>255.0.255.0</ipv4-source-arbitrary-bitmask>
*/
DottedQuad srcDottedQuadMask = IpConversionUtil.createArbitraryBitMask(mask);
String stringIpv4SrcAddress = ipv4Address.getIpv4Address().getValue();
setSrcIpv4MatchArbitraryBitMaskBuilderFields(ipv4MatchArbitraryBitMaskBuilder, srcDottedQuadMask, stringIpv4SrcAddress);
matchBuilder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());
} else {
String stringIpv4SrcAddress = ipv4Address.getIpv4Address().getValue();
setIpv4MatchBuilderFields(ipv4MatchBuilder, mask, stringIpv4SrcAddress);
matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
}
}
return Optional.of(matchBuilder);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst in project openflowplugin by opendaylight.
the class MatchResponseConvertor method convert.
@Override
public MatchBuilder convert(MatchEntriesGrouping source, VersionDatapathIdConvertorData datapathIdConvertorData) {
final MatchBuilder matchBuilder = new MatchBuilder();
final MatchResponseConvertorData data = new MatchResponseConvertorData(datapathIdConvertorData.getVersion());
data.setDatapathId(datapathIdConvertorData.getDatapathId());
data.setMatchBuilder(matchBuilder);
data.setEthernetMatchBuilder(new EthernetMatchBuilder());
data.setVlanMatchBuilder(new VlanMatchBuilder());
data.setIpMatchBuilder(new IpMatchBuilder());
data.setTcpMatchBuilder(new TcpMatchBuilder());
data.setUdpMatchBuilder(new UdpMatchBuilder());
data.setSctpMatchBuilder(new SctpMatchBuilder());
data.setIcmpv4MatchBuilder(new Icmpv4MatchBuilder());
data.setIcmpv6MatchBuilder(new Icmpv6MatchBuilder());
data.setIpv4MatchBuilder(new Ipv4MatchBuilder());
data.setIpv4MatchArbitraryBitMaskBuilder(new Ipv4MatchArbitraryBitMaskBuilder());
data.setIpv6MatchArbitraryBitMaskBuilder(new Ipv6MatchArbitraryBitMaskBuilder());
data.setArpMatchBuilder(new ArpMatchBuilder());
data.setIpv6MatchBuilder(new Ipv6MatchBuilder());
data.setProtocolMatchFieldsBuilder(new ProtocolMatchFieldsBuilder());
data.setTunnelIpv4MatchBuilder(new TunnelIpv4MatchBuilder());
data.setTcpFlagsMatchBuilder(new TcpFlagsMatchBuilder());
for (MatchEntry ofMatch : source.getMatchEntry()) {
if (TunnelIpv4Dst.class.isAssignableFrom(ofMatch.getOxmMatchField()) || TunnelIpv4Src.class.isAssignableFrom(ofMatch.getOxmMatchField())) {
/*
* TODO: Fix TunnelIpv4Src and Ipv4Dst, because current implementation do not work
* TunnelIpv4Src and TunnelIpv4Dst are not compatible with
* org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField
* and so you cannot even set them to OxmMatchField.
* Creation of TunnelIpv4SrcCase and TunnelIpv4DstCase in
* org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value
* .grouping.match.entry.value
* and proper use of it can fix this bug.
*/
OF_TO_SAL_TUNNEL_PROCESSOR.process(ofMatch.getMatchEntryValue(), data, getConvertorExecutor());
} else {
data.setOxmMatchField(ofMatch.getOxmMatchField());
OF_TO_SAL_PROCESSOR.process(ofMatch.getMatchEntryValue(), data, getConvertorExecutor());
}
}
return matchBuilder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst in project openflowplugin by opendaylight.
the class OfToSalTunnelIpv4DstCase method process.
@Override
public Optional<MatchBuilder> process(@Nonnull Ipv4DstCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
final MatchBuilder matchBuilder = data.getMatchBuilder();
final Ipv4MatchBuilder ipv4MatchBuilder = data.getIpv4MatchBuilder();
final TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = data.getTunnelIpv4MatchBuilder();
Ipv4Dst tunnelIpv4Dst = source.getIpv4Dst();
if (tunnelIpv4Dst != null) {
String ipv4PrefixStr = tunnelIpv4Dst.getIpv4Address().getValue();
byte[] mask = tunnelIpv4Dst.getMask();
ipv4PrefixStr += IpConversionUtil.PREFIX_SEPARATOR + ByteBuffer.wrap(tunnelIpv4Dst.getMask()).getInt();
final Ipv4Prefix ipv4Prefix;
if (mask != null) {
ipv4Prefix = IpConversionUtil.createPrefix(new Ipv4Address(ipv4PrefixStr), mask);
} else {
// Openflow Spec : 1.3.2
// An all-one-bits oxm_mask is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.
// So when user specify 32 as a mast, switch omit that mast and we get null as a mask in flow
// statistics response.
ipv4Prefix = IpConversionUtil.createPrefix(new Ipv4Address(ipv4PrefixStr));
}
ipv4MatchBuilder.setIpv4Destination(ipv4Prefix);
matchBuilder.setLayer3Match(tunnelIpv4MatchBuilder.build());
}
return Optional.of(matchBuilder);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst in project openflowplugin by opendaylight.
the class OfToSalIpv4DstCase method process.
@Override
public Optional<MatchBuilder> process(@Nonnull Ipv4DstCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
final MatchBuilder matchBuilder = data.getMatchBuilder();
final Ipv4MatchBuilder ipv4MatchBuilder = data.getIpv4MatchBuilder();
final Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder = data.getIpv4MatchArbitraryBitMaskBuilder();
Ipv4Dst ipv4Address = source.getIpv4Dst();
if (ipv4Address != null) {
byte[] mask = ipv4Address.getMask();
if (mask != null && IpConversionUtil.isArbitraryBitMask(mask)) {
// Needs to convert ipv4src to ipv4MatchArbitrary.
if (ipv4MatchBuilder.getIpv4Source() != null) {
Ipv4Prefix ipv4PrefixSourceAddress = ipv4MatchBuilder.getIpv4Source();
Ipv4Address ipv4SourceAddress = IpConversionUtil.extractIpv4Address(ipv4PrefixSourceAddress);
DottedQuad srcDottedQuad = IpConversionUtil.extractIpv4AddressMask(ipv4PrefixSourceAddress);
setSrcIpv4MatchArbitraryBitMaskBuilderFields(ipv4MatchArbitraryBitMaskBuilder, srcDottedQuad, ipv4SourceAddress.getValue());
}
DottedQuad dstDottedQuadMask = IpConversionUtil.createArbitraryBitMask(mask);
String stringIpv4DstAddress = ipv4Address.getIpv4Address().getValue();
setDstIpv4MatchArbitraryBitMaskBuilderFields(ipv4MatchArbitraryBitMaskBuilder, dstDottedQuadMask, stringIpv4DstAddress);
matchBuilder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());
} else if (ipv4MatchArbitraryBitMaskBuilder.getIpv4SourceAddressNoMask() != null) {
/*
Case where source is of type ipv4MatchArbitraryBitMask already exists in Layer3Match,
destination which of type ipv4Match needs to be converted to ipv4MatchArbitraryBitMask.
We convert 36.36.36.0/24 to 36.36.0/255.255.255.0
expected output example:-
<ipv4-source>36.36.36.0/24</ipv4-source>
<ipv4-destination-address-no-mask>36.36.36.0</ipv4-destination-address-no-mask>
<ipv4-destination-arbitrary-bitmask>255.0.255.0</ipv4-destination-arbitrary-bitmask>
after conversion output example:-
<ipv4-source-address-no-mask>36.36.36.0</ipv4-source-address-no-mask>
<ipv4-source-arbitrary-bitmask>255.255.255.0</ipv4-source-arbitrary-bitmask>
<ipv4-destination-address-no-mask>36.36.36.0</ipv4-destination-address-no-mask>
<ipv4-destination-arbitrary-bitmask>255.0.255.0</ipv4-destination-arbitrary-bitmask>
*/
DottedQuad dstDottedQuadMask = IpConversionUtil.createArbitraryBitMask(mask);
String stringIpv4DstAddress = ipv4Address.getIpv4Address().getValue();
setDstIpv4MatchArbitraryBitMaskBuilderFields(ipv4MatchArbitraryBitMaskBuilder, dstDottedQuadMask, stringIpv4DstAddress);
matchBuilder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());
} else {
String ipv4PrefixStr = ipv4Address.getIpv4Address().getValue();
setIpv4MatchBuilderFields(ipv4MatchBuilder, mask, ipv4PrefixStr);
matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
}
}
return Optional.of(matchBuilder);
}
Aggregations