예제 #1
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);
} 
예제 #2
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);
		}
	}
}
예제 #3
0
/****************************************************************************
As a domain master browser, do a sync with a local master browser.
**************************************************************************/
static void sync_with_lmb(struct browse_cache_record *browc)
{                     
  struct work_record *work;

  if( !(work = find_workgroup_on_subnet(unicast_subnet, browc->work_group)) )
  {
    if( DEBUGLVL( 0 ) )
    {
      dbgtext( "sync_with_lmb:\n" );
      dbgtext( "Failed to get a workgroup for a local master browser " );
      dbgtext( "cache entry workgroup " );
      dbgtext( "%s, server %s\n", browc->work_group, browc->lmb_name );
    }
    return;
  }

  /* We should only be doing this if we are a domain master browser for
     the given workgroup. Ensure this is so. */

  if(!AM_DOMAIN_MASTER_BROWSER(work))
  {
    if( DEBUGLVL( 0 ) )
    {
      dbgtext( "sync_with_lmb:\n" );
      dbgtext( "We are trying to sync with a local master browser " );
      dbgtext( "%s for workgroup %s\n", browc->lmb_name, browc->work_group );
      dbgtext( "and we are not a domain master browser on this workgroup.\n" );
      dbgtext( "Error!\n" );
    }
    return;
  }

  if( DEBUGLVL( 2 ) )
  {
    dbgtext( "sync_with_lmb:\n" );
    dbgtext( "Initiating sync with local master browser " );
    dbgtext( "%s<0x20> at IP %s ", browc->lmb_name, inet_ntoa(browc->ip) );
    dbgtext( "for workgroup %s\n", browc->work_group );
  }

  sync_browse_lists(work, browc->lmb_name, 0x20, browc->ip, True, True);

  browc->sync_time += (CHECK_TIME_DMB_TO_LMB_SYNC * 60);
}