Search in sources :

Example 1 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder in project netvirt by opendaylight.

the class AclMatches method addIpProtocolMatch.

private void addIpProtocolMatch(AceIp aceIp) {
    // Match on IP
    setIpv4EtherType();
    IpMatchBuilder ipMatch = new IpMatchBuilder();
    ipMatch.setIpProtocol(aceIp.getProtocol());
    matchBuilder.setIpMatch(mergeIpMatch(matchBuilder, ipMatch));
    // TODO Ranges are not supported yet
    int srcPort = 0;
    if (aceIp.getSourcePortRange() != null && aceIp.getSourcePortRange().getLowerPort() != null) {
        srcPort = aceIp.getSourcePortRange().getLowerPort().getValue();
    }
    int dstPort = 0;
    if (aceIp.getDestinationPortRange() != null && aceIp.getDestinationPortRange().getLowerPort() != null) {
        dstPort = aceIp.getDestinationPortRange().getLowerPort().getValue();
    }
    // Match on a TCP/UDP src/dst port
    if (aceIp.getProtocol() == IPProtocols.TCP.shortValue()) {
        TcpMatchBuilder tcpMatch = new TcpMatchBuilder();
        if (srcPort != 0) {
            tcpMatch.setTcpSourcePort(new PortNumber(srcPort));
        }
        if (dstPort != 0) {
            tcpMatch.setTcpDestinationPort(new PortNumber(dstPort));
        }
        if (srcPort != 0 || dstPort != 0) {
            matchBuilder.setLayer4Match(tcpMatch.build());
        }
    } else if (aceIp.getProtocol() == IPProtocols.UDP.shortValue()) {
        UdpMatchBuilder udpMatch = new UdpMatchBuilder();
        if (srcPort != 0) {
            udpMatch.setUdpSourcePort(new PortNumber(srcPort));
        }
        if (dstPort != 0) {
            udpMatch.setUdpDestinationPort(new PortNumber(dstPort));
        }
        if (srcPort != 0 || dstPort != 0) {
            matchBuilder.setLayer4Match(udpMatch.build());
        }
    }
}
Also used : IpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder) TcpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) UdpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder)

Example 2 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder in project netvirt by opendaylight.

the class AclMatches method setEtherType.

private void setEtherType(long etherType) {
    EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
    ethTypeBuilder.setType(new EtherType(etherType));
    EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
    ethernetMatch.setEthernetType(ethTypeBuilder.build());
    matchBuilder.setEthernetMatch(mergeEthernetMatch(matchBuilder, ethernetMatch));
}
Also used : 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)

Example 3 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder in project netvirt by opendaylight.

the class AclMatches method addEthMatch.

private void addEthMatch() {
    AceEth aceEth = (AceEth) matches.getAceType();
    if (aceEth.getSourceMacAddress() != null) {
        EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
        EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
        ethSourceBuilder.setAddress(new MacAddress(aceEth.getSourceMacAddress()));
        ethernetMatch.setEthernetSource(ethSourceBuilder.build());
        matchBuilder.setEthernetMatch(mergeEthernetMatch(matchBuilder, ethernetMatch));
    }
    if (aceEth.getDestinationMacAddress() != null) {
        EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
        EthernetDestinationBuilder ethDestBuilder = new EthernetDestinationBuilder();
        ethDestBuilder.setAddress(new MacAddress(aceEth.getDestinationMacAddress()));
        ethernetMatch.setEthernetDestination(ethDestBuilder.build());
        matchBuilder.setEthernetMatch(mergeEthernetMatch(matchBuilder, ethernetMatch));
    }
}
Also used : EthernetDestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder) EthernetSourceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder) AceEth(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceEth) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)

Example 4 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder in project netvirt by opendaylight.

the class AclMatches method addIpV4Match.

private void addIpV4Match(AceIp aceIp) {
    setIpv4EtherType();
    AceIpv4 aceIpv4 = (AceIpv4) aceIp.getAceIpVersion();
    if (aceIpv4.getDestinationIpv4Network() != null) {
        Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
        ipv4match.setIpv4Destination(aceIpv4.getDestinationIpv4Network());
        matchBuilder.setLayer3Match(mergeIpv4Match(matchBuilder, ipv4match));
    }
    if (aceIpv4.getSourceIpv4Network() != null) {
        Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
        ipv4match.setIpv4Source(aceIpv4.getSourceIpv4Network());
        matchBuilder.setLayer3Match(mergeIpv4Match(matchBuilder, ipv4match));
    }
}
Also used : Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) AceIpv4(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4)

Example 5 with MatchBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder in project netvirt by opendaylight.

the class OpenFlow13Utils method addMatchTunDstIp.

public static void addMatchTunDstIp(MatchBuilder match, Ipv4Address ipv4Address) {
    NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder().setNxmNxTunIpv4Dst(new NxmNxTunIpv4DstBuilder().setIpv4Address(ipv4Address).build()).build();
    addExtension(match, NxmNxTunIpv4DstKey.class, am);
}
Also used : NxAugMatchNodesNodeTableFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow) NxAugMatchNodesNodeTableFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder) NxmNxTunIpv4DstBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.tun.ipv4.dst.grouping.NxmNxTunIpv4DstBuilder)

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