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
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
+#include "../librpc/gen_ndr/svcctl.h"
+#include "nmbd/nmbd.h"
-extern struct in_addr allones_ip;
-
-extern uint16 samba_nb_type; /* Samba's NetBIOS type. */
+extern uint16_t samba_nb_type; /* Samba's NetBIOS type. */
static void become_domain_master_browser_bcast(const char *);
/* Set the state back to DOMAIN_NONE. */
work->dom_state = DOMAIN_NONE;
- if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) {
+ if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) {
DEBUG(0,("become_domain_master_fail: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname(), work->work_group, subrec->subnet_name));
+ lp_netbios_name(), work->work_group, subrec->subnet_name));
return;
}
static void become_domain_master_stage2(struct subnet_record *subrec,
struct userdata_struct *userdata,
struct nmb_name *registered_name,
- uint16 nb_flags,
+ uint16_t nb_flags,
int ttl, struct in_addr registered_ip)
{
unstring regname;
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname())) == NULL) {
+ if((servrec = find_server_in_workgroup( work, lp_netbios_name())) == NULL) {
DEBUG(0,("become_domain_master_stage2: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname(), regname, subrec->subnet_name));
+ lp_netbios_name(), regname, subrec->subnet_name));
work->dom_state = DOMAIN_NONE;
return;
}
subrec->work_changed = True;
if( DEBUGLVL( 0 ) ) {
- dbgtext( "*****\n\nSamba server %s ", global_myname() );
+ dbgtext( "*****\n\nSamba server %s ", lp_netbios_name() );
dbgtext( "is now a domain master browser for " );
dbgtext( "workgroup %s ", work->work_group );
dbgtext( "on subnet %s\n\n*****\n", subrec->subnet_name );
if( subrec == unicast_subnet ) {
struct nmb_name nmbname;
struct in_addr my_first_ip;
- struct in_addr *nip;
+ const struct in_addr *nip;
/* Put our name and first IP address into the
workgroup struct as domain master browser. This
will stop us syncing with ourself if we are also
a local master browser. */
- make_nmb_name(&nmbname, global_myname(), 0x20);
+ make_nmb_name(&nmbname, lp_netbios_name(), 0x20);
work->dmb_name = nmbname;
- /* Pick the first interface ip address as the domain master browser ip. */
- nip = iface_n_ip(0);
+ /* Pick the first interface IPv4 address as the domain master
+ * browser ip. */
+ nip = first_ipv4_iface();
if (!nip) {
- DEBUG(0,("become_domain_master_stage2: Error. iface_n_ip returned NULL\n"));
+ DEBUG(0,("become_domain_master_stage2: "
+ "Error. get_interface returned NULL\n"));
return;
}
-
my_first_ip = *nip;
putip((char *)&work->dmb_addr, &my_first_ip);
static void become_domain_master_query_success(struct subnet_record *subrec,
struct userdata_struct *userdata,
- struct nmb_name *nmbname, struct in_addr ip,
+ struct nmb_name *nmbname, struct in_addr ip,
struct res_rec *rrec)
{
unstring name;
+ struct in_addr allones_ip;
+
pull_ascii_nstring(name, sizeof(name), nmbname->name);
/* If the given ip is not ours, then we can't become a domain
/* BUG note. Samba 1.9.16p11 servers seem to return the broadcast
address or zero ip for this query. Pretend this is ok. */
- if(ismyip(ip) || ip_equal(allones_ip, ip) || is_zero_ip(ip)) {
+ allones_ip.s_addr = htonl(INADDR_BROADCAST);
+
+ if(ismyip_v4(ip) || ip_equal_v4(allones_ip, ip) || is_zero_ip_v4(ip)) {
if( DEBUGLVL( 3 ) ) {
dbgtext( "become_domain_master_query_success():\n" );
dbgtext( "Our address (%s) ", inet_ntoa(ip) );
lastrun = t;
/* Do the "internet group" - <1c> names. */
- if (lp_domain_logons())
+ if (IS_DC)
add_logon_names();
/* Do the domain master names. */