1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

backout all the changes to nmbd.

The 1.9.16 tree is now back to 1.9.16p2 as far as nmbd is concerned
apart from a small change that fixes the announce type in two places.
(This used to be commit 45e66a69d3)
This commit is contained in:
Andrew Tridgell 1996-10-02 15:41:30 +00:00
parent 5a2f52b79e
commit afd08462ad
29 changed files with 2008 additions and 2440 deletions

View File

@ -3787,12 +3787,10 @@ static BOOL list_servers(char *wk_grp)
for (i=0;i<count;i++) { for (i=0;i<count;i++) {
char *sname = p2; char *sname = p2;
uint32 stype = IVAL(p2,18);
int comment_offset = IVAL(p2,22) & 0xFFFF; int comment_offset = IVAL(p2,22) & 0xFFFF;
printf("\t%-16.16s %s (%8x)\n", printf("\t%-16.16s %s\n",
sname, sname,
comment_offset?rdata+comment_offset-converter:"", comment_offset?rdata+comment_offset-converter:"");
stype);
ok=True; ok=True;
p2 += 26; p2 += 26;
@ -3828,12 +3826,10 @@ static BOOL list_servers(char *wk_grp)
for (i=0;i<count;i++) { for (i=0;i<count;i++) {
char *sname = p2; char *sname = p2;
uint32 stype = IVAL(p2,18);
int comment_offset = IVAL(p2,22) & 0xFFFF; int comment_offset = IVAL(p2,22) & 0xFFFF;
printf("\t%-16.16s %s (%8x)\n", printf("\t%-16.16s %s\n",
sname, sname,
comment_offset?rdata+comment_offset-converter:"", comment_offset?rdata+comment_offset-converter:"");
stype);
ok=True; ok=True;
p2 += 26; p2 += 26;

View File

@ -54,19 +54,6 @@
#define NB_HFLAG 0x60 /* microsoft 'hybrid' node type */ #define NB_HFLAG 0x60 /* microsoft 'hybrid' node type */
#define NB_FLGMSK 0x60 #define NB_FLGMSK 0x60
#define WG_BROWSE_SIGNATURE 0x017e
#define WG_BROWSE_VERSION 0xff08
#define HOST_BROWSE_SIGNATURE 0xaa55
#define HOST_BROWSE_VERSION 0x010f
#define WG_MAJOR_VERSION 0x03
#define WG_MINOR_VERSION 0x0a
#define HOST_MAJOR_VERSION 0x04 /* nt/as host version */
#define HOST_MINOR_VERSION 0x01 /* one better than current nt/as version */
#define REFRESH_TIME (15*60) #define REFRESH_TIME (15*60)
#define NAME_POLL_REFRESH_TIME (5*60) #define NAME_POLL_REFRESH_TIME (5*60)
#define NAME_POLL_INTERVAL 15 #define NAME_POLL_INTERVAL 15
@ -86,7 +73,7 @@
/* server type identifiers */ /* server type identifiers */
#define AM_MASTER(work) (work->ServerType & SV_TYPE_MASTER_BROWSER) #define AM_MASTER(work) (work->ServerType & SV_TYPE_MASTER_BROWSER)
#define AM_BACKUP(work) (work->ServerType & SV_TYPE_BACKUP_BROWSER) #define AM_BACKUP(work) (work->ServerType & SV_TYPE_BACKUP_BROWSER)
#define AM_DMBRSE(work) (work->ServerType & SV_TYPE_DOMAIN_MASTER) #define AM_DOMCTL(work) (work->ServerType & SV_TYPE_DOMAIN_CTRL)
/* microsoft browser NetBIOS name */ /* microsoft browser NetBIOS name */
#define MSBROWSE "\001\002__MSBROWSE__\002" #define MSBROWSE "\001\002__MSBROWSE__\002"
@ -134,14 +121,6 @@ struct nmb_name {
int name_type; int name_type;
}; };
/* A server name and comment. */
struct server_identity
{
char *name;
char *comment;
struct server_identity *next;
};
/* a netbios flags + ip address structure */ /* a netbios flags + ip address structure */
/* this is used for multi-homed systems and for internet group names */ /* this is used for multi-homed systems and for internet group names */
struct nmb_ip struct nmb_ip
@ -172,9 +151,9 @@ struct browse_cache_record
struct browse_cache_record *next; struct browse_cache_record *next;
struct browse_cache_record *prev; struct browse_cache_record *prev;
char name[17]; pstring name;
int type; int type;
char group[17]; pstring group;
struct in_addr ip; struct in_addr ip;
time_t sync_time; time_t sync_time;
BOOL synced; BOOL synced;
@ -204,7 +183,7 @@ struct work_record
enum master_state state; enum master_state state;
/* work group info */ /* work group info */
char work_group[17]; fstring work_group;
int token; /* used when communicating with backup browsers */ int token; /* used when communicating with backup browsers */
int ServerType; int ServerType;
@ -235,18 +214,17 @@ struct response_record
int fd; int fd;
int quest_type; int quest_type;
struct nmb_name name; struct nmb_name name;
struct nmb_ip reply; int nb_flags;
time_t ttl; time_t ttl;
enum name_source source;
int token; /* unique workgroup token id */
int server_type; int server_type;
char my_name[17]; fstring my_name;
char my_comment[50]; fstring my_comment;
BOOL bcast; BOOL bcast;
BOOL recurse; BOOL recurse;
struct in_addr send_ip; struct in_addr send_ip;
struct in_addr reply_to_ip;
int num_msgs; int num_msgs;

View File

@ -124,7 +124,6 @@ char *lp_smbrun(void);
char *lp_configfile(void); char *lp_configfile(void);
char *lp_smb_passwd_file(void); char *lp_smb_passwd_file(void);
char *lp_serverstring(void); char *lp_serverstring(void);
char *lp_server_comment(void);
char *lp_printcapname(void); char *lp_printcapname(void);
char *lp_lockdir(void); char *lp_lockdir(void);
char *lp_rootdir(void); char *lp_rootdir(void);
@ -147,7 +146,6 @@ char *lp_interfaces(void);
char *lp_socket_address(void); char *lp_socket_address(void);
BOOL lp_wins_support(void); BOOL lp_wins_support(void);
BOOL lp_wins_proxy(void); BOOL lp_wins_proxy(void);
BOOL lp_local_master(void);
BOOL lp_domain_master(void); BOOL lp_domain_master(void);
BOOL lp_domain_logons(void); BOOL lp_domain_logons(void);
BOOL lp_preferred_master(void); BOOL lp_preferred_master(void);
@ -294,8 +292,9 @@ int reply_sendend(char *inbuf,char *outbuf);
/*The following definitions come from nameannounce.c */ /*The following definitions come from nameannounce.c */
void announce_request(struct work_record *work, struct in_addr ip); void announce_request(struct work_record *work, struct in_addr ip);
void do_announce_request(char *info, char *from_name, char *to_name, void do_announce_request(char *info, char *to_name, int announce_type,
int announce_type, int from, int to, struct in_addr dest_ip); int from,
int to, struct in_addr dest_ip);
void sync_server(enum state_type state, char *serv_name, char *work_name, void sync_server(enum state_type state, char *serv_name, char *work_name,
int name_type, int name_type,
struct in_addr ip); struct in_addr ip);
@ -303,10 +302,7 @@ void do_announce_host(int command,
char *from_name, int from_type, struct in_addr from_ip, char *from_name, int from_type, struct in_addr from_ip,
char *to_name , int to_type , struct in_addr to_ip, char *to_name , int to_type , struct in_addr to_ip,
time_t announce_interval, time_t announce_interval,
char *server_name, int server_type, char *server_name, int server_type, char *server_comment);
char major_version, char minor_version,
uint16 browse_version, uint16 browse_sig,
char *server_comment);
void remove_my_servers(void); void remove_my_servers(void);
void announce_server(struct subnet_record *d, struct work_record *work, void announce_server(struct subnet_record *d, struct work_record *work,
char *name, char *comment, time_t ttl, int server_type); char *name, char *comment, time_t ttl, int server_type);
@ -326,10 +322,8 @@ void do_browser_lists(void);
int get_num_workgroups(void); int get_num_workgroups(void);
int conf_workgroup_name_to_token(char *workgroup_name,char *default_name); int conf_workgroup_name_to_token(char *workgroup_name,char *default_name);
char *conf_workgroup_name(int token); char *conf_workgroup_name(int token);
int conf_should_preferred_master(int token);
int conf_should_workgroup_member(int token); int conf_should_workgroup_member(int token);
int conf_should_local_master(int token); int conf_should_local_master(int token);
int conf_should_domain_logon(int token);
int conf_should_domain_master(int token); int conf_should_domain_master(int token);
char *conf_browsing_alias(int token); char *conf_browsing_alias(int token);
char *conf_browsing_alias_comment(int token); char *conf_browsing_alias_comment(int token);
@ -358,7 +352,7 @@ struct name_record *add_netbios_entry(struct subnet_record *d,
char *name, int type, int nb_flags, char *name, int type, int nb_flags,
int ttl, enum name_source source, struct in_addr ip, int ttl, enum name_source source, struct in_addr ip,
BOOL new_only,BOOL wins); BOOL new_only,BOOL wins);
void check_expire_names(time_t t); void expire_names(time_t t);
struct name_record *search_for_name(struct subnet_record **d, struct name_record *search_for_name(struct subnet_record **d,
struct nmb_name *question, struct nmb_name *question,
struct in_addr ip, int Time, int search); struct in_addr ip, int Time, int search);
@ -370,9 +364,8 @@ void add_response_record(struct subnet_record *d,
void remove_response_record(struct subnet_record *d, void remove_response_record(struct subnet_record *d,
struct response_record *n); struct response_record *n);
struct response_record *make_response_queue_record(enum state_type state, struct response_record *make_response_queue_record(enum state_type state,
int id,uint16 fd, int quest_type, int id,uint16 fd,
int token, char *name,int type, int quest_type, char *name,int type, int nb_flags, time_t ttl,
enum name_source source, int nb_flags, time_t ttl,
int server_type, char *my_name, char *my_comment, int server_type, char *my_name, char *my_comment,
BOOL bcast,BOOL recurse, BOOL bcast,BOOL recurse,
struct in_addr send_ip, struct in_addr reply_to_ip); struct in_addr send_ip, struct in_addr reply_to_ip);
@ -396,9 +389,7 @@ void expire_servers(time_t t);
struct subnet_record *find_subnet(struct in_addr bcast_ip); struct subnet_record *find_subnet(struct in_addr bcast_ip);
struct subnet_record *find_req_subnet(struct in_addr ip, BOOL bcast); struct subnet_record *find_req_subnet(struct in_addr ip, BOOL bcast);
void add_subnet_interfaces(void); void add_subnet_interfaces(void);
void add_workgroup_to_subnet(char *group, struct in_addr bcast_ip, void add_my_subnets(char *group);
struct in_addr mask_ip);
void add_workgroups_to_subnets();
struct subnet_record *add_subnet_entry(struct in_addr bcast_ip, struct subnet_record *add_subnet_entry(struct in_addr bcast_ip,
struct in_addr mask_ip, struct in_addr mask_ip,
char *name, BOOL add, BOOL lmhosts); char *name, BOOL add, BOOL lmhosts);
@ -420,9 +411,8 @@ void browser_gone(char *work_name, struct in_addr ip);
void send_election(struct subnet_record *d, char *group,uint32 criterion, void send_election(struct subnet_record *d, char *group,uint32 criterion,
int timeup,char *name); int timeup,char *name);
void name_unregister_work(struct subnet_record *d, char *name, int name_type); void name_unregister_work(struct subnet_record *d, char *name, int name_type);
void name_register_work(struct subnet_record *d, int token, void name_register_work(struct subnet_record *d, char *name, int name_type,
char *name, int name_type, enum name_source source, int nb_flags, time_t ttl, struct in_addr ip, BOOL bcast);
struct nmb_ip *data, time_t ttl, struct in_addr ip, BOOL bcast);
void become_master(struct subnet_record *d, struct work_record *work); void become_master(struct subnet_record *d, struct work_record *work);
void become_nonmaster(struct subnet_record *d, struct work_record *work, void become_nonmaster(struct subnet_record *d, struct work_record *work,
int remove_type); int remove_type);
@ -437,7 +427,7 @@ void process_logon_packet(struct packet_struct *p,char *buf,int len);
/*The following definitions come from namepacket.c */ /*The following definitions come from namepacket.c */
void debug_browse_data(char *outbuf, int len); void debug_browse_data(char *outbuf, int len);
BOOL initiate_netbios_packet(uint16 id, void initiate_netbios_packet(uint16 *id,
int fd,int quest_type,char *name,int name_type, int fd,int quest_type,char *name,int name_type,
int nb_flags,BOOL bcast,BOOL recurse, int nb_flags,BOOL bcast,BOOL recurse,
struct in_addr to_ip); struct in_addr to_ip);
@ -463,30 +453,27 @@ BOOL name_query(int fd,char *name,int name_type,
/*The following definitions come from nameresp.c */ /*The following definitions come from nameresp.c */
void update_name_trn_id(void);
void expire_netbios_response_entries(); void expire_netbios_response_entries();
void queue_netbios_pkt_wins(struct subnet_record *d, struct response_record *queue_netbios_pkt_wins(struct subnet_record *d,
int fd,int quest_type,enum state_type state, int fd,int quest_type,enum state_type state,
int token, char *name,int name_type, char *name,int name_type,int nb_flags, time_t ttl,
enum name_source source, int nb_flags, time_t ttl,
int server_type, char *my_name, char *my_comment, int server_type, char *my_name, char *my_comment,
BOOL bcast,BOOL recurse, BOOL bcast,BOOL recurse,
struct in_addr send_ip, struct in_addr reply_to_ip); struct in_addr send_ip, struct in_addr reply_to_ip);
void queue_netbios_packet(struct subnet_record *d, struct response_record *queue_netbios_packet(struct subnet_record *d,
int fd,int quest_type,enum state_type state, int fd,int quest_type,enum state_type state,char *name,
int token, char *name, int name_type, int name_type,int nb_flags, time_t ttl,
enum name_source source, int nb_flags, time_t ttl,
int server_type, char *my_name, char *my_comment, int server_type, char *my_name, char *my_comment,
BOOL bcast,BOOL recurse, BOOL bcast,BOOL recurse,
struct in_addr send_ip, struct in_addr reply_to_ip); struct in_addr send_ip, struct in_addr reply_to_ip);
/*The following definitions come from nameserv.c */ /*The following definitions come from nameserv.c */
void remove_name_entry(struct subnet_record *d, int token, char *name,int type); void remove_name_entry(struct subnet_record *d, char *name,int type);
void add_my_name_entry(struct subnet_record *d, int token, void add_my_name_entry(struct subnet_record *d,char *name,int type,int nb_flags);
char *name,int type,int nb_flags);
void add_my_names(void); void add_my_names(void);
void remove_my_names(); void remove_my_names();
void refresh_my_names(time_t t);
void query_refresh_names(void); void query_refresh_names(void);
/*The following definitions come from nameservreply.c */ /*The following definitions come from nameservreply.c */
@ -508,18 +495,13 @@ void reply_name_query(struct packet_struct *p);
/*The following definitions come from nameservresp.c */ /*The following definitions come from nameservresp.c */
void debug_state_type(int state); void debug_state_type(int state);
void response_process(struct in_addr ip, struct subnet_record *d,
struct response_record *n,
int rcode, char *nmb_data, struct nmb_name *q_name,
time_t ttl, BOOL bcast, struct nmb_name *ans_name);
void response_netbios_packet(struct packet_struct *p); void response_netbios_packet(struct packet_struct *p);
/*The following definitions come from namework.c */ /*The following definitions come from namework.c */
void reset_server(struct work_record *work, char *name, int state, struct in_addr ip); void reset_server(char *name, int state, struct in_addr ip);
void tell_become_backup(void); void tell_become_backup(void);
BOOL same_context(struct dgram_packet *dgram); BOOL same_context(struct dgram_packet *dgram);
BOOL listening_name(struct work_record *work, struct nmb_name *n);
void process_browse_packet(struct packet_struct *p,char *buf,int len); void process_browse_packet(struct packet_struct *p,char *buf,int len);
/*The following definitions come from nmbd.c */ /*The following definitions come from nmbd.c */
@ -769,7 +751,6 @@ unsigned int Ucrit_checkPid(int pid);
int sys_select(fd_set *fds,struct timeval *tval); int sys_select(fd_set *fds,struct timeval *tval);
int sys_select(fd_set *fds,struct timeval *tval); int sys_select(fd_set *fds,struct timeval *tval);
int sys_unlink(char *fname); int sys_unlink(char *fname);
unsigned int sys_random(int max_range);
int sys_open(char *fname,int flags,int mode); int sys_open(char *fname,int flags,int mode);
DIR *sys_opendir(char *dname); DIR *sys_opendir(char *dname);
int sys_stat(char *fname,struct stat *sbuf); int sys_stat(char *fname,struct stat *sbuf);

View File

@ -380,10 +380,10 @@ typedef struct
/* used for server information: client, nameserv and ipc */ /* used for server information: client, nameserv and ipc */
struct server_info_struct struct server_info_struct
{ {
char name[17]; fstring name;
uint32 type; uint32 type;
char comment[50]; fstring comment;
char domain[17]; /* used ONLY in ipc.c NOT namework.c */ fstring domain; /* used ONLY in ipc.c NOT namework.c */
BOOL server_added; /* used ONLY in ipc.c NOT namework.c */ BOOL server_added; /* used ONLY in ipc.c NOT namework.c */
}; };

View File

@ -115,15 +115,6 @@ int sys_unlink(char *fname)
} }
/*******************************************************************
random number generator
********************************************************************/
unsigned int sys_random(int max_range)
{
return(((unsigned int)random()) % max_range);
}
/******************************************************************* /*******************************************************************
a simple open() wrapper a simple open() wrapper
********************************************************************/ ********************************************************************/

View File

@ -65,7 +65,7 @@ static void debug_nmb_res_rec(struct res_rec *res, char *hdr)
for (j = 0; j < 16; j++) for (j = 0; j < 16; j++)
{ {
if (i+j >= res->rdlength) break; if (i+j >= res->rdlength) break;
DEBUG(4, ("%02x", (unsigned char)res->rdata[i+j])); DEBUG(4, ("%02X", (unsigned char)res->rdata[i+j]));
} }
DEBUG(4, ("\n")); DEBUG(4, ("\n"));

View File

@ -23,18 +23,19 @@
14 jan 96: lkcl@pires.co.uk 14 jan 96: lkcl@pires.co.uk
added multiple workgroup domain master support added multiple workgroup domain master support
30 July 96: David.Chappell@mail.trincoll.edu
Expanded multiple workgroup domain master browser support.
*/ */
#include "includes.h" #include "includes.h"
#define TEST_CODE
extern int DEBUGLEVEL; extern int DEBUGLEVEL;
extern BOOL CanRecurse; extern BOOL CanRecurse;
extern struct in_addr ipzero; extern struct in_addr ipzero;
extern pstring myname;
extern int ClientDGRAM; extern int ClientDGRAM;
extern int ClientNMB; extern int ClientNMB;
@ -42,17 +43,14 @@ extern int ClientNMB;
extern struct subnet_record *subnetlist; extern struct subnet_record *subnetlist;
extern int updatecount; extern int updatecount;
extern int workgroup_count;
extern struct in_addr ipgrp; extern struct in_addr ipgrp;
extern pstring myname;
/**************************************************************************** /****************************************************************************
Send a announce request to the local net. send a announce request to the local net
This is called by become_master(). This purpose of this action is to
encourage servers to send us host announcements right away.
**************************************************************************/ **************************************************************************/
void announce_request(struct work_record *work, struct in_addr ip) void announce_request(struct work_record *work, struct in_addr ip)
{ {
@ -73,7 +71,8 @@ void announce_request(struct work_record *work, struct in_addr ip)
CVAL(p,0) = work->token; /* (local) unique workgroup token id */ CVAL(p,0) = work->token; /* (local) unique workgroup token id */
p++; p++;
StrnCpy(p,conf_browsing_alias(work->token),16); StrnCpy(p,myname,16);
strupper(p);
p = skip_string(p,1); p = skip_string(p,1);
/* XXXX note: if we sent the announcement request to 0x1d instead /* XXXX note: if we sent the announcement request to 0x1d instead
@ -81,17 +80,16 @@ void announce_request(struct work_record *work, struct in_addr ip)
us instead of the members of the workgroup. wha-hey! */ us instead of the members of the workgroup. wha-hey! */
send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,PTR_DIFF(p,outbuf), send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,PTR_DIFF(p,outbuf),
conf_browsing_alias(work->token),work->work_group, myname,work->work_group,0x20,0x1e,ip,*iface_ip(ip));
0x20, 0x1e,
ip,*iface_ip(ip));
} }
/**************************************************************************** /****************************************************************************
request an announcement request an announcement
**************************************************************************/ **************************************************************************/
void do_announce_request(char *info, char *from_name, char *to_name, void do_announce_request(char *info, char *to_name, int announce_type,
int announce_type, int from, int to, struct in_addr dest_ip) int from,
int to, struct in_addr dest_ip)
{ {
pstring outbuf; pstring outbuf;
char *p; char *p;
@ -109,8 +107,7 @@ void do_announce_request(char *info, char *from_name, char *to_name,
p = skip_string(p,1); p = skip_string(p,1);
send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,PTR_DIFF(p,outbuf), send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,PTR_DIFF(p,outbuf),
from_name,to_name,from,to, myname,to_name,from,to,dest_ip,*iface_ip(dest_ip));
dest_ip,*iface_ip(dest_ip));
} }
@ -122,20 +119,16 @@ void sync_server(enum state_type state, char *serv_name, char *work_name,
int name_type, int name_type,
struct in_addr ip) struct in_addr ip)
{ {
int token = conf_workgroup_name_to_token(work_name, myname);
/* with a domain master we can get the whole list (not local only list) */ /* with a domain master we can get the whole list (not local only list) */
BOOL local_only = (state != NAME_STATUS_DOM_SRV_CHK); BOOL local_only = (state != NAME_STATUS_DOM_SRV_CHK);
add_browser_entry(serv_name, name_type, work_name, 0, ip, local_only); add_browser_entry(serv_name, name_type, work_name, 0, ip, local_only);
if (state == NAME_STATUS_DOM_SRV_CHK && conf_should_local_master(token)) if (state == NAME_STATUS_DOM_SRV_CHK)
{ {
/* announce ourselves as a master browser to serv_name */ /* announce ourselves as a master browser to serv_name */
do_announce_request(conf_browsing_alias(token), /* info */ do_announce_request(myname, serv_name, ANN_MasterAnnouncement,
conf_browsing_alias(token), /* from */ 0x20, 0, ip);
serv_name, /* to */
ANN_MasterAnnouncement, 0x20, 0,ip);
} }
} }
@ -147,10 +140,7 @@ void do_announce_host(int command,
char *from_name, int from_type, struct in_addr from_ip, char *from_name, int from_type, struct in_addr from_ip,
char *to_name , int to_type , struct in_addr to_ip, char *to_name , int to_type , struct in_addr to_ip,
time_t announce_interval, time_t announce_interval,
char *server_name, int server_type, char *server_name, int server_type, char *server_comment)
char major_version, char minor_version,
uint16 browse_version, uint16 browse_sig,
char *server_comment)
{ {
pstring outbuf; pstring outbuf;
char *p; char *p;
@ -168,13 +158,12 @@ void do_announce_host(int command,
StrnCpy(p+5,server_name,16); StrnCpy(p+5,server_name,16);
strupper(p+5); strupper(p+5);
CVAL(p,21) = major_version; CVAL(p,21) = 0x02; /* major version */
CVAL(p,22) = minor_version; CVAL(p,22) = 0x02; /* minor version */
SIVAL(p,23,server_type); SIVAL(p,23,server_type);
SSVAL(p,27,0x010f); /* browse version: got from NT/AS 4.00 */
SSVAL(p,27,browse_version); SSVAL(p,29,0xaa55); /* browse signature */
SSVAL(p,29,browse_sig);
strcpy(p+31,server_comment); strcpy(p+31,server_comment);
p += 31; p += 31;
@ -205,10 +194,7 @@ void remove_my_servers(void)
struct server_record *s; struct server_record *s;
for (s = work->serverlist; s; s = s->next) for (s = work->serverlist; s; s = s->next)
{ {
if (!strequal(conf_browsing_alias(work->token),s->serv.name)) if (!strequal(myname,s->serv.name)) continue;
{
continue;
}
announce_server(d, work, s->serv.name, s->serv.comment, 0, 0); announce_server(d, work, s->serv.name, s->serv.comment, 0, 0);
} }
} }
@ -227,7 +213,6 @@ void announce_server(struct subnet_record *d, struct work_record *work,
(SV_TYPE_SERVER_UNIX, for example) (SV_TYPE_SERVER_UNIX, for example)
*/ */
uint32 domain_type = SV_TYPE_DOMAIN_ENUM|SV_TYPE_NT; uint32 domain_type = SV_TYPE_DOMAIN_ENUM|SV_TYPE_NT;
BOOL wins_iface = ip_equal(d->bcast_ip, ipgrp); BOOL wins_iface = ip_equal(d->bcast_ip, ipgrp);
if (wins_iface && server_type != 0) if (wins_iface && server_type != 0)
@ -235,13 +220,14 @@ void announce_server(struct subnet_record *d, struct work_record *work,
/* wins pseudo-ip interface */ /* wins pseudo-ip interface */
if (!AM_MASTER(work)) if (!AM_MASTER(work))
{ {
/* non-master announce by unicast to the domain master */ /* non-master announce by unicast to the domain
master */
if (!lp_wins_support() && *lp_wins_server()) if (!lp_wins_support() && *lp_wins_server())
{ {
/* look up the domain master with the WINS server */ /* look up the domain master with the WINS server */
queue_netbios_pkt_wins(d,ClientNMB,NMB_QUERY, queue_netbios_pkt_wins(d,ClientNMB,NMB_QUERY,
NAME_QUERY_ANNOUNCE_HOST, NAME_QUERY_ANNOUNCE_HOST,
work->token,work->work_group,0x1b,0,0,ttl*1000, work->work_group,0x1b,0,ttl*1000,
server_type,name,comment, server_type,name,comment,
False, False, ipzero, d->bcast_ip); False, False, ipzero, d->bcast_ip);
} }
@ -257,7 +243,9 @@ void announce_server(struct subnet_record *d, struct work_record *work,
/* XXXX any other kinds of announcements we need to consider here? /* XXXX any other kinds of announcements we need to consider here?
e.g local master browsers... no. local master browsers do e.g local master browsers... no. local master browsers do
local master announcements to their domain master. local master announcements to their domain master. they even
use WINS lookup of the domain master if another wins server
is being used!
*/ */
} }
else else
@ -271,10 +259,7 @@ void announce_server(struct subnet_record *d, struct work_record *work,
name , 0x00, d->myip, name , 0x00, d->myip,
work->work_group, 0x1e, d->bcast_ip, work->work_group, 0x1e, d->bcast_ip,
ttl*1000, ttl*1000,
name, server_type, name, server_type, comment);
HOST_MAJOR_VERSION, HOST_MINOR_VERSION,
HOST_BROWSE_VERSION, HOST_BROWSE_SIGNATURE,
comment);
DEBUG(3,("sending domain announce to %s for %s\n", DEBUG(3,("sending domain announce to %s for %s\n",
inet_ntoa(d->bcast_ip),work->work_group)); inet_ntoa(d->bcast_ip),work->work_group));
@ -287,8 +272,6 @@ void announce_server(struct subnet_record *d, struct work_record *work,
MSBROWSE, 0x01, d->bcast_ip, MSBROWSE, 0x01, d->bcast_ip,
ttl*1000, ttl*1000,
work->work_group, server_type ? domain_type : 0, work->work_group, server_type ? domain_type : 0,
WG_MAJOR_VERSION, WG_MINOR_VERSION,
WG_BROWSE_VERSION, WG_BROWSE_SIGNATURE,
name); name);
} }
} }
@ -301,10 +284,7 @@ void announce_server(struct subnet_record *d, struct work_record *work,
name , 0x00, d->myip, name , 0x00, d->myip,
work->work_group, 0x1d, d->bcast_ip, work->work_group, 0x1d, d->bcast_ip,
ttl*1000, ttl*1000,
name, server_type, name, server_type, comment);
HOST_MAJOR_VERSION, HOST_MINOR_VERSION,
HOST_BROWSE_VERSION, HOST_BROWSE_SIGNATURE,
comment);
} }
} }
} }
@ -317,6 +297,11 @@ void announce_host(void)
time_t t = time(NULL); time_t t = time(NULL);
struct subnet_record *d; struct subnet_record *d;
pstring comment; pstring comment;
char *my_name;
StrnCpy(comment, lp_serverstring(), 43);
my_name = *myname ? myname : "NoName";
for (d = subnetlist; d; d = d->next) for (d = subnetlist; d; d = d->next)
{ {
@ -328,11 +313,7 @@ void announce_host(void)
{ {
uint32 stype = work->ServerType; uint32 stype = work->ServerType;
struct server_record *s; struct server_record *s;
BOOL announce = False;
char *my_name = conf_browsing_alias(work->token);
char *my_comment = conf_browsing_alias_comment(work->token);
StrnCpy(comment, my_comment, 43);
/* must work on the code that does announcements at up to /* must work on the code that does announcements at up to
30 seconds later if a master browser sends us a request 30 seconds later if a master browser sends us a request
@ -358,14 +339,17 @@ void announce_host(void)
work->lastannounce_time = t; work->lastannounce_time = t;
for (s = work->serverlist; s; s = s->next) { for (s = work->serverlist; s; s = s->next) {
if (strequal(my_name, s->serv.name)) if (strequal(myname, s->serv.name)) {
{ announce = True;
announce_server(d,work,my_name,comment,
work->announce_interval,stype);
break; break;
} }
} }
if (announce) {
announce_server(d,work,my_name,comment,
work->announce_interval,stype);
}
if (work->needannounce) if (work->needannounce)
{ {
work->needannounce = False; work->needannounce = False;
@ -378,10 +362,10 @@ void announce_host(void)
/**************************************************************************** /****************************************************************************
announce samba as a master to all other primary domain conrollers. announce myself as a master to all other primary domain conrollers.
this actually gets done in search_and_sync_workgroups() via the this actually gets done in search_and_sync_workgroups() via the
NAME_QUERY_DOM_SRV_CHK state, if there is a response from the NAME_QUERY_DOM_SRV_CHK command, if there is a response from the
name query initiated here. see response_name_query() name query initiated here. see response_name_query()
**************************************************************************/ **************************************************************************/
void announce_master(void) void announce_master(void)
@ -402,7 +386,7 @@ void announce_master(void)
struct work_record *work; struct work_record *work;
for (work = d->workgrouplist; work; work = work->next) for (work = d->workgrouplist; work; work = work->next)
{ {
if (AM_MASTER(work) || AM_DMBRSE(work)) if (AM_MASTER(work))
{ {
am_master = True; am_master = True;
} }
@ -419,30 +403,23 @@ void announce_master(void)
struct server_record *s; struct server_record *s;
for (s = work->serverlist; s; s = s->next) for (s = work->serverlist; s; s = s->next)
{ {
if (strequal(s->serv.name, conf_browsing_alias(work->token))) continue; if (strequal(s->serv.name, myname)) continue;
/* all master browsers */ /* all DOMs (which should also be master browsers) */
if (s->serv.type & SV_TYPE_DOMAIN_MASTER) if (s->serv.type & SV_TYPE_DOMAIN_CTRL)
{ {
/* check the existence of a domain master for this workgroup, /* check the existence of a pdc for this workgroup, and if
and if one exists at the specified ip, sync with it and one exists at the specified ip, sync with it and announce
announce ourselves as a local master browser to it */ ourselves as a master browser to it */
/* exclude lp_domain_controller() from this check if it's
in our browse lists, because it's dealt with separately
*/
if (!*lp_domain_controller() || if (!*lp_domain_controller() ||
!strequal(lp_domain_controller(), s->serv.name)) !strequal(lp_domain_controller(), s->serv.name))
{ {
if (lp_wins_support() || *lp_wins_server()) if (!lp_wins_support() && *lp_wins_server())
{ {
/* query the WINS server (that may include samba itself)
to find the browse master
*/
queue_netbios_pkt_wins(d,ClientNMB,NMB_QUERY, queue_netbios_pkt_wins(d,ClientNMB,NMB_QUERY,
NAME_QUERY_DOM_SRV_CHK, NAME_QUERY_DOM_SRV_CHK,
work->token, work->work_group,0x1b,0,0,0,NULL,NULL,
work->work_group,0x1b,0,0,0,0,NULL,NULL,
False, False, ipzero, ipzero); False, False, ipzero, ipzero);
} }
else else
@ -450,13 +427,9 @@ void announce_master(void)
struct subnet_record *d2; struct subnet_record *d2;
for (d2 = subnetlist; d2; d2 = d2->next) for (d2 = subnetlist; d2; d2 = d2->next)
{ {
/* query by broadcast on every local interface
to find the browse master
*/
queue_netbios_packet(d,ClientNMB,NMB_QUERY, queue_netbios_packet(d,ClientNMB,NMB_QUERY,
NAME_QUERY_DOM_SRV_CHK, NAME_QUERY_DOM_SRV_CHK,
work->token, work->work_group,0x1b, work->work_group,0x1b,0,0,0,NULL,NULL,
0,0,0,0,NULL,NULL,
True, False, d2->bcast_ip, d2->bcast_ip); True, False, d2->bcast_ip, d2->bcast_ip);
} }
} }
@ -474,13 +447,14 @@ void announce_master(void)
if (*lp_domain_controller()) if (*lp_domain_controller())
{ {
struct in_addr ip; struct in_addr ip;
BOOL bcast = False;
ip = *interpret_addr2(lp_domain_controller()); ip = *interpret_addr2(lp_domain_controller());
/* if the ip is zero, then make the query to samba as a WINS server */ if (zero_ip(ip)) {
/* XXXX later, if this also fails, we could also do a broadcast query on ip = d->bcast_ip;
samba's local subnets bcast = True;
*/ }
DEBUG(2, ("Searching for DOM %s at %s\n", DEBUG(2, ("Searching for DOM %s at %s\n",
lp_domain_controller(), inet_ntoa(ip))); lp_domain_controller(), inet_ntoa(ip)));
@ -489,9 +463,8 @@ void announce_master(void)
one exists at the specified ip, sync with it and announce one exists at the specified ip, sync with it and announce
ourselves as a master browser to it */ ourselves as a master browser to it */
queue_netbios_pkt_wins(d,ClientNMB,NMB_QUERY,NAME_QUERY_DOM_SRV_CHK, queue_netbios_pkt_wins(d,ClientNMB,NMB_QUERY,NAME_QUERY_DOM_SRV_CHK,
work->token, work->work_group,0x1b, work->work_group,0x1b,0,0,0,NULL,NULL,
0,0,0,0,NULL,NULL, bcast, False, ip, ip);
False, False, ip, ip);
} }
} }
} }
@ -512,7 +485,6 @@ void announce_remote(void)
pstring s2; pstring s2;
struct in_addr addr; struct in_addr addr;
char *comment,*workgroup; char *comment,*workgroup;
int token;
int stype = DFLT_SERVER_TYPE; int stype = DFLT_SERVER_TYPE;
if (last_time && t < last_time + REMOTE_ANNOUNCE_INTERVAL) if (last_time && t < last_time + REMOTE_ANNOUNCE_INTERVAL)
@ -523,16 +495,13 @@ void announce_remote(void)
s = lp_remote_announce(); s = lp_remote_announce();
if (!*s) return; if (!*s) return;
comment = lp_serverstring(); /* default comment */ comment = lp_serverstring();
workgroup = lp_workgroup(); /* default workgroup name */ workgroup = lp_workgroup();
for (ptr=s; next_token(&ptr,s2,NULL); ) for (ptr=s; next_token(&ptr,s2,NULL); ) {
{
/* the entries are of the form a.b.c.d/WORKGROUP with /* the entries are of the form a.b.c.d/WORKGROUP with
WORKGROUP being optional */ WORKGROUP being optional */
char *wgroup; char *wgroup;
char *my_name;
extern pstring myname; /* samba's default NetBIOS name */
wgroup = strchr(s2,'/'); wgroup = strchr(s2,'/');
if (wgroup) *wgroup++ = 0; if (wgroup) *wgroup++ = 0;
@ -541,17 +510,10 @@ void announce_remote(void)
addr = *interpret_addr2(s2); addr = *interpret_addr2(s2);
token = conf_workgroup_name_to_token(wgroup, myname); do_announce_host(ANN_HostAnnouncement,myname,0x20,*iface_ip(addr),
my_name = conf_browsing_alias(token); wgroup,0x1e,addr,
my_name = my_name ? my_name : myname;
do_announce_host(ANN_HostAnnouncement,
my_name, 0x20, *iface_ip(addr),
wgroup , 0x1e, addr,
REMOTE_ANNOUNCE_INTERVAL, REMOTE_ANNOUNCE_INTERVAL,
my_name,stype, myname,stype,comment);
HOST_MAJOR_VERSION, HOST_MINOR_VERSION,
HOST_BROWSE_VERSION, HOST_BROWSE_SIGNATURE,
comment);
} }
} }

View File

@ -23,9 +23,6 @@
14 jan 96: lkcl@pires.co.uk 14 jan 96: lkcl@pires.co.uk
added multiple workgroup domain master support added multiple workgroup domain master support
30 July 96: David.Chappell@mail.trincoll.edu
Expanded multiple workgroup domain master browser support.
*/ */
#include "includes.h" #include "includes.h"
@ -169,7 +166,7 @@ static void start_sync_browse_entry(struct browse_cache_record *b)
struct subnet_record *d; struct subnet_record *d;
struct work_record *work; struct work_record *work;
if( (d = find_subnet(b->ip)) == (struct subnet_record *)NULL ) return; if (!(d = find_subnet(b->ip))) return;
if (!(work = find_workgroupstruct(d, b->group, False))) return; if (!(work = find_workgroupstruct(d, b->group, False))) return;
@ -182,7 +179,7 @@ static void start_sync_browse_entry(struct browse_cache_record *b)
/* see response_netbios_packet() or expire_netbios_response_entries() */ /* see response_netbios_packet() or expire_netbios_response_entries() */
queue_netbios_packet(d,ClientNMB,NMB_QUERY, queue_netbios_packet(d,ClientNMB,NMB_QUERY,
b->local?NAME_QUERY_SYNC_LOCAL:NAME_QUERY_SYNC_REMOTE, b->local?NAME_QUERY_SYNC_LOCAL:NAME_QUERY_SYNC_REMOTE,
work->token,b->group,0x20,0,0,0,0,NULL,NULL, b->group,0x20,0,0,0,NULL,NULL,
False,False,b->ip,b->ip); False,False,b->ip,b->ip);
} }

View File

@ -58,12 +58,10 @@ struct smbbrowse
char work_name[16]; /* workgroup name */ char work_name[16]; /* workgroup name */
char browsing_alias[16]; /* alias for our role in this workgroup */ char browsing_alias[16]; /* alias for our role in this workgroup */
struct server_identity *my_names; /* a list of server name we should appear here as */ struct server_identity *my_names; /* a list of server name we should appear here as */
BOOL should_workgroup_member; /* should we be a member of this workgroup? */ BOOL should_workgroup_member; /* should we try to become a member of this workgroup? */
BOOL should_local_master; /* should we be a master browser? */ BOOL should_local_master; /* should we try to become a master browser? */
BOOL should_preferred_master; /* should we initiate attempts to become a master browser? */ BOOL should_domain_master; /* should we try to become the domain master browser? */
BOOL should_domain_master; /* should we be the domain master browser? */ } ;
BOOL should_domain_logon; /* should we be the domain logon? */
};
/* The whole list */ /* The whole list */
static struct smbbrowse *smbbrowse_workgroups = (struct smbbrowse*)NULL; static struct smbbrowse *smbbrowse_workgroups = (struct smbbrowse*)NULL;
@ -89,7 +87,7 @@ static struct smbbrowse *new_workgroup(struct smbbrowse *model,
{ {
struct smbbrowse *new; struct smbbrowse *new;
if ( ! (array_size > nexttoken) ) if( ! (array_size > nexttoken) )
{ {
array_size += 10; array_size += 10;
smbbrowse_workgroups = (struct smbbrowse*)realloc(smbbrowse_workgroups, smbbrowse_workgroups = (struct smbbrowse*)realloc(smbbrowse_workgroups,
@ -98,7 +96,7 @@ static struct smbbrowse *new_workgroup(struct smbbrowse *model,
new = &smbbrowse_workgroups[nexttoken]; new = &smbbrowse_workgroups[nexttoken];
if (model != (struct smbbrowse *)NULL ) if(model != (struct smbbrowse *)NULL )
memcpy(new, model, sizeof(struct smbbrowse)); memcpy(new, model, sizeof(struct smbbrowse));
else else
memset(new, 0, sizeof(struct smbbrowse)); memset(new, 0, sizeof(struct smbbrowse));
@ -129,22 +127,22 @@ int conf_workgroup_name_to_token(char *workgroup_name,char *default_name)
int idx; int idx;
/* Look for an existing instance. */ /* Look for an existing instance. */
for (idx=0; idx < nexttoken; idx++) for(idx=0; idx < nexttoken; idx++)
{ {
if (strequal(workgroup_name, smbbrowse_workgroups[idx].work_name)) if(strequal(workgroup_name, smbbrowse_workgroups[idx].work_name))
{ {
return idx; return idx;
} }
} }
/* See if creating new ones in admissable. */ /* See if creating new ones in admissable. */
for (idx=0; idx < nexttoken; idx++) for(idx=0; idx < nexttoken; idx++)
{ {
if (strequal("*", smbbrowse_workgroups[idx].work_name)) if(strequal("*", smbbrowse_workgroups[idx].work_name))
{ {
struct smbbrowse *w = new_workgroup(&smbbrowse_workgroups[idx], struct smbbrowse *w = new_workgroup(&smbbrowse_workgroups[idx],
workgroup_name, default_name); workgroup_name, default_name);
w->should_workgroup_member = True; w->should_workgroup_member = False;
return (nexttoken - 1); return (nexttoken - 1);
} }
@ -160,7 +158,7 @@ int conf_workgroup_name_to_token(char *workgroup_name,char *default_name)
*/ */
static int range_check(int token) static int range_check(int token)
{ {
if (token < 0 || token >= nexttoken) if(token < 0 || token >= nexttoken)
{ {
DEBUG(0, ("range_check(): failed\n")); DEBUG(0, ("range_check(): failed\n"));
return True; return True;
@ -174,25 +172,12 @@ static int range_check(int token)
*/ */
char *conf_workgroup_name(int token) char *conf_workgroup_name(int token)
{ {
if (range_check(token)) if(range_check(token))
return (char*)NULL; return (char*)NULL;
return smbbrowse_workgroups[token].work_name; return smbbrowse_workgroups[token].work_name;
} }
/*
** Given a token, return True if we should try
** to become a master browser.
*/
int conf_should_preferred_master(int token)
{
if (range_check(token))
return False;
return smbbrowse_workgroups[token].should_preferred_master;
}
/* /*
** Given a token, return True if we should try ** Given a token, return True if we should try
** to become a master browser. ** to become a master browser.
@ -200,7 +185,7 @@ int conf_should_preferred_master(int token)
int conf_should_workgroup_member(int token) int conf_should_workgroup_member(int token)
{ {
if (range_check(token)) if(range_check(token))
return False; return False;
return smbbrowse_workgroups[token].should_workgroup_member; return smbbrowse_workgroups[token].should_workgroup_member;
@ -211,22 +196,12 @@ int conf_should_workgroup_member(int token)
** to become a master browser. ** to become a master browser.
*/ */
int conf_should_local_master(int token) int conf_should_local_master(int token)
{ {
if (range_check(token)) return False; if(range_check(token))
return False;
return smbbrowse_workgroups[token].should_local_master; return smbbrowse_workgroups[token].should_local_master;
} }
/*
** Given a token, return True if we should try
** to become a domain master browser.
*/
int conf_should_domain_logon(int token)
{
if (range_check(token)) return False;
return smbbrowse_workgroups[token].should_domain_logon;
}
/* /*
** Given a token, return True if we should try ** Given a token, return True if we should try
@ -234,7 +209,7 @@ int conf_should_domain_logon(int token)
*/ */
int conf_should_domain_master(int token) int conf_should_domain_master(int token)
{ {
if (range_check(token)) if(range_check(token))
return False; return False;
return smbbrowse_workgroups[token].should_domain_master; return smbbrowse_workgroups[token].should_domain_master;
@ -244,12 +219,12 @@ int conf_should_domain_master(int token)
** Given a token, return the name. ** Given a token, return the name.
*/ */
char *conf_browsing_alias(int token) char *conf_browsing_alias(int token)
{ {
if (range_check(token)) if(range_check(token))
return (char*)NULL; return (char*)NULL;
return smbbrowse_workgroups[token].browsing_alias; return smbbrowse_workgroups[token].browsing_alias;
} }
/* /*
** Return the server comment which should be used with the ** Return the server comment which should be used with the
@ -257,11 +232,11 @@ char *conf_browsing_alias(int token)
*/ */
char *conf_browsing_alias_comment(int token) char *conf_browsing_alias_comment(int token)
{ {
if (range_check(token)) if(range_check(token))
return (char*) NULL; return (char*) NULL;
return lp_server_comment(); return "Browser";
} }
/* /*
** Given an alias name for this server, return the name of the workgroup ** Given an alias name for this server, return the name of the workgroup
@ -273,11 +248,11 @@ char *conf_alias_to_workgroup(char *alias)
DEBUG(4,("alias_to_workgroup: %s", alias)); DEBUG(4,("alias_to_workgroup: %s", alias));
for (x=0; x < nexttoken; x++) for(x=0; x < nexttoken; x++)
{ {
DEBUG(4,("%s ", smbbrowse_workgroups[x].browsing_alias)); DEBUG(4,("%s ", smbbrowse_workgroups[x].browsing_alias));
if (strequal(alias, smbbrowse_workgroups[x].browsing_alias)) if(strequal(alias, smbbrowse_workgroups[x].browsing_alias))
{ {
DEBUG(4,("OK\n")); DEBUG(4,("OK\n"));
return smbbrowse_workgroups[x].work_name; return smbbrowse_workgroups[x].work_name;
@ -295,9 +270,9 @@ int conf_alias_to_token(char *alias)
{ {
int x; int x;
for (x=0; x < nexttoken; x++) for(x=0; x < nexttoken; x++)
{ {
if (strequal(alias, smbbrowse_workgroups[x].browsing_alias)) if(strequal(alias, smbbrowse_workgroups[x].browsing_alias))
{ {
return x; return x;
} }
@ -315,19 +290,15 @@ static void default_smbbrowse_conf(char *default_name)
/* The workgroup specified in smb.conf */ /* The workgroup specified in smb.conf */
w = new_workgroup((struct smbbrowse *)NULL, lp_workgroup(), default_name); w = new_workgroup((struct smbbrowse *)NULL, lp_workgroup(), default_name);
w->should_local_master = lp_local_master(); w->should_local_master = lp_preferred_master();
w->should_domain_master = lp_domain_master(); w->should_domain_master = lp_domain_master();
w->should_domain_logon = lp_domain_logons();
w->should_workgroup_member = True; w->should_workgroup_member = True;
/* default action: allow any new workgroup to be added. this is /* default action: allow any new workgroup to be added */
_not_ the same as the old 1.9.14-1.9.15 definition of "*"
*/
w = new_workgroup((struct smbbrowse *)NULL, "*", default_name); w = new_workgroup((struct smbbrowse *)NULL, "*", default_name);
w->should_local_master = False; w->should_local_master = False;
w->should_domain_master = False; w->should_domain_master = False;
w->should_workgroup_member = False; w->should_workgroup_member = False;
w->should_domain_logon = False;
} }
/* /*
@ -362,8 +333,6 @@ void read_smbbrowse_conf(char *default_name)
w = new_workgroup((struct smbbrowse *)NULL, work_name, default_name); w = new_workgroup((struct smbbrowse *)NULL, work_name, default_name);
w->should_local_master = lp_local_master(); w->should_local_master = lp_local_master();
w->should_domain_master = lp_domain_master(); w->should_domain_master = lp_domain_master();
w->should_preferred_master = lp_preferred_master();
w->should_domain_logon = lp_domain_logons();
w->should_workgroup_member = True; w->should_workgroup_member = True;
} }

View File

@ -27,10 +27,6 @@
04 jul 96: lkcl@pires.co.uk 04 jul 96: lkcl@pires.co.uk
created module namedbname containing name database functions created module namedbname containing name database functions
30 July 96: David.Chappell@mail.trincoll.edu
Expanded multiple workgroup domain master browser support.
*/ */
#include "includes.h" #include "includes.h"
@ -47,16 +43,6 @@ extern struct subnet_record *subnetlist;
uint16 nb_type = 0; /* samba's NetBIOS name type */ uint16 nb_type = 0; /* samba's NetBIOS name type */
static char *source_description[] =
{
"STATUS_QUERY",
"LMHOSTS",
"REG",
"SELF",
"DNS",
"DNSFAIL"
};
/**************************************************************************** /****************************************************************************
samba's NetBIOS name type samba's NetBIOS name type
@ -187,10 +173,8 @@ struct name_record *find_name_search(struct subnet_record **d,
{ {
if (d == NULL) return NULL; /* bad error! */ if (d == NULL) return NULL; /* bad error! */
if (search & FIND_LOCAL) if (search & FIND_LOCAL) {
{ if (*d != NULL) {
if (*d != NULL)
{
struct name_record *n = find_name((*d)->namelist, name, search); struct name_record *n = find_name((*d)->namelist, name, search);
DEBUG(4,("find_name on local: %s %s search %x\n", DEBUG(4,("find_name on local: %s %s search %x\n",
namestr(name),inet_ntoa(ip), search)); namestr(name),inet_ntoa(ip), search));
@ -198,7 +182,7 @@ struct name_record *find_name_search(struct subnet_record **d,
} }
} }
if ((search & FIND_WINS) != FIND_WINS) return NULL; if (!(search & FIND_WINS)) return NULL;
/* find WINS subnet record. */ /* find WINS subnet record. */
*d = find_subnet(ipgrp); *d = find_subnet(ipgrp);
@ -244,16 +228,18 @@ void dump_names(void)
{ {
int i; int i;
DEBUG(3,("%-15s ", inet_ntoa(d->bcast_ip))); DEBUG(3,("%15s ", inet_ntoa(d->bcast_ip)));
DEBUG(3,("%-19s TTL=%7ld %s ", DEBUG(3,("%15s ", inet_ntoa(d->mask_ip)));
DEBUG(3,("%-19s TTL=%ld ",
namestr(&n->name), namestr(&n->name),
n->death_time?n->death_time-t:0, source_description[n->source])); n->death_time?n->death_time-t:0));
for (i = 0; i < n->num_ips; i++) for (i = 0; i < n->num_ips; i++)
{ {
DEBUG(3,("%-15s NB=%2x ", DEBUG(3,("%15s NB=%2x source=%d",
inet_ntoa(n->ip_flgs[i].ip), inet_ntoa(n->ip_flgs[i].ip),
(unsigned char)n->ip_flgs[i].nb_flags)); n->ip_flgs[i].nb_flags,n->source));
} }
DEBUG(3,("\n")); DEBUG(3,("\n"));
@ -270,7 +256,7 @@ void dump_names(void)
{ {
fprintf(f, "%s %2x ", fprintf(f, "%s %2x ",
inet_ntoa(n->ip_flgs[i].ip), inet_ntoa(n->ip_flgs[i].ip),
(unsigned char)n->ip_flgs[i].nb_flags); n->ip_flgs[i].nb_flags);
} }
fprintf(f, "\n"); fprintf(f, "\n");
} }
@ -426,15 +412,7 @@ struct name_record *add_netbios_entry(struct subnet_record *d,
struct name_record *n; struct name_record *n;
struct name_record *n2=NULL; struct name_record *n2=NULL;
int search = 0; int search = 0;
BOOL self; BOOL self = source == SELF;
if (iface_ip(ip))
{
source = SELF;
putip(&ip, &ipzero);
}
self = source == SELF;
/* add the name to the WINS list if the name comes from a directed query */ /* add the name to the WINS list if the name comes from a directed query */
search |= wins ? FIND_WINS : FIND_LOCAL; search |= wins ? FIND_WINS : FIND_LOCAL;
@ -494,12 +472,9 @@ struct name_record *add_netbios_entry(struct subnet_record *d,
/******************************************************************* /*******************************************************************
expires or refreshes old names in the namelist expires old names in the namelist
if the name is a samba SELF name, it must be refreshed rather than
removed.
******************************************************************/ ******************************************************************/
void check_expire_names(time_t t) void expire_names(time_t t)
{ {
struct name_record *n; struct name_record *n;
struct name_record *next; struct name_record *next;
@ -511,21 +486,13 @@ void check_expire_names(time_t t)
for (n = d->namelist; n; n = next) for (n = d->namelist; n; n = next)
{ {
next = n->next; next = n->next;
if (n->death_time && n->death_time < t) if (n->death_time && n->death_time < t)
{ {
if (n->source == SELF) if (n->source == SELF) {
{ DEBUG(3,("not expiring SELF name %s\n", namestr(&n->name)));
/* refresh the samba name. if this refresh fails n->death_time += 300;
for any reason, it will be deleted.
*/
DEBUG(3,("Refreshing SELF name %s\n", namestr(&n->name)));
add_my_name_entry(d, -1,
n->name.name, n->name.name_type,
n->ip_flgs[0].nb_flags);
continue; continue;
} }
DEBUG(3,("Removing dead name %s\n", namestr(&n->name))); DEBUG(3,("Removing dead name %s\n", namestr(&n->name)));
if (n->prev) n->prev->next = n->next; if (n->prev) n->prev->next = n->next;

View File

@ -92,9 +92,8 @@ void remove_response_record(struct subnet_record *d,
create a name query response record create a name query response record
**************************************************************************/ **************************************************************************/
struct response_record *make_response_queue_record(enum state_type state, struct response_record *make_response_queue_record(enum state_type state,
int id,uint16 fd, int quest_type, int id,uint16 fd,
int token, char *name,int type, int quest_type, char *name,int type, int nb_flags, time_t ttl,
enum name_source source, int nb_flags, time_t ttl,
int server_type, char *my_name, char *my_comment, int server_type, char *my_name, char *my_comment,
BOOL bcast,BOOL recurse, BOOL bcast,BOOL recurse,
struct in_addr send_ip, struct in_addr reply_to_ip) struct in_addr send_ip, struct in_addr reply_to_ip)
@ -110,17 +109,14 @@ struct response_record *make_response_queue_record(enum state_type state,
n->state = state; n->state = state;
n->fd = fd; n->fd = fd;
n->quest_type = quest_type; n->quest_type = quest_type;
n->token = token;
make_nmb_name(&n->name, name, type, scope); make_nmb_name(&n->name, name, type, scope);
n->nb_flags = nb_flags;
n->ttl = ttl; n->ttl = ttl;
n->source = source;
n->server_type = server_type; n->server_type = server_type;
n->bcast = bcast; n->bcast = bcast;
n->recurse = recurse; n->recurse = recurse;
n->reply.nb_flags = nb_flags;
n->reply.ip = reply_to_ip;
n->send_ip = send_ip; n->send_ip = send_ip;
n->reply_to_ip = reply_to_ip;
StrnCpy(my_name , n->my_name , sizeof(n->my_name )-1); StrnCpy(my_name , n->my_name , sizeof(n->my_name )-1);
StrnCpy(my_comment, n->my_comment, sizeof(n->my_comment)-1); StrnCpy(my_comment, n->my_comment, sizeof(n->my_comment)-1);

View File

@ -133,7 +133,6 @@ struct server_record *add_server_entry(struct subnet_record *d,
{ {
BOOL newentry=False; BOOL newentry=False;
struct server_record *s; struct server_record *s;
int token = conf_workgroup_name_to_token(work->work_group, myname);
if (name[0] == '*') if (name[0] == '*')
{ {
@ -161,9 +160,11 @@ struct server_record *add_server_entry(struct subnet_record *d,
bzero((char *)s,sizeof(*s)); bzero((char *)s,sizeof(*s));
} }
if (conf_should_workgroup_member(token))
if (strequal(lp_workgroup(),work->work_group))
{ {
if (servertype) servertype |= SV_TYPE_LOCAL_LIST_ONLY; if (servertype)
servertype |= SV_TYPE_LOCAL_LIST_ONLY;
} }
else else
{ {

View File

@ -26,9 +26,6 @@
04 jul 96: lkcl@pires.co.uk 04 jul 96: lkcl@pires.co.uk
created module namedbsubnet containing subnet database functions created module namedbsubnet containing subnet database functions
30 July 96: David.Chappell@mail.trincoll.edu
Expanded multiple workgroup domain master browser support.
*/ */
#include "includes.h" #include "includes.h"
@ -180,36 +177,23 @@ void add_subnet_interfaces(void)
/****************************************************************************
add the default workgroups into my domain
**************************************************************************/
void add_workgroup_to_subnet(char *group, struct in_addr bcast_ip,
struct in_addr mask_ip)
{
if (group && *group != '*')
{
DEBUG(4,("add_wg_to_subnet: %s %s\n", group, inet_ntoa(bcast_ip)));
add_subnet_entry(bcast_ip,mask_ip,group, True, False);
}
}
/**************************************************************************** /****************************************************************************
add the default workgroup into my domain add the default workgroup into my domain
**************************************************************************/ **************************************************************************/
void add_workgroups_to_subnets() void add_my_subnets(char *group)
{ {
struct interface *i; struct interface *i;
/* add or find domain on our local subnet, in the default workgroup */ /* add or find domain on our local subnet, in the default workgroup */
if (*group == '*') return;
/* the coding choice is up to you, andrew: i can see why you don't want
global access to the local_interfaces structure: so it can't get
messed up! */
for (i = local_interfaces; i; i = i->next) for (i = local_interfaces; i; i = i->next)
{ {
int token; add_subnet_entry(i->bcast,i->nmask,group, True, False);
for (token = 0; token < get_num_workgroups(); token++)
{
add_workgroup_to_subnet(conf_workgroup_name(token),i->bcast,i->nmask);
}
} }
} }
@ -224,44 +208,43 @@ struct subnet_record *add_subnet_entry(struct in_addr bcast_ip,
{ {
struct subnet_record *d; struct subnet_record *d;
DEBUG(4,("add_subnet_entry: %s %\n", name,inet_ntoa(bcast_ip))); /* XXXX andrew: struct in_addr ip appears not to be referenced at all except
in the DEBUG comment. i assume that the DEBUG comment below actually
intends to refer to bcast_ip? i don't know.
if (zero_ip(bcast_ip)) bcast_ip = *iface_bcast(bcast_ip); struct in_addr ip = ipgrp;
*/
if (zero_ip(bcast_ip))
bcast_ip = *iface_bcast(bcast_ip);
/* add the domain into our domain database */ /* add the domain into our domain database */
if ((d = find_subnet(bcast_ip)) || (d = make_subnet(bcast_ip, mask_ip))) if ((d = find_subnet(bcast_ip)) ||
(d = make_subnet(bcast_ip, mask_ip)))
{ {
struct work_record *work = find_workgroupstruct(d, name, add); struct work_record *w = find_workgroupstruct(d, name, add);
if (!work) return NULL; if (!w) return NULL;
if (conf_should_workgroup_member(work->token))
{
/* add samba server name to workgroup list. don't add
lmhosts server entries to local interfaces */
pstring comment;
char *my_name = conf_browsing_alias (work->token);
char *my_comment = conf_browsing_alias_comment(work->token);
StrnCpy(comment, my_comment, 43);
add_server_entry(d,work,my_name,
work->ServerType | SV_TYPE_LOCAL_LIST_ONLY,
0,comment,True);
DEBUG(3,("Added server name entry %s at %s\n",
name,inet_ntoa(bcast_ip)));
/* add WORKGROUP(1e) and WORKGROUP(00) entries into name database /* add WORKGROUP(1e) and WORKGROUP(00) entries into name database
or register with WINS server, if it's our workgroup */ or register with WINS server, if it's our workgroup */
add_my_name_entry(d,work->token,name,0x1e,nb_type|NB_ACTIVE|NB_GROUP); if (strequal(lp_workgroup(), name))
add_my_name_entry(d,work->token,name,0x0 ,nb_type|NB_ACTIVE|NB_GROUP); {
add_my_name_entry(d,name,0x1e,nb_type|NB_ACTIVE|NB_GROUP);
add_my_name_entry(d,name,0x0 ,nb_type|NB_ACTIVE|NB_GROUP);
}
/* add samba server name to workgroup list. don't add
lmhosts server entries to local interfaces */
if (strequal(lp_workgroup(), name))
{
add_server_entry(d,w,myname,w->ServerType,0,lp_serverstring(),True);
DEBUG(3,("Added server name entry %s at %s\n",
name,inet_ntoa(bcast_ip)));
} }
return d; return d;
} }
return NULL; return NULL;
} }

View File

@ -26,9 +26,6 @@
04 jul 96: lkcl@pires.co.uk 04 jul 96: lkcl@pires.co.uk
created module namedbwork containing workgroup database functions created module namedbwork containing workgroup database functions
30 July 96: David.Chappell@mail.trincoll.edu
Expanded multiple workgroup domain master browser support.
*/ */
#include "includes.h" #include "includes.h"
@ -43,7 +40,9 @@ extern struct subnet_record *subnetlist;
extern struct in_addr ipgrp; extern struct in_addr ipgrp;
extern pstring myname; int workgroup_count = 0; /* unique index key: one for each workgroup */
/**************************************************************************** /****************************************************************************
add a workgroup into the domain list add a workgroup into the domain list
@ -76,17 +75,11 @@ static void add_workgroup(struct work_record *work, struct subnet_record *d)
static struct work_record *make_workgroup(char *name) static struct work_record *make_workgroup(char *name)
{ {
struct work_record *work; struct work_record *work;
struct subnet_record *d;
int t = -1; int t = -1;
if (!name || !name[0]) return NULL; if (!name || !name[0]) return NULL;
/* conf_workgroup_name_to_token() gets or creates a unique index for the workgroup name */
if ((t = conf_workgroup_name_to_token(name, myname)) == -1)
{
DEBUG(3, ("work_record(\"%s\"): conf_workgroup_name_to_token() refuses to allow workgroup\n", name));
return (struct work_record *)NULL;
}
work = (struct work_record *)malloc(sizeof(*work)); work = (struct work_record *)malloc(sizeof(*work));
if (!work) return(NULL); if (!work) return(NULL);
@ -99,16 +92,34 @@ static struct work_record *make_workgroup(char *name)
work->needelection = False; work->needelection = False;
work->needannounce = True; work->needannounce = True;
work->state = MST_NONE; work->state = MST_NONE;
/* make sure all token representations of workgroups are unique */
for (d = subnetlist; d && t == -1; d = d->next)
{
struct work_record *w;
for (w = d->workgrouplist; w && t == -1; w = w->next)
{
if (strequal(w->work_group, work->work_group)) t = w->token;
}
}
if (t == -1)
{
work->token = ++workgroup_count;
}
else
{
work->token = t; work->token = t;
}
/* WfWg uses 01040b01 */ /* WfWg uses 01040b01 */
/* Win95 uses 01041501 */ /* Win95 uses 01041501 */
/* NTAS uses ???????? */ /* NTAS uses ???????? */
work->ElectionCriterion = (MAINTAIN_LIST<<1)|(ELECTION_VERSION<<8); work->ElectionCriterion = (MAINTAIN_LIST<<1)|(ELECTION_VERSION<<8);
work->ElectionCriterion |= (lp_os_level() << 24); work->ElectionCriterion |= (lp_os_level() << 24);
if (lp_domain_master()) {
if (conf_should_domain_master(work->token))
{
work->ElectionCriterion |= 0x80; work->ElectionCriterion |= 0x80;
} }
@ -164,45 +175,33 @@ struct work_record *find_workgroupstruct(struct subnet_record *d,
if (strequal(name, "*")) if (strequal(name, "*"))
{ {
#if 0 /* XXXX this is being called too many times */
DEBUG(2,("add any workgroups: initiating browser search on %s\n", DEBUG(2,("add any workgroups: initiating browser search on %s\n",
inet_ntoa(d->bcast_ip))); inet_ntoa(d->bcast_ip)));
queue_netbios_pkt_wins(d,ClientNMB,NMB_QUERY, NAME_QUERY_FIND_MST, queue_netbios_pkt_wins(d,ClientNMB,NMB_QUERY, NAME_QUERY_FIND_MST,
-1,MSBROWSE,0x1,0,0,0,0,NULL,NULL, MSBROWSE,0x1,0,0,0,NULL,NULL,
True,False, d->bcast_ip, d->bcast_ip); True,False, d->bcast_ip, d->bcast_ip);
#endif
return NULL; return NULL;
} }
for (ret = d->workgrouplist; ret; ret = ret->next) for (ret = d->workgrouplist; ret; ret = ret->next) {
{ if (!strcmp(ret->work_group,name)) {
if (!strcmp(ret->work_group,name))
{
DEBUG(4, ("found\n")); DEBUG(4, ("found\n"));
return(ret); return(ret);
} }
} }
if (!add) if (!add) {
{
DEBUG(4, ("not found\n")); DEBUG(4, ("not found\n"));
return NULL; return NULL;
} }
DEBUG(4,("not found: creating\n")); DEBUG(4,("not found: creating\n"));
if ((work = make_workgroup(name)) != NULL) if ((work = make_workgroup(name)))
{ {
DEBUG(4,("bcast_ip:%s preferred master=%s local_master=%s\n",
inet_ntoa(d->bcast_ip),
BOOLSTR(conf_should_preferred_master(work->token)),
BOOLSTR(conf_should_local_master(work->token)) ));
if (!ip_equal(d->bcast_ip, ipgrp) && if (!ip_equal(d->bcast_ip, ipgrp) &&
conf_should_preferred_master(work->token) && lp_preferred_master() &&
conf_should_local_master (work->token)) strequal(lp_workgroup(), name))
{ {
DEBUG(3, ("preferred master startup for %s\n", work->work_group)); DEBUG(3, ("preferred master startup for %s\n", work->work_group));
work->needelection = True; work->needelection = True;

View File

@ -28,8 +28,6 @@
04 jul 96: lkcl@pires.co.uk 04 jul 96: lkcl@pires.co.uk
added system to become a master browser by stages. added system to become a master browser by stages.
30 July 96: David.Chappell@mail.trincoll.edu
Expanded multiple workgroup domain master browser support.
*/ */
@ -41,6 +39,7 @@ extern int ClientDGRAM;
extern int DEBUGLEVEL; extern int DEBUGLEVEL;
extern pstring scope; extern pstring scope;
extern pstring myname;
extern struct in_addr ipzero; extern struct in_addr ipzero;
extern struct in_addr ipgrp; extern struct in_addr ipgrp;
@ -52,9 +51,6 @@ extern struct subnet_record *subnetlist;
extern uint16 nb_type; /* samba's NetBIOS name type */ extern uint16 nb_type; /* samba's NetBIOS name type */
extern pstring myname;
/******************************************************************* /*******************************************************************
occasionally check to see if the master browser is around occasionally check to see if the master browser is around
******************************************************************/ ******************************************************************/
@ -83,7 +79,7 @@ void check_master_browser(void)
if (!AM_MASTER(work)) if (!AM_MASTER(work))
{ {
queue_netbios_packet(d,ClientNMB,NMB_QUERY,NAME_QUERY_MST_CHK, queue_netbios_packet(d,ClientNMB,NMB_QUERY,NAME_QUERY_MST_CHK,
work->token, work->work_group,0x1d,REGISTER,0,0,0,NULL,NULL, work->work_group,0x1d,0,0,0,NULL,NULL,
True,False,d->bcast_ip,d->bcast_ip); True,False,d->bcast_ip,d->bcast_ip);
} }
} }
@ -106,8 +102,9 @@ void browser_gone(char *work_name, struct in_addr ip)
if (ip_equal(d->bcast_ip,ipgrp)) if (ip_equal(d->bcast_ip,ipgrp))
return; return;
if (conf_should_local_master(work->token)) if (strequal(work->work_group, lp_workgroup()))
{ {
DEBUG(2,("Forcing election on %s %s\n", DEBUG(2,("Forcing election on %s %s\n",
work->work_group,inet_ntoa(d->bcast_ip))); work->work_group,inet_ntoa(d->bcast_ip)));
@ -117,10 +114,10 @@ void browser_gone(char *work_name, struct in_addr ip)
else else
{ {
/* local interfaces: force an election */ /* local interfaces: force an election */
send_election(d, work->work_group, 0, 0, conf_browsing_alias(work->token)); send_election(d, work->work_group, 0, 0, myname);
/* only removes workgroup completely on a local interface /* only removes workgroup completely on a local interface
persistent lmhosts entries on a local interface _will_ be removed. persistent lmhosts entries on a local interface _will_ be removed).
*/ */
remove_workgroup(d, work,True); remove_workgroup(d, work,True);
} }
@ -175,10 +172,8 @@ void name_unregister_work(struct subnet_record *d, char *name, int name_type)
if (!(work = find_workgroupstruct(d, name, False))) return; if (!(work = find_workgroupstruct(d, name, False))) return;
if (!AM_MASTER(work) && !AM_DMBRSE(work)) return;
if (ms_browser_name(name, name_type) || if (ms_browser_name(name, name_type) ||
(conf_should_workgroup_member(work->token) && (AM_MASTER(work) && strequal(name, lp_workgroup()) == 0 &&
(name_type == 0x1d || name_type == 0x1b))) (name_type == 0x1d || name_type == 0x1b)))
{ {
int remove_type = 0; int remove_type = 0;
@ -202,17 +197,17 @@ void name_unregister_work(struct subnet_record *d, char *name, int name_type)
whether to proceed to the next stage in samba becoming a master browser. whether to proceed to the next stage in samba becoming a master browser.
**************************************************************************/ **************************************************************************/
void name_register_work(struct subnet_record *d, int token, void name_register_work(struct subnet_record *d, char *name, int name_type,
char *name, int name_type, enum name_source source, int nb_flags, time_t ttl, struct in_addr ip, BOOL bcast)
struct nmb_ip *data, time_t ttl, struct in_addr ip, BOOL bcast)
{ {
enum name_source source = (ismyip(ip) || ip_equal(ip, ipzero)) ?
SELF : REGISTER;
if (source == SELF) if (source == SELF)
{ {
char *work_name = conf_workgroup_name(token); struct work_record *work = find_workgroupstruct(d, lp_workgroup(), False);
struct work_record *work = find_workgroupstruct(d, work_name, False);
add_netbios_entry(d,name,name_type,data->nb_flags, add_netbios_entry(d,name,name_type,nb_flags,ttl,source,ip,True,!bcast);
ttl,source,data->ip,True,!bcast);
if (work) if (work)
{ {
@ -254,8 +249,6 @@ void name_register_work(struct subnet_record *d, int token,
******************************************************************/ ******************************************************************/
void become_master(struct subnet_record *d, struct work_record *work) void become_master(struct subnet_record *d, struct work_record *work)
{ {
pstring comment;
/* domain type must be limited to domain enum + server type. it must /* domain type must be limited to domain enum + server type. it must
not have SV_TYPE_SERVER or anything else with SERVER in it, else not have SV_TYPE_SERVER or anything else with SERVER in it, else
clients get confused and start thinking this entry is a server clients get confused and start thinking this entry is a server
@ -263,24 +256,8 @@ void become_master(struct subnet_record *d, struct work_record *work)
*/ */
uint32 domain_type = SV_TYPE_DOMAIN_ENUM|SV_TYPE_NT; uint32 domain_type = SV_TYPE_DOMAIN_ENUM|SV_TYPE_NT;
char *my_name ;
char *my_comment;
if (!work) return; if (!work) return;
my_name = conf_browsing_alias(work->token);
my_comment = conf_browsing_alias_comment(work->token);
StrnCpy(comment, my_comment, 43);
if (!conf_should_local_master(work->token))
{
DEBUG(1,("Should not become master for %s %s\n",
work->work_group,inet_ntoa(d->bcast_ip)));
work->state = MST_NONE;
return;
}
DEBUG(2,("Becoming master for %s %s (currently at stage %d)\n", DEBUG(2,("Becoming master for %s %s (currently at stage %d)\n",
work->work_group,inet_ntoa(d->bcast_ip),work->state)); work->work_group,inet_ntoa(d->bcast_ip),work->state));
@ -295,10 +272,10 @@ void become_master(struct subnet_record *d, struct work_record *work)
/* update our server status */ /* update our server status */
work->ServerType &= ~SV_TYPE_POTENTIAL_BROWSER; work->ServerType &= ~SV_TYPE_POTENTIAL_BROWSER;
add_server_entry(d,work,my_name,work->ServerType,0,comment,True); add_server_entry(d,work,myname,work->ServerType,0,lp_serverstring(),True);
/* add special browser name */ /* add special browser name */
add_my_name_entry(d,work->token,MSBROWSE,0x01,nb_type|NB_ACTIVE|NB_GROUP); add_my_name_entry(d,MSBROWSE ,0x01,nb_type|NB_ACTIVE|NB_GROUP);
/* DON'T do anything else after calling add_my_name_entry() */ /* DON'T do anything else after calling add_my_name_entry() */
return; return;
@ -309,11 +286,10 @@ void become_master(struct subnet_record *d, struct work_record *work)
work->state = MST_MSB; /* ... registering MSBROWSE was successful */ work->state = MST_MSB; /* ... registering MSBROWSE was successful */
/* add server entry on successful registration of MSBROWSE */ /* add server entry on successful registration of MSBROWSE */
add_server_entry(d,work,work->work_group, add_server_entry(d,work,work->work_group,domain_type,0,myname,True);
domain_type,0,conf_browsing_alias(work->token),True);
/* add master name */ /* add master name */
add_my_name_entry(d,work->token,work->work_group,0x1d,nb_type|NB_ACTIVE); add_my_name_entry(d,work->work_group,0x1d,nb_type|NB_ACTIVE);
/* DON'T do anything else after calling add_my_name_entry() */ /* DON'T do anything else after calling add_my_name_entry() */
return; return;
@ -325,8 +301,7 @@ void become_master(struct subnet_record *d, struct work_record *work)
/* update our server status */ /* update our server status */
work->ServerType |= SV_TYPE_MASTER_BROWSER; work->ServerType |= SV_TYPE_MASTER_BROWSER;
add_server_entry(d,work,conf_browsing_alias(work->token), add_server_entry(d,work,myname,work->ServerType,0,lp_serverstring(),True);
work->ServerType,0,comment,True);
if (work->serverlist == NULL) /* no servers! */ if (work->serverlist == NULL) /* no servers! */
{ {
@ -346,14 +321,13 @@ void become_master(struct subnet_record *d, struct work_record *work)
case MST_DOMAIN_NONE: case MST_DOMAIN_NONE:
{ {
if (conf_should_domain_master(work->token)) if (lp_domain_master())
{ {
work->state = MST_DOMAIN_MEM; /* ... become domain member */ work->state = MST_DOMAIN_MEM; /* ... become domain member */
DEBUG(3,("domain first stage: register as domain member\n")); DEBUG(3,("domain first stage: register as domain member\n"));
/* add domain member name */ /* add domain member name */
add_my_name_entry(d,work->token,work->work_group,0x1e, add_my_name_entry(d,work->work_group,0x1e,nb_type|NB_ACTIVE|NB_GROUP);
nb_type|NB_ACTIVE|NB_GROUP);
/* DON'T do anything else after calling add_my_name_entry() */ /* DON'T do anything else after calling add_my_name_entry() */
return; return;
@ -368,20 +342,19 @@ void become_master(struct subnet_record *d, struct work_record *work)
case MST_DOMAIN_MEM: case MST_DOMAIN_MEM:
{ {
if (conf_should_domain_master(work->token)) if (lp_domain_master())
{ {
work->state = MST_DOMAIN_TST; /* ... possibly become domain master */ work->state = MST_DOMAIN_TST; /* ... possibly become domain master */
DEBUG(3,("domain second stage: register as domain master\n")); DEBUG(3,("domain second stage: register as domain master\n"));
if (conf_should_domain_logon(work->token)) if (lp_domain_logons())
{ {
work->ServerType |= SV_TYPE_DOMAIN_MEMBER; work->ServerType |= SV_TYPE_DOMAIN_MEMBER;
add_server_entry(d,work,my_name,work->ServerType,0,comment,True); add_server_entry(d,work,myname,work->ServerType,0,lp_serverstring(),True);
} }
/* add domain master name */ /* add domain master name */
add_my_name_entry(d,work->token,work->work_group,0x1b, add_my_name_entry(d,work->work_group,0x1b,nb_type|NB_ACTIVE );
nb_type|NB_ACTIVE );
/* DON'T do anything else after calling add_my_name_entry() */ /* DON'T do anything else after calling add_my_name_entry() */
return; return;
@ -397,7 +370,7 @@ void become_master(struct subnet_record *d, struct work_record *work)
case MST_DOMAIN_TST: /* while we were still a master browser... */ case MST_DOMAIN_TST: /* while we were still a master browser... */
{ {
/* update our server status */ /* update our server status */
if (conf_should_domain_master(work->token)) if (lp_domain_master())
{ {
struct subnet_record *d1; struct subnet_record *d1;
uint32 update_type = 0; uint32 update_type = 0;
@ -409,7 +382,7 @@ void become_master(struct subnet_record *d, struct work_record *work)
SV_TYPE_POTENTIAL_BROWSER; SV_TYPE_POTENTIAL_BROWSER;
work->ServerType |= update_type; work->ServerType |= update_type;
add_server_entry(d,work,my_name,work->ServerType,0,comment,True); add_server_entry(d,work,myname,work->ServerType,0,lp_serverstring(),True);
for (d1 = subnetlist; d1; d1 = d1->next) for (d1 = subnetlist; d1; d1 = d1->next)
{ {
@ -418,7 +391,7 @@ void become_master(struct subnet_record *d, struct work_record *work)
for (w = d1->workgrouplist; w; w = w->next) for (w = d1->workgrouplist; w; w = w->next)
{ {
struct server_record *s = find_server(w, my_name); struct server_record *s = find_server(w, myname);
if (strequal(w->work_group, work->work_group)) if (strequal(w->work_group, work->work_group))
{ {
w->ServerType |= update_type; w->ServerType |= update_type;
@ -456,21 +429,7 @@ void become_nonmaster(struct subnet_record *d, struct work_record *work,
{ {
int new_server_type = work->ServerType; int new_server_type = work->ServerType;
pstring comment; DEBUG(2,("Becoming non-master for %s\n",work->work_group));
char *my_name ;
char *my_comment;
BOOL wins = ip_equal(d->bcast_ip, ipgrp);
enum master_state state;
if (!work) return;
my_name = conf_browsing_alias (work->token);
my_comment = conf_browsing_alias_comment(work->token);
StrnCpy(comment, my_comment, 43);
DEBUG(2,("Becoming non-master for %s alias %s\n",work->work_group, my_name));
/* can only remove master or domain types with this function */ /* can only remove master or domain types with this function */
remove_type &= SV_TYPE_MASTER_BROWSER|SV_TYPE_DOMAIN_MASTER; remove_type &= SV_TYPE_MASTER_BROWSER|SV_TYPE_DOMAIN_MASTER;
@ -480,7 +439,6 @@ void become_nonmaster(struct subnet_record *d, struct work_record *work,
remove_type |= SV_TYPE_DOMAIN_MASTER; remove_type |= SV_TYPE_DOMAIN_MASTER;
new_server_type &= ~remove_type; new_server_type &= ~remove_type;
state = work->state;
if (!(new_server_type & (SV_TYPE_MASTER_BROWSER|SV_TYPE_DOMAIN_MASTER))) if (!(new_server_type & (SV_TYPE_MASTER_BROWSER|SV_TYPE_DOMAIN_MASTER)))
{ {
@ -490,40 +448,25 @@ void become_nonmaster(struct subnet_record *d, struct work_record *work,
work->ElectionCriterion &= ~0x4; work->ElectionCriterion &= ~0x4;
work->state = MST_NONE; work->state = MST_NONE;
remove_name_entry(d,work->token,MSBROWSE,0x01); /* announce ourselves as no longer active as a master browser. */
announce_server(d, work, work->work_group, myname, 0, 0);
remove_name_entry(d,MSBROWSE ,0x01);
} }
work->ServerType = new_server_type; work->ServerType = new_server_type;
if (!(work->ServerType & SV_TYPE_DOMAIN_MASTER)) if (!(work->ServerType & SV_TYPE_DOMAIN_MASTER))
{ {
if (state == MST_DOMAIN) if (work->state == MST_DOMAIN)
{
if (wins)
work->state = MST_NONE;
else
work->state = MST_BROWSER; work->state = MST_BROWSER;
} remove_name_entry(d,work->work_group,0x1b);
remove_name_entry(d,work->token,work->work_group,0x1b);
} }
if (!(work->ServerType & SV_TYPE_MASTER_BROWSER)) if (!(work->ServerType & SV_TYPE_MASTER_BROWSER))
{ {
if (state >= MST_BROWSER) if (work->state >= MST_BROWSER)
work->state = MST_NONE; work->state = MST_NONE;
remove_name_entry(d,work->token,work->work_group,0x1d); remove_name_entry(d,work->work_group,0x1d);
}
/* update our internal records with our new server state */
add_server_entry(d, work, my_name, work->ServerType, 0, my_comment, True);
/* announce change in status on local interface */
if (!wins)
{
/* XXXX do we need also to do an announce with a time of zero
if we are no longer a local master browser?
*/
work->needannounce = True;
} }
} }
@ -550,16 +493,14 @@ void run_elections(void)
{ {
if (work->RunningElection) if (work->RunningElection)
{ {
char *alias = conf_browsing_alias(work->token);
send_election(d,work->work_group, work->ElectionCriterion, send_election(d,work->work_group, work->ElectionCriterion,
t-StartupTime,alias); t-StartupTime,myname);
if (work->ElectionCount++ >= 4) if (work->ElectionCount++ >= 4)
{ {
/* I won! now what :-) */ /* I won! now what :-) */
DEBUG(2,(">>> Won election for %s as %s on %s <<<\n", DEBUG(2,(">>> Won election on %s %s <<<\n",
work->work_group,alias,inet_ntoa(d->bcast_ip))); work->work_group,inet_ntoa(d->bcast_ip)));
work->RunningElection = False; work->RunningElection = False;
work->state = MST_NONE; work->state = MST_NONE;
@ -596,7 +537,7 @@ static BOOL win_election(struct work_record *work,int version,uint32 criterion,
if (timeup > mytimeup) return(False); if (timeup > mytimeup) return(False);
if (timeup < mytimeup) return(True); if (timeup < mytimeup) return(True);
if (strcasecmp(conf_browsing_alias(work->token),name) > 0) return(False); if (strcasecmp(myname,name) > 0) return(False);
return(True); return(True);
} }
@ -635,37 +576,29 @@ void process_election(struct packet_struct *p,char *buf)
for (work = d->workgrouplist; work; work = work->next) for (work = d->workgrouplist; work; work = work->next)
{ {
if (!conf_should_local_master(work->token)) continue; if (!strequal(work->work_group, lp_workgroup()))
continue;
if (win_election(work, version,criterion,timeup,name)) if (win_election(work, version,criterion,timeup,name)) {
{ if (!work->RunningElection) {
if (!work->RunningElection)
{
work->needelection = True; work->needelection = True;
work->ElectionCount=0; work->ElectionCount=0;
work->state = MST_NONE; work->state = MST_NONE;
} }
} } else {
else
{
work->needelection = False; work->needelection = False;
if (work->RunningElection || AM_MASTER(work)) if (work->RunningElection || AM_MASTER(work)) {
{
work->RunningElection = False; work->RunningElection = False;
DEBUG(3,(">>> Lost election on %s %s <<<\n", DEBUG(3,(">>> Lost election on %s %s <<<\n",
work->work_group,inet_ntoa(d->bcast_ip))); work->work_group,inet_ntoa(d->bcast_ip)));
/* if we are the master then remove our masterly names */
if (AM_MASTER(work)) if (AM_MASTER(work))
{
become_nonmaster(d, work, become_nonmaster(d, work,
SV_TYPE_MASTER_BROWSER| SV_TYPE_MASTER_BROWSER|
SV_TYPE_DOMAIN_MASTER); SV_TYPE_DOMAIN_MASTER);
} }
} }
} }
}
} }

View File

@ -21,11 +21,7 @@
Revision History: Revision History:
14 jan 96: lkcl@pires.co.uk 14 jan 96: lkcl@pires.co.uk
added domain master browser support added multiple workgroup domain master support
30 aug 96: lkcl@pires.co.uk
added multiple domain logon support, using extensions to David Chappell's
multiple domain master browser code.
*/ */
@ -33,8 +29,13 @@
extern int ClientDGRAM; extern int ClientDGRAM;
#define TEST_CODE /* want to debug unknown browse packets */
extern int DEBUGLEVEL; extern int DEBUGLEVEL;
extern pstring myname;
/**************************************************************************** /****************************************************************************
process a domain logon packet process a domain logon packet
@ -53,18 +54,14 @@ void process_logon_packet(struct packet_struct *p,char *buf,int len)
pstring outbuf; pstring outbuf;
int code,reply_code; int code,reply_code;
struct work_record *work; struct work_record *work;
char *my_name;
if (!d) return; if (!d) return;
if (!(work = find_workgroupstruct(d,dgram->dest_name.name, False))) if (!(work = find_workgroupstruct(d,dgram->dest_name.name, False)))
return; return;
if ((my_name = conf_browsing_alias(work->token)) == NULL) return; if (!lp_domain_logons()) {
DEBUG(3,("No domain logons\n"));
if (!conf_should_domain_logon(work->token))
{
DEBUG(3,("No domain logons for %s (%s)\n", work->work_group, my_name));
return; return;
} }
@ -76,7 +73,7 @@ void process_logon_packet(struct packet_struct *p,char *buf,int len)
char *user = skip_string(machine,1); char *user = skip_string(machine,1);
logname = skip_string(user,1); logname = skip_string(user,1);
reply_code = 6; reply_code = 6;
strcpy(reply_name, my_name); strcpy(reply_name,myname);
strupper(reply_name); strupper(reply_name);
add_slashes = True; add_slashes = True;
DEBUG(3,("Domain login request from %s(%s) user=%s\n", DEBUG(3,("Domain login request from %s(%s) user=%s\n",
@ -90,7 +87,7 @@ void process_logon_packet(struct packet_struct *p,char *buf,int len)
reply_code = 7; reply_code = 7;
strcpy(reply_name,lp_domain_controller()); strcpy(reply_name,lp_domain_controller());
if (!*reply_name) { if (!*reply_name) {
strcpy(reply_name,my_name); strcpy(reply_name,myname);
reply_code = 0xC; reply_code = 0xC;
} }
strupper(reply_name); strupper(reply_name);
@ -124,8 +121,8 @@ void process_logon_packet(struct packet_struct *p,char *buf,int len)
PutUniCode(q,reply_name); PutUniCode(q,reply_name);
q += 2*(strlen(reply_name) + 1); q += 2*(strlen(reply_name) + 1);
PutUniCode(q,work->work_group); PutUniCode(q,lp_workgroup());
q += 2*(strlen(work->work_group) + 1); q += 2*(strlen(lp_workgroup()) + 1);
SIVAL(q,0,1); SIVAL(q,0,1);
q += 4; q += 4;
@ -137,6 +134,6 @@ void process_logon_packet(struct packet_struct *p,char *buf,int len)
q += 2; q += 2;
send_mailslot_reply(logname,ClientDGRAM,outbuf,PTR_DIFF(q,outbuf), send_mailslot_reply(logname,ClientDGRAM,outbuf,PTR_DIFF(q,outbuf),
my_name,&dgram->source_name.name[0],0x20,0,p->ip, myname,&dgram->source_name.name[0],0x20,0,p->ip,
*iface_ip(p->ip)); *iface_ip(p->ip));
} }

View File

@ -38,92 +38,7 @@ BOOL CanRecurse = True;
extern pstring scope; extern pstring scope;
extern struct in_addr ipgrp; extern struct in_addr ipgrp;
extern uint16 name_trn_id; static uint16 name_trn_id=0;
/****************************************************************************
process a nmb packet
****************************************************************************/
static void process_nmb(struct packet_struct *p)
{
struct nmb_packet *nmb = &p->packet.nmb;
debug_nmb_packet(p);
switch (nmb->header.opcode)
{
case 8: /* what is this?? */
case NMB_REG:
case NMB_REG_REFRESH:
{
if (nmb->header.response)
{
if (nmb->header.ancount==0) break;
response_netbios_packet(p);
}
else
{
if (nmb->header.qdcount==0 || nmb->header.arcount==0) break;
reply_name_reg(p);
}
break;
}
case 0:
{
if (nmb->header.response)
{
switch (nmb->question.question_type)
{
case 0x0:
{
response_netbios_packet(p);
break;
}
}
return;
}
else if (nmb->header.qdcount>0)
{
switch (nmb->question.question_type)
{
case NMB_QUERY:
{
reply_name_query(p);
break;
}
case NMB_STATUS:
{
reply_name_status(p);
break;
}
}
return;
}
break;
}
case NMB_REL:
{
if (nmb->header.qdcount==0 || nmb->header.arcount==0)
{
DEBUG(2,("netbios release packet rejected\n"));
break;
}
if (nmb->header.response)
{
if (nmb->header.ancount==0) break;
response_netbios_packet(p);
}
else
{
reply_name_release(p);
}
break;
}
}
}
/*************************************************************************** /***************************************************************************
@ -150,7 +65,7 @@ void debug_browse_data(char *outbuf, int len)
for (j = 0; j < 16; j++) for (j = 0; j < 16; j++)
{ {
if (i+j >= len) break; if (i+j >= len) break;
DEBUG(4, (" %02x", (unsigned char)outbuf[i+j])); DEBUG(4, (" %02x", outbuf[i+j]));
} }
DEBUG(4, ("\n")); DEBUG(4, ("\n"));
@ -159,20 +74,23 @@ void debug_browse_data(char *outbuf, int len)
} }
/***************************************************************************
updates the unique transaction identifier
**************************************************************************/
static void update_name_trn_id(void)
{
if (!name_trn_id)
{
name_trn_id = (time(NULL)%(unsigned)0x7FFF) + (getpid()%(unsigned)100);
}
name_trn_id = (name_trn_id+1) % (unsigned)0x7FFF;
}
/**************************************************************************** /****************************************************************************
initiate a netbios packet initiate a netbios packet
if we are making queries to samba, then the ip must be zero. in this
instance, the packet is constructed and then dealt with immediately.
netbios packets sent to an ip of zero are dealt with immediately by calling
process_nmb(), in order to allow, for example, querying of samba's WINS
records. at first, this seems like a really dumb thing to do. but then
again, the packet_struct created contains _exactly_ the information
required. the alternative is to take packet_struct out of the loop,
which is a fairly messy operation.
****************************************************************************/ ****************************************************************************/
BOOL initiate_netbios_packet(uint16 id, void initiate_netbios_packet(uint16 *id,
int fd,int quest_type,char *name,int name_type, int fd,int quest_type,char *name,int name_type,
int nb_flags,BOOL bcast,BOOL recurse, int nb_flags,BOOL bcast,BOOL recurse,
struct in_addr to_ip) struct in_addr to_ip)
@ -180,23 +98,30 @@ BOOL initiate_netbios_packet(uint16 id,
struct packet_struct p; struct packet_struct p;
struct nmb_packet *nmb = &p.packet.nmb; struct nmb_packet *nmb = &p.packet.nmb;
struct res_rec additional_rec; struct res_rec additional_rec;
char *pkt_type = "unknown"; char *packet_type = "unknown";
int opcode = -1; int opcode = -1;
if (quest_type == NMB_STATUS) { pkt_type = "nmb_status"; opcode = 0; } if (!id) return;
if (quest_type == NMB_QUERY ) { pkt_type = "nmb_query"; opcode = 0; }
if (quest_type == NMB_REG ) { pkt_type = "nmb_reg"; opcode = 5; } if (quest_type == NMB_STATUS) { packet_type = "nmb_status"; opcode = 0; }
if (quest_type == NMB_REG_REFRESH) { pkt_type="nmb_reg_refresh"; opcode=9; } if (quest_type == NMB_QUERY ) { packet_type = "nmb_query"; opcode = 0; }
if (quest_type == NMB_REL ) { pkt_type = "nmb_rel"; opcode = 6; } if (quest_type == NMB_REG ) { packet_type = "nmb_reg"; opcode = 5; }
if (quest_type == NMB_REG_REFRESH ) { packet_type = "nmb_reg_refresh"; opcode = 9; }
if (quest_type == NMB_REL ) { packet_type = "nmb_rel"; opcode = 6; }
DEBUG(4,("initiating netbios packet: %s %s(%x) (bcast=%s) %s\n", DEBUG(4,("initiating netbios packet: %s %s(%x) (bcast=%s) %s\n",
pkt_type, name, name_type, BOOLSTR(bcast), inet_ntoa(to_ip))); packet_type, name, name_type, BOOLSTR(bcast), inet_ntoa(to_ip)));
if (opcode == -1) return False; if (opcode == -1) return;
bzero((char *)&p,sizeof(p)); bzero((char *)&p,sizeof(p));
nmb->header.name_trn_id = id; if (*id == 0xffff) {
update_name_trn_id();
*id = name_trn_id; /* allow resending with same id */
}
nmb->header.name_trn_id = *id;
nmb->header.opcode = opcode; nmb->header.opcode = opcode;
nmb->header.response = False; nmb->header.response = False;
@ -245,21 +170,12 @@ BOOL initiate_netbios_packet(uint16 id,
p.timestamp = time(NULL); p.timestamp = time(NULL);
p.packet_type = NMB_PACKET; p.packet_type = NMB_PACKET;
if (zero_ip(to_ip)) /* samba's own ip */
{
DEBUG(4,("process packet ourselves\n"));
/* respond internally to the packet. */
process_nmb(&p);
}
else
{
if (!send_packet(&p)) { if (!send_packet(&p)) {
DEBUG(3,("send_packet to %s %d failed\n",inet_ntoa(p.ip),p.port)); DEBUG(3,("send_packet to %s %d failed\n",inet_ntoa(p.ip),p.port));
return False; *id = 0xffff;
}
} }
return True; return;
} }
@ -358,16 +274,7 @@ void reply_netbios_packet(struct packet_struct *p1,int trn_id,
debug_nmb_packet(&p); debug_nmb_packet(&p);
if (zero_ip(p.ip)) /* samba's own ip */
{
DEBUG(4,("process response packet ourselves\n"));
/* respond internally to the packet. */
process_nmb(&p);
}
else
{
send_packet(&p); send_packet(&p);
}
} }
@ -472,6 +379,83 @@ static void process_dgram(struct packet_struct *p)
} }
} }
/****************************************************************************
process a nmb packet
****************************************************************************/
static void process_nmb(struct packet_struct *p)
{
struct nmb_packet *nmb = &p->packet.nmb;
debug_nmb_packet(p);
switch (nmb->header.opcode)
{
case 8: /* what is this?? */
case NMB_REG:
case NMB_REG_REFRESH:
{
if (nmb->header.qdcount==0 || nmb->header.arcount==0) break;
if (nmb->header.response)
response_netbios_packet(p); /* response to registration dealt
with here */
else
reply_name_reg(p);
break;
}
case 0:
{
if (nmb->header.response)
{
switch (nmb->question.question_type)
{
case 0x0:
{
response_netbios_packet(p);
break;
}
}
return;
}
else if (nmb->header.qdcount>0)
{
switch (nmb->question.question_type)
{
case NMB_QUERY:
{
reply_name_query(p);
break;
}
case NMB_STATUS:
{
reply_name_status(p);
break;
}
}
return;
}
break;
}
case NMB_REL:
{
if (nmb->header.qdcount==0 || nmb->header.arcount==0)
{
DEBUG(2,("netbios release packet rejected\n"));
break;
}
if (nmb->header.response)
response_netbios_packet(p); /* response to reply dealt with
in here */
else
reply_name_release(p);
break;
}
}
}
/******************************************************************* /*******************************************************************
run elements off the packet queue till its empty run elements off the packet queue till its empty
******************************************************************/ ******************************************************************/

View File

@ -35,21 +35,6 @@ extern pstring scope;
extern struct in_addr ipzero; extern struct in_addr ipzero;
extern struct in_addr ipgrp; extern struct in_addr ipgrp;
uint16 name_trn_id=0;
/***************************************************************************
updates the unique transaction identifier
**************************************************************************/
void update_name_trn_id(void)
{
if (!name_trn_id)
{
name_trn_id = (time(NULL)%(unsigned)0x7FFF) + (getpid()%(unsigned)100);
}
name_trn_id = (name_trn_id+1) % (unsigned)0x7FFF;
}
/*************************************************************************** /***************************************************************************
deals with an entry before it dies deals with an entry before it dies
@ -75,7 +60,7 @@ static void dead_netbios_entry(struct subnet_record *d,
/* IMPORTANT: see query_refresh_names() */ /* IMPORTANT: see query_refresh_names() */
if ((!NAME_GROUP(n->reply.nb_flags))) if ((!NAME_GROUP(n->nb_flags)))
{ {
struct subnet_record *d1 = find_subnet(ipgrp); struct subnet_record *d1 = find_subnet(ipgrp);
if (d1) if (d1)
@ -131,8 +116,8 @@ static void dead_netbios_entry(struct subnet_record *d,
*/ */
add_name_respond(d,n->fd,d->myip, n->response_id ,&n->name, add_name_respond(d,n->fd,d->myip, n->response_id ,&n->name,
n->reply.nb_flags, GET_TTL(0), n->nb_flags, GET_TTL(0),
n->reply.ip, False, n->reply.ip); n->reply_to_ip, False, n->reply_to_ip);
if (!n->bcast) if (!n->bcast)
{ {
@ -156,8 +141,8 @@ static void dead_netbios_entry(struct subnet_record *d,
/* IMPORTANT: see response_name_reg() */ /* IMPORTANT: see response_name_reg() */
name_register_work(d,n->token,n->name.name,n->name.name_type, name_register_work(d,n->name.name,n->name.name_type,
n->source, &n->reply, n->ttl, n->reply.ip, n->bcast); n->nb_flags, n->ttl, n->reply_to_ip, n->bcast);
} }
else else
{ {
@ -206,9 +191,9 @@ void expire_netbios_response_entries()
if (n->repeat_count > 0) if (n->repeat_count > 0)
{ {
/* resend the entry */ /* resend the entry */
initiate_netbios_packet(n->response_id, n->fd, n->quest_type, initiate_netbios_packet(&n->response_id, n->fd, n->quest_type,
n->name.name, n->name.name_type, n->name.name, n->name.name_type,
n->reply.nb_flags, n->bcast, n->recurse, n->send_ip); n->nb_flags, n->bcast, n->recurse, n->send_ip);
n->repeat_time += n->repeat_interval; /* XXXX ms needed */ n->repeat_time += n->repeat_interval; /* XXXX ms needed */
n->repeat_count--; n->repeat_count--;
@ -232,47 +217,17 @@ void expire_netbios_response_entries()
/**************************************************************************** /****************************************************************************
wrapper function to override a broadcast message and send it to the WINS
name server instead, if it exists. if wins is false, and there has been no
WINS server specified, the packet will NOT be sent.
****************************************************************************/ ****************************************************************************/
void queue_netbios_pkt_wins(struct subnet_record *d, struct response_record *queue_netbios_pkt_wins(struct subnet_record *d,
int fd,int quest_type,enum state_type state, int fd,int quest_type,enum state_type state,
int token, char *name,int name_type, char *name,int name_type,int nb_flags, time_t ttl,
enum name_source source, int nb_flags, time_t ttl,
int server_type, char *my_name, char *my_comment, int server_type, char *my_name, char *my_comment,
BOOL bcast,BOOL recurse, BOOL bcast,BOOL recurse,
struct in_addr send_ip, struct in_addr reply_to_ip) struct in_addr send_ip, struct in_addr reply_to_ip)
{ {
queue_netbios_packet(d,fd, quest_type, state,
token, name, name_type, source, nb_flags, ttl,
server_type,my_name,my_comment,
bcast, recurse, send_ip, reply_to_ip);
}
/****************************************************************************
initiate a netbios name query to find someone's or someones' IP
this is intended to be used (not exclusively) for broadcasting to
master browsers (WORKGROUP(1d or 1b) or __MSBROWSE__(1)) to get
complete lists across a wide area network
a broadcast message will be over-ridden if the packet it sent to an
ip of zero, and the packet will be sent to the WINS name server instead,
if it exists. if samba is configured to be a WINS server, then the
packet will be dealt with _as if_ it had been sent on the network,
but in fact the function process_nmb() is called.
****************************************************************************/
void queue_netbios_packet(struct subnet_record *d,
int fd,int quest_type,enum state_type state,
int token, char *name, int name_type,
enum name_source source, int nb_flags, time_t ttl,
int server_type, char *my_name, char *my_comment,
BOOL bcast,BOOL recurse,
struct in_addr send_ip, struct in_addr reply_to_ip)
{
struct response_record *n;
/* ha ha. no. do NOT broadcast to 255.255.255.255: it's a pseudo address */
if (ip_equal(send_ip, ipgrp)) return;
/* XXXX note: please see rfc1001.txt section 10 for details on this /* XXXX note: please see rfc1001.txt section 10 for details on this
function: it is currently inappropriate to use this - it will do function: it is currently inappropriate to use this - it will do
for now - once there is a clarification of B, M and P nodes and for now - once there is a clarification of B, M and P nodes and
@ -298,38 +253,50 @@ void queue_netbios_packet(struct subnet_record *d,
} }
} }
if (zero_ip(send_ip)) if (zero_ip(send_ip)) return NULL;
{
/* doing a netbios query to samba as a WINS server, internally */ return queue_netbios_packet(d,fd, quest_type, state,
if (lp_wins_support()) /* samba is a WINS server */ name, name_type, nb_flags, ttl,
{ server_type,my_name,my_comment,
DEBUG(4,("queue netbios packet with ourselves...\n")); bcast, recurse, send_ip, reply_to_ip);
bcast = False; }
}
else
{ /****************************************************************************
return; initiate a netbios name query to find someone's or someones' IP
} this is intended to be used (not exclusively) for broadcasting to
master browsers (WORKGROUP(1d or 1b) or __MSBROWSE__(1)) to get
complete lists across a wide area network
****************************************************************************/
struct response_record *queue_netbios_packet(struct subnet_record *d,
int fd,int quest_type,enum state_type state,char *name,
int name_type,int nb_flags, time_t ttl,
int server_type, char *my_name, char *my_comment,
BOOL bcast,BOOL recurse,
struct in_addr send_ip, struct in_addr reply_to_ip)
{
struct in_addr wins_ip = ipgrp;
struct response_record *n;
uint16 id = 0xffff;
/* ha ha. no. do NOT broadcast to 255.255.255.255: it's a pseudo address */
if (ip_equal(wins_ip, send_ip)) return NULL;
initiate_netbios_packet(&id, fd, quest_type, name, name_type,
nb_flags, bcast, recurse, send_ip);
if (id == 0xffff) {
DEBUG(4,("did not initiate netbios packet: %s\n", inet_ntoa(send_ip)));
return NULL;
} }
update_name_trn_id(); if ((n = make_response_queue_record(state,id,fd,
quest_type,name,name_type,nb_flags,ttl,
/* queue the response expected because if we do a query with an ip server_type,my_name, my_comment,
of zero, we are expecting to hear from ourself immediately */ bcast,recurse,send_ip,reply_to_ip)))
if ((n = make_response_queue_record(state, name_trn_id, fd, quest_type,
token, name, name_type, source, nb_flags, ttl,
server_type, my_name, my_comment,
bcast, recurse, send_ip, reply_to_ip)))
{ {
add_response_record(d,n); add_response_record(d,n);
return n;
} }
return NULL;
if (!initiate_netbios_packet(name_trn_id, fd, quest_type, name, name_type,
nb_flags, bcast, recurse, send_ip))
{
/* packet wasn't sent - not expecting a response */
DEBUG(4,("did not initiate netbios packet: %s\n", inet_ntoa(send_ip)));
remove_response_record(d, n);
return;
}
} }

View File

@ -51,7 +51,7 @@ extern uint16 nb_type; /* samba's NetBIOS type */
XXXX at present, the name is removed _even_ if a WINS server says keep it. XXXX at present, the name is removed _even_ if a WINS server says keep it.
****************************************************************************/ ****************************************************************************/
void remove_name_entry(struct subnet_record *d, int token, char *name,int type) void remove_name_entry(struct subnet_record *d, char *name,int type)
{ {
/* XXXX BUG: if samba is offering WINS support, it should still broadcast /* XXXX BUG: if samba is offering WINS support, it should still broadcast
a de-registration packet to the local subnet before removing the a de-registration packet to the local subnet before removing the
@ -80,18 +80,17 @@ void remove_name_entry(struct subnet_record *d, int token, char *name,int type)
don't really own */ don't really own */
remove_netbios_name(d,name,type,SELF,n2->ip_flgs[0].ip); remove_netbios_name(d,name,type,SELF,n2->ip_flgs[0].ip);
if (ip_equal(d->bcast_ip, ipgrp)) if (ip_equal(d->bcast_ip, ipgrp)) {
{ if (!lp_wins_support()) {
/* use WINS. this function can now be used to _either_ /* not a WINS server: we have to release them on the network */
do the release on samba's own database _or_ release
the name with an arbitrary WINS server */
queue_netbios_pkt_wins(d,ClientNMB,NMB_REL,NAME_RELEASE, queue_netbios_pkt_wins(d,ClientNMB,NMB_REL,NAME_RELEASE,
token, name, type, SELF, 0, 0,0,NULL,NULL, name, type, 0, 0,0,NULL,NULL,
False, True, ipzero, ipzero); False, True, ipzero, ipzero);
}
} else { } else {
/* local interface: release them on the network */ /* local interface: release them on the network */
queue_netbios_packet(d,ClientNMB,NMB_REL,NAME_RELEASE, queue_netbios_packet(d,ClientNMB,NMB_REL,NAME_RELEASE,
token, name, type, SELF, 0, 0,0,NULL,NULL, name, type, 0, 0,0,NULL,NULL,
True, True, d->bcast_ip, d->bcast_ip); True, True, d->bcast_ip, d->bcast_ip);
} }
} }
@ -104,8 +103,7 @@ void remove_name_entry(struct subnet_record *d, int token, char *name,int type)
it's just a matter of when this will be done (e.g after a time-out). it's just a matter of when this will be done (e.g after a time-out).
****************************************************************************/ ****************************************************************************/
void add_my_name_entry(struct subnet_record *d, int token, void add_my_name_entry(struct subnet_record *d,char *name,int type,int nb_flags)
char *name,int type,int nb_flags)
{ {
BOOL re_reg = False; BOOL re_reg = False;
struct nmb_name n; struct nmb_name n;
@ -125,7 +123,6 @@ void add_my_name_entry(struct subnet_record *d, int token,
if (ip_equal(d->bcast_ip, ipgrp)) if (ip_equal(d->bcast_ip, ipgrp))
{ {
#if 0
if (lp_wins_support()) if (lp_wins_support())
{ {
/* we are a WINS server. */ /* we are a WINS server. */
@ -134,37 +131,25 @@ void add_my_name_entry(struct subnet_record *d, int token,
actually be true actually be true
*/ */
struct nmb_ip data;
data.nb_flags = nb_flags;
putip(&data.ip, ipzero);
DEBUG(4,("samba as WINS server adding: ")); DEBUG(4,("samba as WINS server adding: "));
/* this will call add_netbios_entry() */ /* this will call add_netbios_entry() */
name_register_work(d, name, type, nb_flags,0, ipzero, False);
name_register_work(d,token,name,type,SELF,&data,GET_TTL(0),ipzero,False);
} }
else else
{ {
#endif
/* ipzero when not using an arbitrary wins server results in the
netbios packet being short-circuited to process_nmb()
*/
/* a time-to-live allows us to refresh this name with the WINS server. */ /* a time-to-live allows us to refresh this name with the WINS server. */
queue_netbios_pkt_wins(d,ClientNMB, queue_netbios_pkt_wins(d,ClientNMB,
re_reg ? NMB_REG_REFRESH : NMB_REG, NAME_REGISTER, re_reg ? NMB_REG_REFRESH : NMB_REG, NAME_REGISTER,
token, name, type, SELF, nb_flags, GET_TTL(0),0,NULL,NULL, name, type, nb_flags, GET_TTL(0),0,NULL,NULL,
False, True, ipzero, ipzero); False, True, ipzero, ipzero);
#if 0
} }
#endif
} }
else else
{ {
/* broadcast the packet, but it comes from ipzero */ /* broadcast the packet, but it comes from ipzero */
queue_netbios_packet(d,ClientNMB, queue_netbios_packet(d,ClientNMB,
re_reg ? NMB_REG_REFRESH : NMB_REG, NAME_REGISTER, re_reg ? NMB_REG_REFRESH : NMB_REG, NAME_REGISTER,
token, name, type, SELF, nb_flags, GET_TTL(0),0,NULL,NULL, name, type, nb_flags, GET_TTL(0),0,NULL,NULL,
True, True, d->bcast_ip, ipzero); True, True, d->bcast_ip, ipzero);
} }
} }
@ -176,8 +161,6 @@ void add_my_name_entry(struct subnet_record *d, int token,
void add_my_names(void) void add_my_names(void)
{ {
struct subnet_record *d; struct subnet_record *d;
int token;
/* each subnet entry, including WINS pseudo-subnet, has SELF names */ /* each subnet entry, including WINS pseudo-subnet, has SELF names */
/* XXXX if there was a transport layer added to samba (ipx/spx etc) then /* XXXX if there was a transport layer added to samba (ipx/spx etc) then
@ -186,58 +169,34 @@ void add_my_names(void)
for (d = subnetlist; d; d = d->next) for (d = subnetlist; d; d = d->next)
{ {
BOOL wins = ip_equal(d->bcast_ip,ipgrp); BOOL wins = lp_wins_support() && ip_equal(d->bcast_ip,ipgrp);
for (token = 0; token < get_num_workgroups(); token++) add_my_name_entry(d, myname,0x20,nb_type|NB_ACTIVE);
{ add_my_name_entry(d, myname,0x03,nb_type|NB_ACTIVE);
char *my_name = conf_browsing_alias(token); add_my_name_entry(d, myname,0x00,nb_type|NB_ACTIVE);
char *wg_name = conf_workgroup_name(token); add_my_name_entry(d, myname,0x1f,nb_type|NB_ACTIVE);
if (my_name)
{
add_my_name_entry(d, token, my_name,0x20,nb_type|NB_ACTIVE);
add_my_name_entry(d, token, my_name,0x03,nb_type|NB_ACTIVE);
add_my_name_entry(d, token, my_name,0x00,nb_type|NB_ACTIVE);
add_my_name_entry(d, token, my_name,0x1f,nb_type|NB_ACTIVE);
}
if (wg_name && conf_should_domain_logon(token))
{
/* the 0x1c is to do with domain logons */
add_my_name_entry(d, token, wg_name,0x1c,nb_type|NB_ACTIVE|NB_GROUP);
}
}
/* these names are added permanently (ttl of zero) and will NOT be /* these names are added permanently (ttl of zero) and will NOT be
refreshed with the WINS server */ refreshed with the WINS server */
add_netbios_entry(d,"*",0x0,nb_type|NB_ACTIVE,0,SELF,d->myip,False,wins); add_netbios_entry(d,"*",0x0,nb_type|NB_ACTIVE,0,SELF,d->myip,False,wins);
add_netbios_entry(d,"*",0x20,nb_type|NB_ACTIVE,0,SELF,d->myip,False,wins);
add_netbios_entry(d,"__SAMBA__",0x20,nb_type|NB_ACTIVE,0,SELF,d->myip,False,wins); add_netbios_entry(d,"__SAMBA__",0x20,nb_type|NB_ACTIVE,0,SELF,d->myip,False,wins);
add_netbios_entry(d,"__SAMBA__",0x00,nb_type|NB_ACTIVE,0,SELF,d->myip,False,wins); add_netbios_entry(d,"__SAMBA__",0x00,nb_type|NB_ACTIVE,0,SELF,d->myip,False,wins);
if (lp_domain_logons()) {
/* XXXX the 0x1c is apparently something to do with domain logons */
add_my_name_entry(d, lp_workgroup(),0x1c,nb_type|NB_ACTIVE|NB_GROUP);
} }
}
/* check becoming a domain master under all browser aliases */ if (lp_domain_master() && (d = find_subnet(ipgrp)))
if ((d = find_subnet(ipgrp)))
{ {
for (token = 0; token < get_num_workgroups(); token++) struct work_record *work = find_workgroupstruct(d, lp_workgroup(), True);
{
if (conf_should_domain_master(token))
{
char *work_name = conf_workgroup_name(token);
if (work_name)
{
struct work_record *work = find_workgroupstruct(d,work_name,True);
if (work && work->state == MST_NONE) if (work && work->state == MST_NONE)
{ {
work->state = MST_DOMAIN_NONE; work->state = MST_DOMAIN_NONE;
become_master(d, work); become_master(d, work);
} }
} }
}
}
}
} }
@ -260,7 +219,35 @@ void remove_my_names()
/* get all SELF names removed from the WINS server's database */ /* get all SELF names removed from the WINS server's database */
/* XXXX note: problem occurs if this removes the wrong one! */ /* XXXX note: problem occurs if this removes the wrong one! */
remove_name_entry(d, -1, n->name.name, n->name.name_type); remove_name_entry(d,n->name.name, n->name.name_type);
}
}
}
}
/*******************************************************************
refresh my own names
******************************************************************/
void refresh_my_names(time_t t)
{
struct subnet_record *d;
for (d = subnetlist; d; d = d->next)
{
struct name_record *n;
for (n = d->namelist; n; n = n->next)
{
/* each SELF name has an individual time to be refreshed */
if (n->source == SELF && n->refresh_time < time(NULL) &&
n->death_time != 0)
{
add_my_name_entry(d,n->name.name,n->name.name_type,
n->ip_flgs[0].nb_flags);
/* they get a new lease on life :-) */
n->death_time += GET_TTL(0);
n->refresh_time += GET_TTL(0);
} }
} }
} }
@ -302,7 +289,7 @@ void query_refresh_names(void)
for (n = d->namelist; n; n = n->next) for (n = d->namelist; n; n = n->next)
{ {
/* only do unique, registered names. */ /* only do unique, registered names */
if (n->source != REGISTER) continue; if (n->source != REGISTER) continue;
if (!NAME_GROUP(n->ip_flgs[0].nb_flags)) continue; if (!NAME_GROUP(n->ip_flgs[0].nb_flags)) continue;
@ -312,8 +299,8 @@ void query_refresh_names(void)
DEBUG(3,("Polling name %s\n", namestr(&n->name))); DEBUG(3,("Polling name %s\n", namestr(&n->name)));
queue_netbios_packet(d,ClientNMB,NMB_QUERY,NAME_QUERY_CONFIRM, queue_netbios_packet(d,ClientNMB,NMB_QUERY,NAME_QUERY_CONFIRM,
-1,n->name.name, n->name.name_type, n->name.name, n->name.name_type,
n->source,0,0,0,NULL,NULL, 0,0,0,NULL,NULL,
False,False,n->ip_flgs[0].ip,n->ip_flgs[0].ip); False,False,n->ip_flgs[0].ip,n->ip_flgs[0].ip);
count++; count++;
} }

View File

@ -294,8 +294,8 @@ void reply_name_reg(struct packet_struct *p)
/* initiate some enquiries to the current owner. */ /* initiate some enquiries to the current owner. */
queue_netbios_packet(d,ClientNMB,NMB_QUERY, queue_netbios_packet(d,ClientNMB,NMB_QUERY,
NAME_REGISTER_CHALLENGE, NAME_REGISTER_CHALLENGE,
-1,reply_name->name,reply_name->name_type, reply_name->name,reply_name->name_type,
n->source, nb_flags,0,0,NULL,NULL, nb_flags,0,0,NULL,NULL,
False, False, n->ip_flgs[0].ip, p->ip); False, False, n->ip_flgs[0].ip, p->ip);
} }
else else

View File

@ -46,29 +46,38 @@ extern struct in_addr ipzero;
response for a reg release received. samba has asked a WINS server if it response for a reg release received. samba has asked a WINS server if it
could release a name. could release a name.
**************************************************************************/ **************************************************************************/
static void response_name_release(struct nmb_ip *data, struct nmb_name *name, static void response_name_release(struct subnet_record *d,
struct subnet_record *d) struct packet_struct *p)
{ {
struct nmb_packet *nmb = &p->packet.nmb;
char *name = nmb->question.question_name.name;
int type = nmb->question.question_name.name_type;
DEBUG(4,("response name release received\n")); DEBUG(4,("response name release received\n"));
if (data) if (nmb->header.rcode == 0 && nmb->answers->rdata)
{ {
/* IMPORTANT: see expire_netbios_response_entries() */ /* IMPORTANT: see expire_netbios_response_entries() */
struct in_addr found_ip;
putip((char*)&found_ip,&nmb->answers->rdata[2]);
/* NOTE: we only release our own names at present */ /* NOTE: we only release our own names at present */
if (ismyip(data->ip)) if (ismyip(found_ip))
{ {
name_unregister_work(d, name->name, name->name_type); name_unregister_work(d,name,type);
} }
else else
{ {
DEBUG(2,("name release for different ip! %s %s\n", DEBUG(2,("name release for different ip! %s %s\n",
inet_ntoa(data->ip),namestr(name))); inet_ntoa(found_ip),
namestr(&nmb->question.question_name)));
} }
} }
else else
{ {
DEBUG(2,("name release for %s rejected!\n",namestr(name))); DEBUG(2,("name release for %s rejected!\n",
namestr(&nmb->question.question_name)));
/* XXXX PANIC! what to do if it's one of samba's own names? */ /* XXXX PANIC! what to do if it's one of samba's own names? */
@ -82,25 +91,34 @@ static void response_name_release(struct nmb_ip *data, struct nmb_name *name,
/**************************************************************************** /****************************************************************************
response for a reg request received response for a reg request received
**************************************************************************/ **************************************************************************/
static void response_name_reg(struct nmb_ip *data, struct nmb_name *name, static void response_name_reg(struct subnet_record *d, struct packet_struct *p)
time_t ttl, BOOL bcast, struct in_addr source_ip,
struct subnet_record *d, enum name_source source, int token)
{ {
struct nmb_packet *nmb = &p->packet.nmb;
char *name = nmb->question.question_name.name;
int type = nmb->question.question_name.name_type;
BOOL bcast = nmb->header.nm_flags.bcast;
DEBUG(4,("response name registration received!\n")); DEBUG(4,("response name registration received!\n"));
if (data) if (nmb->header.rcode == 0 && nmb->answers->rdata)
{ {
/* IMPORTANT: see expire_netbios_response_entries() */ /* IMPORTANT: see expire_netbios_response_entries() */
name_register_work(d, token, name->name,name->name_type, int nb_flags = nmb->answers->rdata[0];
source, data, ttl, source_ip, bcast); int ttl = nmb->answers->ttl;
struct in_addr found_ip;
putip((char*)&found_ip,&nmb->answers->rdata[2]);
name_register_work(d,name,type,nb_flags,ttl,found_ip,bcast);
} }
else else
{ {
DEBUG(1,("name registration for %s rejected!\n", namestr(name))); DEBUG(1,("name registration for %s rejected!\n",
namestr(&nmb->question.question_name)));
/* oh dear. we have problems. possibly unbecome a master browser. */ /* oh dear. we have problems. possibly unbecome a master browser. */
name_unregister_work(d,name->name,name->name_type); name_unregister_work(d,name,type);
} }
} }
@ -109,8 +127,8 @@ static void response_name_reg(struct nmb_ip *data, struct nmb_name *name,
response from a name query announce host response from a name query announce host
NAME_QUERY_ANNOUNCE_HOST is dealt with here NAME_QUERY_ANNOUNCE_HOST is dealt with here
****************************************************************************/ ****************************************************************************/
static void response_announce_host(struct nmb_ip *data, static void response_announce_host(struct nmb_name *ans_name,
struct nmb_name *ans_name, struct nmb_packet *nmb,
struct response_record *n, struct subnet_record *d) struct response_record *n, struct subnet_record *d)
{ {
DEBUG(4, ("Name query at %s ip %s - ", DEBUG(4, ("Name query at %s ip %s - ",
@ -125,7 +143,7 @@ static void response_announce_host(struct nmb_ip *data,
return; return;
} }
if (data) if (nmb->header.rcode == 0 && nmb->answers->rdata)
{ {
/* we had sent out a name query to the current owner /* we had sent out a name query to the current owner
of a name because someone else wanted it. now they of a name because someone else wanted it. now they
@ -135,25 +153,27 @@ static void response_announce_host(struct nmb_ip *data,
/* first check all the details are correct */ /* first check all the details are correct */
if (data->nb_flags != n->reply.nb_flags) int nb_flags = nmb->answers->rdata[0];
struct in_addr found_ip;
putip((char*)&found_ip,&nmb->answers->rdata[2]);
if (nb_flags != n->nb_flags)
{ {
/* someone gave us the wrong nb_flags as a reply. oops. */ /* someone gave us the wrong nb_flags as a reply. oops. */
/* XXXX should say to them 'oi! release that name!' */ /* XXXX should say to them 'oi! release that name!' */
DEBUG(4,("expected nb_flags: %d\n", n->reply.nb_flags)); DEBUG(4,("expected nb_flags: %d\n", n->nb_flags));
DEBUG(4,("unexpected nb_flags: %d\n", data->nb_flags)); DEBUG(4,("unexpected nb_flags: %d\n", nb_flags));
return; return;
} }
/* do an announce host */ /* do an announce host */
do_announce_host(ANN_HostAnnouncement, do_announce_host(ANN_HostAnnouncement,
n->my_name , 0x00, d->myip, n->my_name , 0x00, d->myip,
n->name.name, 0x1d, data->ip, n->name.name, 0x1d, found_ip,
n->ttl, n->ttl,
n->my_name, n->server_type, n->my_name, n->server_type, n->my_comment);
HOST_MAJOR_VERSION, HOST_MINOR_VERSION,
HOST_BROWSE_VERSION, HOST_BROWSE_SIGNATURE,
n->my_comment);
} }
else else
{ {
@ -176,9 +196,9 @@ static void response_server_check(struct nmb_name *ans_name,
/* initiate a name status check on the server that replied */ /* initiate a name status check on the server that replied */
queue_netbios_packet(d,ClientNMB,NMB_STATUS, cmd, queue_netbios_packet(d,ClientNMB,NMB_STATUS, cmd,
-1,ans_name->name, ans_name->name_type, ans_name->name, ans_name->name_type,
0,0,0,0,NULL,NULL, 0,0,0,NULL,NULL,
False,False,n->send_ip,n->reply.ip); False,False,n->send_ip,n->reply_to_ip);
} }
@ -279,7 +299,7 @@ static BOOL interpret_node_status(struct subnet_record *d,
and NAME_STATUS_SRV_CHK dealt with here. and NAME_STATUS_SRV_CHK dealt with here.
****************************************************************************/ ****************************************************************************/
static void response_name_status_check(struct in_addr ip, static void response_name_status_check(struct in_addr ip,
char *data, BOOL bcast, struct nmb_packet *nmb, BOOL bcast,
struct response_record *n, struct subnet_record *d) struct response_record *n, struct subnet_record *d)
{ {
/* NMB_STATUS arrives: contains workgroup name and server name required. /* NMB_STATUS arrives: contains workgroup name and server name required.
@ -288,11 +308,13 @@ static void response_name_status_check(struct in_addr ip,
struct nmb_name name; struct nmb_name name;
fstring serv_name; fstring serv_name;
if (interpret_node_status(d,data,&name,name.name_type,serv_name,ip,bcast)) if (interpret_node_status(d,nmb->answers->rdata,
&name,name.name_type,serv_name,ip,bcast))
{ {
if (*serv_name) if (*serv_name)
{ {
sync_server(n->state,serv_name,name.name,name.name_type,n->send_ip); sync_server(n->state,serv_name,
name.name,name.name_type, n->send_ip);
} }
} }
else else
@ -306,7 +328,7 @@ static void response_name_status_check(struct in_addr ip,
response from a name query for secured WINS registration. a state of response from a name query for secured WINS registration. a state of
NAME_REGISTER_CHALLENGE is dealt with here. NAME_REGISTER_CHALLENGE is dealt with here.
****************************************************************************/ ****************************************************************************/
static void response_name_query_register(struct nmb_ip *data, static void response_name_query_register(struct nmb_packet *nmb,
struct nmb_name *ans_name, struct nmb_name *ans_name,
struct response_record *n, struct subnet_record *d) struct response_record *n, struct subnet_record *d)
{ {
@ -325,7 +347,7 @@ static void response_name_query_register(struct nmb_ip *data,
return; return;
} }
if (data) if (nmb->header.rcode == 0 && nmb->answers->rdata)
{ {
/* we had sent out a name query to the current owner /* we had sent out a name query to the current owner
of a name because someone else wanted it. now they of a name because someone else wanted it. now they
@ -335,27 +357,32 @@ static void response_name_query_register(struct nmb_ip *data,
/* first check all the details are correct */ /* first check all the details are correct */
if (data->nb_flags != n->reply.nb_flags) int nb_flags = nmb->answers->rdata[0];
struct in_addr found_ip;
putip((char*)&found_ip,&nmb->answers->rdata[2]);
if (nb_flags != n->nb_flags)
{ {
/* someone gave us the wrong nb_flags as a reply. oops. */ /* someone gave us the wrong nb_flags as a reply. oops. */
/* XXXX should say to them 'oi! release that name!' */ /* XXXX should say to them 'oi! release that name!' */
DEBUG(4,("expected nb_flags: %d\n", n->reply.nb_flags)); DEBUG(4,("expected nb_flags: %d\n", n->nb_flags));
DEBUG(4,("unexpected nb_flags: %d\n", data->nb_flags)); DEBUG(4,("unexpected nb_flags: %d\n", nb_flags));
return; return;
} }
if (!ip_equal(n->send_ip, data->ip)) if (!ip_equal(n->send_ip, found_ip))
{ {
/* someone gave us the wrong ip as a reply. oops. */ /* someone gave us the wrong ip as a reply. oops. */
/* XXXX should say to them 'oi! release that name!' */ /* XXXX should say to them 'oi! release that name!' */
DEBUG(4,("expected ip: %s\n", inet_ntoa(n->send_ip))); DEBUG(4,("expected ip: %s\n", inet_ntoa(n->send_ip)));
DEBUG(4,("unexpected ip: %s\n", inet_ntoa(data->ip))); DEBUG(4,("unexpected ip: %s\n", inet_ntoa(found_ip)));
return; return;
} }
DEBUG(4, (" OK: %s\n", inet_ntoa(data->ip))); DEBUG(4, (" OK: %s\n", inet_ntoa(found_ip)));
/* fine: now tell the other host they can't have the name */ /* fine: now tell the other host they can't have the name */
register_ip = n->send_ip; register_ip = n->send_ip;
@ -366,14 +393,14 @@ static void response_name_query_register(struct nmb_ip *data,
DEBUG(4, (" NEGATIVE RESPONSE!\n")); DEBUG(4, (" NEGATIVE RESPONSE!\n"));
/* the owner didn't want the name: the other host can have it */ /* the owner didn't want the name: the other host can have it */
register_ip = n->reply.ip; register_ip = n->reply_to_ip;
new_owner = True; new_owner = True;
} }
/* register the old or the new owners' ip */ /* register the old or the new owners' ip */
add_name_respond(d, n->fd, d->myip, n->response_id,&n->name, add_name_respond(d, n->fd, d->myip, n->response_id,&n->name,n->nb_flags,
n->reply.nb_flags, GET_TTL(0), register_ip, GET_TTL(0), register_ip,
new_owner, n->reply.ip); new_owner, n->reply_to_ip);
} }
@ -381,7 +408,7 @@ static void response_name_query_register(struct nmb_ip *data,
response from a name query to sync browse lists or to update our netbios response from a name query to sync browse lists or to update our netbios
entry. states of type NAME_QUERY_SYNC and NAME_QUERY_CONFIRM entry. states of type NAME_QUERY_SYNC and NAME_QUERY_CONFIRM
****************************************************************************/ ****************************************************************************/
static void response_name_query_sync(struct nmb_ip *data, static void response_name_query_sync(struct nmb_packet *nmb,
struct nmb_name *ans_name, BOOL bcast, struct nmb_name *ans_name, BOOL bcast,
struct response_record *n, struct subnet_record *d) struct response_record *n, struct subnet_record *d)
{ {
@ -395,17 +422,22 @@ static void response_name_query_sync(struct nmb_ip *data,
return; return;
} }
if (data) if (nmb->header.rcode == 0 && nmb->answers->rdata)
{ {
if (!ip_equal(n->send_ip, data->ip)) int nb_flags = nmb->answers->rdata[0];
struct in_addr found_ip;
putip((char*)&found_ip,&nmb->answers->rdata[2]);
if (!ip_equal(n->send_ip, found_ip))
{ {
/* someone gave us the wrong ip as a reply. oops. */ /* someone gave us the wrong ip as a reply. oops. */
DEBUG(4,("expected ip: %s\n", inet_ntoa(n->send_ip))); DEBUG(4,("expected ip: %s\n", inet_ntoa(n->send_ip)));
DEBUG(4,("unexpected ip: %s\n", inet_ntoa(data->ip))); DEBUG(4,("unexpected ip: %s\n", inet_ntoa(found_ip)));
return; return;
} }
DEBUG(4, (" OK: %s\n", inet_ntoa(data->ip))); DEBUG(4, (" OK: %s\n", inet_ntoa(found_ip)));
if (n->state == NAME_QUERY_SYNC_LOCAL || if (n->state == NAME_QUERY_SYNC_LOCAL ||
n->state == NAME_QUERY_SYNC_REMOTE) n->state == NAME_QUERY_SYNC_REMOTE)
@ -417,15 +449,15 @@ static void response_name_query_sync(struct nmb_ip *data,
/* the server is there: sync quick before it (possibly) dies! */ /* the server is there: sync quick before it (possibly) dies! */
sync_browse_lists(d, work, ans_name->name, ans_name->name_type, sync_browse_lists(d, work, ans_name->name, ans_name->name_type,
data->ip, local_list_only); found_ip, local_list_only);
} }
} }
else else
{ {
/* update our netbios name list (re-register it if necessary) */ /* update our netbios name list (re-register it if necessary) */
add_netbios_entry(d, ans_name->name, ans_name->name_type, add_netbios_entry(d, ans_name->name, ans_name->name_type,
data->nb_flags,GET_TTL(0),REGISTER, nb_flags,GET_TTL(0),REGISTER,
data->ip,False,!bcast); found_ip,False,!bcast);
} }
} }
else else
@ -603,14 +635,11 @@ static BOOL response_compatible(struct response_record *n,
case NAME_REGISTER: case NAME_REGISTER:
{ {
/* rfc1002.txt states that nmb->answers->rr_type must equal 0x20 */
#if 0
if (nmb->answers->rr_type != NMB_REG) if (nmb->answers->rr_type != NMB_REG)
{ {
DEBUG(1,("Name register reply has wrong answer rr_type\n")); DEBUG(1,("Name register reply has wrong answer rr_type\n"));
return False; return False;
} }
#endif
break; break;
} }
@ -656,62 +685,27 @@ static BOOL response_compatible(struct response_record *n,
/**************************************************************************** /****************************************************************************
process the response packet received process the response packet received
****************************************************************************/ ****************************************************************************/
void response_process(struct in_addr ip, struct subnet_record *d, static void response_process(struct subnet_record *d, struct packet_struct *p,
struct response_record *n, struct response_record *n, struct nmb_packet *nmb,
int rcode, char *nmb_data, struct nmb_name *q_name, BOOL bcast, struct nmb_name *ans_name)
time_t ttl, BOOL bcast, struct nmb_name *ans_name)
{ {
switch (n->state) switch (n->state)
{ {
case NAME_RELEASE: case NAME_RELEASE:
{ {
struct nmb_ip found; response_name_release(d, p);
struct nmb_ip *data = NULL;
if (rcode == 0 && nmb_data)
{
/* copy the netbios flags and the ip address out of the reply data */
found.nb_flags = nmb_data[0];
putip((char*)&found.ip,&nmb_data[2]);
data = &found;
}
response_name_release(data, q_name, d);
break; break;
} }
case NAME_REGISTER: case NAME_REGISTER:
{ {
struct nmb_ip found; response_name_reg(d, p);
struct nmb_ip *data = NULL;
if (rcode == 0 && nmb_data)
{
/* copy the netbios flags and the ip address out of the reply data */
found.nb_flags = nmb_data[0];
putip((char*)&found.ip,&nmb_data[2]);
data = &found;
}
response_name_reg(data,ans_name,ttl,bcast,ip,d,n->source,n->token);
break; break;
} }
case NAME_REGISTER_CHALLENGE: case NAME_REGISTER_CHALLENGE:
{ {
struct nmb_ip found; response_name_query_register(nmb, ans_name, n, d);
struct nmb_ip *data = NULL;
if (rcode == 0 && nmb_data)
{
/* copy the netbios flags and the ip address out of the reply data */
found.nb_flags = nmb_data[0];
putip((char*)&found.ip,&nmb_data[2]);
data = &found;
}
response_name_query_register(data, ans_name, n, d);
break; break;
} }
@ -726,24 +720,13 @@ void response_process(struct in_addr ip, struct subnet_record *d,
case NAME_STATUS_DOM_SRV_CHK: case NAME_STATUS_DOM_SRV_CHK:
case NAME_STATUS_SRV_CHK: case NAME_STATUS_SRV_CHK:
{ {
response_name_status_check(ip,nmb_data,bcast,n,d); response_name_status_check(p->ip, nmb, bcast, n, d);
break; break;
} }
case NAME_QUERY_ANNOUNCE_HOST: case NAME_QUERY_ANNOUNCE_HOST:
{ {
struct nmb_ip found; response_announce_host(ans_name, nmb, n, d);
struct nmb_ip *data = NULL;
if (rcode == 0 && nmb_data)
{
/* copy the netbios flags and the ip address out of the reply data */
found.nb_flags = nmb_data[0];
putip((char*)&found.ip,&nmb_data[2]);
data = &found;
}
response_announce_host(data, ans_name, n, d);
break; break;
} }
@ -751,18 +734,7 @@ void response_process(struct in_addr ip, struct subnet_record *d,
case NAME_QUERY_SYNC_LOCAL: case NAME_QUERY_SYNC_LOCAL:
case NAME_QUERY_SYNC_REMOTE: case NAME_QUERY_SYNC_REMOTE:
{ {
struct nmb_ip found; response_name_query_sync(nmb, ans_name, bcast, n, d);
struct nmb_ip *data = NULL;
if (rcode == 0 && nmb_data)
{
/* copy the netbios flags and the ip address out of the reply data */
found.nb_flags = nmb_data[0];
putip((char*)&found.ip,&nmb_data[2]);
data = &found;
}
response_name_query_sync(data,ans_name,bcast,n,d);
break; break;
} }
case NAME_QUERY_MST_CHK: case NAME_QUERY_MST_CHK:
@ -808,9 +780,7 @@ void response_netbios_packet(struct packet_struct *p)
return; return;
} }
DEBUG(4,("response packet received: %s %d\n", /* args wrong way round: spotted by ccm@shentel.net */
inet_ntoa(p->ip),n->response_id));
if (!same_net(d->bcast_ip, p->ip, d->mask_ip)) /* copes with WINS 'subnet' */ if (!same_net(d->bcast_ip, p->ip, d->mask_ip)) /* copes with WINS 'subnet' */
{ {
DEBUG(2,("response from %s. ", inet_ntoa(p->ip))); DEBUG(2,("response from %s. ", inet_ntoa(p->ip)));
@ -846,13 +816,7 @@ void response_netbios_packet(struct packet_struct *p)
return; return;
/* now deal with the current state */ /* now deal with the current state */
response_process(p->ip, d, n, response_process(d, p, n, nmb, bcast, ans_name);
nmb->header.rcode,
nmb->answers->rdata,
question,
nmb->answers->ttl, bcast, ans_name);
remove_response_record(d, n);
} }

View File

@ -23,9 +23,6 @@
14 jan 96: lkcl@pires.co.uk 14 jan 96: lkcl@pires.co.uk
added multiple workgroup domain master support added multiple workgroup domain master support
30 July 96: David.Chappell@mail.trincoll.edu
Expanded multiple workgroup domain master browser support.
*/ */
#include "includes.h" #include "includes.h"
@ -33,34 +30,41 @@
extern int ClientNMB; extern int ClientNMB;
extern int ClientDGRAM; extern int ClientDGRAM;
#define TEST_CODE /* want to debug unknown browse packets */
extern int DEBUGLEVEL; extern int DEBUGLEVEL;
extern pstring scope; extern pstring scope;
extern BOOL CanRecurse; extern BOOL CanRecurse;
extern pstring myname;
extern int ClientNMB; extern int ClientNMB;
extern int ClientDGRAM; extern int ClientDGRAM;
extern struct in_addr ipzero; extern struct in_addr ipzero;
extern int workgroup_count; /* total number of workgroups we know about */
/* this is our domain/workgroup/server database */ /* this is our domain/workgroup/server database */
extern struct subnet_record *subnetlist; extern struct subnet_record *subnetlist;
extern int updatecount; extern int updatecount;
/* backup request types: which servers are to be included */
#define MASTER_TYPE (SV_TYPE_MASTER_BROWSER)
#define DOMCTL_TYPE (SV_TYPE_DOMAIN_CTRL )
extern time_t StartupTime; extern time_t StartupTime;
extern BOOL updatedlists; extern BOOL updatedlists;
extern pstring myname;
/**************************************************************************** /****************************************************************************
tell a server to become a backup browser tell a server to become a backup browser
state - 0x01 become backup instead of master state - 0x01 become backup instead of master
- 0x02 remove all entries in browse list and become non-master - 0x02 remove all entries in browse list and become non-master
- 0x04 stop master browser service altogether. NT ignores this - 0x04 stop master browser service altogether. NT ignores this
**************************************************************************/ **************************************************************************/
void reset_server(struct work_record *work, char *name, int state, struct in_addr ip) void reset_server(char *name, int state, struct in_addr ip)
{ {
char outbuf[20]; char outbuf[20];
char *p; char *p;
@ -76,7 +80,7 @@ void reset_server(struct work_record *work, char *name, int state, struct in_add
name,inet_ntoa(ip),state)); name,inet_ntoa(ip),state));
send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,PTR_DIFF(p,outbuf), send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,PTR_DIFF(p,outbuf),
conf_browsing_alias(work->token),name,0x20,0x1d,ip,*iface_ip(ip)); myname,name,0x20,0x1d,ip,*iface_ip(ip));
} }
@ -106,7 +110,7 @@ void tell_become_backup(void)
num_servers++; num_servers++;
if (strequal(conf_browsing_alias(work->token), s->serv.name)) continue; if (strequal(myname, s->serv.name)) continue;
if (s->serv.type & SV_TYPE_BACKUP_BROWSER) { if (s->serv.type & SV_TYPE_BACKUP_BROWSER) {
num_backups++; num_backups++;
@ -131,8 +135,8 @@ void tell_become_backup(void)
s->serv.name, inet_ntoa(d->bcast_ip), s->serv.name, inet_ntoa(d->bcast_ip),
work->work_group)); work->work_group));
/* type 11 request from conf_browsing_alias(work->token)(20) to WG(1e) for SERVER */ /* type 11 request from MYNAME(20) to WG(1e) for SERVER */
do_announce_request(s->serv.name, s->serv.name, work->work_group, do_announce_request(s->serv.name, work->work_group,
ANN_BecomeBackup, 0x20, 0x1e, d->bcast_ip); ANN_BecomeBackup, 0x20, 0x1e, d->bcast_ip);
} }
} }
@ -146,23 +150,8 @@ void tell_become_backup(void)
******************************************************************/ ******************************************************************/
BOOL same_context(struct dgram_packet *dgram) BOOL same_context(struct dgram_packet *dgram)
{ {
if (!strequal(dgram->dest_name .scope,scope )) return True; if (!strequal(dgram->dest_name .scope,scope )) return(True);
if ( strequal(dgram->source_name.name ,myname)) return(True);
return False;
}
/*******************************************************************
am I listening on a name. XXXX check the type of name as well.
******************************************************************/
BOOL listening_name(struct work_record *work, struct nmb_name *n)
{
if (strequal(n->name,conf_browsing_alias(work->token)) ||
strequal(n->name,work->work_group) ||
strequal(n->name,MSBROWSE))
{
return(True);
}
return(False); return(False);
} }
@ -289,40 +278,26 @@ static void process_master_announce(struct packet_struct *p,char *buf)
struct in_addr ip = dgram->header.source_ip; struct in_addr ip = dgram->header.source_ip;
struct subnet_record *d = find_subnet(ip); struct subnet_record *d = find_subnet(ip);
struct subnet_record *mydomain = find_subnet(*iface_bcast(ip)); struct subnet_record *mydomain = find_subnet(*iface_bcast(ip));
char *to_name = dgram->dest_name.name; /* our primary name or an alias */
char *name = buf; char *name = buf;
char *work_name; struct work_record *work;
int token;
name[15] = 0; name[15] = 0;
DEBUG(3,("Master Announce from %s (%s)\n", name, inet_ntoa(ip))); DEBUG(3,("Master Announce from %s (%s)\n",name,inet_ntoa(ip)));
if (same_context(dgram)) return; if (same_context(dgram)) return;
if (!d || !mydomain) return; if (!d || !mydomain) return;
token = conf_alias_to_token(to_name); if (!lp_domain_master()) return;
if (token == -1) for (work = mydomain->workgrouplist; work; work = work->next)
{ {
DEBUG(4, ("alias %s not known\n", to_name)); if (AM_MASTER(work))
return;
}
/* carry on only if we are a domain master under the server alias */
if (!conf_should_domain_master(token)) return;
/* Convert the server name by which the master browser
called this server to the workgroup name. */
if ((work_name = conf_workgroup_name(token)) == (char*)NULL)
{ {
DEBUG(4, ("process_master_announce(): no alias for \"%s\"\n", to_name));
return;
}
/* merge browse lists with them */ /* merge browse lists with them */
add_browser_entry(name, 0x1b, work_name,30,ip,True); add_browser_entry(name,0x1b, work->work_group,30,ip,True);
}
}
} }
/******************************************************************* /*******************************************************************
@ -343,7 +318,6 @@ static void process_rcv_backup_list(struct packet_struct *p,char *buf)
struct dgram_packet *dgram = &p->packet.dgram; struct dgram_packet *dgram = &p->packet.dgram;
struct in_addr ip = dgram->header.source_ip; struct in_addr ip = dgram->header.source_ip;
int count = CVAL(buf,0); int count = CVAL(buf,0);
unsigned int pick;
uint32 info = IVAL(buf,1); /* XXXX caller's incremental info */ uint32 info = IVAL(buf,1); /* XXXX caller's incremental info */
char *buf1; char *buf1;
@ -355,40 +329,59 @@ static void process_rcv_backup_list(struct packet_struct *p,char *buf)
if (count <= 0) return; if (count <= 0) return;
pick = sys_random(count);
/* go through the list of servers attempting to sync browse lists */ /* go through the list of servers attempting to sync browse lists */
for (buf1 = buf+5; *buf1 && count; buf1 = skip_string(buf1, 1), --count) for (buf1 = buf+5; *buf1 && count; buf1 = skip_string(buf1, 1), --count)
{ {
struct in_addr back_ip;
struct subnet_record *d; struct subnet_record *d;
if (count != pick) continue; DEBUG(4,("Searching for backup browser %s at %s...\n",
buf1, inet_ntoa(ip)));
DEBUG(4,("Searching for backup browser %s...\n", buf1)); /* XXXX assume name is a DNS name NOT a netbios name. a more complete
approach is to use reply_name_query functionality to find the name */
if ((d = find_subnet(ip)) != NULL) back_ip = *interpret_addr2(buf1);
if (zero_ip(back_ip))
{
DEBUG(4,("Failed to find backup browser server using DNS\n"));
continue;
}
DEBUG(4,("Found browser server at %s\n", inet_ntoa(back_ip)));
DEBUG(4,("END THIS LOOP: CODE NEEDS UPDATING\n"));
/* XXXX function needs work */
continue;
if ((d = find_subnet(back_ip)))
{
struct subnet_record *d1;
for (d1 = subnetlist; d1; d1 = d1->next)
{ {
struct work_record *work; struct work_record *work;
for (work = d->workgrouplist; work; work = work->next) for (work = d1->workgrouplist; work; work = work->next)
{ {
if (work->token == 0 /* token */) if (work->token == 0 /* token */)
{ {
queue_netbios_packet(d,ClientNMB,NMB_QUERY,NAME_QUERY_SRV_CHK, queue_netbios_packet(d1,ClientNMB,NMB_QUERY,NAME_QUERY_SRV_CHK,
work->token,work->work_group,0x1d, work->work_group,0x1d,
0,0,0,0,NULL,NULL, 0,0,0,NULL,NULL,
False,False,ipzero,ipzero); False,False,back_ip,back_ip);
return; return;
} }
} }
} }
} }
}
} }
/**************************************************************************** /****************************************************************************
send a backup list response. send a backup list response.
**************************************************************************/ **************************************************************************/
static void send_backup_list(struct work_record *work, struct nmb_name *src_name, static void send_backup_list(char *work_name, struct nmb_name *src_name,
int token, uint32 info, int token, uint32 info,
int name_type, struct in_addr ip) int name_type, struct in_addr ip)
{ {
@ -398,8 +391,8 @@ static void send_backup_list(struct work_record *work, struct nmb_name *src_name
char *theirname = src_name->name; char *theirname = src_name->name;
DEBUG(3,("sending backup list of %s to %s: %s(%x) %s(%x)\n", DEBUG(3,("sending backup list of %s to %s: %s(%x) %s(%x)\n",
work->work_group, inet_ntoa(ip), work_name, inet_ntoa(ip),
conf_browsing_alias(work->token),0x0,theirname,0x0)); myname,0x0,theirname,0x0));
if (name_type == 0x1d) if (name_type == 0x1d)
{ {
@ -431,8 +424,16 @@ static void send_backup_list(struct work_record *work, struct nmb_name *src_name
#if 0 #if 0
for (d = subnetlist; d; d = d->next)
{
struct work_record *work;
for (work = d->workgrouplist; work; work = work->next)
{
struct server_record *s; struct server_record *s;
if (!strequal(work->work_group, work_name)) continue;
for (s = work->serverlist; s; s = s->next) for (s = work->serverlist; s; s = s->next)
{ {
BOOL found = False; BOOL found = False;
@ -450,8 +451,8 @@ static void send_backup_list(struct work_record *work, struct nmb_name *src_name
/* workgroup request: include all backup browsers in the list */ /* workgroup request: include all backup browsers in the list */
/* domain request: include all domain members in the list */ /* domain request: include all domain members in the list */
if ((name_type == 0x1d && (s->serv.type & SV_TYPE_MASTER_BROWSER)) || if ((name_type == 0x1d && (s->serv.type & MASTER_TYPE)) ||
(name_type == 0x1b && (s->serv.type & SV_TYPE_DOMAIN_BROWSER))) (name_type == 0x1b && (s->serv.type & DOMCTL_TYPE)))
{ {
DEBUG(4, ("%s ", s->serv.name)); DEBUG(4, ("%s ", s->serv.name));
@ -461,10 +462,13 @@ static void send_backup_list(struct work_record *work, struct nmb_name *src_name
p = skip_string(p,1); p = skip_string(p,1);
} }
} }
}
}
#endif #endif
count++; count++;
strcpy(p,conf_browsing_alias(work->token)); strcpy(p,myname);
strupper(p); strupper(p);
p = skip_string(p,1); p = skip_string(p,1);
@ -484,7 +488,7 @@ static void send_backup_list(struct work_record *work, struct nmb_name *src_name
debug_browse_data(outbuf, len); debug_browse_data(outbuf, len);
} }
send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,PTR_DIFF(p,outbuf), send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,PTR_DIFF(p,outbuf),
conf_browsing_alias(work->token),theirname,0x0,0x0,ip,*iface_ip(ip)); myname,theirname,0x0,0x0,ip,*iface_ip(ip));
} }
@ -528,7 +532,7 @@ static void process_send_backup_list(struct packet_struct *p,char *buf)
DEBUG(2,("sending backup list to %s %s id=%x\n", DEBUG(2,("sending backup list to %s %s id=%x\n",
namestr(&dgram->dest_name),inet_ntoa(ip),info)); namestr(&dgram->dest_name),inet_ntoa(ip),info));
send_backup_list(work,&dgram->source_name, send_backup_list(work->work_group,&dgram->source_name,
token,info,name_type,ip); token,info,name_type,ip);
return; return;
} }
@ -578,16 +582,13 @@ static void process_reset_browser(struct packet_struct *p,char *buf)
/* totally delete all servers and start afresh */ /* totally delete all servers and start afresh */
if (state & 0x2) if (state & 0x2)
{ {
/* remove all workgroups (and their servers) from database */
struct subnet_record *d; struct subnet_record *d;
for (d = subnetlist; d; d = d->next) for (d = subnetlist; d; d = d->next)
{ {
struct work_record *work; struct work_record *work;
for (work=d->workgrouplist;work;work=remove_workgroup(d,work,True)); for (work=d->workgrouplist;work;work=remove_workgroup(d,work,True));
} }
add_my_subnets(lp_workgroup());
/* add all known workgroups back into database */
add_workgroups_to_subnets();
} }
/* stop browsing altogether. i don't think this is a good idea! */ /* stop browsing altogether. i don't think this is a good idea! */
@ -610,43 +611,39 @@ static void process_announce_request(struct packet_struct *p,char *buf)
struct in_addr ip = dgram->header.source_ip; struct in_addr ip = dgram->header.source_ip;
struct subnet_record *d = find_subnet(ip); struct subnet_record *d = find_subnet(ip);
int token = CVAL(buf,0); int token = CVAL(buf,0);
int wg_token = 0;
char *name = buf+1; char *name = buf+1;
char *samba_alias;
name[15] = 0; name[15] = 0;
DEBUG(3,("Announce request from %s to %s token=0x%X\n", DEBUG(3,("Announce request from %s to %s token=0x%X\n",
name,namestr(&dgram->dest_name), token)); name,namestr(&dgram->dest_name), token));
/* look up the index for this workgroup */ if (strequal(dgram->source_name.name,myname)) return;
wg_token = conf_workgroup_name_to_token(dgram->dest_name.name,myname);
if (wg_token == -1) return;
/* check that samba is participating in this workgroup */ /* XXXX BUG or FEATURE?: need to ensure that we are a member of
if (!conf_should_workgroup_member(wg_token)) return; this workgroup before announcing, particularly as we only
respond on local interfaces anyway.
/* find samba's NetBIOS alias it operates under in this workgroup */ if (strequal(dgram->dest_name, lp_workgroup()) return; ???
if ((samba_alias = conf_browsing_alias(wg_token)) == (char*)NULL) return; */
/* ignore announce requests from samba under its own alias.
this should no longer happen because code has been added to
discard packets from ourself. */
if (strequal(dgram->source_name.name,samba_alias)) return;
if (!d) return; if (!d) return;
for (work = d->workgrouplist; work; work = work->next)
{
/* XXXX BUG: the destination name type should also be checked, /* XXXX BUG: the destination name type should also be checked,
not just the name. e.g if the name is WORKGROUP(0x1d) then not just the name. e.g if the name is WORKGROUP(0x1d) then
we should only respond if we own that name */ we should only respond if we own that name */
for (work = d->workgrouplist; work; work = work->next) if (strequal(dgram->dest_name.name,work->work_group))
{ {
if (wg_token == work->token) work->needannounce = True; work->needannounce = True;
}
} }
} }
/**************************************************************************** /****************************************************************************
process a browse frame process a browse frame
****************************************************************************/ ****************************************************************************/

View File

@ -23,10 +23,6 @@
14 jan 96: lkcl@pires.co.uk 14 jan 96: lkcl@pires.co.uk
added multiple workgroup domain master support added multiple workgroup domain master support
30 July 96: David.Chappell@mail.trincoll.edu
Expanded multiple workgroup domain master browser support.
*/ */
#include "includes.h" #include "includes.h"
@ -169,10 +165,10 @@ static void expire_names_and_servers(void)
time_t t = time(NULL); time_t t = time(NULL);
if (!lastrun) lastrun = t; if (!lastrun) lastrun = t;
if (t < lastrun + 15) return; /* give samba time to check its names */ if (t < lastrun + 5) return;
lastrun = t; lastrun = t;
check_expire_names(t); /* this checks samba's NetBIOS names */ expire_names(t);
expire_servers(t); expire_servers(t);
} }
@ -297,6 +293,7 @@ static void process(void)
while (True) while (True)
{ {
time_t t = time(NULL);
run_election = check_elections(); run_election = check_elections();
listen_for_packets(run_election); listen_for_packets(run_election);
@ -313,6 +310,7 @@ static void process(void)
expire_names_and_servers(); expire_names_and_servers();
expire_netbios_response_entries(); expire_netbios_response_entries();
refresh_my_names(t);
write_browse_list(); write_browse_list();
do_browser_lists(); do_browser_lists();
@ -493,14 +491,6 @@ static void usage(char *pname)
init_structs(); init_structs();
/* reads the smbbrowse.conf file. this is an alias mapping between
workgroups and samba NetBIOS aliases. samba can therefore be
a member of multiple workgroups, a local master browser of
multiple workgroups, or a domain master browser of multiple
workgroups, via each NetBIOS name alias. the aliases MUST
be unique for this to work. */
read_smbbrowse_conf(myname);
reload_services(True); reload_services(True);
set_samba_nb_type(); set_samba_nb_type();
@ -530,7 +520,7 @@ static void usage(char *pname)
DEBUG(0,("ERROR: a workgroup name of * is no longer supported\n")); DEBUG(0,("ERROR: a workgroup name of * is no longer supported\n"));
} }
add_workgroups_to_subnets(); add_my_subnets(lp_workgroup());
DEBUG(3,("Checked names\n")); DEBUG(3,("Checked names\n"));

View File

@ -117,10 +117,7 @@ static BOOL add_info(struct subnet_record *d, struct work_record *work, int serv
} }
if (w) if (w)
{ add_server_entry(d,w,sname,stype,lp_max_ttl(),cmnt,False);
add_server_entry(d,w,sname,stype & ~SV_TYPE_LOCAL_LIST_ONLY,
lp_max_ttl(),cmnt,False);
}
} }
} }
} }

View File

@ -106,34 +106,33 @@ extern int coding_system;
*/ */
typedef struct typedef struct
{ {
char *szAutoServices; char *szPrintcapname;
char *szCharacterSet; char *szLockDir;
char *szConfigFile; char *szRootdir;
char *szDefaultService; char *szDefaultService;
char *szDfree; char *szDfree;
char *szDomainController;
char *szHostsEquiv;
char *szInterfaces;
char *szLockDir;
char *szLogFile;
char *szLogonScript;
char *szMsgCommand; char *szMsgCommand;
char *szPasswdChat; char *szHostsEquiv;
char *szPasswdProgram;
char *szPasswordServer;
char *szPrintcapname;
char *szRemoteAnnounce;
char *szRootdir;
char *szServerComment;
char *szServerString; char *szServerString;
char *szSmbrun; char *szAutoServices;
char *szPasswdProgram;
char *szPasswdChat;
char *szLogFile;
char *szConfigFile;
char *szSMBPasswdFile; char *szSMBPasswdFile;
char *szSocketAddress; char *szPasswordServer;
char *szSocketOptions; char *szSocketOptions;
char *szUsernameMap;
char *szValidChars; char *szValidChars;
char *szWINSserver;
char *szWorkGroup; char *szWorkGroup;
char *szDomainController;
char *szUsernameMap;
char *szCharacterSet;
char *szLogonScript;
char *szSmbrun;
char *szWINSserver;
char *szInterfaces;
char *szRemoteAnnounce;
char *szSocketAddress;
int max_log_size; int max_log_size;
int mangled_stack; int mangled_stack;
int max_xmit; int max_xmit;
@ -153,7 +152,6 @@ typedef struct
BOOL bWINSsupport; BOOL bWINSsupport;
BOOL bWINSproxy; BOOL bWINSproxy;
BOOL bPreferredMaster; BOOL bPreferredMaster;
BOOL bLocalMaster;
BOOL bDomainMaster; BOOL bDomainMaster;
BOOL bDomainLogons; BOOL bDomainLogons;
BOOL bEncryptPasswords; BOOL bEncryptPasswords;
@ -384,7 +382,6 @@ struct parm_struct
{"hosts equiv", P_STRING, P_GLOBAL, &Globals.szHostsEquiv, NULL}, {"hosts equiv", P_STRING, P_GLOBAL, &Globals.szHostsEquiv, NULL},
{"preload", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL}, {"preload", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL},
{"auto services", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL}, {"auto services", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL},
{"server comment", P_STRING, P_GLOBAL, &Globals.szServerComment, NULL},
{"server string", P_STRING, P_GLOBAL, &Globals.szServerString, NULL}, {"server string", P_STRING, P_GLOBAL, &Globals.szServerString, NULL},
{"printcap name", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL}, {"printcap name", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL},
{"printcap", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL}, {"printcap", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL},
@ -428,7 +425,6 @@ struct parm_struct
{"wins server", P_STRING, P_GLOBAL, &Globals.szWINSserver, NULL}, {"wins server", P_STRING, P_GLOBAL, &Globals.szWINSserver, NULL},
{"preferred master", P_BOOL, P_GLOBAL, &Globals.bPreferredMaster, NULL}, {"preferred master", P_BOOL, P_GLOBAL, &Globals.bPreferredMaster, NULL},
{"prefered master", P_BOOL, P_GLOBAL, &Globals.bPreferredMaster, NULL}, {"prefered master", P_BOOL, P_GLOBAL, &Globals.bPreferredMaster, NULL},
{"local master", P_BOOL, P_GLOBAL, &Globals.bLocalMaster, NULL},
{"domain master", P_BOOL, P_GLOBAL, &Globals.bDomainMaster, NULL}, {"domain master", P_BOOL, P_GLOBAL, &Globals.bDomainMaster, NULL},
{"domain logons", P_BOOL, P_GLOBAL, &Globals.bDomainLogons, NULL}, {"domain logons", P_BOOL, P_GLOBAL, &Globals.bDomainLogons, NULL},
{"browse list", P_BOOL, P_GLOBAL, &Globals.bBrowseList, NULL}, {"browse list", P_BOOL, P_GLOBAL, &Globals.bBrowseList, NULL},
@ -564,9 +560,6 @@ static void init_globals(void)
string_set(&Globals.szSocketAddress, "0.0.0.0"); string_set(&Globals.szSocketAddress, "0.0.0.0");
sprintf(s,"Samba %s",VERSION); sprintf(s,"Samba %s",VERSION);
string_set(&Globals.szServerString,s); string_set(&Globals.szServerString,s);
strcpy(s,"Samba %v"); /* samba comment */
string_sub(s,"%v",VERSION);
string_set(&Globals.szServerComment,s);
Globals.bLoadPrinters = True; Globals.bLoadPrinters = True;
Globals.bUseRhosts = False; Globals.bUseRhosts = False;
Globals.max_packet = 65535; Globals.max_packet = 65535;
@ -591,9 +584,8 @@ static void init_globals(void)
Globals.bSyslogOnly = False; Globals.bSyslogOnly = False;
Globals.os_level = 0; Globals.os_level = 0;
Globals.max_ttl = 60*60*4; /* 2 hours default */ Globals.max_ttl = 60*60*4; /* 2 hours default */
Globals.bPreferredMaster = True; /* force election on startup */ Globals.bPreferredMaster = True;
Globals.bLocalMaster = True; /* master browser on local subnet */ Globals.bDomainMaster = False;
Globals.bDomainMaster = False; /* maintain wide area network browse list */
Globals.bDomainLogons = False; Globals.bDomainLogons = False;
Globals.bBrowseList = True; Globals.bBrowseList = True;
Globals.bWINSsupport = True; Globals.bWINSsupport = True;
@ -732,7 +724,6 @@ FN_GLOBAL_STRING(lp_smbrun,&Globals.szSmbrun)
FN_GLOBAL_STRING(lp_configfile,&Globals.szConfigFile) FN_GLOBAL_STRING(lp_configfile,&Globals.szConfigFile)
FN_GLOBAL_STRING(lp_smb_passwd_file,&Globals.szSMBPasswdFile) FN_GLOBAL_STRING(lp_smb_passwd_file,&Globals.szSMBPasswdFile)
FN_GLOBAL_STRING(lp_serverstring,&Globals.szServerString) FN_GLOBAL_STRING(lp_serverstring,&Globals.szServerString)
FN_GLOBAL_STRING(lp_server_comment,&Globals.szServerComment)
FN_GLOBAL_STRING(lp_printcapname,&Globals.szPrintcapname) FN_GLOBAL_STRING(lp_printcapname,&Globals.szPrintcapname)
FN_GLOBAL_STRING(lp_lockdir,&Globals.szLockDir) FN_GLOBAL_STRING(lp_lockdir,&Globals.szLockDir)
FN_GLOBAL_STRING(lp_rootdir,&Globals.szRootdir) FN_GLOBAL_STRING(lp_rootdir,&Globals.szRootdir)
@ -756,7 +747,6 @@ FN_GLOBAL_STRING(lp_socket_address,&Globals.szSocketAddress)
FN_GLOBAL_BOOL(lp_wins_support,&Globals.bWINSsupport) FN_GLOBAL_BOOL(lp_wins_support,&Globals.bWINSsupport)
FN_GLOBAL_BOOL(lp_wins_proxy,&Globals.bWINSproxy) FN_GLOBAL_BOOL(lp_wins_proxy,&Globals.bWINSproxy)
FN_GLOBAL_BOOL(lp_local_master,&Globals.bLocalMaster)
FN_GLOBAL_BOOL(lp_domain_master,&Globals.bDomainMaster) FN_GLOBAL_BOOL(lp_domain_master,&Globals.bDomainMaster)
FN_GLOBAL_BOOL(lp_domain_logons,&Globals.bDomainLogons) FN_GLOBAL_BOOL(lp_domain_logons,&Globals.bDomainLogons)
FN_GLOBAL_BOOL(lp_preferred_master,&Globals.bPreferredMaster) FN_GLOBAL_BOOL(lp_preferred_master,&Globals.bPreferredMaster)

View File

@ -812,7 +812,10 @@ static int get_server_info(uint32 servertype,
if (!next_token(&ptr,s->name , NULL)) continue; if (!next_token(&ptr,s->name , NULL)) continue;
if (!next_token(&ptr,stype , NULL)) continue; if (!next_token(&ptr,stype , NULL)) continue;
if (!next_token(&ptr,s->comment, NULL)) continue; if (!next_token(&ptr,s->comment, NULL)) continue;
if (!next_token(&ptr,s->domain , NULL)) continue; if (!next_token(&ptr,s->domain , NULL)) {
/* this allows us to cope with an old nmbd */
strcpy(s->domain,lp_workgroup());
}
if (sscanf(stype,"%X",&s->type) != 1) { if (sscanf(stype,"%X",&s->type) != 1) {
DEBUG(4,("r:host file ")); DEBUG(4,("r:host file "));
@ -980,22 +983,8 @@ static BOOL api_RNetServerEnum(int cnum, int uid, char *param, char *data,
if (strcmp(str1, "WrLehDz") == 0) { if (strcmp(str1, "WrLehDz") == 0) {
StrnCpy(domain, p, sizeof(fstring)-1); StrnCpy(domain, p, sizeof(fstring)-1);
} } else {
else StrnCpy(domain, lp_workgroup(), sizeof(fstring)-1);
{
/* a server will connect to us under one of samba's NetBIOS
name aliases, and by not giving us a domain name it
assumes we know which domain it's talking about.
do a look-up for the workgroup name against the name
the host connected to us as.
*/
char *work_alias;
work_alias = conf_alias_to_workgroup(local_machine); /* look-up */
if (work_alias)
StrnCpy(domain, work_alias, sizeof(fstring)-1);
} }
if (lp_browse_list()) if (lp_browse_list())
@ -1679,19 +1668,9 @@ static BOOL api_RNetServerGetInfo(int cnum,int uid, char *param,char *data,
pstring comment; pstring comment;
uint32 servertype=DFLT_SERVER_TYPE; uint32 servertype=DFLT_SERVER_TYPE;
char *work_alias;
char domain[16];
work_alias = conf_alias_to_workgroup(local_machine); /* look-up */
if (work_alias)
StrnCpy(domain, work_alias, sizeof(fstring)-1);
else
*domain = 0;
strcpy(comment,lp_serverstring()); strcpy(comment,lp_serverstring());
if ((count=get_server_info(SV_TYPE_ALL,&servers,domain))>0) { if ((count=get_server_info(SV_TYPE_ALL,&servers,lp_workgroup()))>0) {
for (i=0;i<count;i++) for (i=0;i<count;i++)
if (strequal(servers[i].name,local_machine)) { if (strequal(servers[i].name,local_machine)) {
servertype = servers[i].type; servertype = servers[i].type;
@ -1744,14 +1723,6 @@ static BOOL api_NetWkstaGetInfo(int cnum,int uid, char *param,char *data,
char *p2; char *p2;
extern pstring sesssetup_user; extern pstring sesssetup_user;
int level = SVAL(p,0); int level = SVAL(p,0);
char domain[17];
char *work_alias = conf_alias_to_workgroup(local_machine); /* look-up */
if (work_alias)
StrnCpy(domain, work_alias, 16);
else
StrnCpy(domain, lp_workgroup(), 16);
DEBUG(4,("NetWkstaGetInfo level %d\n",level)); DEBUG(4,("NetWkstaGetInfo level %d\n",level));
@ -1782,7 +1753,7 @@ static BOOL api_NetWkstaGetInfo(int cnum,int uid, char *param,char *data,
p += 4; p += 4;
SIVAL(p,0,PTR_DIFF(p2,*rdata)); SIVAL(p,0,PTR_DIFF(p2,*rdata));
StrCpy(p2,domain); strcpy(p2,lp_workgroup());
p2 = skip_string(p2,1); p2 = skip_string(p2,1);
p += 4; p += 4;
@ -1791,7 +1762,7 @@ static BOOL api_NetWkstaGetInfo(int cnum,int uid, char *param,char *data,
p += 2; p += 2;
SIVAL(p,0,PTR_DIFF(p2,*rdata)); SIVAL(p,0,PTR_DIFF(p2,*rdata));
strcpy(p2,domain); /* login domain?? */ strcpy(p2,lp_workgroup()); /* login domain?? */
p2 = skip_string(p2,1); p2 = skip_string(p2,1);
p += 4; p += 4;
@ -2014,14 +1985,6 @@ static BOOL api_WWkstaUserLogon(int cnum,int uid, char *param,char *data,
int uLevel; int uLevel;
struct pack_desc desc; struct pack_desc desc;
char* name; char* name;
char domain[17];
char *work_alias = conf_alias_to_workgroup(local_machine); /* look-up */
if (work_alias)
StrnCpy(domain, work_alias, 16);
else
StrnCpy(domain, lp_workgroup(), 16);
uLevel = SVAL(p,0); uLevel = SVAL(p,0);
name = p + 2; name = p + 2;
@ -2064,7 +2027,7 @@ static BOOL api_WWkstaUserLogon(int cnum,int uid, char *param,char *data,
strupper(mypath); strupper(mypath);
PACKS(&desc,"z",mypath); /* computer */ PACKS(&desc,"z",mypath); /* computer */
} }
PACKS(&desc,"z",domain);/* domain */ PACKS(&desc,"z",lp_workgroup());/* domain */
PACKS(&desc,"z",lp_logon_script()); /* script path */ PACKS(&desc,"z",lp_logon_script()); /* script path */
PACKI(&desc,"D",0); /* reserved */ PACKI(&desc,"D",0); /* reserved */
} }

View File

@ -44,8 +44,6 @@ extern BOOL case_sensitive;
extern pstring sesssetup_user; extern pstring sesssetup_user;
extern int Client; extern int Client;
extern pstring local_machine;
/* this macro should always be used to extract an fnum (smb_fid) from /* this macro should always be used to extract an fnum (smb_fid) from
a packet to ensure chaining works correctly */ a packet to ensure chaining works correctly */
#define GETFNUM(buf,where) (chain_fnum!= -1?chain_fnum:SVAL(buf,where)) #define GETFNUM(buf,where) (chain_fnum!= -1?chain_fnum:SVAL(buf,where))
@ -253,18 +251,9 @@ static void LsarpcTNP3(char *data,char **rdata, int *rdata_len)
{ {
uint32 dword1; uint32 dword1;
uint16 word1; uint16 word1;
int wglen; char * workgroup = lp_workgroup();
int wglen = strlen(workgroup);
int i; int i;
char domain[17];
char *work_alias = conf_alias_to_workgroup(local_machine); /* look-up */
if (work_alias)
StrnCpy(domain, work_alias, 16);
else
StrnCpy(domain, lp_workgroup(), 16);
wglen = strlen(domain);
/* All kinds of mysterious numbers here */ /* All kinds of mysterious numbers here */
*rdata_len = 90 + 2 * wglen; *rdata_len = 90 + 2 * wglen;
@ -290,7 +279,7 @@ static void LsarpcTNP3(char *data,char **rdata, int *rdata_len)
SIVAL(*rdata,0x2C,4); SIVAL(*rdata,0x2C,4);
SIVAL(*rdata,0x34,wglen); SIVAL(*rdata,0x34,wglen);
for ( i = 0 ; i < wglen ; i++ ) for ( i = 0 ; i < wglen ; i++ )
(*rdata)[0x38 + i * 2] = domain[i]; (*rdata)[0x38 + i * 2] = workgroup[i];
/* Now fill in the rest */ /* Now fill in the rest */
i = 0x38 + wglen * 2; i = 0x38 + wglen * 2;

View File

@ -37,7 +37,6 @@ extern connection_struct Connections[];
extern files_struct Files[]; extern files_struct Files[];
extern BOOL case_sensitive; extern BOOL case_sensitive;
extern pstring sesssetup_user; extern pstring sesssetup_user;
extern fstring local_machine;
extern int Client; extern int Client;
/* this macro should always be used to extract an fnum (smb_fid) from /* this macro should always be used to extract an fnum (smb_fid) from
@ -55,6 +54,7 @@ int reply_special(char *inbuf,char *outbuf)
int msg_flags = CVAL(inbuf,1); int msg_flags = CVAL(inbuf,1);
pstring name1,name2; pstring name1,name2;
extern fstring remote_machine; extern fstring remote_machine;
extern fstring local_machine;
char *p; char *p;
*name1 = *name2 = 0; *name1 = *name2 = 0;
@ -319,14 +319,6 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
BOOL guest=False; BOOL guest=False;
BOOL computer_id=False; BOOL computer_id=False;
char domain[17];
char *work_alias = conf_alias_to_workgroup(local_machine); /* look-up */
if (work_alias)
StrnCpy(domain, work_alias, 16);
else
StrnCpy(domain, lp_workgroup(), 16);
*smb_apasswd = 0; *smb_apasswd = 0;
sess_uid = SVAL(inbuf,smb_uid); sess_uid = SVAL(inbuf,smb_uid);
@ -460,7 +452,7 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
p = smb_buf(outbuf); p = smb_buf(outbuf);
strcpy(p,"Unix"); p = skip_string(p,1); strcpy(p,"Unix"); p = skip_string(p,1);
strcpy(p,"Samba "); strcat(p,VERSION); p = skip_string(p,1); strcpy(p,"Samba "); strcat(p,VERSION); p = skip_string(p,1);
strcpy(p,domain); p = skip_string(p,1); strcpy(p,lp_workgroup()); p = skip_string(p,1);
set_message(outbuf,3,PTR_DIFF(p,smb_buf(outbuf)),False); set_message(outbuf,3,PTR_DIFF(p,smb_buf(outbuf)),False);
/* perhaps grab OS version here?? */ /* perhaps grab OS version here?? */
} }

View File

@ -3746,8 +3746,6 @@ static void usage(char *pname)
DEBUG(2,("%s changed root to %s\n",timestring(),lp_rootdir())); DEBUG(2,("%s changed root to %s\n",timestring(),lp_rootdir()));
} }
read_smbbrowse_conf(myhostname);
process(); process();
close_sockets(); close_sockets();