mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
libwbclient: Add wbcNetbiosName_send/recv calls
This commit is contained in:
parent
fd6b145793
commit
7cb070f2b3
@ -113,4 +113,11 @@ wbcErr wbcInfo_recv(struct tevent_req *req,
|
||||
char *winbind_separator,
|
||||
char **version_string);
|
||||
|
||||
struct tevent_req *wbcNetbiosName_send(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev,
|
||||
struct wb_context *wb_ctx);
|
||||
wbcErr wbcNetbiosName_recv(struct tevent_req *req,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
char **netbios_name);
|
||||
|
||||
#endif /*_WBC_ASYNC_H_*/
|
||||
|
@ -314,6 +314,101 @@ wbcErr wbcInfo_recv(struct tevent_req *req,
|
||||
return WBC_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
struct wbc_netbios_name_state {
|
||||
struct winbindd_request req;
|
||||
char *netbios_name;
|
||||
};
|
||||
|
||||
static void wbcNetbiosName_done(struct tevent_req *subreq);
|
||||
|
||||
/**
|
||||
* @brief Request the machine's netbios 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 *wbcNetbiosName_send(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev,
|
||||
struct wb_context *wb_ctx)
|
||||
{
|
||||
struct tevent_req *req, *subreq;
|
||||
struct wbc_netbios_name_state *state;
|
||||
|
||||
req = tevent_req_create(mem_ctx, &state, struct wbc_netbios_name_state);
|
||||
if (req == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(state->req);
|
||||
state->req.cmd = WINBINDD_NETBIOS_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, wbcNetbiosName_done, req);
|
||||
return req;
|
||||
}
|
||||
|
||||
static void wbcNetbiosName_done(struct tevent_req *subreq)
|
||||
{
|
||||
struct tevent_req *req = tevent_req_callback_data(
|
||||
subreq, struct tevent_req);
|
||||
struct wbc_netbios_name_state *state = tevent_req_data(
|
||||
req, struct wbc_netbios_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->netbios_name = talloc_strdup(state,
|
||||
resp->data.info.samba_version);
|
||||
if (tevent_req_nomem(state->netbios_name, subreq)) {
|
||||
return;
|
||||
}
|
||||
TALLOC_FREE(resp);
|
||||
|
||||
tevent_req_done(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Receive the machine's netbios name
|
||||
*
|
||||
* @param req tevent_req containing the request
|
||||
* @param mem_ctx talloc context to allocate memory from
|
||||
* @param netbios_name pointer to a string to hold the netbios name
|
||||
*
|
||||
* @return #wbcErr
|
||||
*/
|
||||
|
||||
wbcErr wbcNetbiosName_recv(struct tevent_req *req,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
char **netbios_name)
|
||||
{
|
||||
struct wbc_netbios_name_state *state = tevent_req_data(
|
||||
req, struct wbc_netbios_name_state);
|
||||
wbcErr wbc_status;
|
||||
|
||||
if (tevent_req_is_wbcerr(req, &wbc_status)) {
|
||||
tevent_req_received(req);
|
||||
return wbc_status;
|
||||
}
|
||||
|
||||
*netbios_name = talloc_steal(mem_ctx, state->netbios_name);
|
||||
|
||||
tevent_req_received(req);
|
||||
return WBC_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
wbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details)
|
||||
{
|
||||
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
|
||||
|
Loading…
Reference in New Issue
Block a user