summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-08-30 05:43:59 +0000
committerAndrew Tridgell <tridge@samba.org>1998-08-30 05:43:59 +0000
commit5a44ce9caaa9e3b19ee387b698ac255ec2cb5785 (patch)
tree5d84f78bfaa57a87285b785daa9d2b472ca5f2f6 /source3/lib
parent56cbed3904b3db90404d19d084e140c715aef6ec (diff)
downloadsamba-5a44ce9caaa9e3b19ee387b698ac255ec2cb5785.tar.gz
samba-5a44ce9caaa9e3b19ee387b698ac255ec2cb5785.tar.bz2
samba-5a44ce9caaa9e3b19ee387b698ac255ec2cb5785.zip
changed the format of the wins.dat file slightly.
It now has a line like this: VERSION 1 251152 the first number is a version #define in nmbd_winsserver.c and will be used if we ever have to change the format again. The second number is a hash of the current interfaces setting. It is used to detect the case where nmbd is restarted on a machine after the IP of the machine has changed (or the interfaces list has changed in any way). When that happens we need to discard the old wins.dat cache or you end up with chaos. This has bitten quite a few people, they find that when they move a machine it continues using the old IP for some things for the next week until the wins entries time out! I've checked, and the old nmbd can handle the new format, although it does spit out a spurious error message about the VERSION line. So users can safely run 2.0alpha then switch back to 1.9.18 without problems. (This used to be commit c4a8cdc60a5b01894ab2456e77b6d89d4c16a088)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/interface.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/source3/lib/interface.c b/source3/lib/interface.c
index 7aae803abf..8cc5cfb0b1 100644
--- a/source3/lib/interface.c
+++ b/source3/lib/interface.c
@@ -350,6 +350,28 @@ static struct interface *iface_find(struct in_addr ip)
return NULL;
}
+
+/****************************************************************************
+this function provides a simple hash of the configured interfaces. It is
+used to detect a change in interfaces to tell us whether to discard
+the current wins.dat file.
+Note that the result is independent of the order of the interfaces
+ **************************************************************************/
+unsigned iface_hash(void)
+{
+ unsigned ret = 0;
+ struct interface *i;
+
+ for (i=local_interfaces;i;i=i->next) {
+ unsigned x1 = (unsigned)str_checksum(inet_ntoa(i->ip));
+ unsigned x2 = (unsigned)str_checksum(inet_ntoa(i->nmask));
+ ret ^= (x1 ^ x2);
+ }
+
+ return ret;
+}
+
+
/* these 3 functions return the ip/bcast/nmask for the interface
most appropriate for the given ip address. If they can't find
an appropriate interface they return the requested field of the