use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder 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.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder 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.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder in project openflowplugin by opendaylight.
the class MatchNormalizationUtilTest method normalizeTunnelIpv4Match.
@Test
public void normalizeTunnelIpv4Match() {
final String source = "192.168.1.2/24";
final String destination = "192.168.2.2/24";
final MatchBuilder matchBuilder = MatchNormalizationUtil.normalizeTunnelIpv4Match(new MatchBuilder().setLayer3Match(new TunnelIpv4MatchBuilder().setTunnelIpv4Source(new Ipv4Prefix(source)).setTunnelIpv4Destination(new Ipv4Prefix(destination)).build()));
assertEquals("192.168.1.0/24", TunnelIpv4Match.class.cast(matchBuilder.getLayer3Match()).getTunnelIpv4Source().getValue());
assertEquals("192.168.2.0/24", TunnelIpv4Match.class.cast(matchBuilder.getLayer3Match()).getTunnelIpv4Destination().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder in project openflowplugin by opendaylight.
the class OfToSalTunnelIpv4SrcCase 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 TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = data.getTunnelIpv4MatchBuilder();
Ipv4Src tunnelIpv4Dst = source.getIpv4Src();
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.setIpv4Source(ipv4Prefix);
matchBuilder.setLayer3Match(tunnelIpv4MatchBuilder.build());
}
return Optional.of(matchBuilder);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder in project openflowplugin by opendaylight.
the class TunnelIpv4SourceEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Match ipv4match = new MatchBuilder().setLayer3Match(new TunnelIpv4MatchBuilder().setTunnelIpv4Source(new Ipv4Prefix("10.0.2.0/24")).build()).build();
assertMatch(ipv4match, true, (out) -> {
byte[] address = new byte[4];
out.readBytes(address);
assertArrayEquals(address, new byte[] { 10, 0, 2, 0 });
byte[] mask = new byte[4];
out.readBytes(mask);
assertArrayEquals(mask, new byte[] { (byte) 255, (byte) 255, (byte) 255, 0 });
});
final Match ipv4matchNoMask = new MatchBuilder().setLayer3Match(new TunnelIpv4MatchBuilder().setTunnelIpv4Source(new Ipv4Prefix("10.0.0.0/32")).build()).build();
assertMatch(ipv4matchNoMask, false, (out) -> {
byte[] address = new byte[4];
out.readBytes(address);
assertArrayEquals(address, new byte[] { 10, 0, 0, 0 });
});
}
Aggregations