}
struct sequence_state {
- TALLOC_CTX *mem_ctx;
struct winbindd_cli_state *cli_state;
struct winbindd_domain *domain;
- struct winbindd_request *request;
- struct winbindd_response *response;
+ struct winbind_get_domain_info *r;
char *extra_data;
+ void (*recv_fn)(void *priv, bool succ,
+ struct winbind_get_domain_info *r);
};
-static void sequence_recv(void *private_data, bool success);
+static void sequence_one_recv(void *private_data, bool success,
+ struct winbind_get_domain_info *r);
+static void sequence_next_recv(void *private_data, bool success,
+ struct winbind_get_domain_info *r);
void winbindd_show_sequence(struct winbindd_cli_state *state)
{
/* Ensure null termination */
state->request.domain_name[sizeof(state->request.domain_name)-1]='\0';
+ seq = TALLOC_P(state->mem_ctx, struct sequence_state);
+ if (!seq) goto nomem;
+ seq->cli_state = state;
+ seq->extra_data = talloc_strdup(state->mem_ctx, "");
+ if (!seq->extra_data) goto nomem;
+ seq->r = TALLOC_P(seq, struct winbind_get_domain_info);
+ if (!seq->r) goto nomem;
+ seq->r->in.level = TALLOC_P(seq->r, enum winbind_domain_info_level);
+ if (!seq->r->in.level) goto nomem;
+
if (strlen(state->request.domain_name) > 0) {
- struct winbindd_domain *domain;
- domain = find_domain_from_name_noinit(
+ seq->domain = find_domain_from_name_noinit(
state->request.domain_name);
- if (domain == NULL) {
+ if (seq->domain == NULL) {
+ DEBUG(0,("domain '%s' not found\n",
+ state->request.domain_name));
request_error(state);
return;
}
- sendto_domain(state, domain);
- return;
+ seq->recv_fn = sequence_one_recv;
+ } else {
+ seq->domain = domain_list();
+ if (seq->domain == NULL) {
+ DEBUG(0, ("domain list empty\n"));
+ request_error(state);
+ return;
+ }
+ seq->recv_fn = sequence_next_recv;
}
- /* Ask all domains in sequence, collect the results in sequence_recv */
+ *seq->r->in.level = WINBIND_DOMAIN_INFO_LEVEL_SEQNUM;
+ seq->r->in.domain_name = seq->domain->name;
+ seq->r->in.dc_name = NULL;
- seq = TALLOC_P(state->mem_ctx, struct sequence_state);
- if (seq == NULL) {
- DEBUG(0, ("talloc failed\n"));
- request_error(state);
- return;
- }
+ winbindd_get_domain_info_async(seq, seq->domain, seq->r,
+ seq->recv_fn, seq);
+ return;
+nomem:
+ request_error(state);
+ return;
+}
- seq->mem_ctx = state->mem_ctx;
- seq->cli_state = state;
- seq->domain = domain_list();
- if (seq->domain == NULL) {
- DEBUG(0, ("domain list empty\n"));
- request_error(state);
- return;
- }
- seq->request = TALLOC_ZERO_P(state->mem_ctx,
- struct winbindd_request);
- seq->response = TALLOC_ZERO_P(state->mem_ctx,
- struct winbindd_response);
- seq->extra_data = talloc_strdup(state->mem_ctx, "");
+static void sequence_one_recv(void *private_data, bool success,
+ struct winbind_get_domain_info *r)
+{
+ struct sequence_state *state = talloc_get_type_abort(private_data,
+ struct sequence_state);
- if ((seq->request == NULL) || (seq->response == NULL) ||
- (seq->extra_data == NULL)) {
- DEBUG(0, ("talloc failed\n"));
- request_error(state);
+ if (!success) {
+ request_error(state->cli_state);
return;
}
- seq->request->length = sizeof(*seq->request);
- seq->request->cmd = WINBINDD_SHOW_SEQUENCE;
- fstrcpy(seq->request->domain_name, seq->domain->name);
+ state->cli_state->response.data.sequence_number =
+ state->r->out.domain_info->seqnum;
- async_domain_request(state->mem_ctx, seq->domain,
- seq->request, seq->response,
- sequence_recv, seq);
+ request_ok(state->cli_state);
}
-static void sequence_recv(void *private_data, bool success)
+static void sequence_next_recv(void *private_data, bool success,
+ struct winbind_get_domain_info *r)
{
- struct sequence_state *state =
- (struct sequence_state *)private_data;
- uint32 seq = DOM_SEQUENCE_NONE;
+ struct sequence_state *state = talloc_get_type_abort(private_data,
+ struct sequence_state);
+ uint64_t seq = DOM_SEQUENCE_NONE;
- if ((success) && (state->response->result == WINBINDD_OK))
- seq = state->response->data.sequence_number;
+ if (success) {
+ seq = state->r->out.domain_info->seqnum;
+ }
if (seq == DOM_SEQUENCE_NONE) {
- state->extra_data = talloc_asprintf(state->mem_ctx,
+ state->extra_data = talloc_asprintf(state,
"%s%s : DISCONNECTED\n",
state->extra_data,
state->domain->name);
} else {
- state->extra_data = talloc_asprintf(state->mem_ctx,
- "%s%s : %d\n",
+ state->extra_data = talloc_asprintf(state,
+ "%s%s : %lld\n",
state->extra_data,
- state->domain->name, seq);
+ state->domain->name,
+ (unsigned long long)seq);
}
state->domain->sequence_number = seq;
}
/* Ask the next domain */
- fstrcpy(state->request->domain_name, state->domain->name);
- async_domain_request(state->mem_ctx, state->domain,
- state->request, state->response,
- sequence_recv, state);
+ *state->r->in.level = WINBIND_DOMAIN_INFO_LEVEL_SEQNUM;
+ state->r->in.domain_name= state->domain->name;
+ state->r->in.dc_name = NULL;
+
+ winbindd_get_domain_info_async(state, state->domain, state->r,
+ state->recv_fn, state);
}
/* This is the child-only version of --sequence. It only allows for a single