2 Unix SMB/Netbios implementation.
4 NBT netbios routines to synchronise browse lists
5 Copyright (C) Andrew Tridgell 1994-1997
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 extern int DEBUGLEVEL
;
27 static struct work_record
*call_w
;
28 static struct subnet_record
*call_d
;
30 /*******************************************************************
31 This is the NetServerEnum callback
32 ******************************************************************/
33 static void callback(char *sname
, uint32 stype
, char *comment
)
35 struct work_record
*w
= call_w
;
37 stype
&= ~SV_TYPE_LOCAL_LIST_ONLY
;
39 if (stype
& SV_TYPE_DOMAIN_ENUM
) {
40 /* creates workgroup on remote subnet */
41 if ((w
= find_workgroupstruct(call_d
,sname
,True
))) {
42 announce_request(w
, call_d
->bcast_ip
);
47 add_server_entry(call_d
,w
,sname
,stype
,
48 lp_max_ttl(),comment
,False
);
53 /*******************************************************************
54 synchronise browse lists with another browse server.
56 log in on the remote server's SMB port to their IPC$ service,
57 do a NetServerEnum and update our server and workgroup databases.
58 ******************************************************************/
59 void sync_browse_lists(struct subnet_record
*d
, struct work_record
*work
,
60 char *name
, int nm_type
, struct in_addr ip
, BOOL local
)
62 extern fstring local_machine
;
64 static struct cli_state cli
;
65 uint32 local_type
= local
? SV_TYPE_LOCAL_LIST_ONLY
: 0;
67 if (!d
|| !work
) return;
69 if(d
!= wins_client_subnet
) {
70 DEBUG(0,("sync_browse_lists: ERROR sync requested on non-WINS subnet.\n"));
74 DEBUG(2,("sync_browse_lists: Sync browse lists with %s for %s %s\n",
75 name
, work
->work_group
, inet_ntoa(ip
)));
77 if (!cli_initialise(&cli
) || !cli_connect(&cli
, name
, &ip
)) {
78 DEBUG(1,("Failed to start browse sync with %s\n", name
));
81 if (!cli_session_request(&cli
, name
, nm_type
, local_machine
)) {
82 DEBUG(1,("%s rejected the browse sync session\n",name
));
87 if (!cli_negprot(&cli
)) {
88 DEBUG(1,("%s rejected the negprot\n",name
));
93 if (!cli_session_setup(&cli
, "", "", 1, "", 0, work
->work_group
)) {
94 DEBUG(1,("%s rejected the browse sync sessionsetup\n",
100 sprintf(share
,"\\\\%s\\IPC$", name
);
102 if (!cli_send_tconX(&cli
, share
, "IPC", "", 1)) {
103 DEBUG(1,("%s refused browse sync IPC$ connect\n", name
));
111 cli_NetServerEnum(&cli
, work
->work_group
,
112 local_type
|SV_TYPE_DOMAIN_ENUM
,
115 cli_NetServerEnum(&cli
, work
->work_group
,
116 local
?SV_TYPE_LOCAL_LIST_ONLY
:SV_TYPE_ALL
,