Search in sources :

Example 1 with IpMatch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch 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 IpMatch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch in project netvirt by opendaylight.

the class AclMatchesTest method buildIpv4DscpMatchTest.

@Test
public void buildIpv4DscpMatchTest() {
    AceIpBuilder aceIpBuilder = new AceIpBuilder();
    aceIpBuilder.setAceIpVersion(new AceIpv4Builder().build());
    aceIpBuilder.setDscp(new Dscp(DSCP_VALUE));
    MatchesBuilder matchesBuilder = new MatchesBuilder();
    matchesBuilder.setAceType(aceIpBuilder.build());
    // Create the aclMatches that is the object to be tested
    AclMatches aclMatches = new AclMatches(matchesBuilder.build());
    MatchBuilder matchBuilder = aclMatches.buildMatch();
    // There should be an IPv4 etherType set
    EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
    assertNotNull(ethMatch);
    assertEquals(ethMatch.getEthernetType().getType().getValue(), Long.valueOf(NwConstants.ETHTYPE_IPV4));
    // Check the DSCP value
    IpMatch ipMatch = matchBuilder.getIpMatch();
    assertNotNull(ipMatch);
    assertEquals(ipMatch.getIpDscp().getValue(), Short.valueOf(DSCP_VALUE));
    // The rest should be null
    assertNull(matchBuilder.getLayer3Match());
    assertNull(matchBuilder.getLayer4Match());
}
Also used : EthernetMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch) AceIpBuilder(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.AceIpBuilder) AceIpv4Builder(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.AceIpv4Builder) Dscp(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp) MatchesBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.MatchesBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) IpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch) Test(org.junit.Test)

Example 3 with IpMatch

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

the class OpenflowPluginBulkTransactionProvider method createICMPv6Match.

private static MatchBuilder createICMPv6Match() {
    MatchBuilder match = new MatchBuilder();
    EthernetMatchBuilder eth = new EthernetMatchBuilder();
    EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
    ethTypeBuilder.setType(new EtherType(0x86ddL));
    eth.setEthernetType(ethTypeBuilder.build());
    match.setEthernetMatch(eth.build());
    // ipv4 version
    IpMatchBuilder ipmatch = new IpMatchBuilder();
    ipmatch.setIpProtocol((short) 58);
    match.setIpMatch(ipmatch.build());
    // icmpv6
    Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
    // match
    icmpv6match.setIcmpv6Type((short) 135);
    icmpv6match.setIcmpv6Code((short) 1);
    match.setIcmpv6Match(icmpv6match.build());
    return match;
}
Also used : IpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder) 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) Ipv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder) IpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder) Icmpv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Icmpv6MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)

Example 4 with IpMatch

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

the class IpProtoEntryDeserializer method deserializeEntry.

@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
    processHeader(message);
    final short proto = message.readUnsignedByte();
    if (Objects.isNull(builder.getIpMatch())) {
        builder.setIpMatch(new IpMatchBuilder().setIpProtocol(proto).build());
    } else if (Objects.isNull(builder.getIpMatch().getIpProtocol())) {
        builder.setIpMatch(new IpMatchBuilder(builder.getIpMatch()).setIpProtocol(proto).build());
    } else {
        throwErrorOnMalformed(builder, "ipMatch", "ipProtocol");
    }
}
Also used : IpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder)

Example 5 with IpMatch

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

the class IpEcnEntryDeserializer method deserializeEntry.

@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
    processHeader(message);
    final short ecn = message.readUnsignedByte();
    if (Objects.isNull(builder.getIpMatch())) {
        builder.setIpMatch(new IpMatchBuilder().setIpEcn(ecn).build());
    } else if (Objects.isNull(builder.getIpMatch().getIpEcn())) {
        builder.setIpMatch(new IpMatchBuilder(builder.getIpMatch()).setIpEcn(ecn).build());
    } else {
        throwErrorOnMalformed(builder, "ipMatch", "ipEcn");
    }
}
Also used : IpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder)

Aggregations

IpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder)16 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)13 EtherType (org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType)9 EthernetTypeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder)9 EthernetMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)9 Icmpv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder)9 IpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch)9 Ipv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder)9 Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)9 TcpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder)9 UdpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder)9 Test (org.junit.Test)8 EthernetMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch)8 Icmpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder)8 TcpFlagsMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatchBuilder)8 VlanMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder)8 ArpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder)8 TunnelIpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder)8 SctpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder)8 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)7