svn commit: samba r5408 - in branches/SAMBA_4_0/source: nbt_server
torture/nbt
tridge at samba.org
tridge at samba.org
Tue Feb 15 11:14:05 GMT 2005
Author: tridge
Date: 2005-02-15 11:14:04 +0000 (Tue, 15 Feb 2005)
New Revision: 5408
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5408
Log:
- added testing for the behaviour of the special 0x1c name
- added WINS server support for the 0x1c name
Modified:
branches/SAMBA_4_0/source/nbt_server/defense.c
branches/SAMBA_4_0/source/nbt_server/nbt_server.h
branches/SAMBA_4_0/source/nbt_server/winsserver.c
branches/SAMBA_4_0/source/nbt_server/winswack.c
branches/SAMBA_4_0/source/torture/nbt/wins.c
branches/SAMBA_4_0/source/torture/nbt/winsbench.c
Changeset:
Modified: branches/SAMBA_4_0/source/nbt_server/defense.c
===================================================================
--- branches/SAMBA_4_0/source/nbt_server/defense.c 2005-02-15 10:36:59 UTC (rev 5407)
+++ branches/SAMBA_4_0/source/nbt_server/defense.c 2005-02-15 11:14:04 UTC (rev 5408)
@@ -56,7 +56,8 @@
name = &packet->questions[0].name;
iname = nbtd_find_iname(iface, name, NBT_NM_ACTIVE);
- if (iname != NULL && !(iname->nb_flags & NBT_NM_GROUP)) {
+ if (iname != NULL &&
+ !IS_GROUP_NAME(name, iname->nb_flags)) {
DEBUG(2,("Defending name %s on %s against %s\n",
nbt_name_string(packet, name),
iface->bcast_address, src_address));
Modified: branches/SAMBA_4_0/source/nbt_server/nbt_server.h
===================================================================
--- branches/SAMBA_4_0/source/nbt_server/nbt_server.h 2005-02-15 10:36:59 UTC (rev 5407)
+++ branches/SAMBA_4_0/source/nbt_server/nbt_server.h 2005-02-15 11:14:04 UTC (rev 5408)
@@ -79,3 +79,7 @@
return; \
} \
} while (0)
+
+/* this copes with the nasty hack that is the type 0x1c name */
+#define IS_GROUP_NAME(name, nb_flags) \
+ ((name)->type != NBT_NAME_LOGON && (nb_flags & NBT_NM_GROUP))
Modified: branches/SAMBA_4_0/source/nbt_server/winsserver.c
===================================================================
--- branches/SAMBA_4_0/source/nbt_server/winsserver.c 2005-02-15 10:36:59 UTC (rev 5407)
+++ branches/SAMBA_4_0/source/nbt_server/winsserver.c 2005-02-15 11:14:04 UTC (rev 5408)
@@ -56,7 +56,7 @@
rec.state = WINS_REC_ACTIVE;
rec.expire_time = time(NULL) + ttl;
rec.registered_by = src_address;
- if (nb_flags & NBT_NM_GROUP) {
+ if (IS_GROUP_NAME(name, nb_flags)) {
rec.addresses = str_list_make(packet, "255.255.255.255", NULL);
} else {
rec.addresses = str_list_make(packet, address, NULL);
@@ -145,7 +145,7 @@
/* if the registration is for a group, then just update the expiry time
and we are done */
- if (nb_flags & NBT_NM_GROUP) {
+ if (IS_GROUP_NAME(name, nb_flags)) {
wins_update_ttl(nbtsock, packet, rec, src_address, src_port);
goto done;
}
@@ -207,7 +207,7 @@
rec = winsdb_load(winssrv, name, packet);
if (rec == NULL ||
rec->state != WINS_REC_ACTIVE ||
- (rec->nb_flags & NBT_NM_GROUP)) {
+ IS_GROUP_NAME(name, rec->nb_flags)) {
goto done;
}
Modified: branches/SAMBA_4_0/source/nbt_server/winswack.c
===================================================================
--- branches/SAMBA_4_0/source/nbt_server/winswack.c 2005-02-15 10:36:59 UTC (rev 5407)
+++ branches/SAMBA_4_0/source/nbt_server/winswack.c 2005-02-15 11:14:04 UTC (rev 5408)
@@ -173,11 +173,6 @@
state->src_address = talloc_strdup(state, src_address);
if (state->src_address == NULL) goto failed;
- /* send a WACK to the client, specifying the maximum time it could
- take to check with the owner, plus some slack */
- ttl = 5 + 4 * str_list_length(rec->addresses);
- nbtd_wack_reply(nbtsock, packet, src_address, src_port, ttl);
-
/* setup a name query to the first address */
state->query.in.name = *rec->name;
state->query.in.dest_addr = state->owner_addresses[0];
@@ -186,6 +181,17 @@
state->query.in.timeout = 1;
state->query.in.retries = 2;
+ /* the LOGON type is a nasty hack */
+ if (rec->name->type == NBT_NAME_LOGON) {
+ wins_wack_allow(state);
+ return;
+ }
+
+ /* send a WACK to the client, specifying the maximum time it could
+ take to check with the owner, plus some slack */
+ ttl = 5 + 4 * str_list_length(rec->addresses);
+ nbtd_wack_reply(nbtsock, packet, src_address, src_port, ttl);
+
req = nbt_name_query_send(nbtsock, &state->query);
if (req == NULL) goto failed;
Modified: branches/SAMBA_4_0/source/torture/nbt/wins.c
===================================================================
--- branches/SAMBA_4_0/source/torture/nbt/wins.c 2005-02-15 10:36:59 UTC (rev 5407)
+++ branches/SAMBA_4_0/source/torture/nbt/wins.c 2005-02-15 11:14:04 UTC (rev 5408)
@@ -111,7 +111,9 @@
CHECK_STRING(io.out.wins_server, address);
CHECK_VALUE(io.out.rcode, 0);
- if (name->type != NBT_NAME_MASTER && nb_flags & NBT_NM_GROUP) {
+ if (name->type != NBT_NAME_MASTER &&
+ name->type != NBT_NAME_LOGON &&
+ (nb_flags & NBT_NM_GROUP)) {
printf("Try to register as non-group\n");
io.in.nb_flags &= ~NBT_NM_GROUP;
status = nbt_name_register_wins(nbtsock, mem_ctx, &io);
@@ -152,7 +154,8 @@
CHECK_NAME(query.out.name, *name);
CHECK_VALUE(query.out.num_addrs, 1);
- if (nb_flags & NBT_NM_GROUP) {
+ if (name->type != NBT_NAME_LOGON &&
+ (nb_flags & NBT_NM_GROUP)) {
CHECK_STRING(query.out.reply_addrs[0], "255.255.255.255");
} else {
CHECK_STRING(query.out.reply_addrs[0], myaddress);
@@ -258,7 +261,8 @@
printf("query the name to make sure its gone\n");
query.in.name = *name;
status = nbt_name_query(nbtsock, mem_ctx, &query);
- if (nb_flags & NBT_NM_GROUP) {
+ if (name->type != NBT_NAME_LOGON &&
+ (nb_flags & NBT_NM_GROUP)) {
if (!NT_STATUS_IS_OK(status)) {
printf("ERROR: Name query failed after group release - %s\n",
nt_errstr(status));
@@ -300,6 +304,9 @@
ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H | NBT_NM_GROUP);
+ name.type = NBT_NAME_LOGON;
+ ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H | NBT_NM_GROUP);
+
name.scope = "example";
name.type = 0x72;
ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H);
Modified: branches/SAMBA_4_0/source/torture/nbt/winsbench.c
===================================================================
--- branches/SAMBA_4_0/source/torture/nbt/winsbench.c 2005-02-15 10:36:59 UTC (rev 5407)
+++ branches/SAMBA_4_0/source/torture/nbt/winsbench.c 2005-02-15 11:14:04 UTC (rev 5408)
@@ -120,7 +120,7 @@
}
/*
- generate a registration
+ generate a name release
*/
static void generate_release(struct nbt_name_socket *nbtsock, struct wins_state *state, int idx)
{
More information about the samba-cvs
mailing list