Search in sources :

Example 11 with Ipv4Match

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

the class OpenflowPluginBulkGroupTransactionProvider method createMatch2.

private static MatchBuilder createMatch2() {
    MatchBuilder match = new MatchBuilder();
    Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
    Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
    ipv4Match.setIpv4Source(prefix);
    Ipv4Match i4m = ipv4Match.build();
    match.setLayer3Match(i4m);
    EthernetMatchBuilder eth = new EthernetMatchBuilder();
    EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
    ethTypeBuilder.setType(new EtherType(0x0800L));
    eth.setEthernetType(ethTypeBuilder.build());
    match.setEthernetMatch(eth.build());
    return match;
}
Also used : Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) EthernetTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder) EtherType(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder) Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)

Example 12 with Ipv4Match

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match 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);
}
Also used : Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) 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) Ipv4Dst(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4Dst) 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 13 with Ipv4Match

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

the class MatchV10Convertor method convertL3Ipv4SrcMatch.

/**
 * Method splits the IP address and its mask and set their respective values in MatchV10Builder instance.
 * Wildcard value of the IP mask will be determined by Openflow java encoding library.
 *
 * @param matchBuilder match builder
 * @param ipv4         ip v4 match
 */
private static void convertL3Ipv4SrcMatch(final MatchV10Builder matchBuilder, final Ipv4Match ipv4) {
    if (ipv4.getIpv4Source() != null) {
        Iterator<String> addressParts = IpConversionUtil.PREFIX_SPLITTER.split(ipv4.getIpv4Source().getValue()).iterator();
        Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
        int prefix = buildPrefix(addressParts);
        matchBuilder.setNwSrc(ipv4Address);
        matchBuilder.setNwSrcMask((short) prefix);
    }
}
Also used : Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 14 with Ipv4Match

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match 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 });
    });
}
Also used : TunnelIpv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder) TunnelIpv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) Test(org.junit.Test)

Example 15 with Ipv4Match

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

the class BulkOMaticUtils method getMatch.

public static Match getMatch(final int sourceIp) {
    Ipv4Match ipv4Match = new Ipv4MatchBuilder().setIpv4Source(new Ipv4Prefix(ipIntToStr(sourceIp))).build();
    MatchBuilder matchBuilder = new MatchBuilder();
    matchBuilder.setLayer3Match(ipv4Match);
    EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
    EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder();
    ethTypeBuilder.setType(new EtherType(2048L));
    ethMatchBuilder.setEthernetType(ethTypeBuilder.build());
    matchBuilder.setEthernetMatch(ethMatchBuilder.build());
    return matchBuilder.build();
}
Also used : Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) EthernetTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder) EtherType(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType) Ipv4Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder) Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)

Aggregations

Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)26 Ipv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match)22 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)19 Ipv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder)18 EtherType (org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType)11 EthernetTypeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder)11 EthernetMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)11 Test (org.junit.Test)10 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)10 Icmpv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder)6 IpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder)6 Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)6 TunnelIpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder)6 ArrayList (java.util.ArrayList)5 BigInteger (java.math.BigInteger)4 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match)4 EthernetMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch)4 TcpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch)4 UdpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch)4 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)3