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 DEBUG(level, "DP Request [%s]: " fmt "\n", (name ?: "Unknown"), ##__VA_ARGS__)
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina struct dp_client *clients[DP_CLIENT_SENTINEL];
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* Numeric identificator that will be assigned to next request. */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* List of all ongoing requests. */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* Table containing list of sbus_requests where DP sends reply when
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * a request is finished. Value of this table is pair
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * <tevent_req, list of sbus_request>
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinaerrno_t dp_find_method(struct data_provider *provider,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinastruct dp_module *dp_load_module(TALLOC_CTX *mem_ctx,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina const char *name);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinaerrno_t dp_init_modules(TALLOC_CTX *mem_ctx, struct dp_module ***_modules);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinaconst char *dp_target_to_string(enum dp_targets target);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinabool dp_target_initialized(struct dp_target **targets, enum dp_targets type);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina/* Reply callbacks. */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinatypedef void (*dp_req_post_fn)(const char *req_name,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinatypedef void (*dp_req_reply_fn)(const char *req_name,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinavoid dp_req_reply_default(const char *req_name,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina/* Data provider request table. */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinaerrno_t dp_req_table_init(TALLOC_CTX *mem_ctx, hash_table_t **_table);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinastruct dp_table_value *dp_req_table_lookup(hash_table_t *table,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina const char *key);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina const char *key,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina const char *key);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinavoid dp_req_table_del_and_free(hash_table_t *table,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina const char *key);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina const char *key);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina/* Data provider request. */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinavoid dp_terminate_active_requests(struct data_provider *provider);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinavoid dp_req_reply_error(struct sbus_request *sbus_req,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinavoid _dp_req_with_reply(struct dp_client *dp_cli,
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * If @domain is NULL, be_ctx->domain is used.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * If req_key is NULL, address of sbus_req is used.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * If @pp_fn (post process function) is set it is call on a successful
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina * DP request before reply is sent.
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina#define dp_req_with_reply_pp(dp_cli, domain, req_name, req_key, sbus_req, \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* Check postprocess function parameter types. */ \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina void (*__pp_fn)(const char *, struct data_provider *, \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina /* Check reply function parameter types. */ \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina void (*__reply_fn)(const char *, struct sbus_request *, \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina _dp_req_with_reply(dp_cli, domain, req_name, req_key, sbus_req, \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina (dp_req_reply_fn)__reply_fn, #output_dtype); \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina#define dp_req_with_reply(dp_cli, domain, req_name, req_key, sbus_req, target,\
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina dp_req_with_reply_pp(dp_cli, domain, req_name, req_key, sbus_req, target, \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina method, dp_flags, req_data, NULL, NULL, void, \
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina/* Client shared functions. */
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinaerrno_t dp_client_init(struct sbus_connection *conn, void *data);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinastruct data_provider *dp_client_provider(struct dp_client *dp_cli);
2f18b8d67c86a1a277b59894f24ea6e09b41b7eaPavel Březinastruct be_ctx *dp_client_be(struct dp_client *dp_cli);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březinastruct sbus_connection *dp_client_conn(struct dp_client *dp_cli);
d3dee2a07f1a8ee9ae6f94e149ced754ef76c248Pavel Březina#endif /* _DP_PRIVATE_H_ */