[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Fri Apr 5 13:29:01 UTC 2024


The branch, master has been updated
       via  814ae222ca1 s3:winbindd: use better debug messages than 'talloc_strdup failed'
       via  72a4d3ad5a9 s3:passdb: use DBG_ERR() for 'talloc_strdup failed' messages
       via  ca859e55d28 s3:libads: avoid changing ADS->server.workgroup
       via  796f33c05a0 s4:nbt_server: simulate nmbd and provide unexpected handling
       via  bfb10774b65 s4:libcli/dgram: add nbt_dgram_send_raw() to send raw blobs
       via  77f4f1c7dba s4:libcli/dgram: make use of socket_address_copy()
       via  11861bcfc30 s4:libcli/dgram: let the generic incoming handler also get unexpected mailslot messages
       via  cca373b806e libcli/nbt: add nbt_name_send_raw()
       via  2b66663c75c s3:libsmb/dsgetdcname: use NETLOGON_NT_VERSION_AVOID_NT4EMUL
       via  696505a1efb s3:libsmb/unexpected: pass nmbd_socket_dir from the callers of nb_packet_{server_create,reader_send}()
       via  f90cf0822d6 s3:libsmb/unexpected: don't use talloc_tos() in async code
       via  011f68ae5dd s3:wscript: LIBNMB requires lp_ functions
       via  105247c9000 s3:include: split out fstring.h
       via  7f96c21029e s3:include: let nameserv.h be useable on its own
      from  f8b72aa1f72 tests: Add a test for "all_groups=no" to test_idmap_ad.sh

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 814ae222ca15ff7093a71639cdcc97b9937670ce
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jan 26 09:25:11 2024 +0100

    s3:winbindd: use better debug messages than 'talloc_strdup failed'
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Fri Apr  5 13:28:42 UTC 2024 on atb-devel-224

commit 72a4d3ad5a9d1ea5cd0b2a940893727f0283879a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Jan 26 09:21:03 2024 +0100

    s3:passdb: use DBG_ERR() for 'talloc_strdup failed' messages
    
    Otherwise it's completely unclear where the messages come from
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit ca859e55d28f421196bc2660cfa84595ec5b57c6
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Oct 15 03:34:11 2021 +0200

    s3:libads: avoid changing ADS->server.workgroup
    
    ads_find_dc() uses c_domain = ads->server.workgroup and
    don't expect it to get out of scope deep in resolve_and_ping_dns().
    
    The result are corrupted domain values in the debug output.
    
    Valgrind shows this:
    
     Invalid read of size 1
        at 0x483EF46: strlen (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
        by 0x608BE94: __vfprintf_internal (vfprintf-internal.c:1688)
        by 0x609ED49: __vasprintf_internal (vasprintf.c:57)
        by 0x5D2EC0F: __dbgtext_va (debug.c:1860)
        by 0x5D2ED3F: dbgtext (debug.c:1881)
        by 0x4BFFB50: ads_find_dc (ldap.c:570)
        by 0x4C001F4: ads_connect (ldap.c:704)
        by 0x4C1DC12: ads_dc_name (namequery_dc.c:84)
      Address 0xb69f6f0 is 0 bytes inside a block of size 11 free'd
        at 0x483CA3F: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
        by 0x4BFF0AF: ads_try_connect (ldap.c:299)
        by 0x4BFF40E: cldap_ping_list (ldap.c:367)
        by 0x4BFF75F: resolve_and_ping_dns (ldap.c:468)
        by 0x4BFFA91: ads_find_dc (ldap.c:556)
        by 0x4C001F4: ads_connect (ldap.c:704)
        by 0x4C1DC12: ads_dc_name (namequery_dc.c:84)
      Block was alloc'd at
        at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
        by 0x60B250E: strdup (strdup.c:42)
        by 0x4FF1492: smb_xstrdup (util.c:743)
        by 0x4C10E62: ads_init (ads_struct.c:148)
        by 0x4C1DB68: ads_dc_name (namequery_dc.c:73)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14981
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 796f33c05a0ca337b675b5d4d127f7c53b22528f
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Feb 14 12:34:48 2024 +0100

    s4:nbt_server: simulate nmbd and provide unexpected handling
    
    This is needed in order to let nbt_getdc() work against
    another AD DC and get back a modern response with
    DNS based names. Instead of falling back to
    the ugly name_status_find() that simulates just
    an NETLOGON_SAM_LOGON_RESPONSE_NT40 response.
    
    This way dsgetdcname() can work with just the netbios
    domain name given and still return an active directory
    response.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15620
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit bfb10774b65af65f9c438a5d3e87529b1fcf46a1
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Feb 14 13:49:21 2024 +0100

    s4:libcli/dgram: add nbt_dgram_send_raw() to send raw blobs
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15620
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 77f4f1c7dbaa2bb04d59d908923f6d11fd514da2
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Feb 15 17:47:45 2024 +0100

    s4:libcli/dgram: make use of socket_address_copy()
    
    This avoids talloc_reference...
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15620
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 11861bcfc3054894bc445e631ae03befb4865db8
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Feb 15 16:42:16 2024 +0100

    s4:libcli/dgram: let the generic incoming handler also get unexpected mailslot messages
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15620
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit cca373b806e01fc57bd5316d3f8a17578b4b6531
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Feb 15 17:47:13 2024 +0100

    libcli/nbt: add nbt_name_send_raw()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15620
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 2b66663c75cdb3bc1b6bc5b1736dd9d35b094b42
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Feb 15 17:29:46 2024 +0100

    s3:libsmb/dsgetdcname: use NETLOGON_NT_VERSION_AVOID_NT4EMUL
    
    In 2024 we always want an active directory response...
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15620
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 696505a1efbcc9803a287d8c267fed9d04bf8885
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Feb 14 11:38:19 2024 +0100

    s3:libsmb/unexpected: pass nmbd_socket_dir from the callers of nb_packet_{server_create,reader_send}()
    
    This will allow source4/nbt_server to make use of
    nb_packet_server_create().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15620
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit f90cf0822d6e66426d72f92bd585119066e2a9c3
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Feb 14 13:49:43 2024 +0100

    s3:libsmb/unexpected: don't use talloc_tos() in async code
    
    It's not needed and it requires the caller to setup a
    stackframe...
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15620
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 011f68ae5ddc3fae8b453744aeb95766d885915e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Feb 15 16:37:34 2024 +0100

    s3:wscript: LIBNMB requires lp_ functions
    
    We need to make this explicit in order to let LIBNMB be used
    in source4 code.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15620
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 105247c90007474947e2314b63be72fb21f09811
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Feb 15 16:53:29 2024 +0100

    s3:include: split out fstring.h
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15620
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 7f96c21029e3b94d38bd871c79cabf872ad77fae
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Feb 14 14:15:47 2024 +0100

    s3:include: let nameserv.h be useable on its own
    
    A lot of stuff is private to nmbd and can
    be moved from nameserv.h.
    
    This allows move required types from smb.h to
    nameserv.h, so that this can be standalone.
    Including it from smb.h is not a huge problem
    as nmbd internals are gone from nameserv.h.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15620
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 libcli/nbt/libnbt.h                                |   3 +
 libcli/nbt/nbtsocket.c                             |  44 +++
 selftest/target/Samba4.pm                          |   2 +
 lib/util/unix_match.h => source3/include/fstring.h |  14 +-
 source3/include/includes.h                         |   5 +-
 source3/include/nameserv.h                         | 380 ++------------------
 source3/include/smb.h                              |  26 +-
 source3/libads/ldap.c                              |  16 +-
 source3/librpc/idl/ads.idl                         |   1 +
 source3/libsmb/clidgram.c                          |   6 +-
 source3/libsmb/dsgetdcname.c                       |   5 +
 source3/libsmb/namequery.c                         |   7 +-
 source3/libsmb/nmblib.c                            |   6 +
 source3/libsmb/nmblib.h                            |   2 +
 source3/libsmb/unexpected.c                        |  18 +-
 source3/libsmb/unexpected.h                        |   2 +
 source3/nmbd/nmbd.h                                | 382 +++++++++++++++++++++
 source3/nmbd/nmbd_packets.c                        |   1 +
 source3/passdb/pdb_smbpasswd.c                     |   4 +-
 source3/passdb/pdb_tdb.c                           |   2 +-
 source3/utils/net_ads.c                            |   6 +
 source3/winbindd/winbindd_cm.c                     |  11 +-
 source3/wscript_build                              |   1 +
 source4/libcli/dgram/dgramsocket.c                 |  40 ++-
 source4/libcli/dgram/libdgram.h                    |   3 +
 source4/nbt_server/dgram/request.c                 |  56 ++-
 source4/nbt_server/interfaces.c                    |  29 ++
 source4/nbt_server/nbt_server.c                    | 143 ++++++++
 source4/nbt_server/nbt_server.h                    |   2 +
 source4/nbt_server/wscript_build                   |   2 +-
 30 files changed, 793 insertions(+), 426 deletions(-)
 copy lib/util/unix_match.h => source3/include/fstring.h (76%)


Changeset truncated at 500 lines:

diff --git a/libcli/nbt/libnbt.h b/libcli/nbt/libnbt.h
index 204484be73f..6a30c9fedb5 100644
--- a/libcli/nbt/libnbt.h
+++ b/libcli/nbt/libnbt.h
@@ -331,6 +331,9 @@ NTSTATUS nbt_set_unexpected_handler(struct nbt_name_socket *nbtsock,
 				    void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
 						    struct socket_address *),
 				    void *private_data);
+NTSTATUS nbt_name_send_raw(struct nbt_name_socket *nbtsock,
+			   struct socket_address *dest,
+			   const DATA_BLOB pkt_blob);
 NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
 			     struct socket_address *dest,
 			     struct nbt_name_packet *request);
