'Checks and returns the matching state for v4 or v6 scopes.'

def _check_if_address_scopes_match(self, int_port, ex_gw_port):

    int_port_addr_scopes = int_port.get('address_scopes', {})
    ext_port_addr_scopes = ex_gw_port.get('address_scopes', {})
    key = (lib_constants.IP_VERSION_6 if self._port_has_ipv6_subnet(int_port) else lib_constants.IP_VERSION_4)
    int_port_addr_value = int_port_addr_scopes.get(str(key))
    if (int_port_addr_value is None):
        return False
    if ((key != lib_constants.IP_VERSION_6) and (int_port_addr_scopes.get(str(key)) in ext_port_addr_scopes.values())):
        return True
    return False
