summaryrefslogtreecommitdiffstats
path: root/nsswitch/libwbclient/wbc_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'nsswitch/libwbclient/wbc_util.c')
-rw-r--r--nsswitch/libwbclient/wbc_util.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/nsswitch/libwbclient/wbc_util.c b/nsswitch/libwbclient/wbc_util.c
index ddef8b644d..f72f4fc749 100644
--- a/nsswitch/libwbclient/wbc_util.c
+++ b/nsswitch/libwbclient/wbc_util.c
@@ -123,6 +123,98 @@ wbcErr wbcPing(void)
return wbcRequestResponse(WINBINDD_PING, &request, &response);
}
+struct wbc_interface_version_state {
+ struct winbindd_request req;
+ uint32_t version;
+};
+
+static void wbcInterfaceVersion_done(struct tevent_req *subreq);
+
+/**
+ * @brief Request the interface version from winbind
+ *
+ * @param mem_ctx talloc context to allocate memory from
+ * @param ev tevent context to use for async requests
+ * @param wb_ctx winbind context
+ *
+ * @return tevevt_req on success, NULL on failure
+ */
+
+struct tevent_req *wbcInterfaceVersion_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct wb_context *wb_ctx)
+{
+ struct tevent_req *req, *subreq;
+ struct wbc_interface_version_state *state;
+
+ req = tevent_req_create(mem_ctx, &state, struct wbc_interface_version_state);
+ if (req == NULL) {
+ return NULL;
+ }
+
+ ZERO_STRUCT(state->req);
+ state->req.cmd = WINBINDD_INTERFACE_VERSION;
+
+ subreq = wb_trans_send(state, ev, wb_ctx, false, &state->req);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+
+ tevent_req_set_callback(subreq, wbcInterfaceVersion_done, req);
+
+ return req;
+}
+
+static void wbcInterfaceVersion_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct wbc_interface_version_state *state = tevent_req_data(
+ req, struct wbc_interface_version_state);
+ struct winbindd_response *resp;
+ wbcErr wbc_status;
+
+ wbc_status = wb_trans_recv(subreq, state, &resp);
+ TALLOC_FREE(subreq);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ tevent_req_error(req, wbc_status);
+ return;
+ }
+ state->version = resp->data.interface_version;
+ TALLOC_FREE(resp);
+
+ tevent_req_done(req);
+}
+
+/**
+ * @brief Receive the winbind interface version
+ *
+ * @param req tevent_req containing the request
+ * @param interface_version pointer to uint32_t to hold the interface
+ * version
+ *
+ * @return #wbcErr
+ */
+
+wbcErr wbcInterfaceVersion_recv(struct tevent_req *req,
+ uint32_t *interface_version)
+{
+ struct wbc_interface_version_state *state = tevent_req_data(
+ req, struct wbc_interface_version_state);
+ wbcErr wbc_status;
+
+ if (tevent_req_is_wbcerr(req, &wbc_status)) {
+ tevent_req_received(req);
+ return wbc_status;
+ }
+
+ *interface_version = state->version;
+
+ tevent_req_received(req);
+ return WBC_ERR_SUCCESS;
+}
+
+
wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details)
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;