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_request.h"
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina#include "providers/data_provider/dp_custom_data.h"
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * Module constructor.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * It is possible to create a module data that is passed into all
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * target initialization functions.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinatypedef errno_t (*dp_module_init_fn)(TALLOC_CTX *mem_ctx,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * Target initialization function.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * Pointer to dp_method is unique for all targets. Make sure that
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * dp_set_method is called in all targets even if you are reusing
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * some existing context or initialization function.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinatypedef errno_t (*dp_target_init_fn)(TALLOC_CTX *mem_ctx,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina/* Method handler. */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinatypedef struct tevent_req *
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina(*dp_req_send_fn)(TALLOC_CTX *mem_ctx, void *method_data, void *request_data,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina(*dp_req_recv_fn)(TALLOC_CTX *mem_ctx, struct tevent_req *req, void *data);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina/* Data provider initialization. */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinabool _dp_target_enabled(struct data_provider *provider,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina#define dp_target_enabled(provider, module_name, ...) \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina _dp_target_enabled(provider, module_name, ##__VA_ARGS__, DP_TARGET_SENTINEL)
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinastruct dp_module *dp_target_module(struct data_provider *provider,
35fa5a83ce8badf6bc868937047f44c3f32b7c28Sumit Bosevoid *dp_get_module_data(struct dp_module *dp_module);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina/* We check function headers on compile time and data types on run time. This
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * check requires that both method and request private data are talloc-created
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * with talloc name set to data type name (which is done by talloc unless
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * you use _size variations of talloc functions.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * This way we ensure that we always pass correct data and we can access them
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * directly in request handler without the need to cast them explicitly
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * from void pointer. */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina#define dp_set_method(methods, method, send_fn, recv_fn, method_data, \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* Check _send function parameter types. */ \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina struct tevent_req *(*__send_fn)(TALLOC_CTX *, method_dtype *, \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina req_dtype *, struct dp_req_params *params) = (send_fn); \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* Check _recv function parameter types. */ \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina errno_t (*__recv_fn)(TALLOC_CTX *, struct tevent_req *, \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina _dp_set_method(methods, method, (dp_req_send_fn)__send_fn, \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinabool dp_method_enabled(struct data_provider *provider,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinavoid dp_terminate_domain_requests(struct data_provider *provider,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina const char *domain);
b3ee4be9e1794fa823696d70d4958f3b0269939cJakub Hrozekvoid dp_sbus_domain_active(struct data_provider *provider,
b3ee4be9e1794fa823696d70d4958f3b0269939cJakub Hrozekvoid dp_sbus_domain_inconsistent(struct data_provider *provider,
af28fa659f7ffcd12ecf8bda64e79cf5dd225651Jakub Hrozekvoid dp_sbus_reset_users_ncache(struct data_provider *provider,
af28fa659f7ffcd12ecf8bda64e79cf5dd225651Jakub Hrozekvoid dp_sbus_reset_groups_ncache(struct data_provider *provider,
5007103e82f34e64a0ff3b278797b9fa42ba1ddaJakub Hrozekvoid dp_sbus_reset_users_memcache(struct data_provider *provider);
5007103e82f34e64a0ff3b278797b9fa42ba1ddaJakub Hrozekvoid dp_sbus_reset_groups_memcache(struct data_provider *provider);
5007103e82f34e64a0ff3b278797b9fa42ba1ddaJakub Hrozekvoid dp_sbus_reset_initgr_memcache(struct data_provider *provider);
709c42f0cabc96d0e0edf72753a0967593206ff4Fabiano Fidênciovoid dp_sbus_invalidate_group_memcache(struct data_provider *provider,
c0f9f5a0f6d71a1596ee3cef549b4b02295313c3Jakub Hrozek * A dummy handler for DPM_ACCT_DOMAIN_HANDLER.
c0f9f5a0f6d71a1596ee3cef549b4b02295313c3Jakub Hrozek * Its purpose is to always return ERR_GET_ACCT_DOM_NOT_SUPPORTED
c0f9f5a0f6d71a1596ee3cef549b4b02295313c3Jakub Hrozek * which the responder should evaluate as "this back end does not
c0f9f5a0f6d71a1596ee3cef549b4b02295313c3Jakub Hrozek * support locating entries' domain" and never call
c0f9f5a0f6d71a1596ee3cef549b4b02295313c3Jakub Hrozek * DPM_ACCT_DOMAIN_HANDLER again
c0f9f5a0f6d71a1596ee3cef549b4b02295313c3Jakub Hrozek * This request cannot fail, except for critical errors like OOM.
c0f9f5a0f6d71a1596ee3cef549b4b02295313c3Jakub Hrozekdefault_account_domain_send(TALLOC_CTX *mem_ctx,
c0f9f5a0f6d71a1596ee3cef549b4b02295313c3Jakub Hrozekerrno_t default_account_domain_recv(TALLOC_CTX *mem_ctx,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina#endif /* _DP_H_ */