summaryrefslogtreecommitdiff
path: root/source4/torture/nbt/register.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-02-10 03:22:47 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:37 -0500
commitb9bb7f596de51496c18580863efbb8ac17c78970 (patch)
treee8ea83908a7a2e259e97b309595208481ef70b3d /source4/torture/nbt/register.c
parent57f69e6f37949636ae14c646517792fa40c9c75b (diff)
downloadsamba-b9bb7f596de51496c18580863efbb8ac17c78970.tar.gz
samba-b9bb7f596de51496c18580863efbb8ac17c78970.tar.bz2
samba-b9bb7f596de51496c18580863efbb8ac17c78970.zip
r5294: - added a separate NBT-WINS test for WINS operations (register, refresh, release and query)
- change the iface_n_*() functions to return a "const char *" instead of a "struct ipv4_addr" I think that in general we should move towards "const char *" for all IP addresses, as this makes IPv6 much easier, and is also easier to debug. Andrew, when you get a chance, could you fix some of the auth code to use strings for IPs ? - return a NTSTATUS error on bad name queries and node status instead of using rcode. This makes the calling code simpler. - added low level name release code in libcli/nbt/ - use a real IP in the register and wins nbt torture tests, as w2k3 WINS server silently rejects some operations that don't come from the IP being used (eg. it says "yes" to a release, but does not in fact release the name) (This used to be commit bb1ab11d8e0ea0bd9ae34aebeb565d36fe4b495f)
Diffstat (limited to 'source4/torture/nbt/register.c')
-rw-r--r--source4/torture/nbt/register.c82
1 files changed, 10 insertions, 72 deletions
diff --git a/source4/torture/nbt/register.c b/source4/torture/nbt/register.c
index 6094d9fcaf..a8be5dbb9a 100644
--- a/source4/torture/nbt/register.c
+++ b/source4/torture/nbt/register.c
@@ -38,9 +38,6 @@
ret = False; \
}} while (0)
-#define BOGUS_ADDRESS1 "255.255.255.254"
-#define BOGUS_ADDRESS2 "255.255.255.253"
-
/*
test that a server responds correctly to attempted registrations of its name
*/
@@ -51,12 +48,15 @@ static BOOL nbt_register_own(TALLOC_CTX *mem_ctx, struct nbt_name *name,
NTSTATUS status;
struct nbt_name_socket *nbtsock = nbt_name_socket_init(mem_ctx, NULL);
BOOL ret = True;
+ const char *myaddress = iface_n_ip(0);
+
+ socket_listen(nbtsock->sock, myaddress, 0, 0, 0);
printf("Testing name defense to name registration\n");
io.in.name = *name;
io.in.dest_addr = address;
- io.in.address = BOGUS_ADDRESS1;
+ io.in.address = myaddress;
io.in.nb_flags = NBT_NODE_B | NBT_NM_ACTIVE;
io.in.register_demand = False;
io.in.broadcast = True;
@@ -81,7 +81,7 @@ static BOOL nbt_register_own(TALLOC_CTX *mem_ctx, struct nbt_name *name,
CHECK_VALUE(io.out.rcode, NBT_RCODE_ACT);
/* check a register demand */
- io.in.address = BOGUS_ADDRESS2;
+ io.in.address = myaddress;
io.in.register_demand = True;
status = nbt_name_register(nbtsock, mem_ctx, &io);
@@ -113,14 +113,17 @@ static BOOL nbt_refresh_own(TALLOC_CTX *mem_ctx, struct nbt_name *name,
NTSTATUS status;
struct nbt_name_socket *nbtsock = nbt_name_socket_init(mem_ctx, NULL);
BOOL ret = True;
+ const char *myaddress = iface_n_ip(0);
+
+ socket_listen(nbtsock->sock, myaddress, 0, 0, 0);
printf("Testing name defense to name refresh\n");
io.in.name = *name;
io.in.dest_addr = address;
- io.in.address = BOGUS_ADDRESS1;
+ io.in.address = myaddress;
io.in.nb_flags = NBT_NODE_B | NBT_NM_ACTIVE;
- io.in.broadcast = True;
+ io.in.broadcast = False;
io.in.ttl = 1234;
io.in.timeout = 3;
io.in.retries = 0;
@@ -144,70 +147,6 @@ 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
@@ -235,7 +174,6 @@ 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);