summaryrefslogtreecommitdiff
path: root/nsswitch/libwbclient/wbc_util.c
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2009-02-13 22:51:52 +0100
committerKai Blin <kai@samba.org>2010-02-11 23:56:33 +0100
commit99c0f569f9a62b63e1d26418a777302b03c3fc7f (patch)
treee3b7f754c6ed486635299a071eefb032e3b4673b /nsswitch/libwbclient/wbc_util.c
parent7cb070f2b346ed486ee24926965290890f72786f (diff)
downloadsamba-99c0f569f9a62b63e1d26418a777302b03c3fc7f.tar.gz
samba-99c0f569f9a62b63e1d26418a777302b03c3fc7f.tar.bz2
samba-99c0f569f9a62b63e1d26418a777302b03c3fc7f.zip
libwbclient: Add wbcDomainName_send/recv call
Diffstat (limited to 'nsswitch/libwbclient/wbc_util.c')
-rw-r--r--nsswitch/libwbclient/wbc_util.c94
1 files changed, 94 insertions, 0 deletions
diff --git a/nsswitch/libwbclient/wbc_util.c b/nsswitch/libwbclient/wbc_util.c
index fca0b061af..fcec32af8a 100644
--- a/nsswitch/libwbclient/wbc_util.c
+++ b/nsswitch/libwbclient/wbc_util.c
@@ -409,6 +409,100 @@ wbcErr wbcNetbiosName_recv(struct tevent_req *req,
return WBC_ERR_SUCCESS;
}
+struct wbc_domain_name_state {
+ struct winbindd_request req;
+ char *domain_name;
+};
+
+static void wbcDomainName_done(struct tevent_req *subreq);
+
+/**
+ * @brief Request the machine's domain name
+ *
+ * @param mem_ctx talloc context to allocate memory from
+ * @param ev tevent context to use for async requests
+ * @param wb_ctx winbind context
+ *
+ * @return tevent_req on success, NULL on failure
+ */
+
+struct tevent_req *wbcDomainName_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct wb_context *wb_ctx)
+{
+ struct tevent_req *req, *subreq;
+ struct wbc_domain_name_state *state;
+
+ req = tevent_req_create(mem_ctx, &state, struct wbc_domain_name_state);
+ if (req == NULL) {
+ return NULL;
+ }
+
+ ZERO_STRUCT(state->req);
+ state->req.cmd = WINBINDD_DOMAIN_NAME;
+
+ 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, wbcDomainName_done, req);
+ return req;
+}
+
+static void wbcDomainName_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct wbc_domain_name_state *state = tevent_req_data(
+ req, struct wbc_domain_name_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->domain_name = talloc_strdup(state, resp->data.domain_name);
+ if (tevent_req_nomem(state->domain_name, subreq)) {
+ return;
+ }
+ TALLOC_FREE(resp);
+
+ tevent_req_done(req);
+}
+
+/**
+ * @brief Receive the machine's domain name
+ *
+ * @param req tevent_req containing the request
+ * @param mem_ctx talloc context to allocate memory from
+ * @param domain_name pointer to a string to hold the domain name
+ *
+ * @return #wbcErr
+ */
+
+wbcErr wbcDomainName_recv(struct tevent_req *req,
+ TALLOC_CTX *mem_ctx,
+ char **domain_name)
+{
+ struct wbc_domain_name_state *state = tevent_req_data(
+ req, struct wbc_domain_name_state);
+ wbcErr wbc_status;
+
+ if (tevent_req_is_wbcerr(req, &wbc_status)) {
+ tevent_req_received(req);
+ return wbc_status;
+ }
+
+ *domain_name = talloc_steal(mem_ctx, state->domain_name);
+
+ tevent_req_received(req);
+ return WBC_ERR_SUCCESS;
+}
+
wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details)
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;