diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2012-01-20 13:53:16 +0100 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2012-01-27 09:02:01 -0500 |
commit | 990b7ebaf67b6d4cc982c805a8ec1126111bd4b4 (patch) | |
tree | aa0f7e8018a5d5170c7486e8b0105b212b894bb2 /src/responder/common/responder.h | |
parent | aec5785126354bd8b192f63fe04ea08dae9c0705 (diff) | |
download | sssd-990b7ebaf67b6d4cc982c805a8ec1126111bd4b4.tar.gz sssd-990b7ebaf67b6d4cc982c805a8ec1126111bd4b4.tar.bz2 sssd-990b7ebaf67b6d4cc982c805a8ec1126111bd4b4.zip |
DP: Refactor responder_dp_req so it's reusable by other responders
* the internal request is now more generic and is decoupled from
account-specific data. There is a new sss_dp_issue_request() wrapper
that issues a BE request or registers a callback
* the public requests all use struct sss_dp_req_state as the tevent_req
state data. This allows to report back data from the internal request
even if the caller is just a callback notifier
* each specific request now uses an _info structure that contains all
the data necessary to construct a DBusMessage passed to provider
* each specific request now defines a sss_dp_get_$data_msg callback that
is called from the sss_dp_issue_request() common wraper. The purpose
of the wrapper is to construct a DBusMessage and bind it to a DBus
method so the message can be just sent over to back end
The miscellanous changes include:
* change SSS_DP_ constants to an enum. This way, a switch() would error
if a value is not handled.
* rename sss_dp_get_account_int_send() to sss_dp_internal_get_send()
request because the internal request is going to handle more than just
account data
* the DBus return values were renamed from err_maj, err_min to dp_err
and dp_ret respectively
Diffstat (limited to 'src/responder/common/responder.h')
-rw-r--r-- | src/responder/common/responder.h | 56 |
1 files changed, 49 insertions, 7 deletions
diff --git a/src/responder/common/responder.h b/src/responder/common/responder.h index 2944aa5c..235b1d97 100644 --- a/src/responder/common/responder.h +++ b/src/responder/common/responder.h @@ -157,12 +157,6 @@ void sss_cmd_done(struct cli_ctx *cctx, void *freectx); int sss_cmd_get_version(struct cli_ctx *cctx); struct cli_protocol_version *register_cli_protocol_version(void); -#define SSS_DP_USER 1 -#define SSS_DP_GROUP 2 -#define SSS_DP_INITGROUPS 3 -#define SSS_DP_NETGR 4 -#define SSS_DP_SERVICES 5 - typedef void (*sss_dp_callback_t)(uint16_t err_maj, uint32_t err_min, const char *err_msg, void *ptr); @@ -179,6 +173,45 @@ void handle_requests_after_reconnect(void); int responder_logrotate(DBusMessage *message, struct sbus_connection *conn); +/* Each responder-specific request must create a constructor + * function that creates a DBus Message that would be sent to + * the back end + */ +typedef DBusMessage * (dbus_msg_constructor)(void *); + +/* + * This function is indended for consumption by responders to create + * responder-specific requests such as sss_dp_get_account_send for + * downloading account data. + * + * Issues a new back end request based on strkey if not already running + * or registers a callback that is called when an existing request finishes. + */ +errno_t +sss_dp_issue_request(TALLOC_CTX *mem_ctx, struct resp_ctx *rctx, + const char *strkey, struct sss_domain_info *dom, + dbus_msg_constructor msg_create, void *pvt, + struct tevent_req *nreq); + +/* Every provider specific request uses this structure as the tevent_req + * "state" structure. + */ +struct sss_dp_req_state { + dbus_uint16_t dp_err; + dbus_uint32_t dp_ret; + char *err_msg; +}; + +/* The _recv functions of provider specific requests usually need to + * only call sss_dp_req_recv() to get return codes from back end + */ +errno_t +sss_dp_req_recv(TALLOC_CTX *mem_ctx, + struct tevent_req *sidereq, + dbus_uint16_t *dp_err, + dbus_uint32_t *dp_ret, + char **err_msg); + /* Send a request to the data provider * Once this function is called, the communication * with the data provider will always run to @@ -186,12 +219,21 @@ int responder_logrotate(DBusMessage *message, * cancel the notification of completion, but not * the data provider action. */ + +enum sss_dp_acct_type { + SSS_DP_USER = 1, + SSS_DP_GROUP, + SSS_DP_INITGROUPS, + SSS_DP_NETGR, + SSS_DP_SERVICES +}; + struct tevent_req * sss_dp_get_account_send(TALLOC_CTX *mem_ctx, struct resp_ctx *rctx, struct sss_domain_info *dom, bool fast_reply, - int type, + enum sss_dp_acct_type type, const char *opt_name, uint32_t opt_id, const char *extra); |