diff --git a/libcli/nbt/nbtsocket.c b/libcli/nbt/nbtsocket.c
index 47e73cf2e8d..b2945ad912f 100644
--- a/libcli/nbt/nbtsocket.c
+++ b/libcli/nbt/nbtsocket.c
@@ -448,6 +448,50 @@ failed:
 	return NULL;
 }
 
+/*
+  send off a nbt name packet
+*/
+_PUBLIC_ NTSTATUS nbt_name_send_raw(struct nbt_name_socket *nbtsock,
+				    struct socket_address *dest,
+				    const DATA_BLOB pkt_blob)
+{
+	struct nbt_name_request *req;
+
+	req = talloc_zero(nbtsock, struct nbt_name_request);
+	NT_STATUS_HAVE_NO_MEMORY(req);
+
+	req->nbtsock = nbtsock;
+	req->dest = socket_address_copy(req, dest);
+	if (req->dest == NULL) {
+		goto failed;
+	}
+	req->state = NBT_REQUEST_SEND;
+	/*
+	 * We don't expect a response so
+	 * just pretent it is a request,
+	 * but we really don't care about the
+	 * content.
+	 */
+	req->is_reply = true;
+
+	req->encoded = data_blob_dup_talloc(req, pkt_blob);
+	if (req->encoded.length != pkt_blob.length) {
+		goto failed;
+	}
+
+	talloc_set_destructor(req, nbt_name_request_destructor);
+
+	DLIST_ADD_END(nbtsock->send_queue, req);
+
+	TEVENT_FD_WRITEABLE(nbtsock->fde);
+
+	return NT_STATUS_OK;
+
+failed:
+	talloc_free(req);
+	return NT_STATUS_NO_MEMORY;
+}
+
 
 /*
   send off a nbt name reply
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index 2d449e4a652..f2b84b4f9b7 100755
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -618,6 +618,7 @@ sub provision_raw_prepare($$$$$$$$$$$$$$)
 	$ctx->{statedir} = "$prefix_abs/statedir";
 	$ctx->{cachedir} = "$prefix_abs/cachedir";
 	$ctx->{winbindd_socket_dir} = "$prefix_abs/wbsock";
+	$ctx->{nmbd_socket_dir} = "$prefix_abs/nmbsock";
 	$ctx->{ntp_signd_socket_dir} = "$prefix_abs/ntp_signd_socket";
 	$ctx->{nsswrap_passwd} = "$ctx->{etcdir}/passwd";
 	$ctx->{nsswrap_group} = "$ctx->{etcdir}/group";
@@ -774,6 +775,7 @@ sub provision_raw_step1($$)
 	state directory = $ctx->{statedir}
 	cache directory = $ctx->{cachedir}
 	winbindd socket directory = $ctx->{winbindd_socket_dir}
+	nmbd:socket dir = $ctx->{nmbd_socket_dir}
 	ntp signd socket directory = $ctx->{ntp_signd_socket_dir}
 	winbind separator = /
 	interfaces = $interfaces
diff --git a/lib/util/unix_match.h b/source3/include/fstring.h
similarity index 76%
copy from lib/util/unix_match.h
copy to source3/include/fstring.h
index a7b693500b2..dfc8f17a8f3 100644
--- a/lib/util/unix_match.h
+++ b/source3/include/fstring.h
@@ -1,7 +1,6 @@
 /*
    Unix SMB/CIFS implementation.
-   Utility functions for Samba
-   Copyright (C) Jeremy Allison 2001
+   Copyright (C) 2002 by Martin Pool <mbp at samba.org>
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -17,9 +16,12 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#ifndef _UNIX_MASK_H_
-#define _UNIX_MASK_H_
-
-bool unix_wild_match(const char *pattern, const char *string);
+#ifndef _SAMBA_FSTRING_H
+#define _SAMBA_FSTRING_H
 
+#ifndef FSTRING_LEN
+#define FSTRING_LEN 256
+typedef char fstring[FSTRING_LEN];
 #endif
+
+#endif /* _SAMBA_FSTRING_H */
diff --git a/source3/include/includes.h b/source3/include/includes.h
index 1e7b79ba0a9..ee05b93c07d 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -237,10 +237,7 @@ enum timestamp_set_resolution {
    _________)/\\_//(\/(/\)/\//\/\///|_)_______
 */
 
