void tell_become_backup | ( | void | ) |
nmbd_incomingdgrams.c の 40 行で定義されています。
参照先 subnet_record::bcast_ip・is_myname()・server_info_struct::name・server_record::next・work_record::next・server_record::serv・server_info_struct::type・subnet_record::workgrouplist.
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 /* make first server a backup server. thereafter make every 00075 tenth server a backup server */ 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 /* type 11 request from MYNAME(20) to WG(1e) for SERVER */ 00084 do_announce_request(servrec->serv.name, work->work_group, 00085 ANN_BecomeBackup, 0x20, 0x1e, subrec->bcast_ip); 00086 } 00087 } 00088 } 00089 }
void process_host_announce | ( | struct subnet_record * | subrec, | |
struct packet_struct * | p, | |||
char * | buf | |||
) |
nmbd_incomingdgrams.c の 96 行で定義されています。
参照先 server_info_struct::comment・create_server_on_workgroup()・create_workgroup_on_subnet()・dgram_packet::dest_name・packet_struct::dgram・find_server_in_workgroup()・find_workgroup_on_subnet()・global_myname・packet_struct::ip・is_myname()・lp_workgroup()・nmb_name::name・nmb_name::name_type・nmb_namestr()・packet_struct::packet・pull_ascii_fstring()・pull_ascii_nstring()・remove_server_from_workgroup()・server_record::serv・dgram_packet::source_name・strequal()・server_info_struct::type・update_server_ttl()・subnet_record::work_changed.
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 /* Filter servertype to remove impossible bits. */ 00123 servertype &= ~(SV_TYPE_LOCAL_LIST_ONLY|SV_TYPE_DOMAIN_ENUM); 00124 00125 /* A host announcement must be sent to the name WORKGROUP<1d>. */ 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 /* Change it so it was. */ 00131 dgram->dest_name.name_type = 0x1d; 00132 } 00133 00134 /* For a host announce the workgroup name is the destination name. */ 00135 pull_ascii_nstring(work_name, sizeof(work_name), dgram->dest_name.name); 00136 00137 /* 00138 * Syntax servers version 5.1 send HostAnnounce packets to 00139 * *THE WRONG NAME*. They send to LOCAL_MASTER_BROWSER_NAME<00> 00140 * instead of WORKGROUP<1d> name. So to fix this we check if 00141 * the workgroup name is our own name, and if so change it 00142 * to be our primary workgroup name. 00143 */ 00144 00145 if(strequal(work_name, global_myname())) 00146 unstrcpy(work_name,lp_workgroup()); 00147 00148 /* 00149 * We are being very agressive here in adding a workgroup 00150 * name on the basis of a host announcing itself as being 00151 * in that workgroup. Maybe we should wait for the workgroup 00152 * announce instead ? JRA. 00153 */ 00154 00155 work = find_workgroup_on_subnet(subrec, work_name); 00156 00157 if(servertype != 0) { 00158 if (work ==NULL ) { 00159 /* We have no record of this workgroup. Add it. */ 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 /* If this server is not already in the workgroup, add it. */ 00166 create_server_on_workgroup(work, announce_name, 00167 servertype|SV_TYPE_LOCAL_LIST_ONLY, 00168 ttl, comment); 00169 } else { 00170 /* Update the record. */ 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 * This server is announcing it is going down. Remove it from the 00178 * workgroup. 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 }
void process_workgroup_announce | ( | struct subnet_record * | subrec, | |
struct packet_struct * | p, | |||
char * | buf | |||
) |
nmbd_incomingdgrams.c の 196 行で定義されています。
参照先 create_workgroup_on_subnet()・dgram_packet::dest_name・packet_struct::dgram・find_workgroup_on_subnet()・packet_struct::ip・work_record::local_master_browser_name・nmb_name::name・nmb_name::name_type・nmb_namestr()・packet_struct::packet・pull_ascii_nstring()・set_workgroup_local_master_browser_name()・dgram_packet::source_name・strequal()・update_workgroup_ttl()・subnet_record::work_changed.
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 /* Workgroup announcements must only go to the MSBROWSE name. */ 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 /* We have no record of this workgroup. Add it. */ 00230 if((work = create_workgroup_on_subnet(subrec, workgroup_announce_name, ttl))==NULL) 00231 goto done; 00232 } else { 00233 /* Update the workgroup death_time. */ 00234 update_workgroup_ttl(work, ttl); 00235 } 00236 00237 if(*work->local_master_browser_name == '\0') { 00238 /* Set the master browser name. */ 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 }
void process_local_master_announce | ( | struct subnet_record * | subrec, | |
struct packet_struct * | p, | |||
char * | buf | |||
) |
nmbd_incomingdgrams.c の 253 行で定義されています。
参照先 server_info_struct::comment・create_server_on_workgroup()・create_workgroup_on_subnet()・dgram_packet::dest_name・packet_struct::dgram・find_server_in_workgroup()・find_workgroup_on_subnet()・packet_struct::ip・is_myname()・nmb_name::name・nmb_name::name_type・nmb_namestr()・packet_struct::packet・pull_ascii_fstring()・pull_ascii_nstring()・remove_server_from_workgroup()・send_browser_reset()・server_record::serv・set_workgroup_local_master_browser_name()・dgram_packet::source_name・server_info_struct::type・unbecome_local_master_browser()・update_server_ttl()・subnet_record::work_changed.
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 /* A local master announcement must be sent to the name WORKGROUP<1e>. */ 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 /* Filter servertype to remove impossible bits. */ 00288 servertype &= ~(SV_TYPE_LOCAL_LIST_ONLY|SV_TYPE_DOMAIN_ENUM); 00289 00290 /* For a local master announce the workgroup name is the destination name. */ 00291 00292 if ((work = find_workgroup_on_subnet(subrec, work_name))==NULL) { 00293 /* Don't bother adding if it's a local master release announce. */ 00294 if(servertype == 0) 00295 goto done; 00296 00297 /* We have no record of this workgroup. Add it. */ 00298 if((work = create_workgroup_on_subnet(subrec, work_name, ttl))==NULL) 00299 goto done; 00300 } 00301 00302 /* If we think we're the local master browser for this workgroup, 00303 we should never have got this packet. We don't see our own 00304 packets. 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 /* Samba nmbd versions 1.9.17 to 1.9.17p4 have a bug in that when 00312 they have become a local master browser once, they will never 00313 stop sending local master announcements. To fix this we send 00314 them a reset browser packet, with level 0x2 on the __SAMBA__ 00315 name that only they should be listening to. */ 00316 00317 send_browser_reset( 0x2, "__SAMBA__" , 0x20, p->ip); 00318 00319 /* We should demote ourself and force an election. */ 00320 00321 unbecome_local_master_browser( subrec, work, True); 00322 00323 /* The actual election requests are handled in nmbd_election.c */ 00324 goto done; 00325 } 00326 00327 /* Find the server record on this workgroup. If it doesn't exist, add it. */ 00328 00329 if(servertype != 0) { 00330 if((servrec = find_server_in_workgroup( work, server_name))==NULL) { 00331 /* If this server is not already in the workgroup, add it. */ 00332 create_server_on_workgroup(work, server_name, 00333 servertype|SV_TYPE_LOCAL_LIST_ONLY, 00334 ttl, comment); 00335 } else { 00336 /* Update the record. */ 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 * This server is announcing it is going down. Remove it from the 00346 * workgroup. 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 }
void process_master_browser_announce | ( | struct subnet_record * | subrec, | |
struct packet_struct * | p, | |||
char * | buf | |||
) |
nmbd_incomingdgrams.c の 367 行で定義されています。
参照先 create_browser_in_lmb_cache()・find_browser_in_lmb_cache()・find_workgroup_on_subnet()・packet_struct::ip・lp_workgroup()・pull_ascii_nstring()・subnet_record::subnet_name・update_browser_death_time()・work_record::work_group.
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 /* Add this host as a local master browser entry on the browse lists. 00400 This causes a sync request to be made to it at a later date. 00401 */ 00402 00403 if((browrec = find_browser_in_lmb_cache( local_master_name )) == NULL) { 00404 /* Add it. */ 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 }
void process_lm_host_announce | ( | struct subnet_record * | subrec, | |
struct packet_struct * | p, | |||
char * | buf, | |||
int | len | |||
) |
nmbd_incomingdgrams.c の 419 行で定義されています。
参照先 server_info_struct::comment・create_server_on_workgroup()・create_workgroup_on_subnet()・dgram_packet::dest_name・packet_struct::dgram・find_server_in_workgroup()・find_workgroup_on_subnet()・found_lm_clients・get_safe_str_ptr()・global_myname・packet_struct::ip・is_myname()・lp_workgroup()・nmb_name::name・nmb_name::name_type・nmb_namestr()・packet_struct::packet・pull_ascii()・pull_ascii_nstring()・remove_server_from_workgroup()・server_record::serv・skip_string()・dgram_packet::source_name・strequal()・server_info_struct::type・update_server_ttl()・subnet_record::work_changed.
00420 { 00421 struct dgram_packet *dgram = &p->packet.dgram; 00422 uint32 servertype = IVAL(buf,1); 00423 int osmajor=CVAL(buf,5); /* major version of node software */ 00424 int osminor=CVAL(buf,6); /* minor version of node software */ 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 /* For a LanMan host announce the workgroup name is the destination name. */ 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 /* Could have been from a Windows machine (with its LM Announce enabled), 00460 or a Samba server. Then don't disrupt the current browse list. */ 00461 goto done; 00462 } 00463 00464 /* Filter servertype to remove impossible bits. */ 00465 servertype &= ~(SV_TYPE_LOCAL_LIST_ONLY|SV_TYPE_DOMAIN_ENUM); 00466 00467 /* A LanMan host announcement must be sent to the name WORKGROUP<00>. */ 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 /* Change it so it was. */ 00473 dgram->dest_name.name_type = 0x00; 00474 } 00475 00476 /* 00477 * Syntax servers version 5.1 send HostAnnounce packets to 00478 * *THE WRONG NAME*. They send to LOCAL_MASTER_BROWSER_NAME<00> 00479 * instead of WORKGROUP<1d> name. So to fix this we check if 00480 * the workgroup name is our own name, and if so change it 00481 * to be our primary workgroup name. This code is probably 00482 * not needed in the LanMan announce code, but it won't hurt. 00483 */ 00484 00485 if(strequal(work_name, global_myname())) 00486 unstrcpy(work_name,lp_workgroup()); 00487 00488 /* 00489 * We are being very agressive here in adding a workgroup 00490 * name on the basis of a host announcing itself as being 00491 * in that workgroup. Maybe we should wait for the workgroup 00492 * announce instead ? JRA. 00493 */ 00494 00495 work = find_workgroup_on_subnet(subrec, work_name); 00496 00497 if(servertype != 0) { 00498 if (work == NULL) { 00499 /* We have no record of this workgroup. Add it. */ 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 /* If this server is not already in the workgroup, add it. */ 00506 create_server_on_workgroup(work, announce_name, 00507 servertype|SV_TYPE_LOCAL_LIST_ONLY, 00508 ttl, comment); 00509 } else { 00510 /* Update the record. */ 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 * This server is announcing it is going down. Remove it from the 00518 * workgroup. 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 }
static void send_backup_list_response | ( | struct subnet_record * | subrec, | |
struct work_record * | work, | |||
struct nmb_name * | send_to_name, | |||
unsigned char | max_number_requested, | |||
uint32 | token, | |||
struct in_addr | sendto_ip, | |||
int | port | |||
) | [static] |
nmbd_incomingdgrams.c の 538 行で定義されています。
参照先 global_myname・len・subnet_record::myip・myname・nmb_name::name・server_info_struct::name・server_record::next・nmb_namestr()・pull_ascii_nstring()・send_mailslot()・server_record::serv・work_record::serverlist・skip_string()・strnequal()・strupper_m()・server_info_struct::type・work_record::work_group.
参照元 process_get_backup_list_request().
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); /* Backup list response opcode. */ 00562 p++; 00563 00564 countptr = p; 00565 p++; 00566 00567 SIVAL(p,0,token); /* The sender's unique info. */ 00568 p += 4; 00569 00570 /* We always return at least one name - our own. */ 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 /* Look for backup browsers in this workgroup. */ 00580 00581 #if 0 00582 /* we don't currently send become_backup requests so we should never 00583 send any other servers names out as backups for our 00584 workgroup. That's why this is commented out (tridge) */ 00585 00586 /* 00587 * NB. Note that the struct work_record here is not neccessarily 00588 * attached to the subnet *subrec. 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 }
void process_get_backup_list_request | ( | struct subnet_record * | subrec, | |
struct packet_struct * | p, | |||
char * | buf | |||
) |
nmbd_incomingdgrams.c の 641 行で定義されています。
参照先 dgram_packet::dest_name・packet_struct::dgram・find_workgroup_on_subnet()・packet_struct::ip・lp_workgroup()・nmb_name::name・nmb_name::name_type・name_type・nmb_namestr()・packet_struct::packet・packet_struct::port・pull_ascii_nstring()・send_backup_list_response()・dgram_packet::source_name・strequal()・subnet_record::subnet_name・work_record::token・unicast_subnet.
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); /* Sender's key index for the workgroup. */ 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 /* We have to be a master browser, or a domain master browser 00660 for the requested workgroup. That means it must be our 00661 workgroup. */ 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 * If the packet was sent to WORKGROUP<1b> instead 00677 * of WORKGROUP<1d> then it was unicast to us a domain master 00678 * browser. Change search subrec to unicast. 00679 */ 00680 00681 if(name_type == 0x1b) { 00682 /* We must be a domain master browser in order to 00683 process this packet. */ 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 /* We must be a local master browser in order to process this packet. */ 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 }
void process_reset_browser | ( | struct subnet_record * | subrec, | |
struct packet_struct * | p, | |||
char * | buf | |||
) |
nmbd_incomingdgrams.c の 724 行で定義されています。
参照先 packet_struct::dgram・expire_workgroups_and_servers()・packet_struct::ip・work_record::next・nmb_namestr()・packet_struct::packet・dgram_packet::source_name・unbecome_local_master_browser()・subnet_record::workgrouplist.
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 /* Stop being a local master browser on all our broadcast subnets. */ 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 /* Discard our browse lists. */ 00749 if (state & 0x2) { 00750 /* 00751 * Calling expire_workgroups_and_servers with a -1 00752 * time causes all servers not marked with a PERMANENT_TTL 00753 * on the workgroup lists to be discarded, and all 00754 * workgroups with empty server lists to be discarded. 00755 * This means we keep our own server names and workgroup 00756 * as these have a PERMANENT_TTL. 00757 */ 00758 00759 expire_workgroups_and_servers(-1); 00760 } 00761 00762 /* Request to stop browsing altogether. */ 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 }
void process_announce_request | ( | struct subnet_record * | subrec, | |
struct packet_struct * | p, | |||
char * | buf | |||
) |
nmbd_incomingdgrams.c の 777 行で定義されています。
参照先 dgram_packet::dest_name・packet_struct::dgram・find_workgroup_on_subnet()・packet_struct::ip・lp_workgroup()・nmb_name::name・work_record::needannounce・nmb_namestr()・packet_struct::packet・pull_ascii_nstring()・dgram_packet::source_name・strequal().
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 /* We only send announcement requests on our workgroup. */ 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 }
void process_lm_announce_request | ( | struct subnet_record * | subrec, | |
struct packet_struct * | p, | |||
char * | buf, | |||
int | len | |||
) |
nmbd_incomingdgrams.c の 818 行で定義されています。
参照先 dgram_packet::dest_name・packet_struct::dgram・find_workgroup_on_subnet()・found_lm_clients・packet_struct::ip・lp_workgroup()・nmb_name::name・nmb_namestr()・packet_struct::packet・pull_ascii_nstring()・dgram_packet::source_name・strequal().
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 /* We only send announcement requests on our workgroup. */ 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 }