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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations