00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "includes.h"
00025
00026 extern BOOL found_lm_clients;
00027
00028 #if 0
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 void tell_become_backup(void)
00041 {
00042 struct subnet_record *subrec;
00043 for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec))
00044 {
00045 struct work_record *work;
00046 for (work = subrec->workgrouplist; work; work = work->next)
00047 {
00048 struct server_record *servrec;
00049 int num_servers = 0;
00050 int num_backups = 0;
00051
00052 for (servrec = work->serverlist; servrec; servrec = servrec->next)
00053 {
00054 num_servers++;
00055
00056 if (is_myname(servrec->serv.name))
00057 continue;
00058
00059 if (servrec->serv.type & SV_TYPE_BACKUP_BROWSER)
00060 {
00061 num_backups++;
00062 continue;
00063 }
00064
00065 if (servrec->serv.type & SV_TYPE_MASTER_BROWSER)
00066 continue;
00067
00068 if (!(servrec->serv.type & SV_TYPE_POTENTIAL_BROWSER))
00069 continue;
00070
00071 DEBUG(3,("num servers: %d num backups: %d\n",
00072 num_servers, num_backups));
00073
00074
00075
00076 if (num_backups != 0 && (num_servers+9) / num_backups > 10)
00077 continue;
00078
00079 DEBUG(2,("sending become backup to %s %s for %s\n",
00080 servrec->serv.name, inet_ntoa(subrec->bcast_ip),
00081 work->work_group));
00082
00083
00084 do_announce_request(servrec->serv.name, work->work_group,
00085 ANN_BecomeBackup, 0x20, 0x1e, subrec->bcast_ip);
00086 }
00087 }
00088 }
00089 }
00090 #endif
00091
00092
00093
00094
00095
00096 void process_host_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf)
00097 {
00098 struct dgram_packet *dgram = &p->packet.dgram;
00099 int ttl = IVAL(buf,1)/1000;
00100 unstring announce_name;
00101 uint32 servertype = IVAL(buf,23);
00102 fstring comment;
00103 struct work_record *work;
00104 struct server_record *servrec;
00105 unstring work_name;
00106 unstring source_name;
00107
00108 START_PROFILE(host_announce);
00109
00110 pull_ascii_fstring(comment, buf+31);
00111
00112 pull_ascii_nstring(announce_name, sizeof(announce_name), buf+5);
00113 pull_ascii_nstring(source_name, sizeof(source_name), dgram->source_name.name);
00114
00115 DEBUG(3,("process_host_announce: from %s<%02x> IP %s to \
00116 %s for server %s.\n", source_name, source_name[15], inet_ntoa(p->ip),
00117 nmb_namestr(&dgram->dest_name),announce_name));
00118
00119 DEBUG(5,("process_host_announce: ttl=%d server type=%08x comment=%s\n",
00120 ttl, servertype,comment));
00121
00122
00123 servertype &= ~(SV_TYPE_LOCAL_LIST_ONLY|SV_TYPE_DOMAIN_ENUM);
00124
00125
00126 if(dgram->dest_name.name_type != 0x1d) {
00127 DEBUG(2,("process_host_announce: incorrect name type for destination from IP %s \
00128 (was %02x) should be 0x1d. Allowing packet anyway.\n",
00129 inet_ntoa(p->ip), dgram->dest_name.name_type));
00130
00131 dgram->dest_name.name_type = 0x1d;
00132 }
00133
00134
00135 pull_ascii_nstring(work_name, sizeof(work_name), dgram->dest_name.name);
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145 if(strequal(work_name, global_myname()))
00146 unstrcpy(work_name,lp_workgroup());
00147
00148
00149
00150
00151
00152
00153
00154
00155 work = find_workgroup_on_subnet(subrec, work_name);
00156
00157 if(servertype != 0) {
00158 if (work ==NULL ) {
00159
00160 if((work = create_workgroup_on_subnet(subrec, work_name, ttl))==NULL)
00161 goto done;
00162 }
00163
00164 if((servrec = find_server_in_workgroup( work, announce_name))==NULL) {
00165
00166 create_server_on_workgroup(work, announce_name,
00167 servertype|SV_TYPE_LOCAL_LIST_ONLY,
00168 ttl, comment);
00169 } else {
00170
00171 servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
00172 update_server_ttl( servrec, ttl);
00173 fstrcpy(servrec->serv.comment,comment);
00174 }
00175 } else {
00176
00177
00178
00179
00180 if(!is_myname(announce_name) && (work != NULL) &&
00181 ((servrec = find_server_in_workgroup( work, announce_name))!=NULL)) {
00182 remove_server_from_workgroup( work, servrec);
00183 }
00184 }
00185
00186 subrec->work_changed = True;
00187 done:
00188
00189 END_PROFILE(host_announce);
00190 }
00191
00192
00193
00194
00195
00196 void process_workgroup_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf)
00197 {
00198 struct dgram_packet *dgram = &p->packet.dgram;
00199 int ttl = IVAL(buf,1)/1000;
00200 unstring workgroup_announce_name;
00201 unstring master_name;
00202 uint32 servertype = IVAL(buf,23);
00203 struct work_record *work;
00204 unstring source_name;
00205 unstring dest_name;
00206
00207 START_PROFILE(workgroup_announce);
00208
00209 pull_ascii_nstring(workgroup_announce_name,sizeof(workgroup_announce_name),buf+5);
00210 pull_ascii_nstring(master_name,sizeof(master_name),buf+31);
00211 pull_ascii_nstring(source_name,sizeof(source_name),dgram->source_name.name);
00212 pull_ascii_nstring(dest_name,sizeof(dest_name),dgram->dest_name.name);
00213
00214 DEBUG(3,("process_workgroup_announce: from %s<%02x> IP %s to \
00215 %s for workgroup %s.\n", source_name, source_name[15], inet_ntoa(p->ip),
00216 nmb_namestr(&dgram->dest_name),workgroup_announce_name));
00217
00218 DEBUG(5,("process_workgroup_announce: ttl=%d server type=%08x master browser=%s\n",
00219 ttl, servertype, master_name));
00220
00221
00222 if (!strequal(dest_name, MSBROWSE) || (dgram->dest_name.name_type != 0x1)) {
00223 DEBUG(0,("process_workgroup_announce: from IP %s should be to __MSBROWSE__<0x01> not %s\n",
00224 inet_ntoa(p->ip), nmb_namestr(&dgram->dest_name)));
00225 goto done;
00226 }
00227
00228 if ((work = find_workgroup_on_subnet(subrec, workgroup_announce_name))==NULL) {
00229
00230 if((work = create_workgroup_on_subnet(subrec, workgroup_announce_name, ttl))==NULL)
00231 goto done;
00232 } else {
00233
00234 update_workgroup_ttl(work, ttl);
00235 }
00236
00237 if(*work->local_master_browser_name == '\0') {
00238
00239 set_workgroup_local_master_browser_name( work, master_name );
00240 }
00241
00242 subrec->work_changed = True;
00243
00244 done:
00245
00246 END_PROFILE(workgroup_announce);
00247 }
00248
00249
00250
00251
00252
00253 void process_local_master_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf)
00254 {
00255 struct dgram_packet *dgram = &p->packet.dgram;
00256 int ttl = IVAL(buf,1)/1000;
00257 unstring server_name;
00258 uint32 servertype = IVAL(buf,23);
00259 fstring comment;
00260 unstring work_name;
00261 struct work_record *work;
00262 struct server_record *servrec;
00263 unstring source_name;
00264
00265 START_PROFILE(local_master_announce);
00266
00267 pull_ascii_nstring(server_name,sizeof(server_name),buf+5);
00268 pull_ascii_fstring(comment, buf+31);
00269 pull_ascii_nstring(source_name, sizeof(source_name), dgram->source_name.name);
00270 pull_ascii_nstring(work_name, sizeof(work_name), dgram->dest_name.name);
00271
00272 DEBUG(3,("process_local_master_announce: from %s<%02x> IP %s to \
00273 %s for server %s.\n", source_name, source_name[15], inet_ntoa(p->ip),
00274 nmb_namestr(&dgram->dest_name),server_name));
00275
00276 DEBUG(5,("process_local_master_announce: ttl=%d server type=%08x comment=%s\n",
00277 ttl, servertype, comment));
00278
00279
00280 if(dgram->dest_name.name_type != 0x1e) {
00281 DEBUG(0,("process_local_master_announce: incorrect name type for destination from IP %s \
00282 (was %02x) should be 0x1e. Ignoring packet.\n",
00283 inet_ntoa(p->ip), dgram->dest_name.name_type));
00284 goto done;
00285 }
00286
00287
00288 servertype &= ~(SV_TYPE_LOCAL_LIST_ONLY|SV_TYPE_DOMAIN_ENUM);
00289
00290
00291
00292 if ((work = find_workgroup_on_subnet(subrec, work_name))==NULL) {
00293
00294 if(servertype == 0)
00295 goto done;
00296
00297
00298 if((work = create_workgroup_on_subnet(subrec, work_name, ttl))==NULL)
00299 goto done;
00300 }
00301
00302
00303
00304
00305
00306 if(AM_LOCAL_MASTER_BROWSER(work)) {
00307 DEBUG(0,("process_local_master_announce: Server %s at IP %s is announcing itself as \
00308 a local master browser for workgroup %s and we think we are master. Forcing election.\n",
00309 server_name, inet_ntoa(p->ip), work_name));
00310
00311
00312
00313
00314
00315
00316
00317 send_browser_reset( 0x2, "__SAMBA__" , 0x20, p->ip);
00318
00319
00320
00321 unbecome_local_master_browser( subrec, work, True);
00322
00323
00324 goto done;
00325 }
00326
00327
00328
00329 if(servertype != 0) {
00330 if((servrec = find_server_in_workgroup( work, server_name))==NULL) {
00331
00332 create_server_on_workgroup(work, server_name,
00333 servertype|SV_TYPE_LOCAL_LIST_ONLY,
00334 ttl, comment);
00335 } else {
00336
00337 servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
00338 update_server_ttl(servrec, ttl);
00339 fstrcpy(servrec->serv.comment,comment);
00340 }
00341
00342 set_workgroup_local_master_browser_name( work, server_name );
00343 } else {
00344
00345
00346
00347
00348 if(!is_myname(server_name) && (work != NULL) &&
00349 ((servrec = find_server_in_workgroup( work, server_name))!=NULL)) {
00350 remove_server_from_workgroup( work, servrec);
00351 }
00352 }
00353
00354 subrec->work_changed = True;
00355 done:
00356
00357 END_PROFILE(local_master_announce);
00358 }
00359
00360
00361
00362
00363
00364
00365
00366
00367 void process_master_browser_announce(struct subnet_record *subrec,
00368 struct packet_struct *p,char *buf)
00369 {
00370 unstring local_master_name;
00371 struct work_record *work;
00372 struct browse_cache_record *browrec;
00373
00374 START_PROFILE(master_browser_announce);
00375
00376 pull_ascii_nstring(local_master_name,sizeof(local_master_name),buf);
00377
00378 DEBUG(3,("process_master_browser_announce: Local master announce from %s IP %s.\n",
00379 local_master_name, inet_ntoa(p->ip)));
00380
00381 if (!lp_domain_master()) {
00382 DEBUG(0,("process_master_browser_announce: Not configured as domain \
00383 master - ignoring master announce.\n"));
00384 goto done;
00385 }
00386
00387 if((work = find_workgroup_on_subnet(subrec, lp_workgroup())) == NULL) {
00388 DEBUG(0,("process_master_browser_announce: Cannot find workgroup %s on subnet %s\n",
00389 lp_workgroup(), subrec->subnet_name));
00390 goto done;
00391 }
00392
00393 if(!AM_DOMAIN_MASTER_BROWSER(work)) {
00394 DEBUG(0,("process_master_browser_announce: Local master announce made to us from \
00395 %s IP %s and we are not a domain master browser.\n", local_master_name, inet_ntoa(p->ip)));
00396 goto done;
00397 }
00398
00399
00400
00401
00402
00403 if((browrec = find_browser_in_lmb_cache( local_master_name )) == NULL) {
00404
00405 create_browser_in_lmb_cache( work->work_group, local_master_name, p->ip);
00406 } else {
00407 update_browser_death_time(browrec);
00408 }
00409
00410 done:
00411
00412 END_PROFILE(master_browser_announce);
00413 }
00414
00415
00416
00417
00418
00419 void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf, int len)
00420 {
00421 struct dgram_packet *dgram = &p->packet.dgram;
00422 uint32 servertype = IVAL(buf,1);
00423 int osmajor=CVAL(buf,5);
00424 int osminor=CVAL(buf,6);
00425 int ttl = SVAL(buf,7);
00426 unstring announce_name;
00427 struct work_record *work;
00428 struct server_record *servrec;
00429 unstring work_name;
00430 unstring source_name;
00431 fstring comment;
00432 char *s = get_safe_str_ptr(buf,len,buf,9);
00433
00434 START_PROFILE(lm_host_announce);
00435 if (!s) {
00436 goto done;
00437 }
00438 s = skip_string(buf,len,s);
00439 if (!s) {
00440 goto done;
00441 }
00442 pull_ascii(comment, s, sizeof(fstring), 43, STR_TERMINATE);
00443
00444 pull_ascii_nstring(announce_name,sizeof(announce_name),buf+9);
00445 pull_ascii_nstring(source_name,sizeof(source_name),dgram->source_name.name);
00446
00447 pull_ascii_nstring(work_name,sizeof(work_name),dgram->dest_name.name);
00448
00449 DEBUG(3,("process_lm_host_announce: LM Announcement from %s IP %s to \
00450 %s for server %s.\n", nmb_namestr(&dgram->source_name), inet_ntoa(p->ip),
00451 nmb_namestr(&dgram->dest_name),announce_name));
00452
00453 DEBUG(5,("process_lm_host_announce: os=(%d,%d) ttl=%d server type=%08x comment=%s\n",
00454 osmajor, osminor, ttl, servertype,comment));
00455
00456 if ((osmajor < 36) || (osmajor > 38) || (osminor !=0)) {
00457 DEBUG(5,("process_lm_host_announce: LM Announcement packet does not \
00458 originate from OS/2 Warp client. Ignoring packet.\n"));
00459
00460
00461 goto done;
00462 }
00463
00464
00465 servertype &= ~(SV_TYPE_LOCAL_LIST_ONLY|SV_TYPE_DOMAIN_ENUM);
00466
00467
00468 if(dgram->dest_name.name_type != 0x00) {
00469 DEBUG(2,("process_lm_host_announce: incorrect name type for destination from IP %s \
00470 (was %02x) should be 0x00. Allowing packet anyway.\n",
00471 inet_ntoa(p->ip), dgram->dest_name.name_type));
00472
00473 dgram->dest_name.name_type = 0x00;
00474 }
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485 if(strequal(work_name, global_myname()))
00486 unstrcpy(work_name,lp_workgroup());
00487
00488
00489
00490
00491
00492
00493
00494
00495 work = find_workgroup_on_subnet(subrec, work_name);
00496
00497 if(servertype != 0) {
00498 if (work == NULL) {
00499
00500 if((work = create_workgroup_on_subnet(subrec, work_name, ttl))==NULL)
00501 goto done;
00502 }
00503
00504 if((servrec = find_server_in_workgroup( work, announce_name))==NULL) {
00505
00506 create_server_on_workgroup(work, announce_name,
00507 servertype|SV_TYPE_LOCAL_LIST_ONLY,
00508 ttl, comment);
00509 } else {
00510
00511 servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
00512 update_server_ttl( servrec, ttl);
00513 fstrcpy(servrec->serv.comment,comment);
00514 }
00515 } else {
00516
00517
00518
00519
00520 if(!is_myname(announce_name) && (work != NULL) &&
00521 ((servrec = find_server_in_workgroup( work, announce_name))!=NULL)) {
00522 remove_server_from_workgroup( work, servrec);
00523 }
00524 }
00525
00526 subrec->work_changed = True;
00527 found_lm_clients = True;
00528
00529 done:
00530
00531 END_PROFILE(lm_host_announce);
00532 }
00533
00534
00535
00536
00537
00538 static void send_backup_list_response(struct subnet_record *subrec,
00539 struct work_record *work,
00540 struct nmb_name *send_to_name,
00541 unsigned char max_number_requested,
00542 uint32 token, struct in_addr sendto_ip,
00543 int port)
00544 {
00545 char outbuf[1024];
00546 char *p, *countptr;
00547 unsigned int count = 0;
00548 unstring send_to_namestr;
00549 #if 0
00550 struct server_record *servrec;
00551 #endif
00552 unstring myname;
00553
00554 memset(outbuf,'\0',sizeof(outbuf));
00555
00556 DEBUG(3,("send_backup_list_response: sending backup list for workgroup %s to %s IP %s\n",
00557 work->work_group, nmb_namestr(send_to_name), inet_ntoa(sendto_ip)));
00558
00559 p = outbuf;
00560
00561 SCVAL(p,0,ANN_GetBackupListResp);
00562 p++;
00563
00564 countptr = p;
00565 p++;
00566
00567 SIVAL(p,0,token);
00568 p += 4;
00569
00570
00571 count = 1;
00572 unstrcpy(myname, global_myname());
00573 strupper_m(myname);
00574 myname[15]='\0';
00575 push_pstring_base(p, myname, outbuf);
00576
00577 p = skip_string(outbuf,sizeof(outbuf),p);
00578
00579
00580
00581 #if 0
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591 for (servrec = work->serverlist; servrec; servrec = servrec->next)
00592 {
00593 int len = PTR_DIFF(p, outbuf);
00594 if((sizeof(outbuf) - len) < 16)
00595 break;
00596
00597 if(count >= (unsigned int)max_number_requested)
00598 break;
00599
00600 if(strnequal(servrec->serv.name, global_myname(),15))
00601 continue;
00602
00603 if(!(servrec->serv.type & SV_TYPE_BACKUP_BROWSER))
00604 continue;
00605
00606 StrnCpy(p, servrec->serv.name, 15);
00607 strupper_m(p);
00608 count++;
00609
00610 DEBUG(5,("send_backup_list_response: Adding server %s number %d\n",
00611 p, count));
00612
00613 p = skip_string(outbuf,sizeof(outbuf),p);
00614 }
00615 #endif
00616
00617 SCVAL(countptr, 0, count);
00618
00619 pull_ascii_nstring(send_to_namestr, sizeof(send_to_namestr), send_to_name->name);
00620
00621 DEBUG(4,("send_backup_list_response: sending response to %s<00> IP %s with %d servers.\n",
00622 send_to_namestr, inet_ntoa(sendto_ip), count));
00623
00624 send_mailslot(True, BROWSE_MAILSLOT,
00625 outbuf,PTR_DIFF(p,outbuf),
00626 global_myname(), 0,
00627 send_to_namestr,0,
00628 sendto_ip, subrec->myip, port);
00629 }
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641 void process_get_backup_list_request(struct subnet_record *subrec,
00642 struct packet_struct *p,char *buf)
00643 {
00644 struct dgram_packet *dgram = &p->packet.dgram;
00645 struct work_record *work;
00646 unsigned char max_number_requested = CVAL(buf,0);
00647 uint32 token = IVAL(buf,1);
00648 int name_type = dgram->dest_name.name_type;
00649 unstring workgroup_name;
00650 struct subnet_record *search_subrec = subrec;
00651
00652 START_PROFILE(get_backup_list);
00653 pull_ascii_nstring(workgroup_name, sizeof(workgroup_name), dgram->dest_name.name);
00654
00655 DEBUG(3,("process_get_backup_list_request: request from %s IP %s to %s.\n",
00656 nmb_namestr(&dgram->source_name), inet_ntoa(p->ip),
00657 nmb_namestr(&dgram->dest_name)));
00658
00659
00660
00661
00662
00663 if(strequal(workgroup_name, lp_workgroup()) == False) {
00664 DEBUG(7,("process_get_backup_list_request: Ignoring announce request for workgroup %s.\n",
00665 workgroup_name));
00666 goto done;
00667 }
00668
00669 if((work = find_workgroup_on_subnet(search_subrec, workgroup_name)) == NULL) {
00670 DEBUG(0,("process_get_backup_list_request: Cannot find workgroup %s on \
00671 subnet %s.\n", workgroup_name, search_subrec->subnet_name));
00672 goto done;
00673 }
00674
00675
00676
00677
00678
00679
00680
00681 if(name_type == 0x1b) {
00682
00683
00684
00685 if(!AM_DOMAIN_MASTER_BROWSER(work)) {
00686 DEBUG(0,("process_get_backup_list_request: domain list requested for workgroup %s \
00687 and I am not a domain master browser.\n", workgroup_name));
00688 goto done;
00689 }
00690
00691 search_subrec = unicast_subnet;
00692 } else if (name_type == 0x1d) {
00693
00694
00695 if(!AM_LOCAL_MASTER_BROWSER(work)) {
00696 DEBUG(0,("process_get_backup_list_request: domain list requested for workgroup %s \
00697 and I am not a local master browser.\n", workgroup_name));
00698 goto done;
00699 }
00700 } else {
00701 DEBUG(0,("process_get_backup_list_request: Invalid name type %x - should be 0x1b or 0x1d.\n",
00702 name_type));
00703 goto done;
00704 }
00705
00706 send_backup_list_response(subrec, work, &dgram->source_name,
00707 max_number_requested, token, p->ip, p->port);
00708
00709 done:
00710
00711 END_PROFILE(get_backup_list);
00712 }
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724 void process_reset_browser(struct subnet_record *subrec,
00725 struct packet_struct *p,char *buf)
00726 {
00727 struct dgram_packet *dgram = &p->packet.dgram;
00728 int state = CVAL(buf,0);
00729 struct subnet_record *sr;
00730
00731 START_PROFILE(reset_browser);
00732
00733 DEBUG(1,("process_reset_browser: received diagnostic browser reset \
00734 request from %s IP %s state=0x%X\n",
00735 nmb_namestr(&dgram->source_name), inet_ntoa(p->ip), state));
00736
00737
00738 if (state & 0x1) {
00739 for (sr = FIRST_SUBNET; sr; sr = NEXT_SUBNET_EXCLUDING_UNICAST(sr)) {
00740 struct work_record *work;
00741 for (work = sr->workgrouplist; work; work = work->next) {
00742 if (AM_LOCAL_MASTER_BROWSER(work))
00743 unbecome_local_master_browser(sr, work, True);
00744 }
00745 }
00746 }
00747
00748
00749 if (state & 0x2) {
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759 expire_workgroups_and_servers(-1);
00760 }
00761
00762
00763 if (state & 0x4)
00764 DEBUG(1,("process_reset_browser: ignoring request to stop being a browser.\n"));
00765
00766 END_PROFILE(reset_browser);
00767 }
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777 void process_announce_request(struct subnet_record *subrec, struct packet_struct *p, char *buf)
00778 {
00779 struct dgram_packet *dgram = &p->packet.dgram;
00780 struct work_record *work;
00781 unstring workgroup_name;
00782
00783 START_PROFILE(announce_request);
00784
00785 pull_ascii_nstring(workgroup_name, sizeof(workgroup_name), dgram->dest_name.name);
00786 DEBUG(3,("process_announce_request: Announce request from %s IP %s to %s.\n",
00787 nmb_namestr(&dgram->source_name), inet_ntoa(p->ip),
00788 nmb_namestr(&dgram->dest_name)));
00789
00790
00791 if(strequal(workgroup_name, lp_workgroup()) == False) {
00792 DEBUG(7,("process_announce_request: Ignoring announce request for workgroup %s.\n",
00793 workgroup_name));
00794 goto done;
00795 }
00796
00797 if((work = find_workgroup_on_subnet(subrec, workgroup_name)) == NULL) {
00798 DEBUG(0,("process_announce_request: Unable to find workgroup %s on subnet !\n",
00799 workgroup_name));
00800 goto done;
00801 }
00802
00803 work->needannounce = True;
00804 done:
00805
00806 END_PROFILE(announce_request);
00807 }
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818 void process_lm_announce_request(struct subnet_record *subrec, struct packet_struct *p, char *buf, int len)
00819 {
00820 struct dgram_packet *dgram = &p->packet.dgram;
00821 unstring workgroup_name;
00822
00823 START_PROFILE(lm_announce_request);
00824
00825 pull_ascii_nstring(workgroup_name, sizeof(workgroup_name), dgram->dest_name.name);
00826 DEBUG(3,("process_lm_announce_request: Announce request from %s IP %s to %s.\n",
00827 nmb_namestr(&dgram->source_name), inet_ntoa(p->ip),
00828 nmb_namestr(&dgram->dest_name)));
00829
00830
00831 if(strequal(workgroup_name, lp_workgroup()) == False) {
00832 DEBUG(7,("process_lm_announce_request: Ignoring announce request for workgroup %s.\n",
00833 workgroup_name));
00834 goto done;
00835 }
00836
00837 if(find_workgroup_on_subnet(subrec, workgroup_name) == NULL) {
00838 DEBUG(0,("process_announce_request: Unable to find workgroup %s on subnet !\n",
00839 workgroup_name));
00840 goto done;
00841 }
00842
00843 found_lm_clients = True;
00844
00845 done:
00846
00847 END_PROFILE(lm_announce_request);
00848 }