Search in sources :

Example 31 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder in project openflowplugin by opendaylight.

the class OfToSalIpProtoCase method process.

@Override
public Optional<MatchBuilder> process(@Nonnull IpProtoCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
    final MatchBuilder matchBuilder = data.getMatchBuilder();
    final IpMatchBuilder ipMatchBuilder = data.getIpMatchBuilder();
    IpProto ipProto = source.getIpProto();
    Short protocolNumber = ipProto.getProtocolNumber();
    if (protocolNumber != null) {
        ipMatchBuilder.setIpProtocol(protocolNumber);
        matchBuilder.setIpMatch(ipMatchBuilder.build());
    }
    return Optional.of(matchBuilder);
}
Also used : IpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder) IpProto(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.proto._case.IpProto) IpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)

Example 32 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder 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);
}
Also used : Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) Ipv4Src(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4Src) Ipv4MatchArbitraryBitMaskBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMaskBuilder) DottedQuad(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 33 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder in project openflowplugin by opendaylight.

the class OfToSalIpv6NdSllCase method process.

@Override
public Optional<MatchBuilder> process(@Nonnull Ipv6NdSllCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
    final MatchBuilder matchBuilder = data.getMatchBuilder();
    final Ipv6MatchBuilder ipv6MatchBuilder = data.getIpv6MatchBuilder();
    Ipv6NdSll ipv6NdSll = source.getIpv6NdSll();
    if (ipv6NdSll != null) {
        ipv6MatchBuilder.setIpv6NdSll(ipv6NdSll.getMacAddress());
        matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
    }
    return Optional.of(matchBuilder);
}
Also used : Ipv6NdSll(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.sll._case.Ipv6NdSll) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)

Example 34 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder in project openflowplugin by opendaylight.

the class OfToSalIpv6NdTllCase method process.

@Override
public Optional<MatchBuilder> process(@Nonnull Ipv6NdTllCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
    final MatchBuilder matchBuilder = data.getMatchBuilder();
    final Ipv6MatchBuilder ipv6MatchBuilder = data.getIpv6MatchBuilder();
    Ipv6NdTll ipv6NdTll = source.getIpv6NdTll();
    if (ipv6NdTll != null) {
        ipv6MatchBuilder.setIpv6NdTll(ipv6NdTll.getMacAddress());
        matchBuilder.setLayer3Match(ipv6MatchBuilder.build());
    }
    return Optional.of(matchBuilder);
}
Also used : Ipv6NdTll(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.tll._case.Ipv6NdTll) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)

Example 35 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder in project openflowplugin by opendaylight.

the class OfToSalMetadataCase method process.

@Override
public Optional<MatchBuilder> process(@Nonnull MetadataCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
    final MatchBuilder matchBuilder = data.getMatchBuilder();
    final MetadataBuilder metadataBuilder = new MetadataBuilder();
    final Metadata metadata = source.getMetadata();
    if (metadata != null) {
        metadataBuilder.setMetadata(new BigInteger(OFConstants.SIGNUM_UNSIGNED, metadata.getMetadata()));
        byte[] metadataMask = metadata.getMask();
        if (metadataMask != null) {
            metadataBuilder.setMetadataMask(new BigInteger(OFConstants.SIGNUM_UNSIGNED, metadataMask));
        }
        matchBuilder.setMetadata(metadataBuilder.build());
    }
    return Optional.of(matchBuilder);
}
Also used : MetadataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder) Metadata(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.Metadata) BigInteger(java.math.BigInteger) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)

Aggregations

MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)220 Test (org.junit.Test)135 EthernetMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)90 Ipv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder)84 Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)80 IpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder)69 ArrayList (java.util.ArrayList)65 ArpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder)63 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)56 Icmpv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder)55 VlanMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder)54 TcpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder)53 TunnelIpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder)52 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)51 Icmpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder)51 UdpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder)51 BigInteger (java.math.BigInteger)46 SctpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder)44 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)42 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)40