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"
-
-extern int ClientNMB;
+#include "../librpc/gen_ndr/svcctl.h"
+#include "nmbd/nmbd.h"
extern uint16 samba_nb_type;
subrec->work_changed = True;
}
+/****************************************************************************
+ Copy name to unstring. Used by create_workgroup() and find_workgroup_on_subnet().
+**************************************************************************/
+
+static void name_to_unstring(unstring unname, const char *name)
+{
+ nstring nname;
+
+ errno = 0;
+ push_ascii_nstring(nname, name);
+ if (errno == E2BIG) {
+ unstring tname;
+ pull_ascii_nstring(tname, sizeof(tname), nname);
+ strlcpy(unname, tname, sizeof(nname));
+ DEBUG(0,("name_to_nstring: workgroup name %s is too long. Truncating to %s\n",
+ name, tname));
+ } else {
+ unstrcpy(unname, name);
+ }
+}
+
/****************************************************************************
Create an empty workgroup.
**************************************************************************/
{
struct work_record *work;
struct subnet_record *subrec;
- nstring nname;
-
int t = -1;
- if((work = (struct work_record *)malloc(sizeof(*work))) == NULL) {
+ if((work = SMB_MALLOC_P(struct work_record)) == NULL) {
DEBUG(0,("create_workgroup: malloc fail !\n"));
return NULL;
}
memset((char *)work, '\0', sizeof(*work));
- errno = 0;
- push_ascii_nstring(nname, name);
- if (errno == E2BIG) {
- unstring tname;
- pull_ascii_nstring(tname, sizeof(tname), nname);
- unstrcpy(work->work_group,tname);
- DEBUG(0,("create_workgroup: workgroup name %s is too long. Truncating to %s\n",
- name, tname));
- } else {
- unstrcpy(work->work_group,name);
- }
+ name_to_unstring(work->work_group, name);
+
work->serverlist = NULL;
work->RunningElection = False;
/* No known domain master browser as yet. */
*work->dmb_name.name = '\0';
- zero_ip(&work->dmb_addr);
+ zero_ip_v4(&work->dmb_addr);
/* WfWg uses 01040b01 */
/* Win95 uses 01041501 */
remove_all_servers(work);
if (!work->serverlist) {
- if (work->prev)
- work->prev->next = work->next;
- if (work->next)
- work->next->prev = work->prev;
-
- if (subrec->workgrouplist == work)
- subrec->workgrouplist = work->next;
-
+ DLIST_REMOVE(subrec->workgrouplist, work);
ZERO_STRUCTP(work);
SAFE_FREE(work);
}
const char *name)
{
struct work_record *ret;
-
+ unstring un_name;
+
DEBUG(4, ("find_workgroup_on_subnet: workgroup search for %s on subnet %s: ",
name, subrec->subnet_name));
+ name_to_unstring(un_name, name);
+
for (ret = subrec->workgrouplist; ret; ret = ret->next) {
- if (strequal(ret->work_group,name)) {
+ if (strequal(ret->work_group,un_name)) {
DEBUGADD(4, ("found.\n"));
return(ret);
}
const char *name = my_netbios_names(i);
int stype = lp_default_server_announce() | (lp_local_master() ? SV_TYPE_POTENTIAL_BROWSER : 0 );
- if(!strequal(global_myname(), name))
+ if(!strequal(lp_netbios_name(), name))
stype &= ~(SV_TYPE_MASTER_BROWSER|SV_TYPE_POTENTIAL_BROWSER|SV_TYPE_DOMAIN_MASTER|SV_TYPE_DOMAIN_MEMBER);
create_server_on_workgroup(work,name,stype|SV_TYPE_LOCAL_LIST_ONLY, PERMANENT_TTL,
- string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH));
+ string_truncate(lp_serverstring(talloc_tos()), MAX_SERVER_STRING_LENGTH));
DEBUG(3,("initiate_myworkgroup_startup: Added server name entry %s \
on subnet %s\n", name, subrec->subnet_name));
}
Dump a copy of the workgroup database into the log file.
**************************************************************************/
-void dump_workgroups(BOOL force_write)
+void dump_workgroups(bool force_write)
{
struct subnet_record *subrec;
int debuglevel = force_write ? 0 : 4;
expire_servers(work, t);
if ((work->serverlist == NULL) && (work->death_time != PERMANENT_TTL) &&
- ((t == -1) || (work->death_time < t))) {
+ ((t == (time_t)-1) || (work->death_time < t))) {
DEBUG(3,("expire_workgroups_and_servers: Removing timed out workgroup %s\n",
work->work_group));
remove_workgroup_from_subnet(subrec, work);