[SCM] Samba Shared Repository - branch master updated
Stefan Metzmacher
metze at samba.org
Mon Oct 18 10:19:01 MDT 2010
The branch, master has been updated
via a610ce4 libcli/nbt: we don't need LIBCLI_COMPOSITE anymore
via 820ae3d libcli/nbt: convert nbt_name_register_bcast_send/recv to tevent_req
via 0b8056d libcli/nbt: s/name_register_bcast_handler/nbt_name_register_bcast_handler
via c654a6c libcli/nbt: s/register_bcast_state/nbt_name_register_bcast_state/
via 77d82fe libcli/nbt: move nbt_name_register_bcast_send to the top of nbt_name_register_bcast_*
via 6f2d94b s4:nbt_server/register: add a nbtd_register_name_state
via e3a0463 libcli/nbt: convert nbt_name_register_wins_send/recv to tevent_req
via 4f233c7 libcli/nbt: s/name_register_wins_handler/nbt_name_register_wins_handler
via b166813 libcli/nbt: s/register_wins_state/nbt_name_register_wins_state
via 549b594 libcli/nbt: move nbt_name_register_wins_send() to the top of all nbt_name_register_wins_* related code
via 12c3880 s4:nbt_server/winsclient: add a nbtd_wins_register_state
via 43fb7f1 libcli/nbt: convert nbt_name_refresh_wins_send/recv to tevent_req
via 332f261 libcli/nbt: s/name_refresh_wins_handler/nbt_name_refresh_wins_handler
via 3ded1da libcli/nbt: s/refresh_wins_state/nbt_name_refresh_wins_state
via e36e729 libcli/nbt: move nbt_name_refresh_wins_send() to the top of all nbt_name_refresh_wins_* related code
via 5f19a24 s4:nbt_server/winsclient: add a nbtd_wins_refresh_state
via 2ae3bb0 s4:nbt_server/wins: fix compiler warnings
from a10b341 Include misc.idl for policy_handle in srvsvc.idl.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit a610ce4aa63b5bbe0886e510f7ccd9a6f95e266d
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 11 22:29:30 2010 +0200
libcli/nbt: we don't need LIBCLI_COMPOSITE anymore
metze
Autobuild-User: Stefan Metzmacher <metze at samba.org>
Autobuild-Date: Mon Oct 18 16:18:32 UTC 2010 on sn-devel-104
commit 820ae3d9a36e031027be163d22eec468a6da8603
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 11 21:18:15 2010 +0200
libcli/nbt: convert nbt_name_register_bcast_send/recv to tevent_req
metze
commit 0b8056d580e2d2475b208c73ffb698b0bcd487eb
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 11 21:01:23 2010 +0200
libcli/nbt: s/name_register_bcast_handler/nbt_name_register_bcast_handler
metze
commit c654a6c02bbd7c7a245b2a06e405d88724c12fc7
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 11 20:59:35 2010 +0200
libcli/nbt: s/register_bcast_state/nbt_name_register_bcast_state/
metze
commit 77d82fe944fa1f02c150cc2e0967cca654cd4dae
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 11 20:57:58 2010 +0200
libcli/nbt: move nbt_name_register_bcast_send to the top of nbt_name_register_bcast_*
metze
commit 6f2d94b960bb6d23ff8932eff2b44722cf335280
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 11 22:17:02 2010 +0200
s4:nbt_server/register: add a nbtd_register_name_state
metze
commit e3a0463414ba7759d332d5bebf6222bfa17ed037
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 11 21:58:29 2010 +0200
libcli/nbt: convert nbt_name_register_wins_send/recv to tevent_req
metze
commit 4f233c7ff8b23b0dd4797e08d7dc680598e1b844
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 11 21:23:58 2010 +0200
libcli/nbt: s/name_register_wins_handler/nbt_name_register_wins_handler
metze
commit b16681374c6c4d010a74bb2cb914ac226643c634
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 11 21:21:26 2010 +0200
libcli/nbt: s/register_wins_state/nbt_name_register_wins_state
metze
commit 549b594c5798954de056cf7e3858e94f1b965bdb
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 11 21:19:59 2010 +0200
libcli/nbt: move nbt_name_register_wins_send() to the top of all nbt_name_register_wins_* related code
metze
commit 12c38806af46da329e2f370d32a4fa964ceeb23f
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 11 20:49:28 2010 +0200
s4:nbt_server/winsclient: add a nbtd_wins_register_state
We now keep the nbtd_wins_register_state around between
nbt_name_register_wins_send() and nbt_name_register_wins_recv()
metze
commit 43fb7f1698c0c8aaa7f1e5d6a0f924396a9a12fe
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 11 08:54:27 2010 +0200
libcli/nbt: convert nbt_name_refresh_wins_send/recv to tevent_req
metze
commit 332f261bbf5a3179cbab6cb7aa8b490d0072b7af
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 11 08:33:06 2010 +0200
libcli/nbt: s/name_refresh_wins_handler/nbt_name_refresh_wins_handler
metze
commit 3ded1da8e99a628530d0a45256e012b7553c094c
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 11 08:18:16 2010 +0200
libcli/nbt: s/refresh_wins_state/nbt_name_refresh_wins_state
metze
commit e36e7295da42743519470f5b5c06e65071707db5
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 11 08:15:01 2010 +0200
libcli/nbt: move nbt_name_refresh_wins_send() to the top of all nbt_name_refresh_wins_* related code
metze
commit 5f19a24c500c17de9159f721c75077a162fa8bac
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 11 09:41:16 2010 +0200
s4:nbt_server/winsclient: add a nbtd_wins_refresh_state
We now keep the nbtd_wins_refresh_state around between
nbt_name_refresh_wins_send() and nbt_name_refresh_wins_recv()
metze
commit 2ae3bb0b160c8c1cc0f500bfdd39125292db5f59
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 11 22:26:09 2010 +0200
s4:nbt_server/wins: fix compiler warnings
metze
-----------------------------------------------------------------------
Summary of changes:
libcli/nbt/libnbt.h | 32 ++-
libcli/nbt/namerefresh.c | 254 +++++++++++--------
libcli/nbt/nameregister.c | 483 +++++++++++++++++++--------------
libcli/nbt/wscript_build | 2 +-
source4/nbt_server/register.c | 58 +++--
source4/nbt_server/wins/winsclient.c | 175 +++++++------
source4/nbt_server/wins/winsserver.h | 1 +
7 files changed, 586 insertions(+), 419 deletions(-)
Changeset truncated at 500 lines:
diff --git a/libcli/nbt/libnbt.h b/libcli/nbt/libnbt.h
index 6165548..21fd859 100644
--- a/libcli/nbt/libnbt.h
+++ b/libcli/nbt/libnbt.h
@@ -339,19 +339,27 @@ NDR_SCALAR_PROTO(nbt_string, const char *)
NDR_BUFFER_PROTO(nbt_name, struct nbt_name)
NTSTATUS nbt_rcode_to_ntstatus(uint8_t rcode);
-struct composite_context;
-struct composite_context *nbt_name_register_bcast_send(struct nbt_name_socket *nbtsock,
- struct nbt_name_register_bcast *io);
-NTSTATUS nbt_name_register_bcast_recv(struct composite_context *c);
-struct composite_context *nbt_name_register_wins_send(struct nbt_name_socket *nbtsock,
- struct nbt_name_register_wins *io);
-NTSTATUS nbt_name_refresh_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
- struct nbt_name_refresh_wins *io);
-struct composite_context *nbt_name_refresh_wins_send(struct nbt_name_socket *nbtsock,
- struct nbt_name_refresh_wins *io);
-NTSTATUS nbt_name_register_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
+struct tevent_context;
+struct tevent_req;
+struct tevent_req *nbt_name_register_bcast_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct nbt_name_socket *nbtsock,
+ struct nbt_name_register_bcast *io);
+NTSTATUS nbt_name_register_bcast_recv(struct tevent_req *req);
+struct tevent_req *nbt_name_register_wins_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct nbt_name_socket *nbtsock,
+ struct nbt_name_register_wins *io);
+NTSTATUS nbt_name_register_wins_recv(struct tevent_req *req,
+ TALLOC_CTX *mem_ctx,
struct nbt_name_register_wins *io);
-
+struct tevent_req *nbt_name_refresh_wins_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct nbt_name_socket *nbtsock,
+ struct nbt_name_refresh_wins *io);
+NTSTATUS nbt_name_refresh_wins_recv(struct tevent_req *req,
+ TALLOC_CTX *mem_ctx,
+ struct nbt_name_refresh_wins *io);
XFILE *startlmhosts(const char *fname);
bool getlmhostsent(TALLOC_CTX *ctx, XFILE *fp, char **pp_name, int *name_type,
diff --git a/libcli/nbt/namerefresh.c b/libcli/nbt/namerefresh.c
index ec63df9..79c6c1f 100644
--- a/libcli/nbt/namerefresh.c
+++ b/libcli/nbt/namerefresh.c
@@ -20,10 +20,11 @@
*/
#include "includes.h"
+#include <tevent.h>
#include "../libcli/nbt/libnbt.h"
#include "../libcli/nbt/nbt_proto.h"
-#include "libcli/composite/composite.h"
#include "lib/socket/socket.h"
+#include "lib/util/tevent_ntstatus.h"
/*
send a nbt name refresh request
@@ -142,104 +143,70 @@ _PUBLIC_ NTSTATUS nbt_name_refresh(struct nbt_name_socket *nbtsock,
addresses to refresh. Try each WINS server in turn, until we get a
reply for each address
*/
-struct refresh_wins_state {
+struct nbt_name_refresh_wins_state {
struct nbt_name_socket *nbtsock;
struct nbt_name_refresh *io;
- const char **wins_servers;
+ char **wins_servers;
uint16_t wins_port;
- const char **addresses;
+ char **addresses;
int address_idx;
- struct nbt_name_request *req;
};
+static void nbt_name_refresh_wins_handler(struct nbt_name_request *subreq);
/**
- state handler for WINS multi-homed multi-server name refresh
+ the async send call for a multi-server WINS refresh
*/
-static void name_refresh_wins_handler(struct nbt_name_request *req)
+_PUBLIC_ struct tevent_req *nbt_name_refresh_wins_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct nbt_name_socket *nbtsock,
+ struct nbt_name_refresh_wins *io)
{
- struct composite_context *c = talloc_get_type(req->async.private_data,
- struct composite_context);
- struct refresh_wins_state *state = talloc_get_type(c->private_data,
- struct refresh_wins_state);
- NTSTATUS status;
-
- status = nbt_name_refresh_recv(state->req, state, state->io);
- if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
- /* the refresh timed out - try the next WINS server */
- state->wins_servers++;
- state->address_idx = 0;
- if (state->wins_servers[0] == NULL) {
- c->state = COMPOSITE_STATE_ERROR;
- c->status = status;
- goto done;
- }
- state->io->in.dest_addr = state->wins_servers[0];
- state->io->in.dest_port = state->wins_port;
- state->io->in.address = state->addresses[0];
- state->req = nbt_name_refresh_send(state->nbtsock, state->io);
- if (state->req == NULL) {
- c->state = COMPOSITE_STATE_ERROR;
- c->status = NT_STATUS_NO_MEMORY;
- } else {
- state->req->async.fn = name_refresh_wins_handler;
- state->req->async.private_data = c;
- }
- } else if (!NT_STATUS_IS_OK(status)) {
- c->state = COMPOSITE_STATE_ERROR;
- c->status = status;
- } else {
- if (state->io->out.rcode == 0 &&
- state->addresses[state->address_idx+1] != NULL) {
- /* refresh our next address */
- state->io->in.address = state->addresses[++(state->address_idx)];
- state->req = nbt_name_refresh_send(state->nbtsock, state->io);
- if (state->req == NULL) {
- c->state = COMPOSITE_STATE_ERROR;
- c->status = NT_STATUS_NO_MEMORY;
- } else {
- state->req->async.fn = name_refresh_wins_handler;
- state->req->async.private_data = c;
- }
- } else {
- c->state = COMPOSITE_STATE_DONE;
- c->status = NT_STATUS_OK;
- }
+ struct tevent_req *req;
+ struct nbt_name_refresh_wins_state *state;
+ struct nbt_name_request *subreq;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct nbt_name_refresh_wins_state);
+ if (req == NULL) {
+ return NULL;
}
-done:
- if (c->state >= COMPOSITE_STATE_DONE &&
- c->async.fn) {
- c->async.fn(c);
+ state->io = talloc(state, struct nbt_name_refresh);
+ if (tevent_req_nomem(state->io, req)) {
+ return tevent_req_post(req, ev);
}
-}
-/**
- the async send call for a multi-server WINS refresh
-*/
-_PUBLIC_ struct composite_context *nbt_name_refresh_wins_send(struct nbt_name_socket *nbtsock,
- struct nbt_name_refresh_wins *io)
-{
- struct composite_context *c;
- struct refresh_wins_state *state;
+ if (io->in.wins_servers == NULL) {
+ tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+ return tevent_req_post(req, ev);
+ }
- c = talloc_zero(nbtsock, struct composite_context);
- if (c == NULL) goto failed;
+ if (io->in.wins_servers[0] == NULL) {
+ tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+ return tevent_req_post(req, ev);
+ }
- state = talloc(c, struct refresh_wins_state);
- if (state == NULL) goto failed;
+ if (io->in.addresses == NULL) {
+ tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+ return tevent_req_post(req, ev);
+ }
- state->io = talloc(state, struct nbt_name_refresh);
- if (state->io == NULL) goto failed;
+ if (io->in.addresses[0] == NULL) {
+ tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+ return tevent_req_post(req, ev);
+ }
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->wins_servers = str_list_copy(state, io->in.wins_servers);
+ if (tevent_req_nomem(state->wins_servers, req)) {
+ return tevent_req_post(req, ev);
+ }
- state->addresses = (const char **)str_list_copy(state, io->in.addresses);
- if (state->addresses == NULL ||
- state->addresses[0] == NULL) goto failed;
+ state->addresses = str_list_copy(state, io->in.addresses);
+ if (tevent_req_nomem(state->addresses, req)) {
+ return tevent_req_post(req, ev);
+ }
state->io->in.name = io->in.name;
state->io->in.dest_addr = state->wins_servers[0];
@@ -254,48 +221,127 @@ _PUBLIC_ struct composite_context *nbt_name_refresh_wins_send(struct nbt_name_so
state->nbtsock = nbtsock;
state->address_idx = 0;
- state->req = nbt_name_refresh_send(nbtsock, state->io);
- if (state->req == NULL) goto failed;
+ subreq = nbt_name_refresh_send(nbtsock, state->io);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
- state->req->async.fn = name_refresh_wins_handler;
- state->req->async.private_data = c;
+ subreq->async.fn = nbt_name_refresh_wins_handler;
+ subreq->async.private_data = req;
- c->private_data = state;
- c->state = COMPOSITE_STATE_IN_PROGRESS;
- c->event_ctx = nbtsock->event_ctx;
+ return req;
+}
- return c;
+static void nbt_name_refresh_wins_handler(struct nbt_name_request *subreq)
+{
+ struct tevent_req *req =
+ talloc_get_type_abort(subreq->async.private_data,
+ struct tevent_req);
+ struct nbt_name_refresh_wins_state *state =
+ tevent_req_data(req,
+ struct nbt_name_refresh_wins_state);
+ NTSTATUS status;
-failed:
- talloc_free(c);
- return NULL;
+ status = nbt_name_refresh_recv(subreq, state, state->io);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
+ /* the refresh timed out - try the next WINS server */
+ state->wins_servers++;
+ if (state->wins_servers[0] == NULL) {
+ tevent_req_nterror(req, status);
+ return;
+ }
+
+ state->address_idx = 0;
+ state->io->in.dest_addr = state->wins_servers[0];
+ state->io->in.dest_port = state->wins_port;
+ state->io->in.address = state->addresses[0];
+
+ subreq = nbt_name_refresh_send(state->nbtsock, state->io);
+ if (tevent_req_nomem(subreq, req)) {
+ return;
+ }
+ subreq->async.fn = nbt_name_refresh_wins_handler;
+ subreq->async.private_data = req;
+ } else if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
+ }
+
+ if (state->io->out.rcode == 0 &&
+ state->addresses[state->address_idx+1] != NULL) {
+ /* refresh our next address */
+ state->io->in.address = state->addresses[++(state->address_idx)];
+ subreq = nbt_name_refresh_send(state->nbtsock, state->io);
+ if (tevent_req_nomem(subreq, req)) {
+ return;
+ }
+ subreq->async.fn = nbt_name_refresh_wins_handler;
+ subreq->async.private_data = req;
+ return;
+ }
+
+ tevent_req_done(req);
}
/*
multi-homed WINS name refresh - recv side
*/
-_PUBLIC_ NTSTATUS nbt_name_refresh_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
- struct nbt_name_refresh_wins *io)
+_PUBLIC_ NTSTATUS nbt_name_refresh_wins_recv(struct tevent_req *req,
+ TALLOC_CTX *mem_ctx,
+ struct nbt_name_refresh_wins *io)
{
+ struct nbt_name_refresh_wins_state *state =
+ tevent_req_data(req,
+ struct nbt_name_refresh_wins_state);
NTSTATUS status;
- status = composite_wait(c);
- if (NT_STATUS_IS_OK(status)) {
- struct refresh_wins_state *state =
- talloc_get_type(c->private_data, struct refresh_wins_state);
- io->out.wins_server = talloc_steal(mem_ctx, state->wins_servers[0]);
- io->out.rcode = state->io->out.rcode;
+
+ if (tevent_req_is_nterror(req, &status)) {
+ tevent_req_received(req);
+ return status;
}
- talloc_free(c);
- return status;
+
+ io->out.wins_server = talloc_move(mem_ctx, &state->wins_servers[0]);
+ io->out.rcode = state->io->out.rcode;
+
+ tevent_req_received(req);
+ return NT_STATUS_OK;
}
/*
multi-homed WINS refresh - sync interface
*/
_PUBLIC_ NTSTATUS nbt_name_refresh_wins(struct nbt_name_socket *nbtsock,
- TALLOC_CTX *mem_ctx,
- struct nbt_name_refresh_wins *io)
+ TALLOC_CTX *mem_ctx,
+ struct nbt_name_refresh_wins *io)
{
- struct composite_context *c = nbt_name_refresh_wins_send(nbtsock, io);
- return nbt_name_refresh_wins_recv(c, mem_ctx, io);
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct tevent_context *ev;
+ struct tevent_req *subreq;
+ NTSTATUS status;
+
+ /*
+ * TODO: create a temporary event context
+ */
+ ev = nbtsock->event_ctx;
+
+ subreq = nbt_name_refresh_wins_send(frame, ev, nbtsock, io);
+ if (subreq == NULL) {
+ talloc_free(frame);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ if (!tevent_req_poll(subreq, ev)) {
+ status = map_nt_error_from_unix(errno);
+ talloc_free(frame);
+ return status;
+ }
+
+ status = nbt_name_refresh_wins_recv(subreq, mem_ctx, io);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(frame);
+ return status;
+ }
+
+ TALLOC_FREE(frame);
+ return NT_STATUS_OK;
}
diff --git a/libcli/nbt/nameregister.c b/libcli/nbt/nameregister.c
index 39ef056..204fb6f 100644
--- a/libcli/nbt/nameregister.c
+++ b/libcli/nbt/nameregister.c
@@ -20,11 +20,12 @@
*/
#include "includes.h"
+#include <tevent.h>
#include "../libcli/nbt/libnbt.h"
#include "../libcli/nbt/nbt_proto.h"
-#include "libcli/composite/composite.h"
#include "lib/socket/socket.h"
#include "librpc/gen_ndr/ndr_nbt.h"
+#include "../lib/util/tevent_ntstatus.h"
/*
send a nbt name registration request
@@ -148,120 +149,115 @@ _PUBLIC_ NTSTATUS nbt_name_register(struct nbt_name_socket *nbtsock,
a 4 step broadcast registration. 3 lots of name registration requests, followed by
a name registration demand
*/
-struct register_bcast_state {
+struct nbt_name_register_bcast_state {
struct nbt_name_socket *nbtsock;
- struct nbt_name_register *io;
- struct nbt_name_request *req;
+ struct nbt_name_register io;
};
+static void nbt_name_register_bcast_handler(struct nbt_name_request *subreq);
/*
- state handler for 4 stage name registration
+ the async send call for a 4 stage name registration
*/
-static void name_register_bcast_handler(struct nbt_name_request *req)
+_PUBLIC_ struct tevent_req *nbt_name_register_bcast_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct nbt_name_socket *nbtsock,
+ struct nbt_name_register_bcast *io)
{
- struct composite_context *c = talloc_get_type(req->async.private_data, struct composite_context);
- struct register_bcast_state *state = talloc_get_type(c->private_data, struct register_bcast_state);
- NTSTATUS status;
+ struct tevent_req *req;
+ struct nbt_name_register_bcast_state *state;
+ struct nbt_name_request *subreq;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct nbt_name_register_bcast_state);
+ if (req == NULL) {
+ return NULL;
+ }
- status = nbt_name_register_recv(state->req, state, state->io);
- if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
- if (state->io->in.register_demand == true) {
- /* all done */
- c->state = COMPOSITE_STATE_DONE;
- c->status = NT_STATUS_OK;
- goto done;
- }
+ state->io.in.name = io->in.name;
+ state->io.in.dest_addr = io->in.dest_addr;
+ state->io.in.dest_port = io->in.dest_port;
+ state->io.in.address = io->in.address;
+ state->io.in.nb_flags = io->in.nb_flags;
+ state->io.in.register_demand = false;
+ state->io.in.broadcast = true;
+ state->io.in.multi_homed = false;
+ state->io.in.ttl = io->in.ttl;
+ state->io.in.timeout = 1;
+ state->io.in.retries = 2;
- /* the registration timed out - good, send the demand */
- state->io->in.register_demand = true;
- state->io->in.retries = 0;
- state->req = nbt_name_register_send(state->nbtsock, state->io);
- if (state->req == NULL) {
- c->state = COMPOSITE_STATE_ERROR;
- c->status = NT_STATUS_NO_MEMORY;
- } else {
- state->req->async.fn = name_register_bcast_handler;
- state->req->async.private_data = c;
- }
- } else if (!NT_STATUS_IS_OK(status)) {
- c->state = COMPOSITE_STATE_ERROR;
- c->status = status;
- } else {
- c->state = COMPOSITE_STATE_ERROR;
- c->status = NT_STATUS_CONFLICTING_ADDRESSES;
- DEBUG(3,("Name registration conflict from %s for %s with ip %s - rcode %d\n",
- state->io->out.reply_from,
- nbt_name_string(state, &state->io->out.name),
- state->io->out.reply_addr,
- state->io->out.rcode));
- }
+ state->nbtsock = nbtsock;
-done:
- if (c->state >= COMPOSITE_STATE_DONE &&
- c->async.fn) {
- c->async.fn(c);
+ subreq = nbt_name_register_send(nbtsock, &state->io);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
}
+
+ subreq->async.fn = nbt_name_register_bcast_handler;
+ subreq->async.private_data = req;
+
+ return req;
}
-/*
- the async send call for a 4 stage name registration
-*/
-_PUBLIC_ struct composite_context *nbt_name_register_bcast_send(struct nbt_name_socket *nbtsock,
- struct nbt_name_register_bcast *io)
+static void nbt_name_register_bcast_handler(struct nbt_name_request *subreq)
{
- struct composite_context *c;
- struct register_bcast_state *state;
-
- c = talloc_zero(nbtsock, struct composite_context);
- if (c == NULL) goto failed;
-
- state = talloc(c, struct register_bcast_state);
- if (state == NULL) goto failed;
-
- state->io = talloc(state, struct nbt_name_register);
- if (state->io == NULL) goto failed;
-
- state->io->in.name = io->in.name;
- state->io->in.dest_addr = io->in.dest_addr;
- state->io->in.dest_port = io->in.dest_port;
--
Samba Shared Repository
More information about the samba-cvs
mailing list