sssd_dbus_private.h revision b46c4c0d3e364636af1b42683cd3229ffa0b77cb
e59faf65ce864fe95dc00f5d52b8323cdbd0608aTimo Sirainen/*
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen Authors:
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen Simo Sorce <ssorce@redhat.com>
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen Stephen Gallagher <sgallagh@redhat.com>
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen
76a99afe0914951d20d96e0bf5e6d8d3ea3fd503Timo Sirainen Copyright (C) 2009 Red Hat
76a99afe0914951d20d96e0bf5e6d8d3ea3fd503Timo Sirainen
76a99afe0914951d20d96e0bf5e6d8d3ea3fd503Timo Sirainen This program is free software; you can redistribute it and/or modify
596ec384269cad3b0f0661df89b9cf33cbd171b7Timo Sirainen it under the terms of the GNU General Public License as published by
b039dabf4c53f72454e795930e7643b6e0e625f9Timo Sirainen the Free Software Foundation; either version 3 of the License, or
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen (at your option) any later version.
a35cbba04d0a2823da98e693bd09a051addffdb2Timo Sirainen
94e1adead9faddec88a623485b9999a87b1684faTimo Sirainen This program is distributed in the hope that it will be useful,
94e1adead9faddec88a623485b9999a87b1684faTimo Sirainen but WITHOUT ANY WARRANTY; without even the implied warranty of
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
503e5ef896c7b4a51cf73efb0d132860a8c747e6Timo Sirainen GNU General Public License for more details.
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
cb2b5a7d6e7e651191bf9ee1eda94a6e207288b0Timo Sirainen You should have received a copy of the GNU General Public License
cb2b5a7d6e7e651191bf9ee1eda94a6e207288b0Timo Sirainen along with this program. If not, see <http://www.gnu.org/licenses/>.
7ca2a9f1cca63cbc2ebffc185c7e5a2b32bc2780Timo Sirainen*/
7ca2a9f1cca63cbc2ebffc185c7e5a2b32bc2780Timo Sirainen
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen#ifndef _SSSD_DBUS_PRIVATE_H_
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen#define _SSSD_DBUS_PRIVATE_H_
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen#include <dhash.h>
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen#include "sssd_dbus_meta.h"
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainenunion dbus_conn_pointer {
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen DBusServer *server;
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen DBusConnection *conn;
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen};
cb951d3282610a9a0960230865bc5f3e3347b203Timo Sirainenenum dbus_conn_type {
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen SBUS_SERVER,
cb951d3282610a9a0960230865bc5f3e3347b203Timo Sirainen SBUS_CONNECTION
a35cbba04d0a2823da98e693bd09a051addffdb2Timo Sirainen};
3fe44a0df5a0bdd80c495f79cbf0e384441d6fccTimo Sirainen
a35cbba04d0a2823da98e693bd09a051addffdb2Timo Sirainenstruct sbus_watch_ctx;
cb951d3282610a9a0960230865bc5f3e3347b203Timo Sirainen
a35cbba04d0a2823da98e693bd09a051addffdb2Timo Sirainenstruct sbus_connection {
cb951d3282610a9a0960230865bc5f3e3347b203Timo Sirainen struct tevent_context *ev;
cb951d3282610a9a0960230865bc5f3e3347b203Timo Sirainen
cb951d3282610a9a0960230865bc5f3e3347b203Timo Sirainen enum dbus_conn_type type;
a35cbba04d0a2823da98e693bd09a051addffdb2Timo Sirainen union dbus_conn_pointer dbus;
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen
3fe44a0df5a0bdd80c495f79cbf0e384441d6fccTimo Sirainen char *address;
3fe44a0df5a0bdd80c495f79cbf0e384441d6fccTimo Sirainen int connection_type;
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen int disconnect;
4316355ca8b7698516272520a972291378698140Timo Sirainen
4316355ca8b7698516272520a972291378698140Timo Sirainen hash_table_t *managed_paths;
4316355ca8b7698516272520a972291378698140Timo Sirainen hash_table_t *nodes_fns;
4316355ca8b7698516272520a972291378698140Timo Sirainen hash_table_t *incoming_signals;
4316355ca8b7698516272520a972291378698140Timo Sirainen
4316355ca8b7698516272520a972291378698140Timo Sirainen /* reconnect settings */
4316355ca8b7698516272520a972291378698140Timo Sirainen int retries;
4316355ca8b7698516272520a972291378698140Timo Sirainen int max_retries;
4316355ca8b7698516272520a972291378698140Timo Sirainen sbus_conn_reconn_callback_fn reconnect_callback;
4316355ca8b7698516272520a972291378698140Timo Sirainen /* Private data needed to reinit after reconnection */
4316355ca8b7698516272520a972291378698140Timo Sirainen void *reconnect_pvt;
4316355ca8b7698516272520a972291378698140Timo Sirainen
4316355ca8b7698516272520a972291378698140Timo Sirainen /* server related stuff */
4316355ca8b7698516272520a972291378698140Timo Sirainen char *symlink;
4316355ca8b7698516272520a972291378698140Timo Sirainen sbus_server_conn_init_fn srv_init_fn;
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen void *srv_init_data;
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen hash_table_t *clients;
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen /* watches list */
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen struct sbus_watch_ctx *watch_list;
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen /* responder related stuff */
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen time_t *last_request_time;
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen};
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen/* =Standard=interfaces=================================================== */
4316355ca8b7698516272520a972291378698140Timo Sirainen
4316355ca8b7698516272520a972291378698140Timo Sirainenstruct sbus_vtable *sbus_introspect_vtable(void);
4316355ca8b7698516272520a972291378698140Timo Sirainenstruct sbus_vtable *sbus_properties_vtable(void);
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen/* =Watches=============================================================== */
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen
4316355ca8b7698516272520a972291378698140Timo Sirainenstruct sbus_watch_ctx {
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen struct sbus_watch_ctx *prev, *next;
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen
4316355ca8b7698516272520a972291378698140Timo Sirainen struct sbus_connection *conn;
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen
4316355ca8b7698516272520a972291378698140Timo Sirainen struct tevent_fd *fde;
4316355ca8b7698516272520a972291378698140Timo Sirainen int fd;
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen DBusWatch *dbus_read_watch;
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen DBusWatch *dbus_write_watch;
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen};
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainendbus_bool_t sbus_add_watch(DBusWatch *watch, void *data);
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainenvoid sbus_toggle_watch(DBusWatch *watch, void *data);
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainenvoid sbus_remove_watch(DBusWatch *watch, void *data);
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen/* =Timeouts============================================================== */
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen
4316355ca8b7698516272520a972291378698140Timo Sirainenstruct sbus_timeout_ctx {
4316355ca8b7698516272520a972291378698140Timo Sirainen DBusTimeout *dbus_timeout;
4316355ca8b7698516272520a972291378698140Timo Sirainen struct tevent_timer *te;
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen};
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainendbus_bool_t sbus_add_timeout(DBusTimeout *dbus_timeout, void *data);
4316355ca8b7698516272520a972291378698140Timo Sirainenvoid sbus_toggle_timeout(DBusTimeout *dbus_timeout, void *data);
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainenvoid sbus_remove_timeout(DBusTimeout *dbus_timeout, void *data);
0df9428baed48afaff90b4d4f03792d2fd756a43Timo Sirainen
4316355ca8b7698516272520a972291378698140Timo Sirainen/* =Requests============================================================== */
4316355ca8b7698516272520a972291378698140Timo Sirainen
4316355ca8b7698516272520a972291378698140Timo Sirainenstruct sbus_request *
4316355ca8b7698516272520a972291378698140Timo Sirainensbus_new_request(struct sbus_connection *conn, struct sbus_interface *intf,
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen DBusMessage *message);
d23c747de9d33966483fbdd41f08ad7766da7c5cTimo Sirainen
3fe44a0df5a0bdd80c495f79cbf0e384441d6fccTimo Sirainen/* =Interface=and=object=paths============================================ */
d23c747de9d33966483fbdd41f08ad7766da7c5cTimo Sirainen
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainenstruct sbus_interface_list {
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen struct sbus_interface_list *prev, *next;
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen struct sbus_interface *interface;
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen};
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenerrno_t
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainensbus_opath_hash_init(TALLOC_CTX *mem_ctx,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen struct sbus_connection *conn,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen hash_table_t **_table);
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainenstruct sbus_interface *
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainensbus_opath_hash_lookup_iface(hash_table_t *table,
d9b8c65d0a0ffc709ba7d23c449dbf2f46b10674Timo Sirainen const char *object_path,
4316355ca8b7698516272520a972291378698140Timo Sirainen const char *iface_name);
4316355ca8b7698516272520a972291378698140Timo Sirainen
4316355ca8b7698516272520a972291378698140Timo Sirainenerrno_t
d9b8c65d0a0ffc709ba7d23c449dbf2f46b10674Timo Sirainensbus_opath_hash_lookup_supported(TALLOC_CTX *mem_ctx,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen hash_table_t *table,
d23c747de9d33966483fbdd41f08ad7766da7c5cTimo Sirainen const char *object_path,
d23c747de9d33966483fbdd41f08ad7766da7c5cTimo Sirainen struct sbus_interface_list **_list);
d23c747de9d33966483fbdd41f08ad7766da7c5cTimo Sirainen
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenerrno_t
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainensbus_nodes_hash_init(TALLOC_CTX *mem_ctx,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen struct sbus_connection *conn,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen hash_table_t **_table);
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen
d23c747de9d33966483fbdd41f08ad7766da7c5cTimo Sirainenconst char **
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainensbus_nodes_hash_lookup(TALLOC_CTX *mem_ctx,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen hash_table_t *table,
d23c747de9d33966483fbdd41f08ad7766da7c5cTimo Sirainen const char *object_path);
d23c747de9d33966483fbdd41f08ad7766da7c5cTimo Sirainen
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainenvoid
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainensbus_request_invoke_or_finish(struct sbus_request *dbus_req,
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen sbus_msg_handler_fn handler_fn,
d23c747de9d33966483fbdd41f08ad7766da7c5cTimo Sirainen void *handler_data,
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen sbus_method_invoker_fn invoker_fn);
d23c747de9d33966483fbdd41f08ad7766da7c5cTimo Sirainen
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen/* A low-level, private variant of sbus_conn_send that accepts just
d23c747de9d33966483fbdd41f08ad7766da7c5cTimo Sirainen * DBusConnection. It should never be used outside sbus code, responders
e5acc283bf030b0b5c79ca4e52d315c516a299faPascal Volk * and back ends should use sbus_conn_send!
e5acc283bf030b0b5c79ca4e52d315c516a299faPascal Volk */
e3077468777f5d324224365e34d7bbc449168e52Timo Sirainenint sss_dbus_conn_send(DBusConnection *dbus_conn,
e3077468777f5d324224365e34d7bbc449168e52Timo Sirainen DBusMessage *msg,
d23c747de9d33966483fbdd41f08ad7766da7c5cTimo Sirainen int timeout_ms,
d23c747de9d33966483fbdd41f08ad7766da7c5cTimo Sirainen DBusPendingCallNotifyFunction reply_handler,
d23c747de9d33966483fbdd41f08ad7766da7c5cTimo Sirainen void *pvt,
4316355ca8b7698516272520a972291378698140Timo Sirainen DBusPendingCall **pending);
4316355ca8b7698516272520a972291378698140Timo Sirainen
d23c747de9d33966483fbdd41f08ad7766da7c5cTimo Sirainen
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen/* =Retrieve-conn-credentials=============================================== */
4316355ca8b7698516272520a972291378698140Timo Sirainenstruct tevent_req *sbus_get_sender_id_send(TALLOC_CTX *mem_ctx,
4316355ca8b7698516272520a972291378698140Timo Sirainen struct tevent_context *ev,
4316355ca8b7698516272520a972291378698140Timo Sirainen struct sbus_connection *conn,
4316355ca8b7698516272520a972291378698140Timo Sirainen const char *sender);
4316355ca8b7698516272520a972291378698140Timo Sirainenint sbus_get_sender_id_recv(struct tevent_req *req, int64_t *_uid);
4316355ca8b7698516272520a972291378698140Timo Sirainen
4316355ca8b7698516272520a972291378698140Timo Sirainen/* =Properties============================================================ */
4316355ca8b7698516272520a972291378698140Timo Sirainen
4316355ca8b7698516272520a972291378698140Timo Sirainenint sbus_properties_dispatch(struct sbus_request *dbus_req);
4316355ca8b7698516272520a972291378698140Timo Sirainen
4316355ca8b7698516272520a972291378698140Timo Sirainen/* =Signals=============================================================== */
4316355ca8b7698516272520a972291378698140Timo Sirainen
4316355ca8b7698516272520a972291378698140Timo SirainenDBusHandlerResult
4316355ca8b7698516272520a972291378698140Timo Sirainensbus_signal_handler(DBusConnection *conn,
4316355ca8b7698516272520a972291378698140Timo Sirainen DBusMessage *message,
4316355ca8b7698516272520a972291378698140Timo Sirainen void *handler_data);
4316355ca8b7698516272520a972291378698140Timo Sirainen
4316355ca8b7698516272520a972291378698140Timo Sirainenerrno_t
4316355ca8b7698516272520a972291378698140Timo Sirainensbus_incoming_signal_hash_init(TALLOC_CTX *mem_ctx,
4316355ca8b7698516272520a972291378698140Timo Sirainen hash_table_t **_table);
4316355ca8b7698516272520a972291378698140Timo Sirainen
4316355ca8b7698516272520a972291378698140Timo Sirainenvoid sbus_register_common_signals(struct sbus_connection *conn, void *pvt);
4316355ca8b7698516272520a972291378698140Timo Sirainen
4316355ca8b7698516272520a972291378698140Timo Sirainen#endif /* _SSSD_DBUS_PRIVATE_H_ */
4316355ca8b7698516272520a972291378698140Timo Sirainen