-#ifndef FSTRING_LEN
-#define FSTRING_LEN 256
-typedef char fstring[FSTRING_LEN];
-#endif
+#include "fstring.h"
 
 /* debug.h need to be included before samba_util.h for the macro SMB_ASSERT */
 #include "../lib/util/debug.h"
diff --git a/source3/include/nameserv.h b/source3/include/nameserv.h
index 8fbe5a33a29..51efe82d061 100644
--- a/source3/include/nameserv.h
+++ b/source3/include/nameserv.h
@@ -20,18 +20,6 @@
    
 */
 
-#define INFO_VERSION	"INFO/version"
-#define INFO_COUNT	"INFO/num_entries"
-#define INFO_ID_HIGH	"INFO/id_high"
-#define INFO_ID_LOW	"INFO/id_low"
-#define ENTRY_PREFIX 	"ENTRY/"
-
-#define PERMANENT_TTL 0
-
-/* NTAS uses 2, NT uses 1, WfWg uses 0 */
-#define MAINTAIN_LIST    2
-#define ELECTION_VERSION 1
-
 #define MAX_DGRAM_SIZE (576) /* tcp/ip datagram limit is 576 bytes */
 #define MIN_DGRAM_SIZE 12
 
@@ -140,12 +128,6 @@ enum netbios_reply_type_code { NMB_QUERY, NMB_STATUS, NMB_REG, NMB_REG_REFRESH,
 #define NAME_POLL_REFRESH_TIME (5*60)
 #define NAME_POLL_INTERVAL 15
 
-/* Workgroup state identifiers. */
-#define AM_POTENTIAL_MASTER_BROWSER(work) ((work)->mst_state == MST_POTENTIAL)
-#define AM_LOCAL_MASTER_BROWSER(work) ((work)->mst_state == MST_BROWSER)
-#define AM_DOMAIN_MASTER_BROWSER(work) ((work)->dom_state == DOMAIN_MST)
-#define AM_DOMAIN_MEMBER(work) ((work)->log_state == LOGON_SRV)
-
 /* Microsoft browser NetBIOS name. */
 #define MSBROWSE "\001\002__MSBROWSE__\002"
 
@@ -159,293 +141,33 @@ enum netbios_reply_type_code { NMB_QUERY, NMB_STATUS, NMB_REG, NMB_REG_REFRESH,
 #define FIND_ANY_NAME   0
 #define FIND_SELF_NAME  1
 
-/*
- * The different name types that can be in namelists.
- *
- * SELF_NAME should only be on the broadcast and unicast subnets.
- * LMHOSTS_NAME should only be in the remote_broadcast_subnet.
- * REGISTER_NAME, DNS_NAME, DNSFAIL_NAME should only be in the wins_server_subnet.
- * WINS_PROXY_NAME should only be on the broadcast subnets.
- * PERMANENT_NAME can be on all subnets except remote_broadcast_subnet.
- *
- */
-
-enum name_source {LMHOSTS_NAME, REGISTER_NAME, SELF_NAME, DNS_NAME, 
-                  DNSFAIL_NAME, PERMANENT_NAME, WINS_PROXY_NAME};
 enum node_type {B_NODE=0, P_NODE=1, M_NODE=2, NBDD_NODE=3};
 enum packet_type {NMB_PACKET, DGRAM_PACKET};
 
-enum master_state {
-	MST_NONE,
-	MST_POTENTIAL,
-	MST_BACKUP,
-	MST_MSB,
-	MST_BROWSER,
-	MST_UNBECOMING_MASTER
-};
-
-enum domain_state {
-	DOMAIN_NONE,
-	DOMAIN_WAIT,
-	DOMAIN_MST
-};
-
-enum logon_state {
-	LOGON_NONE,
-	LOGON_WAIT,
-	LOGON_SRV
-};
-
-struct subnet_record;
-
-struct nmb_data {
-	uint16_t nb_flags;       /* Netbios flags. */
-	int num_ips;             /* Number of ip entries. */
-	struct in_addr *ip;      /* The ip list for this name. */
-
-	enum name_source source; /* Where the name came from. */
-
-	time_t death_time; /* The time the record must be removed (do not remove if 0). */
-	time_t refresh_time; /* The time the record should be refreshed. */
-  
-	uint64_t id;		/* unique id */
-	struct in_addr wins_ip;	/* the address of the wins server this record comes from */
-
-	int wins_flags;		/* similar to the netbios flags but different ! */
-};
-
-/* This structure represents an entry in a local netbios name list. */
-struct name_record {
-	struct name_record *prev, *next;
-	struct subnet_record *subnet;
-	struct nmb_name       name;    /* The netbios name. */
-	struct nmb_data       data;    /* The netbios data. */
-};
-
-/* Browser cache for synchronising browse lists. */
-struct browse_cache_record {
-	struct browse_cache_record *prev, *next;
-	unstring        lmb_name;
-	unstring        work_group;
-	struct in_addr ip;
-	time_t         sync_time;
-	time_t         death_time; /* The time the record must be removed. */
-};
-
-/* used for server information: client, nameserv and ipc */
-struct server_info_struct {
-	fstring name;
-	uint32_t type;
-	fstring comment;
-	fstring domain; /* used ONLY in ipc.c NOT namework.c */
-	bool server_added; /* used ONLY in ipc.c NOT namework.c */
-};
-
-/* This is used to hold the list of servers in my domain, and is
-   contained within lists of domains. */
-
-struct server_record {
-	struct server_record *next;
-	struct server_record *prev;
-
-	struct subnet_record *subnet;
-
-	struct server_info_struct serv;
-	time_t death_time;  
-};
-
-/* A workgroup structure. It contains a list of servers. */
-struct work_record {
-	struct work_record *next;
-	struct work_record *prev;
-
-	struct subnet_record *subnet;
-
-	struct server_record *serverlist;
-
-	/* Stage of development from non-local-master up to local-master browser. */
-	enum master_state mst_state;
-
-	/* Stage of development from non-domain-master to domain-master browser. */
-	enum domain_state dom_state;
-
-  	/* Stage of development from non-logon-server to logon server. */
-	enum logon_state log_state;
-
-	/* Work group info. */
-	unstring work_group;
-	int     token;        /* Used when communicating with backup browsers. */
-	unstring local_master_browser_name;      /* Current local master browser. */
-
-	/* Announce info. */
-	time_t lastannounce_time;
-	int announce_interval;
-	bool    needannounce;
-
-	/* Timeout time for this workgroup. 0 means permanent. */
-	time_t death_time;  
-
-	/* Election info */
-	bool    RunningElection;
-	bool    needelection;
-	int     ElectionCount;
-	uint32_t  ElectionCriterion;
-
-	/* Domain master browser info. Used for efficient syncs. */
-	struct nmb_name dmb_name;
-	struct in_addr dmb_addr;
-};
-
-/* typedefs needed to define copy & free functions for userdata. */
-struct userdata_struct;
-
-typedef struct userdata_struct * (*userdata_copy_fn)(struct userdata_struct *);
-typedef void (*userdata_free_fn)(struct userdata_struct *);
-
-/* Structure to define any userdata passed around. */
-
-struct userdata_struct {
-	userdata_copy_fn copy_fn;
-	userdata_free_fn free_fn;
-	unsigned int userdata_len;
-	char data[16]; /* 16 is to ensure alignment/padding on all systems */
+#define MAX_NETBIOSNAME_LEN 16
+/* DOS character, NetBIOS namestring. Type used on the wire. */
+typedef char nstring[MAX_NETBIOSNAME_LEN];
+/* Unix character, NetBIOS namestring. Type used to manipulate name in nmbd. */
+typedef char unstring[MAX_NETBIOSNAME_LEN*4];
+
+/* A netbios name structure. */
+struct nmb_name {
+	nstring      name;
+	char         scope[64];
+	unsigned int name_type;
 };
 
-struct response_record;
-struct packet_struct;
-struct res_rec;
-
-/* typedef to define the function called when this response packet comes in. */
-typedef void (*response_function)(struct subnet_record *, struct response_record *,
-                                  struct packet_struct *);
-
-/* typedef to define the function called when this response record times out. */
-typedef void (*timeout_response_function)(struct subnet_record *,
-                                          struct response_record *);
-
-/* typedef to define the function called when the request that caused this
-   response record to be created is successful. */
-typedef void (*success_function)(struct subnet_record *, struct userdata_struct *, ...);
-
-/* typedef to define the function called when the request that caused this
-   response record to be created is unsuccessful. */
-typedef void (*fail_function)(struct subnet_record *, struct response_record *, ...);
-
-/* List of typedefs for success and fail functions of the different query
-   types. Used to catch any compile time prototype errors. */
-
-typedef void (*register_name_success_function)( struct subnet_record *,
-                                                struct userdata_struct *,
-                                                struct nmb_name *,
-                                                uint16_t,
-                                                int,
-                                                struct in_addr);
-typedef void (*register_name_fail_function)( struct subnet_record *,
-                                             struct response_record *,
-                                             struct nmb_name *);
-
-typedef void (*release_name_success_function)( struct subnet_record *,
-                                               struct userdata_struct *, 
-                                               struct nmb_name *,
-                                               struct in_addr);
-typedef void (*release_name_fail_function)( struct subnet_record *,
-                                            struct response_record *, 
-                                            struct nmb_name *);
-
-typedef void (*refresh_name_success_function)( struct subnet_record *,
-                                               struct userdata_struct *, 
-                                               struct nmb_name *,
-                                               uint16_t,
-                                               int,
-                                               struct in_addr);
-typedef void (*refresh_name_fail_function)( struct subnet_record *,
-                                            struct response_record *,
-                                            struct nmb_name *);
-
-typedef void (*query_name_success_function)( struct subnet_record *,
-                                             struct userdata_struct *,
-                                             struct nmb_name *,
-                                             struct in_addr,
-                                             struct res_rec *answers);
-
-typedef void (*query_name_fail_function)( struct subnet_record *,
-                                          struct response_record *,    
-                                          struct nmb_name *,
-                                          int);  
-
-typedef void (*node_status_success_function)( struct subnet_record *,
-                                              struct userdata_struct *,
-                                              struct res_rec *,
-                                              struct in_addr);
-typedef void (*node_status_fail_function)( struct subnet_record *,
-                                           struct response_record *);
-
-/* Initiated name queries are recorded in this list to track any responses. */
-
-struct response_record {
-	struct response_record *next;
-	struct response_record *prev;
-
-	uint16_t response_id;
-
-	/* Callbacks for packets received or not. */ 
-	response_function resp_fn;
-	timeout_response_function timeout_fn;
-
-	/* Callbacks for the request succeeding or not. */
-	success_function success_fn;
-	fail_function fail_fn;
- 
-	struct packet_struct *packet;
-
-	struct userdata_struct *userdata;
-
-	int num_msgs;
-
-	time_t repeat_time;
-	time_t repeat_interval;
-	int    repeat_count;
-
-	/* Recursion protection. */
-	bool in_expiration_processing;
+/* A netbios node status array element. */
+struct node_status {
+	nstring name;
+	unsigned char type;
+	unsigned char flags;
 };
 
-/* A subnet structure. It contains a list of workgroups and netbios names. */
-
-/*
-   B nodes will have their own, totally separate subnet record, with their
-   own netbios name set. These do NOT interact with other subnet records'
-   netbios names.
-*/
-
-enum subnet_type {
-	NORMAL_SUBNET              = 0,  /* Subnet listed in interfaces list. */
-	UNICAST_SUBNET             = 1,  /* Subnet for unicast packets. */
-	REMOTE_BROADCAST_SUBNET    = 2,  /* Subnet for remote broadcasts. */
-	WINS_SERVER_SUBNET         = 3   /* Only created if we are a WINS server. */
-};
-
-struct subnet_record {
-	struct subnet_record *next;
-	struct subnet_record *prev;
-
-	char  *subnet_name;      /* For Debug identification. */
-	enum subnet_type type;   /* To catagorize the subnet. */
-
-	struct work_record     *workgrouplist; /* List of workgroups. */
-	struct name_record     *namelist;   /* List of netbios names. */
-	struct response_record *responselist;  /* List of responses expected. */
-
-	bool namelist_changed;
-	bool work_changed;
-
-	struct in_addr bcast_ip;
-	struct in_addr mask_ip;
-	struct in_addr myip;
-	int nmb_sock;               /* socket to listen for unicast 137. */
-	int nmb_bcast;              /* socket to listen for broadcast 137. */
-	int dgram_sock;             /* socket to listen for unicast 138. */
-	int dgram_bcast;            /* socket to listen for broadcast 138. */
+/* The extra info from a NetBIOS node status query */
+struct node_status_extra {
+	unsigned char mac_addr[6];
+	/* There really is more here ... */
 };
 
 /* A resource record. */
@@ -564,66 +286,4 @@ struct packet_struct
 #define ANN_ResetBrowserState       14
 #define ANN_LocalMasterAnnouncement 15
 
-
-/* Broadcast packet announcement intervals, in minutes. */
-
-/* Attempt to add domain logon and domain master names. */
-#define CHECK_TIME_ADD_DOM_NAMES 5 
-
-/* Search for master browsers of workgroups samba knows about, 
-   except default. */


-- 
Samba Shared Repository



More information about the samba-cvs mailing list