2005-01-21 13:13:24 +00: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 02:07:03 +00:00
the Free Software Foundation ; either version 3 of the License , or
2005-01-21 13:13:24 +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-01-21 13:13:24 +00:00
*/
# include "includes.h"
2008-09-23 08:06:33 +02:00
# include "../libcli/nbt/libnbt.h"
2006-03-07 11:07:23 +00:00
# include "libcli/resolve/resolve.h"
2007-09-08 12:42:09 +00:00
# include "param/param.h"
2008-12-11 15:43:47 +01:00
# include "lib/socket/socket.h"
2007-12-13 22:46:44 +01:00
# include "lib/socket/netif.h"
2005-01-21 13:13:24 +00:00
2007-12-10 18:41:19 +01:00
struct resolve_wins_data {
const char * * address_list ;
2007-12-13 22:46:44 +01:00
struct interface * ifaces ;
uint16_t nbt_port ;
2008-02-21 17:17:37 +01:00
int nbt_timeout ;
2007-12-10 18:41:19 +01:00
} ;
/**
2005-01-21 13:13:24 +00:00
wins name resolution method - async send
*/
2007-09-07 15:35:18 +00:00
struct composite_context * resolve_name_wins_send (
TALLOC_CTX * mem_ctx ,
2008-12-29 20:24:57 +01:00
struct tevent_context * event_ctx ,
2007-12-10 18:41:19 +01:00
void * userdata ,
2008-12-13 11:03:52 +01:00
uint32_t flags ,
2008-12-17 17:25:40 +01:00
uint16_t port ,
2007-09-07 15:35:18 +00:00
struct nbt_name * name )
2005-01-21 13:13:24 +00:00
{
2007-12-10 18:41:19 +01: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 17:25:40 +01:00
return resolve_name_nbtlist_send ( mem_ctx , event_ctx , flags , port , name ,
2008-12-13 11:03:52 +01:00
wins_data - > address_list , wins_data - > ifaces ,
wins_data - > nbt_port , wins_data - > nbt_timeout ,
false , true ) ;
2005-01-21 13:13:24 +00:00
}
/*
wins name resolution method - recv side
*/
2005-01-31 08:30:44 +00:00
NTSTATUS resolve_name_wins_recv ( struct composite_context * c ,
2008-12-11 15:43:47 +01:00
TALLOC_CTX * mem_ctx ,
2008-12-13 20:50:36 +01:00
struct socket_address * * * addrs ,
char * * * names )
2005-01-21 13:13:24 +00:00
{
2008-12-13 20:50:36 +01:00
return resolve_name_nbtlist_recv ( c , mem_ctx , addrs , names ) ;
2005-01-21 13:13:24 +00:00
}
2008-02-21 17:17:37 +01: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 18:41:19 +01:00
{
struct resolve_wins_data * wins_data = talloc ( ctx , struct resolve_wins_data ) ;
2008-10-12 00:56:56 +02:00
wins_data - > address_list = ( const char * * ) str_list_copy ( wins_data , address_list ) ;
2007-12-13 22:46:44 +01:00
wins_data - > ifaces = talloc_reference ( wins_data , ifaces ) ;
wins_data - > nbt_port = nbt_port ;
2008-02-21 17:17:37 +01:00
wins_data - > nbt_timeout = nbt_timeout ;
2007-12-10 18:41:19 +01:00
return resolve_context_add_method ( ctx , resolve_name_wins_send , resolve_name_wins_recv ,
wins_data ) ;
}
2007-12-13 22:46:44 +01: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 17:17:37 +01: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-13 22:46:44 +01:00
}