+/****************************************************************************
+ add the internet group <1c> domain logon names by wins unicast and broadcast.
+ ****************************************************************************/
+void add_domain_logon_names(void)
+{
+ struct subnet_record *d;
+
+ if (!lp_domain_logons()) return;
+
+ for (d = FIRST_SUBNET; d; d = NEXT_SUBNET_INCLUDING_WINS(d))
+ {
+ struct work_record *work = find_workgroupstruct(d, myworkgroup, True);
+
+ if (work && work->log_state == LOGON_NONE)
+ {
+ struct nmb_name n;
+ make_nmb_name(&n,myworkgroup,0x1c,scope);
+
+ if (!find_name(d->namelist, &n, FIND_SELF))
+ {
+ /* logon servers are group names. don't expect failure */
+
+ DEBUG(0,("%s attempting to become logon server for %s %s\n",
+ timestring(), myworkgroup, inet_ntoa(d->bcast_ip)));
+
+ become_logon_server(d, work);
+ }
+ }
+ }
+}
+
+
+/****************************************************************************
+ add the <1b> domain master names by broadcast.
+ ****************************************************************************/
+void add_domain_master_bcast(void)
+{
+ struct subnet_record *d;
+
+ if (!lp_domain_master()) return;
+
+ for (d = FIRST_SUBNET; d; d = NEXT_SUBNET_EXCLUDING_WINS(d))
+ {
+ struct work_record *work = find_workgroupstruct(d, myworkgroup, True);
+
+ if (work && work->dom_state == DOMAIN_NONE)
+ {
+ struct nmb_name n;
+ make_nmb_name(&n,myworkgroup,0x1b,scope);
+
+ if (!find_name(d->namelist, &n, FIND_SELF))
+ {
+ DEBUG(0,("%s add_domain_names: attempting to become domain \
+master browser on workgroup %s %s\n",
+ timestring(), myworkgroup, inet_ntoa(d->bcast_ip)));
+
+ /* send out a query to establish whether there's a
+ domain controller on the local subnet. if not,
+ we can become a domain controller. it's only
+ polite that we check, before claiming the
+ NetBIOS name 0x1b.
+ */
+
+ DEBUG(0,("add_domain_names:querying subnet %s \
+for domain master on workgroup %s\n",
+ inet_ntoa(d->bcast_ip), myworkgroup));
+
+ queue_netbios_packet(d,ClientNMB,NMB_QUERY,
+ NAME_QUERY_DOMAIN,
+ myworkgroup, 0x1b,
+ 0, 0,0,NULL,NULL,
+ True, False,
+ d->bcast_ip, d->bcast_ip);
+ }
+ }
+ }
+}
+
+
+/****************************************************************************
+ add the <1b> domain master name by wins unicast.
+ ****************************************************************************/
+void add_domain_master_wins(void)
+{
+ struct work_record *work;
+
+ if (!lp_domain_master() || wins_subnet == NULL) return;
+
+ work = find_workgroupstruct(wins_subnet, myworkgroup, True);
+
+ if (work && work->dom_state == DOMAIN_NONE)
+ {
+ struct nmb_name n;
+ make_nmb_name(&n,myworkgroup,0x1b,scope);
+
+ if (!find_name(wins_subnet->namelist, &n, FIND_SELF))
+ {
+ DEBUG(0,("%s add_domain_names: attempting to become domain \
+master browser on workgroup %s %s\n",
+ timestring(), myworkgroup, inet_ntoa(wins_subnet->bcast_ip)));
+
+ if (lp_wins_support())
+ {
+ /* use the wins server's capabilities (indirectly). if
+ someone has already registered the domain<1b>
+ name with the WINS server, then the WINS
+ server's job is to _check_ that the owner still
+ wants it, before giving it away.
+ */
+
+ DEBUG(1,("%s initiate become domain master for %s\n",
+ timestring(), myworkgroup));
+
+ become_domain_master(wins_subnet, work);
+ }
+ else
+ {
+ /* send out a query to establish whether there's a
+ domain controller on the WINS subnet. if not,
+ we can become a domain controller. it's only
+ polite that we check, before claiming the
+ NetBIOS name 0x1b.
+ */
+
+ DEBUG(0,("add_domain_names:querying WINS \
+for domain master on workgroup %s\n", myworkgroup));
+
+ queue_netbios_pkt_wins(ClientNMB,NMB_QUERY,
+ NAME_QUERY_DOMAIN,
+ myworkgroup, 0x1b,
+ 0, 0,0,NULL,NULL,
+ False, True, ipzero, ipzero);
+ }
+ }
+ }
+}
+
+