+ public static List<AllowedAddressPairs> getPortAllowedAddresses(Interface port) {
+ if (port == null) {
+ LOG.error("Port is Null");
+ return null;
+ }
+ InterfaceAcl aclInPort = port.getAugmentation(InterfaceAcl.class);
+ if (aclInPort == null) {
+ LOG.error("getSecurityGroupInPortList: no security group associated to Interface port: {}", port.getName());
+ return null;
+ }
+ return aclInPort.getAllowedAddressPairs();
+ }
+
+ public static BigInteger getDpIdFromIterfaceState(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf
+ .interfaces.rev140508.interfaces.state.Interface interfaceState) {
+ BigInteger dpId = null;
+ String interfaceName = interfaceState.getName();
+ List<String> ofportIds = interfaceState.getLowerLayerIf();
+ if (ofportIds != null && !ofportIds.isEmpty()) {
+ NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
+ dpId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
+ }
+ return dpId;
+ }
+
+ /**
+ * Builds the ip matches.
+ *
+ * @param ipPrefixOrAddress the ip prefix or address
+ * @param ipv4MatchType the ipv4 match type
+ * @return the list
+ */
+ public static List<MatchInfoBase> buildIpMatches(IpPrefixOrAddress ipPrefixOrAddress,
+ MatchFieldType ipv4MatchType) {
+ List<MatchInfoBase> flowMatches = new ArrayList<>();
+ flowMatches.add(new MatchInfo(MatchFieldType.eth_type, new long[] {NwConstants.ETHTYPE_IPV4}));
+ IpPrefix ipPrefix = ipPrefixOrAddress.getIpPrefix();
+ if (ipPrefix != null) {
+ if (ipPrefix.getIpv4Prefix().getValue() != null) {
+ String[] ipaddressValues = ipPrefix.getIpv4Prefix().getValue().split("/");
+ flowMatches.add(new MatchInfo(ipv4MatchType, new String[] {ipaddressValues[0], ipaddressValues[1]}));
+ } else {
+ // Handle IPv6
+ }
+ } else {
+ IpAddress ipAddress = ipPrefixOrAddress.getIpAddress();
+ if (ipAddress.getIpv4Address() != null) {
+ flowMatches
+ .add(new MatchInfo(ipv4MatchType, new String[] {ipAddress.getIpv4Address().getValue(), "32"}));
+ } else {
+ // Handle IPv6
+ }
+ }
+ return flowMatches;
+ }
+
+ /**
+ * Gets the lport tag match.
+ *
+ * @param lportTag the lport tag
+ * @return the lport tag match
+ */
+ public static MatchInfo buildLPortTagMatch(int lportTag) {
+ return new MatchInfo(MatchFieldType.metadata,
+ new BigInteger[] {MetaDataUtil.getLportTagMetaData(lportTag), MetaDataUtil.METADATA_MASK_LPORT_TAG});
+ }