diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-02-06 08:27:12 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:09:34 -0500 |
commit | 7f10614e94e5e502b53e64519ac4b0476ab858ae (patch) | |
tree | 59d5ee81bf277e2d5d600f1c531c81ab89898201 /source4 | |
parent | a75e9a3ee91b83af9c0fa25e407bf63cd67cd343 (diff) | |
download | samba-7f10614e94e5e502b53e64519ac4b0476ab858ae.tar.gz samba-7f10614e94e5e502b53e64519ac4b0476ab858ae.tar.bz2 samba-7f10614e94e5e502b53e64519ac4b0476ab858ae.zip |
r5252: - fixed nmblookup for the nbt api changes
- added a simple WINS server name registration and query test
(This used to be commit d56e68ebf584e50aa409d22b1ca7c9276abea962)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/torture/nbt/register.c | 68 | ||||
-rw-r--r-- | source4/utils/nmblookup.c | 6 |
2 files changed, 72 insertions, 2 deletions
diff --git a/source4/torture/nbt/register.c b/source4/torture/nbt/register.c index 90ecc7ac28..40086e12cc 100644 --- a/source4/torture/nbt/register.c +++ b/source4/torture/nbt/register.c @@ -62,6 +62,7 @@ static BOOL nbt_register_own(TALLOC_CTX *mem_ctx, struct nbt_name *name, io.in.broadcast = True; io.in.ttl = 1234; io.in.timeout = 3; + io.in.retries = 0; status = nbt_name_register(nbtsock, mem_ctx, &io); if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { @@ -121,6 +122,7 @@ static BOOL nbt_refresh_own(TALLOC_CTX *mem_ctx, struct nbt_name *name, io.in.broadcast = True; io.in.ttl = 1234; io.in.timeout = 3; + io.in.retries = 0; status = nbt_name_refresh(nbtsock, mem_ctx, &io); if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { @@ -142,6 +144,71 @@ static BOOL nbt_refresh_own(TALLOC_CTX *mem_ctx, struct nbt_name *name, /* + register names with a WINS server +*/ +static BOOL nbt_register_wins(TALLOC_CTX *mem_ctx, struct nbt_name *name, + const char *address) +{ + struct nbt_name_refresh_wins io; + struct nbt_name_query q; + NTSTATUS status; + struct nbt_name_socket *nbtsock = nbt_name_socket_init(mem_ctx, NULL); + BOOL ret = True; + + printf("Testing name registration to WINS\n"); + + io.in.name.name = talloc_asprintf(mem_ctx, "_TORTURE-%5u", + (unsigned)(random() % (100000))); + io.in.name.type = NBT_NAME_CLIENT; + io.in.name.scope = NULL; + io.in.wins_servers = str_list_make(mem_ctx, address, NULL); + io.in.addresses = str_list_make(mem_ctx, BOGUS_ADDRESS1, NULL); + io.in.nb_flags = NBT_NODE_M | NBT_NM_ACTIVE; + io.in.ttl = 12345; + + status = nbt_name_refresh_wins(nbtsock, mem_ctx, &io); + if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { + printf("No response from %s for name register\n", address); + return False; + } + if (!NT_STATUS_IS_OK(status)) { + printf("Bad response from %s for name register - %s\n", + address, nt_errstr(status)); + return False; + } + + CHECK_STRING(io.out.wins_server, address); + CHECK_VALUE(io.out.rcode, 0); + + /* query the name to make sure its there */ + q.in.name = io.in.name; + q.in.dest_addr = address; + q.in.broadcast = False; + q.in.wins_lookup = True; + q.in.timeout = 3; + q.in.retries = 0; + + status = nbt_name_query(nbtsock, mem_ctx, &q); + if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { + printf("No response from %s for name query\n", address); + return False; + } + if (!NT_STATUS_IS_OK(status)) { + printf("Bad response from %s for name query - %s\n", + address, nt_errstr(status)); + return False; + } + + CHECK_STRING(q.out.name.name, q.in.name.name); + CHECK_VALUE(q.out.name.type, q.in.name.type); + CHECK_VALUE(q.out.num_addrs, 1); + CHECK_STRING(q.out.reply_addrs[0], BOGUS_ADDRESS1); + + return ret; +} + + +/* test name registration to a server */ BOOL torture_nbt_register(void) @@ -167,6 +234,7 @@ BOOL torture_nbt_register(void) ret &= nbt_register_own(mem_ctx, &name, address); ret &= nbt_refresh_own(mem_ctx, &name, address); + ret &= nbt_register_wins(mem_ctx, &name, address); talloc_free(mem_ctx); diff --git a/source4/utils/nmblookup.c b/source4/utils/nmblookup.c index 824ce64298..3e3a4415d5 100644 --- a/source4/utils/nmblookup.c +++ b/source4/utils/nmblookup.c @@ -109,7 +109,8 @@ static void do_node_status(struct nbt_name_socket *nbtsock, io.in.name.type = 0; io.in.name.scope = NULL; io.in.dest_addr = addr; - io.in.timeout = 3; + io.in.timeout = 1; + io.in.retries = 2; status = nbt_name_status(nbtsock, nbtsock, &io); if (NT_STATUS_IS_OK(status)) { @@ -149,7 +150,8 @@ static NTSTATUS do_node_query(struct nbt_name_socket *nbtsock, io.in.dest_addr = addr; io.in.broadcast = broadcast; io.in.wins_lookup = options.wins_lookup; - io.in.timeout = 3; + io.in.timeout = 1; + io.in.retries = 2; status = nbt_name_query(nbtsock, nbtsock, &io); NT_STATUS_NOT_OK_RETURN(status); |