Search in sources :

Example 1 with MatchUdpSourcePort

use of org.opendaylight.genius.mdsalutil.matches.MatchUdpSourcePort in project netvirt by opendaylight.

the class NaptEventHandler method buildAndGetMatchInfo.

private static List<MatchInfo> buildAndGetMatchInfo(String ip, int port, short tableId, NAPTEntryEvent.Protocol protocol, long segmentId) {
    MatchInfo ipMatchInfo = null;
    MatchInfo portMatchInfo = null;
    MatchInfo protocolMatchInfo = null;
    InetAddress ipAddress = null;
    String ipAddressAsString = null;
    try {
        ipAddress = InetAddress.getByName(ip);
        ipAddressAsString = ipAddress.getHostAddress();
    } catch (UnknownHostException e) {
        LOG.error("buildAndGetMatchInfo : UnknowHostException in buildAndGetMatchInfo." + "Failed  to build NAPT Flow for ip {}", ip, e);
        return null;
    }
    MatchInfo metaDataMatchInfo = null;
    if (tableId == NwConstants.OUTBOUND_NAPT_TABLE) {
        ipMatchInfo = new MatchIpv4Source(ipAddressAsString, "32");
        if (protocol == NAPTEntryEvent.Protocol.TCP) {
            protocolMatchInfo = MatchIpProtocol.TCP;
            portMatchInfo = new MatchTcpSourcePort(port);
        } else if (protocol == NAPTEntryEvent.Protocol.UDP) {
            protocolMatchInfo = MatchIpProtocol.UDP;
            portMatchInfo = new MatchUdpSourcePort(port);
        }
        metaDataMatchInfo = new MatchMetadata(MetaDataUtil.getVpnIdMetadata(segmentId), MetaDataUtil.METADATA_MASK_VRFID);
    } else {
        ipMatchInfo = new MatchIpv4Destination(ipAddressAsString, "32");
        if (protocol == NAPTEntryEvent.Protocol.TCP) {
            protocolMatchInfo = MatchIpProtocol.TCP;
            portMatchInfo = new MatchTcpDestinationPort(port);
        } else if (protocol == NAPTEntryEvent.Protocol.UDP) {
            protocolMatchInfo = MatchIpProtocol.UDP;
            portMatchInfo = new MatchUdpDestinationPort(port);
        }
    // metaDataMatchInfo = new MatchMetadata(BigInteger.valueOf(vpnId), MetaDataUtil.METADATA_MASK_VRFID);
    }
    ArrayList<MatchInfo> matchInfo = new ArrayList<>();
    matchInfo.add(MatchEthernetType.IPV4);
    matchInfo.add(ipMatchInfo);
    matchInfo.add(protocolMatchInfo);
    matchInfo.add(portMatchInfo);
    if (tableId == NwConstants.OUTBOUND_NAPT_TABLE) {
        matchInfo.add(metaDataMatchInfo);
    }
    return matchInfo;
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) MatchTcpSourcePort(org.opendaylight.genius.mdsalutil.matches.MatchTcpSourcePort) MatchUdpDestinationPort(org.opendaylight.genius.mdsalutil.matches.MatchUdpDestinationPort) UnknownHostException(java.net.UnknownHostException) MatchTcpDestinationPort(org.opendaylight.genius.mdsalutil.matches.MatchTcpDestinationPort) ArrayList(java.util.ArrayList) MatchIpv4Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination) MatchIpv4Source(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Source) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) MatchUdpSourcePort(org.opendaylight.genius.mdsalutil.matches.MatchUdpSourcePort) InetAddress(java.net.InetAddress)

Example 2 with MatchUdpSourcePort

use of org.opendaylight.genius.mdsalutil.matches.MatchUdpSourcePort in project netvirt by opendaylight.

the class DhcpServiceUtils method getDhcpMatch.

public static List<MatchInfo> getDhcpMatch() {
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.IPV4);
    matches.add(MatchIpProtocol.UDP);
    matches.add(new MatchUdpSourcePort(DhcpMConstants.DHCP_CLIENT_PORT));
    matches.add(new MatchUdpDestinationPort(DhcpMConstants.DHCP_SERVER_PORT));
    return matches;
}
Also used : MatchUdpDestinationPort(org.opendaylight.genius.mdsalutil.matches.MatchUdpDestinationPort) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) MatchUdpSourcePort(org.opendaylight.genius.mdsalutil.matches.MatchUdpSourcePort) ArrayList(java.util.ArrayList)

Example 3 with MatchUdpSourcePort

use of org.opendaylight.genius.mdsalutil.matches.MatchUdpSourcePort in project netvirt by opendaylight.

the class CountersServiceUtils method buildUdpMatchIfExists.

