Search in sources :

Example 1 with MatchTcpDestinationPort

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

the class CountersServiceUtils method buildTcpMatchIfExists.

private static boolean buildTcpMatchIfExists(ElementCountersRequest ecr, List<MatchInfoBase> matches) {
    boolean tcpFilterExist = false;
    if (ecr.isFilterGroupExist(CountersUtils.ELEMENT_COUNTERS_TCP_FILTER_GROUP_NAME)) {
        tcpFilterExist = true;
        matches.add(MatchIpProtocol.TCP);
    }
    if (ecr.isFilterExist(CountersUtils.ELEMENT_COUNTERS_TCP_FILTER_GROUP_NAME, CountersUtils.TCP_SRC_PORT_FILTER_NAME)) {
        int tcpSrcPort = Integer.parseInt(ecr.getFilterFromFilterGroup(CountersUtils.ELEMENT_COUNTERS_TCP_FILTER_GROUP_NAME, CountersUtils.TCP_SRC_PORT_FILTER_NAME));
        matches.add(new MatchTcpSourcePort(tcpSrcPort));
    }
    if (ecr.isFilterExist(CountersUtils.ELEMENT_COUNTERS_TCP_FILTER_GROUP_NAME, CountersUtils.TCP_DST_PORT_FILTER_NAME)) {
        int tcpDstPort = Integer.parseInt(ecr.getFilterFromFilterGroup(CountersUtils.ELEMENT_COUNTERS_TCP_FILTER_GROUP_NAME, CountersUtils.TCP_DST_PORT_FILTER_NAME));
        matches.add(new MatchTcpDestinationPort(tcpDstPort));
    }
    return tcpFilterExist;
}
Also used : MatchTcpSourcePort(org.opendaylight.genius.mdsalutil.matches.MatchTcpSourcePort) MatchTcpDestinationPort(org.opendaylight.genius.mdsalutil.matches.MatchTcpDestinationPort)

Example 2 with MatchTcpDestinationPort

use of org.opendaylight.genius.mdsalutil.matches.MatchTcpDestinationPort 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)

Aggregations

MatchTcpDestinationPort (org.opendaylight.genius.mdsalutil.matches.MatchTcpDestinationPort)2 MatchTcpSourcePort (org.opendaylight.genius.mdsalutil.matches.MatchTcpSourcePort)2 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)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 MatchUdpDestinationPort (org.opendaylight.genius.mdsalutil.matches.MatchUdpDestinationPort)1 MatchUdpSourcePort (org.opendaylight.genius.mdsalutil.matches.MatchUdpSourcePort)1