static void send_election_dgram(struct subnet_record *subrec, const char *workgroup_name, uint32 criterion, int timeup,const char *server_name) { pstring outbuf; unstring srv_name; char *p; DEBUG(2,("send_election_dgram: Sending election packet for workgroup %s on subnet %s\n", workgroup_name, subrec->subnet_name )); memset(outbuf,'\0',sizeof(outbuf)); p = outbuf; SCVAL(p,0,ANN_Election); /* Election opcode. */ p++; SCVAL(p,0,((criterion == 0 && timeup == 0) ? 0 : ELECTION_VERSION)); SIVAL(p,1,criterion); SIVAL(p,5,timeup*1000); /* ms - Despite what the spec says. */ p += 13; unstrcpy(srv_name, server_name); strupper_m(srv_name); /* The following call does UNIX -> DOS charset conversion. */ pstrcpy_base(p, srv_name, outbuf); p = skip_string(p,1); send_mailslot(False, BROWSE_MAILSLOT, outbuf, PTR_DIFF(p,outbuf), global_myname(), 0, workgroup_name, 0x1e, subrec->bcast_ip, subrec->myip, DGRAM_PORT); }
static void send_announcement(struct subnet_record *subrec, int announce_type, const char *from_name, const char *to_name, int to_type, struct in_addr to_ip, time_t announce_interval, const char *server_name, int server_type, const char *server_comment) { pstring outbuf; char *p; memset(outbuf,'\0',sizeof(outbuf)); p = outbuf+1; SCVAL(outbuf,0,announce_type); /* Announcement parameters. */ SCVAL(p,0,updatecount); SIVAL(p,1,announce_interval*1000); /* Milliseconds - despite the spec. */ push_string(NULL, p+5, server_name, 15, STR_ASCII|STR_UPPER|STR_TERMINATE); SCVAL(p,21,lp_major_announce_version()); /* Major version. */ SCVAL(p,22,lp_minor_announce_version()); /* Minor version. */ SIVAL(p,23,server_type & ~SV_TYPE_LOCAL_LIST_ONLY); /* Browse version: got from NT/AS 4.00 - Value defined in smb.h (JHT). */ SSVAL(p,27,BROWSER_ELECTION_VERSION); SSVAL(p,29,BROWSER_CONSTANT); /* Browse signature. */ p += 31 + push_string(NULL, p+31, server_comment, -1, STR_ASCII|STR_TERMINATE); send_mailslot(False,BROWSE_MAILSLOT, outbuf, PTR_DIFF(p,outbuf), from_name, 0x0, to_name, to_type, to_ip, subrec->myip, DGRAM_PORT); }
static void send_election_dgram(struct subnet_record *subrec, const char *workgroup_name, uint32_t criterion, int timeup,const char *server_name) { char outbuf[1024]; unstring srv_name; char *p; DEBUG(2,("send_election_dgram: Sending election packet for workgroup %s on subnet %s\n", workgroup_name, subrec->subnet_name )); memset(outbuf,'\0',sizeof(outbuf)); p = outbuf; SCVAL(p,0,ANN_Election); /* Election opcode. */ p++; SCVAL(p,0,((criterion == 0 && timeup == 0) ? 0 : ELECTION_VERSION)); SIVAL(p,1,criterion); SIVAL(p,5,timeup*1000); /* ms - Despite what the spec says. */ p += 13; unstrcpy(srv_name, server_name); if (!strupper_m(srv_name)) { DEBUG(2,("strupper_m failed for %s\n", srv_name)); return; } /* The following call does UNIX -> DOS charset conversion. */ push_ascii(p, srv_name, sizeof(outbuf)-PTR_DIFF(p,outbuf)-1, STR_TERMINATE); p = skip_string(outbuf,sizeof(outbuf),p); send_mailslot(False, BROWSE_MAILSLOT, outbuf, PTR_DIFF(p,outbuf), lp_netbios_name(), 0, workgroup_name, 0x1e, subrec->bcast_ip, subrec->myip, DGRAM_PORT); }
void broadcast_announce_request(struct subnet_record *subrec, struct work_record *work) { pstring outbuf; char *p; work->needannounce = True; DEBUG(3,("broadcast_announce_request: sending announce request for workgroup %s \ to subnet %s\n", work->work_group, subrec->subnet_name)); memset(outbuf,'\0',sizeof(outbuf)); p = outbuf; SCVAL(p,0,ANN_AnnouncementRequest); p++; SCVAL(p,0,work->token); /* (local) Unique workgroup token id. */ p++; StrnCpy(p,global_myname,15); strupper(p); p = skip_string(p,1); send_mailslot(False, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf), global_myname, 0x0, work->work_group,0x1e, subrec->bcast_ip, subrec->myip, DGRAM_PORT); }
static void send_lm_announcement(struct subnet_record *subrec, int announce_type, char *from_name, 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; memset(outbuf,'\0',sizeof(outbuf)); SSVAL(p,0,announce_type); SIVAL(p,2,server_type & ~SV_TYPE_LOCAL_LIST_ONLY); SCVAL(p,6,lp_major_announce_version()); /* Major version. */ SCVAL(p,7,lp_minor_announce_version()); /* Minor version. */ SSVAL(p,8,announce_interval); /* In seconds - according to spec. */ p += 10; StrnCpy(p,server_name,15); strupper(p); p = skip_string(p,1); pstrcpy(p,server_comment); p = skip_string(p,1); send_mailslot(False,LANMAN_MAILSLOT, outbuf, PTR_DIFF(p,outbuf), from_name, 0x0, to_name, to_type, to_ip, subrec->myip, DGRAM_PORT); }
static void announce_local_master_browser_to_domain_master_browser( struct work_record *work) { char outbuf[1024]; unstring myname; unstring dmb_name; char *p; if(ismyip_v4(work->dmb_addr)) { if( DEBUGLVL( 2 ) ) { dbgtext( "announce_local_master_browser_to_domain_master_browser:\n" ); dbgtext( "We are both a domain and a local master browser for " ); dbgtext( "workgroup %s. ", work->work_group ); dbgtext( "Do not announce to ourselves.\n" ); } return; } memset(outbuf,'\0',sizeof(outbuf)); p = outbuf; SCVAL(p,0,ANN_MasterAnnouncement); p++; unstrcpy(myname, lp_netbios_name()); if (!strupper_m(myname)) { DEBUG(2,("strupper_m %s failed\n", myname)); return; } myname[15]='\0'; /* The call below does CH_UNIX -> CH_DOS conversion. JRA */ push_ascii(p, myname, sizeof(outbuf)-PTR_DIFF(p,outbuf)-1, STR_TERMINATE); p = skip_string(outbuf,sizeof(outbuf),p); if( DEBUGLVL( 4 ) ) { dbgtext( "announce_local_master_browser_to_domain_master_browser:\n" ); dbgtext( "Sending local master announce to " ); dbgtext( "%s for workgroup %s.\n", nmb_namestr(&work->dmb_name), work->work_group ); } /* Target name for send_mailslot must be in UNIX charset. */ pull_ascii_nstring(dmb_name, sizeof(dmb_name), work->dmb_name.name); send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf), lp_netbios_name(), 0x0, dmb_name, 0x0, work->dmb_addr, FIRST_SUBNET->myip, DGRAM_PORT); }
void send_browser_reset(int reset_type, const char *to_name, int to_type, struct in_addr to_ip) { char outbuf[1024]; char *p; DEBUG(3,("send_browser_reset: sending reset request type %d to %s<%02x> IP %s.\n", reset_type, to_name, to_type, inet_ntoa(to_ip) )); memset(outbuf,'\0',sizeof(outbuf)); p = outbuf; SCVAL(p,0,ANN_ResetBrowserState); p++; SCVAL(p,0,reset_type); p++; send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf), lp_netbios_name(), 0x0, to_name, to_type, to_ip, FIRST_SUBNET->myip, DGRAM_PORT); }
static void announce_local_master_browser_to_domain_master_browser( struct work_record *work) { pstring outbuf; char *p; if(ismyip(work->dmb_addr)) { if( DEBUGLVL( 2 ) ) { dbgtext( "announce_local_master_browser_to_domain_master_browser:\n" ); dbgtext( "We are both a domain and a local master browser for " ); dbgtext( "workgroup %s. ", work->work_group ); dbgtext( "Do not announce to ourselves.\n" ); } return; } memset(outbuf,'\0',sizeof(outbuf)); p = outbuf; SCVAL(p,0,ANN_MasterAnnouncement); p++; StrnCpy(p,global_myname,15); strupper(p); p = skip_string(p,1); if( DEBUGLVL( 4 ) ) { dbgtext( "announce_local_master_browser_to_domain_master_browser:\n" ); dbgtext( "Sending local master announce to " ); dbgtext( "%s for workgroup %s.\n", nmb_namestr(&work->dmb_name), work->work_group ); } send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf), global_myname, 0x0, work->dmb_name.name, 0x0, work->dmb_addr, FIRST_SUBNET->myip, DGRAM_PORT); }
static void send_announcement(struct subnet_record *subrec, int announce_type, const char *from_name, const char *to_name, int to_type, struct in_addr to_ip, time_t announce_interval, const char *server_name, int server_type, const char *server_comment) { char outbuf[1024]; unstring upper_server_name; char *p; memset(outbuf,'\0',sizeof(outbuf)); p = outbuf+1; SCVAL(outbuf,0,announce_type); /* Announcement parameters. */ SCVAL(p,0,updatecount); SIVAL(p,1,announce_interval*1000); /* Milliseconds - despite the spec. */ strlcpy(upper_server_name, server_name ? server_name : "", sizeof(upper_server_name)); if (!strupper_m(upper_server_name)) { DEBUG(2,("strupper_m %s failed\n", upper_server_name)); return; } push_string_check(p+5, upper_server_name, 16, STR_ASCII|STR_TERMINATE); SCVAL(p,21,SAMBA_MAJOR_NBT_ANNOUNCE_VERSION); /* Major version. */ SCVAL(p,22,SAMBA_MINOR_NBT_ANNOUNCE_VERSION); /* Minor version. */ SIVAL(p,23,server_type & ~SV_TYPE_LOCAL_LIST_ONLY); /* Browse version: got from NT/AS 4.00 - Value defined in smb.h (JHT). */ SSVAL(p,27,BROWSER_ELECTION_VERSION); SSVAL(p,29,BROWSER_CONSTANT); /* Browse signature. */ p += 31 + push_string_check(p+31, server_comment, sizeof(outbuf) - (p + 31 - outbuf), STR_ASCII|STR_TERMINATE); send_mailslot(False,BROWSE_MAILSLOT, outbuf, PTR_DIFF(p,outbuf), from_name, 0x0, to_name, to_type, to_ip, subrec->myip, DGRAM_PORT); }
void broadcast_announce_request(struct subnet_record *subrec, struct work_record *work) { char outbuf[1024]; char *p; work->needannounce = True; DEBUG(3,("broadcast_announce_request: sending announce request for workgroup %s \ to subnet %s\n", work->work_group, subrec->subnet_name)); memset(outbuf,'\0',sizeof(outbuf)); p = outbuf; SCVAL(p,0,ANN_AnnouncementRequest); p++; SCVAL(p,0,work->token); /* (local) Unique workgroup token id. */ p++; p += push_string_check(p+1, lp_netbios_name(), 15, STR_ASCII|STR_UPPER|STR_TERMINATE); send_mailslot(False, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf), lp_netbios_name(), 0x0, work->work_group,0x1e, subrec->bcast_ip, subrec->myip, DGRAM_PORT); }
static void send_lm_announcement(struct subnet_record *subrec, int announce_type, char *from_name, char *to_name, int to_type, struct in_addr to_ip, time_t announce_interval, char *server_name, int server_type, char *server_comment) { char outbuf[1024]; char *p=outbuf; memset(outbuf,'\0',sizeof(outbuf)); SSVAL(p,0,announce_type); SIVAL(p,2,server_type & ~SV_TYPE_LOCAL_LIST_ONLY); SCVAL(p,6,SAMBA_MAJOR_NBT_ANNOUNCE_VERSION); /* Major version. */ SCVAL(p,7,SAMBA_MINOR_NBT_ANNOUNCE_VERSION); /* Minor version. */ SSVAL(p,8,announce_interval); /* In seconds - according to spec. */ p += 10; p += push_string_check(p, server_name, 15, STR_ASCII|STR_UPPER|STR_TERMINATE); p += push_string_check(p, server_comment, sizeof(outbuf)- (p - outbuf), STR_ASCII|STR_UPPER|STR_TERMINATE); send_mailslot(False,LANMAN_MAILSLOT, outbuf, PTR_DIFF(p,outbuf), from_name, 0x0, to_name, to_type, to_ip, subrec->myip, DGRAM_PORT); }