Beispiel #1
0
void announce_and_sync_with_domain_master_browser( struct subnet_record *subrec,
                                                   struct work_record *work)
{
  struct nmb_name nmbname;

  /* Only do this if we are using a WINS server. */
  if(we_are_a_wins_client() == False)
  {
    if( DEBUGLVL( 10 ) )
    {
      dbgtext( "announce_and_sync_with_domain_master_browser:\n" );
      dbgtext( "Ignoring, as we are not a WINS client.\n" );
    }
    return;
  }

  make_nmb_name(&nmbname,work->work_group,0x1b);

  /* First, query for the WORKGROUP<1b> name from the WINS server. */
  query_name(unicast_subnet, nmbname.name, nmbname.name_type,
             find_domain_master_name_query_success,
             find_domain_master_name_query_fail,
             NULL);

}
Beispiel #2
0
void collect_all_workgroup_names_from_wins_server(time_t t)
{
	static time_t lastrun = 0;
	struct work_record *work;

	/* Only do this if we are using a WINS server. */
	if(we_are_a_wins_client() == False)
		return;

	/* Check to see if we are a domain master browser on the unicast subnet. */
	if((work = find_workgroup_on_subnet( unicast_subnet, lp_workgroup())) == NULL) {
		if( DEBUGLVL( 0 ) ) {
			dbgtext( "collect_all_workgroup_names_from_wins_server:\n" );
			dbgtext( "Cannot find my workgroup %s ", lp_workgroup() );
			dbgtext( "on subnet %s.\n", unicast_subnet->subnet_name );
		}
		return;
	}

	if(!AM_DOMAIN_MASTER_BROWSER(work))
		return;

	if ((lastrun != 0) && (t < lastrun + (15 * 60)))
		return;
     
	lastrun = t;

	/* First, query for the *<1b> name from the WINS server. */
	query_name(unicast_subnet, "*", 0x1b,
		find_all_domain_master_names_query_success,
		find_all_domain_master_names_query_fail,
		NULL);
} 
Beispiel #3
0
void sync_all_dmbs(time_t t)
{
	static time_t lastrun = 0;
	struct work_record *work;
	int count=0;

	/* Only do this if we are using a WINS server. */
	if(we_are_a_wins_client() == False)
		return;

	/* Check to see if we are a domain master browser on the
           unicast subnet. */
	work = find_workgroup_on_subnet(unicast_subnet, lp_workgroup());
	if (!work)
		return;

	if (!AM_DOMAIN_MASTER_BROWSER(work))
		return;

	if ((lastrun != 0) && (t < lastrun + (5 * 60)))
		return;
     
	/* count how many syncs we might need to do */
	for (work=unicast_subnet->workgrouplist; work; work = work->next) {
		if (strcmp(lp_workgroup(), work->work_group)) {
			count++;
		}
	}

	/* sync with a probability of 1/count */
	for (work=unicast_subnet->workgrouplist; work; work = work->next) {
		if (strcmp(lp_workgroup(), work->work_group)) {
			unstring dmb_name;

			if (((unsigned)sys_random()) % count != 0)
				continue;

			lastrun = t;

			if (!work->dmb_name.name[0]) {
				/* we don't know the DMB - assume it is
				   the same as the unicast local master */
				make_nmb_name(&work->dmb_name, 
					      work->local_master_browser_name,
					      0x20);
			}

			pull_ascii_nstring(dmb_name, sizeof(dmb_name), work->dmb_name.name);

			DEBUG(3,("Initiating DMB<->DMB sync with %s(%s)\n",
				 dmb_name, inet_ntoa(work->dmb_addr)));

			sync_browse_lists(work, 
					  dmb_name,
					  work->dmb_name.name_type, 
					  work->dmb_addr, False, False);
		}
	}
}
Beispiel #4
0
struct subnet_record *get_next_subnet_maybe_unicast(struct subnet_record *subrec)
{
	if(subrec == unicast_subnet)
		return NULL;
	else if((subrec->next == NULL) && we_are_a_wins_client())
		return unicast_subnet;
	else
		return subrec->next;
}
Beispiel #5
0
struct subnet_record *get_next_subnet_maybe_unicast_or_wins_server(struct subnet_record *subrec)
{
	if(subrec == unicast_subnet) {
		if(wins_server_subnet)
			return wins_server_subnet;
		else
			return NULL;
	}

	if(wins_server_subnet && subrec == wins_server_subnet)
		return NULL;

	if((subrec->next == NULL) && we_are_a_wins_client())
		return unicast_subnet;
	else
		return subrec->next;
}
Beispiel #6
0
void announce_myself_to_domain_master_browser(time_t t)
{
    struct subnet_record *subrec;
    struct work_record *work;

    if(!we_are_a_wins_client())
    {
        DEBUG(10,("announce_myself_to_domain_master_browser: no unicast subnet, ignoring.\n"));
        return;
    }

    if (!announce_timer_last)
        announce_timer_last = t;

    if ((t-announce_timer_last) < (CHECK_TIME_MST_ANNOUNCE * 60))
    {
        DEBUG(10,("announce_myself_to_domain_master_browser: t (%d) - last(%d) < %d\n",
                  (int)t, (int)announce_timer_last,
                  CHECK_TIME_MST_ANNOUNCE * 60 ));
        return;
    }

    announce_timer_last = t;

    /* Look over all our broadcast subnets to see if any of them
       has the state set as local master browser. */

    for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec))
    {
        for (work = subrec->workgrouplist; work; work = work->next)
        {
            if (AM_LOCAL_MASTER_BROWSER(work))
            {
                DEBUG(4,( "announce_myself_to_domain_master_browser: I am a local master browser for \
workgroup %s on subnet %s\n", work->work_group, subrec->subnet_name));

                /* Look in nmbd_browsersync.c for the rest of this code. */
                announce_and_sync_with_domain_master_browser(subrec, work);
            }
        }
    }
}