mirror of
https://github.com/samba-team/samba.git
synced 2025-02-03 13:47:25 +03:00
libcli/nbt: move nbt_name_register_wins_send() to the top of all nbt_name_register_wins_* related code
metze
This commit is contained in:
parent
12c38806af
commit
549b594c57
@ -290,6 +290,66 @@ struct register_wins_state {
|
||||
struct nbt_name_request *req;
|
||||
};
|
||||
|
||||
static void name_register_wins_handler(struct nbt_name_request *req);
|
||||
|
||||
/*
|
||||
the async send call for a multi-server WINS register
|
||||
*/
|
||||
_PUBLIC_ struct composite_context *nbt_name_register_wins_send(struct nbt_name_socket *nbtsock,
|
||||
struct nbt_name_register_wins *io)
|
||||
{
|
||||
struct composite_context *c;
|
||||
struct register_wins_state *state;
|
||||
|
||||
c = talloc_zero(nbtsock, struct composite_context);
|
||||
if (c == NULL) goto failed;
|
||||
|
||||
state = talloc(c, struct register_wins_state);
|
||||
if (state == NULL) goto failed;
|
||||
|
||||
state->io = talloc(state, struct nbt_name_register);
|
||||
if (state->io == NULL) goto failed;
|
||||
|
||||
state->wins_port = io->in.wins_port;
|
||||
state->wins_servers = (const char **)str_list_copy(state, io->in.wins_servers);
|
||||
if (state->wins_servers == NULL ||
|
||||
state->wins_servers[0] == NULL) goto failed;
|
||||
|
||||
state->addresses = (const char **)str_list_copy(state, io->in.addresses);
|
||||
if (state->addresses == NULL ||
|
||||
state->addresses[0] == NULL) goto failed;
|
||||
|
||||
state->io->in.name = io->in.name;
|
||||
state->io->in.dest_addr = state->wins_servers[0];
|
||||
state->io->in.dest_port = state->wins_port;
|
||||
state->io->in.address = io->in.addresses[0];
|
||||
state->io->in.nb_flags = io->in.nb_flags;
|
||||
state->io->in.broadcast = false;
|
||||
state->io->in.register_demand = false;
|
||||
state->io->in.multi_homed = (io->in.nb_flags & NBT_NM_GROUP)?false:true;
|
||||
state->io->in.ttl = io->in.ttl;
|
||||
state->io->in.timeout = 3;
|
||||
state->io->in.retries = 2;
|
||||
|
||||
state->nbtsock = nbtsock;
|
||||
state->address_idx = 0;
|
||||
|
||||
state->req = nbt_name_register_send(nbtsock, state->io);
|
||||
if (state->req == NULL) goto failed;
|
||||
|
||||
state->req->async.fn = name_register_wins_handler;
|
||||
state->req->async.private_data = c;
|
||||
|
||||
c->private_data = state;
|
||||
c->state = COMPOSITE_STATE_IN_PROGRESS;
|
||||
c->event_ctx = nbtsock->event_ctx;
|
||||
|
||||
return c;
|
||||
|
||||
failed:
|
||||
talloc_free(c);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
state handler for WINS multi-homed multi-server name register
|
||||
@ -352,65 +412,6 @@ done:
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
the async send call for a multi-server WINS register
|
||||
*/
|
||||
_PUBLIC_ struct composite_context *nbt_name_register_wins_send(struct nbt_name_socket *nbtsock,
|
||||
struct nbt_name_register_wins *io)
|
||||
{
|
||||
struct composite_context *c;
|
||||
struct register_wins_state *state;
|
||||
|
||||
c = talloc_zero(nbtsock, struct composite_context);
|
||||
if (c == NULL) goto failed;
|
||||
|
||||
state = talloc(c, struct register_wins_state);
|
||||
if (state == NULL) goto failed;
|
||||
|
||||
state->io = talloc(state, struct nbt_name_register);
|
||||
if (state->io == NULL) goto failed;
|
||||
|
||||
state->wins_port = io->in.wins_port;
|
||||
state->wins_servers = (const char **)str_list_copy(state, io->in.wins_servers);
|
||||
if (state->wins_servers == NULL ||
|
||||
state->wins_servers[0] == NULL) goto failed;
|
||||
|
||||
state->addresses = (const char **)str_list_copy(state, io->in.addresses);
|
||||
if (state->addresses == NULL ||
|
||||
state->addresses[0] == NULL) goto failed;
|
||||
|
||||
state->io->in.name = io->in.name;
|
||||
state->io->in.dest_addr = state->wins_servers[0];
|
||||
state->io->in.dest_port = state->wins_port;
|
||||
state->io->in.address = io->in.addresses[0];
|
||||
state->io->in.nb_flags = io->in.nb_flags;
|
||||
state->io->in.broadcast = false;
|
||||
state->io->in.register_demand = false;
|
||||
state->io->in.multi_homed = (io->in.nb_flags & NBT_NM_GROUP)?false:true;
|
||||
state->io->in.ttl = io->in.ttl;
|
||||
state->io->in.timeout = 3;
|
||||
state->io->in.retries = 2;
|
||||
|
||||
state->nbtsock = nbtsock;
|
||||
state->address_idx = 0;
|
||||
|
||||
state->req = nbt_name_register_send(nbtsock, state->io);
|
||||
if (state->req == NULL) goto failed;
|
||||
|
||||
state->req->async.fn = name_register_wins_handler;
|
||||
state->req->async.private_data = c;
|
||||
|
||||
c->private_data = state;
|
||||
c->state = COMPOSITE_STATE_IN_PROGRESS;
|
||||
c->event_ctx = nbtsock->event_ctx;
|
||||
|
||||
return c;
|
||||
|
||||
failed:
|
||||
talloc_free(c);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
multi-homed WINS name register - recv side
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user