--- Makefile.orig Mon Apr 14 17:59:16 1997 +++ Makefile Wed Apr 16 08:45:38 1997 @@ -576,7 +576,7 @@ SMBDOBJ = predict.o $(SMBDOBJ1) $(SMBDOBJ2) $(VTP_OBJ) NMBDOBJ1 = nmblib.o namepacket.o nameresp.o nmbsync.o nameannounce.o nameelect.o NMBDOBJ2 = namedbresp.o namedbwork.o namedbserver.o namedbsubnet.o namedbname.o -NMBDOBJ3 = nameservresp.o nameservreply.o namelogon.o namebrowse.o namework.o nameserv.o clientutil.o +NMBDOBJ3 = nameservresp.o nameservreply.o namelogon.o namebrowse.o namework.o nameserv.o clientutil.o namelanman.o NMBDOBJ = $(UTILOBJ) $(NMBDOBJ1) $(NMBDOBJ2) $(NMBDOBJ3) .SUFFIXES: .SUFFIXES: .c .o .h --- nameserv.h.orig Mon Apr 14 17:31:01 1997 +++ nameserv.h Mon Apr 14 17:32:49 1997 @@ -81,6 +81,7 @@ /* mail slots */ #define BROWSE_MAILSLOT "\\MAILSLOT\\BROWSE" #define NET_LOGON_MAILSLOT "\\MAILSLOT\\NET\\NETLOGON" +#define LANMAN_MAILSLOT "\\MAILSLOT\\LANMAN" enum name_source {STATUS_QUERY, LMHOSTS, REGISTER, SELF, DNS, DNSFAIL}; enum node_type {B_NODE=0, P_NODE=1, M_NODE=2, NBDD_NODE=3}; --- proto.h.orig Mon Apr 14 23:54:26 1997 +++ proto.h Wed Apr 16 08:43:42 1997 @@ -180,6 +180,7 @@ int lp_maxdisksize(void); int lp_lpqcachetime(void); int lp_syslog(void); +int lp_lm_announce(void); char *lp_preexec(int ); char *lp_postexec(int ); char *lp_rootpreexec(int ); @@ -416,6 +417,16 @@ void run_elections(time_t t); void process_election(struct packet_struct *p,char *buf); BOOL check_elections(void); + +/*The following definitions come from namelanman.c */ + +void do_announce_lm_host(char *from_name, int from_type, + struct in_addr from_ip, char *to_name, + int to_type, struct in_addr to_ip, + time_t announce_interval, char *server_name, + int server_type, char *server_comment); +void announce_lm_server(time_t t); +void process_lanman_packet(struct packet_struct *p,char *buf,int len); /*The following definitions come from namelogon.c */ --- loadparm.c.orig Mon Apr 14 17:33:44 1997 +++ loadparm.c Mon Apr 14 17:38:11 1997 @@ -151,6 +151,7 @@ int os_level; int max_ttl; int ReadSize; + int lm_announce; BOOL bWINSsupport; BOOL bWINSproxy; BOOL bPreferredMaster; @@ -434,6 +435,7 @@ {"domain master", P_BOOL, P_GLOBAL, &Globals.bDomainMaster, NULL}, {"domain logons", P_BOOL, P_GLOBAL, &Globals.bDomainLogons, NULL}, {"browse list", P_BOOL, P_GLOBAL, &Globals.bBrowseList, NULL}, + {"lm announce", P_INTEGER, P_GLOBAL, &Globals.lm_announce, NULL}, {"-valid", P_BOOL, P_LOCAL, &sDefault.valid, NULL}, {"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL}, @@ -599,6 +601,7 @@ Globals.bWINSsupport = True; Globals.bWINSproxy = False; Globals.ReadSize = 16*1024; + Globals.lm_announce = 0; #ifdef KANJI coding_system = interpret_coding_system (KANJI, SJIS_CODE); @@ -790,6 +793,7 @@ FN_GLOBAL_INTEGER(lp_maxdisksize,&Globals.maxdisksize) FN_GLOBAL_INTEGER(lp_lpqcachetime,&Globals.lpqcachetime) FN_GLOBAL_INTEGER(lp_syslog,&Globals.syslog) +FN_GLOBAL_INTEGER(lp_lm_announce,&Globals.lm_announce) FN_LOCAL_STRING(lp_preexec,szPreExec) FN_LOCAL_STRING(lp_postexec,szPostExec) --- namelanman.c.orig Mon Apr 14 20:02:18 1997 +++ namelanman.c Mon Apr 14 23:08:58 1997 @@ -0,0 +1,252 @@ + +/* + Unix SMB/Netbios implementation. + Version 1.9. + NBT netbios routines and daemon - version 2 + Copyright (C) Andrew Tridgell 1994-1995 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + Revision History: + + 27 mar 1997: Andreas Degert (ad@papyrus.hamburg.com) + Implementation of LAN Manager announcements. OS/2 clients + should be able to see Samba servers now. + 14 apr 1997: Jacco de Leeuw (leeuw@wins.uva.nl) + Found OS/2 machines will be added to Samba's browse list. + Moved all LAN Manager routines to one file. + +*/ + +#include "includes.h" + +extern int ClientDGRAM; +extern pstring myname; +extern struct subnet_record *subnetlist; +extern struct in_addr ipgrp; +extern int DEBUGLEVEL; +extern pstring scope; +extern BOOL updatedlists; + +/**************************************************************************** + send a LAN Manager host announcement packet + **************************************************************************/ + +void do_announce_lm_host(char *from_name, int from_type, + struct in_addr from_ip, char *to_name, + int to_type, struct in_addr to_ip, + time_t announce_interval, char *server_name, + int server_type, char *server_comment) +{ + pstring outbuf; + char *p = outbuf; + + bzero(outbuf,sizeof(outbuf)); + + SSVAL(p,0,1); /* type: announcement */ + SIVAL(p,2,server_type); /* services offered by this server */ + CVAL(p,6) = 1; /* major version of node software */ + CVAL(p,7) = 9; /* minor version of node software */ + SSVAL(p,8,announce_interval); /* announcement cycle in seconds */ + p += 10; + strcpy(p,server_name); + strupper(p); + p = skip_string(p,1); + strcpy(p,server_comment); + p = skip_string(p,1); + + debug_browse_data(outbuf, PTR_DIFF(p,outbuf)); + + /* send the announcement */ + send_mailslot_reply(LANMAN_MAILSLOT,ClientDGRAM,outbuf, + PTR_DIFF(p,outbuf), + from_name, to_name, + from_type, to_type, + to_ip, from_ip); +} + + +/**************************************************************************** + announce a LAN Manager server entry on all subnets + **************************************************************************/ + +void announce_lm_server(time_t t) +{ + static time_t lastannounce_time = 0; + int announce_interval = lp_lm_announce(); + struct subnet_record *d; + int server_type; + pstring comment; + + if (announce_interval <=0) return; + + StrnCpy(comment, lp_serverstring(), 43); + + if (myname[0] == '\0') return; + + if (lastannounce_time && (t - lastannounce_time) < announce_interval) + return; + + lastannounce_time = t; + + server_type = SV_TYPE_WORKSTATION|SV_TYPE_SERVER|SV_TYPE_TIME_SOURCE; + /* JdL: if it's a domain controller for Windows clients, is it also one + for OS/2 clients??? */ + if (lp_domain_logons()) server_type |= SV_TYPE_DOMAIN_CTRL; + + for (d = subnetlist; d; d = d->next) + { + if (ip_equal(d->bcast_ip, ipgrp)) continue; + + do_announce_lm_host(myname,0x00,d->myip, + lp_workgroup(),0x00,d->bcast_ip, + announce_interval,myname,server_type, + comment); + } + } + + + /******************************************************************* + process a LAN Manager announcement frame + ******************************************************************/ +static void process_lm_announce(struct packet_struct *p,uint16 command,char *buf) +{ + struct dgram_packet *dgram = &p->packet.dgram; + struct in_addr ip = dgram->header.source_ip; + struct subnet_record *d = find_subnet(ip); + + int ttl = SVAL(buf,8); /* time-to-live for this announcement */ + char *name = buf+10; + int osmajor=CVAL(buf,6); /* major version of node software */ + int osminor=CVAL(buf,7); /* minor version of node software */ + uint32 server_type = IVAL(buf,2); /* services offered by this server */ + char *comment = buf+10; + + struct work_record *work; + char *work_name; + char *serv_name = dgram->source_name.name; + BOOL add = False; + + comment = skip_string(comment,1); + /* JdL: dunno is this is needed. I am leaning towards leaving it out because + it might just as well go out of bounds. + comment[43] = 0; + */ + + DEBUG(4,("LM Announcement(%d) from %s",command,name)); + DEBUG(4,(" on %s ttl=%d OS=(%d,%d) type=%08x comment=%s\n", + namestr(&dgram->dest_name),ttl,osmajor,osminor, + server_type,comment)); + if (((osmajor != 37) && (osmajor != 36)) || (osminor !=0)) + { + DEBUG(4,("LM Announcement frame discarded: didn't come from OS/2 machine\n")); + /* Could have been from a Windows machine (with LM Announce=Yes), + or a Samba server. Then don't disrupt the current browse list. */ + return; + } + + /* JdL: dunno is this is needed, I just left it in. */ + if (!strequal(dgram->dest_name.scope,scope )) return; + + /* we need some way of finding out about new workgroups + that appear to be sending packets to us. The name_type checks make + sure we don't add host names as workgroups */ + /* JdL: dunno is this is needed, I just left it in. */ + if (command == ANN_HostAnnouncement && + (dgram->dest_name.name_type == 0x1d || + dgram->dest_name.name_type == 0x1e)) + add = True; + + work_name = dgram->dest_name.name; + if (!(work = find_workgroupstruct(d, work_name,add))) + return; + + DEBUG(4, ("workgroup %s on %s\n", work->work_group, serv_name)); + + ttl = GET_TTL(ttl); /* the time-to-live of OS/2 LAN Manager packets + is according to the specs, so in seconds */ + + /* add them to our browse list, and update the browse.dat file */ + add_server_entry(d,work,name,server_type,ttl,comment,True); + updatedlists = True; +} + + +/******************************************************************* + process a LAN Manager announcement request +*******************************************************************/ + +static void process_lm_announce_request(struct packet_struct *p,char *buf) +{ + pstring comment; + uint32 server_type; + int announce_interval = lp_lm_announce(); + + + if (announce_interval <= 0) + { + DEBUG(3,("ignoring LM announcement request from %s\n",buf+2)); + /* The server is configured to not to send LM announcements */ + return; + } + + DEBUG(3,("responding to LM announcement request from %s\n",buf+2)); + + server_type = SV_TYPE_WORKSTATION|SV_TYPE_SERVER|SV_TYPE_TIME_SOURCE; + /* JdL: if it's a domain controller for Windows clients, is it also one + for OS/2 clients? */ + if (lp_domain_logons()) server_type |= SV_TYPE_DOMAIN_CTRL; + + StrnCpy(comment, lp_serverstring(), 43); + + do_announce_lm_host(myname,0x00,*iface_ip(p->ip), + lp_workgroup(),0x00,p->ip, + announce_interval,myname,server_type, + comment); +} + + +/**************************************************************************** + process a LAN Manager browse frame + **************************************************************************/ + +void process_lanman_packet(struct packet_struct *p,char *buf,int len) +{ + int code = SVAL(buf,0); + switch( code ) + { + case ANN_HostAnnouncement: + { + debug_browse_data(buf, len); + process_lm_announce(p, ANN_HostAnnouncement, buf); + break; + } + + case ANN_AnnouncementRequest: + { + debug_browse_data(buf, len); + process_lm_announce_request(p, buf); + break; + } + + default: + { + struct dgram_packet *dgram = &p->packet.dgram; + DEBUG(4,("ignoring LM browse packet %d from %s %s to %s\n", + code, namestr(&dgram->source_name), + inet_ntoa(p->ip), namestr(&dgram->dest_name))); + } + } +} --- namepacket.c.orig Mon Apr 14 17:45:38 1997 +++ namepacket.c Mon Apr 14 17:46:52 1997 @@ -378,6 +378,13 @@ process_logon_packet(p,buf2,len); return; } + + /* datagram packet received for the LAN Manager (OS/2) mailslot */ + if (strequal(smb_buf(buf),LANMAN_MAILSLOT)) { + process_lanman_packet(p,buf2,len); + return; + } + } /**************************************************************************** --- nmbd.c.orig Mon Apr 14 17:54:36 1997 +++ nmbd.c Mon Apr 14 23:52:37 1997 @@ -305,6 +305,8 @@ announce_remote(t); + announce_lm_server(t); + query_refresh_names(t); expire_names_and_servers(t);