2005-01-21 16:13:24 +03:00
/*
Unix SMB / CIFS implementation .
wins name resolution module
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 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2005-01-21 16:13:24 +03: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 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2005-01-21 16:13:24 +03:00
*/
# include "includes.h"
2008-09-23 10:06:33 +04:00
# include "../libcli/nbt/libnbt.h"
2006-03-07 14:07:23 +03:00
# include "libcli/resolve/resolve.h"
2007-09-08 16:42:09 +04:00
# include "param/param.h"
2008-12-11 17:43:47 +03:00
# include "lib/socket/socket.h"
2007-12-14 00:46:44 +03:00
# include "lib/socket/netif.h"
2005-01-21 16:13:24 +03:00
2007-12-10 20:41:19 +03:00
struct resolve_wins_data {
const char * * address_list ;
2007-12-14 00:46:44 +03:00
struct interface * ifaces ;
uint16_t nbt_port ;
2008-02-21 19:17:37 +03:00
int nbt_timeout ;
2007-12-10 20:41:19 +03:00
} ;
/**
2005-01-21 16:13:24 +03:00
wins name resolution method - async send
*/
2007-09-07 19:35:18 +04:00
struct composite_context * resolve_name_wins_send (
TALLOC_CTX * mem_ctx ,
2008-12-29 22:24:57 +03:00
struct tevent_context * event_ctx ,
2007-12-10 20:41:19 +03:00
void * userdata ,
2008-12-13 13:03:52 +03:00
uint32_t flags ,
2008-12-17 19:25:40 +03:00
uint16_t port ,
2007-09-07 19:35:18 +04:00
struct nbt_name * name )
2005-01-21 16:13:24 +03:00
{
2007-12-10 20:41:19 +03:00
struct resolve_wins_data * wins_data = talloc_get_type ( userdata , struct resolve_wins_data ) ;
if ( wins_data - > address_list = = NULL ) return NULL ;
2008-12-17 19:25:40 +03:00
return resolve_name_nbtlist_send ( mem_ctx , event_ctx , flags , port , name ,
2008-12-13 13:03:52 +03:00
wins_data - > address_list , wins_data - > ifaces ,
wins_data - > nbt_port , wins_data - > nbt_timeout ,
false , true ) ;
2005-01-21 16:13:24 +03:00
}
/*
wins name resolution method - recv side
*/
2005-01-31 11:30:44 +03:00
NTSTATUS resolve_name_wins_recv ( struct composite_context * c ,
2008-12-11 17:43:47 +03:00
TALLOC_CTX * mem_ctx ,
2008-12-13 22:50:36 +03:00
struct socket_address * * * addrs ,
char * * * names )
2005-01-21 16:13:24 +03:00
{
2008-12-13 22:50:36 +03:00
return resolve_name_nbtlist_recv ( c , mem_ctx , addrs , names ) ;
2005-01-21 16:13:24 +03:00
}
2008-02-21 19:17:37 +03:00
bool resolve_context_add_wins_method ( struct resolve_context * ctx , const char * * address_list , struct interface * ifaces , uint16_t nbt_port , int nbt_timeout )
2007-12-10 20:41:19 +03:00
{
struct resolve_wins_data * wins_data = talloc ( ctx , struct resolve_wins_data ) ;
2008-10-12 02:56:56 +04:00
wins_data - > address_list = ( const char * * ) str_list_copy ( wins_data , address_list ) ;
2007-12-14 00:46:44 +03:00
wins_data - > ifaces = talloc_reference ( wins_data , ifaces ) ;
wins_data - > nbt_port = nbt_port ;
2008-02-21 19:17:37 +03:00
wins_data - > nbt_timeout = nbt_timeout ;
2007-12-10 20:41:19 +03:00
return resolve_context_add_method ( ctx , resolve_name_wins_send , resolve_name_wins_recv ,
wins_data ) ;
}
2007-12-14 00:46:44 +03:00
bool resolve_context_add_wins_method_lp ( struct resolve_context * ctx , struct loadparm_context * lp_ctx )
{
struct interface * ifaces ;
load_interfaces ( ctx , lp_interfaces ( lp_ctx ) , & ifaces ) ;
2008-02-21 19:17:37 +03:00
return resolve_context_add_wins_method ( ctx , lp_wins_server_list ( lp_ctx ) , ifaces , lp_nbt_port ( lp_ctx ) , lp_parm_int ( lp_ctx , NULL , " nbt " , " timeout " , 1 ) ) ;
2007-12-14 00:46:44 +03:00
}