private static boolean buildUdpMatchIfExists(ElementCountersRequest ecr, List<MatchInfoBase> matches) {
    boolean udpFilterExist = false;
    if (ecr.isFilterGroupExist(CountersUtils.ELEMENT_COUNTERS_UDP_FILTER_GROUP_NAME)) {
        udpFilterExist = true;
        matches.add(MatchIpProtocol.UDP);
    }
    if (ecr.isFilterExist(CountersUtils.ELEMENT_COUNTERS_UDP_FILTER_GROUP_NAME, CountersUtils.UDP_SRC_PORT_FILTER_NAME)) {
        Integer udpSrcPort = Integer.valueOf(ecr.getFilterFromFilterGroup(CountersUtils.ELEMENT_COUNTERS_UDP_FILTER_GROUP_NAME, CountersUtils.UDP_SRC_PORT_FILTER_NAME));
        matches.add(new MatchUdpSourcePort(udpSrcPort));
    }
    if (ecr.isFilterExist(CountersUtils.ELEMENT_COUNTERS_UDP_FILTER_GROUP_NAME, CountersUtils.UDP_DST_PORT_FILTER_NAME)) {
        Integer udpDstPort = Integer.valueOf(ecr.getFilterFromFilterGroup(CountersUtils.ELEMENT_COUNTERS_UDP_FILTER_GROUP_NAME, CountersUtils.UDP_DST_PORT_FILTER_NAME));
        matches.add(new MatchUdpDestinationPort(udpDstPort));
    }
    return udpFilterExist;
}
Also used : BigInteger(java.math.BigInteger) MatchUdpDestinationPort(org.opendaylight.genius.mdsalutil.matches.MatchUdpDestinationPort) MatchUdpSourcePort(org.opendaylight.genius.mdsalutil.matches.MatchUdpSourcePort)

Example 4 with MatchUdpSourcePort

use of org.opendaylight.genius.mdsalutil.matches.MatchUdpSourcePort in project netvirt by opendaylight.

the class AclServiceUtils method buildDhcpMatches.

/**
 * Returns the DHCP match.
 *
 * @param srcPort the source port.
 * @param dstPort the destination port.
 * @param lportTag the lport tag
 * @param serviceMode ingress or egress service
 * @return list of matches.
 */
public static List<MatchInfoBase> buildDhcpMatches(int srcPort, int dstPort, int lportTag, Class<? extends ServiceModeBase> serviceMode) {
    List<MatchInfoBase> matches = new ArrayList<>(5);
    matches.add(MatchEthernetType.IPV4);
    matches.add(MatchIpProtocol.UDP);
    matches.add(new MatchUdpDestinationPort(dstPort));
    matches.add(new MatchUdpSourcePort(srcPort));
    matches.add(AclServiceUtils.buildLPortTagMatch(lportTag, serviceMode));
    return matches;
}
Also used : MatchUdpDestinationPort(org.opendaylight.genius.mdsalutil.matches.MatchUdpDestinationPort) MatchUdpSourcePort(org.opendaylight.genius.mdsalutil.matches.MatchUdpSourcePort) ArrayList(java.util.ArrayList) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Example 5 with MatchUdpSourcePort

use of org.opendaylight.genius.mdsalutil.matches.MatchUdpSourcePort in project netvirt by opendaylight.

the class AclServiceUtils method buildDhcpV6Matches.

/**
 * Returns the DHCPv6 match.
 *
 * @param srcPort the source port.
 * @param dstPort the destination port.
 * @param lportTag the lport tag
 * @param serviceMode ingress or egress
 * @return list of matches.
 */
public static List<MatchInfoBase> buildDhcpV6Matches(int srcPort, int dstPort, int lportTag, Class<? extends ServiceModeBase> serviceMode) {
    List<MatchInfoBase> matches = new ArrayList<>(6);
    matches.add(MatchEthernetType.IPV6);
    matches.add(MatchIpProtocol.UDP);
    matches.add(new MatchUdpDestinationPort(dstPort));
    matches.add(new MatchUdpSourcePort(srcPort));
    matches.add(AclServiceUtils.buildLPortTagMatch(lportTag, serviceMode));
    return matches;
}
Also used : MatchUdpDestinationPort(org.opendaylight.genius.mdsalutil.matches.MatchUdpDestinationPort) MatchUdpSourcePort(org.opendaylight.genius.mdsalutil.matches.MatchUdpSourcePort) ArrayList(java.util.ArrayList) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Aggregations

MatchUdpDestinationPort (org.opendaylight.genius.mdsalutil.matches.MatchUdpDestinationPort)5 MatchUdpSourcePort (org.opendaylight.genius.mdsalutil.matches.MatchUdpSourcePort)5 ArrayList (java.util.ArrayList)4 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)2 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)2 BigInteger (java.math.BigInteger)1 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 MatchIpv4Destination (org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination)1 MatchIpv4Source (org.opendaylight.genius.mdsalutil.matches.MatchIpv4Source)1 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)1 MatchTcpDestinationPort (org.opendaylight.genius.mdsalutil.matches.MatchTcpDestinationPort)1 MatchTcpSourcePort (org.opendaylight.genius.mdsalutil.matches.MatchTcpSourcePort)1