summaryrefslogtreecommitdiff
path: root/source3/nameannounce.c
diff options
context:
space:
mode:
authorSamba Release Account <samba-bugs@samba.org>1996-06-29 18:49:20 +0000
committerSamba Release Account <samba-bugs@samba.org>1996-06-29 18:49:20 +0000
commited2639ebe21dde49af816a96ec6ea1e40f76e768 (patch)
tree969aa897016d8e4f29d846cf23c5fa832ae6cf58 /source3/nameannounce.c
parent851ee418b499df481b765286405cd761e91dcaaf (diff)
downloadsamba-ed2639ebe21dde49af816a96ec6ea1e40f76e768.tar.gz
samba-ed2639ebe21dde49af816a96ec6ea1e40f76e768.tar.bz2
samba-ed2639ebe21dde49af816a96ec6ea1e40f76e768.zip
luke's first attempt at using cvs
accidentally updated the Makefile updated the name database structure (again!). this time, there is one name database per local interface. there is also a pseudo-interface on ip 255.255.255.255. its purpose is to store WINS name entries. all the local interface name databases store SELF names only. the WINS name database stores non-special browser names. added wins.dat file: records WINS entries in ascii format. this is reloaded when nmbd restarts. added repeating code for response packets. timer is in seconds only at the moment. updated the response queue code to deal with samba registering with a WINS server a bit better (added more cases when a response isn't received). tidied up the response packet processing code and expire_response_queue() code. added cross references between response received and await-response expired code. added over-zealous code that checks all machines that register with samba as a WINS server (every 10 minutes i think): to see whether they are still alive or not (see rfc1001.txt) bug reported by terry@ren.pc.athabascau.ca: DNSFAILed names _stay_ as DNSFAIL, even though the machine may come back up and REGISTER. removed update_from_reg() function. it's not necessary, and it does too much. added code that announces on each local interface samba's ttl as zero and servertype as zero when nmbd is kill -TERMed first attempt at putting the first functionality of samba browsing back in (remote subnets should have samba appear in a workgroup specified through the lmhosts file) lots of other miscellaneous tidying up / chopping about. (This used to be commit 7e8c60cfe54060860e5ce20b1c3b8ec6aa5c54da)
Diffstat (limited to 'source3/nameannounce.c')
-rw-r--r--source3/nameannounce.c196
1 files changed, 107 insertions, 89 deletions
diff --git a/source3/nameannounce.c b/source3/nameannounce.c
index 9b0ef7067f..5163c4aea9 100644
--- a/source3/nameannounce.c
+++ b/source3/nameannounce.c
@@ -122,7 +122,8 @@ void announce_backup(void)
int tok;
if (!lastrun) lastrun = t;
- if (t < lastrun + CHECK_TIME_ANNOUNCE_BACKUP * 60) return;
+ if (t < lastrun + CHECK_TIME_ANNOUNCE_BACKUP * 60)
+ return;
lastrun = t;
for (tok = 0; tok <= workgroup_count; tok++)
@@ -179,19 +180,102 @@ void announce_backup(void)
/****************************************************************************
+ send a host announcement packet
+ **************************************************************************/
+void do_announce_host(int command,
+ char *from_name, int from_type, struct in_addr from_ip,
+ char *to_name , int to_type , struct in_addr to_ip,
+ int updatecount, time_t announce_interval,
+ char *server_name, int server_type, char *server_comment)
+{
+ pstring outbuf;
+ char *p;
+
+ bzero(outbuf,sizeof(outbuf));
+ p = outbuf+1;
+
+ /* command type */
+ CVAL(outbuf,0) = command;
+
+ /* announcement parameters */
+ CVAL(p,0) = updatecount;
+ SIVAL(p,1,announce_interval*1000); /* ms - despite the spec */
+
+ StrnCpy(p+5,server_name,16);
+ strupper(p+5);
+
+ CVAL(p,21) = 2; /* major version */
+ CVAL(p,22) = 2; /* minor version */
+
+ SIVAL(p,23,server_type);
+ SSVAL(p,27,0xaa55); /* browse signature */
+ SSVAL(p,29,1); /* browse version */
+
+ strcpy(p+31,server_comment);
+ p += 31;
+ p = skip_string(p,1);
+
+ /* send the announcement */
+ send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,
+ PTR_DIFF(p,outbuf),
+ from_name, to_name,
+ from_type, to_type,
+ to_ip, from_ip);
+}
+
+
+/****************************************************************************
+ announce a server entry
+ ****************************************************************************/
+void announce_server(struct subnet_record *d, struct work_record *work,
+ char *name, char *comment, time_t ttl, int server_type)
+{
+ if (AM_MASTER(work))
+ {
+ DEBUG(3,("sending local master announce to %s for %s(1e)\n",
+ inet_ntoa(d->bcast_ip),work->work_group));
+
+ do_announce_host(ANN_LocalMasterAnnouncement,
+ name , 0x00, d->myip,
+ work->work_group, 0x1e, d->bcast_ip,
+ updatecount, ttl*1000,
+ name, server_type, comment);
+
+ DEBUG(3,("sending domain announce to %s for %s\n",
+ inet_ntoa(d->bcast_ip),work->work_group));
+
+ /* XXXX should we do a domain-announce-kill? */
+ if (server_type != 0)
+ {
+ do_announce_host(ANN_DomainAnnouncement,
+ work->work_group, 0x00, d->myip,
+ MSBROWSE , 0x01, d->bcast_ip,
+ updatecount, ttl*1000,
+ name, server_type ? SV_TYPE_DOMAIN_ENUM : 0, comment);
+ }
+ }
+ else
+ {
+ DEBUG(3,("sending host announce to %s for %s(1d)\n",
+ inet_ntoa(d->bcast_ip),work->work_group));
+
+ do_announce_host(ANN_HostAnnouncement,
+ name , 0x00, d->myip,
+ work->work_group, 0x1d, d->bcast_ip,
+ updatecount, ttl*1000,
+ name, server_type, comment);
+ }
+}
+
+/****************************************************************************
construct a host announcement unicast
**************************************************************************/
void announce_host(void)
{
time_t t = time(NULL);
- pstring outbuf;
- char *p;
- char *namep;
- char *stypep;
- char *commentp;
+ struct subnet_record *d;
pstring comment;
char *my_name;
- struct subnet_record *d;
StrnCpy(comment, *ServerComment ? ServerComment : "NoComment", 43);
@@ -225,9 +309,6 @@ void announce_host(void)
work->lastannounce_time = t;
- /* when announcing to remote networks we make sure we don't
- claim to be any sort of special server, otherwise we may
- stuff up their browsing */
if (!d->my_interface) {
stype &= ~(SV_TYPE_POTENTIAL_BROWSER | SV_TYPE_MASTER_BROWSER |
SV_TYPE_DOMAIN_MASTER | SV_TYPE_BACKUP_BROWSER |
@@ -243,78 +324,15 @@ void announce_host(void)
if (announce)
{
- bzero(outbuf,sizeof(outbuf));
- p = outbuf+1;
-
- CVAL(p,0) = updatecount;
- /* ms - despite the spec */
- SIVAL(p,1,work->announce_interval*1000);
- namep = p+5;
- StrnCpy(namep,my_name,16);
- strupper(namep);
- CVAL(p,21) = 2; /* major version */
- CVAL(p,22) = 2; /* minor version */
- stypep = p+23;
- SIVAL(p,23,stype);
- SSVAL(p,27,0xaa55); /* browse signature */
- SSVAL(p,29,1); /* browse version */
- commentp = p+31;
- strcpy(commentp,comment);
- p = p+31;
- p = skip_string(p,1);
-
- if (d->my_interface && AM_MASTER(work))
- {
- SIVAL(stypep,0,work->ServerType);
-
- DEBUG(2,("sending local master announce to %s for %s\n",
- inet_ntoa(d->bcast_ip),work->work_group));
-
- CVAL(outbuf,0) = ANN_LocalMasterAnnouncement;
-
- send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,
- PTR_DIFF(p,outbuf),
- my_name,work->work_group,0,
- 0x1e,d->bcast_ip,
- *iface_ip(d->bcast_ip));
-
- DEBUG(2,("sending domain announce to %s for %s\n",
- inet_ntoa(d->bcast_ip),work->work_group));
-
- CVAL(outbuf,0) = ANN_DomainAnnouncement;
-
- StrnCpy(namep,work->work_group,15);
- strupper(namep);
- StrnCpy(commentp,myname,15);
- strupper(commentp);
-
- SIVAL(stypep,0,(unsigned)0x80000000);
- p = commentp + strlen(commentp) + 1;
-
- send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,
- PTR_DIFF(p,outbuf),
- my_name,MSBROWSE,0,0x01,d->bcast_ip,
- *iface_ip(d->bcast_ip));
- }
- else
- {
- DEBUG(2,("sending host announce to %s for %s\n",
- inet_ntoa(d->bcast_ip),work->work_group));
-
- CVAL(outbuf,0) = ANN_HostAnnouncement;
-
- send_mailslot_reply(BROWSE_MAILSLOT,ClientDGRAM,outbuf,
- PTR_DIFF(p,outbuf),
- my_name,work->work_group,0,0x1d,
- d->bcast_ip,*iface_ip(d->bcast_ip));
- }
+ announce_server(d,work,my_name,comment,work->announce_interval,stype);
}
- if (work->needannounce) {
- work->needannounce = False;
- break;
- /* sorry: can't do too many announces. do some more later */
- }
+ if (work->needannounce)
+ {
+ work->needannounce = False;
+ break;
+ /* sorry: can't do too many announces. do some more later */
+ }
}
}
}
@@ -328,7 +346,7 @@ void announce_host(void)
least 15 minutes.
this actually gets done in search_and_sync_workgroups() via the
- MASTER_SERVER_CHECK command, if there is a response from the
+ NAME_QUERY_MST_SRV_CHK command, if there is a response from the
name query initiated here. see response_name_query()
**************************************************************************/
void announce_master(void)
@@ -382,9 +400,9 @@ void announce_master(void)
struct in_addr ip;
ip = ipzero;
- queue_netbios_pkt_wins(ClientNMB,NMB_QUERY,
- MASTER_SERVER_CHECK,
- work->work_group,0x1b,0,
+ queue_netbios_pkt_wins(d,ClientNMB,NMB_QUERY,
+ NAME_QUERY_MST_SRV_CHK,
+ work->work_group,0x1b,0,0,
False, False, ip);
}
else
@@ -392,9 +410,9 @@ void announce_master(void)
struct subnet_record *d2;
for (d2 = subnetlist; d2; d2 = d2->next)
{
- queue_netbios_packet(ClientNMB,NMB_QUERY,
- MASTER_SERVER_CHECK,
- work->work_group,0x1b,0,
+ queue_netbios_packet(d,ClientNMB,NMB_QUERY,
+ NAME_QUERY_MST_SRV_CHK,
+ work->work_group,0x1b,0,0,
True, False, d2->bcast_ip);
}
}
@@ -427,8 +445,8 @@ void announce_master(void)
/* check the existence of a pdc for this workgroup, and if
one exists at the specified ip, sync with it and announce
ourselves as a master browser to it */
- queue_netbios_pkt_wins(ClientNMB, NMB_QUERY,MASTER_SERVER_CHECK,
- work->work_group,0x1b, 0,
+ queue_netbios_pkt_wins(d,ClientNMB, NMB_QUERY,NAME_QUERY_MST_SRV_CHK,
+ work->work_group,0x1b, 0, 0,
bcast, False, ip);
}
}