2005-04-08 08:57:09 +00:00
/*
Unix SMB / CIFS implementation .
NBT datagram browse server
Copyright ( C ) Andrew Tridgell 2005
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
2007-07-10 02:07:03 +00:00
the Free Software Foundation ; either version 3 of the License , or
2005-04-08 08:57:09 +00:00
( 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
2007-07-10 02:07:03 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2005-04-08 08:57:09 +00:00
*/
# include "includes.h"
# include "nbt_server/nbt_server.h"
2006-01-09 22:12:53 +00:00
# include "lib/socket/socket.h"
2006-03-16 00:23:11 +00:00
# include "librpc/gen_ndr/ndr_nbt.h"
2008-10-20 18:59:51 +02:00
# include "nbt_server/dgram/proto.h"
2005-04-08 08:57:09 +00:00
2006-01-14 10:11:04 +00:00
static const char * nbt_browse_opcode_string ( enum nbt_browse_opcode r )
{
const char * val = NULL ;
switch ( r ) {
case HostAnnouncement : val = " HostAnnouncement " ; break ;
case AnnouncementRequest : val = " AnnouncementRequest " ; break ;
case Election : val = " Election " ; break ;
case GetBackupListReq : val = " GetBackupListReq " ; break ;
case GetBackupListResp : val = " GetBackupListResp " ; break ;
case BecomeBackup : val = " BecomeBackup " ; break ;
case DomainAnnouncement : val = " DomainAnnouncement " ; break ;
case MasterAnnouncement : val = " MasterAnnouncement " ; break ;
case ResetBrowserState : val = " ResetBrowserState " ; break ;
case LocalMasterAnnouncement : val = " LocalMasterAnnouncement " ; break ;
}
return val ;
}
2005-04-08 08:57:09 +00:00
/*
handle incoming browse mailslot requests
*/
void nbtd_mailslot_browse_handler ( struct dgram_mailslot_handler * dgmslot ,
struct nbt_dgram_packet * packet ,
2006-01-09 22:12:53 +00:00
struct socket_address * src )
2005-04-08 08:57:09 +00:00
{
2006-01-14 10:11:04 +00:00
struct nbt_browse_packet * browse = talloc ( dgmslot , struct nbt_browse_packet ) ;
struct nbt_name * name = & packet - > data . msg . dest_name ;
NTSTATUS status ;
2006-10-13 09:14:43 +00:00
if ( browse = = NULL ) {
status = NT_STATUS_INVALID_PARAMETER ;
goto failed ;
}
2006-01-14 10:11:04 +00:00
status = dgram_mailslot_browse_parse ( dgmslot , browse , packet , browse ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) goto failed ;
2010-11-08 16:02:21 +11:00
DEBUG ( 4 , ( " Browse %s (Op %d) on '%s' '%s' from %s:%d \n " ,
2006-01-14 10:11:04 +00:00
nbt_browse_opcode_string ( browse - > opcode ) , browse - > opcode ,
nbt_name_string ( browse , name ) , dgmslot - > mailslot_name ,
src - > addr , src - > port ) ) ;
if ( DEBUGLEVEL > = 10 ) {
NDR_PRINT_DEBUG ( nbt_browse_packet , browse ) ;
}
talloc_free ( browse ) ;
return ;
failed :
2006-03-03 08:01:09 +00:00
DEBUG ( 2 , ( " nbtd browse handler failed from %s:%d to %s - %s \n " ,
src - > addr , src - > port , nbt_name_string ( browse , name ) ,
nt_errstr ( status ) ) ) ;
2006-01-14 10:11:04 +00:00
talloc_free ( browse ) ;
2005-04-08 08:57:09 +00:00
}