Search in sources :

Example 36 with Protocol

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.network.instance.protocols.Protocol in project netvirt by opendaylight.

the class NaptManager method removeFromIpPortMapDS.

protected void removeFromIpPortMapDS(long segmentId, String internalIpPort, NAPTEntryEvent.Protocol protocol) {
    ProtocolTypes protocolType = NatUtil.getProtocolType(protocol);
    removeFromIpPortMapDS(segmentId, internalIpPort, protocolType);
}
Also used : ProtocolTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProtocolTypes)

Example 37 with Protocol

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.network.instance.protocols.Protocol in project netvirt by opendaylight.

the class AclServiceOFFlowBuilder method programIpFlow.

/**
 * Converts IP matches into flows.
 * @param matches
 *            the matches
 * @return the map containing the flows and the respective flow id
 */
public static Map<String, List<MatchInfoBase>> programIpFlow(Matches matches) {
    if (matches != null) {
        AceIp acl = (AceIp) matches.getAceType();
        Short protocol = acl.getProtocol();
        if (protocol == null) {
            return programEtherFlow(acl);
        } else if (acl.getProtocol() == NwConstants.IP_PROT_TCP) {
            return programTcpFlow(acl);
        } else if (acl.getProtocol() == NwConstants.IP_PROT_UDP) {
            return programUdpFlow(acl);
        } else if (acl.getProtocol() == NwConstants.IP_PROT_ICMP) {
            return programIcmpFlow(acl);
        } else if (acl.getProtocol() != -1) {
            return programOtherProtocolFlow(acl);
        }
    }
    return null;
}
Also used : AceIp(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.AceIp)

Example 38 with Protocol

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.network.instance.protocols.Protocol in project netvirt by opendaylight.

the class AclServiceOFFlowBuilder method programOtherProtocolFlow.

/**
 * Converts generic protocol matches to flows.
 *
 * @param acl the access control list
 * @return the map containing the flows and the respective flow id
 */
public static Map<String, List<MatchInfoBase>> programOtherProtocolFlow(AceIp acl) {
    List<MatchInfoBase> flowMatches = new ArrayList<>();
    flowMatches.addAll(addSrcIpMatches(acl));
    flowMatches.addAll(addDstIpMatches(acl));
    if (acl.getAceIpVersion() instanceof AceIpv4) {
        flowMatches.add(MatchEthernetType.IPV4);
    } else if (acl.getAceIpVersion() instanceof AceIpv6) {
        flowMatches.add(MatchEthernetType.IPV6);
    }
    flowMatches.add(new MatchIpProtocol(acl.getProtocol()));
    String flowId = "OTHER_PROTO" + acl.getProtocol();
    Map<String, List<MatchInfoBase>> flowMatchesMap = new HashMap<>();
    flowMatchesMap.put(flowId, flowMatches);
    return flowMatchesMap;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) AceIpv6(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.AceIpv6) MatchIpProtocol(org.opendaylight.genius.mdsalutil.matches.MatchIpProtocol) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) 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 39 with Protocol

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.network.instance.protocols.Protocol in project netvirt by opendaylight.

the class AclServiceUtils method getHardTimoutForApplyStatefulChangeOnExistingTraffic.

/**
 * Returns the hard timeout based on the protocol when a ACL rule removed from the instance.
 * It will returns the timeout configured in the {@link AclserviceConfig} class.
 *
 * @param ace the ace
 * @param aclServiceUtils acl service utils
 * @return the hard time out
 */
public static Integer getHardTimoutForApplyStatefulChangeOnExistingTraffic(Ace ace, AclServiceUtils aclServiceUtils) {
    int hardTimeout = AclConstants.SECURITY_GROUP_ICMP_IDLE_TIME_OUT;
    Matches matches = ace.getMatches();
    AceIp acl = (AceIp) matches.getAceType();
    Short protocol = acl.getProtocol();
    if (protocol == null) {
        return hardTimeout;
    } else if (protocol == NwConstants.IP_PROT_TCP) {
        hardTimeout = aclServiceUtils.getConfig().getSecurityGroupTcpIdleTimeout();
    } else if (protocol == NwConstants.IP_PROT_UDP) {
        hardTimeout = aclServiceUtils.getConfig().getSecurityGroupUdpIdleTimeout();
    }
    return hardTimeout;
}
Also used : Matches(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches) AceIp(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.AceIp)

Example 40 with Protocol

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.network.instance.protocols.Protocol in project netvirt by opendaylight.

the class AclServiceOFFlowBuilderTest method testProgramUdpFlow_NoSrcDstPortRange.

@Test
public void testProgramUdpFlow_NoSrcDstPortRange() {
    AceIpBuilder builder = new AceIpBuilder();
    AceIpv4Builder v4builder = new AceIpv4Builder();
    v4builder.setSourceIpv4Network(new Ipv4Prefix("10.1.1.1/24"));
    v4builder.setDestinationIpv4Network(new Ipv4Prefix("20.1.1.1/24"));
    builder.setAceIpVersion(v4builder.build());
    builder.setSourcePortRange(null);
    builder.setDestinationPortRange(null);
    short protocol = 1;
    builder.setProtocol(protocol);
    Map<String, List<MatchInfoBase>> flowMatchesMap = AclServiceOFFlowBuilder.programUdpFlow(builder.build());
    List<MatchInfoBase> flowMatches = flowMatchesMap.get("UDP_SOURCE_ALL_");
    AclServiceTestUtils.verifyGeneralFlows(flowMatches, "1", "10.1.1.1", "20.1.1.1", "24");
    AclServiceTestUtils.verifyMatchFieldTypeDontExist(flowMatches, NxMatchUdpSourcePort.class);
    AclServiceTestUtils.verifyMatchFieldTypeDontExist(flowMatches, NxMatchUdpDestinationPort.class);
}
Also used : 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) ArrayList(java.util.ArrayList) List(java.util.List) 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) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)16 ArrayList (java.util.ArrayList)15 BigInteger (java.math.BigInteger)9 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)8 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)8 ExecutionException (java.util.concurrent.ExecutionException)7 Ipv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match)6 TcpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch)6 UdpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch)6 ProtocolTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProtocolTypes)6 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)5 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)5 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)5 ByteBuf (io.netty.buffer.ByteBuf)4 List (java.util.List)4 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match)4 EthernetMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch)4 Icmpv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match)4 IpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch)4 IntextIpPortMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.IntextIpPortMap)4