summaryrefslogtreecommitdiff
path: root/server/providers
diff options
context:
space:
mode:
Diffstat (limited to 'server/providers')
-rw-r--r--server/providers/data_provider.c46
-rw-r--r--server/providers/data_provider_be.c71
2 files changed, 66 insertions, 51 deletions
diff --git a/server/providers/data_provider.c b/server/providers/data_provider.c
index c1dc2801..aa66c8e5 100644
--- a/server/providers/data_provider.c
+++ b/server/providers/data_provider.c
@@ -76,9 +76,9 @@ struct dp_frontend {
static int dp_backend_destructor(void *ctx);
static int dp_frontend_destructor(void *ctx);
-static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply);
-static int service_pong(DBusMessage *message, struct sbus_message_ctx *reply);
-static int service_reload(DBusMessage *message, struct sbus_message_ctx *reply);
+static int service_identity(DBusMessage *message, void *data, DBusMessage **r);
+static int service_pong(DBusMessage *message, void *data, DBusMessage **r);
+static int service_reload(DBusMessage *message, void *data, DBusMessage **r);
struct sbus_method mon_sbus_methods[] = {
{ SERVICE_METHOD_IDENTITY, service_identity },
@@ -87,7 +87,7 @@ struct sbus_method mon_sbus_methods[] = {
{ NULL, NULL }
};
-static int dp_get_account_info(DBusMessage *message, struct sbus_message_ctx *reply);
+static int dp_get_account_info(DBusMessage *message, void *data, DBusMessage **r);
struct sbus_method dp_sbus_methods[] = {
{ DP_SRV_METHOD_GETACCTINFO, dp_get_account_info },
@@ -108,16 +108,17 @@ struct dp_be_request {
struct dp_backend *be;
};
-static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply)
+static int service_identity(DBusMessage *message, void *data, DBusMessage **r)
{
dbus_uint16_t version = DATA_PROVIDER_VERSION;
const char *name = DATA_PROVIDER_SERVICE_NAME;
+ DBusMessage *reply;
dbus_bool_t ret;
DEBUG(4, ("Sending identity data [%s,%d]\n", name, version));
- reply->reply_message = dbus_message_new_method_return(message);
- ret = dbus_message_append_args(reply->reply_message,
+ reply = dbus_message_new_method_return(message);
+ ret = dbus_message_append_args(reply,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_UINT16, &version,
DBUS_TYPE_INVALID);
@@ -125,30 +126,33 @@ static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply
return EIO;
}
+ *r = reply;
return EOK;
}
-static int service_pong(DBusMessage *message, struct sbus_message_ctx *reply)
+static int service_pong(DBusMessage *message, void *data, DBusMessage **r)
{
+ DBusMessage *reply;
dbus_bool_t ret;
- reply->reply_message = dbus_message_new_method_return(message);
- ret = dbus_message_append_args(reply->reply_message, DBUS_TYPE_INVALID);
+ reply = dbus_message_new_method_return(message);
+ ret = dbus_message_append_args(reply, DBUS_TYPE_INVALID);
if (!ret) {
return EIO;
}
+ *r = reply;
return EOK;
}
-static int service_reload(DBusMessage *message, struct sbus_message_ctx *reply) {
+static int service_reload(DBusMessage *message, void *data, DBusMessage **r) {
/* Monitor calls this function when we need to reload
* our configuration information. Perform whatever steps
* are needed to update the configuration objects.
*/
/* Send an empty reply to acknowledge receipt */
- return service_pong(message, reply);
+ return service_pong(message, data, r);
}
static int dp_monitor_init(struct dp_ctx *dpctx)
@@ -534,13 +538,14 @@ static int dp_send_acct_req(struct dp_be_request *bereq,
return EOK;
}
-static int dp_get_account_info(DBusMessage *message, struct sbus_message_ctx *reply)
+static int dp_get_account_info(DBusMessage *message, void *data, DBusMessage **r)
{
struct sbus_message_handler_ctx *smh_ctx;
struct dp_client *dpcli;
struct dp_be_request *bereq;
struct dp_request *dpreq = NULL;
struct dp_backend *dpbe;
+ DBusMessage *reply;
DBusError dbus_error;
dbus_bool_t dbret;
void *user_data;
@@ -549,11 +554,9 @@ static int dp_get_account_info(DBusMessage *message, struct sbus_message_ctx *re
const char *errmsg = NULL;
int dpret = 0, ret = 0;
- if (!reply) return EINVAL;
-
- smh_ctx = reply->mh_ctx;
+ if (!data) return EINVAL;
+ smh_ctx = talloc_get_type(data, struct sbus_message_handler_ctx);
if (!smh_ctx) return EINVAL;
-
user_data = sbus_conn_get_private_data(smh_ctx->conn_ctx);
if (!user_data) return EINVAL;
dpcli = talloc_get_type(user_data, struct dp_client);
@@ -575,7 +578,7 @@ static int dp_get_account_info(DBusMessage *message, struct sbus_message_ctx *re
DEBUG(4, ("Got request for [%s][%u][%s][%s]\n",
domain, type, attrs, filter));
- reply->reply_message = dbus_message_new_method_return(message);
+ reply = dbus_message_new_method_return(message);
/* search for domain */
if (!domain) {
@@ -603,7 +606,7 @@ static int dp_get_account_info(DBusMessage *message, struct sbus_message_ctx *re
goto respond;
}
- dpreq->reply = reply->reply_message;
+ dpreq->reply = reply;
dpreq->src_cli = dpcli;
dpreq->pending_replies = 0;
@@ -659,7 +662,7 @@ static int dp_get_account_info(DBusMessage *message, struct sbus_message_ctx *re
goto respond;
}
- dpreq->reply = reply->reply_message;
+ dpreq->reply = reply;
dpreq->src_cli = dpcli;
dpreq->pending_replies = 1;
@@ -695,13 +698,14 @@ static int dp_get_account_info(DBusMessage *message, struct sbus_message_ctx *re
return EOK;
respond:
- dbret = dbus_message_append_args(reply->reply_message,
+ dbret = dbus_message_append_args(reply,
DBUS_TYPE_UINT16, &dpret,
DBUS_TYPE_UINT32, &ret,
DBUS_TYPE_STRING, &errmsg,
DBUS_TYPE_INVALID);
if (!dbret) return EIO;
+ *r = reply;
return EOK;
}
diff --git a/server/providers/data_provider_be.c b/server/providers/data_provider_be.c
index c12e2b2f..7b491ce7 100644
--- a/server/providers/data_provider_be.c
+++ b/server/providers/data_provider_be.c
@@ -44,8 +44,8 @@
typedef int (*be_init_fn_t)(TALLOC_CTX *, struct be_mod_ops **, void **);
-static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply);
-static int service_pong(DBusMessage *message, struct sbus_message_ctx *reply);
+static int service_identity(DBusMessage *message, void *data, DBusMessage **r);
+static int service_pong(DBusMessage *message, void *data, DBusMessage **r);
struct sbus_method mon_sbus_methods[] = {
{ SERVICE_METHOD_IDENTITY, service_identity },
@@ -53,9 +53,9 @@ struct sbus_method mon_sbus_methods[] = {
{ NULL, NULL }
};
-static int be_identity(DBusMessage *message, struct sbus_message_ctx *reply);
-static int be_check_online(DBusMessage *message, struct sbus_message_ctx *reply);
-static int be_get_account_info(DBusMessage *message, struct sbus_message_ctx *reply);
+static int be_identity(DBusMessage *message, void *data, DBusMessage **r);
+static int be_check_online(DBusMessage *message, void *data, DBusMessage **r);
+static int be_get_account_info(DBusMessage *message, void *data, DBusMessage **r);
struct sbus_method be_methods[] = {
{ DP_CLI_METHOD_IDENTITY, be_identity },
@@ -64,16 +64,17 @@ struct sbus_method be_methods[] = {
{ NULL, NULL }
};
-static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply)
+static int service_identity(DBusMessage *message, void *data, DBusMessage **r)
{
dbus_uint16_t version = DATA_PROVIDER_VERSION;
struct sbus_message_handler_ctx *smh_ctx;
struct be_ctx *ctx;
+ DBusMessage *reply;
dbus_bool_t ret;
void *user_data;
- if (!reply) return EINVAL;
- smh_ctx = reply->mh_ctx;
+ if (!data) return EINVAL;
+ smh_ctx = talloc_get_type(data, struct sbus_message_handler_ctx);
if (!smh_ctx) return EINVAL;
user_data = sbus_conn_get_private_data(smh_ctx->conn_ctx);
if (!user_data) return EINVAL;
@@ -82,8 +83,8 @@ static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply
DEBUG(4,("Sending ID reply: (%s,%d)\n", ctx->identity, version));
- reply->reply_message = dbus_message_new_method_return(message);
- ret = dbus_message_append_args(reply->reply_message,
+ reply = dbus_message_new_method_return(message);
+ ret = dbus_message_append_args(reply,
DBUS_TYPE_STRING, &ctx->identity,
DBUS_TYPE_UINT16, &version,
DBUS_TYPE_INVALID);
@@ -91,33 +92,37 @@ static int service_identity(DBusMessage *message, struct sbus_message_ctx *reply
return EIO;
}
+ *r = reply;
return EOK;
}
-static int service_pong(DBusMessage *message, struct sbus_message_ctx *reply)
+static int service_pong(DBusMessage *message, void *data, DBusMessage **r)
{
+ DBusMessage *reply;
dbus_bool_t ret;
- reply->reply_message = dbus_message_new_method_return(message);
- ret = dbus_message_append_args(reply->reply_message, DBUS_TYPE_INVALID);
+ reply = dbus_message_new_method_return(message);
+ ret = dbus_message_append_args(reply, DBUS_TYPE_INVALID);
if (!ret) {
return EIO;
}
+ *r = reply;
return EOK;
}
-static int be_identity(DBusMessage *message, struct sbus_message_ctx *reply)
+static int be_identity(DBusMessage *message, void *data, DBusMessage **r)
{
dbus_uint16_t version = DATA_PROVIDER_VERSION;
dbus_uint16_t clitype = DP_CLI_BACKEND;
struct sbus_message_handler_ctx *smh_ctx;
struct be_ctx *ctx;
+ DBusMessage *reply;
dbus_bool_t ret;
void *user_data;
- if (!reply) return EINVAL;
- smh_ctx = reply->mh_ctx;
+ if (!data) return EINVAL;
+ smh_ctx = talloc_get_type(data, struct sbus_message_handler_ctx);
if (!smh_ctx) return EINVAL;
user_data = sbus_conn_get_private_data(smh_ctx->conn_ctx);
if (!user_data) return EINVAL;
@@ -127,8 +132,8 @@ static int be_identity(DBusMessage *message, struct sbus_message_ctx *reply)
DEBUG(4,("Sending ID reply: (%d,%d,%s,%s)\n",
clitype, version, ctx->name, ctx->domain));
- reply->reply_message = dbus_message_new_method_return(message);
- ret = dbus_message_append_args(reply->reply_message,
+ reply = dbus_message_new_method_return(message);
+ ret = dbus_message_append_args(reply,
DBUS_TYPE_UINT16, &clitype,
DBUS_TYPE_UINT16, &version,
DBUS_TYPE_STRING, &ctx->name,
@@ -138,6 +143,7 @@ static int be_identity(DBusMessage *message, struct sbus_message_ctx *reply)
return EIO;
}
+ *r = reply;
return EOK;
}
@@ -231,12 +237,13 @@ static void online_chk_callback(struct be_req *req, int status,
}
-static int be_check_online(DBusMessage *message, struct sbus_message_ctx *reply)
+static int be_check_online(DBusMessage *message, void *data, DBusMessage **r)
{
struct sbus_message_handler_ctx *smh_ctx;
struct be_online_req *req;
struct be_req *be_req;
struct be_ctx *ctx;
+ DBusMessage *reply;
dbus_bool_t dbret;
void *user_data;
int ret;
@@ -245,15 +252,15 @@ static int be_check_online(DBusMessage *message, struct sbus_message_ctx *reply)
dbus_uint32_t err_min;
const char *err_msg;
- if (!reply) return EINVAL;
- smh_ctx = reply->mh_ctx;
+ if (!data) return EINVAL;
+ smh_ctx = talloc_get_type(data, struct sbus_message_handler_ctx);
if (!smh_ctx) return EINVAL;
user_data = sbus_conn_get_private_data(smh_ctx->conn_ctx);
if (!user_data) return EINVAL;
ctx = talloc_get_type(user_data, struct be_ctx);
if (!ctx) return EINVAL;
- reply->reply_message = dbus_message_new_method_return(message);
+ reply = dbus_message_new_method_return(message);
/* process request */
be_req = talloc(ctx, struct be_req);
@@ -266,7 +273,7 @@ static int be_check_online(DBusMessage *message, struct sbus_message_ctx *reply)
}
be_req->be_ctx = ctx;
be_req->fn = online_chk_callback;
- be_req->pvt = reply->reply_message;
+ be_req->pvt = reply;
req = talloc(be_req, struct be_online_req);
if (!req) {
@@ -296,7 +303,7 @@ done:
talloc_free(be_req);
}
- dbret = dbus_message_append_args(reply->reply_message,
+ dbret = dbus_message_append_args(reply,
DBUS_TYPE_UINT16, &online,
DBUS_TYPE_UINT16, &err_maj,
DBUS_TYPE_UINT32, &err_min,
@@ -304,6 +311,7 @@ done:
DBUS_TYPE_INVALID);
if (!dbret) return EIO;
+ *r = reply;
return EOK;
}
@@ -347,12 +355,13 @@ static void acctinfo_callback(struct be_req *req, int status,
talloc_free(req);
}
-static int be_get_account_info(DBusMessage *message, struct sbus_message_ctx *reply)
+static int be_get_account_info(DBusMessage *message, void *data, DBusMessage **r)
{
struct sbus_message_handler_ctx *smh_ctx;
struct be_acct_req *req;
struct be_req *be_req;
struct be_ctx *ctx;
+ DBusMessage *reply;
DBusError dbus_error;
dbus_bool_t dbret;
void *user_data;
@@ -366,9 +375,10 @@ static int be_get_account_info(DBusMessage *message, struct sbus_message_ctx *re
const char *err_msg;
be_req = NULL;
+ *r = NULL;
- if (!reply) return EINVAL;
- smh_ctx = reply->mh_ctx;
+ if (!data) return EINVAL;
+ smh_ctx = talloc_get_type(data, struct sbus_message_handler_ctx);
if (!smh_ctx) return EINVAL;
user_data = sbus_conn_get_private_data(smh_ctx->conn_ctx);
if (!user_data) return EINVAL;
@@ -389,7 +399,7 @@ static int be_get_account_info(DBusMessage *message, struct sbus_message_ctx *re
DEBUG(4, ("Got request for [%u][%s][%s]\n", type, attrs, filter));
- reply->reply_message = dbus_message_new_method_return(message);
+ reply = dbus_message_new_method_return(message);
if (attrs) {
if (strcmp(attrs, "core") == 0) attr_type = BE_ATTR_CORE;
@@ -438,7 +448,7 @@ static int be_get_account_info(DBusMessage *message, struct sbus_message_ctx *re
}
be_req->be_ctx = ctx;
be_req->fn = acctinfo_callback;
- be_req->pvt = reply->reply_message;
+ be_req->pvt = reply;
req = talloc(be_req, struct be_acct_req);
if (!req) {
@@ -469,7 +479,7 @@ done:
talloc_free(be_req);
}
- dbret = dbus_message_append_args(reply->reply_message,
+ dbret = dbus_message_append_args(reply,
DBUS_TYPE_UINT16, &err_maj,
DBUS_TYPE_UINT32, &err_min,
DBUS_TYPE_STRING, &err_msg,
@@ -479,6 +489,7 @@ done:
DEBUG(4, ("Request processed. Returned %d,%d,%s\n",
err_maj, err_min, err_msg));
+ *r = reply;
return EOK;
}