}
struct cli_connect_sock_state {
- struct sockaddr_storage *addrs;
- size_t num_addrs;
const char **called_names;
const char **calling_names;
int *called_types;
- size_t chosen_index;
int fd;
uint16_t port;
};
struct tevent_req *req, *subreq;
struct cli_connect_sock_state *state;
struct sockaddr_storage *addrs;
- size_t i;
+ unsigned i, num_addrs;
NTSTATUS status;
req = tevent_req_create(mem_ctx, &state,
*/
status = resolve_name_list(state, host, name_type,
- &state->addrs, &state->num_addrs);
+ &addrs, &num_addrs);
if (!NT_STATUS_IS_OK(status)) {
tevent_req_nterror(req, status);
return tevent_req_post(req, ev);
}
} else {
- state->addrs = talloc_array(state, struct sockaddr_storage, 1);
- if (tevent_req_nomem(state->addrs, req)) {
+ addrs = talloc_array(state, struct sockaddr_storage, 1);
+ if (tevent_req_nomem(addrs, req)) {
return tevent_req_post(req, ev);
}
- state->addrs[0] = *pss;
- state->num_addrs = 1;
+ addrs[0] = *pss;
+ num_addrs = 1;
}
state->called_names = talloc_array(state, const char *, num_addrs);
if (tevent_req_nomem(state->calling_names, req)) {
return tevent_req_post(req, ev);
}
- for (i=0; i<state->num_addrs; i++) {
+ for (i=0; i<num_addrs; i++) {
state->called_names[i] = host;
state->called_types[i] = name_type;
state->calling_names[i] = myname;
}
subreq = smbsock_any_connect_send(
- state, ev, state->addrs,
- state->called_names, state->called_types, state->calling_names,
- NULL, state->num_addrs, port);
+ state, ev, addrs, state->called_names, state->called_types,
+ state->calling_names, NULL, num_addrs, port);
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
}
req, struct cli_connect_sock_state);
NTSTATUS status;
- status = smbsock_any_connect_recv(subreq, &state->fd,
- &state->chosen_index,
+ status = smbsock_any_connect_recv(subreq, &state->fd, NULL,
&state->port);
TALLOC_FREE(subreq);
if (tevent_req_nterror(req, status)) {
}
static NTSTATUS cli_connect_sock_recv(struct tevent_req *req,
- int *pfd,
- struct sockaddr_storage *pss,
- uint16_t *pport)
+ int *pfd, uint16_t *pport)
{
struct cli_connect_sock_state *state = tevent_req_data(
req, struct cli_connect_sock_state);
return status;
}
*pfd = state->fd;
- *pss = state->addrs[state->chosen_index];
*pport = state->port;
return NT_STATUS_OK;
}