d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina Pavel Březina <pbrezina@redhat.com>
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina Copyright (C) 2016 Red Hat
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina This program is free software; you can redistribute it and/or modify
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina it under the terms of the GNU General Public License as published by
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina the Free Software Foundation; either version 3 of the License, or
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina (at your option) any later version.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina This program is distributed in the hope that it will be useful,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina GNU General Public License for more details.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina You should have received a copy of the GNU General Public License
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina#include "providers/data_provider/dp_private.h"
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Bug: invalid method %d\n", method);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* Each method can be set only once, if we attempt to set it twice it
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * is a bug in module initialization. */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Bug: method %d is already set!\n", method);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina if (send_fn == NULL || recv_fn == NULL || method_dtype == NULL
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina || request_dtype == NULL || output_dtype == NULL) {
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Bug: one or more required parameter was "
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina methods[method].request_dtype = request_dtype;
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinabool dp_method_enabled(struct data_provider *provider,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina if (target >= DP_TARGET_SENTINEL || method >= DP_METHOD_SENTINEL) {
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Bug: Invalid target or method ID\n");
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina return false;
a16e7a370d0b564a5edad7791d2421d175c0787aPavel Březina if (provider == NULL || provider->targets == NULL) {
a16e7a370d0b564a5edad7791d2421d175c0787aPavel Březina DEBUG(SSSDBG_TRACE_FUNC, "Target %s is not yet initialized\n",
a16e7a370d0b564a5edad7791d2421d175c0787aPavel Březina return false;
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina if (dp_target == NULL || dp_target->initialized == false) {
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "Target %s is not configured\n",
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina return false;
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina if (dp_target->methods[method].send_fn == NULL) {
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina return false;
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinaerrno_t dp_find_method(struct data_provider *provider,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina if (target >= DP_TARGET_SENTINEL || method >= DP_METHOD_SENTINEL) {
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Bug: Invalid target or method ID\n");
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina if (!dp_target_initialized(provider->targets, target)) {
e98d085b529e0ae5e07a717ce3b30f3943be0ee0Justin Stephenson DEBUG(SSSDBG_CONF_SETTINGS, "Target [%s] is not initialized\n",
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina execute = &provider->targets[target]->methods[method];
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina if (execute->send_fn == NULL || execute->recv_fn == NULL) {
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina "Bug: Invalid combination of target [%s] and method [%d]\n",