summaryrefslogtreecommitdiffstats
path: root/src/monitor
diff options
context:
space:
mode:
authorStef Walter <stefw@redhat.com>2014-01-10 08:58:12 +0100
committerJakub Hrozek <jhrozek@redhat.com>2014-02-24 11:14:59 +0100
commit769347ad4d35d43488eb98f980143495b0db415d (patch)
tree1613fff70e57d363ceda4f5d2d3d48efd87073a0 /src/monitor
parent3e7d7af1953410f3f009bf3b2e481a46fb80de83 (diff)
downloadsssd-769347ad4d35d43488eb98f980143495b0db415d.tar.gz
sssd-769347ad4d35d43488eb98f980143495b0db415d.tar.xz
sssd-769347ad4d35d43488eb98f980143495b0db415d.zip
sbus: Rework sbus to use interface metadata and vtables
Previous commits added support for interface metadata and handler vtables. This commit ports sbus_dbus_connection to use them. Port the internal uses of dbus to use the new scheme in a very minimal way. Further cleanup is possible here. This commit provides basic definitions of the internal dbus interfaces. The interfaces aren't fully defined, as the handlers will continue to unpack manually, and often overload DBus methods with different arguments (which is rather unorthodox, but not the end of the world). Reviewed-by: Jakub Hrozek <jhrozek@redhat.com> Reviewed-by: Sumit Bose <sbose@redhat.com> Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'src/monitor')
-rw-r--r--src/monitor/monitor.c12
-rw-r--r--src/monitor/monitor_iface.xml41
-rw-r--r--src/monitor/monitor_iface_generated.c92
-rw-r--r--src/monitor/monitor_iface_generated.h56
-rw-r--r--src/monitor/monitor_interfaces.h2
5 files changed, 196 insertions, 7 deletions
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 8a0844bbc..c2e5a5af6 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -523,17 +523,15 @@ static int add_services_startup_timeout(struct mt_ctx *ctx)
return EOK;
}
-struct sbus_method monitor_methods[] = {
- { MON_SRV_METHOD_VERSION, get_monitor_version },
- { MON_SRV_METHOD_REGISTER, client_registration },
- { NULL, NULL }
+struct mon_srv_iface monitor_methods = {
+ { &mon_srv_iface_meta, 0 },
+ .getVersion = get_monitor_version,
+ .RegisterService = client_registration,
};
struct sbus_interface monitor_server_interface = {
- MON_SRV_INTERFACE,
MON_SRV_PATH,
- SBUS_DEFAULT_VTABLE,
- monitor_methods,
+ &monitor_methods.vtable,
NULL
};
diff --git a/src/monitor/monitor_iface.xml b/src/monitor/monitor_iface.xml
new file mode 100644
index 000000000..506b749c8
--- /dev/null
+++ b/src/monitor/monitor_iface.xml
@@ -0,0 +1,41 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.freedesktop.sssd.monitor">
+ <annotation value="mon_srv_iface" name="org.freedesktop.DBus.GLib.CSymbol"/>
+ <method name="getVersion">
+ <!-- manual argument parsing -->
+ </method>
+ <method name="RegisterService">
+ <!-- manual argument parsing -->
+ </method>
+ </interface>
+
+ <interface name="org.freedesktop.sssd.service">
+ <annotation value="mon_cli_iface" name="org.freedesktop.DBus.GLib.CSymbol"/>
+ <method name="ping">
+ <!-- no arguments -->
+ </method>
+ <method name="resInit">
+ <!-- no arguments -->
+ </method>
+ <method name="shutDown">
+ <!-- no arguments -->
+ </method>
+ <method name="goOffline">
+ <!-- no arguments -->
+ </method>
+ <method name="resetOffline">
+ <!-- no arguments -->
+ </method>
+ <method name="rotateLogs">
+ <!-- no arguments -->
+ </method>
+ <method name="clearMemcache">
+ <!-- no arguments -->
+ </method>
+ <method name="clearEnumCache">
+ <!-- no arguments -->
+ </method>
+ </interface>
+</node>
diff --git a/src/monitor/monitor_iface_generated.c b/src/monitor/monitor_iface_generated.c
new file mode 100644
index 000000000..81a7c247a
--- /dev/null
+++ b/src/monitor/monitor_iface_generated.c
@@ -0,0 +1,92 @@
+/* The following definitions are auto-generated from monitor_iface.xml */
+
+#include "util/util.h"
+#include "sbus/sssd_dbus.h"
+#include "sbus/sssd_dbus_meta.h"
+#include "monitor_iface_generated.h"
+
+/* methods for org.freedesktop.sssd.monitor */
+const struct sbus_method_meta mon_srv_iface__methods[] = {
+ {
+ "getVersion", /* name */
+ NULL, /* no in_args */
+ NULL, /* no out_args */
+ offsetof(struct mon_srv_iface, getVersion),
+ },
+ {
+ "RegisterService", /* name */
+ NULL, /* no in_args */
+ NULL, /* no out_args */
+ offsetof(struct mon_srv_iface, RegisterService),
+ },
+ { NULL, }
+};
+
+/* interface info for org.freedesktop.sssd.monitor */
+const struct sbus_interface_meta mon_srv_iface_meta = {
+ "org.freedesktop.sssd.monitor", /* name */
+ mon_srv_iface__methods,
+ NULL, /* no signals */
+ NULL, /* no propetries */
+};
+
+/* methods for org.freedesktop.sssd.service */
+const struct sbus_method_meta mon_cli_iface__methods[] = {
+ {
+ "ping", /* name */
+ NULL, /* no in_args */
+ NULL, /* no out_args */
+ offsetof(struct mon_cli_iface, ping),
+ },
+ {
+ "resInit", /* name */
+ NULL, /* no in_args */
+ NULL, /* no out_args */
+ offsetof(struct mon_cli_iface, resInit),
+ },
+ {
+ "shutDown", /* name */
+ NULL, /* no in_args */
+ NULL, /* no out_args */
+ offsetof(struct mon_cli_iface, shutDown),
+ },
+ {
+ "goOffline", /* name */
+ NULL, /* no in_args */
+ NULL, /* no out_args */
+ offsetof(struct mon_cli_iface, goOffline),
+ },
+ {
+ "resetOffline", /* name */
+ NULL, /* no in_args */
+ NULL, /* no out_args */
+ offsetof(struct mon_cli_iface, resetOffline),
+ },
+ {
+ "rotateLogs", /* name */
+ NULL, /* no in_args */
+ NULL, /* no out_args */
+ offsetof(struct mon_cli_iface, rotateLogs),
+ },
+ {
+ "clearMemcache", /* name */
+ NULL, /* no in_args */
+ NULL, /* no out_args */
+ offsetof(struct mon_cli_iface, clearMemcache),
+ },
+ {
+ "clearEnumCache", /* name */
+ NULL, /* no in_args */
+ NULL, /* no out_args */
+ offsetof(struct mon_cli_iface, clearEnumCache),
+ },
+ { NULL, }
+};
+
+/* interface info for org.freedesktop.sssd.service */
+const struct sbus_interface_meta mon_cli_iface_meta = {
+ "org.freedesktop.sssd.service", /* name */
+ mon_cli_iface__methods,
+ NULL, /* no signals */
+ NULL, /* no propetries */
+};
diff --git a/src/monitor/monitor_iface_generated.h b/src/monitor/monitor_iface_generated.h
new file mode 100644
index 000000000..cde774985
--- /dev/null
+++ b/src/monitor/monitor_iface_generated.h
@@ -0,0 +1,56 @@
+/* The following declarations are auto-generated from monitor_iface.xml */
+
+#ifndef __MONITOR_IFACE_XML__
+#define __MONITOR_IFACE_XML__
+
+#include "sbus/sssd_dbus.h"
+
+/* ------------------------------------------------------------------------
+ * DBus Vtable handler structures
+ *
+ * These structures are filled in by implementors of the different
+ * dbus interfaces to handle method calls.
+ *
+ * Handler functions of type sbus_msg_handler_fn accept raw messages,
+ * other handlers will be typed appropriately. If a handler that is
+ * set to NULL is invoked it will result in a
+ * org.freedesktop.DBus.Error.NotSupported error for the caller.
+ */
+
+/* vtable for org.freedesktop.sssd.monitor */
+struct mon_srv_iface {
+ struct sbus_vtable vtable; /* derive from sbus_vtable */
+ sbus_msg_handler_fn getVersion;
+ sbus_msg_handler_fn RegisterService;
+};
+
+/* vtable for org.freedesktop.sssd.service */
+struct mon_cli_iface {
+ struct sbus_vtable vtable; /* derive from sbus_vtable */
+ sbus_msg_handler_fn ping;
+ sbus_msg_handler_fn resInit;
+ sbus_msg_handler_fn shutDown;
+ sbus_msg_handler_fn goOffline;
+ sbus_msg_handler_fn resetOffline;
+ sbus_msg_handler_fn rotateLogs;
+ sbus_msg_handler_fn clearMemcache;
+ sbus_msg_handler_fn clearEnumCache;
+};
+
+/* ------------------------------------------------------------------------
+ * DBus Interface Metadata
+ *
+ * These structure definitions are filled in with the information about
+ * the interfaces, methods, properties and so on.
+ *
+ * The actual definitions are found in the accompanying C file next
+ * to this header.
+ */
+
+/* interface info for org.freedesktop.sssd.monitor */
+extern const struct sbus_interface_meta mon_srv_iface_meta;
+
+/* interface info for org.freedesktop.sssd.service */
+extern const struct sbus_interface_meta mon_cli_iface_meta;
+
+#endif /* __MONITOR_IFACE_XML__ */
diff --git a/src/monitor/monitor_interfaces.h b/src/monitor/monitor_interfaces.h
index f27c7d00c..308642f78 100644
--- a/src/monitor/monitor_interfaces.h
+++ b/src/monitor/monitor_interfaces.h
@@ -21,6 +21,8 @@
#include "sbus/sssd_dbus.h"
+#include "monitor/monitor_iface_generated.h"
+
/*** Monitor ***/
#define MONITOR_VERSION 0x0001