void announce_remote(time_t t) { char *s; const char *ptr; static time_t last_time = 0; pstring s2; struct in_addr addr; char *comment; int stype = lp_default_server_announce(); if (last_time && (t < (last_time + REMOTE_ANNOUNCE_INTERVAL))) return; last_time = t; s = lp_remote_announce(); if (!*s) return; comment = string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH); for (ptr=s; next_token(&ptr,s2,NULL,sizeof(s2)); ) { /* The entries are of the form a.b.c.d/WORKGROUP with WORKGROUP being optional */ const char *wgroup; char *pwgroup; int i; pwgroup = strchr_m(s2,'/'); if (pwgroup) *pwgroup++ = 0; if (!pwgroup || !*pwgroup) wgroup = lp_workgroup(); else wgroup = pwgroup; addr = *interpret_addr2(s2); /* Announce all our names including aliases */ /* Give the ip address as the address of our first broadcast subnet. */ for(i=0; my_netbios_names(i); i++) { const char *name = my_netbios_names(i); DEBUG(5,("announce_remote: Doing remote announce for server %s to IP %s.\n", name, inet_ntoa(addr) )); send_announcement(FIRST_SUBNET, ANN_HostAnnouncement, name, /* From nbt name. */ wgroup, 0x1d, /* To nbt name. */ addr, /* To ip. */ REMOTE_ANNOUNCE_INTERVAL, /* Time until next announce. */ name, /* Name to announce. */ stype, /* Type field. */ comment); } } }
bool init_names(void) { int n; if (!set_netbios_aliases(lp_netbios_aliases())) { DEBUG( 0, ( "init_names: malloc fail.\n" ) ); return False; } set_local_machine_name(lp_netbios_name(),false); DEBUG( 5, ("Netbios name list:-\n") ); for( n=0; my_netbios_names(n); n++ ) { DEBUGADD( 5, ("my_netbios_names[%d]=\"%s\"\n", n, my_netbios_names(n) ) ); } return( True ); }
bool set_netbios_aliases(const char **str_array) { size_t namecount; /* Work out the max number of netbios aliases that we have */ for( namecount=0; str_array && (str_array[namecount] != NULL); namecount++ ) ; if ( lp_netbios_name() && *lp_netbios_name()) namecount++; /* Allocate space for the netbios aliases */ if (!allocate_my_netbios_names_array(namecount)) return False; /* Use the global_myname string first */ namecount=0; if ( lp_netbios_name() && *lp_netbios_name()) { set_my_netbios_names( lp_netbios_name(), namecount ); namecount++; } if (str_array) { size_t i; for ( i = 0; str_array[i] != NULL; i++) { size_t n; bool duplicate = False; /* Look for duplicates */ for( n=0; n<namecount; n++ ) { if( strequal( str_array[i], my_netbios_names(n) ) ) { duplicate = True; break; } } if (!duplicate) { if (!set_my_netbios_names(str_array[i], namecount)) return False; namecount++; } } } return True; }